agent-tower 0.7.0-beta.2 → 0.7.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/runtime/__tests__/acp-driver-lifecycle.test.js +295 -1
  2. package/dist/runtime/__tests__/acp-driver-lifecycle.test.js.map +1 -1
  3. package/dist/runtime/acp/acp-driver.d.ts.map +1 -1
  4. package/dist/runtime/acp/acp-driver.js +152 -3
  5. package/dist/runtime/acp/acp-driver.js.map +1 -1
  6. package/dist/services/__tests__/conversation.service.test.js +126 -0
  7. package/dist/services/__tests__/conversation.service.test.js.map +1 -1
  8. package/dist/services/session-manager.d.ts.map +1 -1
  9. package/dist/services/session-manager.js +48 -1
  10. package/dist/services/session-manager.js.map +1 -1
  11. package/dist/web/assets/AgentDemoPage-Bz3RnDCN.js +1 -0
  12. package/dist/web/assets/{AgentEnvironmentSettingsPage-B571SLF5.js → AgentEnvironmentSettingsPage-CDWsry49.js} +1 -1
  13. package/dist/web/assets/{AgentLogo-VGcaaJum.js → AgentLogo-CRz3CfP5.js} +1 -1
  14. package/dist/web/assets/ConversationPage-U5VIw8hs.js +3 -0
  15. package/dist/web/assets/{CreateTaskInput-kkWy5nmc.js → CreateTaskInput-CX7_o02E.js} +1 -1
  16. package/dist/web/assets/{DemoPage-CpMV8Rv7.js → DemoPage-DwoVTSFm.js} +3 -3
  17. package/dist/web/assets/{GeneralSettingsPage-BvME4SJc.js → GeneralSettingsPage-CH7NW0Q1.js} +1 -1
  18. package/dist/web/assets/{Icons-DXzgw2xT.js → Icons-BsJUZk4z.js} +1 -1
  19. package/dist/web/assets/{LoadingPreviewPage-D6OzaV9-.js → LoadingPreviewPage-sN12whUD.js} +1 -1
  20. package/dist/web/assets/{McpSettingsPage-CCWuZ-IU.js → McpSettingsPage-D6dQVSij.js} +1 -1
  21. package/dist/web/assets/{MemberAvatar-DeKYSBH9.js → MemberAvatar-0z2Vg7fM.js} +1 -1
  22. package/dist/web/assets/{NotificationSettingsPage-BOhJqIXv.js → NotificationSettingsPage-Zzsus8n0.js} +1 -1
  23. package/dist/web/assets/ProfileSettingsPage-Ck5bJV8U.js +3 -0
  24. package/dist/web/assets/{ProjectKanbanPage-Ka243_RU.js → ProjectKanbanPage-Dy1q4F4o.js} +31 -31
  25. package/dist/web/assets/ProjectSettingsPage-CG599xXR.js +2 -0
  26. package/dist/web/assets/{ProviderSettingsPage-BCXTXcbc.js → ProviderSettingsPage-DI8pXhJO.js} +2 -2
  27. package/dist/web/assets/SettingsMasterDetail-BgUcVoVU.js +1 -0
  28. package/dist/web/assets/TeamSettingsPage-CQYgBktd.js +1 -0
  29. package/dist/web/assets/{arc-Bl7tPfS7.js → arc-C0TZ2Mr-.js} +1 -1
  30. package/dist/web/assets/{architectureDiagram-3BPJPVTR-CoP7qomY.js → architectureDiagram-3BPJPVTR-BfAyZiaB.js} +1 -1
  31. package/dist/web/assets/{blockDiagram-GPEHLZMM-Dyj3wCtX.js → blockDiagram-GPEHLZMM-Bw4bLBtW.js} +1 -1
  32. package/dist/web/assets/{c4Diagram-AAUBKEIU-BHpYwHH5.js → c4Diagram-AAUBKEIU-DJxag49S.js} +1 -1
  33. package/dist/web/assets/channel-Rd2UMQwz.js +1 -0
  34. package/dist/web/assets/check-BVfJOKK5.js +1 -0
  35. package/dist/web/assets/{chevron-down-B8PIP1yU.js → chevron-down-gt857XmZ.js} +1 -1
  36. package/dist/web/assets/{chevron-right-h-JkCAHM.js → chevron-right-Dn5EL2Lm.js} +1 -1
  37. package/dist/web/assets/{chevron-up-C5SQd6qy.js → chevron-up-Dv5ThQH5.js} +1 -1
  38. package/dist/web/assets/{chunk-2J33WTMH--mm3IA_q.js → chunk-2J33WTMH-71tuZDDX.js} +1 -1
  39. package/dist/web/assets/{chunk-4BX2VUAB-DSTjg6vT.js → chunk-4BX2VUAB-CJ5SCvua.js} +1 -1
  40. package/dist/web/assets/{chunk-55IACEB6-BMI8DRl6.js → chunk-55IACEB6-D3qUQw2o.js} +1 -1
  41. package/dist/web/assets/{chunk-727SXJPM-DB6yt8nI.js → chunk-727SXJPM-e-4CtmqG.js} +1 -1
  42. package/dist/web/assets/{chunk-AQP2D5EJ-BMFO2BIQ.js → chunk-AQP2D5EJ-bktXIBYA.js} +1 -1
  43. package/dist/web/assets/{chunk-FMBD7UC4-BWW53Tgv.js → chunk-FMBD7UC4--QBxBR_l.js} +1 -1
  44. package/dist/web/assets/{chunk-ND2GUHAM-3Q1rz4Rn.js → chunk-ND2GUHAM-D6p_CtQB.js} +1 -1
  45. package/dist/web/assets/{chunk-QZHKN3VN-DHZfBhTv.js → chunk-QZHKN3VN-DxmZnnse.js} +1 -1
  46. package/dist/web/assets/{circle-alert-B2WJJFVc.js → circle-alert-BeGGmA-3.js} +1 -1
  47. package/dist/web/assets/classDiagram-4FO5ZUOK-Dv78yDSv.js +1 -0
  48. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-Dv78yDSv.js +1 -0
  49. package/dist/web/assets/{code-block-OCS4YCEC-DAvNvPo_.js → code-block-OCS4YCEC-1KMwkqn9.js} +1 -1
  50. package/dist/web/assets/{confirm-dialog-59aNupkb.js → confirm-dialog-CMtca90c.js} +1 -1
  51. package/dist/web/assets/{cose-bilkent-S5V4N54A-BkBXPAOW.js → cose-bilkent-S5V4N54A-CKIKijp7.js} +1 -1
  52. package/dist/web/assets/cssMode-D8Dg9C1q.js +1 -0
  53. package/dist/web/assets/{dagre-BM42HDAG-0o3tAN58.js → dagre-BM42HDAG-jag-rU-a.js} +1 -1
  54. package/dist/web/assets/{diagram-2AECGRRQ-BaozWVAC.js → diagram-2AECGRRQ-DlSUMPBb.js} +1 -1
  55. package/dist/web/assets/{diagram-5GNKFQAL-BQGxsEX-.js → diagram-5GNKFQAL-gJzBEa1h.js} +1 -1
  56. package/dist/web/assets/{diagram-KO2AKTUF-BhOfCrvE.js → diagram-KO2AKTUF-CK-dl0Mm.js} +1 -1
  57. package/dist/web/assets/{diagram-LMA3HP47-1C0Ajian.js → diagram-LMA3HP47-nd0QxqLP.js} +1 -1
  58. package/dist/web/assets/{diagram-OG6HWLK6-BZsvylQi.js → diagram-OG6HWLK6-0UCe4OEH.js} +1 -1
  59. package/dist/web/assets/{erDiagram-TEJ5UH35-BODPoCQX.js → erDiagram-TEJ5UH35-DwJFF8MD.js} +1 -1
  60. package/dist/web/assets/{flowDiagram-I6XJVG4X-B0BsMsro.js → flowDiagram-I6XJVG4X-DJGfuTg-.js} +1 -1
  61. package/dist/web/assets/{folder-picker-B5RdK3CX.js → folder-picker-AfAde06M.js} +1 -1
  62. package/dist/web/assets/{freemarker2-B62GnwxO.js → freemarker2-ByNQbhxB.js} +2 -2
  63. package/dist/web/assets/{ganttDiagram-6RSMTGT7-BsXOoMru.js → ganttDiagram-6RSMTGT7-C6zNqsn4.js} +1 -1
  64. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DVuq4oVA.js → gitGraphDiagram-PVQCEYII-CAkDPCOB.js} +1 -1
  65. package/dist/web/assets/handlebars-9LtiNcLO.js +1 -0
  66. package/dist/web/assets/html-BwSL2qe7.js +1 -0
  67. package/dist/web/assets/htmlMode-0mfuF13e.js +1 -0
  68. package/dist/web/assets/{index-DfRNL5pP.js → index-B5PmQdbq.js} +4 -4
  69. package/dist/web/assets/index-CBhC80Wq.js +122 -0
  70. package/dist/web/assets/index-CxCjROy9.css +1 -0
  71. package/dist/web/assets/{infoDiagram-5YYISTIA-CkI-s2fN.js → infoDiagram-5YYISTIA-DJylJYHq.js} +1 -1
  72. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DExbu0jt.js → ishikawaDiagram-YF4QCWOH-Da6zdjFO.js} +1 -1
  73. package/dist/web/assets/javascript-CJNcoLqd.js +1 -0
  74. package/dist/web/assets/{journeyDiagram-JHISSGLW-C03_8hib.js → journeyDiagram-JHISSGLW-DrjNy1ij.js} +1 -1
  75. package/dist/web/assets/{jsonMode-SxmrKu-q.js → jsonMode-BEBKjViV.js} +4 -4
  76. package/dist/web/assets/{kanban-definition-UN3LZRKU-CkQ5JqTm.js → kanban-definition-UN3LZRKU-DNc4IquB.js} +1 -1
  77. package/dist/web/assets/{layers-DVjF8vaY.js → layers-CPYZanud.js} +1 -1
  78. package/dist/web/assets/{linear-VXyesiU2.js → linear-BsMeiiUP.js} +1 -1
  79. package/dist/web/assets/liquid-BZSJkIo-.js +1 -0
  80. package/dist/web/assets/{lspLanguageFeatures-D46XQnYj.js → lspLanguageFeatures-u5EzjXi-.js} +1 -1
  81. package/dist/web/assets/mdx-Bjp1I9VZ.js +1 -0
  82. package/dist/web/assets/{mermaid-NOHMQCX5-Cxj8y3xL.js → mermaid-NOHMQCX5-juygW0p8.js} +65 -66
  83. package/dist/web/assets/{message-square-BleDaJqD.js → message-square-DMhmeoQR.js} +1 -1
  84. package/dist/web/assets/{mindmap-definition-RKZ34NQL-OB13sryT.js → mindmap-definition-RKZ34NQL-BZTf4eUu.js} +1 -1
  85. package/dist/web/assets/{modal-DCycqy3L.js → modal-DdlXdmPL.js} +1 -1
  86. package/dist/web/assets/{monaco-C5uCiSc1.js → monaco-B4gWh5LA.js} +3 -3
  87. package/dist/web/assets/{pencil-7Lu7CiFO.js → pencil-BQnPUnRD.js} +1 -1
  88. package/dist/web/assets/{pieDiagram-4H26LBE5-CU-pnTSj.js → pieDiagram-4H26LBE5-DmYvE5xK.js} +1 -1
  89. package/dist/web/assets/python-B32s9JOZ.js +1 -0
  90. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-yZ7s-n8V.js → quadrantDiagram-W4KKPZXB-Clc4Is7S.js} +1 -1
  91. package/dist/web/assets/razor-81IfaByI.js +1 -0
  92. package/dist/web/assets/{requirementDiagram-4Y6WPE33-B0anLb96.js → requirementDiagram-4Y6WPE33-DYAvCl67.js} +1 -1
  93. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-DHcV9eve.js → sankeyDiagram-5OEKKPKP-BE8zoPb1.js} +1 -1
  94. package/dist/web/assets/{select-EnAkHFwg.js → select-CifNrwRy.js} +1 -1
  95. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DqgRRD9W.js → sequenceDiagram-3UESZ5HK-CZ-1XEig.js} +1 -1
  96. package/dist/web/assets/{server-a_4ZRCwE.js → server-DIU8iWhx.js} +1 -1
  97. package/dist/web/assets/{stateDiagram-AJRCARHV-BM_vAe4X.js → stateDiagram-AJRCARHV-BwL5WvW1.js} +1 -1
  98. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-By_Z6bpf.js +1 -0
  99. package/dist/web/assets/{switch-D_UoJD1K.js → switch-C2P_p2lg.js} +1 -1
  100. package/dist/web/assets/{textarea-Cmy7-X_E.js → textarea-7PW0aHOr.js} +1 -1
  101. package/dist/web/assets/{timeline-definition-PNZ67QCA-BRstBzgi.js → timeline-definition-PNZ67QCA-CJFGlrxn.js} +1 -1
  102. package/dist/web/assets/{trash-2-0UA8zJ8I.js → trash-2-BoBBdVYu.js} +1 -1
  103. package/dist/web/assets/{tsMode-BASXySxT.js → tsMode-5BiN2VdS.js} +2 -2
  104. package/dist/web/assets/typescript-B3ZemQIx.js +1 -0
  105. package/dist/web/assets/{upload-CfzBeWxL.js → upload-BGixJJOY.js} +1 -1
  106. package/dist/web/assets/{use-profiles-MVQfFrhT.js → use-profiles-DcSLdHYE.js} +1 -1
  107. package/dist/web/assets/{use-projects-CJ8Wn6Xl.js → use-projects-CnaCjQj2.js} +1 -1
  108. package/dist/web/assets/{use-providers-DvV0mdqo.js → use-providers-BOBu75PJ.js} +1 -1
  109. package/dist/web/assets/useNormalizedLogs-DU1I1PCJ.js +1 -0
  110. package/dist/web/assets/{vennDiagram-CIIHVFJN-DzhupKpF.js → vennDiagram-CIIHVFJN-BC6dMCwh.js} +1 -1
  111. package/dist/web/assets/{wardley-L42UT6IY-BwWhS3dk.js → wardley-L42UT6IY--kwEwWxY.js} +1 -1
  112. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-iG6xXnIJ.js → wardleyDiagram-YWT4CUSO-B75j5BO3.js} +1 -1
  113. package/dist/web/assets/xml-CyF6O2wF.js +1 -0
  114. package/dist/web/assets/{xychartDiagram-2RQKCTM6-hgKK9aU8.js → xychartDiagram-2RQKCTM6-DumRqRWt.js} +1 -1
  115. package/dist/web/assets/yaml-i8UwSbhD.js +1 -0
  116. package/dist/web/index.html +2 -2
  117. package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts +4 -1
  118. package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts.map +1 -1
  119. package/node_modules/@agent-tower/shared/dist/log-adapter.js +38 -5
  120. package/node_modules/@agent-tower/shared/dist/log-adapter.js.map +1 -1
  121. package/package.json +1 -1
  122. package/dist/web/assets/AgentDemoPage-DP9u0ylA.js +0 -1
  123. package/dist/web/assets/ConversationPage-CbMlQ5UC.js +0 -3
  124. package/dist/web/assets/ProfileSettingsPage-BEMuDjhF.js +0 -3
  125. package/dist/web/assets/ProjectSettingsPage-sE0Thu7d.js +0 -2
  126. package/dist/web/assets/SettingsMasterDetail-DmqYixrL.js +0 -1
  127. package/dist/web/assets/TeamSettingsPage-Dxk7-1fD.js +0 -1
  128. package/dist/web/assets/arrow-left-4_9exfZH.js +0 -1
  129. package/dist/web/assets/channel-D6ei4By-.js +0 -1
  130. package/dist/web/assets/check-CIGH6GLr.js +0 -1
  131. package/dist/web/assets/classDiagram-4FO5ZUOK-Dy0gEbpJ.js +0 -1
  132. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-Dy0gEbpJ.js +0 -1
  133. package/dist/web/assets/cssMode-r4PsUEeI.js +0 -1
  134. package/dist/web/assets/handlebars-BBm4KBDp.js +0 -1
  135. package/dist/web/assets/html-BlMJourI.js +0 -1
  136. package/dist/web/assets/htmlMode-vGjPTlal.js +0 -1
  137. package/dist/web/assets/index-BziFEuBL.js +0 -122
  138. package/dist/web/assets/index-KjsBZlkg.css +0 -1
  139. package/dist/web/assets/javascript-CnnNs3bZ.js +0 -1
  140. package/dist/web/assets/liquid-B_CJMcDS.js +0 -1
  141. package/dist/web/assets/mdx-B2i6poYS.js +0 -1
  142. package/dist/web/assets/python-CdqaVxbU.js +0 -1
  143. package/dist/web/assets/razor-BZtfxDHk.js +0 -1
  144. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DXSW0BBn.js +0 -1
  145. package/dist/web/assets/typescript-DbOfWuuq.js +0 -1
  146. package/dist/web/assets/useNormalizedLogs-D8-yjxOI.js +0 -1
  147. package/dist/web/assets/xml-Dn2Ep0JI.js +0 -1
  148. package/dist/web/assets/yaml-CA2Cgl3R.js +0 -1
@@ -1,34 +1,34 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-C5uCiSc1.js","assets/index-BziFEuBL.js","assets/index-KjsBZlkg.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
- import{ah as od,ai as oo,aj as ad,ak as ld,al as cd,k as Ke,r as b,am as le,z as Ss,m as jt,an as Es,n as zt,p as Ee,o as bt,q as ce,u as ae,j as t,a9 as xt,Y as Ra,Z as dd,l as te,$ as Ws,B as Me,ao as Aa,ap as Ta,aq as Ma,af as Cs,X as qt,ar as gn,as as ud,O as br,at as hd,D as fd,au as md,av as pd,aw as gd,T as js,t as st,U as os,V as lt,W as Os,P as ze,ax as Ns,Q as lr,ay as vd,az as oi,ag as xd,ad as bd,ae as _d,aA as Da,aB as vn,aC as yd,aD as Pa,aE as La,aF as Ia,aG as Sd,aH as wd,a2 as Cd,aI as kd,aJ as Ed,aK as jd,_ as ao,a8 as lo}from"./index-BziFEuBL.js";import{S as ct,u as xn,A as bn,l as Nd,F as Oa,p as Rd,m as Ad,o as Td,Q as _n,q as Md,r as Mt,W as _t,t as Ba,C as fr,v as Ir,w as Dd,x as Pd,y as Ld,T as Id,h as kt,b as qr,z as Fa,B as $t}from"./mermaid-NOHMQCX5-Cxj8y3xL.js";import{C as yn}from"./confirm-dialog-59aNupkb.js";import{c as za,a as Wa,b as Ha,I as $a,d as Ua,A as co,G as qa}from"./Icons-DXzgw2xT.js";import{C as wt}from"./chevron-down-B8PIP1yU.js";import{C as Pt}from"./chevron-right-h-JkCAHM.js";import{d as Sn,S as Od,u as wn,A as mr,c as Cn,G as Ka,Z as Bd,e as kn,T as En,f as Fd,g as jn,h as uo,i as zd,b as Va,j as Xa,a as Ya,k as Ga,R as Qa,P as Za,l as Kr,m as Wd,C as ho,B as fo}from"./CreateTaskInput-kkWy5nmc.js";import{a as Hd,F as $d,b as Ud}from"./folder-picker-B5RdK3CX.js";import{M as ai}from"./message-square-BleDaJqD.js";import{L as Hs}from"./layers-DVjF8vaY.js";import{P as Nn,u as Ja,a as el,T as Vr}from"./useNormalizedLogs-D8-yjxOI.js";import{u as Ks}from"./use-providers-DvV0mdqo.js";import{A as li}from"./AgentLogo-VGcaaJum.js";import{M as Ut}from"./MemberAvatar-DeKYSBH9.js";import{C as tl}from"./chevron-up-C5SQd6qy.js";import{C as Kt}from"./check-CIGH6GLr.js";import{M as fs}from"./modal-DCycqy3L.js";import{S as as}from"./select-EnAkHFwg.js";import{P as ls,T as Rn}from"./trash-2-0UA8zJ8I.js";import{T as qd}from"./textarea-Cmy7-X_E.js";import{S as Zi,C as mo}from"./server-a_4ZRCwE.js";import{F as An,e as Kd,d as Vd,f as Xd,u as Yd}from"./use-projects-CJ8Wn6Xl.js";import{U as Xr}from"./upload-CfzBeWxL.js";import{A as $s}from"./arrow-left-4_9exfZH.js";import{P as Gd}from"./pencil-7Lu7CiFO.js";var Qd=class extends od{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:oo()})}getOptimisticResult(e){return e.behavior=oo(),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:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=v&&i==="forward",u=p&&i==="forward",c=v&&i==="backward",g=p&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ld(s,r.data),hasPreviousPage:ad(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:n&&!l&&!c,isRefetching:m&&!u&&!g}}};function Tn(e,s){return cd(e,Qd)}const Zd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],sl=Ke("arrow-right",Zd);const Jd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rl=Ke("ban",Jd);const eu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],tu=Ke("chevron-left",eu);const su=[["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"}]],ru=Ke("clipboard-paste",su);const iu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cs=Ke("clock-3",iu);const nu=[["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"}]],ci=Ke("code-xml",nu);const ou=[["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"}]],po=Ke("copy-plus",ou);const au=[["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"}]],lu=Ke("earth",au);const cu=[["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"}]],il=Ke("ellipsis-vertical",cu);const du=[["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"}]],uu=Ke("file-braces-corner",du);const hu=[["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"}]],Yr=Ke("file-code-corner",hu);const fu=[["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"}]],mu=Ke("file-exclamation-point",fu);const pu=[["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"}]],di=Ke("folder-open",pu);const gu=[["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"}]],Vs=Ke("git-graph",gu);const vu=[["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"}]],Us=Ke("history",vu);const xu=[["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"}]],bu=Ke("maximize",xu);const _u=[["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"}]],yu=Ke("panel-left-close",_u);const Su=[["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"}]],wu=Ke("panel-left-open",Su);const Cu=[["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"}]],ku=Ke("panel-right-close",Cu);const Eu=[["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"}]],Ji=Ke("panel-right-open",Eu);const ju=[["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"}]],Nu=Ke("pen-line",ju);const Ru=[["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"}]],es=Ke("play",Ru);const Au=[["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"}]],nl=Ke("settings-2",Au);const Tu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],go=Ke("smartphone",Tu);const Mu=[["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"}]],Or=Ke("user-plus",Mu);const Du=[["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"}]],Pu=Ke("zoom-in",Du);const Lu=[["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"}]],Iu=Ke("zoom-out",Lu),ui=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Mn(e){return"nodeType"in e}function yt(e){var s,r;return e?Xs(e)?e:Mn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Dn(e){const{Document:s}=yt(e);return e instanceof s}function _r(e){return Xs(e)?!1:e instanceof yt(e).HTMLElement}function ol(e){return e instanceof yt(e).SVGElement}function Ys(e){return e?Xs(e)?e.document:Mn(e)?Dn(e)?e:_r(e)||ol(e)?e.ownerDocument:document:document:document}const ts=ui?b.useLayoutEffect:b.useEffect;function hi(e){const s=b.useRef(e);return ts(()=>{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 Ou(){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 pr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return ts(()=>{r.current!==e&&(r.current=e)},s),r}function yr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Gr(e){const s=hi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Qr(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Ri={};function fi(e,s){return b.useMemo(()=>{if(s)return s;const r=Ri[e]==null?0:Ri[e]+1;return Ri[e]=r,e+"-"+r},[e,s])}function al(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,v)=>{const n=Object.entries(v);for(const[i,l]of n){const u=m[i];u!=null&&(m[i]=u+e*l)}return m},{...s})}}const zs=al(1),Zr=al(-1);function Bu(e){return"clientX"in e&&"clientY"in e}function Pn(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function Fu(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function Jr(e){if(Fu(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 Bu(e)?{x:e.clientX,y:e.clientY}:null}const gr=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[gr.Translate.toString(e),gr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),vo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function zu(e){return e.matches(vo)?e:e.querySelector(vo)}const Wu={display:"none"};function Hu(e){let{id:s,value:r}=e;return le.createElement("div",{id:s,style:Wu},r)}function $u(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 le.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function Uu(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const ll=b.createContext(null);function qu(e){const s=b.useContext(ll);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Ku(){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(v=>{var n;return(n=v[p])==null?void 0:n.call(v,m)})},[e]),s]}const Vu={draggable:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-B4gWh5LA.js","assets/index-CBhC80Wq.js","assets/index-CxCjROy9.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
+ import{aj as ad,ak as ao,al as ld,am as cd,an as dd,k as Ke,r as b,ao as le,D as Ss,m as jt,ap as Es,n as zt,p as Ee,o as bt,q as ce,u as ae,j as t,aa as xt,Z as Aa,_ as ud,l as te,a0 as Ws,B as Me,aq as Ta,ar as Ma,as as Da,ah as Cs,X as qt,at as vn,au as hd,P as br,av as fd,E as md,aw as pd,ax as gd,ay as vd,T as js,t as st,V as os,W as lt,Y as Os,Q as ze,az as Ns,U as lr,aA as xd,aB as ai,ai as bd,af as _d,s as Hs,ag as yd,aC as Pa,aD as xn,aE as Sd,aF as La,aG as Ia,aH as Oa,aI as wd,aJ as Cd,a3 as kd,aK as Ed,aL as jd,aM as Nd,$ as lo,a9 as co}from"./index-CBhC80Wq.js";import{S as ct,u as bn,A as _n,l as Rd,F as Ba,p as Ad,m as Td,o as Md,Q as yn,q as Dd,r as Mt,W as _t,t as Fa,C as fr,v as Ir,w as Pd,x as Ld,y as Id,T as Od,h as kt,b as qr,z as za,B as $t}from"./mermaid-NOHMQCX5-juygW0p8.js";import{C as Sn}from"./confirm-dialog-CMtca90c.js";import{c as Wa,a as Ha,b as $a,I as Ua,d as qa,A as uo,G as Ka}from"./Icons-BsJUZk4z.js";import{C as wt}from"./chevron-down-gt857XmZ.js";import{C as Pt}from"./chevron-right-Dn5EL2Lm.js";import{d as wn,S as Bd,u as Cn,A as mr,c as kn,G as Va,Z as Fd,e as En,T as jn,f as zd,g as Nn,h as ho,i as Wd,b as Xa,j as Ya,a as Ga,k as Qa,R as Za,P as Ja,l as Kr,m as Hd,C as fo,B as mo}from"./CreateTaskInput-CX7_o02E.js";import{a as $d,F as Ud,b as qd}from"./folder-picker-AfAde06M.js";import{M as li}from"./message-square-DMhmeoQR.js";import{L as $s}from"./layers-CPYZanud.js";import{P as Rn,u as el,a as tl,L as Vr,T as Xr}from"./useNormalizedLogs-DU1I1PCJ.js";import{u as Ks}from"./use-providers-BOBu75PJ.js";import{A as ci}from"./AgentLogo-CRz3CfP5.js";import{M as Ut}from"./MemberAvatar-0z2Vg7fM.js";import{C as sl}from"./chevron-up-Dv5ThQH5.js";import{C as Kt}from"./check-BVfJOKK5.js";import{M as fs}from"./modal-DdlXdmPL.js";import{S as as}from"./select-CifNrwRy.js";import{P as ls,T as An}from"./trash-2-BoBBdVYu.js";import{T as Kd}from"./textarea-7PW0aHOr.js";import{S as Ji,C as po}from"./server-DIU8iWhx.js";import{F as Tn,e as Vd,d as Xd,f as Yd,u as Gd}from"./use-projects-CnaCjQj2.js";import{U as Yr}from"./upload-BGixJJOY.js";import{P as Qd}from"./pencil-BQnPUnRD.js";var Zd=class extends ad{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:ao()})}getOptimisticResult(e){return e.behavior=ao(),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:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=v&&i==="forward",u=p&&i==="forward",c=v&&i==="backward",g=p&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:cd(s,r.data),hasPreviousPage:ld(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:n&&!l&&!c,isRefetching:m&&!u&&!g}}};function Mn(e,s){return dd(e,Zd)}const Jd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],rl=Ke("arrow-right",Jd);const eu=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],il=Ke("ban",eu);const tu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],su=Ke("chevron-left",tu);const ru=[["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"}]],iu=Ke("clipboard-paste",ru);const nu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cs=Ke("clock-3",nu);const ou=[["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"}]],di=Ke("code-xml",ou);const au=[["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"}]],go=Ke("copy-plus",au);const lu=[["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"}]],cu=Ke("earth",lu);const du=[["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"}]],nl=Ke("ellipsis-vertical",du);const uu=[["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"}]],hu=Ke("file-braces-corner",uu);const fu=[["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"}]],Gr=Ke("file-code-corner",fu);const mu=[["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"}]],pu=Ke("file-exclamation-point",mu);const gu=[["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"}]],ui=Ke("folder-open",gu);const vu=[["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"}]],Vs=Ke("git-graph",vu);const xu=[["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"}]],Us=Ke("history",xu);const bu=[["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"}]],_u=Ke("maximize",bu);const yu=[["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"}]],Su=Ke("panel-left-close",yu);const wu=[["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"}]],Cu=Ke("panel-left-open",wu);const ku=[["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"}]],Eu=Ke("panel-right-close",ku);const ju=[["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"}]],en=Ke("panel-right-open",ju);const Nu=[["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"}]],Ru=Ke("pen-line",Nu);const Au=[["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"}]],es=Ke("play",Au);const Tu=[["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"}]],ol=Ke("settings-2",Tu);const Mu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],vo=Ke("smartphone",Mu);const Du=[["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"}]],Or=Ke("user-plus",Du);const Pu=[["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"}]],Lu=Ke("zoom-in",Pu);const Iu=[["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"}]],Ou=Ke("zoom-out",Iu),hi=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Dn(e){return"nodeType"in e}function yt(e){var s,r;return e?Xs(e)?e:Dn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Pn(e){const{Document:s}=yt(e);return e instanceof s}function _r(e){return Xs(e)?!1:e instanceof yt(e).HTMLElement}function al(e){return e instanceof yt(e).SVGElement}function Ys(e){return e?Xs(e)?e.document:Dn(e)?Pn(e)?e:_r(e)||al(e)?e.ownerDocument:document:document:document}const ts=hi?b.useLayoutEffect:b.useEffect;function fi(e){const s=b.useRef(e);return ts(()=>{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 Bu(){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 pr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return ts(()=>{r.current!==e&&(r.current=e)},s),r}function yr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Qr(e){const s=fi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Zr(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Ai={};function mi(e,s){return b.useMemo(()=>{if(s)return s;const r=Ai[e]==null?0:Ai[e]+1;return Ai[e]=r,e+"-"+r},[e,s])}function ll(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,v)=>{const n=Object.entries(v);for(const[i,l]of n){const u=m[i];u!=null&&(m[i]=u+e*l)}return m},{...s})}}const zs=ll(1),Jr=ll(-1);function Fu(e){return"clientX"in e&&"clientY"in e}function Ln(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function zu(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function ei(e){if(zu(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 Fu(e)?{x:e.clientX,y:e.clientY}:null}const gr=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[gr.Translate.toString(e),gr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),xo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Wu(e){return e.matches(xo)?e:e.querySelector(xo)}const Hu={display:"none"};function $u(e){let{id:s,value:r}=e;return le.createElement("div",{id:s,style:Hu},r)}function Uu(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 le.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function qu(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const cl=b.createContext(null);function Ku(e){const s=b.useContext(cl);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Vu(){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(v=>{var n;return(n=v[p])==null?void 0:n.call(v,m)})},[e]),s]}const Xu={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.
6
- `},Xu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Yu(e){let{announcements:s=Xu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=Vu}=e;const{announce:m,announcement:v}=Uu(),n=fi("DndLiveRegion"),[i,l]=b.useState(!1);if(b.useEffect(()=>{l(!0)},[]),qu(b.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:x}=c;s.onDragMove&&m(s.onDragMove({active:g,over:x}))},onDragOver(c){let{active:g,over:x}=c;m(s.onDragOver({active:g,over:x}))},onDragEnd(c){let{active:g,over:x}=c;m(s.onDragEnd({active:g,over:x}))},onDragCancel(c){let{active:g,over:x}=c;m(s.onDragCancel({active:g,over:x}))}}),[m,s])),!i)return null;const u=le.createElement(le.Fragment,null,le.createElement(Hu,{id:o,value:p.draggable}),le.createElement($u,{id:n,announcement:v}));return r?Ss.createPortal(u,r):u}var ot;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));function ei(){}function Gu(e,s){return b.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Qu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return b.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Ft=Object.freeze({x:0,y:0});function Zu(e,s){const r=Jr(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function Ju(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function eh(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function th(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),v=p-o,n=m-r;if(o<p&&r<m){const i=s.width*s.height,l=e.width*e.height,u=v*n,c=u/(i+l-u);return Number(c.toFixed(4))}return 0}const sh=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:v}=m,n=r.get(v);if(n){const i=th(n,s);i>0&&p.push({id:v,data:{droppableContainer:m,value:i}})}}return p.sort(Ju)};function rh(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function cl(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ft}function ih(e){return function(r){for(var o=arguments.length,p=new Array(o>1?o-1:0),m=1;m<o;m++)p[m-1]=arguments[m];return p.reduce((v,n)=>({...v,top:v.top+e*n.y,bottom:v.bottom+e*n.y,left:v.left+e*n.x,right:v.right+e*n.x}),{...r})}}const nh=ih(1);function dl(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function oh(e,s,r){const o=dl(s);if(!o)return e;const{scaleX:p,scaleY:m,x:v,y:n}=o,i=e.left-v-(1-p)*parseFloat(r),l=e.top-n-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),u=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:u,height:c,top:l,right:i+u,bottom:l+c,left:i}}const ah={ignoreTransform:!1};function Sr(e,s){s===void 0&&(s=ah);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:u}=yt(e).getComputedStyle(e);l&&(r=oh(r,l,u))}const{top:o,left:p,width:m,height:v,bottom:n,right:i}=r;return{top:o,left:p,width:m,height:v,bottom:n,right:i}}function xo(e){return Sr(e,{ignoreTransform:!0})}function lh(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function ch(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function dh(e,s){s===void 0&&(s=yt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function Ln(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Dn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!_r(p)||ol(p)||r.includes(p))return r;const m=yt(e).getComputedStyle(p);return p!==e&&dh(p,m)&&r.push(p),ch(p,m)?r:o(p.parentNode)}return e?o(e):r}function ul(e){const[s]=Ln(e,1);return s??null}function Ai(e){return!ui||!e?null:Xs(e)?e:Mn(e)?Dn(e)||e===Ys(e).scrollingElement?window:_r(e)?e:null:null}function hl(e){return Xs(e)?e.scrollX:e.scrollLeft}function fl(e){return Xs(e)?e.scrollY:e.scrollTop}function en(e){return{x:hl(e),y:fl(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function ml(e){return!ui||!e?!1:e===document.scrollingElement}function pl(e){const s={x:0,y:0},r=ml(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:v,isRight:n,maxScroll:o,minScroll:s}}const uh={x:.2,y:.2};function hh(e,s,r,o,p){let{top:m,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),p===void 0&&(p=uh);const{isTop:l,isBottom:u,isLeft:c,isRight:g}=pl(e),x={x:0,y:0},_={x:0,y:0},w={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+w.height?(x.y=dt.Backward,_.y=o*Math.abs((s.top+w.height-m)/w.height)):!u&&i>=s.bottom-w.height&&(x.y=dt.Forward,_.y=o*Math.abs((s.bottom-w.height-i)/w.height)),!g&&n>=s.right-w.width?(x.x=dt.Forward,_.x=o*Math.abs((s.right-w.width-n)/w.width)):!c&&v<=s.left+w.width&&(x.x=dt.Backward,_.x=o*Math.abs((s.left+w.width-v)/w.width)),{direction:x,speed:_}}function fh(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:v}=window;return{top:0,left:0,right:m,bottom:v,width:m,height:v}}const{top:s,left:r,right:o,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:p,width:e.clientWidth,height:e.clientHeight}}function gl(e){return e.reduce((s,r)=>zs(s,en(r)),Ft)}function mh(e){return e.reduce((s,r)=>s+hl(r),0)}function ph(e){return e.reduce((s,r)=>s+fl(r),0)}function vl(e,s){if(s===void 0&&(s=Sr),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);ul(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const gh=[["x",["left","right"],mh],["y",["top","bottom"],ph]];class In{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=Ln(r),p=gl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,n]of gh)for(const i of v)Object.defineProperty(this,i,{get:()=>{const l=n(o),u=p[m]-l;return this.rect[i]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class cr{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var p;(p=this.target)==null||p.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function vh(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Ys(e)}function Ti(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Tt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Tt||(Tt={}));function bo(e){e.preventDefault()}function xh(e){e.stopPropagation()}var qe;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(qe||(qe={}));const xl={start:[qe.Space,qe.Enter],cancel:[qe.Esc],end:[qe.Space,qe.Enter,qe.Tab]},bh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case qe.Right:return{...r,x:r.x+25};case qe.Left:return{...r,x:r.x-25};case qe.Down:return{...r,y:r.y+25};case qe.Up:return{...r,y:r.y-25}}};class bl{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new cr(Ys(r)),this.windowListeners=new cr(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Tt.Resize,this.handleCancel),this.windowListeners.add(Tt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Tt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&vl(o),r(Ft)}handleKeyDown(s){if(Pn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=xl,coordinateGetter:v=bh,scrollBehavior:n="smooth"}=p,{code:i}=s;if(m.end.includes(i)){this.handleEnd(s);return}if(m.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:l}=o.current,u=l?{x:l.left,y:l.top}:Ft;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Zr(c,u),x={x:0,y:0},{scrollableAncestors:_}=o.current;for(const w of _){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:S,maxScroll:C,minScroll:k}=pl(w),E=fh(w),y={x:Math.min(a===qe.Right?E.right-E.width/2:E.right,Math.max(a===qe.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(a===qe.Down?E.bottom-E.height/2:E.bottom,Math.max(a===qe.Down?E.top:E.top+E.height/2,c.y))},j=a===qe.Right&&!d||a===qe.Left&&!f,R=a===qe.Down&&!S||a===qe.Up&&!h;if(j&&y.x!==c.x){const L=w.scrollLeft+g.x,T=a===qe.Right&&L<=C.x||a===qe.Left&&L>=k.x;if(T&&!g.y){w.scrollTo({left:L,behavior:n});return}T?x.x=w.scrollLeft-L:x.x=a===qe.Right?w.scrollLeft-C.x:w.scrollLeft-k.x,x.x&&w.scrollBy({left:-x.x,behavior:n});break}else if(R&&y.y!==c.y){const L=w.scrollTop+g.y,T=a===qe.Down&&L<=C.y||a===qe.Up&&L>=k.y;if(T&&!g.x){w.scrollTo({top:L,behavior:n});return}T?x.y=w.scrollTop-L:x.y=a===qe.Down?w.scrollTop-C.y:w.scrollTop-k.y,x.y&&w.scrollBy({top:-x.y,behavior:n});break}}this.handleMove(s,zs(Zr(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}bl.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=xl,onActivation:p}=s,{active:m}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const n=m.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function _o(e){return!!(e&&"distance"in e)}function yo(e){return!!(e&&"delay"in e)}class On{constructor(s,r,o){var p;o===void 0&&(o=vh(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:v}=m;this.props=s,this.events=r,this.document=Ys(v),this.documentListeners=new cr(this.document),this.listeners=new cr(o),this.windowListeners=new cr(yt(v)),this.initialCoordinates=(p=Jr(m))!=null?p:Ft,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Tt.Resize,this.handleCancel),this.windowListeners.add(Tt.DragStart,bo),this.windowListeners.add(Tt.VisibilityChange,this.handleCancel),this.windowListeners.add(Tt.ContextMenu,bo),this.documentListeners.add(Tt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(yo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(_o(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:p}=this.props;p(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Tt.Click,xh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Tt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:n}}=m;if(!p)return;const i=(r=Jr(s))!=null?r:Ft,l=Zr(p,i);if(!o&&n){if(_o(n)){if(n.tolerance!=null&&Ti(l,n.tolerance))return this.handleCancel();if(Ti(l,n.distance))return this.handleStart()}if(yo(n)&&Ti(l,n.tolerance))return this.handleCancel();this.handlePending(n,l);return}s.cancelable&&s.preventDefault(),v(i)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===qe.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const _h={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Bn extends On{constructor(s){const{event:r}=s,o=Ys(r.target);super(s,_h,o)}}Bn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const yh={move:{name:"mousemove"},end:{name:"mouseup"}};var tn;(function(e){e[e.RightClick=2]="RightClick"})(tn||(tn={}));class Sh extends On{constructor(s){super(s,yh,Ys(s.event.target))}}Sh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===tn.RightClick?!1:(o?.({event:r}),!0)}}];const Mi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class wh extends On{constructor(s){super(s,Mi)}static setup(){return window.addEventListener(Mi.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Mi.move.name,s)};function s(){}}}wh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:p}=r;return p.length>1?!1:(o?.({event:r}),!0)}}];var dr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(dr||(dr={}));var ti;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ti||(ti={}));function Ch(e){let{acceleration:s,activator:r=dr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:n=ti.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:g}=e;const x=Eh({delta:c,disabled:!m}),[_,w]=Ou(),a=b.useRef({x:0,y:0}),h=b.useRef({x:0,y:0}),d=b.useMemo(()=>{switch(r){case dr.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case dr.DraggableRect:return p}},[r,p,i]),f=b.useRef(null),S=b.useCallback(()=>{const k=f.current;if(!k)return;const E=a.current.x*h.current.x,y=a.current.y*h.current.y;k.scrollBy(E,y)},[]),C=b.useMemo(()=>n===ti.TreeOrder?[...l].reverse():l,[n,l]);b.useEffect(()=>{if(!m||!l.length||!d){w();return}for(const k of C){if(o?.(k)===!1)continue;const E=l.indexOf(k),y=u[E];if(!y)continue;const{direction:j,speed:R}=hh(k,y,d,s,g);for(const L of["x","y"])x[L][j[L]]||(R[L]=0,j[L]=0);if(R.x>0||R.y>0){w(),f.current=k,_(S,v),a.current=R,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},w()},[s,S,o,w,m,v,JSON.stringify(d),JSON.stringify(x),_,l,C,u,JSON.stringify(g)])}const kh={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function Eh(e){let{delta:s,disabled:r}=e;const o=Qr(s);return yr(p=>{if(r||!o||!p)return kh;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[dt.Backward]:p.x[dt.Backward]||m.x===-1,[dt.Forward]:p.x[dt.Forward]||m.x===1},y:{[dt.Backward]:p.y[dt.Backward]||m.y===-1,[dt.Forward]:p.y[dt.Forward]||m.y===1}}},[r,s,o])}function jh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return yr(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function Nh(e,s){return b.useMemo(()=>e.reduce((r,o)=>{const{sensor:p}=o,m=p.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...m]},[]),[e,s])}var vr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(vr||(vr={}));var sn;(function(e){e.Optimized="optimized"})(sn||(sn={}));const So=new Map;function Rh(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,v]=b.useState(null),{frequency:n,measure:i,strategy:l}=p,u=b.useRef(e),c=a(),g=pr(c),x=b.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(f=>!d.includes(f))))},[g]),_=b.useRef(null),w=yr(h=>{if(c&&!r)return So;if(!h||h===So||u.current!==e||m!=null){const d=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const S=f.node.current,C=S?new In(i(S),S):null;f.rect.current=C,C&&d.set(f.id,C)}return d}return h},[e,m,r,c,i]);return b.useEffect(()=>{u.current=e},[e]),b.useEffect(()=>{c||x()},[r,c]),b.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),b.useEffect(()=>{c||typeof n!="number"||_.current!==null||(_.current=setTimeout(()=>{x(),_.current=null},n))},[n,c,x,...o]),{droppableRects:w,measureDroppableContainers:x,measuringScheduled:m!=null};function a(){switch(l){case vr.Always:return!1;case vr.BeforeDragging:return r;default:return!r}}}function Fn(e,s){return yr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Ah(e,s){return Fn(e,s)}function Th(e){let{callback:s,disabled:r}=e;const o=hi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function mi(e){let{callback:s,disabled:r}=e;const o=hi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function Mh(e){return new In(Sr(e),e)}function wo(e,s,r){s===void 0&&(s=Mh);const[o,p]=b.useState(null);function m(){p(i=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=i??r)!=null?l:null}const u=s(e);return JSON.stringify(i)===JSON.stringify(u)?i:u})}const v=Th({callback(i){if(e)for(const l of i){const{type:u,target:c}=l;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),n=mi({callback:m});return ts(()=>{m(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function Dh(e){const s=Fn(e);return cl(e,s)}const Co=[];function Ph(e){const s=b.useRef(e),r=yr(o=>e?o&&o!==Co&&e&&s.current&&e.parentNode===s.current.parentNode?o:Ln(e):Co,[e]);return b.useEffect(()=>{s.current=e},[e]),r}function Lh(e){const[s,r]=b.useState(null),o=b.useRef(e),p=b.useCallback(m=>{const v=Ai(m.target);v&&r(n=>n?(n.set(v,en(v)),new Map(n)):null)},[]);return b.useEffect(()=>{const m=o.current;if(e!==m){v(m);const n=e.map(i=>{const l=Ai(i);return l?(l.addEventListener("scroll",p,{passive:!0}),[l,en(l)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{v(e),v(m)};function v(n){n.forEach(i=>{const l=Ai(i);l?.removeEventListener("scroll",p)})}},[p,e]),b.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>zs(m,v),Ft):gl(e):Ft,[e,s])}function ko(e,s){s===void 0&&(s=[]);const r=b.useRef(null);return b.useEffect(()=>{r.current=null},s),b.useEffect(()=>{const o=e!==Ft;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Zr(e,r.current):Ft}function Ih(e){b.useEffect(()=>{if(!ui)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function Oh(e,s){return b.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=v=>{m(v,s)},r},{}),[e,s])}function _l(e){return b.useMemo(()=>e?lh(e):null,[e])}const Eo=[];function Bh(e,s){s===void 0&&(s=Sr);const[r]=e,o=_l(r?yt(r):null),[p,m]=b.useState(Eo);function v(){m(()=>e.length?e.map(i=>ml(i)?o:new In(s(i),i)):Eo)}const n=mi({callback:v});return ts(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),p}function yl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return _r(s)?s:e}function Fh(e){let{measure:s}=e;const[r,o]=b.useState(null),p=b.useCallback(l=>{for(const{target:u}of l)if(_r(u)){o(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=mi({callback:p}),v=b.useCallback(l=>{const u=yl(l);m?.disconnect(),u&&m?.observe(u),o(u?s(u):null)},[s,m]),[n,i]=Gr(v);return b.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const zh=[{sensor:Bn,options:{}},{sensor:bl,options:{}}],Wh={current:{}},$r={draggable:{measure:xo},droppable:{measure:xo,strategy:vr.WhileDragging,frequency:sn.Optimized},dragOverlay:{measure:Sr}};class ur extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const Hh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ur,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ei},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$r,measureDroppableContainers:ei,windowRect:null,measuringScheduled:!1},Sl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ei,draggableNodes:new Map,over:null,measureDroppableContainers:ei},wr=b.createContext(Sl),wl=b.createContext(Hh);function $h(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ur}}}function Uh(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new ur(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const v=new ur(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new ur(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function qh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=b.useContext(wr),m=Qr(o),v=Qr(r?.id);return b.useEffect(()=>{if(!s&&!o&&m&&v!=null){if(!Pn(m)||document.activeElement===m.target)return;const n=p.get(v);if(!n)return;const{activatorNode:i,node:l}=n;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[i.current,l.current]){if(!u)continue;const c=zu(u);if(c){c.focus();break}}})}},[o,s,p,v,m]),null}function Cl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function Kh(e){return b.useMemo(()=>({draggable:{...$r.draggable,...e?.draggable},droppable:{...$r.droppable,...e?.droppable},dragOverlay:{...$r.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Vh(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=b.useRef(!1),{x:v,y:n}=typeof p=="boolean"?{x:p,y:p}:p;ts(()=>{if(!v&&!n||!s){m.current=!1;return}if(m.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const u=r(l),c=cl(u,o);if(v||(c.x=0),n||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=ul(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,n,o,r])}const pi=b.createContext({...Ft,scaleX:1,scaleY:1});var ns;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ns||(ns={}));const Xh=b.memo(function(s){var r,o,p,m;let{id:v,accessibility:n,autoScroll:i=!0,children:l,sensors:u=zh,collisionDetection:c=sh,measuring:g,modifiers:x,..._}=s;const w=b.useReducer(Uh,void 0,$h),[a,h]=w,[d,f]=Ku(),[S,C]=b.useState(ns.Uninitialized),k=S===ns.Initialized,{draggable:{active:E,nodes:y,translate:j},droppable:{containers:R}}=a,L=E!=null?y.get(E):null,T=b.useRef({initial:null,translated:null}),D=b.useMemo(()=>{var se;return E!=null?{id:E,data:(se=L?.data)!=null?se:Wh,rect:T}:null},[E,L]),F=b.useRef(null),[I,H]=b.useState(null),[q,A]=b.useState(null),P=pr(_,Object.values(_)),M=fi("DndDescribedBy",v),O=b.useMemo(()=>R.getEnabled(),[R]),$=Kh(g),{droppableRects:K,measureDroppableContainers:B,measuringScheduled:z}=Rh(O,{dragging:k,dependencies:[j.x,j.y],config:$.droppable}),U=jh(y,E),N=b.useMemo(()=>q?Jr(q):null,[q]),W=Y(),X=Ah(U,$.draggable.measure);Vh({activeNode:E!=null?y.get(E):null,config:W.layoutShiftCompensation,initialRect:X,measure:$.draggable.measure});const V=wo(U,$.draggable.measure,X),ie=wo(U?U.parentElement:null),ee=b.useRef({activatorEvent:null,active:null,activeNode:U,collisionRect:null,collisions:null,droppableRects:K,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),me=R.getNodeFor((r=ee.current.over)==null?void 0:r.id),he=Fh({measure:$.dragOverlay.measure}),G=(o=he.nodeRef.current)!=null?o:U,pe=k?(p=he.rect)!=null?p:V:null,oe=!!(he.nodeRef.current&&he.rect),We=Dh(oe?null:V),ut=_l(G?yt(G):null),Oe=Ph(k?me??U:null),be=Bh(Oe),Ue=Cl(x,{transform:{x:j.x-We.x,y:j.y-We.y,scaleX:1,scaleY:1},activatorEvent:q,active:D,activeNodeRect:V,containerNodeRect:ie,draggingNodeRect:pe,over:ee.current.over,overlayNodeRect:he.rect,scrollableAncestors:Oe,scrollableAncestorRects:be,windowRect:ut}),Be=N?zs(N,j):null,tt=Lh(Oe),Ye=ko(tt),Ze=ko(tt,[V]),Xe=zs(Ue,Ye),Ne=pe?nh(pe,Ue):null,Ae=D&&Ne?c({active:D,collisionRect:Ne,droppableRects:K,droppableContainers:O,pointerCoordinates:Be}):null,ve=eh(Ae,"id"),[He,_e]=b.useState(null),pt=oe?Ue:zs(Ue,Ze),Je=rh(pt,(m=He?.rect)!=null?m:null,V),Lt=b.useRef(null),J=b.useCallback((se,ne)=>{let{sensor:ke,options:xe}=ne;if(F.current==null)return;const je=y.get(F.current);if(!je)return;const Te=se.nativeEvent,ye=new ke({active:F.current,activeNode:je,event:Te,options:xe,context:ee,onAbort(Se){if(!y.get(Se))return;const{onDragAbort:Qe}=P.current,rt={id:Se};Qe?.(rt),d({type:"onDragAbort",event:rt})},onPending(Se,De,Qe,rt){if(!y.get(Se))return;const{onDragPending:it}=P.current,nt={id:Se,constraint:De,initialCoordinates:Qe,offset:rt};it?.(nt),d({type:"onDragPending",event:nt})},onStart(Se){const De=F.current;if(De==null)return;const Qe=y.get(De);if(!Qe)return;const{onDragStart:rt}=P.current,Ct={activatorEvent:Te,active:{id:De,data:Qe.data,rect:T}};Ss.unstable_batchedUpdates(()=>{rt?.(Ct),C(ns.Initializing),h({type:ot.DragStart,initialCoordinates:Se,active:De}),d({type:"onDragStart",event:Ct}),H(Lt.current),A(Te)})},onMove(Se){h({type:ot.DragMove,coordinates:Se})},onEnd:Le(ot.DragEnd),onCancel:Le(ot.DragCancel)});Lt.current=ye;function Le(Se){return async function(){const{active:Qe,collisions:rt,over:Ct,scrollAdjustedTranslate:it}=ee.current;let nt=null;if(Qe&&it){const{cancelDrop:gt}=P.current;nt={activatorEvent:Te,active:Qe,collisions:rt,delta:it,over:Ct},Se===ot.DragEnd&&typeof gt=="function"&&await Promise.resolve(gt(nt))&&(Se=ot.DragCancel)}F.current=null,Ss.unstable_batchedUpdates(()=>{h({type:Se}),C(ns.Uninitialized),_e(null),H(null),A(null),Lt.current=null;const gt=Se===ot.DragEnd?"onDragEnd":"onDragCancel";if(nt){const Vt=P.current[gt];Vt?.(nt),d({type:gt,event:nt})}})}}},[y]),fe=b.useCallback((se,ne)=>(ke,xe)=>{const je=ke.nativeEvent,Te=y.get(xe);if(F.current!==null||!Te||je.dndKit||je.defaultPrevented)return;const ye={active:Te};se(ke,ne.options,ye)===!0&&(je.dndKit={capturedBy:ne.sensor},F.current=xe,J(ke,ne))},[y,J]),ue=Nh(u,fe);Ih(u),ts(()=>{V&&S===ns.Initializing&&C(ns.Initialized)},[V,S]),b.useEffect(()=>{const{onDragMove:se}=P.current,{active:ne,activatorEvent:ke,collisions:xe,over:je}=ee.current;if(!ne||!ke)return;const Te={active:ne,activatorEvent:ke,collisions:xe,delta:{x:Xe.x,y:Xe.y},over:je};Ss.unstable_batchedUpdates(()=>{se?.(Te),d({type:"onDragMove",event:Te})})},[Xe.x,Xe.y]),b.useEffect(()=>{const{active:se,activatorEvent:ne,collisions:ke,droppableContainers:xe,scrollAdjustedTranslate:je}=ee.current;if(!se||F.current==null||!ne||!je)return;const{onDragOver:Te}=P.current,ye=xe.get(ve),Le=ye&&ye.rect.current?{id:ye.id,rect:ye.rect.current,data:ye.data,disabled:ye.disabled}:null,Se={active:se,activatorEvent:ne,collisions:ke,delta:{x:je.x,y:je.y},over:Le};Ss.unstable_batchedUpdates(()=>{_e(Le),Te?.(Se),d({type:"onDragOver",event:Se})})},[ve]),ts(()=>{ee.current={activatorEvent:q,active:D,activeNode:U,collisionRect:Ne,collisions:Ae,droppableRects:K,draggableNodes:y,draggingNode:G,draggingNodeRect:pe,droppableContainers:R,over:He,scrollableAncestors:Oe,scrollAdjustedTranslate:Xe},T.current={initial:pe,translated:Ne}},[D,U,Ae,Ne,y,G,pe,K,R,He,Oe,Xe]),Ch({...W,delta:j,draggingRect:Ne,pointerCoordinates:Be,scrollableAncestors:Oe,scrollableAncestorRects:be});const ge=b.useMemo(()=>({active:D,activeNode:U,activeNodeRect:V,activatorEvent:q,collisions:Ae,containerNodeRect:ie,dragOverlay:he,draggableNodes:y,droppableContainers:R,droppableRects:K,over:He,measureDroppableContainers:B,scrollableAncestors:Oe,scrollableAncestorRects:be,measuringConfiguration:$,measuringScheduled:z,windowRect:ut}),[D,U,V,q,Ae,ie,he,y,R,K,He,B,Oe,be,$,z,ut]),Ce=b.useMemo(()=>({activatorEvent:q,activators:ue,active:D,activeNodeRect:V,ariaDescribedById:{draggable:M},dispatch:h,draggableNodes:y,over:He,measureDroppableContainers:B}),[q,ue,D,V,h,M,y,He,B]);return le.createElement(ll.Provider,{value:f},le.createElement(wr.Provider,{value:Ce},le.createElement(wl.Provider,{value:ge},le.createElement(pi.Provider,{value:Je},l)),le.createElement(qh,{disabled:n?.restoreFocus===!1})),le.createElement(Yu,{...n,hiddenTextDescribedById:M}));function Y(){const se=I?.autoScrollEnabled===!1,ne=typeof i=="object"?i.enabled===!1:i===!1,ke=k&&!se&&!ne;return typeof i=="object"?{...i,enabled:ke}:{enabled:ke}}}),Yh=b.createContext(null),jo="button",Gh="Draggable";function Qh(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=fi(Gh),{activators:v,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=b.useContext(wr),{role:x=jo,roleDescription:_="draggable",tabIndex:w=0}=p??{},a=i?.id===s,h=b.useContext(a?pi:Yh),[d,f]=Gr(),[S,C]=Gr(),k=Oh(v,s),E=pr(r);ts(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:S,data:E}),()=>{const j=c.get(s);j&&j.key===m&&c.delete(s)}),[c,s]);const y=b.useMemo(()=>({role:x,tabIndex:w,"aria-disabled":o,"aria-pressed":a&&x===jo?!0:void 0,"aria-roledescription":_,"aria-describedby":u.draggable}),[o,x,w,a,_,u.draggable]);return{active:i,activatorEvent:n,activeNodeRect:l,attributes:y,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:C,transform:h}}function Zh(){return b.useContext(wl)}const Jh="Droppable",ef={timeout:25};function tf(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=fi(Jh),{active:v,dispatch:n,over:i,measureDroppableContainers:l}=b.useContext(wr),u=b.useRef({disabled:r}),c=b.useRef(!1),g=b.useRef(null),x=b.useRef(null),{disabled:_,updateMeasurementsFor:w,timeout:a}={...ef,...p},h=pr(w??o),d=b.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),x.current=null},a)},[a]),f=mi({callback:d,disabled:_||!v}),S=b.useCallback((y,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),y&&f.observe(y))},[f]),[C,k]=Gr(S),E=pr(s);return b.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),b.useEffect(()=>(n({type:ot.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:E}}),()=>n({type:ot.UnregisterDroppable,key:m,id:o})),[o]),b.useEffect(()=>{r!==u.current.disabled&&(n({type:ot.SetDroppableDisabled,id:o,key:m,disabled:r}),u.current.disabled=r)},[o,m,r,n]),{active:v,rect:g,isOver:i?.id===o,node:C,over:i,setNodeRef:k}}function sf(e){let{animation:s,children:r}=e;const[o,p]=b.useState(null),[m,v]=b.useState(null),n=Qr(r);return!r&&!o&&n&&p(n),ts(()=>{if(!m)return;const i=o?.key,l=o?.props.id;if(i==null||l==null){p(null);return}Promise.resolve(s(l,m)).then(()=>{p(null)})},[s,o,m]),le.createElement(le.Fragment,null,r,o?b.cloneElement(o,{ref:v}):null)}const rf={x:0,y:0,scaleX:1,scaleY:1};function nf(e){let{children:s}=e;return le.createElement(wr.Provider,{value:Sl},le.createElement(pi.Provider,{value:rf},s))}const of={position:"fixed",touchAction:"none"},af=e=>Pn(e)?"transform 250ms ease":void 0,lf=b.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:v,rect:n,style:i,transform:l,transition:u=af}=e;if(!n)return null;const c=p?l:{...l,scaleX:1,scaleY:1},g={...of,width:n.width,height:n.height,top:n.top,left:n.left,transform:gr.Transform.toString(c),transformOrigin:p&&o?Zu(o,n):void 0,transition:typeof u=="function"?u(o):u,...i};return le.createElement(r,{className:v,style:g,ref:s},m)}),cf=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:v}=e;if(m!=null&&m.active)for(const[n,i]of Object.entries(m.active))i!==void 0&&(p[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(m!=null&&m.dragOverlay)for(const[n,i]of Object.entries(m.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[i,l]of Object.entries(p))r.node.style.setProperty(i,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},df=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:gr.Transform.toString(s)},{transform:gr.Transform.toString(r)}]},uf={duration:250,easing:"ease",keyframes:df,sideEffects:cf({styles:{active:{opacity:"0"}}})};function hf(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return hi((m,v)=>{if(s===null)return;const n=r.get(m);if(!n)return;const i=n.node.current;if(!i)return;const l=yl(v);if(!l)return;const{transform:u}=yt(v).getComputedStyle(v),c=dl(u);if(!c)return;const g=typeof s=="function"?s:ff(s);return vl(i,p.draggable.measure),g({active:{id:m,data:n.data,node:i,rect:p.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function ff(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...uf,...e};return m=>{let{active:v,dragOverlay:n,transform:i,...l}=m;if(!s)return;const u={x:n.rect.left-v.rect.left,y:n.rect.top-v.rect.top},c={scaleX:i.scaleX!==1?v.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?v.rect.height*i.scaleY/n.rect.height:1},g={x:i.x-u.x,y:i.y-u.y,...c},x=p({...l,active:v,dragOverlay:n,transform:{initial:i,final:g}}),[_]=x,w=x[x.length-1];if(JSON.stringify(_)===JSON.stringify(w))return;const a=o?.({active:v,dragOverlay:n,...l}),h=n.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let No=0;function mf(e){return b.useMemo(()=>{if(e!=null)return No++,No},[e])}const pf=le.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:v,wrapperElement:n="div",className:i,zIndex:l=999}=e;const{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:x,draggableNodes:_,droppableContainers:w,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:S,windowRect:C}=Zh(),k=b.useContext(pi),E=mf(c?.id),y=Cl(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:x,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:S,transform:k,windowRect:C}),j=Fn(g),R=hf({config:o,draggableNodes:_,droppableContainers:w,measuringConfiguration:d}),L=j?a.setRef:void 0;return le.createElement(nf,null,le.createElement(sf,{animation:R},c&&E?le.createElement(lf,{key:E,id:c.id,ref:L,as:n,activatorEvent:u,adjustScale:s,className:i,transition:m,rect:j,style:{zIndex:l,...p},transform:y},r):null))}),kl=768;function gf(e){const s=window.matchMedia(`(max-width: ${kl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function vf(){return window.innerWidth<kl}function xf(){return!1}function El(){return b.useSyncExternalStore(gf,vf,xf)}const bf=1500,_f=2e3,yf=5e3;function jl(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?bf:!1}function Sf(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?_f:!1}function wf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?yf:!1}function zn(e){return jt({queryKey:ce.workspaces.list(e),queryFn:()=>Ee.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Nl(e){const s=bt();return zt({mutationFn:r=>Ee.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ce.workspaces.list(e)}),s.invalidateQueries({queryKey:ce.tasks.all})}})}function Rl(){const e=bt();return zt({mutationFn:({id:s,commitMessage:r,stopActiveServices:o})=>Ee.post(`/workspaces/${s}/merge`,{commitMessage:r,stopActiveServices:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all}),e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})},onError:()=>{e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})}})}function Cf(){const e=bt();return zt({mutationFn:s=>Ee.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function Wn(){return zt({mutationFn:({workspaceId:e,editorType:s})=>Ee.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Hn(e,s={}){const r=Es(p=>p.visibleContext),o=Sf(e,r);return jt({queryKey:ce.workspaces.gitStatus(e),queryFn:()=>Ee.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Al(){const e=bt();return zt({mutationFn:s=>Ee.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function $n(){const e=bt();return zt({mutationFn:s=>Ee.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function kf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(v=>v.status===ct.RUNNING||v.status===ct.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function Un({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:v}){const{t:n}=ae(),{data:i,isLoading:l}=zn(m===void 0&&e?o:""),u=m??i,c=m===void 0&&e&&l,g=b.useMemo(()=>kf(u,n),[u,n]);return t.jsx(yn,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((x,_)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:x})]},_))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||c})}const we={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},rn={[we.Review]:{label:"Review",icon:Ua,iconClass:"text-warning",accentClass:"text-warning"},[we.Running]:{label:"Running",icon:$a,iconClass:"text-info",accentClass:"text-info"},[we.Pending]:{label:"Pending",icon:Ha,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[we.Done]:{label:"Done",icon:Wa,iconClass:"text-success/80",accentClass:"text-success"},[we.Cancelled]:{label:"Cancelled",icon:za,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},Ef=[we.Review,we.Running,we.Pending,we.Done,we.Cancelled],Tl=b.createContext(null),jf=3e4;function Nf(e=jf){const[,s]=b.useState(0);b.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function Rf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?xt("{count}s ago",{count:s}):s<3600?xt("{count}m ago",{count:Math.floor(s/60)}):s<86400?xt("{count}h ago",{count:Math.floor(s/3600)}):xt("{count}d ago",{count:Math.floor(s/86400)})}function Af({task:e,status:s,isSelected:r,project:o,onSelectTask:p,onTaskStatusChange:m,onDeleteTask:v,disableDrag:n}){const{t:i}=ae(),l=b.useContext(Tl),u=b.useRef(null),c=!!e.projectArchivedAt,g=c||!!n,{attributes:x,listeners:_,setNodeRef:w,isDragging:a}=Qh({id:e.id,data:{task:e,fromStatus:s},disabled:g}),h=b.useCallback(T=>{u.current=T,w(T),l&&(T?l.registry.set(e.id,T):l.registry.delete(e.id))},[w,l,e.id]);b.useEffect(()=>()=>{l?.registry.delete(e.id)},[e.id,l]);const[d,f]=b.useState(null),[S,C]=b.useState(!1),k=b.useRef(null),E=b.useRef(null),y=b.useCallback(T=>{c||!m&&!v||(T.preventDefault(),f({x:T.clientX,y:T.clientY}))},[c,m,v]),j=b.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),R=b.useCallback(T=>{if(!n||c||!m&&!v)return;const D=T.touches[0];if(!D)return;const{clientX:F,clientY:I}=D;E.current=setTimeout(()=>{E.current=null,f({x:F,y:I})},500)},[n,c,m,v]);b.useEffect(()=>{if(!d)return;const T=D=>{k.current&&!k.current.contains(D.target)&&f(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[d]);const L=o?o.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:h,onClick:()=>p(e.id),onContextMenu:y,onTouchStart:R,onTouchEnd:j,onTouchMove:j,title:L,"aria-label":L?`${e.title} — ${L}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
6
+ `},Yu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Gu(e){let{announcements:s=Yu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=Xu}=e;const{announce:m,announcement:v}=qu(),n=mi("DndLiveRegion"),[i,l]=b.useState(!1);if(b.useEffect(()=>{l(!0)},[]),Ku(b.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:x}=c;s.onDragMove&&m(s.onDragMove({active:g,over:x}))},onDragOver(c){let{active:g,over:x}=c;m(s.onDragOver({active:g,over:x}))},onDragEnd(c){let{active:g,over:x}=c;m(s.onDragEnd({active:g,over:x}))},onDragCancel(c){let{active:g,over:x}=c;m(s.onDragCancel({active:g,over:x}))}}),[m,s])),!i)return null;const u=le.createElement(le.Fragment,null,le.createElement($u,{id:o,value:p.draggable}),le.createElement(Uu,{id:n,announcement:v}));return r?Ss.createPortal(u,r):u}var ot;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));function ti(){}function Qu(e,s){return b.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Zu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return b.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Ft=Object.freeze({x:0,y:0});function Ju(e,s){const r=ei(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function eh(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function th(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function sh(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),v=p-o,n=m-r;if(o<p&&r<m){const i=s.width*s.height,l=e.width*e.height,u=v*n,c=u/(i+l-u);return Number(c.toFixed(4))}return 0}const rh=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:v}=m,n=r.get(v);if(n){const i=sh(n,s);i>0&&p.push({id:v,data:{droppableContainer:m,value:i}})}}return p.sort(eh)};function ih(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function dl(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ft}function nh(e){return function(r){for(var o=arguments.length,p=new Array(o>1?o-1:0),m=1;m<o;m++)p[m-1]=arguments[m];return p.reduce((v,n)=>({...v,top:v.top+e*n.y,bottom:v.bottom+e*n.y,left:v.left+e*n.x,right:v.right+e*n.x}),{...r})}}const oh=nh(1);function ul(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function ah(e,s,r){const o=ul(s);if(!o)return e;const{scaleX:p,scaleY:m,x:v,y:n}=o,i=e.left-v-(1-p)*parseFloat(r),l=e.top-n-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),u=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:u,height:c,top:l,right:i+u,bottom:l+c,left:i}}const lh={ignoreTransform:!1};function Sr(e,s){s===void 0&&(s=lh);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:u}=yt(e).getComputedStyle(e);l&&(r=ah(r,l,u))}const{top:o,left:p,width:m,height:v,bottom:n,right:i}=r;return{top:o,left:p,width:m,height:v,bottom:n,right:i}}function bo(e){return Sr(e,{ignoreTransform:!0})}function ch(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function dh(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function uh(e,s){s===void 0&&(s=yt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function In(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Pn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!_r(p)||al(p)||r.includes(p))return r;const m=yt(e).getComputedStyle(p);return p!==e&&uh(p,m)&&r.push(p),dh(p,m)?r:o(p.parentNode)}return e?o(e):r}function hl(e){const[s]=In(e,1);return s??null}function Ti(e){return!hi||!e?null:Xs(e)?e:Dn(e)?Pn(e)||e===Ys(e).scrollingElement?window:_r(e)?e:null:null}function fl(e){return Xs(e)?e.scrollX:e.scrollLeft}function ml(e){return Xs(e)?e.scrollY:e.scrollTop}function tn(e){return{x:fl(e),y:ml(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function pl(e){return!hi||!e?!1:e===document.scrollingElement}function gl(e){const s={x:0,y:0},r=pl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:v,isRight:n,maxScroll:o,minScroll:s}}const hh={x:.2,y:.2};function fh(e,s,r,o,p){let{top:m,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),p===void 0&&(p=hh);const{isTop:l,isBottom:u,isLeft:c,isRight:g}=gl(e),x={x:0,y:0},_={x:0,y:0},w={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+w.height?(x.y=dt.Backward,_.y=o*Math.abs((s.top+w.height-m)/w.height)):!u&&i>=s.bottom-w.height&&(x.y=dt.Forward,_.y=o*Math.abs((s.bottom-w.height-i)/w.height)),!g&&n>=s.right-w.width?(x.x=dt.Forward,_.x=o*Math.abs((s.right-w.width-n)/w.width)):!c&&v<=s.left+w.width&&(x.x=dt.Backward,_.x=o*Math.abs((s.left+w.width-v)/w.width)),{direction:x,speed:_}}function mh(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:v}=window;return{top:0,left:0,right:m,bottom:v,width:m,height:v}}const{top:s,left:r,right:o,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:p,width:e.clientWidth,height:e.clientHeight}}function vl(e){return e.reduce((s,r)=>zs(s,tn(r)),Ft)}function ph(e){return e.reduce((s,r)=>s+fl(r),0)}function gh(e){return e.reduce((s,r)=>s+ml(r),0)}function xl(e,s){if(s===void 0&&(s=Sr),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);hl(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const vh=[["x",["left","right"],ph],["y",["top","bottom"],gh]];class On{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=In(r),p=vl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,n]of vh)for(const i of v)Object.defineProperty(this,i,{get:()=>{const l=n(o),u=p[m]-l;return this.rect[i]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class cr{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var p;(p=this.target)==null||p.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function xh(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Ys(e)}function Mi(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Tt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Tt||(Tt={}));function _o(e){e.preventDefault()}function bh(e){e.stopPropagation()}var qe;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(qe||(qe={}));const bl={start:[qe.Space,qe.Enter],cancel:[qe.Esc],end:[qe.Space,qe.Enter,qe.Tab]},_h=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case qe.Right:return{...r,x:r.x+25};case qe.Left:return{...r,x:r.x-25};case qe.Down:return{...r,y:r.y+25};case qe.Up:return{...r,y:r.y-25}}};class _l{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new cr(Ys(r)),this.windowListeners=new cr(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Tt.Resize,this.handleCancel),this.windowListeners.add(Tt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Tt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&xl(o),r(Ft)}handleKeyDown(s){if(Ln(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=bl,coordinateGetter:v=_h,scrollBehavior:n="smooth"}=p,{code:i}=s;if(m.end.includes(i)){this.handleEnd(s);return}if(m.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:l}=o.current,u=l?{x:l.left,y:l.top}:Ft;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Jr(c,u),x={x:0,y:0},{scrollableAncestors:_}=o.current;for(const w of _){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:S,maxScroll:C,minScroll:k}=gl(w),E=mh(w),y={x:Math.min(a===qe.Right?E.right-E.width/2:E.right,Math.max(a===qe.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(a===qe.Down?E.bottom-E.height/2:E.bottom,Math.max(a===qe.Down?E.top:E.top+E.height/2,c.y))},j=a===qe.Right&&!d||a===qe.Left&&!f,R=a===qe.Down&&!S||a===qe.Up&&!h;if(j&&y.x!==c.x){const L=w.scrollLeft+g.x,T=a===qe.Right&&L<=C.x||a===qe.Left&&L>=k.x;if(T&&!g.y){w.scrollTo({left:L,behavior:n});return}T?x.x=w.scrollLeft-L:x.x=a===qe.Right?w.scrollLeft-C.x:w.scrollLeft-k.x,x.x&&w.scrollBy({left:-x.x,behavior:n});break}else if(R&&y.y!==c.y){const L=w.scrollTop+g.y,T=a===qe.Down&&L<=C.y||a===qe.Up&&L>=k.y;if(T&&!g.x){w.scrollTo({top:L,behavior:n});return}T?x.y=w.scrollTop-L:x.y=a===qe.Down?w.scrollTop-C.y:w.scrollTop-k.y,x.y&&w.scrollBy({top:-x.y,behavior:n});break}}this.handleMove(s,zs(Jr(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}_l.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=bl,onActivation:p}=s,{active:m}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const n=m.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function yo(e){return!!(e&&"distance"in e)}function So(e){return!!(e&&"delay"in e)}class Bn{constructor(s,r,o){var p;o===void 0&&(o=xh(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:v}=m;this.props=s,this.events=r,this.document=Ys(v),this.documentListeners=new cr(this.document),this.listeners=new cr(o),this.windowListeners=new cr(yt(v)),this.initialCoordinates=(p=ei(m))!=null?p:Ft,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Tt.Resize,this.handleCancel),this.windowListeners.add(Tt.DragStart,_o),this.windowListeners.add(Tt.VisibilityChange,this.handleCancel),this.windowListeners.add(Tt.ContextMenu,_o),this.documentListeners.add(Tt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(So(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(yo(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:p}=this.props;p(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Tt.Click,bh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Tt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:n}}=m;if(!p)return;const i=(r=ei(s))!=null?r:Ft,l=Jr(p,i);if(!o&&n){if(yo(n)){if(n.tolerance!=null&&Mi(l,n.tolerance))return this.handleCancel();if(Mi(l,n.distance))return this.handleStart()}if(So(n)&&Mi(l,n.tolerance))return this.handleCancel();this.handlePending(n,l);return}s.cancelable&&s.preventDefault(),v(i)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===qe.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const yh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Fn extends Bn{constructor(s){const{event:r}=s,o=Ys(r.target);super(s,yh,o)}}Fn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const Sh={move:{name:"mousemove"},end:{name:"mouseup"}};var sn;(function(e){e[e.RightClick=2]="RightClick"})(sn||(sn={}));class wh extends Bn{constructor(s){super(s,Sh,Ys(s.event.target))}}wh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===sn.RightClick?!1:(o?.({event:r}),!0)}}];const Di={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Ch extends Bn{constructor(s){super(s,Di)}static setup(){return window.addEventListener(Di.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Di.move.name,s)};function s(){}}}Ch.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:p}=r;return p.length>1?!1:(o?.({event:r}),!0)}}];var dr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(dr||(dr={}));var si;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(si||(si={}));function kh(e){let{acceleration:s,activator:r=dr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:n=si.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:g}=e;const x=jh({delta:c,disabled:!m}),[_,w]=Bu(),a=b.useRef({x:0,y:0}),h=b.useRef({x:0,y:0}),d=b.useMemo(()=>{switch(r){case dr.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case dr.DraggableRect:return p}},[r,p,i]),f=b.useRef(null),S=b.useCallback(()=>{const k=f.current;if(!k)return;const E=a.current.x*h.current.x,y=a.current.y*h.current.y;k.scrollBy(E,y)},[]),C=b.useMemo(()=>n===si.TreeOrder?[...l].reverse():l,[n,l]);b.useEffect(()=>{if(!m||!l.length||!d){w();return}for(const k of C){if(o?.(k)===!1)continue;const E=l.indexOf(k),y=u[E];if(!y)continue;const{direction:j,speed:R}=fh(k,y,d,s,g);for(const L of["x","y"])x[L][j[L]]||(R[L]=0,j[L]=0);if(R.x>0||R.y>0){w(),f.current=k,_(S,v),a.current=R,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},w()},[s,S,o,w,m,v,JSON.stringify(d),JSON.stringify(x),_,l,C,u,JSON.stringify(g)])}const Eh={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function jh(e){let{delta:s,disabled:r}=e;const o=Zr(s);return yr(p=>{if(r||!o||!p)return Eh;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[dt.Backward]:p.x[dt.Backward]||m.x===-1,[dt.Forward]:p.x[dt.Forward]||m.x===1},y:{[dt.Backward]:p.y[dt.Backward]||m.y===-1,[dt.Forward]:p.y[dt.Forward]||m.y===1}}},[r,s,o])}function Nh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return yr(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function Rh(e,s){return b.useMemo(()=>e.reduce((r,o)=>{const{sensor:p}=o,m=p.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...m]},[]),[e,s])}var vr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(vr||(vr={}));var rn;(function(e){e.Optimized="optimized"})(rn||(rn={}));const wo=new Map;function Ah(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,v]=b.useState(null),{frequency:n,measure:i,strategy:l}=p,u=b.useRef(e),c=a(),g=pr(c),x=b.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(f=>!d.includes(f))))},[g]),_=b.useRef(null),w=yr(h=>{if(c&&!r)return wo;if(!h||h===wo||u.current!==e||m!=null){const d=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const S=f.node.current,C=S?new On(i(S),S):null;f.rect.current=C,C&&d.set(f.id,C)}return d}return h},[e,m,r,c,i]);return b.useEffect(()=>{u.current=e},[e]),b.useEffect(()=>{c||x()},[r,c]),b.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),b.useEffect(()=>{c||typeof n!="number"||_.current!==null||(_.current=setTimeout(()=>{x(),_.current=null},n))},[n,c,x,...o]),{droppableRects:w,measureDroppableContainers:x,measuringScheduled:m!=null};function a(){switch(l){case vr.Always:return!1;case vr.BeforeDragging:return r;default:return!r}}}function zn(e,s){return yr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Th(e,s){return zn(e,s)}function Mh(e){let{callback:s,disabled:r}=e;const o=fi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function pi(e){let{callback:s,disabled:r}=e;const o=fi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function Dh(e){return new On(Sr(e),e)}function Co(e,s,r){s===void 0&&(s=Dh);const[o,p]=b.useState(null);function m(){p(i=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=i??r)!=null?l:null}const u=s(e);return JSON.stringify(i)===JSON.stringify(u)?i:u})}const v=Mh({callback(i){if(e)for(const l of i){const{type:u,target:c}=l;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),n=pi({callback:m});return ts(()=>{m(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function Ph(e){const s=zn(e);return dl(e,s)}const ko=[];function Lh(e){const s=b.useRef(e),r=yr(o=>e?o&&o!==ko&&e&&s.current&&e.parentNode===s.current.parentNode?o:In(e):ko,[e]);return b.useEffect(()=>{s.current=e},[e]),r}function Ih(e){const[s,r]=b.useState(null),o=b.useRef(e),p=b.useCallback(m=>{const v=Ti(m.target);v&&r(n=>n?(n.set(v,tn(v)),new Map(n)):null)},[]);return b.useEffect(()=>{const m=o.current;if(e!==m){v(m);const n=e.map(i=>{const l=Ti(i);return l?(l.addEventListener("scroll",p,{passive:!0}),[l,tn(l)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{v(e),v(m)};function v(n){n.forEach(i=>{const l=Ti(i);l?.removeEventListener("scroll",p)})}},[p,e]),b.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>zs(m,v),Ft):vl(e):Ft,[e,s])}function Eo(e,s){s===void 0&&(s=[]);const r=b.useRef(null);return b.useEffect(()=>{r.current=null},s),b.useEffect(()=>{const o=e!==Ft;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Jr(e,r.current):Ft}function Oh(e){b.useEffect(()=>{if(!hi)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function Bh(e,s){return b.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=v=>{m(v,s)},r},{}),[e,s])}function yl(e){return b.useMemo(()=>e?ch(e):null,[e])}const jo=[];function Fh(e,s){s===void 0&&(s=Sr);const[r]=e,o=yl(r?yt(r):null),[p,m]=b.useState(jo);function v(){m(()=>e.length?e.map(i=>pl(i)?o:new On(s(i),i)):jo)}const n=pi({callback:v});return ts(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),p}function Sl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return _r(s)?s:e}function zh(e){let{measure:s}=e;const[r,o]=b.useState(null),p=b.useCallback(l=>{for(const{target:u}of l)if(_r(u)){o(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=pi({callback:p}),v=b.useCallback(l=>{const u=Sl(l);m?.disconnect(),u&&m?.observe(u),o(u?s(u):null)},[s,m]),[n,i]=Qr(v);return b.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const Wh=[{sensor:Fn,options:{}},{sensor:_l,options:{}}],Hh={current:{}},$r={draggable:{measure:bo},droppable:{measure:bo,strategy:vr.WhileDragging,frequency:rn.Optimized},dragOverlay:{measure:Sr}};class ur extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const $h={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ur,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ti},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$r,measureDroppableContainers:ti,windowRect:null,measuringScheduled:!1},wl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ti,draggableNodes:new Map,over:null,measureDroppableContainers:ti},wr=b.createContext(wl),Cl=b.createContext($h);function Uh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ur}}}function qh(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new ur(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const v=new ur(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new ur(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function Kh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=b.useContext(wr),m=Zr(o),v=Zr(r?.id);return b.useEffect(()=>{if(!s&&!o&&m&&v!=null){if(!Ln(m)||document.activeElement===m.target)return;const n=p.get(v);if(!n)return;const{activatorNode:i,node:l}=n;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[i.current,l.current]){if(!u)continue;const c=Wu(u);if(c){c.focus();break}}})}},[o,s,p,v,m]),null}function kl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function Vh(e){return b.useMemo(()=>({draggable:{...$r.draggable,...e?.draggable},droppable:{...$r.droppable,...e?.droppable},dragOverlay:{...$r.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Xh(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=b.useRef(!1),{x:v,y:n}=typeof p=="boolean"?{x:p,y:p}:p;ts(()=>{if(!v&&!n||!s){m.current=!1;return}if(m.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const u=r(l),c=dl(u,o);if(v||(c.x=0),n||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=hl(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,n,o,r])}const gi=b.createContext({...Ft,scaleX:1,scaleY:1});var ns;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ns||(ns={}));const Yh=b.memo(function(s){var r,o,p,m;let{id:v,accessibility:n,autoScroll:i=!0,children:l,sensors:u=Wh,collisionDetection:c=rh,measuring:g,modifiers:x,..._}=s;const w=b.useReducer(qh,void 0,Uh),[a,h]=w,[d,f]=Vu(),[S,C]=b.useState(ns.Uninitialized),k=S===ns.Initialized,{draggable:{active:E,nodes:y,translate:j},droppable:{containers:R}}=a,L=E!=null?y.get(E):null,T=b.useRef({initial:null,translated:null}),D=b.useMemo(()=>{var se;return E!=null?{id:E,data:(se=L?.data)!=null?se:Hh,rect:T}:null},[E,L]),F=b.useRef(null),[I,H]=b.useState(null),[q,A]=b.useState(null),P=pr(_,Object.values(_)),M=mi("DndDescribedBy",v),O=b.useMemo(()=>R.getEnabled(),[R]),$=Vh(g),{droppableRects:K,measureDroppableContainers:B,measuringScheduled:z}=Ah(O,{dragging:k,dependencies:[j.x,j.y],config:$.droppable}),U=Nh(y,E),N=b.useMemo(()=>q?ei(q):null,[q]),W=Y(),X=Th(U,$.draggable.measure);Xh({activeNode:E!=null?y.get(E):null,config:W.layoutShiftCompensation,initialRect:X,measure:$.draggable.measure});const V=Co(U,$.draggable.measure,X),ie=Co(U?U.parentElement:null),ee=b.useRef({activatorEvent:null,active:null,activeNode:U,collisionRect:null,collisions:null,droppableRects:K,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),me=R.getNodeFor((r=ee.current.over)==null?void 0:r.id),he=zh({measure:$.dragOverlay.measure}),G=(o=he.nodeRef.current)!=null?o:U,pe=k?(p=he.rect)!=null?p:V:null,oe=!!(he.nodeRef.current&&he.rect),We=Ph(oe?null:V),ut=yl(G?yt(G):null),Oe=Lh(k?me??U:null),be=Fh(Oe),Ue=kl(x,{transform:{x:j.x-We.x,y:j.y-We.y,scaleX:1,scaleY:1},activatorEvent:q,active:D,activeNodeRect:V,containerNodeRect:ie,draggingNodeRect:pe,over:ee.current.over,overlayNodeRect:he.rect,scrollableAncestors:Oe,scrollableAncestorRects:be,windowRect:ut}),Be=N?zs(N,j):null,tt=Ih(Oe),Ye=Eo(tt),Ze=Eo(tt,[V]),Xe=zs(Ue,Ye),Ne=pe?oh(pe,Ue):null,Ae=D&&Ne?c({active:D,collisionRect:Ne,droppableRects:K,droppableContainers:O,pointerCoordinates:Be}):null,ve=th(Ae,"id"),[He,_e]=b.useState(null),pt=oe?Ue:zs(Ue,Ze),Je=ih(pt,(m=He?.rect)!=null?m:null,V),Lt=b.useRef(null),J=b.useCallback((se,ne)=>{let{sensor:ke,options:xe}=ne;if(F.current==null)return;const je=y.get(F.current);if(!je)return;const Te=se.nativeEvent,ye=new ke({active:F.current,activeNode:je,event:Te,options:xe,context:ee,onAbort(Se){if(!y.get(Se))return;const{onDragAbort:Qe}=P.current,rt={id:Se};Qe?.(rt),d({type:"onDragAbort",event:rt})},onPending(Se,De,Qe,rt){if(!y.get(Se))return;const{onDragPending:it}=P.current,nt={id:Se,constraint:De,initialCoordinates:Qe,offset:rt};it?.(nt),d({type:"onDragPending",event:nt})},onStart(Se){const De=F.current;if(De==null)return;const Qe=y.get(De);if(!Qe)return;const{onDragStart:rt}=P.current,Ct={activatorEvent:Te,active:{id:De,data:Qe.data,rect:T}};Ss.unstable_batchedUpdates(()=>{rt?.(Ct),C(ns.Initializing),h({type:ot.DragStart,initialCoordinates:Se,active:De}),d({type:"onDragStart",event:Ct}),H(Lt.current),A(Te)})},onMove(Se){h({type:ot.DragMove,coordinates:Se})},onEnd:Le(ot.DragEnd),onCancel:Le(ot.DragCancel)});Lt.current=ye;function Le(Se){return async function(){const{active:Qe,collisions:rt,over:Ct,scrollAdjustedTranslate:it}=ee.current;let nt=null;if(Qe&&it){const{cancelDrop:gt}=P.current;nt={activatorEvent:Te,active:Qe,collisions:rt,delta:it,over:Ct},Se===ot.DragEnd&&typeof gt=="function"&&await Promise.resolve(gt(nt))&&(Se=ot.DragCancel)}F.current=null,Ss.unstable_batchedUpdates(()=>{h({type:Se}),C(ns.Uninitialized),_e(null),H(null),A(null),Lt.current=null;const gt=Se===ot.DragEnd?"onDragEnd":"onDragCancel";if(nt){const Vt=P.current[gt];Vt?.(nt),d({type:gt,event:nt})}})}}},[y]),fe=b.useCallback((se,ne)=>(ke,xe)=>{const je=ke.nativeEvent,Te=y.get(xe);if(F.current!==null||!Te||je.dndKit||je.defaultPrevented)return;const ye={active:Te};se(ke,ne.options,ye)===!0&&(je.dndKit={capturedBy:ne.sensor},F.current=xe,J(ke,ne))},[y,J]),ue=Rh(u,fe);Oh(u),ts(()=>{V&&S===ns.Initializing&&C(ns.Initialized)},[V,S]),b.useEffect(()=>{const{onDragMove:se}=P.current,{active:ne,activatorEvent:ke,collisions:xe,over:je}=ee.current;if(!ne||!ke)return;const Te={active:ne,activatorEvent:ke,collisions:xe,delta:{x:Xe.x,y:Xe.y},over:je};Ss.unstable_batchedUpdates(()=>{se?.(Te),d({type:"onDragMove",event:Te})})},[Xe.x,Xe.y]),b.useEffect(()=>{const{active:se,activatorEvent:ne,collisions:ke,droppableContainers:xe,scrollAdjustedTranslate:je}=ee.current;if(!se||F.current==null||!ne||!je)return;const{onDragOver:Te}=P.current,ye=xe.get(ve),Le=ye&&ye.rect.current?{id:ye.id,rect:ye.rect.current,data:ye.data,disabled:ye.disabled}:null,Se={active:se,activatorEvent:ne,collisions:ke,delta:{x:je.x,y:je.y},over:Le};Ss.unstable_batchedUpdates(()=>{_e(Le),Te?.(Se),d({type:"onDragOver",event:Se})})},[ve]),ts(()=>{ee.current={activatorEvent:q,active:D,activeNode:U,collisionRect:Ne,collisions:Ae,droppableRects:K,draggableNodes:y,draggingNode:G,draggingNodeRect:pe,droppableContainers:R,over:He,scrollableAncestors:Oe,scrollAdjustedTranslate:Xe},T.current={initial:pe,translated:Ne}},[D,U,Ae,Ne,y,G,pe,K,R,He,Oe,Xe]),kh({...W,delta:j,draggingRect:Ne,pointerCoordinates:Be,scrollableAncestors:Oe,scrollableAncestorRects:be});const ge=b.useMemo(()=>({active:D,activeNode:U,activeNodeRect:V,activatorEvent:q,collisions:Ae,containerNodeRect:ie,dragOverlay:he,draggableNodes:y,droppableContainers:R,droppableRects:K,over:He,measureDroppableContainers:B,scrollableAncestors:Oe,scrollableAncestorRects:be,measuringConfiguration:$,measuringScheduled:z,windowRect:ut}),[D,U,V,q,Ae,ie,he,y,R,K,He,B,Oe,be,$,z,ut]),Ce=b.useMemo(()=>({activatorEvent:q,activators:ue,active:D,activeNodeRect:V,ariaDescribedById:{draggable:M},dispatch:h,draggableNodes:y,over:He,measureDroppableContainers:B}),[q,ue,D,V,h,M,y,He,B]);return le.createElement(cl.Provider,{value:f},le.createElement(wr.Provider,{value:Ce},le.createElement(Cl.Provider,{value:ge},le.createElement(gi.Provider,{value:Je},l)),le.createElement(Kh,{disabled:n?.restoreFocus===!1})),le.createElement(Gu,{...n,hiddenTextDescribedById:M}));function Y(){const se=I?.autoScrollEnabled===!1,ne=typeof i=="object"?i.enabled===!1:i===!1,ke=k&&!se&&!ne;return typeof i=="object"?{...i,enabled:ke}:{enabled:ke}}}),Gh=b.createContext(null),No="button",Qh="Draggable";function Zh(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=mi(Qh),{activators:v,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=b.useContext(wr),{role:x=No,roleDescription:_="draggable",tabIndex:w=0}=p??{},a=i?.id===s,h=b.useContext(a?gi:Gh),[d,f]=Qr(),[S,C]=Qr(),k=Bh(v,s),E=pr(r);ts(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:S,data:E}),()=>{const j=c.get(s);j&&j.key===m&&c.delete(s)}),[c,s]);const y=b.useMemo(()=>({role:x,tabIndex:w,"aria-disabled":o,"aria-pressed":a&&x===No?!0:void 0,"aria-roledescription":_,"aria-describedby":u.draggable}),[o,x,w,a,_,u.draggable]);return{active:i,activatorEvent:n,activeNodeRect:l,attributes:y,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:C,transform:h}}function Jh(){return b.useContext(Cl)}const ef="Droppable",tf={timeout:25};function sf(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=mi(ef),{active:v,dispatch:n,over:i,measureDroppableContainers:l}=b.useContext(wr),u=b.useRef({disabled:r}),c=b.useRef(!1),g=b.useRef(null),x=b.useRef(null),{disabled:_,updateMeasurementsFor:w,timeout:a}={...tf,...p},h=pr(w??o),d=b.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),x.current=null},a)},[a]),f=pi({callback:d,disabled:_||!v}),S=b.useCallback((y,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),y&&f.observe(y))},[f]),[C,k]=Qr(S),E=pr(s);return b.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),b.useEffect(()=>(n({type:ot.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:E}}),()=>n({type:ot.UnregisterDroppable,key:m,id:o})),[o]),b.useEffect(()=>{r!==u.current.disabled&&(n({type:ot.SetDroppableDisabled,id:o,key:m,disabled:r}),u.current.disabled=r)},[o,m,r,n]),{active:v,rect:g,isOver:i?.id===o,node:C,over:i,setNodeRef:k}}function rf(e){let{animation:s,children:r}=e;const[o,p]=b.useState(null),[m,v]=b.useState(null),n=Zr(r);return!r&&!o&&n&&p(n),ts(()=>{if(!m)return;const i=o?.key,l=o?.props.id;if(i==null||l==null){p(null);return}Promise.resolve(s(l,m)).then(()=>{p(null)})},[s,o,m]),le.createElement(le.Fragment,null,r,o?b.cloneElement(o,{ref:v}):null)}const nf={x:0,y:0,scaleX:1,scaleY:1};function of(e){let{children:s}=e;return le.createElement(wr.Provider,{value:wl},le.createElement(gi.Provider,{value:nf},s))}const af={position:"fixed",touchAction:"none"},lf=e=>Ln(e)?"transform 250ms ease":void 0,cf=b.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:v,rect:n,style:i,transform:l,transition:u=lf}=e;if(!n)return null;const c=p?l:{...l,scaleX:1,scaleY:1},g={...af,width:n.width,height:n.height,top:n.top,left:n.left,transform:gr.Transform.toString(c),transformOrigin:p&&o?Ju(o,n):void 0,transition:typeof u=="function"?u(o):u,...i};return le.createElement(r,{className:v,style:g,ref:s},m)}),df=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:v}=e;if(m!=null&&m.active)for(const[n,i]of Object.entries(m.active))i!==void 0&&(p[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(m!=null&&m.dragOverlay)for(const[n,i]of Object.entries(m.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[i,l]of Object.entries(p))r.node.style.setProperty(i,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},uf=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:gr.Transform.toString(s)},{transform:gr.Transform.toString(r)}]},hf={duration:250,easing:"ease",keyframes:uf,sideEffects:df({styles:{active:{opacity:"0"}}})};function ff(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return fi((m,v)=>{if(s===null)return;const n=r.get(m);if(!n)return;const i=n.node.current;if(!i)return;const l=Sl(v);if(!l)return;const{transform:u}=yt(v).getComputedStyle(v),c=ul(u);if(!c)return;const g=typeof s=="function"?s:mf(s);return xl(i,p.draggable.measure),g({active:{id:m,data:n.data,node:i,rect:p.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function mf(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...hf,...e};return m=>{let{active:v,dragOverlay:n,transform:i,...l}=m;if(!s)return;const u={x:n.rect.left-v.rect.left,y:n.rect.top-v.rect.top},c={scaleX:i.scaleX!==1?v.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?v.rect.height*i.scaleY/n.rect.height:1},g={x:i.x-u.x,y:i.y-u.y,...c},x=p({...l,active:v,dragOverlay:n,transform:{initial:i,final:g}}),[_]=x,w=x[x.length-1];if(JSON.stringify(_)===JSON.stringify(w))return;const a=o?.({active:v,dragOverlay:n,...l}),h=n.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let Ro=0;function pf(e){return b.useMemo(()=>{if(e!=null)return Ro++,Ro},[e])}const gf=le.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:v,wrapperElement:n="div",className:i,zIndex:l=999}=e;const{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:x,draggableNodes:_,droppableContainers:w,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:S,windowRect:C}=Jh(),k=b.useContext(gi),E=pf(c?.id),y=kl(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:x,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:S,transform:k,windowRect:C}),j=zn(g),R=ff({config:o,draggableNodes:_,droppableContainers:w,measuringConfiguration:d}),L=j?a.setRef:void 0;return le.createElement(of,null,le.createElement(rf,{animation:R},c&&E?le.createElement(cf,{key:E,id:c.id,ref:L,as:n,activatorEvent:u,adjustScale:s,className:i,transition:m,rect:j,style:{zIndex:l,...p},transform:y},r):null))}),El=768;function vf(e){const s=window.matchMedia(`(max-width: ${El-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function xf(){return window.innerWidth<El}function bf(){return!1}function jl(){return b.useSyncExternalStore(vf,xf,bf)}const _f=1500,yf=2e3,Sf=5e3;function Nl(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?_f:!1}function wf(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?yf:!1}function Cf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?Sf:!1}function Wn(e){return jt({queryKey:ce.workspaces.list(e),queryFn:()=>Ee.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Rl(e){const s=bt();return zt({mutationFn:r=>Ee.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ce.workspaces.list(e)}),s.invalidateQueries({queryKey:ce.tasks.all})}})}function Al(){const e=bt();return zt({mutationFn:({id:s,commitMessage:r,stopActiveServices:o})=>Ee.post(`/workspaces/${s}/merge`,{commitMessage:r,stopActiveServices:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all}),e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})},onError:()=>{e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})}})}function kf(){const e=bt();return zt({mutationFn:s=>Ee.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function Hn(){return zt({mutationFn:({workspaceId:e,editorType:s})=>Ee.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function $n(e,s={}){const r=Es(p=>p.visibleContext),o=wf(e,r);return jt({queryKey:ce.workspaces.gitStatus(e),queryFn:()=>Ee.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Tl(){const e=bt();return zt({mutationFn:s=>Ee.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function Un(){const e=bt();return zt({mutationFn:s=>Ee.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function Ef(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(v=>v.status===ct.RUNNING||v.status===ct.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function qn({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:v}){const{t:n}=ae(),{data:i,isLoading:l}=Wn(m===void 0&&e?o:""),u=m??i,c=m===void 0&&e&&l,g=b.useMemo(()=>Ef(u,n),[u,n]);return t.jsx(Sn,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((x,_)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:x})]},_))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||c})}const we={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},nn={[we.Review]:{label:"Review",icon:qa,iconClass:"text-warning",accentClass:"text-warning"},[we.Running]:{label:"Running",icon:Ua,iconClass:"text-info",accentClass:"text-info"},[we.Pending]:{label:"Pending",icon:$a,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[we.Done]:{label:"Done",icon:Ha,iconClass:"text-success/80",accentClass:"text-success"},[we.Cancelled]:{label:"Cancelled",icon:Wa,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},jf=[we.Review,we.Running,we.Pending,we.Done,we.Cancelled],Ml=b.createContext(null),Nf=3e4;function Rf(e=Nf){const[,s]=b.useState(0);b.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function Af(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?xt("{count}s ago",{count:s}):s<3600?xt("{count}m ago",{count:Math.floor(s/60)}):s<86400?xt("{count}h ago",{count:Math.floor(s/3600)}):xt("{count}d ago",{count:Math.floor(s/86400)})}function Tf({task:e,status:s,isSelected:r,project:o,onSelectTask:p,onTaskStatusChange:m,onDeleteTask:v,disableDrag:n}){const{t:i}=ae(),l=b.useContext(Ml),u=b.useRef(null),c=!!e.projectArchivedAt,g=c||!!n,{attributes:x,listeners:_,setNodeRef:w,isDragging:a}=Zh({id:e.id,data:{task:e,fromStatus:s},disabled:g}),h=b.useCallback(T=>{u.current=T,w(T),l&&(T?l.registry.set(e.id,T):l.registry.delete(e.id))},[w,l,e.id]);b.useEffect(()=>()=>{l?.registry.delete(e.id)},[e.id,l]);const[d,f]=b.useState(null),[S,C]=b.useState(!1),k=b.useRef(null),E=b.useRef(null),y=b.useCallback(T=>{c||!m&&!v||(T.preventDefault(),f({x:T.clientX,y:T.clientY}))},[c,m,v]),j=b.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),R=b.useCallback(T=>{if(!n||c||!m&&!v)return;const D=T.touches[0];if(!D)return;const{clientX:F,clientY:I}=D;E.current=setTimeout(()=>{E.current=null,f({x:F,y:I})},500)},[n,c,m,v]);b.useEffect(()=>{if(!d)return;const T=D=>{k.current&&!k.current.contains(D.target)&&f(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[d]);const L=o?o.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:h,onClick:()=>p(e.id),onContextMenu:y,onTouchStart:R,onTouchEnd:j,onTouchMove:j,title:L,"aria-label":L?`${e.title} — ${L}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
7
7
  ${a?"opacity-30":""}
8
- ${r?"bg-accent":"hover:bg-accent/50"}`,...g?{}:_,...g?{}:x,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:D}=rn[s];return t.jsx(T,{className:`${D} ${s===we.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:Rf(e.updatedAt)}),o&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${o.color.replace("text-","bg-")}`})]}),d&&t.jsxs("div",{ref:k,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:d.x,top:d.y},children:[m&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:i("Move to")}),Ef.filter(T=>T!==s).map(T=>{const{icon:D,label:F,accentClass:I}=rn[T];return t.jsxs("button",{onClick:()=>{m(e.id,T),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(D,{className:`w-3.5 h-3.5 ${I}`}),t.jsx("span",{className:"text-foreground/80",children:i(F)})]},T)})]}),v&&t.jsxs(t.Fragment,{children:[m&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{C(!0),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:i("Delete Task")})]})]})]}),t.jsx(Un,{isOpen:S,onClose:()=>C(!1),onConfirm:()=>{v?.(e.id),C(!1)},taskId:e.id,taskTitle:e.title})]})}const Tf=b.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:v,projects:n,isDragging:i,dragFromStatus:l,onTaskStatusChange:u,onDeleteTask:c,disableDrag:g}){const{t:x}=ae(),[_,w]=b.useState(p);Nf();const a=r.length===0,h=i&&l===o,d=i&&l!==o,{setNodeRef:f,isOver:S}=tf({id:`group-${o}`,data:{status:o}}),C=o===we.Review,k=x(s),E=i?h&&(_||!0):_;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!i&&w(y=>!y),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:k}),C&&!a?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:E?t.jsx(wt,{size:12}):t.jsx(Pt,{size:12})})]}),d&&t.jsx("div",{ref:f,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
8
+ ${r?"bg-accent":"hover:bg-accent/50"}`,...g?{}:_,...g?{}:x,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:D}=nn[s];return t.jsx(T,{className:`${D} ${s===we.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:Af(e.updatedAt)}),o&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${o.color.replace("text-","bg-")}`})]}),d&&t.jsxs("div",{ref:k,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:d.x,top:d.y},children:[m&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:i("Move to")}),jf.filter(T=>T!==s).map(T=>{const{icon:D,label:F,accentClass:I}=nn[T];return t.jsxs("button",{onClick:()=>{m(e.id,T),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(D,{className:`w-3.5 h-3.5 ${I}`}),t.jsx("span",{className:"text-foreground/80",children:i(F)})]},T)})]}),v&&t.jsxs(t.Fragment,{children:[m&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{C(!0),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:i("Delete Task")})]})]})]}),t.jsx(qn,{isOpen:S,onClose:()=>C(!1),onConfirm:()=>{v?.(e.id),C(!1)},taskId:e.id,taskTitle:e.title})]})}const Mf=b.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:v,projects:n,isDragging:i,dragFromStatus:l,onTaskStatusChange:u,onDeleteTask:c,disableDrag:g}){const{t:x}=ae(),[_,w]=b.useState(p);Rf();const a=r.length===0,h=i&&l===o,d=i&&l!==o,{setNodeRef:f,isOver:S}=sf({id:`group-${o}`,data:{status:o}}),C=o===we.Review,k=x(s),E=i?h&&(_||!0):_;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!i&&w(y=>!y),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:k}),C&&!a?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:E?t.jsx(wt,{size:12}):t.jsx(Pt,{size:12})})]}),d&&t.jsx("div",{ref:f,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
9
9
  ${S?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:S?x("Drop into {title}",{title:k}):x("Drop here")})}),E&&!d&&t.jsx("div",{ref:h?void 0:f,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
10
10
  ${S&&!h?"bg-info/10 ring-1 ring-info/30":""}
11
- ${a&&i?"border border-dashed border-border mx-2":""}`,children:a?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:x("No tasks")}):r.map(y=>{const j=m===y.id,R=y.projectId?n.find(L=>L.id===y.projectId):void 0;return t.jsx(Af,{task:y,status:o,isSelected:j,project:R,onSelectTask:v,onTaskStatusChange:y.projectArchivedAt?void 0:u,onDeleteTask:y.projectArchivedAt?void 0:c,disableDrag:g},y.id)})})]})}),Mf=12,Df=50;function Pf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ae(),[v,n]=b.useState(""),[i,l]=b.useState(0),u=b.useRef(null);b.useEffect(()=>{e&&(n(""),l(0))},[e]);const c=b.useMemo(()=>{const _=v.trim().toLowerCase();return _?r.filter(w=>w.title.toLowerCase().includes(_)).slice(0,Df):r.slice(0,Mf)},[r,v]);b.useEffect(()=>{l(0)},[v]),b.useEffect(()=>{u.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const g=b.useCallback(_=>{p(_),s()},[p,s]),x=b.useCallback(_=>{if(_.key==="Escape")_.preventDefault(),s();else if(_.key==="ArrowDown")_.preventDefault(),l(w=>Math.min(w+1,c.length-1));else if(_.key==="ArrowUp")_.preventDefault(),l(w=>Math.max(w-1,0));else if(_.key==="Enter"&&!_.nativeEvent.isComposing){_.preventDefault();const w=c[i];w&&g(w.id)}},[s,c,i,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(Sn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:_=>n(_.target.value),onKeyDown:x,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((_,w)=>{const a=o.find(f=>f.id===_.projectId),{icon:h,iconClass:d}=rn[_.status];return t.jsxs("button",{onClick:()=>g(_.id),onMouseEnter:()=>l(w),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
12
- ${w===i?"bg-accent":""}`,children:[t.jsx(h,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:_.title,children:_.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},_.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const Lf=260,If=220;function Of(e){const s={[we.Review]:[],[we.Running]:[],[we.Pending]:[],[we.Done]:[],[we.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const Bf=[{status:we.Review,title:"Review",defaultOpen:!0},{status:we.Running,title:"Running",defaultOpen:!0},{status:we.Pending,title:"Pending",defaultOpen:!1},{status:we.Done,title:"Done",defaultOpen:!1},{status:we.Cancelled,title:"Cancelled",defaultOpen:!1}];function Ro({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:v=320,onCreateTask:n,onCreateProject:i,isCreateActive:l,onTaskStatusChange:u,onDeleteTask:c}){const{t:g}=ae(),{preserveDesktopSearch:x}=Ra(),_=El(),[w,a]=b.useState(null),[h,d]=b.useState(null),[f,S]=b.useState(!1),C=b.useRef(new Map),k=b.useRef(new Set),E=b.useRef(new Map),y=b.useMemo(()=>({registry:C.current}),[]),j=b.useCallback(M=>{M.remove(),k.current.delete(M)},[]),R=p?e.filter(M=>M.projectId===p):e,L=b.useCallback((M,O)=>{const $=document.querySelector(`[data-task-group-status="${M}"]`);if(!$)return null;const B=($.querySelector("button")??$).getBoundingClientRect();return B.width===0||B.height===0?null:new DOMRect(B.left+8,B.bottom+4,O.width,O.height)},[]),T=b.useCallback((M,O,$,K=!1)=>{const B=document.createElement("div");B.setAttribute("aria-hidden","true"),B.innerHTML=$;const z=B.firstElementChild;z&&(z.style.cssText="",z.className=z.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),z.style.pointerEvents="none",z.style.width=`${M.width}px`,z.style.height=`${M.height}px`,z.style.margin="0",z.style.backgroundColor="var(--sidebar-accent)",z.style.borderRadius="0.375rem",z.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",z.style.opacity="0.96",z.style.transition="none",z.setAttribute("tabindex","-1")),Object.assign(B.style,{position:"fixed",left:`${M.left}px`,top:`${M.top}px`,width:`${M.width}px`,height:`${M.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(B),k.current.add(B);const U=O.left-M.left,N=O.top-M.top;B.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${U}px, ${N}px)`,opacity:K?.12:.96,offset:1}],{duration:K?If:Lf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>j(B),()=>j(B))},[j]);b.useLayoutEffect(()=>{const M=window.matchMedia("(prefers-reduced-motion: reduce)").matches,O=new Map;for(const $ of R){const K=C.current.get($.id);if(!K)continue;const B={status:$.status,rect:K.getBoundingClientRect(),html:K.outerHTML};if(O.set($.id,B),M)continue;const z=E.current.get($.id);if(!z||z.status===$.status)continue;const U=B.rect.left-z.rect.left,N=B.rect.top-z.rect.top;Math.abs(U)<1&&Math.abs(N)<1||T(z.rect,B.rect,z.html)}if(!M)for(const[$,K]of E.current){if(O.has($))continue;const B=R.find(U=>U.id===$);if(!B||B.status===K.status)continue;const z=L(B.status,K.rect);z&&T(K.rect,z,K.html,!0)}E.current=O},[R,T,L]),b.useEffect(()=>()=>{for(const M of k.current)M.remove();k.current.clear()},[]);const D=Qu(Gu(Bn,{activationConstraint:{distance:8}})),F=b.useCallback(M=>{const O=M.active.data.current?.task,$=M.active.data.current?.fromStatus;O&&a(O),$&&d($)},[]),I=b.useCallback(M=>{a(null),d(null);const{active:O,over:$}=M;if(!$)return;const K=O.data.current?.task,B=O.data.current?.fromStatus,z=$.data.current?.status;!K||!B||!z||K.projectArchivedAt||B!==z&&u?.(K.id,z)},[u]),A=!!!(p?s.find(M=>M.id===p)??null:null)?.archivedAt,P=Of(R);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[i&&t.jsxs("button",{onClick:i,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("New Project"),children:[t.jsx(Hd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("New Project")})]}),t.jsxs("button",{onClick:n,disabled:!A,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
13
- ${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:g(A?"New Task":"Deleted projects are read-only"),children:[t.jsx(Od,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("New Task")})]}),t.jsxs("button",{onClick:()=>S(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("Search"),children:[t.jsx(Sn,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("Search")})]}),t.jsxs(dd,{to:x("/conversations"),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("对话"),children:[t.jsx(ai,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("对话")})]})]}),R.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Hs,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:g("No tasks")}),A&&n?t.jsx("button",{onClick:n,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:g("New Task")}):null]}):t.jsx(Tl.Provider,{value:y,children:t.jsxs(Xh,{sensors:D,onDragStart:F,onDragEnd:I,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:Bf.map(({status:M,title:O,defaultOpen:$})=>t.jsx(Tf,{title:O,tasks:P[M],status:M,defaultOpen:$,selectedTaskId:r,onSelectTask:o,projects:s,isDragging:w!==null,dragFromStatus:h,onTaskStatusChange:u,onDeleteTask:c,disableDrag:_},M))}),t.jsx(pf,{dropAnimation:null,children:w?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:w.title,children:w.title})}):null})]})}),R.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:g("{count} tasks",{count:R.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:g("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:g("{count} tasks",{count:0})})}),t.jsx(Pf,{isOpen:f,onClose:()=>S(!1),tasks:R,projects:s,onSelectTask:o})]})}const Ff=10,zf=24,Ml=Ff*zf,Wf=8;function Hf(e,s=Ml){return e>s+Wf}function $f(e,s){return e.includes(s)?e:[...e,s]}function Uf(e,s){return e.filter(r=>r!==s)}function qf(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const gi=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function Ao(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Kf(e,s=[],r=[]){const o=new Set(r.filter(m=>gi.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!o.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,v)=>{const n=Ao(m.sortTime)-Ao(v.sortTime);return n!==0?n:m.order!==v.order?m.order-v.order:m.key.localeCompare(v.key)})}function Vf(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function Xf(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Yf(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const v=r[p];return v?`${v} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function Gf(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Qf({status:e}){const{t:s}=ae();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(Vf(e))})}function Zf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:v,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:l}=ae(),[u,c]=b.useState(Gf),g=b.useMemo(()=>e.filter(_=>gi.has(_.status)).sort((_,w)=>Date.parse(w.updatedAt??w.createdAt??"")-Date.parse(_.updatedAt??_.createdAt??"")),[e]);if(g.length===0)return null;const x=Yf(g,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(_=>!_),"aria-expanded":u,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:x})]}),u?t.jsx(wt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(tl,{size:15,className:"shrink-0 text-neutral-400"})]}),u&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(_=>{const w=s.get(_.memberId),a=r.get(_.workRequestId),h=!!(_.sessionId&&o),d=!!w,f=n===_.id,S=m&&v===_.memberId,C=a?.instruction??_.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:te("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>_.sessionId&&o?.(_.sessionId),onKeyDown:k=>{!h||!_.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(_.sessionId))},children:[t.jsx(Ut,{name:w?.name??l("Agent"),avatar:w?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:w?.name??l("Agent")}),t.jsx("span",{className:te("shrink-0",Xf(_.status)),children:t.jsx(Qf,{status:_.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),_.sessionId&&o?.(_.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:l("View log"),"aria-label":`${l("View log")} ${w?.name??l("Agent")}`,children:t.jsx(Ji,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(_.id)},onKeyDown:k=>k.stopPropagation(),disabled:S,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:l("Stop"),"aria-label":`${l("Stop")} ${w?.name??l("Agent")}`,children:t.jsx(Ws,{size:12})})]}),d&&f&&w&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:l("Stop running work?")}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:()=>p(w.id,!1),children:[t.jsx(Ws,{size:11}),t.jsx("span",{children:l(S?"Stopping":"Stop only")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:S,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(w.id,!0),children:[t.jsx(rl,{size:11}),t.jsx("span",{children:l(S?"Stopping":"Stop + clear queue")})]})]})]},_.id)})})]})}const nn=br(),Jf=240;let To=0;function em(e,s){return To+=1,{id:`pending-room-message-${Date.now()}-${To}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Dl(e){return"pendingStatus"in e}function tm(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function sm(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function on(e,s){if(s.length===0)return e;const r=new Set(s.map(sm));return e.split(`
11
+ ${a&&i?"border border-dashed border-border mx-2":""}`,children:a?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:x("No tasks")}):r.map(y=>{const j=m===y.id,R=y.projectId?n.find(L=>L.id===y.projectId):void 0;return t.jsx(Tf,{task:y,status:o,isSelected:j,project:R,onSelectTask:v,onTaskStatusChange:y.projectArchivedAt?void 0:u,onDeleteTask:y.projectArchivedAt?void 0:c,disableDrag:g},y.id)})})]})}),Df=12,Pf=50;function Lf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ae(),[v,n]=b.useState(""),[i,l]=b.useState(0),u=b.useRef(null);b.useEffect(()=>{e&&(n(""),l(0))},[e]);const c=b.useMemo(()=>{const _=v.trim().toLowerCase();return _?r.filter(w=>w.title.toLowerCase().includes(_)).slice(0,Pf):r.slice(0,Df)},[r,v]);b.useEffect(()=>{l(0)},[v]),b.useEffect(()=>{u.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const g=b.useCallback(_=>{p(_),s()},[p,s]),x=b.useCallback(_=>{if(_.key==="Escape")_.preventDefault(),s();else if(_.key==="ArrowDown")_.preventDefault(),l(w=>Math.min(w+1,c.length-1));else if(_.key==="ArrowUp")_.preventDefault(),l(w=>Math.max(w-1,0));else if(_.key==="Enter"&&!_.nativeEvent.isComposing){_.preventDefault();const w=c[i];w&&g(w.id)}},[s,c,i,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(wn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:_=>n(_.target.value),onKeyDown:x,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((_,w)=>{const a=o.find(f=>f.id===_.projectId),{icon:h,iconClass:d}=nn[_.status];return t.jsxs("button",{onClick:()=>g(_.id),onMouseEnter:()=>l(w),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
12
+ ${w===i?"bg-accent":""}`,children:[t.jsx(h,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:_.title,children:_.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},_.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const If=260,Of=220;function Bf(e){const s={[we.Review]:[],[we.Running]:[],[we.Pending]:[],[we.Done]:[],[we.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const Ff=[{status:we.Review,title:"Review",defaultOpen:!0},{status:we.Running,title:"Running",defaultOpen:!0},{status:we.Pending,title:"Pending",defaultOpen:!1},{status:we.Done,title:"Done",defaultOpen:!1},{status:we.Cancelled,title:"Cancelled",defaultOpen:!1}];function Ao({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:v=320,onCreateTask:n,onCreateProject:i,isCreateActive:l,onTaskStatusChange:u,onDeleteTask:c}){const{t:g}=ae(),{preserveDesktopSearch:x}=Aa(),_=jl(),[w,a]=b.useState(null),[h,d]=b.useState(null),[f,S]=b.useState(!1),C=b.useRef(new Map),k=b.useRef(new Set),E=b.useRef(new Map),y=b.useMemo(()=>({registry:C.current}),[]),j=b.useCallback(M=>{M.remove(),k.current.delete(M)},[]),R=p?e.filter(M=>M.projectId===p):e,L=b.useCallback((M,O)=>{const $=document.querySelector(`[data-task-group-status="${M}"]`);if(!$)return null;const B=($.querySelector("button")??$).getBoundingClientRect();return B.width===0||B.height===0?null:new DOMRect(B.left+8,B.bottom+4,O.width,O.height)},[]),T=b.useCallback((M,O,$,K=!1)=>{const B=document.createElement("div");B.setAttribute("aria-hidden","true"),B.innerHTML=$;const z=B.firstElementChild;z&&(z.style.cssText="",z.className=z.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),z.style.pointerEvents="none",z.style.width=`${M.width}px`,z.style.height=`${M.height}px`,z.style.margin="0",z.style.backgroundColor="var(--sidebar-accent)",z.style.borderRadius="0.375rem",z.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",z.style.opacity="0.96",z.style.transition="none",z.setAttribute("tabindex","-1")),Object.assign(B.style,{position:"fixed",left:`${M.left}px`,top:`${M.top}px`,width:`${M.width}px`,height:`${M.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(B),k.current.add(B);const U=O.left-M.left,N=O.top-M.top;B.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${U}px, ${N}px)`,opacity:K?.12:.96,offset:1}],{duration:K?Of:If,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>j(B),()=>j(B))},[j]);b.useLayoutEffect(()=>{const M=window.matchMedia("(prefers-reduced-motion: reduce)").matches,O=new Map;for(const $ of R){const K=C.current.get($.id);if(!K)continue;const B={status:$.status,rect:K.getBoundingClientRect(),html:K.outerHTML};if(O.set($.id,B),M)continue;const z=E.current.get($.id);if(!z||z.status===$.status)continue;const U=B.rect.left-z.rect.left,N=B.rect.top-z.rect.top;Math.abs(U)<1&&Math.abs(N)<1||T(z.rect,B.rect,z.html)}if(!M)for(const[$,K]of E.current){if(O.has($))continue;const B=R.find(U=>U.id===$);if(!B||B.status===K.status)continue;const z=L(B.status,K.rect);z&&T(K.rect,z,K.html,!0)}E.current=O},[R,T,L]),b.useEffect(()=>()=>{for(const M of k.current)M.remove();k.current.clear()},[]);const D=Zu(Qu(Fn,{activationConstraint:{distance:8}})),F=b.useCallback(M=>{const O=M.active.data.current?.task,$=M.active.data.current?.fromStatus;O&&a(O),$&&d($)},[]),I=b.useCallback(M=>{a(null),d(null);const{active:O,over:$}=M;if(!$)return;const K=O.data.current?.task,B=O.data.current?.fromStatus,z=$.data.current?.status;!K||!B||!z||K.projectArchivedAt||B!==z&&u?.(K.id,z)},[u]),A=!!!(p?s.find(M=>M.id===p)??null:null)?.archivedAt,P=Bf(R);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[i&&t.jsxs("button",{onClick:i,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("New Project"),children:[t.jsx($d,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("New Project")})]}),t.jsxs("button",{onClick:n,disabled:!A,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
13
+ ${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:g(A?"New Task":"Deleted projects are read-only"),children:[t.jsx(Bd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("New Task")})]}),t.jsxs("button",{onClick:()=>S(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("Search"),children:[t.jsx(wn,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("Search")})]}),t.jsxs(ud,{to:x("/conversations"),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("对话"),children:[t.jsx(li,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("对话")})]})]}),R.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx($s,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:g("No tasks")}),A&&n?t.jsx("button",{onClick:n,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:g("New Task")}):null]}):t.jsx(Ml.Provider,{value:y,children:t.jsxs(Yh,{sensors:D,onDragStart:F,onDragEnd:I,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:Ff.map(({status:M,title:O,defaultOpen:$})=>t.jsx(Mf,{title:O,tasks:P[M],status:M,defaultOpen:$,selectedTaskId:r,onSelectTask:o,projects:s,isDragging:w!==null,dragFromStatus:h,onTaskStatusChange:u,onDeleteTask:c,disableDrag:_},M))}),t.jsx(gf,{dropAnimation:null,children:w?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:w.title,children:w.title})}):null})]})}),R.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:g("{count} tasks",{count:R.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:g("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:g("{count} tasks",{count:0})})}),t.jsx(Lf,{isOpen:f,onClose:()=>S(!1),tasks:R,projects:s,onSelectTask:o})]})}const zf=10,Wf=24,Dl=zf*Wf,Hf=8;function $f(e,s=Dl){return e>s+Hf}function Uf(e,s){return e.includes(s)?e:[...e,s]}function qf(e,s){return e.filter(r=>r!==s)}function Kf(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const vi=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function To(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Vf(e,s=[],r=[]){const o=new Set(r.filter(m=>vi.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!o.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,v)=>{const n=To(m.sortTime)-To(v.sortTime);return n!==0?n:m.order!==v.order?m.order-v.order:m.key.localeCompare(v.key)})}function Xf(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function Yf(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Gf(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const v=r[p];return v?`${v} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function Qf(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Zf({status:e}){const{t:s}=ae();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(Xf(e))})}function Jf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:v,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:l}=ae(),[u,c]=b.useState(Qf),g=b.useMemo(()=>e.filter(_=>vi.has(_.status)).sort((_,w)=>Date.parse(w.updatedAt??w.createdAt??"")-Date.parse(_.updatedAt??_.createdAt??"")),[e]);if(g.length===0)return null;const x=Gf(g,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(_=>!_),"aria-expanded":u,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:x})]}),u?t.jsx(wt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(sl,{size:15,className:"shrink-0 text-neutral-400"})]}),u&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(_=>{const w=s.get(_.memberId),a=r.get(_.workRequestId),h=!!(_.sessionId&&o),d=!!w,f=n===_.id,S=m&&v===_.memberId,C=a?.instruction??_.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:te("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>_.sessionId&&o?.(_.sessionId),onKeyDown:k=>{!h||!_.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(_.sessionId))},children:[t.jsx(Ut,{name:w?.name??l("Agent"),avatar:w?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:w?.name??l("Agent")}),t.jsx("span",{className:te("shrink-0",Yf(_.status)),children:t.jsx(Zf,{status:_.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),_.sessionId&&o?.(_.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:l("View log"),"aria-label":`${l("View log")} ${w?.name??l("Agent")}`,children:t.jsx(en,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(_.id)},onKeyDown:k=>k.stopPropagation(),disabled:S,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:l("Stop"),"aria-label":`${l("Stop")} ${w?.name??l("Agent")}`,children:t.jsx(Ws,{size:12})})]}),d&&f&&w&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:l("Stop running work?")}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:()=>p(w.id,!1),children:[t.jsx(Ws,{size:11}),t.jsx("span",{children:l(S?"Stopping":"Stop only")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:S,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(w.id,!0),children:[t.jsx(il,{size:11}),t.jsx("span",{children:l(S?"Stopping":"Stop + clear queue")})]})]})]},_.id)})})]})}const on=br(),em=240;let Mo=0;function tm(e,s){return Mo+=1,{id:`pending-room-message-${Date.now()}-${Mo}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Pl(e){return"pendingStatus"in e}function sm(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function rm(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function an(e,s){if(s.length===0)return e;const r=new Set(s.map(rm));return e.split(`
14
14
  `).map(o=>{const p=o.match(/^\s*/)?.[0]??"",m=o.trimStart();for(const v of r){if(m===v)return null;if(m.startsWith(`${v} `)||m.startsWith(`${v} `))return`${p}${m.slice(v.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
15
15
  `).replace(/\n{3,}/g,`
16
16
 
17
- `).trim()}function rm(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function an(e,s){return e instanceof Error?e.message:s}function im(e,s=Jf){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function nm(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function om(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function Mo(e){return e.membershipStatus!=="REMOVED"}function am(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function lm(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function cm(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(v=>am(v,s)).filter(v=>v&&!o.includes(`@${v}`));if(p.length===0)return o;const m=p.map(v=>`@${v}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${m}`:m}function dm(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function um({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:v}){const n=b.useMemo(()=>m||v?Rd(e):e,[e,v,m]),i=Ad(n),l=b.useMemo(()=>Td({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:v}),[v,p,m,o,r]);return t.jsx("div",{className:te("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(_n,{components:l,plugins:i,controls:i?Md:void 0,children:n})})}function hm({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(v=>v.mimeType.startsWith("image/")),m=new Map(p.map((v,n)=>[v.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const n=`${nn}${v.url}`;if(v.mimeType.startsWith("image/")){const l=m.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,l),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:n,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(Oa,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:tm(v.sizeBytes)})]}),t.jsx(gn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function fm({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i,onOpenVisualization:l,downloadSessionId:u}){const c=b.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:g=[],isLoading:x}=Nd(c),_=g.length>0?on(s,g):s;return t.jsxs(t.Fragment,{children:[_.trim()&&t.jsx(gm,{message:e,content:_,attachments:g,isUser:o,tone:p,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i,onOpenVisualization:l,downloadSessionId:u}),t.jsx(hm,{hasAttachmentIds:c.length>0,attachments:g,isLoading:x,onOpenImage:m})]})}function mm({images:e,index:s,onClose:r,onSelect:o}){const p=e[s];if(!p)return null;const m=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(qt,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(tu,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${nn}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${nn}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(gn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Pt,{size:24,"aria-hidden":!0})})]})}function pm({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const m=[e.trim(),s].filter(Boolean).join(`
17
+ `).trim()}function im(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ln(e,s){return e instanceof Error?e.message:s}function nm(e,s=em){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function om(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function am(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function Do(e){return e.membershipStatus!=="REMOVED"}function lm(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function cm(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function dm(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(v=>lm(v,s)).filter(v=>v&&!o.includes(`@${v}`));if(p.length===0)return o;const m=p.map(v=>`@${v}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${m}`:m}function um(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function hm({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:v}){const n=b.useMemo(()=>m||v?Ad(e):e,[e,v,m]),i=Td(n),l=b.useMemo(()=>Md({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:v}),[v,p,m,o,r]);return t.jsx("div",{className:te("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(yn,{components:l,plugins:i,controls:i?Dd:void 0,children:n})})}function fm({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(v=>v.mimeType.startsWith("image/")),m=new Map(p.map((v,n)=>[v.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const n=`${on}${v.url}`;if(v.mimeType.startsWith("image/")){const l=m.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,l),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:n,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(Ba,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:sm(v.sizeBytes)})]}),t.jsx(vn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function mm({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i,onOpenVisualization:l,downloadSessionId:u}){const c=b.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:g=[],isLoading:x}=Rd(c),_=g.length>0?an(s,g):s;return t.jsxs(t.Fragment,{children:[_.trim()&&t.jsx(vm,{message:e,content:_,attachments:g,isUser:o,tone:p,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i,onOpenVisualization:l,downloadSessionId:u}),t.jsx(fm,{hasAttachmentIds:c.length>0,attachments:g,isLoading:x,onOpenImage:m})]})}function pm({images:e,index:s,onClose:r,onSelect:o}){const p=e[s];if(!p)return null;const m=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(qt,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(su,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${on}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${on}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(vn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Pt,{size:24,"aria-hidden":!0})})]})}function gm({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const m=[e.trim(),s].filter(Boolean).join(`
18
18
 
19
- `);return m?{content:m,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function gm({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent",workingDir:m,onOpenWorkspaceFile:v,onOpenPreviewUrl:n,onOpenVisualization:i,downloadSessionId:l}){const{t:u}=ae(),c=b.useId(),g=b.useRef(null),[x,_]=b.useState(null),[w,a]=b.useState(!1),[h,d]=b.useState(null),f=hd(e.teamRunId,e.id,!1),S=f.data?.content,C=S?on(S,r):void 0,E=!!(C&&C!==s)?C:s,y=!!(e.isTruncated&&!Dl(e)),j=x?.messageId===e.id&&x.content===E&&x.expanded,R=b.useCallback(()=>{const I=g.current;I&&a(Hf(I.scrollHeight))},[]);b.useLayoutEffect(()=>{R();const I=g.current;if(!I)return;const H=window.requestAnimationFrame(R),q=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return q?.observe(I),window.addEventListener("resize",R),()=>{window.cancelAnimationFrame(H),q?.disconnect(),window.removeEventListener("resize",R)}},[E,R]);const L=b.useCallback(async()=>{if(d(null),j){_({messageId:e.id,content:E,expanded:!1});return}if(y&&!S){const I=await f.refetch();if(I.error){d(an(I.error,u("Failed to load full message")));return}const H=I.data?.content?on(I.data.content,r):E;_({messageId:e.id,content:H,expanded:!0});return}_({messageId:e.id,content:E,expanded:!0})},[r,y,S,f,j,e.id,E,u]),T=(w||y)&&!j,D=w||y,F=f.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:c,ref:g,onLoadCapture:R,className:te("relative transition-[max-height] duration-200 ease-out",T?"overflow-hidden":""),style:T?{maxHeight:Ml}:void 0,children:[t.jsx(um,{content:E,isUser:o,workingDir:m,onOpenWorkspaceFile:v,onOpenPreviewUrl:n,onOpenVisualization:i,downloadSessionId:l}),T&&t.jsx("div",{className:te("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),D&&t.jsxs("button",{type:"button","aria-expanded":j,"aria-controls":c,"aria-label":u(j?"Collapse message":"Expand full message"),disabled:F,onClick:()=>{L()},className:te("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",F?"cursor-wait opacity-70":""),children:[j?t.jsx(tl,{size:13}):t.jsx(wt,{size:13}),t.jsx("span",{children:u(F?"Loading":j?"Collapse message":"Expand full message")})]}),h&&t.jsx("div",{className:te("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:h})]})}function Pl({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:v,bubbleClassName:n,isPending:i}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:te("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Ut,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:te("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:te("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:rm(r)}),v]}),t.jsx("div",{className:te("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",n,i?"opacity-70":""),children:m})]}),o&&t.jsx(Ut,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function vm({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(li,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function xm({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l,onOpenVisualization:u,previewWorkspaceId:c,previewSessionId:g}){const{t:x}=ae(),_=e.senderType==="user",w=e.senderType==="system",a=Dl(e)?e.pendingStatus:null,h=e.mentions??[],d=e.workRequestIds?.length??0,f=e.visibility==="PRIVATE",S=b.useCallback(y=>{l?.(y,c)},[l,c]),C=b.useCallback(y=>{g&&u?.(g,y,c)},[u,g,c]),k=f?lm(e,p):[],E=t.jsxs(t.Fragment,{children:[!_&&!w&&o&&t.jsx(vm,{provider:o}),f&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:k.join(", "),children:[t.jsx(ud,{size:10}),t.jsxs("span",{className:"truncate",children:[x("Private"),k.length>0?`: ${k.join(", ")}`:""]})]}),!w&&d>0&&h.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[x("Work requests"),": ",d]}),a==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:x("发送中...")}),a==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:x("发送失败")})]});return t.jsx(Pl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:_,isSystem:w,headerAddon:E,bubbleClassName:_&&a==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:a==="sending",children:t.jsx(fm,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:_&&a!=="failed",tone:w?"system":void 0,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l?S:void 0,onOpenVisualization:u&&g?C:void 0,downloadSessionId:g})})}function bm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:n}=ae();return t.jsx(Pl,{senderName:s?.name??n("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(cs,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??im(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Kt,{size:12}),t.jsx("span",{children:n(m?"Approving":"Approve")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(qt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function Ll({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:n,centered:i,workingDir:l,onOpenWorkspaceFile:u,onOpenPreviewUrl:c,onOpenVisualization:g}){const{t:x}=ae(),_=Aa(e.id),w=Ta(e.id),a=Ma(e.id),[h,d]=b.useState(""),[f,S]=b.useState(!1),[C,k]=b.useState(null),[E,y]=b.useState(0),[j,R]=b.useState([]),[L,T]=b.useState(!1),[D,F]=b.useState(null),[I,H]=b.useState([]),[q,A]=b.useState(null),P=b.useRef(null),M=b.useRef(null),{files:O,addFiles:$,removeFile:K,clear:B,restoreFiles:z,buildMarkdownLinks:U,getDoneAttachments:N,isUploading:W}=xn(),X=O.some(Y=>Y.status==="done"&&Y.attachment),[V,ie]=b.useState(null),{scrollRef:ee,contentRef:me,isAtBottom:he,scrollToBottom:G}=wn({resize:"smooth",initial:"instant"}),pe=b.useRef(!1),oe=b.useRef(null);b.useEffect(()=>{const Y=ee.current;if(!Y)return;const se=ne=>{if(ne.deltaY<0){pe.current=!0;return}ne.deltaY>0&&Y.scrollHeight-Y.scrollTop-Y.clientHeight<=70&&(pe.current=!1)};return Y.addEventListener("wheel",se,{passive:!0}),()=>Y.removeEventListener("wheel",se)},[ee]);const{data:We}=Ks(),ut=b.useMemo(()=>{const Y=new Map;for(const se of We??[])Y.set(se.provider.id,se.provider);return Y},[We]),Oe=b.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),be=b.useMemo(()=>(e.members??[]).filter(Mo),[e.members]),Ue=b.useMemo(()=>new Map((e.invocations??[]).map(Y=>[Y.id,Y])),[e.invocations]),Be=b.useMemo(()=>{const Y=new Set(s.map(ne=>ne.id)),se=I.filter(ne=>!Y.has(ne.id));return[...s,...se].sort((ne,ke)=>{const xe=Date.parse(ne.createdAt??""),je=Date.parse(ke.createdAt??"");return(Number.isNaN(xe)?0:xe)-(Number.isNaN(je)?0:je)})},[s,I]),tt=b.useMemo(()=>new Map((e.workRequests??[]).map(Y=>[Y.id,Y])),[e.workRequests]),Ye=b.useMemo(()=>Kf(Be,e.workRequests??[],e.invocations??[]),[Be,e.invocations,e.workRequests]);b.useEffect(()=>{const Y=Ye.at(-1)?.key??null,se=oe.current;oe.current=Y,!(se==null||Y==null||Y===se||pe.current)&&requestAnimationFrame(()=>{G({animation:"smooth",ignoreEscapes:!0})})},[G,Ye]);const Ze=b.useMemo(()=>(e.invocations??[]).filter(Y=>gi.has(Y.status)),[e.invocations]),Xe=b.useMemo(()=>j.map(Y=>Oe.get(Y)).filter(Y=>!!Y).filter(Mo),[Oe,j]),Ne=b.useMemo(()=>{const Y=C?.query??"";return be.filter(se=>om(se,Y)).sort((se,ne)=>{const ke=j.includes(se.id),xe=j.includes(ne.id);return ke!==xe?ke?1:-1:se.name.localeCompare(ne.name)})},[be,C?.query,j]),Ae=!r&&(f||!!C)&&Ne.length>0,ve=b.useCallback((Y,se)=>{if(se==null){k(null);return}k(nm(Y,se)),y(0)},[]),He=b.useCallback(Y=>{R(je=>$f(je,Y.id));const se=`@${Y.name} `;if(C){const je=`${h.slice(0,C.start)}${se}${h.slice(C.end)}`,Te=C.start+se.length;d(je),k(null),S(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(Te,Te)});return}const ne=h.length===0||/\s$/.test(h)?"":" ",ke=`${h}${ne}${se}`,xe=ke.length;d(ke),S(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(xe,xe)})},[h,C]),_e=b.useCallback(Y=>{R(se=>Uf(se,Y))},[]),pt=b.useCallback(Y=>{const se=Y.target.value;d(se),F(null);const ne=Y.target;ne.style.height="auto",ne.style.height=`${Math.max(n?40:72,Math.min(ne.scrollHeight,n?140:240))}px`,S(!1),ve(se,ne.selectionStart)},[n,ve]),Je=b.useCallback(Y=>{const se=Y.target.files;se&&se.length>0&&($(Array.from(se)),F(null)),Y.target.value=""},[$]),Lt=b.useCallback(Y=>{const se=[];for(const ne of Y.clipboardData.items)if(ne.kind==="file"){const ke=ne.getAsFile();ke&&se.push(ke)}se.length>0&&(Y.preventDefault(),$(se),F(null))},[$]),J=b.useCallback(async()=>{if(r||L||W)return;const Y=U(),se=N().map(Le=>Le.id),ne=qf(j,be),ke=pm({draft:h,attachmentMarkdown:Y,attachmentIds:se,mentions:ne});if(!ke||!h.trim()&&!X)return;const xe=em(e.id,ke),je=h,Te=j,ye=O;H(Le=>[...Le,xe]),d(""),R([]),S(!1),k(null),B(),P.current&&(P.current.style.height=n?"40px":"72px"),requestAnimationFrame(()=>G()),T(!0),F(null);try{const Le=await p(ke);H(Se=>Se.filter(De=>De.id!==xe.id)),Le&&typeof Le=="object"&&"id"in Le&&requestAnimationFrame(()=>G())}catch(Le){const Se=Le instanceof Error?Le.message:"Failed to send room message";H(De=>De.map(Qe=>Qe.id===xe.id?{...Qe,pendingStatus:"failed",error:Se}:Qe)),d(De=>De.length===0?je:De),R(De=>De.length===0?Te:De),z(ye),F(Se),requestAnimationFrame(()=>G())}finally{T(!1)}},[be,O,U,B,n,h,N,X,L,W,p,r,z,G,j,e.id]),fe=b.useCallback(Y=>{const se=Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229;if(Ae){if(Y.key==="ArrowDown"){Y.preventDefault(),y(ne=>(ne+1)%Ne.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),y(ne=>(ne-1+Ne.length)%Ne.length);return}if(Y.key==="Enter"&&!se||Y.key==="Tab"){Y.preventDefault();const ne=Ne[E]??Ne[0];ne&&He(ne);return}if(Y.key==="Escape"){Y.preventDefault(),k(null),S(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!se&&(Y.preventDefault(),J())},[He,J,E,Ne,Ae]);b.useEffect(()=>{d(""),R([]),S(!1),k(null),F(null),H([]),B(),pe.current=!1,oe.current=null,A(null),P.current&&(P.current.style.height=n?"40px":"72px")},[B,n,e.id]);const ue=_.isError?_.error:w.isError?w.error:null,ge=_.isPending||w.isPending,Ce=b.useCallback((Y,se)=>{a.mutate({memberId:Y,cancelQueued:se},{onSuccess:()=>A(null)})},[a]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[V&&t.jsx(mm,{images:V.images,index:V.index,onClose:()=>ie(null),onSelect:Y=>ie(se=>se&&{...se,index:Y})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:ee,className:te("h-full overflow-y-auto scrollbar-app-thin bg-white",n?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:me,className:te(n?"space-y-2.5":"space-y-3",i&&"max-w-4xl mx-auto"),children:[Ye.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(Cs,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:x("No room messages yet")})]}):Ye.map(Y=>{if(Y.kind==="pendingApproval"){const Se=Y.request,De=Oe.get(Se.targetMemberId),Qe=_.isPending&&_.variables===Se.id,rt=w.isPending&&w.variables===Se.id;return t.jsx(bm,{request:Se,member:De,onApprove:()=>_.mutate(Se.id),onReject:()=>w.mutate(Se.id),isActionPending:ge,isApprovePending:Qe,isRejectPending:rt},Y.key)}const se=Y.message,ne=dm(se,Oe,Ue),ke=se.senderType==="user"?x("你"):se.senderType==="system"?x("System"):ne?.name??x("Agent"),xe=cm(se,Oe),je=ne?.providerId?ut.get(ne.providerId)??null:null,Te=se.senderInvocationId?Ue.get(se.senderInvocationId):void 0,ye=Te?.workspaceId??void 0,Le=Te?.sessionId??void 0;return t.jsx(xm,{message:se,senderName:ke,senderMember:ne,senderProvider:je,memberById:Oe,displayContent:xe,onOpenImage:(Se,De)=>ie({images:Se,index:De}),workingDir:l,onOpenWorkspaceFile:u,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:ye,previewSessionId:Le},Y.key)}),ue&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:an(ue,x("Failed to update work request"))}),a.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:an(a.error,x("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>G(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(mr,{size:14}),t.jsx("span",{children:x("Back to bottom")})]})]}),t.jsx("div",{className:te("shrink-0 border-t border-transparent bg-white",n?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:te(i&&"max-w-4xl mx-auto"),children:[t.jsx(Zf,{invocations:Ze,memberById:Oe,workRequestById:tt,onViewInvocationSession:m,onStopMember:Ce,isStopPending:a.isPending,stoppingMemberId:a.variables?.memberId??null,stopPromptInvocationId:q,onToggleStopConfirm:Y=>A(se=>se===Y?null:Y)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??x("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ae&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:x(C?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Ne.map((Y,se)=>{const ne=j.includes(Y.id),ke=se===E;return t.jsxs("button",{type:"button",onMouseEnter:()=>y(se),onMouseDown:xe=>{xe.preventDefault(),He(Y)},className:te("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ke?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ut,{name:Y.name,avatar:Y.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:Y.name}),ne&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:x("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[Y.providerId,Y.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(co,{size:15,className:"text-neutral-400"})]},Y.id)})})]}),Xe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Xe.map(Y=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",Y.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Y.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>_e(Y.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:x("Remove mention"),"aria-label":`${x("Remove mention")} ${Y.name}`,children:t.jsx(qt,{size:12})})]},Y.id))}),t.jsx(bn,{files:O,onRemove:K}),t.jsx("textarea",{ref:P,value:h,rows:n?1:void 0,onChange:pt,onKeyDown:fe,onPaste:Lt,onClick:Y=>ve(h,Y.currentTarget.selectionStart),onSelect:Y=>ve(h,Y.currentTarget.selectionStart),placeholder:x("Message the team room..."),className:te("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",n?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:n?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:te("flex items-center justify-between",n?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Je}),t.jsx("button",{type:"button",onClick:()=>M.current?.click(),title:x("Upload file"),"aria-label":x("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(Nn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{S(Y=>!Y),k(null),requestAnimationFrame(()=>P.current?.focus())},disabled:Xe.length===0&&be.length===0,title:x("Mention members"),"aria-label":x("Mention members"),className:te("rounded-lg transition-colors",n?"p-1.5":"p-2",f?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Xe.length===0&&be.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(co,{size:n?15:18})}),Xe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Xe.length," ",x("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{J()},disabled:r||L||W||!h.trim()&&!X,title:x(W?"Uploading...":L?"发送中...":"发送"),"aria-label":x(W?"Uploading...":L?"发送中...":"发送"),className:te("rounded-lg transition-all duration-200",n?"p-1.5":"p-2",(h.trim()||X)&&!r&&!L&&!W?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",L||W?"opacity-70":""),children:t.jsx(Cn,{size:n?15:18})})]}),D&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:D})]})]})})]})}function _m(e){return e?e.slice(0,8):""}function Do(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function qn(e){return e?.workspaceKind===_t.MAIN_DIRECTORY}function qs(e){return e?qn(e)?"Project directory":e.branchName:"—"}function ds(e){return e?.workingDir||e?.worktreePath||void 0}function Kn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),o=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const v=m.parentWorkspaceId?o.get(m.parentWorkspaceId):void 0,n=m.ownerMemberId?r.get(m.ownerMemberId):void 0,i=!!(p&&m.id===p),l=i?"main":m.parentWorkspaceId?"child":"root",u=n?.name??(m.ownerMemberId?`Member ${_m(m.ownerMemberId)}`:void 0),c=qn(m)?"Project directory":i?"Main workspace":l==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:l,roleLabel:i?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:v?qs(v):void 0,isMain:i}}).sort((m,v)=>{const n=l=>l.kind==="main"?0:l.kind==="child"?1:2,i=n(m)-n(v);return i!==0?i:Do(m.workspace.createdAt)-Do(v.workspace.createdAt)})}function Il(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===Mt.ACTIVE)?.id??e[0]?.id}function Ol(e,s){return!e||e.status!==Mt.ACTIVE||qn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Bl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Vn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},ym=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],Fl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Sm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],zl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],wm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function ir(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Vn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Ps(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Vn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Di(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Vn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Cm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function km(e){return{name:e.name.trim(),aliases:Cm(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function Po(e,s){return e instanceof Error?e.message:s}function Lo(e){return e.membershipStatus!=="REMOVED"}function ln(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Io(e){return ln(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Oo(e){return Fl.find(s=>s.value===e)?.label??e}function Em(e){return zl.find(s=>s.value===e)?.label??e}function Ht({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Bo({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function jm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ae(),{data:p=[]}=fd(),{data:m=[]}=Ks(),v=md(r.id),n=pd(r.id),i=gd(r.id),l=b.useRef(!1),[u,c]=b.useState("edit"),[g,x]=b.useState(null),[_,w]=b.useState(""),[a,h]=b.useState(ir()),[d,f]=b.useState(null),[S,C]=b.useState(null),k=r.members??[],E=b.useMemo(()=>k.filter(Lo),[k]),y=b.useMemo(()=>S&&Lo(S)&&!E.some(U=>U.id===S.id)?[...E,S]:E,[S,E]),j=g?E.find(U=>U.id===g)??null:null,R=S?.id===g?S:j,L=_?p.find(U=>U.id===_)??null:null,T=v.isPending||n.isPending||i.isPending,D=y.filter(ln).length,F=b.useMemo(()=>{const U=m.map(({provider:N,availability:W})=>({value:N.id,label:N.name+(W.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(li,{agentType:N.agentType,className:"size-4"}),disabled:W.type==="NOT_FOUND"}));return a.providerId&&!U.some(N=>N.value===a.providerId)&&U.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),U},[a.providerId,m,o]);b.useEffect(()=>{if(!e){l.current=!1,C(null);return}if(l.current)return;l.current=!0;const U=y[0]??null;c(U?"edit":"add-preset"),x(U?.id??null),w(""),h(U?Ps(U):ir()),f(null)},[y,e]),b.useEffect(()=>{S&&E.some(U=>U.id===S.id)&&C(null)},[S,E]),b.useEffect(()=>{u==="add-preset"&&L&&h(Di(L))},[u,L]);const I=(U,N)=>{h(W=>({...W,[U]:N}))},H=(U,N)=>{h(W=>({...W,capabilities:{...W.capabilities,[U]:N}}))},q=U=>{c("edit"),x(U.id),w(""),h(Ps(U))},A=()=>{c("add-preset"),x(null);const U=L??p[0]??null;w(U?.id??""),h(U?Di(U):ir())},P=()=>{c("add-custom"),x(null),w(""),h(ir())},M=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),O=u==="add-preset"?!!_:u==="edit"?!!(R&&M):M,$=async()=>{try{if(u==="add-preset"){if(!_)return;const N=await v.mutateAsync({memberPresetId:_});st.success(o("Member added")),C(N),c("edit"),x(N.id),w(""),h(Ps(N));return}const U=km(a);if(!U.name||!U.providerId||!U.rolePrompt){st.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:U});st.success(o("Member added")),C(N),c("edit"),x(N.id),h(Ps(N));return}if(R){const N=await n.mutateAsync({memberId:R.id,data:U});st.success(o("Member updated")),C(W=>W?.id===N.id?N:W),x(N.id),h(Ps(N))}}catch(U){st.error(Po(U,o("Failed to save member")))}},K=async()=>{if(d)try{if(await i.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const U=y.find(N=>N.id!==d.id)??null;x(U?.id??null),c(U?"edit":"add-preset"),h(U?Ps(U):ir())}C(U=>U?.id===d.id?null:U),f(null),st.success(o("Member removed"))}catch(U){st.error(Po(U,o("Failed to remove member")))}},B=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Or,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(po,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(Bo,{icon:t.jsx(Or,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(ls,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(U=>{const N=_===U.id;return t.jsxs("button",{type:"button",onClick:()=>{w(U.id),h(Di(U))},className:te("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Ut,{name:U.name,avatar:U.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:U.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:U.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(Oo(U.workspacePolicy))," · ",o(Em(U.sessionPolicy))]})]}),N?t.jsx(Kt,{size:16,className:"shrink-0 text-neutral-900"}):null]},U.id)})})})]}),z=()=>{const U=u==="edit";return U&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Bo,{icon:t.jsx(Cs,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(ls,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[U?t.jsx(nl,{size:15,className:"text-neutral-500"}):t.jsx(ls,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(U?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(U?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),U&&R?t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:()=>f(R),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(Rn,{size:13}),o("Remove")]}):t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(Or,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[U&&R?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Ut,{name:R.name,avatar:R.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:te("h-2 w-2 shrink-0 rounded-full",Io(R))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:R.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[R.providerId," · ",o(Oo(R.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Provider")}),t.jsx(as,{value:a.providerId,onChange:N=>I("providerId",N),options:F})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Workspace policy")}),t.jsx(as,{value:a.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:Fl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Trigger policy")}),t.jsx(as,{value:a.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:Sm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Session policy")}),t.jsx(as,{value:a.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:zl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Queue policy")}),t.jsx(as,{value:a.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:wm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ht,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:ym.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[N.key],onChange:W=>H(N.key,W.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(fs,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Me,{type:"button",onClick:$,disabled:T||!O,children:o(T?"Processing...":u==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Cs,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[y.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(ls,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:y.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:y.map(U=>{const N=u==="edit"&&g===U.id;return t.jsxs("button",{type:"button",onClick:()=>q(U),className:te("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Ut,{name:U.name,avatar:U.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:te("h-1.5 w-1.5 shrink-0 rounded-full",Io(U))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:U.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:U.providerId})]}),t.jsx(Nu,{size:13,className:te("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},U.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:T,className:te("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Or,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:P,disabled:T,className:te("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(po,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?B():z()})]})}),t.jsx(yn,{isOpen:!!d,onClose:()=>f(null),onConfirm:K,title:o("Remove member"),variant:"danger",isLoading:i.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?o("Remove this member from future TeamRun work?"):""}),d&&ln(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(js,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Nm=[],Rm=[],Am=[],Tm=240;function Mm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const Fo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Pi(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function zo(e,s){return e instanceof Error?e.message:s}function Dm(e,s=Tm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Br(e){return e?e.instructionPreview??Dm(e.instruction):""}function Pm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function Lm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Im(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function Om(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Bm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function Fm(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function zm(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 Wm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Hm(e,s){return s.find(r=>r.memberId===e.id&&gi.has(r.status))}function Wl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ae(),v=Aa(e.id),n=Ta(e.id),i=Ma(e.id),[l,u]=b.useState(null),[c,g]=b.useState(null),[x,_]=b.useState(!1),[w,a]=b.useState(!1),h=e.members??Nm,d=b.useMemo(()=>h.filter(I=>I.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??Rm,S=e.invocations??Am,C=b.useMemo(()=>Kn(s,e),[e,s]),k=b.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=b.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),y=b.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=b.useMemo(()=>[...h].map(I=>({member:I,status:Mm(I.status)})).sort((I,H)=>Fo[I.status]-Fo[H.status]),[h]),R=v.isError?v.error:n.isError?n.error:null,L=v.isPending||n.isPending,T=C.find(I=>I.workspace.id===r),D=e.messages??[],F=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(jm,{isOpen:w,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Hs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(ai,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:D.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:F>0?`${F}/${d.length}`:d.length}),F>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),y.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:y.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(cs,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(cs,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const H=h.find(P=>P.id===I.targetMemberId),q=v.isPending&&v.variables===I.id,A=n.isPending&&n.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ut,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Br(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(Om(I.requesterType))}),t.jsx("span",{children:Pi(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Kt,{size:11}),t.jsx("span",{className:"truncate",children:m(q?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qt,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"Rejecting":"Reject")})]})]})]},I.id)})}),R&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:zo(R,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(nl,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:H})=>{const q=Hm(I,S),A=Wm(S.filter(z=>z.memberId===I.id)),P=q?k.get(q.workRequestId):void 0,M=c===I.id,O=H==="running"||H==="waiting room reply",$=O&&!!q,K=l===I.id,B=i.isPending&&i.variables?.memberId===I.id;return t.jsxs("div",{className:te("bg-white",M&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ut,{name:I.name,avatar:I.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:te("h-1.5 w-1.5 shrink-0 rounded-full",Im(H))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Lm(H)),children:m(Pm(H))})]}),O&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Br(P)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>u(K?null:I.id),disabled:i.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(Ws,{size:12})}),q?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(q.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(Ji,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(M?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":M,children:M?t.jsx(wt,{size:13}):t.jsx(Pt,{size:13})})]})]}),$&&K&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ws,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(rl,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),M&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(z=>{const U=k.get(z.workRequestId),N=!!(z.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:te("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Bm(z.status)),children:z.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Pi(z.updatedAt??z.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Br(U)||z.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>z.sessionId&&p?.(z.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(Ji,{size:10}),t.jsx("span",{children:m("Log")})]})]})},z.id)})})]}),j[j.length-1]?.member.id!==I.id&&!M&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:zo(i.error,m("Failed to stop member work"))})]}),y.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(cs,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:y.length})]}),t.jsx("div",{className:"space-y-1",children:y.map(I=>{const H=h.find(q=>q.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ut,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Br(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Pi(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>_(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":x,"aria-label":m("Workspaces"),children:[t.jsx(Hs,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:qs(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),x?t.jsx(wt,{size:13,className:"text-neutral-400"}):t.jsx(Pt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const H=r===I.workspace.id;return t.jsx("div",{className:te("rounded-md border bg-white px-3 py-2",H?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(I.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",zm(I.roleLabel)),children:m(I.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Fm(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:qs(I.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:[I.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||H,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[H?t.jsx(Kt,{size:11}):t.jsx(Ka,{size:11}),t.jsx("span",{children:m(H?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&y.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Li={exports:{}},Wo;function $m(){return Wo||(Wo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,n,i){var l=this&&this.__decorate||function(f,S,C,k){var E,y=arguments.length,j=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var R=f.length-1;R>=0;R--)(E=f[R])&&(j=(y<3?E(j):y>3?E(S,C,j):E(S,C))||j);return y>3&&j&&Object.defineProperty(S,C,j),j},u=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=i(9042),g=i(6114),x=i(9924),_=i(844),w=i(5596),a=i(4725),h=i(3656);let d=n.AccessibilityManager=class extends _.Disposable{constructor(f,S){super(),this._terminal=f,this._renderService=S,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
19
+ `);return m?{content:m,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function vm({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent",workingDir:m,onOpenWorkspaceFile:v,onOpenPreviewUrl:n,onOpenVisualization:i,downloadSessionId:l}){const{t:u}=ae(),c=b.useId(),g=b.useRef(null),[x,_]=b.useState(null),[w,a]=b.useState(!1),[h,d]=b.useState(null),f=fd(e.teamRunId,e.id,!1),S=f.data?.content,C=S?an(S,r):void 0,E=!!(C&&C!==s)?C:s,y=!!(e.isTruncated&&!Pl(e)),j=x?.messageId===e.id&&x.content===E&&x.expanded,R=b.useCallback(()=>{const I=g.current;I&&a($f(I.scrollHeight))},[]);b.useLayoutEffect(()=>{R();const I=g.current;if(!I)return;const H=window.requestAnimationFrame(R),q=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return q?.observe(I),window.addEventListener("resize",R),()=>{window.cancelAnimationFrame(H),q?.disconnect(),window.removeEventListener("resize",R)}},[E,R]);const L=b.useCallback(async()=>{if(d(null),j){_({messageId:e.id,content:E,expanded:!1});return}if(y&&!S){const I=await f.refetch();if(I.error){d(ln(I.error,u("Failed to load full message")));return}const H=I.data?.content?an(I.data.content,r):E;_({messageId:e.id,content:H,expanded:!0});return}_({messageId:e.id,content:E,expanded:!0})},[r,y,S,f,j,e.id,E,u]),T=(w||y)&&!j,D=w||y,F=f.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:c,ref:g,onLoadCapture:R,className:te("relative transition-[max-height] duration-200 ease-out",T?"overflow-hidden":""),style:T?{maxHeight:Dl}:void 0,children:[t.jsx(hm,{content:E,isUser:o,workingDir:m,onOpenWorkspaceFile:v,onOpenPreviewUrl:n,onOpenVisualization:i,downloadSessionId:l}),T&&t.jsx("div",{className:te("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),D&&t.jsxs("button",{type:"button","aria-expanded":j,"aria-controls":c,"aria-label":u(j?"Collapse message":"Expand full message"),disabled:F,onClick:()=>{L()},className:te("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",F?"cursor-wait opacity-70":""),children:[j?t.jsx(sl,{size:13}):t.jsx(wt,{size:13}),t.jsx("span",{children:u(F?"Loading":j?"Collapse message":"Expand full message")})]}),h&&t.jsx("div",{className:te("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:h})]})}function Ll({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:v,bubbleClassName:n,isPending:i}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:te("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Ut,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:te("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:te("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:im(r)}),v]}),t.jsx("div",{className:te("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",n,i?"opacity-70":""),children:m})]}),o&&t.jsx(Ut,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function xm({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(ci,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function bm({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l,onOpenVisualization:u,previewWorkspaceId:c,previewSessionId:g}){const{t:x}=ae(),_=e.senderType==="user",w=e.senderType==="system",a=Pl(e)?e.pendingStatus:null,h=e.mentions??[],d=e.workRequestIds?.length??0,f=e.visibility==="PRIVATE",S=b.useCallback(y=>{l?.(y,c)},[l,c]),C=b.useCallback(y=>{g&&u?.(g,y,c)},[u,g,c]),k=f?cm(e,p):[],E=t.jsxs(t.Fragment,{children:[!_&&!w&&o&&t.jsx(xm,{provider:o}),f&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:k.join(", "),children:[t.jsx(hd,{size:10}),t.jsxs("span",{className:"truncate",children:[x("Private"),k.length>0?`: ${k.join(", ")}`:""]})]}),!w&&d>0&&h.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[x("Work requests"),": ",d]}),a==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:x("发送中...")}),a==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:x("发送失败")})]});return t.jsx(Ll,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:_,isSystem:w,headerAddon:E,bubbleClassName:_&&a==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:a==="sending",children:t.jsx(mm,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:_&&a!=="failed",tone:w?"system":void 0,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l?S:void 0,onOpenVisualization:u&&g?C:void 0,downloadSessionId:g})})}function _m({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:n}=ae();return t.jsx(Ll,{senderName:s?.name??n("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(cs,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??nm(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Kt,{size:12}),t.jsx("span",{children:n(m?"Approving":"Approve")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(qt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function Il({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:n,centered:i,workingDir:l,onOpenWorkspaceFile:u,onOpenPreviewUrl:c,onOpenVisualization:g}){const{t:x}=ae(),_=Ta(e.id),w=Ma(e.id),a=Da(e.id),[h,d]=b.useState(""),[f,S]=b.useState(!1),[C,k]=b.useState(null),[E,y]=b.useState(0),[j,R]=b.useState([]),[L,T]=b.useState(!1),[D,F]=b.useState(null),[I,H]=b.useState([]),[q,A]=b.useState(null),P=b.useRef(null),M=b.useRef(null),{files:O,addFiles:$,removeFile:K,clear:B,restoreFiles:z,buildMarkdownLinks:U,getDoneAttachments:N,isUploading:W}=bn(),X=O.some(Y=>Y.status==="done"&&Y.attachment),[V,ie]=b.useState(null),{scrollRef:ee,contentRef:me,isAtBottom:he,scrollToBottom:G}=Cn({resize:"smooth",initial:"instant"}),pe=b.useRef(!1),oe=b.useRef(null);b.useEffect(()=>{const Y=ee.current;if(!Y)return;const se=ne=>{if(ne.deltaY<0){pe.current=!0;return}ne.deltaY>0&&Y.scrollHeight-Y.scrollTop-Y.clientHeight<=70&&(pe.current=!1)};return Y.addEventListener("wheel",se,{passive:!0}),()=>Y.removeEventListener("wheel",se)},[ee]);const{data:We}=Ks(),ut=b.useMemo(()=>{const Y=new Map;for(const se of We??[])Y.set(se.provider.id,se.provider);return Y},[We]),Oe=b.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),be=b.useMemo(()=>(e.members??[]).filter(Do),[e.members]),Ue=b.useMemo(()=>new Map((e.invocations??[]).map(Y=>[Y.id,Y])),[e.invocations]),Be=b.useMemo(()=>{const Y=new Set(s.map(ne=>ne.id)),se=I.filter(ne=>!Y.has(ne.id));return[...s,...se].sort((ne,ke)=>{const xe=Date.parse(ne.createdAt??""),je=Date.parse(ke.createdAt??"");return(Number.isNaN(xe)?0:xe)-(Number.isNaN(je)?0:je)})},[s,I]),tt=b.useMemo(()=>new Map((e.workRequests??[]).map(Y=>[Y.id,Y])),[e.workRequests]),Ye=b.useMemo(()=>Vf(Be,e.workRequests??[],e.invocations??[]),[Be,e.invocations,e.workRequests]);b.useEffect(()=>{const Y=Ye.at(-1)?.key??null,se=oe.current;oe.current=Y,!(se==null||Y==null||Y===se||pe.current)&&requestAnimationFrame(()=>{G({animation:"smooth",ignoreEscapes:!0})})},[G,Ye]);const Ze=b.useMemo(()=>(e.invocations??[]).filter(Y=>vi.has(Y.status)),[e.invocations]),Xe=b.useMemo(()=>j.map(Y=>Oe.get(Y)).filter(Y=>!!Y).filter(Do),[Oe,j]),Ne=b.useMemo(()=>{const Y=C?.query??"";return be.filter(se=>am(se,Y)).sort((se,ne)=>{const ke=j.includes(se.id),xe=j.includes(ne.id);return ke!==xe?ke?1:-1:se.name.localeCompare(ne.name)})},[be,C?.query,j]),Ae=!r&&(f||!!C)&&Ne.length>0,ve=b.useCallback((Y,se)=>{if(se==null){k(null);return}k(om(Y,se)),y(0)},[]),He=b.useCallback(Y=>{R(je=>Uf(je,Y.id));const se=`@${Y.name} `;if(C){const je=`${h.slice(0,C.start)}${se}${h.slice(C.end)}`,Te=C.start+se.length;d(je),k(null),S(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(Te,Te)});return}const ne=h.length===0||/\s$/.test(h)?"":" ",ke=`${h}${ne}${se}`,xe=ke.length;d(ke),S(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(xe,xe)})},[h,C]),_e=b.useCallback(Y=>{R(se=>qf(se,Y))},[]),pt=b.useCallback(Y=>{const se=Y.target.value;d(se),F(null);const ne=Y.target;ne.style.height="auto",ne.style.height=`${Math.max(n?40:72,Math.min(ne.scrollHeight,n?140:240))}px`,S(!1),ve(se,ne.selectionStart)},[n,ve]),Je=b.useCallback(Y=>{const se=Y.target.files;se&&se.length>0&&($(Array.from(se)),F(null)),Y.target.value=""},[$]),Lt=b.useCallback(Y=>{const se=[];for(const ne of Y.clipboardData.items)if(ne.kind==="file"){const ke=ne.getAsFile();ke&&se.push(ke)}se.length>0&&(Y.preventDefault(),$(se),F(null))},[$]),J=b.useCallback(async()=>{if(r||L||W)return;const Y=U(),se=N().map(Le=>Le.id),ne=Kf(j,be),ke=gm({draft:h,attachmentMarkdown:Y,attachmentIds:se,mentions:ne});if(!ke||!h.trim()&&!X)return;const xe=tm(e.id,ke),je=h,Te=j,ye=O;H(Le=>[...Le,xe]),d(""),R([]),S(!1),k(null),B(),P.current&&(P.current.style.height=n?"40px":"72px"),requestAnimationFrame(()=>G()),T(!0),F(null);try{const Le=await p(ke);H(Se=>Se.filter(De=>De.id!==xe.id)),Le&&typeof Le=="object"&&"id"in Le&&requestAnimationFrame(()=>G())}catch(Le){const Se=Le instanceof Error?Le.message:"Failed to send room message";H(De=>De.map(Qe=>Qe.id===xe.id?{...Qe,pendingStatus:"failed",error:Se}:Qe)),d(De=>De.length===0?je:De),R(De=>De.length===0?Te:De),z(ye),F(Se),requestAnimationFrame(()=>G())}finally{T(!1)}},[be,O,U,B,n,h,N,X,L,W,p,r,z,G,j,e.id]),fe=b.useCallback(Y=>{const se=Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229;if(Ae){if(Y.key==="ArrowDown"){Y.preventDefault(),y(ne=>(ne+1)%Ne.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),y(ne=>(ne-1+Ne.length)%Ne.length);return}if(Y.key==="Enter"&&!se||Y.key==="Tab"){Y.preventDefault();const ne=Ne[E]??Ne[0];ne&&He(ne);return}if(Y.key==="Escape"){Y.preventDefault(),k(null),S(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!se&&(Y.preventDefault(),J())},[He,J,E,Ne,Ae]);b.useEffect(()=>{d(""),R([]),S(!1),k(null),F(null),H([]),B(),pe.current=!1,oe.current=null,A(null),P.current&&(P.current.style.height=n?"40px":"72px")},[B,n,e.id]);const ue=_.isError?_.error:w.isError?w.error:null,ge=_.isPending||w.isPending,Ce=b.useCallback((Y,se)=>{a.mutate({memberId:Y,cancelQueued:se},{onSuccess:()=>A(null)})},[a]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[V&&t.jsx(pm,{images:V.images,index:V.index,onClose:()=>ie(null),onSelect:Y=>ie(se=>se&&{...se,index:Y})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:ee,className:te("h-full overflow-y-auto scrollbar-app-thin bg-white",n?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:me,className:te(n?"space-y-2.5":"space-y-3",i&&"max-w-4xl mx-auto"),children:[Ye.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(Cs,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:x("No room messages yet")})]}):Ye.map(Y=>{if(Y.kind==="pendingApproval"){const Se=Y.request,De=Oe.get(Se.targetMemberId),Qe=_.isPending&&_.variables===Se.id,rt=w.isPending&&w.variables===Se.id;return t.jsx(_m,{request:Se,member:De,onApprove:()=>_.mutate(Se.id),onReject:()=>w.mutate(Se.id),isActionPending:ge,isApprovePending:Qe,isRejectPending:rt},Y.key)}const se=Y.message,ne=um(se,Oe,Ue),ke=se.senderType==="user"?x("你"):se.senderType==="system"?x("System"):ne?.name??x("Agent"),xe=dm(se,Oe),je=ne?.providerId?ut.get(ne.providerId)??null:null,Te=se.senderInvocationId?Ue.get(se.senderInvocationId):void 0,ye=Te?.workspaceId??void 0,Le=Te?.sessionId??void 0;return t.jsx(bm,{message:se,senderName:ke,senderMember:ne,senderProvider:je,memberById:Oe,displayContent:xe,onOpenImage:(Se,De)=>ie({images:Se,index:De}),workingDir:l,onOpenWorkspaceFile:u,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:ye,previewSessionId:Le},Y.key)}),ue&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:ln(ue,x("Failed to update work request"))}),a.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:ln(a.error,x("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>G(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(mr,{size:14}),t.jsx("span",{children:x("Back to bottom")})]})]}),t.jsx("div",{className:te("shrink-0 border-t border-transparent bg-white",n?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:te(i&&"max-w-4xl mx-auto"),children:[t.jsx(Jf,{invocations:Ze,memberById:Oe,workRequestById:tt,onViewInvocationSession:m,onStopMember:Ce,isStopPending:a.isPending,stoppingMemberId:a.variables?.memberId??null,stopPromptInvocationId:q,onToggleStopConfirm:Y=>A(se=>se===Y?null:Y)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??x("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ae&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:x(C?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Ne.map((Y,se)=>{const ne=j.includes(Y.id),ke=se===E;return t.jsxs("button",{type:"button",onMouseEnter:()=>y(se),onMouseDown:xe=>{xe.preventDefault(),He(Y)},className:te("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ke?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ut,{name:Y.name,avatar:Y.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:Y.name}),ne&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:x("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[Y.providerId,Y.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(uo,{size:15,className:"text-neutral-400"})]},Y.id)})})]}),Xe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Xe.map(Y=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",Y.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Y.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>_e(Y.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:x("Remove mention"),"aria-label":`${x("Remove mention")} ${Y.name}`,children:t.jsx(qt,{size:12})})]},Y.id))}),t.jsx(_n,{files:O,onRemove:K}),t.jsx("textarea",{ref:P,value:h,rows:n?1:void 0,onChange:pt,onKeyDown:fe,onPaste:Lt,onClick:Y=>ve(h,Y.currentTarget.selectionStart),onSelect:Y=>ve(h,Y.currentTarget.selectionStart),placeholder:x("Message the team room..."),className:te("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",n?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:n?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:te("flex items-center justify-between",n?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Je}),t.jsx("button",{type:"button",onClick:()=>M.current?.click(),title:x("Upload file"),"aria-label":x("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(Rn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{S(Y=>!Y),k(null),requestAnimationFrame(()=>P.current?.focus())},disabled:Xe.length===0&&be.length===0,title:x("Mention members"),"aria-label":x("Mention members"),className:te("rounded-lg transition-colors",n?"p-1.5":"p-2",f?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Xe.length===0&&be.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(uo,{size:n?15:18})}),Xe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Xe.length," ",x("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{J()},disabled:r||L||W||!h.trim()&&!X,title:x(W?"Uploading...":L?"发送中...":"发送"),"aria-label":x(W?"Uploading...":L?"发送中...":"发送"),className:te("rounded-lg transition-all duration-200",n?"p-1.5":"p-2",(h.trim()||X)&&!r&&!L&&!W?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",L||W?"opacity-70":""),children:t.jsx(kn,{size:n?15:18})})]}),D&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:D})]})]})})]})}function ym(e){return e?e.slice(0,8):""}function Po(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Kn(e){return e?.workspaceKind===_t.MAIN_DIRECTORY}function qs(e){return e?Kn(e)?"Project directory":e.branchName:"—"}function ds(e){return e?.workingDir||e?.worktreePath||void 0}function Vn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),o=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const v=m.parentWorkspaceId?o.get(m.parentWorkspaceId):void 0,n=m.ownerMemberId?r.get(m.ownerMemberId):void 0,i=!!(p&&m.id===p),l=i?"main":m.parentWorkspaceId?"child":"root",u=n?.name??(m.ownerMemberId?`Member ${ym(m.ownerMemberId)}`:void 0),c=Kn(m)?"Project directory":i?"Main workspace":l==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:l,roleLabel:i?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:v?qs(v):void 0,isMain:i}}).sort((m,v)=>{const n=l=>l.kind==="main"?0:l.kind==="child"?1:2,i=n(m)-n(v);return i!==0?i:Po(m.workspace.createdAt)-Po(v.workspace.createdAt)})}function Ol(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===Mt.ACTIVE)?.id??e[0]?.id}function Bl(e,s){return!e||e.status!==Mt.ACTIVE||Kn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Fl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Xn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Sm=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],zl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],wm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Wl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Cm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function ir(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Xn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Ps(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Xn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Pi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Xn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function km(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function Em(e){return{name:e.name.trim(),aliases:km(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function Lo(e,s){return e instanceof Error?e.message:s}function Io(e){return e.membershipStatus!=="REMOVED"}function cn(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Oo(e){return cn(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Bo(e){return zl.find(s=>s.value===e)?.label??e}function jm(e){return Wl.find(s=>s.value===e)?.label??e}function Ht({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Fo({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function Nm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ae(),{data:p=[]}=md(),{data:m=[]}=Ks(),v=pd(r.id),n=gd(r.id),i=vd(r.id),l=b.useRef(!1),[u,c]=b.useState("edit"),[g,x]=b.useState(null),[_,w]=b.useState(""),[a,h]=b.useState(ir()),[d,f]=b.useState(null),[S,C]=b.useState(null),k=r.members??[],E=b.useMemo(()=>k.filter(Io),[k]),y=b.useMemo(()=>S&&Io(S)&&!E.some(U=>U.id===S.id)?[...E,S]:E,[S,E]),j=g?E.find(U=>U.id===g)??null:null,R=S?.id===g?S:j,L=_?p.find(U=>U.id===_)??null:null,T=v.isPending||n.isPending||i.isPending,D=y.filter(cn).length,F=b.useMemo(()=>{const U=m.map(({provider:N,availability:W})=>({value:N.id,label:N.name+(W.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(ci,{agentType:N.agentType,className:"size-4"}),disabled:W.type==="NOT_FOUND"}));return a.providerId&&!U.some(N=>N.value===a.providerId)&&U.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),U},[a.providerId,m,o]);b.useEffect(()=>{if(!e){l.current=!1,C(null);return}if(l.current)return;l.current=!0;const U=y[0]??null;c(U?"edit":"add-preset"),x(U?.id??null),w(""),h(U?Ps(U):ir()),f(null)},[y,e]),b.useEffect(()=>{S&&E.some(U=>U.id===S.id)&&C(null)},[S,E]),b.useEffect(()=>{u==="add-preset"&&L&&h(Pi(L))},[u,L]);const I=(U,N)=>{h(W=>({...W,[U]:N}))},H=(U,N)=>{h(W=>({...W,capabilities:{...W.capabilities,[U]:N}}))},q=U=>{c("edit"),x(U.id),w(""),h(Ps(U))},A=()=>{c("add-preset"),x(null);const U=L??p[0]??null;w(U?.id??""),h(U?Pi(U):ir())},P=()=>{c("add-custom"),x(null),w(""),h(ir())},M=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),O=u==="add-preset"?!!_:u==="edit"?!!(R&&M):M,$=async()=>{try{if(u==="add-preset"){if(!_)return;const N=await v.mutateAsync({memberPresetId:_});st.success(o("Member added")),C(N),c("edit"),x(N.id),w(""),h(Ps(N));return}const U=Em(a);if(!U.name||!U.providerId||!U.rolePrompt){st.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:U});st.success(o("Member added")),C(N),c("edit"),x(N.id),h(Ps(N));return}if(R){const N=await n.mutateAsync({memberId:R.id,data:U});st.success(o("Member updated")),C(W=>W?.id===N.id?N:W),x(N.id),h(Ps(N))}}catch(U){st.error(Lo(U,o("Failed to save member")))}},K=async()=>{if(d)try{if(await i.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const U=y.find(N=>N.id!==d.id)??null;x(U?.id??null),c(U?"edit":"add-preset"),h(U?Ps(U):ir())}C(U=>U?.id===d.id?null:U),f(null),st.success(o("Member removed"))}catch(U){st.error(Lo(U,o("Failed to remove member")))}},B=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Or,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(go,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(Fo,{icon:t.jsx(Or,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(ls,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(U=>{const N=_===U.id;return t.jsxs("button",{type:"button",onClick:()=>{w(U.id),h(Pi(U))},className:te("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Ut,{name:U.name,avatar:U.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:U.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:U.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(Bo(U.workspacePolicy))," · ",o(jm(U.sessionPolicy))]})]}),N?t.jsx(Kt,{size:16,className:"shrink-0 text-neutral-900"}):null]},U.id)})})})]}),z=()=>{const U=u==="edit";return U&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Fo,{icon:t.jsx(Cs,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(ls,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[U?t.jsx(ol,{size:15,className:"text-neutral-500"}):t.jsx(ls,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(U?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(U?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),U&&R?t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:()=>f(R),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(An,{size:13}),o("Remove")]}):t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(Or,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[U&&R?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Ut,{name:R.name,avatar:R.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:te("h-2 w-2 shrink-0 rounded-full",Oo(R))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:R.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[R.providerId," · ",o(Bo(R.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Provider")}),t.jsx(as,{value:a.providerId,onChange:N=>I("providerId",N),options:F})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Workspace policy")}),t.jsx(as,{value:a.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:zl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Trigger policy")}),t.jsx(as,{value:a.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:wm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Session policy")}),t.jsx(as,{value:a.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:Wl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Queue policy")}),t.jsx(as,{value:a.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:Cm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ht,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ht,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Sm.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[N.key],onChange:W=>H(N.key,W.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(fs,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Me,{type:"button",onClick:$,disabled:T||!O,children:o(T?"Processing...":u==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Cs,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[y.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(ls,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:y.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:y.map(U=>{const N=u==="edit"&&g===U.id;return t.jsxs("button",{type:"button",onClick:()=>q(U),className:te("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Ut,{name:U.name,avatar:U.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:te("h-1.5 w-1.5 shrink-0 rounded-full",Oo(U))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:U.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:U.providerId})]}),t.jsx(Ru,{size:13,className:te("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},U.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:T,className:te("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Or,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:P,disabled:T,className:te("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(go,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?B():z()})]})}),t.jsx(Sn,{isOpen:!!d,onClose:()=>f(null),onConfirm:K,title:o("Remove member"),variant:"danger",isLoading:i.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?o("Remove this member from future TeamRun work?"):""}),d&&cn(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(js,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Rm=[],Am=[],Tm=[],Mm=240;function Dm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const zo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Li(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Wo(e,s){return e instanceof Error?e.message:s}function Pm(e,s=Mm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Br(e){return e?e.instructionPreview??Pm(e.instruction):""}function Lm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function Im(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Om(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function Bm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Fm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function zm(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Wm(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 Hm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function $m(e,s){return s.find(r=>r.memberId===e.id&&vi.has(r.status))}function Hl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ae(),v=Ta(e.id),n=Ma(e.id),i=Da(e.id),[l,u]=b.useState(null),[c,g]=b.useState(null),[x,_]=b.useState(!1),[w,a]=b.useState(!1),h=e.members??Rm,d=b.useMemo(()=>h.filter(I=>I.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??Am,S=e.invocations??Tm,C=b.useMemo(()=>Vn(s,e),[e,s]),k=b.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=b.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),y=b.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=b.useMemo(()=>[...h].map(I=>({member:I,status:Dm(I.status)})).sort((I,H)=>zo[I.status]-zo[H.status]),[h]),R=v.isError?v.error:n.isError?n.error:null,L=v.isPending||n.isPending,T=C.find(I=>I.workspace.id===r),D=e.messages??[],F=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(Nm,{isOpen:w,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx($s,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(li,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:D.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:F>0?`${F}/${d.length}`:d.length}),F>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),y.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:y.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(cs,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(cs,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const H=h.find(P=>P.id===I.targetMemberId),q=v.isPending&&v.variables===I.id,A=n.isPending&&n.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ut,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Br(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(Bm(I.requesterType))}),t.jsx("span",{children:Li(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Kt,{size:11}),t.jsx("span",{className:"truncate",children:m(q?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qt,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"Rejecting":"Reject")})]})]})]},I.id)})}),R&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Wo(R,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(ol,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:H})=>{const q=$m(I,S),A=Hm(S.filter(z=>z.memberId===I.id)),P=q?k.get(q.workRequestId):void 0,M=c===I.id,O=H==="running"||H==="waiting room reply",$=O&&!!q,K=l===I.id,B=i.isPending&&i.variables?.memberId===I.id;return t.jsxs("div",{className:te("bg-white",M&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ut,{name:I.name,avatar:I.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:te("h-1.5 w-1.5 shrink-0 rounded-full",Om(H))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Im(H)),children:m(Lm(H))})]}),O&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Br(P)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>u(K?null:I.id),disabled:i.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(Ws,{size:12})}),q?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(q.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(en,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(M?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":M,children:M?t.jsx(wt,{size:13}):t.jsx(Pt,{size:13})})]})]}),$&&K&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ws,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(il,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),M&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(z=>{const U=k.get(z.workRequestId),N=!!(z.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:te("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Fm(z.status)),children:z.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Li(z.updatedAt??z.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Br(U)||z.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>z.sessionId&&p?.(z.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(en,{size:10}),t.jsx("span",{children:m("Log")})]})]})},z.id)})})]}),j[j.length-1]?.member.id!==I.id&&!M&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Wo(i.error,m("Failed to stop member work"))})]}),y.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(cs,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:y.length})]}),t.jsx("div",{className:"space-y-1",children:y.map(I=>{const H=h.find(q=>q.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ut,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Br(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Li(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>_(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":x,"aria-label":m("Workspaces"),children:[t.jsx($s,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:qs(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),x?t.jsx(wt,{size:13,className:"text-neutral-400"}):t.jsx(Pt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const H=r===I.workspace.id;return t.jsx("div",{className:te("rounded-md border bg-white px-3 py-2",H?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(I.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Wm(I.roleLabel)),children:m(I.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",zm(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:qs(I.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:[I.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||H,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[H?t.jsx(Kt,{size:11}):t.jsx(Va,{size:11}),t.jsx("span",{children:m(H?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&y.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Ii={exports:{}},Ho;function Um(){return Ho||(Ho=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,n,i){var l=this&&this.__decorate||function(f,S,C,k){var E,y=arguments.length,j=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var R=f.length-1;R>=0;R--)(E=f[R])&&(j=(y<3?E(j):y>3?E(S,C,j):E(S,C))||j);return y>3&&j&&Object.defineProperty(S,C,j),j},u=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=i(9042),g=i(6114),x=i(9924),_=i(844),w=i(5596),a=i(4725),h=i(3656);let d=n.AccessibilityManager=class extends _.Disposable{constructor(f,S){super(),this._terminal=f,this._renderService=S,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
20
20
  `)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new w.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,_.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let S=0;S<f;S++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
21
21
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,S){this._liveRegionDebouncer.refresh(f,S,this._terminal.rows)}_renderRows(f,S){const C=this._terminal.buffer,k=C.lines.length.toString();for(let E=f;E<=S;E++){const y=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),R=this._rowElements[E];R&&(y.length===0?R.innerText=" ":R.textContent=y,R.setAttribute("aria-posinset",j),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,S){const C=f.target,k=this._rowElements[S===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(S===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,y;if(S===0?(E=C,y=this._rowElements.pop(),this._rowContainer.removeChild(y)):(E=this._rowElements.shift(),y=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),y.removeEventListener("focus",this._bottomBoundaryFocusListener),S===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(S===0?-1:1),this._rowElements[S===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let S=this._rowContainer.children.length;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=d=l([u(1,a.IRenderService)],d)},3614:(v,n)=>{function i(g){return g.replace(/\r?\n/g,"\r")}function l(g,x){return x?"\x1B[200~"+g+"\x1B[201~":g}function u(g,x,_,w){g=l(g=i(g),_.decPrivateModes.bracketedPasteMode&&w.rawOptions.ignoreBracketedPasteMode!==!0),_.triggerDataEvent(g,!0),x.value=""}function c(g,x,_){const w=_.getBoundingClientRect(),a=g.clientX-w.left-10,h=g.clientY-w.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${a}px`,x.style.top=`${h}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=i,n.bracketTextForPaste=l,n.copyHandler=function(g,x){g.clipboardData&&g.clipboardData.setData("text/plain",x.selectionText),g.preventDefault()},n.handlePasteEvent=function(g,x,_,w){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),x,_,w)},n.paste=u,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(g,x,_,w,a){c(g,x,_),a&&w.rightClickSelect(g),x.value=w.selectionText,x.select()}},7239:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const l=i(1505);n.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(u,c,g){this._css.set(u,c,g)}getCss(u,c){return this._css.get(u,c)}setColor(u,c,g){this._color.set(u,c,g)}getColor(u,c){return this._color.get(u,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,l,u,c){i.addEventListener(l,u,c);let g=!1;return{dispose:()=>{g||(g=!0,i.removeEventListener(l,u,c))}}}},6465:function(v,n,i){var l=this&&this.__decorate||function(a,h,d,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(h,d,k):S(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const c=i(3656),g=i(8460),x=i(844),_=i(2585);let w=n.Linkifier2=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,d){this._element=a,this._mouseService=h,this._renderService=d,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const d=a.composedPath();for(let f=0;f<d.length;f++){const S=d[f];if(S.classList.contains("xterm"))break;if(S.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var d,f;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let S=!1;for(const[C,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(S=this._checkLinkProviderResult(C,a,S)):k.provideLinks(a.y,(E=>{var y,j;if(this._isMouseOut)return;const R=E?.map((L=>({link:L})));(y=this._activeProviderReplies)===null||y===void 0||y.set(C,R),S=this._checkLinkProviderResult(C,a,S),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const d=new Set;for(let f=0;f<h.size;f++){const S=h.get(f);if(S)for(let C=0;C<S.length;C++){const k=S[C],E=k.link.range.start.y<a?0:k.link.range.start.x,y=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=y;j++){if(d.has(j)){S.splice(C--,1);break}d.add(j)}}}}_checkLinkProviderResult(a,h,d){var f;if(!this._activeProviderReplies)return d;const S=this._activeProviderReplies.get(a);let C=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&S){const k=S.find((E=>this._linkAtPosition(E.link,h)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((y=>this._linkAtPosition(y.link,h)));if(E){d=!0,this._handleNewLink(E);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:d=>{var f,S;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((S=this._element)===null||S===void 0||S.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.underline},set:d=>{var f,S,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(S=this._currentLink)===null||S===void 0?void 0:S.state)===null||C===void 0?void 0:C.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const f=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,S=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=S&&(this._clearCurrentLink(f,S),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(d,h.text)}_fireUnderlineEvent(a,h){const d=a.range,f=this._bufferService.buffer.ydisp,S=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-f-1,d.end.x,d.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(S)}_linkLeave(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(d,h.text)}_linkAtPosition(a,h){const d=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,S=h.y*this._bufferService.cols+h.x;return d<=S&&S<=f}_positionFromMouseEvent(a,h,d){const f=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,f,S){return{x1:a,y1:h,x2:d,y2:f,cols:this._bufferService.cols,fg:S}}};n.Linkifier2=w=l([u(0,_.IBufferService)],w)},9042:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,n,i){var l=this&&this.__decorate||function(w,a,h,d){var f,S=arguments.length,C=S<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,a,h,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(a,h,C):f(a,h))||C);return S>3&&C&&Object.defineProperty(a,h,C),C},u=this&&this.__param||function(w,a){return function(h,d){a(h,d,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const c=i(511),g=i(2585);let x=n.OscLinkProvider=class{constructor(w,a,h){this._bufferService=w,this._optionsService=a,this._oscLinkService=h}provideLinks(w,a){var h;const d=this._bufferService.buffer.lines.get(w-1);if(!d)return void a(void 0);const f=[],S=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=d.getTrimmedLength();let E=-1,y=-1,j=!1;for(let R=0;R<k;R++)if(y!==-1||d.hasContent(R)){if(d.loadCell(R,C),C.hasExtendedAttrs()&&C.extended.urlId){if(y===-1){y=R,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else y!==-1&&(j=!0);if(j||y!==-1&&R===k-1){const L=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(L){const T={start:{x:y+1,y:w},end:{x:R+(j||R!==k-1?0:1),y:w}};let D=!1;if(!S?.allowNonHttpProtocols)try{const F=new URL(L);["http:","https:"].includes(F.protocol)||(D=!0)}catch{D=!0}D||f.push({text:L,range:T,activate:(F,I)=>S?S.activate(F,I,T):_(0,I),hover:(F,I)=>{var H;return(H=S?.hover)===null||H===void 0?void 0:H.call(S,F,I,T)},leave:(F,I)=>{var H;return(H=S?.leave)===null||H===void 0?void 0:H.call(S,F,I,T)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(y=R,E=C.extended.urlId):(y=-1,E=-1)}}a(f)}};function _(w,a){if(confirm(`Do you want to navigate to ${a}?
22
22
 
23
- WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=x=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],x)},6193:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,l){this._parentWindow=i,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,l,u){this._rowCount=u,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const l=i(844);class u extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}n.ScreenDprMonitor=u},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const l=i(3614),u=i(3656),c=i(6465),g=i(9042),x=i(3730),_=i(1680),w=i(3107),a=i(5744),h=i(2950),d=i(1296),f=i(428),S=i(4269),C=i(5114),k=i(8934),E=i(3230),y=i(9312),j=i(4725),R=i(6731),L=i(8055),T=i(8969),D=i(8460),F=i(844),I=i(6114),H=i(8437),q=i(2584),A=i(7399),P=i(5941),M=i(9074),O=i(2585),$=i(5435),K=i(4567),B=typeof window<"u"?window.document:null;class z extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(M.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((W,X)=>this.refresh(W,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((W=>this._reportWindowsOptions(W)))),this.register(this._inputHandler.onColor((W=>this._handleColorEvent(W)))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((W=>this._afterResize(W.cols,W.rows)))),this.register((0,F.toDisposable)((()=>{var W,X;this._customKeyEventHandler=void 0,(X=(W=this.element)===null||W===void 0?void 0:W.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const W of N){let X,V="";switch(W.index){case 256:X="foreground",V="10";break;case 257:X="background",V="11";break;case 258:X="cursor",V="12";break;default:X="ansi",V="4;"+W.index}switch(W.type){case 0:const ie=L.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[W.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${q.C0.ESC}]${V};${(0,P.toRgbString)(ie)}${q.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((ee=>ee.ansi[W.index]=L.rgba.toColor(...W.color)));else{const ee=X;this._themeService.modifyColors((me=>me[ee]=L.rgba.toColor(...W.color)))}break;case 2:this._themeService.restoreColor(W.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const N=this.buffer.ybase+this.buffer.y,W=this.buffer.lines.get(N);if(!W)return;const X=Math.min(this.buffer.x,this.cols-1),V=this._renderService.dimensions.css.cell.height,ie=W.getWidth(X),ee=this._renderService.dimensions.css.cell.width*ie,me=this.buffer.y*this._renderService.dimensions.css.cell.height,he=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=me+"px",this.textarea.style.width=ee+"px",this.textarea.style.height=V+"px",this.textarea.style.lineHeight=V+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(W=>{this.hasSelection()&&(0,l.copyHandler)(W,this._selectionService)})));const N=W=>(0,l.handlePasteEvent)(W,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,u.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(W=>{W.button===2&&(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(W=>{(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(W=>{W.button===1&&(0,l.moveTextAreaUnderMouseCursor)(W,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var W;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const X=B.createDocumentFragment();this._viewportElement=B.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=B.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=B.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=B.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=B.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(C.CoreBrowserService,this.textarea,(W=this._document.defaultView)!==null&&W!==void 0?W:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(V=>this._handleTextAreaFocus(V)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(S.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((V=>this._onRender.fire(V)))),this.onResize((V=>this._renderService.resize(V.cols,V.rows))),this._compositionView=B.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(_.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((V=>this.scrollLines(V.amount,V.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(y.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((V=>this.scrollLines(V.amount,V.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((V=>this._renderService.handleSelectionChanged(V.start,V.end,V.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((V=>{this.textarea.value=V,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((V=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(w.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(V=>this._selectionService.handleMouseDown(V)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(V=>this._handleScreenReaderModeOptionChange(V)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(V=>{!this._overviewRulerRenderer&&V&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,W=this.element;function X(ee){const me=N._mouseService.getMouseReportCoords(ee,N.screenElement);if(!me)return!1;let he,G;switch(ee.overrideType||ee.type){case"mousemove":G=32,ee.buttons===void 0?(he=3,ee.button!==void 0&&(he=ee.button<3?ee.button:3)):he=1&ee.buttons?0:4&ee.buttons?1:2&ee.buttons?2:3;break;case"mouseup":G=0,he=ee.button<3?ee.button:3;break;case"mousedown":G=1,he=ee.button<3?ee.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(ee)===0)return!1;G=ee.deltaY<0?0:1,he=4;break;default:return!1}return!(G===void 0||he===void 0||he>4)&&N.coreMouseService.triggerMouseEvent({col:me.col,row:me.row,x:me.x,y:me.y,button:he,action:G,ctrl:ee.ctrlKey,alt:ee.altKey,shift:ee.shiftKey})}const V={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ie={mouseup:ee=>(X(ee),ee.buttons||(this._document.removeEventListener("mouseup",V.mouseup),V.mousedrag&&this._document.removeEventListener("mousemove",V.mousedrag)),this.cancel(ee)),wheel:ee=>(X(ee),this.cancel(ee,!0)),mousedrag:ee=>{ee.buttons&&X(ee)},mousemove:ee=>{ee.buttons||X(ee)}};this.register(this.coreMouseService.onProtocolChange((ee=>{ee?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ee)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&ee?V.mousemove||(W.addEventListener("mousemove",ie.mousemove),V.mousemove=ie.mousemove):(W.removeEventListener("mousemove",V.mousemove),V.mousemove=null),16&ee?V.wheel||(W.addEventListener("wheel",ie.wheel,{passive:!1}),V.wheel=ie.wheel):(W.removeEventListener("wheel",V.wheel),V.wheel=null),2&ee?V.mouseup||(W.addEventListener("mouseup",ie.mouseup),V.mouseup=ie.mouseup):(this._document.removeEventListener("mouseup",V.mouseup),W.removeEventListener("mouseup",V.mouseup),V.mouseup=null),4&ee?V.mousedrag||(V.mousedrag=ie.mousedrag):(this._document.removeEventListener("mousemove",V.mousedrag),V.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(W,"mousedown",(ee=>{if(ee.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ee))return X(ee),V.mouseup&&this._document.addEventListener("mouseup",V.mouseup),V.mousedrag&&this._document.addEventListener("mousemove",V.mousedrag),this.cancel(ee)}))),this.register((0,u.addDisposableDomListener)(W,"wheel",(ee=>{if(!V.wheel){if(!this.buffer.hasScrollback){const me=this.viewport.getLinesScrolled(ee);if(me===0)return;const he=q.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ee.deltaY<0?"A":"B");let G="";for(let pe=0;pe<Math.abs(me);pe++)G+=he;return this.coreService.triggerDataEvent(G,!0),this.cancel(ee,!0)}return this.viewport.handleWheel(ee)?this.cancel(ee):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(W,"touchstart",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ee),this.cancel(ee)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(W,"touchmove",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ee)?void 0:this.cancel(ee)}),{passive:!1}))}refresh(N,W){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(N,W)}updateCursorStyle(N){var W;!((W=this._selectionService)===null||W===void 0)&&W.shouldColumnSelect(N)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(N,W,X=0){var V;X===1?(super.scrollLines(N,W,X),this.refresh(0,this.rows-1)):(V=this.viewport)===null||V===void 0||V.scrollLines(N)}paste(N){(0,l.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const W=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),W}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,W,X){this._selectionService.setSelection(N,W,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,W){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(N,W)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const W=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!W&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;W||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const V=this.rows-1;return this.scrollLines(X.type===2?-V:V),this.cancel(N,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(X.cancel&&this.cancel(N,!0),!X.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==q.C0.ETX&&X.key!==q.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,W){const X=N.isMac&&!this.options.macOptionIsMeta&&W.altKey&&!W.ctrlKey&&!W.metaKey||N.isWindows&&W.altKey&&W.ctrlKey&&!W.metaKey||N.isWindows&&W.getModifierState("AltGraph");return W.type==="keypress"?X:X&&(!W.keyCode||W.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(W){return W.keyCode===16||W.keyCode===17||W.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let W;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)W=N.charCode;else if(N.which===null||N.which===void 0)W=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;W=N.which}return!(!W||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(W=String.fromCharCode(W),this._onKey.fire({key:W,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(W,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const W=N.data;return this.coreService.triggerDataEvent(W,!0),this.cancel(N),!0}return!1}resize(N,W){N!==this.cols||W!==this.rows?super.resize(N,W):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,W){var X,V;(X=this._charSizeService)===null||X===void 0||X.measure(),(V=this.viewport)===null||V===void 0||V.syncScrollArea(!0)}clear(){var N;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let W=1;W<this.rows;W++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,W;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(W=this.viewport)===null||W===void 0||W.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(q.C0.ESC+"[I"):this.coreService.triggerDataEvent(q.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const W=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${q.C0.ESC}[4;${X};${W}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const V=this._renderService.dimensions.css.cell.width.toFixed(0),ie=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${q.C0.ESC}[6;${ie};${V}t`)}}cancel(N,W){if(this.options.cancelEvents||W)return N.preventDefault(),N.stopPropagation(),!1}}n.Terminal=z},9924:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,l=1e3){this._renderCallback=i,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,l,u){this._rowCount=u,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l)}}},1680:function(v,n,i){var l=this&&this.__decorate||function(h,d,f,S){var C,k=arguments.length,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,S);else for(var y=h.length-1;y>=0;y--)(C=h[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,S){d(f,S,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),g=i(4725),x=i(8460),_=i(844),w=i(2585);let a=n.Viewport=class extends _.Disposable{constructor(h,d,f,S,C,k,E,y){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=f,this._optionsService=S,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(y.colors),this.register(y.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const d=this._getPixelsScrolled(h);return d!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(h,d){var f;let S,C="";const k=[],E=d??this._bufferService.buffer.lines.length,y=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const R=y.get(j);if(!R)continue;const L=(f=y.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=R.translateToString(!L),!L||j===y.length-1){const T=document.createElement("div");T.textContent=C,k.push(T),C.length>0&&(S=T),C=""}}return{bufferElements:k,cursorElement:S}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(h,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const d=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}};n.Viewport=a=l([u(2,w.IBufferService),u(3,w.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],a)},3107:function(v,n,i){var l=this&&this.__decorate||function(a,h,d,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(h,d,k):S(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),g=i(4725),x=i(844),_=i(2585);let w=n.BufferDecorationRenderer=class extends x.Disposable{constructor(a,h,d,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((S=>this._removeDecoration(S)))),this.register((0,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=(d=a.options.x)!==null&&d!==void 0?d:0;return S&&S>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,h=a.element){var d;if(!h)return;const f=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=w=l([u(1,_.IBufferService),u(2,_.IDecorationService),u(3,g.IRenderService)],w)},5871:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const l of this._zones)if(l.color===i.options.overviewRulerOptions.color&&l.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,i.marker.line))return;if(this._lineAdjacentToZone(l,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(l,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,l){return l>=i.startBufferLine&&l<=i.endBufferLine}_lineAdjacentToZone(i,l,u){return l>=i.startBufferLine-this._linePadding[u||"full"]&&l<=i.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(i,l){i.startBufferLine=Math.min(i.startBufferLine,l),i.endBufferLine=Math.max(i.endBufferLine,l)}}},5744:function(v,n,i){var l=this&&this.__decorate||function(S,C,k,E){var y,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,E);else for(var L=S.length-1;L>=0;L--)(y=S[L])&&(R=(j<3?y(R):j>3?y(C,k,R):y(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},u=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=i(5871),g=i(3656),x=i(4725),_=i(844),w=i(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends _.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(S,C,k,E,y,j,R){var L;super(),this._viewportElement=S,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=y,this._optionsService=j,this._coreBrowseService=R,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,_.toDisposable)((()=>{var D;(D=this._canvas)===null||D===void 0||D.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const S=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=S,h.center=C,h.right=S,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const S=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(S,12),6)*this._coreBrowseService.dpr);a.left=C,a.center=C,a.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const S=this._colorZoneStore.zones;for(const C of S)C.position!=="full"&&this._renderColorZone(C);for(const C of S)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(S){this._ctx.fillStyle=S.color,this._ctx.fillRect(d[S.position||"full"],Math.round((this._canvas.height-1)*(S.startBufferLine/this._bufferService.buffers.active.lines.length)-a[S.position||"full"]/2),h[S.position||"full"],Math.round((this._canvas.height-1)*((S.endBufferLine-S.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[S.position||"full"]))}_queueRefresh(S,C){this._shouldUpdateDimensions=S||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=f=l([u(2,w.IBufferService),u(3,w.IDecorationService),u(4,x.IRenderService),u(5,w.IOptionsService),u(6,x.ICoreBrowserService)],f)},2950:function(v,n,i){var l=this&&this.__decorate||function(w,a,h,d){var f,S=arguments.length,C=S<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,a,h,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(a,h,C):f(a,h))||C);return S>3&&C&&Object.defineProperty(a,h,C),C},u=this&&this.__param||function(w,a){return function(h,d){a(h,d,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),g=i(2585),x=i(2584);let _=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(w,a,h,d,f,S){this._textarea=w,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=f,this._renderService=S,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(w){this._compositionView.textContent=w.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(w){if(this._isComposing||this._isSendingComposition){if(w.keyCode===229||w.keyCode===16||w.keyCode===17||w.keyCode===18)return!1;this._finalizeComposition(!1)}return w.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(w){if(this._compositionView.classList.remove("active"),this._isComposing=!1,w){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const w=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(w,"");this._dataAlreadySent=h,a.length>w.length?this._coreService.triggerDataEvent(h,!0):a.length<w.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===w.length&&a!==w&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(w){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const S=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(S.width,1)+"px",this._textarea.style.height=Math.max(S.height,1)+"px",this._textarea.style.lineHeight=S.height+"px"}w||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=_=l([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,c.IRenderService)],_)},9806:(v,n)=>{function i(l,u,c){const g=c.getBoundingClientRect(),x=l.getComputedStyle(c),_=parseInt(x.getPropertyValue("padding-left")),w=parseInt(x.getPropertyValue("padding-top"));return[u.clientX-g.left-_,u.clientY-g.top-w]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(l,u,c,g,x,_,w,a,h){if(!_)return;const d=i(l,u,c);return d?(d[0]=Math.ceil((d[0]+(h?w/2:0))/w),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),x),d):void 0}},9504:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const l=i(2584);function u(a,h,d,f){const S=a-c(a,d),C=h-c(h,d),k=Math.abs(S-C)-(function(E,y,j){let R=0;const L=E-c(E,j),T=y-c(y,j);for(let D=0;D<Math.abs(L-T);D++){const F=g(E,y)==="A"?-1:1,I=j.buffer.lines.get(L+F*D);I?.isWrapped&&R++}return R})(a,h,d);return w(k,_(g(a,h),f))}function c(a,h){let d=0,f=h.buffer.lines.get(a),S=f?.isWrapped;for(;S&&a>=0&&a<h.rows;)d++,f=h.buffer.lines.get(--a),S=f?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function x(a,h,d,f,S,C){let k=a,E=h,y="";for(;k!==d||E!==f;)k+=S?1:-1,S&&k>C.cols-1?(y+=C.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!S&&k<0&&(y+=C.buffer.translateBufferLineToString(E,!1,0,a+1),k=C.cols-1,a=k,E--);return y+C.buffer.translateBufferLineToString(E,!1,a,k)}function _(a,h){const d=h?"O":"[";return l.C0.ESC+d+a}function w(a,h){a=Math.floor(a);let d="";for(let f=0;f<a;f++)d+=h;return d}n.moveToCellSequence=function(a,h,d,f){const S=d.buffer.x,C=d.buffer.y;if(!d.buffer.hasScrollback)return(function(y,j,R,L,T,D){return u(j,L,T,D).length===0?"":w(x(y,j,y,j-c(j,T),!1,T).length,_("D",D))})(S,C,0,h,d,f)+u(C,h,d,f)+(function(y,j,R,L,T,D){let F;F=u(j,L,T,D).length>0?L-c(L,T):j;const I=L,H=(function(q,A,P,M,O,$){let K;return K=u(P,M,O,$).length>0?M-c(M,O):A,q<P&&K<=M||q>=P&&K<M?"C":"D"})(y,j,R,L,T,D);return w(x(y,F,R,I,H==="C",T).length,_(H,D))})(S,C,a,h,d,f);let k;if(C===h)return k=S>a?"D":"C",w(Math.abs(S-a),_(k,f));k=C>h?"D":"C";const E=Math.abs(C-h);return w((function(y,j){return j.cols-y})(C>h?a:S,d)+(E-1)*d.cols+1+((C>h?S:a)-1),_(k,f))}},1296:function(v,n,i){var l=this&&this.__decorate||function(T,D,F,I){var H,q=arguments.length,A=q<3?D:I===null?I=Object.getOwnPropertyDescriptor(D,F):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(T,D,F,I);else for(var P=T.length-1;P>=0;P--)(H=T[P])&&(A=(q<3?H(A):q>3?H(D,F,A):H(D,F))||A);return q>3&&A&&Object.defineProperty(D,F,A),A},u=this&&this.__param||function(T,D){return function(F,I){D(F,I,T)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=i(3787),g=i(2550),x=i(2223),_=i(6171),w=i(4725),a=i(8055),h=i(8460),d=i(844),f=i(2585),S="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",y="xterm-focus",j="xterm-selection";let R=1,L=n.DomRenderer=class extends d.Disposable{constructor(T,D,F,I,H,q,A,P,M,O){super(),this._element=T,this._screenElement=D,this._viewportElement=F,this._linkifier2=I,this._charSizeService=q,this._optionsService=A,this._bufferService=P,this._coreBrowserService=M,this._themeService=O,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(S+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(S+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const F of this._rowElements)F.style.width=`${this.dimensions.css.canvas.width}px`,F.style.height=`${this.dimensions.css.cell.height}px`,F.style.lineHeight=`${this.dimensions.css.cell.height}px`,F.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const D=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=D,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${C} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${C} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,D+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,D+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",D+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,D+=`${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,D+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[F,I]of T.ansi.entries())D+=`${this._terminalSelector} .${k}${F} { color: ${I.css}; }${this._terminalSelector} .${k}${F}.xterm-dim { color: ${a.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${F} { background-color: ${I.css}; }`;D+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,D){for(let F=this._rowElements.length;F<=D;F++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,D){this._refreshRowElements(T,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,D,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,D,F),this.renderRows(0,this._bufferService.rows-1),!T||!D)return;const I=T[1]-this._bufferService.buffer.ydisp,H=D[1]-this._bufferService.buffer.ydisp,q=Math.max(I,0),A=Math.min(H,this._bufferService.rows-1);if(q>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(F){const M=T[0]>D[0];P.appendChild(this._createSelectionElement(q,M?D[0]:T[0],M?T[0]:D[0],A-q+1))}else{const M=I===q?T[0]:0,O=q===H?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(q,M,O));const $=A-q-1;if(P.appendChild(this._createSelectionElement(q+1,0,this._bufferService.cols,$)),q!==A){const K=H===A?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,K))}}this._selectionContainer.appendChild(P)}_createSelectionElement(T,D,F,I=1){const H=document.createElement("div");return H.style.height=I*this.dimensions.css.cell.height+"px",H.style.top=T*this.dimensions.css.cell.height+"px",H.style.left=D*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(F-D)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,D){const F=this._bufferService.buffer,I=F.ybase+F.y,H=Math.min(F.x,this._bufferService.cols-1),q=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let M=T;M<=D;M++){const O=M+F.ydisp,$=this._rowElements[M],K=F.lines.get(O);if(!$||!K)break;$.replaceChildren(...this._rowFactory.createRow(K,O,O===I,A,P,H,q,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${S}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,D,F,I,H,q){F<0&&(T=0),I<0&&(D=0);const A=this._bufferService.rows-1;F=Math.max(Math.min(F,A),0),I=Math.max(Math.min(I,A),0),H=Math.min(H,this._bufferService.cols);const P=this._bufferService.buffer,M=P.ybase+P.y,O=Math.min(P.x,H-1),$=this._optionsService.rawOptions.cursorBlink,K=this._optionsService.rawOptions.cursorStyle,B=this._optionsService.rawOptions.cursorInactiveStyle;for(let z=F;z<=I;++z){const U=z+P.ydisp,N=this._rowElements[z],W=P.lines.get(U);if(!N||!W)break;N.replaceChildren(...this._rowFactory.createRow(W,U,U===M,K,B,O,$,this.dimensions.css.cell.width,this._widthCache,q?z===F?T:0:-1,q?(z===I?D:H)-1:-1))}}};n.DomRenderer=L=l([u(4,f.IInstantiationService),u(5,w.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,w.ICoreBrowserService),u(9,w.IThemeService)],L)},3787:function(v,n,i){var l=this&&this.__decorate||function(k,E,y,j){var R,L=arguments.length,T=L<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,y):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,y,j);else for(var D=k.length-1;D>=0;D--)(R=k[D])&&(T=(L<3?R(T):L>3?R(E,y,T):R(E,y))||T);return L>3&&T&&Object.defineProperty(E,y,T),T},u=this&&this.__param||function(k,E){return function(y,j){E(y,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),g=i(643),x=i(511),_=i(2585),w=i(8055),a=i(4725),h=i(4269),d=i(6171),f=i(3734);let S=n.DomRendererRowFactory=class{constructor(k,E,y,j,R,L,T){this._document=k,this._characterJoinerService=E,this._optionsService=y,this._coreBrowserService=j,this._coreService=R,this._decorationService=L,this._themeService=T,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,y){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=y}createRow(k,E,y,j,R,L,T,D,F,I,H){const q=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let M,O=k.getNoBgTrimmedLength();y&&O<L+1&&(O=L+1);let $=0,K="",B=0,z=0,U=0,N=!1,W=0,X=!1,V=0;const ie=[],ee=I!==-1&&H!==-1;for(let me=0;me<O;me++){k.loadCell(me,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let G=!1,pe=me,oe=this._workCell;if(A.length>0&&me===A[0][0]){G=!0;const _e=A.shift();oe=new h.JoinedCellData(this._workCell,k.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),pe=_e[1]-1,he=oe.getWidth()}const We=this._isCellInSelection(me,E),ut=y&&me===L,Oe=ee&&me>=I&&me<=H;let be=!1;this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{be=!0}));let Ue=oe.getChars()||g.WHITESPACE_CELL_CHAR;if(Ue===" "&&(oe.isUnderline()||oe.isOverline())&&(Ue=" "),V=he*D-F.get(Ue,oe.isBold(),oe.isItalic()),M){if($&&(We&&X||!We&&!X&&oe.bg===B)&&(We&&X&&P.selectionForeground||oe.fg===z)&&oe.extended.ext===U&&Oe===N&&V===W&&!ut&&!G&&!be){K+=Ue,$++;continue}$&&(M.textContent=K),M=this._document.createElement("span"),$=0,K=""}else M=this._document.createElement("span");if(B=oe.bg,z=oe.fg,U=oe.extended.ext,N=Oe,W=V,X=We,G&&L>=me&&L<=pe&&(L=me),!this._coreService.isCursorHidden&&ut){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&ie.push("xterm-cursor-blink"),ie.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline")}}if(oe.isBold()&&ie.push("xterm-bold"),oe.isItalic()&&ie.push("xterm-italic"),oe.isDim()&&ie.push("xterm-dim"),K=oe.isInvisible()?g.WHITESPACE_CELL_CHAR:oe.getChars()||g.WHITESPACE_CELL_CHAR,oe.isUnderline()&&(ie.push(`xterm-underline-${oe.extended.underlineStyle}`),K===" "&&(K=" "),!oe.isUnderlineColorDefault()))if(oe.isUnderlineColorRGB())M.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(oe.getUnderlineColor()).join(",")})`;else{let _e=oe.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&oe.isBold()&&_e<8&&(_e+=8),M.style.textDecorationColor=P.ansi[_e].css}oe.isOverline()&&(ie.push("xterm-overline"),K===" "&&(K=" ")),oe.isStrikethrough()&&ie.push("xterm-strikethrough"),Oe&&(M.style.textDecoration="underline");let Be=oe.getFgColor(),tt=oe.getFgColorMode(),Ye=oe.getBgColor(),Ze=oe.getBgColorMode();const Xe=!!oe.isInverse();if(Xe){const _e=Be;Be=Ye,Ye=_e;const pt=tt;tt=Ze,Ze=pt}let Ne,Ae,ve,He=!1;switch(this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{_e.options.layer!=="top"&&He||(_e.backgroundColorRGB&&(Ze=50331648,Ye=_e.backgroundColorRGB.rgba>>8&16777215,Ne=_e.backgroundColorRGB),_e.foregroundColorRGB&&(tt=50331648,Be=_e.foregroundColorRGB.rgba>>8&16777215,Ae=_e.foregroundColorRGB),He=_e.options.layer==="top")})),!He&&We&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,Ye=Ne.rgba>>8&16777215,Ze=50331648,He=!0,P.selectionForeground&&(tt=50331648,Be=P.selectionForeground.rgba>>8&16777215,Ae=P.selectionForeground)),He&&ie.push("xterm-decoration-top"),Ze){case 16777216:case 33554432:ve=P.ansi[Ye],ie.push(`xterm-bg-${Ye}`);break;case 50331648:ve=w.rgba.toColor(Ye>>16,Ye>>8&255,255&Ye),this._addStyle(M,`background-color:#${C((Ye>>>0).toString(16),"0",6)}`);break;default:Xe?(ve=P.foreground,ie.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):ve=P.background}switch(Ne||oe.isDim()&&(Ne=w.color.multiplyOpacity(ve,.5)),tt){case 16777216:case 33554432:oe.isBold()&&Be<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Be+=8),this._applyMinimumContrast(M,ve,P.ansi[Be],oe,Ne,void 0)||ie.push(`xterm-fg-${Be}`);break;case 50331648:const _e=w.rgba.toColor(Be>>16&255,Be>>8&255,255&Be);this._applyMinimumContrast(M,ve,_e,oe,Ne,Ae)||this._addStyle(M,`color:#${C(Be.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(M,ve,P.foreground,oe,Ne,void 0)||Xe&&ie.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ie.length&&(M.className=ie.join(" "),ie.length=0),ut||G||be?M.textContent=K:$++,V!==this.defaultSpacing&&(M.style.letterSpacing=`${V}px`),q.push(M),me=pe}return M&&$&&(M.textContent=K),q}_applyMinimumContrast(k,E,y,j,R,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let D;if(R||L||(D=T.getColor(E.rgba,y.rgba)),D===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=w.color.ensureContrastRatio(R||E,L||y,F),T.setColor((R||E).rgba,(L||y).rgba,D??null)}return!!D&&(this._addStyle(k,`color:${D.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const y=this._selectionStart,j=this._selectionEnd;return!(!y||!j)&&(this._columnSelectMode?y[0]<=j[0]?k>=y[0]&&E>=y[1]&&k<j[0]&&E<=j[1]:k<y[0]&&E>=y[1]&&k>=j[0]&&E<=j[1]:E>y[1]&&E<j[1]||y[1]===j[1]&&E===y[1]&&k>=y[0]&&k<j[0]||y[1]<j[1]&&E===j[1]&&k<j[0]||y[1]<j[1]&&E===y[1]&&k>=y[0])}};function C(k,E,y){for(;k.length<y;)k=E+k;return k}n.DomRendererRowFactory=S=l([u(1,a.ICharacterJoinerService),u(2,_.IOptionsService),u(3,a.ICoreBrowserService),u(4,_.ICoreService),u(5,_.IDecorationService),u(6,a.IThemeService)],S)},2550:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=i.createElement("span"),u=i.createElement("span");u.style.fontWeight="bold";const c=i.createElement("span");c.style.fontStyle="italic";const g=i.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[l,u,c,g],this._container.appendChild(l),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(g),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,l,u,c){i===this._font&&l===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=l,this._weight=u,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,l,u){let c=0;if(!l&&!u&&i.length===1&&(c=i.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(i,0);let g=i;l&&(g+="B"),u&&(g+="I");let x=this._holey.get(g);if(x===void 0){let _=0;l&&(_|=1),u&&(_|=2),x=this._measure(i,_),this._holey.set(g,x)}return x}_measure(i,l){const u=this._measureElements[l];return u.textContent=i.repeat(32),u.offsetWidth/32}}},2223:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const l=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,n)=>{function i(l){return 57508<=l&&l<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},n.excludeFromContrastRatioDemands=function(l){return i(l)||(function(u){return 9472<=u&&u<=9631})(l)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,l=this.selectionEnd;return!(!i||!l)&&(i[1]>l[1]||i[1]===l[1]&&i[0]>l[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,n,i){var l=this&&this.__decorate||function(a,h,d,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(h,d,k):S(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),g=i(8460),x=i(844);let _=n.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new w(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};n.CharSizeService=_=l([u(2,c.IOptionsService)],_);class w{constructor(h,d,f){this._document=h,this._parentElement=d,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,n,i){var l=this&&this.__decorate||function(h,d,f,S){var C,k=arguments.length,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,S);else for(var y=h.length-1;y>=0;y--)(C=h[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,S){d(f,S,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),g=i(643),x=i(511),_=i(2585);class w extends c.AttributeData{constructor(d,f,S){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=S}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=w;let a=n.CharacterJoinerService=class Hl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const S=[],C=f.translateToString(!0);let k=0,E=0,y=0,j=f.getFg(0),R=f.getBg(0);for(let L=0;L<f.getTrimmedLength();L++)if(f.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==R){if(L-k>1){const T=this._getJoinedRanges(C,y,E,f,k);for(let D=0;D<T.length;D++)S.push(T[D])}k=L,y=E,j=this._workCell.fg,R=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(C,y,E,f,k);for(let T=0;T<L.length;T++)S.push(L[T])}return S}_getJoinedRanges(d,f,S,C,k){const E=d.substring(f,S);let y=[];try{y=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const R=this._characterJoiners[j].handler(E);for(let L=0;L<R.length;L++)Hl._mergeRanges(y,R[L])}catch(R){console.error(R)}return this._stringRangesToCellRanges(y,C,k),y}_stringRangesToCellRanges(d,f,S){let C=0,k=!1,E=0,y=d[C];if(y){for(let j=S;j<this._bufferService.cols;j++){const R=f.getWidth(j),L=f.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&y[0]<=E&&(y[0]=j,k=!0),y[1]<=E){if(y[1]=j,y=d[++C],!y)break;y[0]<=E?(y[0]=j,k=!0):k=!1}E+=L}}y&&(y[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let S=!1;for(let C=0;C<d.length;C++){const k=d[C];if(S){if(f[1]<=k[0])return d[C-1][1]=f[1],d;if(f[1]<=k[1])return d[C-1][1]=Math.max(f[1],k[1]),d.splice(C,1),d;d.splice(C,1),C--}else{if(f[1]<=k[0])return d.splice(C,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),S=!0)}}return S?d[d.length-1][1]=f[1]:d.push(f),d}};n.CharacterJoinerService=a=l([u(0,_.IBufferService)],a)},5114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,l){this._textarea=i,this.window=l,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(v,n,i){var l=this&&this.__decorate||function(_,w,a,h){var d,f=arguments.length,S=f<3?w:h===null?h=Object.getOwnPropertyDescriptor(w,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,w,a,h);else for(var C=_.length-1;C>=0;C--)(d=_[C])&&(S=(f<3?d(S):f>3?d(w,a,S):d(w,a))||S);return f>3&&S&&Object.defineProperty(w,a,S),S},u=this&&this.__param||function(_,w){return function(a,h){w(a,h,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),g=i(9806);let x=n.MouseService=class{constructor(_,w){this._renderService=_,this._charSizeService=w}getCoords(_,w,a,h,d){return(0,g.getCoords)(window,_,w,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(_,w){const a=(0,g.getCoordsRelativeToElement)(window,_,w);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};n.MouseService=x=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],x)},3230:function(v,n,i){var l=this&&this.__decorate||function(S,C,k,E){var y,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,E);else for(var L=S.length-1;L>=0;L--)(y=S[L])&&(R=(j<3?y(R):j>3?y(C,k,R):y(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},u=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=i(3656),g=i(6193),x=i(5596),_=i(4725),w=i(8460),a=i(844),h=i(7226),d=i(2585);let f=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(S,C,k,E,y,j,R,L){if(super(),this._rowCount=S,this._charSizeService=E,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new w.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new w.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new w.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new w.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((T,D)=>this._renderRows(T,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(y.onDecorationRegistered((()=>this._fullRefresh()))),this.register(y.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const T=new R.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});T.observe(C),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(S){this._isPaused=S.isIntersecting===void 0?S.intersectionRatio===0:!S.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(S,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(S,C,this._rowCount))}_renderRows(S,C){this._renderer.value&&(S=Math.min(S,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(S,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:S,end:C}),this._onRender.fire({start:S,end:C}),this._isNextRenderRedrawOnly=!0)}resize(S,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(S){this._renderer.value=S,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(S){return this._renderDebouncer.addRefreshCallback(S)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var S,C;this._renderer.value&&((C=(S=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(S),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(S,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(S,C))):this._renderer.value.handleResize(S,C),this._fullRefresh())}handleCharSizeChanged(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCharSizeChanged()}handleBlur(){var S;(S=this._renderer.value)===null||S===void 0||S.handleBlur()}handleFocus(){var S;(S=this._renderer.value)===null||S===void 0||S.handleFocus()}handleSelectionChanged(S,C,k){var E;this._selectionState.start=S,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(S,C,k)}handleCursorMove(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCursorMove()}clear(){var S;(S=this._renderer.value)===null||S===void 0||S.clear()}};n.RenderService=f=l([u(2,d.IOptionsService),u(3,_.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,_.ICoreBrowserService),u(7,_.IThemeService)],f)},9312:function(v,n,i){var l=this&&this.__decorate||function(y,j,R,L){var T,D=arguments.length,F=D<3?j:L===null?L=Object.getOwnPropertyDescriptor(j,R):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(y,j,R,L);else for(var I=y.length-1;I>=0;I--)(T=y[I])&&(F=(D<3?T(F):D>3?T(j,R,F):T(j,R))||F);return D>3&&F&&Object.defineProperty(j,R,F),F},u=this&&this.__param||function(y,j){return function(R,L){j(R,L,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),g=i(9504),x=i(456),_=i(4725),w=i(8460),a=i(844),h=i(6114),d=i(4841),f=i(511),S=i(2585),C=" ",k=new RegExp(C,"g");let E=n.SelectionService=class extends a.Disposable{constructor(y,j,R,L,T,D,F,I,H){super(),this._element=y,this._screenElement=j,this._linkifier=R,this._bufferService=L,this._coreService=T,this._mouseService=D,this._optionsService=F,this._renderService=I,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new w.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new w.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new w.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new w.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=q=>this._handleMouseMove(q),this._mouseUpListener=q=>this._handleMouseUp(q),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((q=>this._handleTrim(q))),this.register(this._bufferService.buffers.onBufferActivate((q=>this._handleBufferActivate(q)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!y||!j||y[0]===j[0]&&y[1]===j[1])}get selectionText(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!y||!j)return"";const R=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(y[0]===j[0])return"";const T=y[0]<j[0]?y[0]:j[0],D=y[0]<j[0]?j[0]:y[0];for(let F=y[1];F<=j[1];F++){const I=R.translateBufferLineToString(F,!0,T,D);L.push(I)}}else{const T=y[1]===j[1]?j[0]:void 0;L.push(R.translateBufferLineToString(y[1],!0,y[0],T));for(let D=y[1]+1;D<=j[1]-1;D++){const F=R.lines.get(D),I=R.translateBufferLineToString(D,!0);F?.isWrapped?L[L.length-1]+=I:L.push(I)}if(y[1]!==j[1]){const D=R.lines.get(j[1]),F=R.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?L[L.length-1]+=F:L.push(F)}}return L.map((T=>T.replace(k," "))).join(h.isWindows?`\r
23
+ WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=x=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],x)},6193:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,l){this._parentWindow=i,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,l,u){this._rowCount=u,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const l=i(844);class u extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}n.ScreenDprMonitor=u},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const l=i(3614),u=i(3656),c=i(6465),g=i(9042),x=i(3730),_=i(1680),w=i(3107),a=i(5744),h=i(2950),d=i(1296),f=i(428),S=i(4269),C=i(5114),k=i(8934),E=i(3230),y=i(9312),j=i(4725),R=i(6731),L=i(8055),T=i(8969),D=i(8460),F=i(844),I=i(6114),H=i(8437),q=i(2584),A=i(7399),P=i(5941),M=i(9074),O=i(2585),$=i(5435),K=i(4567),B=typeof window<"u"?window.document:null;class z extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(M.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((W,X)=>this.refresh(W,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((W=>this._reportWindowsOptions(W)))),this.register(this._inputHandler.onColor((W=>this._handleColorEvent(W)))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((W=>this._afterResize(W.cols,W.rows)))),this.register((0,F.toDisposable)((()=>{var W,X;this._customKeyEventHandler=void 0,(X=(W=this.element)===null||W===void 0?void 0:W.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const W of N){let X,V="";switch(W.index){case 256:X="foreground",V="10";break;case 257:X="background",V="11";break;case 258:X="cursor",V="12";break;default:X="ansi",V="4;"+W.index}switch(W.type){case 0:const ie=L.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[W.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${q.C0.ESC}]${V};${(0,P.toRgbString)(ie)}${q.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((ee=>ee.ansi[W.index]=L.rgba.toColor(...W.color)));else{const ee=X;this._themeService.modifyColors((me=>me[ee]=L.rgba.toColor(...W.color)))}break;case 2:this._themeService.restoreColor(W.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const N=this.buffer.ybase+this.buffer.y,W=this.buffer.lines.get(N);if(!W)return;const X=Math.min(this.buffer.x,this.cols-1),V=this._renderService.dimensions.css.cell.height,ie=W.getWidth(X),ee=this._renderService.dimensions.css.cell.width*ie,me=this.buffer.y*this._renderService.dimensions.css.cell.height,he=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=me+"px",this.textarea.style.width=ee+"px",this.textarea.style.height=V+"px",this.textarea.style.lineHeight=V+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(W=>{this.hasSelection()&&(0,l.copyHandler)(W,this._selectionService)})));const N=W=>(0,l.handlePasteEvent)(W,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,u.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(W=>{W.button===2&&(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(W=>{(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(W=>{W.button===1&&(0,l.moveTextAreaUnderMouseCursor)(W,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var W;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const X=B.createDocumentFragment();this._viewportElement=B.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=B.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=B.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=B.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=B.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(C.CoreBrowserService,this.textarea,(W=this._document.defaultView)!==null&&W!==void 0?W:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(V=>this._handleTextAreaFocus(V)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(S.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((V=>this._onRender.fire(V)))),this.onResize((V=>this._renderService.resize(V.cols,V.rows))),this._compositionView=B.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(_.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((V=>this.scrollLines(V.amount,V.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(y.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((V=>this.scrollLines(V.amount,V.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((V=>this._renderService.handleSelectionChanged(V.start,V.end,V.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((V=>{this.textarea.value=V,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((V=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(w.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(V=>this._selectionService.handleMouseDown(V)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(V=>this._handleScreenReaderModeOptionChange(V)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(V=>{!this._overviewRulerRenderer&&V&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,W=this.element;function X(ee){const me=N._mouseService.getMouseReportCoords(ee,N.screenElement);if(!me)return!1;let he,G;switch(ee.overrideType||ee.type){case"mousemove":G=32,ee.buttons===void 0?(he=3,ee.button!==void 0&&(he=ee.button<3?ee.button:3)):he=1&ee.buttons?0:4&ee.buttons?1:2&ee.buttons?2:3;break;case"mouseup":G=0,he=ee.button<3?ee.button:3;break;case"mousedown":G=1,he=ee.button<3?ee.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(ee)===0)return!1;G=ee.deltaY<0?0:1,he=4;break;default:return!1}return!(G===void 0||he===void 0||he>4)&&N.coreMouseService.triggerMouseEvent({col:me.col,row:me.row,x:me.x,y:me.y,button:he,action:G,ctrl:ee.ctrlKey,alt:ee.altKey,shift:ee.shiftKey})}const V={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ie={mouseup:ee=>(X(ee),ee.buttons||(this._document.removeEventListener("mouseup",V.mouseup),V.mousedrag&&this._document.removeEventListener("mousemove",V.mousedrag)),this.cancel(ee)),wheel:ee=>(X(ee),this.cancel(ee,!0)),mousedrag:ee=>{ee.buttons&&X(ee)},mousemove:ee=>{ee.buttons||X(ee)}};this.register(this.coreMouseService.onProtocolChange((ee=>{ee?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ee)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&ee?V.mousemove||(W.addEventListener("mousemove",ie.mousemove),V.mousemove=ie.mousemove):(W.removeEventListener("mousemove",V.mousemove),V.mousemove=null),16&ee?V.wheel||(W.addEventListener("wheel",ie.wheel,{passive:!1}),V.wheel=ie.wheel):(W.removeEventListener("wheel",V.wheel),V.wheel=null),2&ee?V.mouseup||(W.addEventListener("mouseup",ie.mouseup),V.mouseup=ie.mouseup):(this._document.removeEventListener("mouseup",V.mouseup),W.removeEventListener("mouseup",V.mouseup),V.mouseup=null),4&ee?V.mousedrag||(V.mousedrag=ie.mousedrag):(this._document.removeEventListener("mousemove",V.mousedrag),V.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(W,"mousedown",(ee=>{if(ee.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ee))return X(ee),V.mouseup&&this._document.addEventListener("mouseup",V.mouseup),V.mousedrag&&this._document.addEventListener("mousemove",V.mousedrag),this.cancel(ee)}))),this.register((0,u.addDisposableDomListener)(W,"wheel",(ee=>{if(!V.wheel){if(!this.buffer.hasScrollback){const me=this.viewport.getLinesScrolled(ee);if(me===0)return;const he=q.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ee.deltaY<0?"A":"B");let G="";for(let pe=0;pe<Math.abs(me);pe++)G+=he;return this.coreService.triggerDataEvent(G,!0),this.cancel(ee,!0)}return this.viewport.handleWheel(ee)?this.cancel(ee):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(W,"touchstart",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ee),this.cancel(ee)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(W,"touchmove",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ee)?void 0:this.cancel(ee)}),{passive:!1}))}refresh(N,W){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(N,W)}updateCursorStyle(N){var W;!((W=this._selectionService)===null||W===void 0)&&W.shouldColumnSelect(N)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(N,W,X=0){var V;X===1?(super.scrollLines(N,W,X),this.refresh(0,this.rows-1)):(V=this.viewport)===null||V===void 0||V.scrollLines(N)}paste(N){(0,l.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const W=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),W}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,W,X){this._selectionService.setSelection(N,W,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,W){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(N,W)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const W=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!W&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;W||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const V=this.rows-1;return this.scrollLines(X.type===2?-V:V),this.cancel(N,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(X.cancel&&this.cancel(N,!0),!X.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==q.C0.ETX&&X.key!==q.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,W){const X=N.isMac&&!this.options.macOptionIsMeta&&W.altKey&&!W.ctrlKey&&!W.metaKey||N.isWindows&&W.altKey&&W.ctrlKey&&!W.metaKey||N.isWindows&&W.getModifierState("AltGraph");return W.type==="keypress"?X:X&&(!W.keyCode||W.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(W){return W.keyCode===16||W.keyCode===17||W.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let W;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)W=N.charCode;else if(N.which===null||N.which===void 0)W=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;W=N.which}return!(!W||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(W=String.fromCharCode(W),this._onKey.fire({key:W,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(W,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const W=N.data;return this.coreService.triggerDataEvent(W,!0),this.cancel(N),!0}return!1}resize(N,W){N!==this.cols||W!==this.rows?super.resize(N,W):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,W){var X,V;(X=this._charSizeService)===null||X===void 0||X.measure(),(V=this.viewport)===null||V===void 0||V.syncScrollArea(!0)}clear(){var N;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let W=1;W<this.rows;W++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,W;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(W=this.viewport)===null||W===void 0||W.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(q.C0.ESC+"[I"):this.coreService.triggerDataEvent(q.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const W=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${q.C0.ESC}[4;${X};${W}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const V=this._renderService.dimensions.css.cell.width.toFixed(0),ie=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${q.C0.ESC}[6;${ie};${V}t`)}}cancel(N,W){if(this.options.cancelEvents||W)return N.preventDefault(),N.stopPropagation(),!1}}n.Terminal=z},9924:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,l=1e3){this._renderCallback=i,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,l,u){this._rowCount=u,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l)}}},1680:function(v,n,i){var l=this&&this.__decorate||function(h,d,f,S){var C,k=arguments.length,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,S);else for(var y=h.length-1;y>=0;y--)(C=h[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,S){d(f,S,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),g=i(4725),x=i(8460),_=i(844),w=i(2585);let a=n.Viewport=class extends _.Disposable{constructor(h,d,f,S,C,k,E,y){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=f,this._optionsService=S,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(y.colors),this.register(y.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const d=this._getPixelsScrolled(h);return d!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(h,d){var f;let S,C="";const k=[],E=d??this._bufferService.buffer.lines.length,y=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const R=y.get(j);if(!R)continue;const L=(f=y.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=R.translateToString(!L),!L||j===y.length-1){const T=document.createElement("div");T.textContent=C,k.push(T),C.length>0&&(S=T),C=""}}return{bufferElements:k,cursorElement:S}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(h,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const d=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}};n.Viewport=a=l([u(2,w.IBufferService),u(3,w.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],a)},3107:function(v,n,i){var l=this&&this.__decorate||function(a,h,d,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(h,d,k):S(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),g=i(4725),x=i(844),_=i(2585);let w=n.BufferDecorationRenderer=class extends x.Disposable{constructor(a,h,d,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((S=>this._removeDecoration(S)))),this.register((0,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=(d=a.options.x)!==null&&d!==void 0?d:0;return S&&S>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,h=a.element){var d;if(!h)return;const f=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=w=l([u(1,_.IBufferService),u(2,_.IDecorationService),u(3,g.IRenderService)],w)},5871:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const l of this._zones)if(l.color===i.options.overviewRulerOptions.color&&l.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,i.marker.line))return;if(this._lineAdjacentToZone(l,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(l,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,l){return l>=i.startBufferLine&&l<=i.endBufferLine}_lineAdjacentToZone(i,l,u){return l>=i.startBufferLine-this._linePadding[u||"full"]&&l<=i.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(i,l){i.startBufferLine=Math.min(i.startBufferLine,l),i.endBufferLine=Math.max(i.endBufferLine,l)}}},5744:function(v,n,i){var l=this&&this.__decorate||function(S,C,k,E){var y,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,E);else for(var L=S.length-1;L>=0;L--)(y=S[L])&&(R=(j<3?y(R):j>3?y(C,k,R):y(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},u=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=i(5871),g=i(3656),x=i(4725),_=i(844),w=i(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends _.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(S,C,k,E,y,j,R){var L;super(),this._viewportElement=S,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=y,this._optionsService=j,this._coreBrowseService=R,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,_.toDisposable)((()=>{var D;(D=this._canvas)===null||D===void 0||D.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const S=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=S,h.center=C,h.right=S,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const S=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(S,12),6)*this._coreBrowseService.dpr);a.left=C,a.center=C,a.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const S=this._colorZoneStore.zones;for(const C of S)C.position!=="full"&&this._renderColorZone(C);for(const C of S)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(S){this._ctx.fillStyle=S.color,this._ctx.fillRect(d[S.position||"full"],Math.round((this._canvas.height-1)*(S.startBufferLine/this._bufferService.buffers.active.lines.length)-a[S.position||"full"]/2),h[S.position||"full"],Math.round((this._canvas.height-1)*((S.endBufferLine-S.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[S.position||"full"]))}_queueRefresh(S,C){this._shouldUpdateDimensions=S||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=f=l([u(2,w.IBufferService),u(3,w.IDecorationService),u(4,x.IRenderService),u(5,w.IOptionsService),u(6,x.ICoreBrowserService)],f)},2950:function(v,n,i){var l=this&&this.__decorate||function(w,a,h,d){var f,S=arguments.length,C=S<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,a,h,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(a,h,C):f(a,h))||C);return S>3&&C&&Object.defineProperty(a,h,C),C},u=this&&this.__param||function(w,a){return function(h,d){a(h,d,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),g=i(2585),x=i(2584);let _=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(w,a,h,d,f,S){this._textarea=w,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=f,this._renderService=S,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(w){this._compositionView.textContent=w.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(w){if(this._isComposing||this._isSendingComposition){if(w.keyCode===229||w.keyCode===16||w.keyCode===17||w.keyCode===18)return!1;this._finalizeComposition(!1)}return w.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(w){if(this._compositionView.classList.remove("active"),this._isComposing=!1,w){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const w=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(w,"");this._dataAlreadySent=h,a.length>w.length?this._coreService.triggerDataEvent(h,!0):a.length<w.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===w.length&&a!==w&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(w){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const S=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(S.width,1)+"px",this._textarea.style.height=Math.max(S.height,1)+"px",this._textarea.style.lineHeight=S.height+"px"}w||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=_=l([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,c.IRenderService)],_)},9806:(v,n)=>{function i(l,u,c){const g=c.getBoundingClientRect(),x=l.getComputedStyle(c),_=parseInt(x.getPropertyValue("padding-left")),w=parseInt(x.getPropertyValue("padding-top"));return[u.clientX-g.left-_,u.clientY-g.top-w]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(l,u,c,g,x,_,w,a,h){if(!_)return;const d=i(l,u,c);return d?(d[0]=Math.ceil((d[0]+(h?w/2:0))/w),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),x),d):void 0}},9504:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const l=i(2584);function u(a,h,d,f){const S=a-c(a,d),C=h-c(h,d),k=Math.abs(S-C)-(function(E,y,j){let R=0;const L=E-c(E,j),T=y-c(y,j);for(let D=0;D<Math.abs(L-T);D++){const F=g(E,y)==="A"?-1:1,I=j.buffer.lines.get(L+F*D);I?.isWrapped&&R++}return R})(a,h,d);return w(k,_(g(a,h),f))}function c(a,h){let d=0,f=h.buffer.lines.get(a),S=f?.isWrapped;for(;S&&a>=0&&a<h.rows;)d++,f=h.buffer.lines.get(--a),S=f?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function x(a,h,d,f,S,C){let k=a,E=h,y="";for(;k!==d||E!==f;)k+=S?1:-1,S&&k>C.cols-1?(y+=C.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!S&&k<0&&(y+=C.buffer.translateBufferLineToString(E,!1,0,a+1),k=C.cols-1,a=k,E--);return y+C.buffer.translateBufferLineToString(E,!1,a,k)}function _(a,h){const d=h?"O":"[";return l.C0.ESC+d+a}function w(a,h){a=Math.floor(a);let d="";for(let f=0;f<a;f++)d+=h;return d}n.moveToCellSequence=function(a,h,d,f){const S=d.buffer.x,C=d.buffer.y;if(!d.buffer.hasScrollback)return(function(y,j,R,L,T,D){return u(j,L,T,D).length===0?"":w(x(y,j,y,j-c(j,T),!1,T).length,_("D",D))})(S,C,0,h,d,f)+u(C,h,d,f)+(function(y,j,R,L,T,D){let F;F=u(j,L,T,D).length>0?L-c(L,T):j;const I=L,H=(function(q,A,P,M,O,$){let K;return K=u(P,M,O,$).length>0?M-c(M,O):A,q<P&&K<=M||q>=P&&K<M?"C":"D"})(y,j,R,L,T,D);return w(x(y,F,R,I,H==="C",T).length,_(H,D))})(S,C,a,h,d,f);let k;if(C===h)return k=S>a?"D":"C",w(Math.abs(S-a),_(k,f));k=C>h?"D":"C";const E=Math.abs(C-h);return w((function(y,j){return j.cols-y})(C>h?a:S,d)+(E-1)*d.cols+1+((C>h?S:a)-1),_(k,f))}},1296:function(v,n,i){var l=this&&this.__decorate||function(T,D,F,I){var H,q=arguments.length,A=q<3?D:I===null?I=Object.getOwnPropertyDescriptor(D,F):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(T,D,F,I);else for(var P=T.length-1;P>=0;P--)(H=T[P])&&(A=(q<3?H(A):q>3?H(D,F,A):H(D,F))||A);return q>3&&A&&Object.defineProperty(D,F,A),A},u=this&&this.__param||function(T,D){return function(F,I){D(F,I,T)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=i(3787),g=i(2550),x=i(2223),_=i(6171),w=i(4725),a=i(8055),h=i(8460),d=i(844),f=i(2585),S="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",y="xterm-focus",j="xterm-selection";let R=1,L=n.DomRenderer=class extends d.Disposable{constructor(T,D,F,I,H,q,A,P,M,O){super(),this._element=T,this._screenElement=D,this._viewportElement=F,this._linkifier2=I,this._charSizeService=q,this._optionsService=A,this._bufferService=P,this._coreBrowserService=M,this._themeService=O,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(S+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(S+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const F of this._rowElements)F.style.width=`${this.dimensions.css.canvas.width}px`,F.style.height=`${this.dimensions.css.cell.height}px`,F.style.lineHeight=`${this.dimensions.css.cell.height}px`,F.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const D=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=D,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${C} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${C} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,D+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,D+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",D+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,D+=`${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,D+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[F,I]of T.ansi.entries())D+=`${this._terminalSelector} .${k}${F} { color: ${I.css}; }${this._terminalSelector} .${k}${F}.xterm-dim { color: ${a.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${F} { background-color: ${I.css}; }`;D+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,D){for(let F=this._rowElements.length;F<=D;F++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,D){this._refreshRowElements(T,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,D,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,D,F),this.renderRows(0,this._bufferService.rows-1),!T||!D)return;const I=T[1]-this._bufferService.buffer.ydisp,H=D[1]-this._bufferService.buffer.ydisp,q=Math.max(I,0),A=Math.min(H,this._bufferService.rows-1);if(q>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(F){const M=T[0]>D[0];P.appendChild(this._createSelectionElement(q,M?D[0]:T[0],M?T[0]:D[0],A-q+1))}else{const M=I===q?T[0]:0,O=q===H?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(q,M,O));const $=A-q-1;if(P.appendChild(this._createSelectionElement(q+1,0,this._bufferService.cols,$)),q!==A){const K=H===A?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,K))}}this._selectionContainer.appendChild(P)}_createSelectionElement(T,D,F,I=1){const H=document.createElement("div");return H.style.height=I*this.dimensions.css.cell.height+"px",H.style.top=T*this.dimensions.css.cell.height+"px",H.style.left=D*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(F-D)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,D){const F=this._bufferService.buffer,I=F.ybase+F.y,H=Math.min(F.x,this._bufferService.cols-1),q=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let M=T;M<=D;M++){const O=M+F.ydisp,$=this._rowElements[M],K=F.lines.get(O);if(!$||!K)break;$.replaceChildren(...this._rowFactory.createRow(K,O,O===I,A,P,H,q,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${S}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,D,F,I,H,q){F<0&&(T=0),I<0&&(D=0);const A=this._bufferService.rows-1;F=Math.max(Math.min(F,A),0),I=Math.max(Math.min(I,A),0),H=Math.min(H,this._bufferService.cols);const P=this._bufferService.buffer,M=P.ybase+P.y,O=Math.min(P.x,H-1),$=this._optionsService.rawOptions.cursorBlink,K=this._optionsService.rawOptions.cursorStyle,B=this._optionsService.rawOptions.cursorInactiveStyle;for(let z=F;z<=I;++z){const U=z+P.ydisp,N=this._rowElements[z],W=P.lines.get(U);if(!N||!W)break;N.replaceChildren(...this._rowFactory.createRow(W,U,U===M,K,B,O,$,this.dimensions.css.cell.width,this._widthCache,q?z===F?T:0:-1,q?(z===I?D:H)-1:-1))}}};n.DomRenderer=L=l([u(4,f.IInstantiationService),u(5,w.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,w.ICoreBrowserService),u(9,w.IThemeService)],L)},3787:function(v,n,i){var l=this&&this.__decorate||function(k,E,y,j){var R,L=arguments.length,T=L<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,y):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,y,j);else for(var D=k.length-1;D>=0;D--)(R=k[D])&&(T=(L<3?R(T):L>3?R(E,y,T):R(E,y))||T);return L>3&&T&&Object.defineProperty(E,y,T),T},u=this&&this.__param||function(k,E){return function(y,j){E(y,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),g=i(643),x=i(511),_=i(2585),w=i(8055),a=i(4725),h=i(4269),d=i(6171),f=i(3734);let S=n.DomRendererRowFactory=class{constructor(k,E,y,j,R,L,T){this._document=k,this._characterJoinerService=E,this._optionsService=y,this._coreBrowserService=j,this._coreService=R,this._decorationService=L,this._themeService=T,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,y){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=y}createRow(k,E,y,j,R,L,T,D,F,I,H){const q=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let M,O=k.getNoBgTrimmedLength();y&&O<L+1&&(O=L+1);let $=0,K="",B=0,z=0,U=0,N=!1,W=0,X=!1,V=0;const ie=[],ee=I!==-1&&H!==-1;for(let me=0;me<O;me++){k.loadCell(me,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let G=!1,pe=me,oe=this._workCell;if(A.length>0&&me===A[0][0]){G=!0;const _e=A.shift();oe=new h.JoinedCellData(this._workCell,k.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),pe=_e[1]-1,he=oe.getWidth()}const We=this._isCellInSelection(me,E),ut=y&&me===L,Oe=ee&&me>=I&&me<=H;let be=!1;this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{be=!0}));let Ue=oe.getChars()||g.WHITESPACE_CELL_CHAR;if(Ue===" "&&(oe.isUnderline()||oe.isOverline())&&(Ue=" "),V=he*D-F.get(Ue,oe.isBold(),oe.isItalic()),M){if($&&(We&&X||!We&&!X&&oe.bg===B)&&(We&&X&&P.selectionForeground||oe.fg===z)&&oe.extended.ext===U&&Oe===N&&V===W&&!ut&&!G&&!be){K+=Ue,$++;continue}$&&(M.textContent=K),M=this._document.createElement("span"),$=0,K=""}else M=this._document.createElement("span");if(B=oe.bg,z=oe.fg,U=oe.extended.ext,N=Oe,W=V,X=We,G&&L>=me&&L<=pe&&(L=me),!this._coreService.isCursorHidden&&ut){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&ie.push("xterm-cursor-blink"),ie.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline")}}if(oe.isBold()&&ie.push("xterm-bold"),oe.isItalic()&&ie.push("xterm-italic"),oe.isDim()&&ie.push("xterm-dim"),K=oe.isInvisible()?g.WHITESPACE_CELL_CHAR:oe.getChars()||g.WHITESPACE_CELL_CHAR,oe.isUnderline()&&(ie.push(`xterm-underline-${oe.extended.underlineStyle}`),K===" "&&(K=" "),!oe.isUnderlineColorDefault()))if(oe.isUnderlineColorRGB())M.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(oe.getUnderlineColor()).join(",")})`;else{let _e=oe.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&oe.isBold()&&_e<8&&(_e+=8),M.style.textDecorationColor=P.ansi[_e].css}oe.isOverline()&&(ie.push("xterm-overline"),K===" "&&(K=" ")),oe.isStrikethrough()&&ie.push("xterm-strikethrough"),Oe&&(M.style.textDecoration="underline");let Be=oe.getFgColor(),tt=oe.getFgColorMode(),Ye=oe.getBgColor(),Ze=oe.getBgColorMode();const Xe=!!oe.isInverse();if(Xe){const _e=Be;Be=Ye,Ye=_e;const pt=tt;tt=Ze,Ze=pt}let Ne,Ae,ve,He=!1;switch(this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{_e.options.layer!=="top"&&He||(_e.backgroundColorRGB&&(Ze=50331648,Ye=_e.backgroundColorRGB.rgba>>8&16777215,Ne=_e.backgroundColorRGB),_e.foregroundColorRGB&&(tt=50331648,Be=_e.foregroundColorRGB.rgba>>8&16777215,Ae=_e.foregroundColorRGB),He=_e.options.layer==="top")})),!He&&We&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,Ye=Ne.rgba>>8&16777215,Ze=50331648,He=!0,P.selectionForeground&&(tt=50331648,Be=P.selectionForeground.rgba>>8&16777215,Ae=P.selectionForeground)),He&&ie.push("xterm-decoration-top"),Ze){case 16777216:case 33554432:ve=P.ansi[Ye],ie.push(`xterm-bg-${Ye}`);break;case 50331648:ve=w.rgba.toColor(Ye>>16,Ye>>8&255,255&Ye),this._addStyle(M,`background-color:#${C((Ye>>>0).toString(16),"0",6)}`);break;default:Xe?(ve=P.foreground,ie.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):ve=P.background}switch(Ne||oe.isDim()&&(Ne=w.color.multiplyOpacity(ve,.5)),tt){case 16777216:case 33554432:oe.isBold()&&Be<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Be+=8),this._applyMinimumContrast(M,ve,P.ansi[Be],oe,Ne,void 0)||ie.push(`xterm-fg-${Be}`);break;case 50331648:const _e=w.rgba.toColor(Be>>16&255,Be>>8&255,255&Be);this._applyMinimumContrast(M,ve,_e,oe,Ne,Ae)||this._addStyle(M,`color:#${C(Be.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(M,ve,P.foreground,oe,Ne,void 0)||Xe&&ie.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ie.length&&(M.className=ie.join(" "),ie.length=0),ut||G||be?M.textContent=K:$++,V!==this.defaultSpacing&&(M.style.letterSpacing=`${V}px`),q.push(M),me=pe}return M&&$&&(M.textContent=K),q}_applyMinimumContrast(k,E,y,j,R,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let D;if(R||L||(D=T.getColor(E.rgba,y.rgba)),D===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=w.color.ensureContrastRatio(R||E,L||y,F),T.setColor((R||E).rgba,(L||y).rgba,D??null)}return!!D&&(this._addStyle(k,`color:${D.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const y=this._selectionStart,j=this._selectionEnd;return!(!y||!j)&&(this._columnSelectMode?y[0]<=j[0]?k>=y[0]&&E>=y[1]&&k<j[0]&&E<=j[1]:k<y[0]&&E>=y[1]&&k>=j[0]&&E<=j[1]:E>y[1]&&E<j[1]||y[1]===j[1]&&E===y[1]&&k>=y[0]&&k<j[0]||y[1]<j[1]&&E===j[1]&&k<j[0]||y[1]<j[1]&&E===y[1]&&k>=y[0])}};function C(k,E,y){for(;k.length<y;)k=E+k;return k}n.DomRendererRowFactory=S=l([u(1,a.ICharacterJoinerService),u(2,_.IOptionsService),u(3,a.ICoreBrowserService),u(4,_.ICoreService),u(5,_.IDecorationService),u(6,a.IThemeService)],S)},2550:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=i.createElement("span"),u=i.createElement("span");u.style.fontWeight="bold";const c=i.createElement("span");c.style.fontStyle="italic";const g=i.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[l,u,c,g],this._container.appendChild(l),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(g),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,l,u,c){i===this._font&&l===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=l,this._weight=u,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,l,u){let c=0;if(!l&&!u&&i.length===1&&(c=i.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(i,0);let g=i;l&&(g+="B"),u&&(g+="I");let x=this._holey.get(g);if(x===void 0){let _=0;l&&(_|=1),u&&(_|=2),x=this._measure(i,_),this._holey.set(g,x)}return x}_measure(i,l){const u=this._measureElements[l];return u.textContent=i.repeat(32),u.offsetWidth/32}}},2223:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const l=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,n)=>{function i(l){return 57508<=l&&l<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},n.excludeFromContrastRatioDemands=function(l){return i(l)||(function(u){return 9472<=u&&u<=9631})(l)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,l=this.selectionEnd;return!(!i||!l)&&(i[1]>l[1]||i[1]===l[1]&&i[0]>l[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,n,i){var l=this&&this.__decorate||function(a,h,d,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(h,d,k):S(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),g=i(8460),x=i(844);let _=n.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new w(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};n.CharSizeService=_=l([u(2,c.IOptionsService)],_);class w{constructor(h,d,f){this._document=h,this._parentElement=d,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,n,i){var l=this&&this.__decorate||function(h,d,f,S){var C,k=arguments.length,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,S);else for(var y=h.length-1;y>=0;y--)(C=h[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,S){d(f,S,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),g=i(643),x=i(511),_=i(2585);class w extends c.AttributeData{constructor(d,f,S){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=S}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=w;let a=n.CharacterJoinerService=class $l{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const S=[],C=f.translateToString(!0);let k=0,E=0,y=0,j=f.getFg(0),R=f.getBg(0);for(let L=0;L<f.getTrimmedLength();L++)if(f.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==R){if(L-k>1){const T=this._getJoinedRanges(C,y,E,f,k);for(let D=0;D<T.length;D++)S.push(T[D])}k=L,y=E,j=this._workCell.fg,R=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(C,y,E,f,k);for(let T=0;T<L.length;T++)S.push(L[T])}return S}_getJoinedRanges(d,f,S,C,k){const E=d.substring(f,S);let y=[];try{y=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const R=this._characterJoiners[j].handler(E);for(let L=0;L<R.length;L++)$l._mergeRanges(y,R[L])}catch(R){console.error(R)}return this._stringRangesToCellRanges(y,C,k),y}_stringRangesToCellRanges(d,f,S){let C=0,k=!1,E=0,y=d[C];if(y){for(let j=S;j<this._bufferService.cols;j++){const R=f.getWidth(j),L=f.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&y[0]<=E&&(y[0]=j,k=!0),y[1]<=E){if(y[1]=j,y=d[++C],!y)break;y[0]<=E?(y[0]=j,k=!0):k=!1}E+=L}}y&&(y[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let S=!1;for(let C=0;C<d.length;C++){const k=d[C];if(S){if(f[1]<=k[0])return d[C-1][1]=f[1],d;if(f[1]<=k[1])return d[C-1][1]=Math.max(f[1],k[1]),d.splice(C,1),d;d.splice(C,1),C--}else{if(f[1]<=k[0])return d.splice(C,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),S=!0)}}return S?d[d.length-1][1]=f[1]:d.push(f),d}};n.CharacterJoinerService=a=l([u(0,_.IBufferService)],a)},5114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,l){this._textarea=i,this.window=l,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(v,n,i){var l=this&&this.__decorate||function(_,w,a,h){var d,f=arguments.length,S=f<3?w:h===null?h=Object.getOwnPropertyDescriptor(w,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,w,a,h);else for(var C=_.length-1;C>=0;C--)(d=_[C])&&(S=(f<3?d(S):f>3?d(w,a,S):d(w,a))||S);return f>3&&S&&Object.defineProperty(w,a,S),S},u=this&&this.__param||function(_,w){return function(a,h){w(a,h,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),g=i(9806);let x=n.MouseService=class{constructor(_,w){this._renderService=_,this._charSizeService=w}getCoords(_,w,a,h,d){return(0,g.getCoords)(window,_,w,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(_,w){const a=(0,g.getCoordsRelativeToElement)(window,_,w);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};n.MouseService=x=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],x)},3230:function(v,n,i){var l=this&&this.__decorate||function(S,C,k,E){var y,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,E);else for(var L=S.length-1;L>=0;L--)(y=S[L])&&(R=(j<3?y(R):j>3?y(C,k,R):y(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},u=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=i(3656),g=i(6193),x=i(5596),_=i(4725),w=i(8460),a=i(844),h=i(7226),d=i(2585);let f=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(S,C,k,E,y,j,R,L){if(super(),this._rowCount=S,this._charSizeService=E,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new w.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new w.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new w.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new w.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((T,D)=>this._renderRows(T,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(y.onDecorationRegistered((()=>this._fullRefresh()))),this.register(y.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const T=new R.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});T.observe(C),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(S){this._isPaused=S.isIntersecting===void 0?S.intersectionRatio===0:!S.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(S,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(S,C,this._rowCount))}_renderRows(S,C){this._renderer.value&&(S=Math.min(S,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(S,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:S,end:C}),this._onRender.fire({start:S,end:C}),this._isNextRenderRedrawOnly=!0)}resize(S,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(S){this._renderer.value=S,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(S){return this._renderDebouncer.addRefreshCallback(S)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var S,C;this._renderer.value&&((C=(S=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(S),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(S,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(S,C))):this._renderer.value.handleResize(S,C),this._fullRefresh())}handleCharSizeChanged(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCharSizeChanged()}handleBlur(){var S;(S=this._renderer.value)===null||S===void 0||S.handleBlur()}handleFocus(){var S;(S=this._renderer.value)===null||S===void 0||S.handleFocus()}handleSelectionChanged(S,C,k){var E;this._selectionState.start=S,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(S,C,k)}handleCursorMove(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCursorMove()}clear(){var S;(S=this._renderer.value)===null||S===void 0||S.clear()}};n.RenderService=f=l([u(2,d.IOptionsService),u(3,_.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,_.ICoreBrowserService),u(7,_.IThemeService)],f)},9312:function(v,n,i){var l=this&&this.__decorate||function(y,j,R,L){var T,D=arguments.length,F=D<3?j:L===null?L=Object.getOwnPropertyDescriptor(j,R):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(y,j,R,L);else for(var I=y.length-1;I>=0;I--)(T=y[I])&&(F=(D<3?T(F):D>3?T(j,R,F):T(j,R))||F);return D>3&&F&&Object.defineProperty(j,R,F),F},u=this&&this.__param||function(y,j){return function(R,L){j(R,L,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),g=i(9504),x=i(456),_=i(4725),w=i(8460),a=i(844),h=i(6114),d=i(4841),f=i(511),S=i(2585),C=" ",k=new RegExp(C,"g");let E=n.SelectionService=class extends a.Disposable{constructor(y,j,R,L,T,D,F,I,H){super(),this._element=y,this._screenElement=j,this._linkifier=R,this._bufferService=L,this._coreService=T,this._mouseService=D,this._optionsService=F,this._renderService=I,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new w.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new w.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new w.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new w.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=q=>this._handleMouseMove(q),this._mouseUpListener=q=>this._handleMouseUp(q),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((q=>this._handleTrim(q))),this.register(this._bufferService.buffers.onBufferActivate((q=>this._handleBufferActivate(q)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!y||!j||y[0]===j[0]&&y[1]===j[1])}get selectionText(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!y||!j)return"";const R=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(y[0]===j[0])return"";const T=y[0]<j[0]?y[0]:j[0],D=y[0]<j[0]?j[0]:y[0];for(let F=y[1];F<=j[1];F++){const I=R.translateBufferLineToString(F,!0,T,D);L.push(I)}}else{const T=y[1]===j[1]?j[0]:void 0;L.push(R.translateBufferLineToString(y[1],!0,y[0],T));for(let D=y[1]+1;D<=j[1]-1;D++){const F=R.lines.get(D),I=R.translateBufferLineToString(D,!0);F?.isWrapped?L[L.length-1]+=I:L.push(I)}if(y[1]!==j[1]){const D=R.lines.get(j[1]),F=R.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?L[L.length-1]+=F:L.push(F)}}return L.map((T=>T.replace(k," "))).join(h.isWindows?`\r
24
24
  `:`
25
25
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(y){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&y&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(y){const j=this._getMouseBufferCoords(y),R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(R&&L&&j)&&this._areCoordsInSelection(j,R,L)}isCellInSelection(y,j){const R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!R||!L)&&this._areCoordsInSelection([y,j],R,L)}_areCoordsInSelection(y,j,R){return y[1]>j[1]&&y[1]<R[1]||j[1]===R[1]&&y[1]===j[1]&&y[0]>=j[0]&&y[0]<R[0]||j[1]<R[1]&&y[1]===R[1]&&y[0]<R[0]||j[1]<R[1]&&y[1]===j[1]&&y[0]>=j[0]}_selectWordAtCursor(y,j){var R,L;const T=(L=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||L===void 0?void 0:L.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(y);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(y,j){this._model.clearSelection(),y=Math.max(y,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,y],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(y){this._model.handleTrim(y)&&this.refresh()}_getMouseBufferCoords(y){const j=this._mouseService.getCoords(y,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(y){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,y,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=R?0:(j>R&&(j-=R),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(y){return h.isMac?y.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:y.shiftKey}handleMouseDown(y){if(this._mouseDownTimeStamp=y.timeStamp,(y.button!==2||!this.hasSelection)&&y.button===0){if(!this._enabled){if(!this.shouldForceSelection(y))return;y.stopPropagation()}y.preventDefault(),this._dragScrollAmount=0,this._enabled&&y.shiftKey?this._handleIncrementalClick(y):y.detail===1?this._handleSingleClick(y):y.detail===2?this._handleDoubleClick(y):y.detail===3&&this._handleTripleClick(y),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(y){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(y))}_handleSingleClick(y){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(y)?3:0,this._model.selectionStart=this._getMouseBufferCoords(y),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(y){this._selectWordAtCursor(y,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(y){const j=this._getMouseBufferCoords(y);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(y){return y.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(y){if(y.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(y),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(y),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const L=R.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const y=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(y.ydisp+this._bufferService.rows,y.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=y.ydisp),this.refresh()}}_handleMouseUp(y){const j=y.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&y.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(y,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const L=(0,g.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,R=!(!y||!j||y[0]===j[0]&&y[1]===j[1]);R?y&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&y[0]===this._oldSelectionStart[0]&&y[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(y,j,R)):this._oldHasSelection&&this._fireOnSelectionChange(y,j,R)}_fireOnSelectionChange(y,j,R){this._oldSelectionStart=y,this._oldSelectionEnd=j,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(y){this.clearSelection(),this._trimListener.dispose(),this._trimListener=y.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(y,j){let R=j;for(let L=0;j>=L;L++){const T=y.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:T>1&&j!==L&&(R+=T-1)}return R}setSelection(y,j,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[y,j],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(y){this._isClickInSelection(y)||(this._selectWordAtCursor(y,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(y,j,R=!0,L=!0){if(y[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,D=T.lines.get(y[1]);if(!D)return;const F=T.translateBufferLineToString(y[1],!1);let I=this._convertViewportColToCharacterIndex(D,y[0]),H=I;const q=y[0]-I;let A=0,P=0,M=0,O=0;if(F.charAt(I)===" "){for(;I>0&&F.charAt(I-1)===" ";)I--;for(;H<F.length&&F.charAt(H+1)===" ";)H++}else{let B=y[0],z=y[0];D.getWidth(B)===0&&(A++,B--),D.getWidth(z)===2&&(P++,z++);const U=D.getString(z).length;for(U>1&&(O+=U-1,H+=U-1);B>0&&I>0&&!this._isCharWordSeparator(D.loadCell(B-1,this._workCell));){D.loadCell(B-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,B--):N>1&&(M+=N-1,I-=N-1),I--,B--}for(;z<D.length&&H+1<F.length&&!this._isCharWordSeparator(D.loadCell(z+1,this._workCell));){D.loadCell(z+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,z++):N>1&&(O+=N-1,H+=N-1),H++,z++}}H++;let $=I+q-A+M,K=Math.min(this._bufferService.cols,H-I+A+P-M-O);if(j||F.slice(I,H).trim()!==""){if(R&&$===0&&D.getCodePoint(0)!==32){const B=T.lines.get(y[1]-1);if(B&&D.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){const z=this._getWordAt([this._bufferService.cols-1,y[1]-1],!1,!0,!1);if(z){const U=this._bufferService.cols-z.start;$-=U,K+=U}}}if(L&&$+K===this._bufferService.cols&&D.getCodePoint(this._bufferService.cols-1)!==32){const B=T.lines.get(y[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){const z=this._getWordAt([0,y[1]+1],!1,!1,!0);z&&(K+=z.length)}}return{start:$,length:K}}}_selectWordAt(y,j){const R=this._getWordAt(y,j);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,y[1]--;this._model.selectionStart=[R.start,y[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(y){const j=this._getWordAt(y,!0);if(j){let R=y[1];for(;j.start<0;)j.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,R]}}_isCharWordSeparator(y){return y.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(y.getChars())>=0}_selectLineAt(y){const j=this._bufferService.buffer.getWrappedRangeForLine(y),R={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(R,this._bufferService.cols)}};n.SelectionService=E=l([u(3,S.IBufferService),u(4,S.ICoreService),u(5,_.IMouseService),u(6,S.IOptionsService),u(7,_.IRenderService),u(8,_.ICoreBrowserService)],E)},4725:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const l=i(8343);n.ICharSizeService=(0,l.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),n.IMouseService=(0,l.createDecorator)("MouseService"),n.IRenderService=(0,l.createDecorator)("RenderService"),n.ISelectionService=(0,l.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,n,i){var l=this&&this.__decorate||function(E,y,j,R){var L,T=arguments.length,D=T<3?y:R===null?R=Object.getOwnPropertyDescriptor(y,j):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,y,j,R);else for(var F=E.length-1;F>=0;F--)(L=E[F])&&(D=(T<3?L(D):T>3?L(y,j,D):L(y,j))||D);return T>3&&D&&Object.defineProperty(y,j,D),D},u=this&&this.__param||function(E,y){return function(j,R){y(j,R,E)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const c=i(7239),g=i(8055),x=i(8460),_=i(844),w=i(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),S={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],y=[0,95,135,175,215,255];for(let j=0;j<216;j++){const R=y[j/36%6|0],L=y[j/6%6|0],T=y[j%6];E.push({css:g.channels.toCss(R,L,T),rgba:g.channels.toRgba(R,L,T)})}for(let j=0;j<24;j++){const R=8+10*j;E.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return E})());let C=n.ThemeService=class extends _.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:S,selectionBackgroundOpaque:g.color.blend(h,S),selectionInactiveBackgroundTransparent:S,selectionInactiveBackgroundOpaque:g.color.blend(h,S),ansi:n.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const y=this._colors;if(y.foreground=k(E.foreground,a),y.background=k(E.background,h),y.cursor=k(E.cursor,d),y.cursorAccent=k(E.cursorAccent,f),y.selectionBackgroundTransparent=k(E.selectionBackground,S),y.selectionBackgroundOpaque=g.color.blend(y.background,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundOpaque=g.color.blend(y.background,y.selectionInactiveBackgroundTransparent),y.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,y.selectionForeground===g.NULL_COLOR&&(y.selectionForeground=void 0),g.color.isOpaque(y.selectionBackgroundTransparent)&&(y.selectionBackgroundTransparent=g.color.opacity(y.selectionBackgroundTransparent,.3)),g.color.isOpaque(y.selectionInactiveBackgroundTransparent)&&(y.selectionInactiveBackgroundTransparent=g.color.opacity(y.selectionInactiveBackgroundTransparent,.3)),y.ansi=n.DEFAULT_ANSI_COLORS.slice(),y.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),y.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),y.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),y.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),y.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),y.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),y.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),y.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),y.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),y.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),y.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),y.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),y.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),y.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),y.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),y.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(y.ansi.length-16,E.extendedAnsi.length);for(let R=0;R<j;R++)y.ansi[R+16]=k(E.extendedAnsi[R],n.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let y=0;y<this._restoreColors.ansi.length;++y)this._colors.ansi[y]=this._restoreColors.ansi[y]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,y){if(E!==void 0)try{return g.css.toColor(E)}catch{}return y}n.ThemeService=C=l([u(0,w.IOptionsService)],C)},6349:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const l=i(8460),u=i(844);class c extends u.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(x){if(this._maxLength===x)return;const _=new Array(x);for(let w=0;w<Math.min(x,this.length);w++)_[w]=this._array[this._getCyclicIndex(w)];this._array=_,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let _=this._length;_<x;_++)this._array[_]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,_){this._array[this._getCyclicIndex(x)]=_}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,_,...w){if(_){for(let a=x;a<this._length-_;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+_)];this._length-=_,this.onDeleteEmitter.fire({index:x,amount:_})}for(let a=this._length-1;a>=x;a--)this._array[this._getCyclicIndex(a+w.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<w.length;a++)this._array[this._getCyclicIndex(x+a)]=w[a];if(w.length&&this.onInsertEmitter.fire({index:x,amount:w.length}),this._length+w.length>this._maxLength){const a=this._length+w.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=w.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,_,w){if(!(_<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+w<0)throw new Error("Cannot shift elements in list beyond index 0");if(w>0){for(let h=_-1;h>=0;h--)this.set(x+h+w,this.get(x+h));const a=x+_+w-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<_;a++)this.set(x+a+w,this.get(x+a))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}n.CircularList=c},1439:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(l,u=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const g in l)c[g]=u<=1?l[g]:l[g]&&i(l[g],u-1);return c}},8055:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;const l=i(6114);let u=0,c=0,g=0,x=0;var _,w,a,h,d;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function S(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,E,y,j){return j!==void 0?`#${f(k)}${f(E)}${f(y)}${f(j)}`:`#${f(k)}${f(E)}${f(y)}`},C.toRgba=function(k,E,y,j=255){return(k<<24|E<<16|y<<8|j)>>>0}})(_||(n.channels=_={})),(function(C){function k(E,y){return x=Math.round(255*y),[u,c,g]=d.toChannels(E.rgba),{css:_.toCss(u,c,g,x),rgba:_.toRgba(u,c,g,x)}}C.blend=function(E,y){if(x=(255&y.rgba)/255,x===1)return{css:y.css,rgba:y.rgba};const j=y.rgba>>24&255,R=y.rgba>>16&255,L=y.rgba>>8&255,T=E.rgba>>24&255,D=E.rgba>>16&255,F=E.rgba>>8&255;return u=T+Math.round((j-T)*x),c=D+Math.round((R-D)*x),g=F+Math.round((L-F)*x),{css:_.toCss(u,c,g),rgba:_.toRgba(u,c,g)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,y,j){const R=d.ensureContrastRatio(E.rgba,y.rgba,j);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},C.opaque=function(E){const y=(255|E.rgba)>>>0;return[u,c,g]=d.toChannels(y),{css:_.toCss(u,c,g),rgba:y}},C.opacity=k,C.multiplyOpacity=function(E,y){return x=255&E.rgba,k(E,x*y/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(w||(n.color=w={})),(function(C){let k,E;if(!l.isNode){const y=document.createElement("canvas");y.width=1,y.height=1;const j=y.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(y){if(y.match(/#[\da-f]{3,8}/i))switch(y.length){case 4:return u=parseInt(y.slice(1,2).repeat(2),16),c=parseInt(y.slice(2,3).repeat(2),16),g=parseInt(y.slice(3,4).repeat(2),16),d.toColor(u,c,g);case 5:return u=parseInt(y.slice(1,2).repeat(2),16),c=parseInt(y.slice(2,3).repeat(2),16),g=parseInt(y.slice(3,4).repeat(2),16),x=parseInt(y.slice(4,5).repeat(2),16),d.toColor(u,c,g,x);case 7:return{css:y,rgba:(parseInt(y.slice(1),16)<<8|255)>>>0};case 9:return{css:y,rgba:parseInt(y.slice(1),16)>>>0}}const j=y.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return u=parseInt(j[1]),c=parseInt(j[2]),g=parseInt(j[3]),x=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(u,c,g,x);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=y,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,c,g,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_.toRgba(u,c,g,x),css:y}}})(a||(n.css=a={})),(function(C){function k(E,y,j){const R=E/255,L=y/255,T=j/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(h||(n.rgb=h={})),(function(C){function k(y,j,R){const L=y>>24&255,T=y>>16&255,D=y>>8&255;let F=j>>24&255,I=j>>16&255,H=j>>8&255,q=S(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));for(;q<R&&(F>0||I>0||H>0);)F-=Math.max(0,Math.ceil(.1*F)),I-=Math.max(0,Math.ceil(.1*I)),H-=Math.max(0,Math.ceil(.1*H)),q=S(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));return(F<<24|I<<16|H<<8|255)>>>0}function E(y,j,R){const L=y>>24&255,T=y>>16&255,D=y>>8&255;let F=j>>24&255,I=j>>16&255,H=j>>8&255,q=S(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));for(;q<R&&(F<255||I<255||H<255);)F=Math.min(255,F+Math.ceil(.1*(255-F))),I=Math.min(255,I+Math.ceil(.1*(255-I))),H=Math.min(255,H+Math.ceil(.1*(255-H))),q=S(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));return(F<<24|I<<16|H<<8|255)>>>0}C.ensureContrastRatio=function(y,j,R){const L=h.relativeLuminance(y>>8),T=h.relativeLuminance(j>>8);if(S(L,T)<R){if(T<L){const I=k(y,j,R),H=S(L,h.relativeLuminance(I>>8));if(H<R){const q=E(y,j,R);return H>S(L,h.relativeLuminance(q>>8))?I:q}return I}const D=E(y,j,R),F=S(L,h.relativeLuminance(D>>8));if(F<R){const I=k(y,j,R);return F>S(L,h.relativeLuminance(I>>8))?D:I}return D}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(y){return[y>>24&255,y>>16&255,y>>8&255,255&y]},C.toColor=function(y,j,R,L){return{css:_.toCss(y,j,R,L),rgba:_.toRgba(y,j,R,L)}}})(d||(n.rgba=d={})),n.toPaddedHex=f,n.contrastRatio=S},8969:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const l=i(844),u=i(2585),c=i(4348),g=i(7866),x=i(744),_=i(7302),w=i(6975),a=i(8460),h=i(1753),d=i(1480),f=i(7994),S=i(9282),C=i(5435),k=i(5981),E=i(2660);let y=!1;class j extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((L=>{var T;(T=this._onScrollApi)===null||T===void 0||T.fire(L.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(L){for(const T in L)this.optionsService.options[T]=L[T]}constructor(L){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new _.OptionsService(L)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(w.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((T,D)=>this._inputHandler.parse(T,D)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,T){this._writeBuffer.write(L,T)}writeSync(L,T){this._logService.logLevel<=u.LogLevelEnum.WARN&&!y&&(this._logService.warn("writeSync is unreliable and will be removed soon."),y=!0),this._writeBuffer.writeSync(L,T)}resize(L,T){isNaN(L)||isNaN(T)||(L=Math.max(L,x.MINIMUM_COLS),T=Math.max(T,x.MINIMUM_ROWS),this._bufferService.resize(L,T))}scroll(L,T=!1){this._bufferService.scroll(L,T)}scrollLines(L,T,D){this._bufferService.scrollLines(L,T,D)}scrollPages(L){this.scrollLines(L*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(L){const T=L-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(L,T){return this._inputHandler.registerEscHandler(L,T)}registerDcsHandler(L,T){return this._inputHandler.registerDcsHandler(L,T)}registerCsiHandler(L,T){return this._inputHandler.registerCsiHandler(L,T)}registerOscHandler(L,T){return this._inputHandler.registerOscHandler(L,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?L=T.backend==="conpty"&&T.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(S.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,S.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const T of L)T.dispose()}))}}}n.CoreTerminal=j},8460:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===i)return void this._listeners.splice(l,1)}}})),this._event}fire(i,l){const u=[];for(let c=0;c<this._listeners.length;c++)u.push(this._listeners[c]);for(let c=0;c<u.length;c++)u[c].call(void 0,i,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,l){return i((u=>l.fire(u)))}},5435:function(v,n,i){var l=this&&this.__decorate||function(q,A,P,M){var O,$=arguments.length,K=$<3?A:M===null?M=Object.getOwnPropertyDescriptor(A,P):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate(q,A,P,M);else for(var B=q.length-1;B>=0;B--)(O=q[B])&&(K=($<3?O(K):$>3?O(A,P,K):O(A,P))||K);return $>3&&K&&Object.defineProperty(A,P,K),K},u=this&&this.__param||function(q,A){return function(P,M){A(P,M,q)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const c=i(2584),g=i(7116),x=i(2015),_=i(844),w=i(482),a=i(8437),h=i(8460),d=i(643),f=i(511),S=i(3734),C=i(2585),k=i(6242),E=i(6351),y=i(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function L(q,A){if(q>24)return A.setWinLines||!1;switch(q){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var T;(function(q){q[q.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",q[q.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(n.WindowsOptionsReportType=T={}));let D=0;class F extends _.Disposable{getAttrData(){return this._curAttrData}constructor(A,P,M,O,$,K,B,z,U=new x.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=P,this._coreService=M,this._logService=O,this._optionsService=$,this._oscLinkService=K,this._coreMouseService=B,this._unicodeService=z,this._parser=U,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new w.StringToUtf32,this._utf8Decoder=new w.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,W)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:W.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,W,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:W,data:X})})),this._parser.setDcsHandlerFallback(((N,W,X)=>{W==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:W,payload:X})})),this._parser.setPrintHandler(((N,W,X)=>this.print(N,W,X))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const N in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((N,W)=>this.requestStatusString(N,W))))}_preserveStack(A,P,M,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=M,this._parseStack.position=O}_logSlowResolvingAsync(A){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([A,new Promise(((P,M)=>setTimeout((()=>M("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,P){let M,O=this._activeBuffer.x,$=this._activeBuffer.y,K=0;const B=this._parseStack.paused;if(B){if(M=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(M),M;O=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(K=this._parseStack.position+R)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(z=>String.fromCharCode(z))).join("")}"`),typeof A=="string"?A.split("").map((z=>z.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),B||this._dirtyRowTracker.clearRange(),A.length>R)for(let z=K;z<A.length;z+=R){const U=z+R<A.length?z+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(z,U),this._parseBuffer):this._utf8Decoder.decode(A.subarray(z,U),this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,$,N,z),this._logSlowResolvingAsync(M),M}else if(!B){const z=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,z))return this._preserveStack(O,$,z,0),this._logSlowResolvingAsync(M),M}this._activeBuffer.x===O&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,P,M){let O,$;const K=this._charsetService.charset,B=this._optionsService.rawOptions.screenReaderMode,z=this._bufferService.cols,U=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,W=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&M-P>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,W.fg,W.bg,W.extended);for(let V=P;V<M;++V){if(O=A[V],$=this._unicodeService.wcwidth(O),O<127&&K){const ie=K[String.fromCharCode(O)];ie&&(O=ie.charCodeAt(0))}if(B&&this._onA11yChar.fire((0,w.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=z){if(U){for(;this._activeBuffer.x<z;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,W.fg,W.bg,W.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=z-1,$===2)continue}if(N&&(X.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(W),W),X.getWidth(z-1)===2&&X.setCellFromCodePoint(z-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,W.fg,W.bg,W.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,O,$,W.fg,W.bg,W.extended),$>0)for(;--$;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,W.fg,W.bg,W.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,O):X.addCodepointToCell(this._activeBuffer.x-2,O)}M-P>0&&(X.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<z&&M-P>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,W.fg,W.bg,W.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,P){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,P):this._parser.registerCsiHandler(A,(M=>!L(M.params[0],this._optionsService.rawOptions.windowOptions)||P(M)))}registerDcsHandler(A,P){return this._parser.registerDcsHandler(A,new E.DcsHandler(P))}registerEscHandler(A,P){return this._parser.registerEscHandler(A,P)}registerOscHandler(A,P){return this._parser.registerOscHandler(A,new k.OscHandler(P))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=A,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+P)}cursorUp(A){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const P=A.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const P=A.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,P,M,O=!1,$=!1){const K=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);K.replaceCells(P,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),O&&(K.isWrapped=!1)}_resetBufferLine(A,P=!1){const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);M&&(M.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),M.isWrapped=!1)}eraseInDisplay(A,P=!1){let M;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);M<this._bufferService.rows;M++)this._resetBufferLine(M,P);this._dirtyRowTracker.markDirty(M);break;case 1:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(M+1).isWrapped=!1);M--;)this._resetBufferLine(M,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(M=this._bufferService.rows,this._dirtyRowTracker.markDirty(M-1);M--;)this._resetBufferLine(M,P);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(A,P=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let P=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;P--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(M,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let P=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;P--;)this._activeBuffer.lines.splice(M,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let P=A.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let P=A.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const P=A.params[0]||1,M=new Uint32Array(P);for(let O=0;O<P;++O)M[O]=this._parser.precedingCodepoint;return this.print(M,0,M.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[P]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,P){const M=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:$}=this._coreMouseService,K=this._coreService,{buffers:B,cols:z}=this._bufferService,{active:U,alt:N}=B,W=this._optionsService.rawOptions,X=me=>me?1:2,V=A.params[0];return ie=V,ee=P?V===2?4:V===4?X(K.modes.insertMode):V===12?3:V===20?X(W.convertEol):0:V===1?X(M.applicationCursorKeys):V===3?W.windowOptions.setWinLines?z===80?2:z===132?1:0:0:V===6?X(M.origin):V===7?X(M.wraparound):V===8?3:V===9?X(O==="X10"):V===12?X(W.cursorBlink):V===25?X(!K.isCursorHidden):V===45?X(M.reverseWraparound):V===66?X(M.applicationKeypad):V===67?4:V===1e3?X(O==="VT200"):V===1002?X(O==="DRAG"):V===1003?X(O==="ANY"):V===1004?X(M.sendFocus):V===1005?4:V===1006?X($==="SGR"):V===1015?4:V===1016?X($==="SGR_PIXELS"):V===1048?1:V===47||V===1047||V===1049?X(U===N):V===2004?X(M.bracketedPasteMode):0,K.triggerDataEvent(`${c.C0.ESC}[${P?"":"?"}${ie};${ee}$y`),!0;var ie,ee}_updateAttrColor(A,P,M,O,$){return P===2?(A|=50331648,A&=-16777216,A|=S.AttributeData.fromColorRGB([M,O,$])):P===5&&(A&=-50331904,A|=33554432|255&M),A}_extractColor(A,P,M){const O=[0,0,-1,0,0,0];let $=0,K=0;do{if(O[K+$]=A.params[P+K],A.hasSubParams(P+K)){const B=A.getSubParams(P+K);let z=0;do O[1]===5&&($=1),O[K+z+1+$]=B[z];while(++z<B.length&&z+K+1+$<O.length);break}if(O[1]===5&&K+$>=2||O[1]===2&&K+$>=5)break;O[1]&&($=1)}while(++K+P<A.length&&K+$<O.length);for(let B=2;B<O.length;++B)O[B]===-1&&(O[B]=0);switch(O[0]){case 38:M.fg=this._updateAttrColor(M.fg,O[1],O[3],O[4],O[5]);break;case 48:M.bg=this._updateAttrColor(M.bg,O[1],O[3],O[4],O[5]);break;case 58:M.extended=M.extended.clone(),M.extended.underlineColor=this._updateAttrColor(M.extended.underlineColor,O[1],O[3],O[4],O[5])}return K}_processUnderline(A,P){P.extended=P.extended.clone(),(!~A||A>5)&&(A=1),P.extended.underlineStyle=A,P.fg|=268435456,A===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(A){A.fg=a.DEFAULT_ATTR_DATA.fg,A.bg=a.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=A.length;let M;const O=this._curAttrData;for(let $=0;$<P;$++)M=A.params[$],M>=30&&M<=37?(O.fg&=-50331904,O.fg|=16777216|M-30):M>=40&&M<=47?(O.bg&=-50331904,O.bg|=16777216|M-40):M>=90&&M<=97?(O.fg&=-50331904,O.fg|=16777224|M-90):M>=100&&M<=107?(O.bg&=-50331904,O.bg|=16777224|M-100):M===0?this._processSGR0(O):M===1?O.fg|=134217728:M===3?O.bg|=67108864:M===4?(O.fg|=268435456,this._processUnderline(A.hasSubParams($)?A.getSubParams($)[0]:1,O)):M===5?O.fg|=536870912:M===7?O.fg|=67108864:M===8?O.fg|=1073741824:M===9?O.fg|=2147483648:M===2?O.bg|=134217728:M===21?this._processUnderline(2,O):M===22?(O.fg&=-134217729,O.bg&=-134217729):M===23?O.bg&=-67108865:M===24?(O.fg&=-268435457,this._processUnderline(0,O)):M===25?O.fg&=-536870913:M===27?O.fg&=-67108865:M===28?O.fg&=-1073741825:M===29?O.fg&=2147483647:M===39?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):M===49?(O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):M===38||M===48||M===58?$+=this._extractColor(A,$,O):M===53?O.bg|=1073741824:M===55?O.bg&=-1073741825:M===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):M===100?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",M);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${P};${M}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const P=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${P};${M}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const P=A.params[0]||1;switch(P){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const M=P%2==1;return this._optionsService.options.cursorBlink=M,!0}setScrollRegion(A){const P=A.params[0]||1;let M;return(A.length<2||(M=A.params[1])>this._bufferService.rows||M===0)&&(M=this._bufferService.rows),M>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=M-1,this._setCursor(0,0)),!0}windowOptions(A){if(!L(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const P=[],M=A.split(";");for(;M.length>1;){const O=M.shift(),$=M.shift();if(/^\d+$/.exec(O)){const K=parseInt(O);if(H(K))if($==="?")P.push({type:0,index:K});else{const B=(0,y.parseColor)($);B&&P.push({type:1,index:K,color:B})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(A){const P=A.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(A,P){this._getCurrentLinkId()&&this._finishHyperlink();const M=A.split(":");let O;const $=M.findIndex((K=>K.startsWith("id=")));return $!==-1&&(O=M[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,P){const M=A.split(";");for(let O=0;O<M.length&&!(P>=this._specialColors.length);++O,++P)if(M[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const $=(0,y.parseColor)(M[O]);$&&this._onColor.fire([{type:1,index:this._specialColors[P],color:$}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const P=[],M=A.split(";");for(let O=0;O<M.length;++O)if(/^\d+$/.exec(M[O])){const $=parseInt(M[O]);H($)&&P.push({type:2,index:$})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(j[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const M=this._activeBuffer.ybase+this._activeBuffer.y+P,O=this._activeBuffer.lines.get(M);O&&(O.fill(A),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,P){const M=this._bufferService.buffer,O=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${M.scrollTop+1};${M.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,P){this._dirtyRowTracker.markRangeDirty(A,P)}}n.InputHandler=F;let I=class{constructor(q){this._bufferService=q,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(q){q<this.start?this.start=q:q>this.end&&(this.end=q)}markRangeDirty(q,A){q>A&&(D=q,q=A,A=D),q<this.start&&(this.start=q),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(q){return 0<=q&&q<256}I=l([u(0,C.IBufferService)],I)},844:(v,n)=>{function i(l){for(const u of l)u.dispose();l.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const u=this._disposables.indexOf(l);u!==-1&&this._disposables.splice(u,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var u;this._isDisposed||l===this._value||((u=this._value)===null||u===void 0||u.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},n.toDisposable=function(l){return{dispose:l}},n.disposeArray=i,n.getDisposeArrayDisposable=function(l){return{dispose:()=>i(l)}}},1505:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(u,c,g){this._data[u]||(this._data[u]={}),this._data[u][c]=g}get(u,c){return this._data[u]?this._data[u][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(l,u,c,g,x){this._data.get(l,u)||this._data.set(l,u,new i),this._data.get(l,u).set(c,g,x)}get(l,u,c,g){var x;return(x=this._data.get(l,u))===null||x===void 0?void 0:x.get(c,g)}clear(){this._data.clear()}}},6114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof navigator>"u";const i=n.isNode?"node":navigator.userAgent,l=n.isNode?"node":navigator.platform;n.isFirefox=i.includes("Firefox"),n.isLegacyEdge=i.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(i),n.getSafariVersion=function(){if(!n.isSafari)return 0;const u=i.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),n.isIpad=l==="iPad",n.isIphone=l==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),n.isLinux=l.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(i=this._search(this._getKey(l)),this._array.splice(i,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const u=this._getKey(l);if(u===void 0||(i=this._search(u),i===-1)||this._getKey(this._array[i])!==u)return!1;do if(this._array[i]===l)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===u);return!1}*getKeyIterator(l){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===l)}forEachByKey(l,u){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do u(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===l)}values(){return[...this._array].values()}_search(l){let u=0,c=this._array.length-1;for(;c>=u;){let g=u+c>>1;const x=this._getKey(this._array[g]);if(x>l)c=g-1;else{if(!(x<l)){for(;g>0&&this._getKey(this._array[g-1])===l;)g--;return g}u=g+1}}return u}}},7226:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const l=i(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let _=0,w=0,a=x.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(_=Date.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,Date.now()-_),w=Math.max(_,w),h=x.timeRemaining(),1.5*w>h)return a-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-_))}ms`),void this._start();a=h}this.clear()}}class c extends u{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const _=Date.now()+x;return{timeRemaining:()=>Math.max(0,_-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const l=i(643);n.updateWindowsModeWrappedState=function(u){const c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),g=c?.get(u.cols-1),x=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);x&&g&&(x.isWrapped=g[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&g[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new i;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}n.AttributeData=i;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=l},9092:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const l=i(6349),u=i(7226),c=i(3734),g=i(8437),x=i(4634),_=i(511),w=i(643),a=i(4863),h=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(d,f,S){this._hasScrollback=d,this._optionsService=f,this._bufferService=S,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=_.CellData.fromCharData([0,w.NULL_CELL_CHAR,w.NULL_CELL_WIDTH,w.NULL_CELL_CODE]),this._whitespaceCell=_.CellData.fromCharData([0,w.WHITESPACE_CELL_CHAR,w.WHITESPACE_CELL_WIDTH,w.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const f=d+this._optionsService.rawOptions.scrollback;return f>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:f}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let y=0;y<this.lines.length;y++)C+=+this.lines.get(y).resize(d,S);let E=0;if(this._rows<f)for(let y=this._rows;y<f;y++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,S)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,S)));else for(let y=this._rows;y>f;y--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const y=this.lines.length-k;y>0&&(this.lines.trimStart(y),this.ybase=Math.max(this.ybase-y,0),this.ydisp=Math.max(this.ydisp-y,0),this.savedY=Math.max(this.savedY-y,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(d,f),this._cols>d))for(let E=0;E<this.lines.length;E++)C+=+this.lines.get(E).resize(d,S);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,f){this._cols!==d&&(d>this._cols?this._reflowLarger(d,f):this._reflowSmaller(d,f))}_reflowLarger(d,f){const S=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(S.length>0){const C=(0,x.reflowLargerCreateNewLayout)(this.lines,S);(0,x.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(d,f,C.countRemoved)}}_reflowLargerAdjustViewport(d,f,S){const C=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=S;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-S,0)}_reflowSmaller(d,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA),C=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let y=this.lines.get(E);if(!y||!y.isWrapped&&y.getTrimmedLength()<=d)continue;const j=[y];for(;y.isWrapped&&E>0;)y=this.lines.get(--E),j.unshift(y);const R=this.ybase+this.y;if(R>=E&&R<E+j.length)continue;const L=j[j.length-1].getTrimmedLength(),T=(0,x.reflowSmallerGetNewLineLengths)(j,this._cols,d),D=T.length-j.length;let F;F=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+D):Math.max(0,this.lines.length-this.lines.maxLength+D);const I=[];for(let O=0;O<D;O++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);I.push($)}I.length>0&&(C.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let H=T.length-1,q=T[H];q===0&&(H--,q=T[H]);let A=j.length-D-1,P=L;for(;A>=0;){const O=Math.min(P,q);if(j[H]===void 0)break;if(j[H].copyCellsFrom(j[A],P-O,q-O,O,!0),q-=O,q===0&&(H--,q=T[H]),P-=O,P===0){A--;const $=Math.max(A,0);P=(0,x.getWrappedLineTrimmedLength)(j,$,this._cols)}}for(let O=0;O<j.length;O++)T[O]<d&&j[O].setCell(T[O],S);let M=D-F;for(;M-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+D,this.ybase+f-1)}if(C.length>0){const E=[],y=[];for(let H=0;H<this.lines.length;H++)y.push(this.lines.get(H));const j=this.lines.length;let R=j-1,L=0,T=C[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let D=0;for(let H=Math.min(this.lines.maxLength-1,j+k-1);H>=0;H--)if(T&&T.start>R+D){for(let q=T.newLines.length-1;q>=0;q--)this.lines.set(H--,T.newLines[q]);H++,E.push({index:R+1,amount:T.newLines.length}),D+=T.newLines.length,T=C[++L]}else this.lines.set(H,y[R--]);let F=0;for(let H=E.length-1;H>=0;H--)E[H].index+=F,this.lines.onInsertEmitter.fire(E[H]),F+=E[H].amount;const I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(d,f,S=0,C){const k=this.lines.get(d);return k?k.translateToString(f,S,C):""}getWrappedRangeForLine(d){let f=d,S=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;S+1<this.lines.length&&this.lines.get(S+1).isWrapped;)S++;return{first:f,last:S}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===d&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const f=new a.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((S=>{f.line-=S,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((S=>{f.line>=S.index&&(f.line+=S.amount)}))),f.register(this.lines.onDelete((S=>{f.line>=S.index&&f.line<S.index+S.amount&&f.dispose(),f.line>S.index&&(f.line-=S.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const l=i(3734),u=i(511),c=i(643),g=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let x=0;class _{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||u.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let S=0;S<a;++S)this.setCell(S,f);this.length=a}get(a){const h=this._data[3*a+0],d=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:d?(0,g.stringFromCodePoint)(d):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,h){this._data[3*a+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return x=3*a,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,d,f,S,C){268435456&S&&(this._extendedAttrs[a]=C),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=f,this._data[3*a+2]=S}addCodepointToCell(a,h){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,g.stringFromCodePoint)(h):(2097151&d?(this._combined[a]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(h),d&=-2097152,d|=2097152):d=h|4194304,this._data[3*a+0]=d)}insertCells(a,h,d,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length-a){const S=new u.CellData;for(let C=this.length-a-h-1;C>=0;--C)this.setCell(a+h+C,this.loadCell(a+C,S));for(let C=0;C<h;++C)this.setCell(a+C,d)}else for(let S=a;S<this.length;++S)this.setCell(S,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}deleteCells(a,h,d,f){if(a%=this.length,h<this.length-a){const S=new u.CellData;for(let C=0;C<this.length-a-h;++C)this.setCell(a+C,this.loadCell(a+h+C,S));for(let C=this.length-h;C<this.length;++C)this.setCell(C,d)}else for(let S=a;S<this.length;++S)this.setCell(S,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}replaceCells(a,h,d,f,S=!1){if(S)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,d),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,d)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const f=new Uint32Array(d);f.set(this._data),this._data=f}for(let f=this.length;f<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=a&&delete this._combined[k]}const S=Object.keys(this._extendedAttrs);for(let C=0;C<S.length;C++){const k=parseInt(S[C],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,a);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new _(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,d,f,S){const C=a._data;if(S)for(let E=f-1;E>=0;E--){for(let y=0;y<3;y++)this._data[3*(d+E)+y]=C[3*(h+E)+y];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[h+E])}else for(let E=0;E<f;E++){for(let y=0;y<3;y++)this._data[3*(d+E)+y]=C[3*(h+E)+y];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[h+E])}const k=Object.keys(a._combined);for(let E=0;E<k.length;E++){const y=parseInt(k[E],10);y>=h&&(this._combined[y-h+d]=a._combined[y])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;h<d;){const S=this._data[3*h+0],C=2097151&S;f+=2097152&S?this._combined[h]:C?(0,g.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,h+=S>>22||1}return f}}n.BufferLine=_},4841:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,l){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return l*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(v,n)=>{function i(l,u,c){if(u===l.length-1)return l[u].getTrimmedLength();const g=!l[u].hasContent(c-1)&&l[u].getWidth(c-1)===1,x=l[u+1].getWidth(0)===2;return g&&x?c-1:c}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(l,u,c,g,x){const _=[];for(let w=0;w<l.length-1;w++){let a=w,h=l.get(++a);if(!h.isWrapped)continue;const d=[l.get(w)];for(;a<l.length&&h.isWrapped;)d.push(h),h=l.get(++a);if(g>=w&&g<a){w+=d.length-1;continue}let f=0,S=i(d,f,u),C=1,k=0;for(;C<d.length;){const y=i(d,C,u),j=y-k,R=c-S,L=Math.min(j,R);d[f].copyCellsFrom(d[C],k,S,L,!1),S+=L,S===c&&(f++,S=0),k+=L,k===y&&(C++,k=0),S===0&&f!==0&&d[f-1].getWidth(c-1)===2&&(d[f].copyCellsFrom(d[f-1],c-1,S++,1,!1),d[f-1].setCell(c-1,x))}d[f].replaceCells(S,c,x);let E=0;for(let y=d.length-1;y>0&&(y>f||d[y].getTrimmedLength()===0);y--)E++;E>0&&(_.push(w+d.length-E),_.push(E)),w+=d.length-1}return _},n.reflowLargerCreateNewLayout=function(l,u){const c=[];let g=0,x=u[g],_=0;for(let w=0;w<l.length;w++)if(x===w){const a=u[++g];l.onDeleteEmitter.fire({index:w-_,amount:a}),w+=a-1,_+=a,x=u[++g]}else c.push(w);return{layout:c,countRemoved:_}},n.reflowLargerApplyNewLayout=function(l,u){const c=[];for(let g=0;g<u.length;g++)c.push(l.get(u[g]));for(let g=0;g<c.length;g++)l.set(g,c[g]);l.length=u.length},n.reflowSmallerGetNewLineLengths=function(l,u,c){const g=[],x=l.map(((h,d)=>i(l,d,u))).reduce(((h,d)=>h+d));let _=0,w=0,a=0;for(;a<x;){if(x-a<c){g.push(x-a);break}_+=c;const h=i(l,w,u);_>h&&(_-=h,w++);const d=l[w].getWidth(_-1)===2;d&&_--;const f=d?c-1:c;g.push(f),a+=f}return g},n.getWrappedLineTrimmedLength=i},5295:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const l=i(8460),u=i(844),c=i(9092);class g extends u.Disposable{constructor(_,w){super(),this._optionsService=_,this._bufferService=w,this._onBufferActivate=this.register(new l.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(_,w){this._normal.resize(_,w),this._alt.resize(_,w),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}n.BufferSet=g},511:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const l=i(482),u=i(643),c=i(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(_){const w=new g;return w.setFromCharData(_),w}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(_){this.fg=_[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let w=!1;if(_[u.CHAR_DATA_CHAR_INDEX].length>2)w=!0;else if(_[u.CHAR_DATA_CHAR_INDEX].length===2){const a=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|_[u.CHAR_DATA_WIDTH_INDEX]<<22:w=!0}else w=!0}else this.content=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[u.CHAR_DATA_WIDTH_INDEX]<<22;w&&(this.combinedData=_[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=g},643:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const l=i(8460),u=i(844);class c{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new l.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,u.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}n.Marker=c,c._nextId=1},7116:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,n)=>{var i,l,u;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
26
26
  `,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(i||(n.C0=i={})),(function(c){c.PAD="€",c.HOP="",c.BPH="‚",c.NBH="ƒ",c.IND="„",c.NEL="…",c.SSA="†",c.ESA="‡",c.HTS="ˆ",c.HTJ="‰",c.VTS="Š",c.PLD="‹",c.PLU="Œ",c.RI="",c.SS2="Ž",c.SS3="",c.DCS="",c.PU1="‘",c.PU2="’",c.STS="“",c.CCH="”",c.MW="•",c.SPA="–",c.EPA="—",c.SOS="˜",c.SGCI="™",c.SCI="š",c.CSI="›",c.ST="œ",c.OSC="",c.PM="ž",c.APC="Ÿ"})(l||(n.C1=l={})),(function(c){c.ST=`${i.ESC}\\`})(u||(n.C1_ESCAPED=u={}))},7399:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const l=i(2584),u={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};n.evaluateKeyboardEvent=function(c,g,x,_){const w={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?w.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?w.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?w.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(w.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){w.key=l.C0.ESC+l.C0.DEL;break}w.key=l.C0.DEL;break;case 9:if(c.shiftKey){w.key=l.C0.ESC+"[Z";break}w.key=l.C0.HT,w.cancel=!0;break;case 13:w.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,w.cancel=!0;break;case 27:w.key=l.C0.ESC,c.altKey&&(w.key=l.C0.ESC+l.C0.ESC),w.cancel=!0;break;case 37:if(c.metaKey)break;a?(w.key=l.C0.ESC+"[1;"+(a+1)+"D",w.key===l.C0.ESC+"[1;3D"&&(w.key=l.C0.ESC+(x?"b":"[1;5D"))):w.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(w.key=l.C0.ESC+"[1;"+(a+1)+"C",w.key===l.C0.ESC+"[1;3C"&&(w.key=l.C0.ESC+(x?"f":"[1;5C"))):w.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(w.key=l.C0.ESC+"[1;"+(a+1)+"A",x||w.key!==l.C0.ESC+"[1;3A"||(w.key=l.C0.ESC+"[1;5A")):w.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(w.key=l.C0.ESC+"[1;"+(a+1)+"B",x||w.key!==l.C0.ESC+"[1;3B"||(w.key=l.C0.ESC+"[1;5B")):w.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(w.key=l.C0.ESC+"[2~");break;case 46:w.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:w.key=a?l.C0.ESC+"[1;"+(a+1)+"H":g?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:w.key=a?l.C0.ESC+"[1;"+(a+1)+"F":g?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?w.type=2:c.ctrlKey?w.key=l.C0.ESC+"[5;"+(a+1)+"~":w.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?w.type=3:c.ctrlKey?w.key=l.C0.ESC+"[6;"+(a+1)+"~":w.key=l.C0.ESC+"[6~";break;case 112:w.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:w.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:w.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:w.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:w.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:w.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:w.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:w.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:w.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:w.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:w.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:w.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(x&&!_||!c.altKey||c.metaKey)!x||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?w.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(w.key=l.C0.US),c.key==="@"&&(w.key=l.C0.NUL)):c.keyCode===65&&(w.type=1);else{const h=u[c.keyCode],d=h?.[c.shiftKey?1:0];if(d)w.key=l.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let S=String.fromCharCode(f);c.shiftKey&&(S=S.toUpperCase()),w.key=l.C0.ESC+S}else if(c.keyCode===32)w.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),w.key=l.C0.ESC+f,w.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?w.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?w.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?w.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?w.key=l.C0.DEL:c.keyCode===219?w.key=l.C0.ESC:c.keyCode===220?w.key=l.C0.FS:c.keyCode===221&&(w.key=l.C0.GS)}return w}},482:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},n.utf32ToString=function(i,l=0,u=i.length){let c="";for(let g=l;g<u;++g){let x=i[g];x>65535?(x-=65536,c+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):c+=String.fromCharCode(x)}return c},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,l){const u=i.length;if(!u)return 0;let c=0,g=0;if(this._interim){const x=i.charCodeAt(g++);56320<=x&&x<=57343?l[c++]=1024*(this._interim-55296)+x-56320+65536:(l[c++]=this._interim,l[c++]=x),this._interim=0}for(let x=g;x<u;++x){const _=i.charCodeAt(x);if(55296<=_&&_<=56319){if(++x>=u)return this._interim=_,c;const w=i.charCodeAt(x);56320<=w&&w<=57343?l[c++]=1024*(_-55296)+w-56320+65536:(l[c++]=_,l[c++]=w)}else _!==65279&&(l[c++]=_)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,l){const u=i.length;if(!u)return 0;let c,g,x,_,w=0,a=0,h=0;if(this.interim[0]){let S=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const y=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=y-E;for(;h<j;){if(h>=u)return 0;if(k=i[h++],(192&k)!=128){h--,S=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}S||(y===2?C<128?h--:l[w++]=C:y===3?C<2048||C>=55296&&C<=57343||C===65279||(l[w++]=C):C<65536||C>1114111||(l[w++]=C)),this.interim.fill(0)}const d=u-4;let f=h;for(;f<u;){for(;!(!(f<d)||128&(c=i[f])||128&(g=i[f+1])||128&(x=i[f+2])||128&(_=i[f+3]));)l[w++]=c,l[w++]=g,l[w++]=x,l[w++]=_,f+=4;if(c=i[f++],c<128)l[w++]=c;else if((224&c)==192){if(f>=u)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(a=(31&c)<<6|63&g,a<128){f--;continue}l[w++]=a}else if((240&c)==224){if(f>=u)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,w;if(x=i[f++],(192&x)!=128){f--;continue}if(a=(15&c)<<12|(63&g)<<6|63&x,a<2048||a>=55296&&a<=57343||a===65279)continue;l[w++]=a}else if((248&c)==240){if(f>=u)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,w;if(x=i[f++],(192&x)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=x,w;if(_=i[f++],(192&_)!=128){f--;continue}if(a=(7&c)<<18|(63&g)<<12|(63&x)<<6|63&_,a<65536||a>1114111)continue;l[w++]=a}}return w}}},225:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let u;n.UnicodeV6=class{constructor(){if(this.version="6",!u){u=new Uint8Array(65536),u.fill(1),u[0]=0,u.fill(0,1,32),u.fill(0,127,160),u.fill(2,4352,4448),u[9001]=2,u[9002]=2,u.fill(2,11904,42192),u[12351]=1,u.fill(2,44032,55204),u.fill(2,63744,64256),u.fill(2,65040,65050),u.fill(2,65072,65136),u.fill(2,65280,65377),u.fill(2,65504,65511);for(let c=0;c<i.length;++c)u.fill(0,i[c][0],i[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?u[c]:(function(g,x){let _,w=0,a=x.length-1;if(g<x[0][0]||g>x[a][1])return!1;for(;a>=w;)if(_=w+a>>1,g>x[_][1])w=_+1;else{if(!(g<x[_][0]))return!0;a=_-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const l=i(8460),u=i(844);class c extends u.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let w;for(this._isSyncWriting=!0;w=this._writeBuffer.shift();){this._action(w);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,_){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(_),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(_)}_innerWrite(x=0,_=!0){const w=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,_);if(h){const f=S=>Date.now()-w>=12?setTimeout((()=>this._innerWrite(0,S))):this._innerWrite(w,S);return void h.catch((S=>(queueMicrotask((()=>{throw S})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-w>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}n.WriteBuffer=c},5941:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function u(c,g){const x=c.toString(16),_=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return _;case 12:return(_+_).slice(0,3);default:return _+_}}n.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const x=i.exec(g);if(x){const _=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/_*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/_*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/_*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),l.exec(g)&&[3,6,9,12].includes(g.length))){const x=g.length/3,_=[0,0,0];for(let w=0;w<3;++w){const a=parseInt(g.slice(x*w,x*w+x),16);_[w]=x===1?a<<4:x===2?a:x===3?a>>4:a>>8}return _}},n.toRgbString=function(c,g=16){const[x,_,w]=c;return`rgb:${u(x,g)}/${u(_,g)}/${u(w,g)}`}},5770:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const l=i(482),u=i(8742),c=i(5770),g=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(_,w){this._handlers[_]===void 0&&(this._handlers[_]=[]);const a=this._handlers[_];return a.push(w),{dispose:()=>{const h=a.indexOf(w);h!==-1&&a.splice(h,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}reset(){if(this._active.length)for(let _=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;_>=0;--_)this._active[_].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(_,w){if(this.reset(),this._ident=_,this._active=this._handlers[_]||g,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(w);else this._handlerFb(this._ident,"HOOK",w)}put(_,w,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(_,w,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(_,w,a))}unhook(_,w=!0){if(this._active.length){let a=!1,h=this._active.length-1,d=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=w,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;h>=0&&(a=this._active[h].unhook(_),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",_);this._active=g,this._ident=0}};const x=new u.Params;x.addParam(0),n.DcsHandler=class{constructor(_){this._handler=_,this._data="",this._params=x,this._hitLimit=!1}hook(_){this._params=_.length>1||_.params[0]?_.clone():x,this._data="",this._hitLimit=!1}put(_,w,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(_,w,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(_){let w=!1;if(this._hitLimit)w=!1;else if(_&&(w=this._handler(this._data,this._params),w instanceof Promise))return w.then((a=>(this._params=x,this._data="",this._hitLimit=!1,a)));return this._params=x,this._data="",this._hitLimit=!1,w}}},2015:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const l=i(844),u=i(8742),c=i(6242),g=i(6351);class x{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,f,S){this.table[d<<8|h]=f<<4|S}addMany(h,d,f,S){for(let C=0;C<h.length;C++)this.table[d<<8|h[C]]=f<<4|S}}n.TransitionTable=x;const _=160;n.VT500_TRANSITION_TABLE=(function(){const a=new x(4095),h=Array.apply(null,Array(256)).map(((E,y)=>y)),d=(E,y)=>h.slice(E,y),f=d(32,127),S=d(0,24);S.push(25),S.push.apply(S,d(28,32));const C=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),C)a.addMany([24,26,153,154],k,3,0),a.addMany(d(128,144),k,3,0),a.addMany(d(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(S,0,3,0),a.addMany(S,1,3,1),a.add(127,1,0,1),a.addMany(S,8,0,8),a.addMany(S,3,3,3),a.add(127,3,0,3),a.addMany(S,4,3,4),a.add(127,4,0,4),a.addMany(S,6,3,6),a.addMany(S,5,3,5),a.add(127,5,0,5),a.addMany(S,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(d(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(S,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(d(64,127),3,7,0),a.addMany(d(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(d(48,60),4,8,4),a.addMany(d(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(d(32,64),6,0,6),a.add(127,6,0,6),a.addMany(d(64,127),6,0,0),a.addMany(d(32,48),3,9,5),a.addMany(d(32,48),5,9,5),a.addMany(d(48,64),5,0,6),a.addMany(d(64,127),5,7,0),a.addMany(d(32,48),4,9,5),a.addMany(d(32,48),1,9,2),a.addMany(d(32,48),2,9,2),a.addMany(d(48,127),2,10,0),a.addMany(d(48,80),1,10,0),a.addMany(d(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(d(96,127),1,10,0),a.add(80,1,11,9),a.addMany(S,9,0,9),a.add(127,9,0,9),a.addMany(d(28,32),9,0,9),a.addMany(d(32,48),9,9,12),a.addMany(d(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(S,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(S,10,0,10),a.add(127,10,0,10),a.addMany(d(28,32),10,0,10),a.addMany(d(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(d(32,48),10,9,12),a.addMany(S,12,0,12),a.add(127,12,0,12),a.addMany(d(28,32),12,0,12),a.addMany(d(32,48),12,9,12),a.addMany(d(48,64),12,0,11),a.addMany(d(64,127),12,12,13),a.addMany(d(64,127),10,12,13),a.addMany(d(64,127),9,12,13),a.addMany(S,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(_,0,2,0),a.add(_,8,5,8),a.add(_,6,0,6),a.add(_,11,0,11),a.add(_,13,13,13),a})();class w extends l.Disposable{constructor(h=n.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,f,S)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,f)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,d=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<h.intermediates.length;++C){const k=h.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const S=h.final.charCodeAt(0);if(d[0]>S||S>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=S,f}identToString(h){const d=[];for(;h;)d.push(String.fromCharCode(255&h)),h>>=8;return d.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,d){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const S=this._escHandlers[f];return S.push(d),{dispose:()=>{const C=S.indexOf(d);C!==-1&&S.splice(C,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,d){this._executeHandlers[h.charCodeAt(0)]=d}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,d){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const S=this._csiHandlers[f];return S.push(d),{dispose:()=>{const C=S.indexOf(d);C!==-1&&S.splice(C,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,d){return this._dcsParser.registerHandler(this._identifier(h),d)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,d){return this._oscParser.registerHandler(h,d)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,d,f,S,C){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=S,this._parseStack.chunkPos=C}parse(h,d,f){let S,C=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const y=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(S=y[j](this._params),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(S=y[j](),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 6:if(C=h[this._parseStack.chunkPos],S=this._dcsParser.unhook(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=h[this._parseStack.chunkPos],S=this._oscParser.end(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let y=E;y<d;++y){switch(C=h[y],k=this._transitions.table[this.currentState<<8|(C<160?C:_)],k>>4){case 2:for(let D=y+1;;++D){if(D>=d||(C=h[D])<32||C>126&&C<_){this._printHandler(h,y,D),y=D-1;break}if(++D>=d||(C=h[D])<32||C>126&&C<_){this._printHandler(h,y,D),y=D-1;break}if(++D>=d||(C=h[D])<32||C>126&&C<_){this._printHandler(h,y,D),y=D-1;break}if(++D>=d||(C=h[D])<32||C>126&&C<_){this._printHandler(h,y,D),y=D-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:y,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|C];let R=j?j.length-1:-1;for(;R>=0&&(S=j[R](this._params),S!==!0);R--)if(S instanceof Promise)return this._preserveStack(3,j,R,k,y),S;R<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++y<d&&(C=h[y])>47&&C<60);y--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const L=this._escHandlers[this._collect<<8|C];let T=L?L.length-1:-1;for(;T>=0&&(S=L[T](),S!==!0);T--)if(S instanceof Promise)return this._preserveStack(4,L,T,k,y),S;T<0&&this._escHandlerFb(this._collect<<8|C),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|C,this._params);break;case 13:for(let D=y+1;;++D)if(D>=d||(C=h[D])===24||C===26||C===27||C>127&&C<_){this._dcsParser.put(h,y,D),y=D-1;break}break;case 14:if(S=this._dcsParser.unhook(C!==24&&C!==26),S)return this._preserveStack(6,[],0,k,y),S;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let D=y+1;;D++)if(D>=d||(C=h[D])<32||C>127&&C<_){this._oscParser.put(h,y,D),y=D-1;break}break;case 6:if(S=this._oscParser.end(C!==24&&C!==26),S)return this._preserveStack(5,[],0,k,y),S;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=w},6242:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const l=i(5770),u=i(482),c=[];n.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const _=this._handlers[g];return _.push(x),{dispose:()=>{const w=_.indexOf(x);w!==-1&&_.splice(w,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,x,_){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(g,x,_);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,x,_))}start(){this.reset(),this._state=1}put(g,x,_){if(this._state!==3){if(this._state===1)for(;x<_;){const w=g[x++];if(w===59){this._state=2,this._start();break}if(w<48||57<w)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+w-48}this._state===2&&_-x>0&&this._put(g,x,_)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let _=!1,w=this._active.length-1,a=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,_=x,a=this._stack.fallThrough,this._stack.paused=!1),!a&&_===!1){for(;w>=0&&(_=this._active[w].end(g),_!==!0);w--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,_;w--}for(;w>=0;w--)if(_=this._active[w].end(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,_}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,x,_){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,x,_),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((_=>(this._data="",this._hitLimit=!1,_)));return this._data="",this._hitLimit=!1,x}}},8742:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class l{static fromArray(c){const g=new l;if(!c.length)return g;for(let x=Array.isArray(c[0])?1:0;x<c.length;++x){const _=c[x];if(Array.isArray(_))for(let w=0;w<_.length;++w)g.addSubParam(_[w]);else g.addParam(_)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const x=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-x>0&&c.push(Array.prototype.slice.call(this._subParams,x,_))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>i?i:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>i?i:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,x=255&this._subParamsIdx[c];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-x>0&&(c[g]=this._subParams.slice(x,_))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,_=x[g-1];x[g-1]=~_?Math.min(10*_+c,i):c}}n.Params=l},5741:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,l){const u={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(u),l.dispose=()=>this._wrappedAddonDispose(u),l.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let l=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===i){l=u;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(l,1)}}},8771:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const l=i(3785),u=i(511);n.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const g=this._buffer.lines.get(c);if(g)return new l.BufferLineApiView(g)}getNullCell(){return new u.CellData}}},3785:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const l=i(511);n.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,c){if(!(u<0||u>=this._line.length))return c?(this._line.loadCell(u,c),c):this._line.loadCell(u,new l.CellData)}translateToString(u,c,g){return this._line.translateToString(u,c,g)}}},8285:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const l=i(8771),u=i(8460),c=i(844);class g extends c.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}n.BufferNamespaceApi=g},7975:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,l){return this._core.registerCsiHandler(i,(u=>l(u.toArray())))}addCsiHandler(i,l){return this.registerCsiHandler(i,l)}registerDcsHandler(i,l){return this._core.registerDcsHandler(i,((u,c)=>l(u,c.toArray())))}addDcsHandler(i,l){return this.registerDcsHandler(i,l)}registerEscHandler(i,l){return this._core.registerEscHandler(i,l)}addEscHandler(i,l){return this.registerEscHandler(i,l)}registerOscHandler(i,l){return this._core.registerOscHandler(i,l)}addOscHandler(i,l){return this.registerOscHandler(i,l)}}},7090:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(v,n,i){var l=this&&this.__decorate||function(a,h,d,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(h,d,k):S(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const c=i(8460),g=i(844),x=i(5295),_=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let w=n.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=d.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const S=d.ybase+d.scrollTop,C=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;C===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=C-S+1;d.lines.shiftElements(S+1,k-1,-1),d.lines.set(C,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const S=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),S!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};n.BufferService=w=l([u(0,_.IOptionsService)],w)},7994:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,l){this._charsets[i]=l,this.glevel===i&&(this.charset=l)}}},1753:function(v,n,i){var l=this&&this.__decorate||function(f,S,C,k){var E,y=arguments.length,j=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var R=f.length-1;R>=0;R--)(E=f[R])&&(j=(y<3?E(j):y>3?E(S,C,j):E(S,C))||j);return y>3&&j&&Object.defineProperty(S,C,j),j},u=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const c=i(2585),g=i(8460),x=i(844),_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function w(f,S){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||S||(C|=3)),C}const a=String.fromCharCode,h={DEFAULT:f=>{const S=[w(f,!1)+32,f.col+32,f.row+32];return S[0]>255||S[1]>255||S[2]>255?"":`\x1B[M${a(S[0])}${a(S[1])}${a(S[2])}`},SGR:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.col};${f.row}${S}`},SGR_PIXELS:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.x};${f.y}${S}`}};let d=n.CoreMouseService=class extends x.Disposable{constructor(f,S){super(),this._bufferService=f,this._coreService=S,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const C of Object.keys(_))this.addProtocol(C,_[C]);for(const C of Object.keys(h))this.addEncoding(C,h[C]);this.reset()}addProtocol(f,S){this._protocols[f]=S}addEncoding(f,S){this._encodings[f]=S}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const S=this._encodings[this._activeEncoding](f);return S&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(S):this._coreService.triggerDataEvent(S,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,S,C){if(C){if(f.x!==S.x||f.y!==S.y)return!1}else if(f.col!==S.col||f.row!==S.row)return!1;return f.button===S.button&&f.action===S.action&&f.ctrl===S.ctrl&&f.alt===S.alt&&f.shift===S.shift}};n.CoreMouseService=d=l([u(0,c.IBufferService),u(1,c.ICoreService)],d)},6975:function(v,n,i){var l=this&&this.__decorate||function(d,f,S,C){var k,E=arguments.length,y=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,S):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(d,f,S,C);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(y=(E<3?k(y):E>3?k(f,S,y):k(f,S))||y);return E>3&&y&&Object.defineProperty(f,S,y),y},u=this&&this.__param||function(d,f){return function(S,C){f(S,C,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const c=i(1439),g=i(8460),x=i(844),_=i(2585),w=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=n.CoreService=class extends x.Disposable{constructor(d,f,S){super(),this._bufferService=d,this._logService=f,this._optionsService=S,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(w),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(w),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const S=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&S.ybase!==S.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(d))}};n.CoreService=h=l([u(0,_.IBufferService),u(1,_.ILogService),u(2,_.IOptionsService)],h)},9074:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const l=i(8055),u=i(8460),c=i(844),g=i(6106);let x=0,_=0;class w extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const f=new a(d);if(f){const S=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),S.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,f,S){var C,k,E;let y=0,j=0;for(const R of this._decorations.getKeyIterator(f))y=(C=R.options.x)!==null&&C!==void 0?C:0,j=y+((k=R.options.width)!==null&&k!==void 0?k:1),d>=y&&d<j&&(!S||((E=R.options.layer)!==null&&E!==void 0?E:"bottom")===S)&&(yield R)}forEachDecorationAtCell(d,f,S,C){this._decorations.forEachByKey(f,(k=>{var E,y,j;x=(E=k.options.x)!==null&&E!==void 0?E:0,_=x+((y=k.options.width)!==null&&y!==void 0?y:1),d>=x&&d<_&&(!S||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===S)&&C(k)}))}}n.DecorationService=w;class a extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const l=i(2585),u=i(8343);class c{constructor(...x){this._entries=new Map;for(const[_,w]of x)this.set(_,w)}set(x,_){const w=this._entries.get(x);return this._entries.set(x,_),w}forEach(x){for(const[_,w]of this._entries.entries())x(_,w)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}n.ServiceCollection=c,n.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const _=(0,u.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),w=[];for(const h of _){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);w.push(d)}const a=_.length>0?_[0].index:x.length;if(x.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${x.length} static arguments`);return new g(...x,...w)}}},7866:function(v,n,i){var l=this&&this.__decorate||function(a,h,d,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(h,d,k):S(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const c=i(844),g=i(2585),x={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let _,w=n.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),_=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...d)}trace(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}debug(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}info(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,a,h)}warn(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,a,h)}error(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,a,h)}};n.LogService=w=l([u(0,g.IOptionsService)],w),n.setTraceLogger=function(a){_=a},n.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...S){if(_.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,S);_.trace(`GlyphRenderer#${f.name}(${S.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,S);return _.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const l=i(8460),u=i(844),c=i(6114);n.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends u.Disposable{constructor(w){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},n.DEFAULT_OPTIONS);for(const h in w)if(h in a)try{const d=w[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(w,a){return this.onOptionChange((h=>{h===w&&a(this.rawOptions[w])}))}onMultipleOptionChange(w,a){return this.onOptionChange((h=>{w.indexOf(h)!==-1&&a()}))}_setupOptions(){const w=h=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,d)=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);d=this._sanitizeAndValidateOption(h,d),this.rawOptions[h]!==d&&(this.rawOptions[h]=d,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const d={get:w.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(w,a){switch(w){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[w]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${w}`);break;case"wordSeparator":a||(a=n.DEFAULT_OPTIONS[w]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:n.DEFAULT_OPTIONS[w];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${w} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${w} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${w} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${w} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}n.OptionsService=x},2660:function(v,n,i){var l=this&&this.__decorate||function(x,_,w,a){var h,d=arguments.length,f=d<3?_:a===null?a=Object.getOwnPropertyDescriptor(_,w):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(x,_,w,a);else for(var S=x.length-1;S>=0;S--)(h=x[S])&&(f=(d<3?h(f):d>3?h(_,w,f):h(_,w))||f);return d>3&&f&&Object.defineProperty(_,w,f),f},u=this&&this.__param||function(x,_){return function(w,a){_(w,a,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const c=i(2585);let g=n.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const _=this._bufferService.buffer;if(x.id===void 0){const S=_.addMarker(_.ybase+_.y),C={data:x,id:this._nextId++,lines:[S]};return S.onDispose((()=>this._removeMarkerFromLink(C,S))),this._dataByLinkId.set(C.id,C),C.id}const w=x,a=this._getEntryIdKey(w),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,_.ybase+_.y),h.id;const d=_.addMarker(_.ybase+_.y),f={id:this._nextId++,key:this._getEntryIdKey(w),data:w,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(x,_){const w=this._dataByLinkId.get(x);if(w&&w.lines.every((a=>a.line!==_))){const a=this._bufferService.buffer.addMarker(_);w.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(w,a)))}}getLinkData(x){var _;return(_=this._dataByLinkId.get(x))===null||_===void 0?void 0:_.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,_){const w=x.lines.indexOf(_);w!==-1&&(x.lines.splice(w,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};n.OscLinkService=g=l([u(0,c.IBufferService)],g)},8343:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",l="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(u){return u[l]||[]},n.createDecorator=function(u){if(n.serviceRegistry.has(u))return n.serviceRegistry.get(u);const c=function(g,x,_){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(w,a,h){a[i]===a?a[l].push({id:w,index:h}):(a[l]=[{id:w,index:h}],a[i]=a)})(c,g,_)};return c.toString=()=>u,n.serviceRegistry.set(u,c),c}},2585:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const l=i(8343);var u;n.IBufferService=(0,l.createDecorator)("BufferService"),n.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),n.ICoreService=(0,l.createDecorator)("CoreService"),n.ICharsetService=(0,l.createDecorator)("CharsetService"),n.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(u||(n.LogLevelEnum=u={})),n.ILogService=(0,l.createDecorator)("LogService"),n.IOptionsService=(0,l.createDecorator)("OptionsService"),n.IOscLinkService=(0,l.createDecorator)("OscLinkService"),n.IUnicodeService=(0,l.createDecorator)("UnicodeService"),n.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const l=i(8460),u=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new u.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const x=c.length;for(let _=0;_<x;++_){let w=c.charCodeAt(_);if(55296<=w&&w<=56319){if(++_>=x)return g+this.wcwidth(w);const a=c.charCodeAt(_);56320<=a&&a<=57343?w=1024*(w-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(w)}return g}}}},o={};function p(v){var n=o[v];if(n!==void 0)return n.exports;var i=o[v]={exports:{}};return r[v].call(i.exports,i,i.exports,p),i.exports}var m={};return(()=>{var v=m;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const n=p(9042),i=p(3236),l=p(844),u=p(5741),c=p(8285),g=p(7975),x=p(7090),_=["cols","rows"];class w extends l.Disposable{constructor(h){super(),this._core=this.register(new i.Terminal(h)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=S=>this._core.options[S],f=(S,C)=>{this._checkReadonlyOptions(S),this._core.options[S]=C};for(const S in this._core.options){const C={get:d.bind(this,S),set:f.bind(this,S)};Object.defineProperty(this._publicOptions,S,C)}}_checkReadonlyOptions(h){if(_.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const d in h)this._publicOptions[d]=h[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,d){this._verifyIntegers(h,d),this._core.resize(h,d)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var d,f,S;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(f=h.width)!==null&&f!==void 0?f:0,(S=h.height)!==null&&S!==void 0?S:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,f){this._verifyIntegers(h,d,f),this._core.select(h,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,d){this._verifyIntegers(h,d),this._core.selectLines(h,d)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,d){this._core.write(h,d)}writeln(h,d){this._core.write(h),this._core.write(`\r
27
- `,d)}paste(h){this._core.paste(h)}refresh(h,d){this._verifyIntegers(h,d),this._core.refresh(h,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return n}_verifyIntegers(...h){for(const d of h)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const d of h)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=w})(),m})()))})(Li)),Li.exports}var Um=$m();var qm=2,Km=1,Vm=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),v={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},n=v.top+v.bottom,i=v.right+v.left,l=o-n,u=p-i-s;return{cols:Math.max(qm,Math.floor(u/e.css.cell.width)),rows:Math.max(Km,Math.floor(l/e.css.cell.height))}}};function Xm(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[v,n]=b.useState(null),[i,l]=b.useState(()=>os.isConnected()),[u,c]=b.useState(!1),[g,x]=b.useState(!1),[_,w]=b.useState(!1),a=b.useRef({onOutput:p,onExit:m});a.current={onOutput:p,onExit:m};const h=b.useRef(null);h.current=v,b.useEffect(()=>{if(!v)return;const k=os.getSocket(),E=()=>{l(!0),c(!1),n(null),w(!0)},y=()=>{l(!1),c(!1)},j=D=>{D.terminalId===v&&a.current.onOutput?.(D.data)},R=D=>{D.terminalId===v&&(c(!1),a.current.onExit?.(D.exitCode),n(null))},L=D=>{D.terminalId===v&&c(!0)},T=D=>{D.terminalId===v&&c(!1)};return k.on("connect",E),k.on("disconnect",y),k.on(lt.TERMINAL_STDOUT,j),k.on(lt.TERMINAL_EXIT,R),k.on(lt.TERMINAL_SUBSCRIBED,L),k.on(lt.TERMINAL_UNSUBSCRIBED,T),l(k.connected),k.connected&&k.emit(Os.SUBSCRIBE,{topic:"terminal",id:v},D=>{D.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",y),k.off(lt.TERMINAL_STDOUT,j),k.off(lt.TERMINAL_EXIT,R),k.off(lt.TERMINAL_SUBSCRIBED,L),k.off(lt.TERMINAL_UNSUBSCRIBED,T),k.emit(Os.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=b.useCallback(async()=>{const k=os.getSocket();if(!k.connected)return null;x(!0);try{const E=await Ee.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(E.terminalId),w(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{x(!1)}},[s,r,o]),f=b.useCallback(async()=>{const k=h.current;if(k){try{await Ee.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}n(null),c(!1)}},[]),S=b.useCallback(k=>{const E=h.current;if(!E)return;os.getSocket().emit(Os.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=b.useCallback((k,E)=>{const y=h.current;if(!y)return;os.getSocket().emit(Os.TERMINAL_RESIZE,{terminalId:y,cols:k,rows:E})},[]);return b.useEffect(()=>()=>{const k=h.current;k&&Ee.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:i,isAttached:u,isCreating:g,needsRecreate:_,create:d,destroy:f,sendInput:S,resize:C}}function Ym({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:p}){const m=b.useRef(null),v=b.useRef(null),n=b.useRef(0),i=b.useCallback(()=>{m.current!=null&&(window.clearTimeout(m.current),m.current=null),v.current!=null&&(window.cancelAnimationFrame(v.current),v.current=null)},[]),l=b.useCallback(()=>{const g=r.current,x=s.current,_=e.current;if(!g||!x||!_||_.clientWidth<=0||_.clientHeight<=0)return!1;try{return g.fit(),x.cols>0&&x.rows>0&&p(x.cols,x.rows),!0}catch{return!1}},[r,p,e,s]),u=b.useCallback((g=6)=>{i();const x=n.current+1;n.current=x;let _=0;const w=()=>{n.current===x&&(v.current=window.requestAnimationFrame(()=>{if(v.current=null,n.current!==x)return;const a=l(),h=_<2;_<g&&(!a||h)&&(_+=1,m.current=window.setTimeout(w,50))}))};w()},[i,l]),c=b.useCallback(()=>{n.current+=1,i()},[i]);return b.useEffect(()=>c,[c]),b.useEffect(()=>{o&&u(8)},[o,u]),b.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){u(8);return}const x=new ResizeObserver(()=>{u(4)});return x.observe(g),g.parentElement&&x.observe(g.parentElement),u(8),()=>{x.disconnect()}},[u,e]),{fitNow:l,scheduleFit:u}}const Gm={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},Qm=le.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=b.useRef(null),v=b.useRef(null),n=b.useRef(null),i=b.useRef(!1),{terminalId:l,isAttached:u,needsRecreate:c,create:g,sendInput:x,resize:_}=Xm({cwd:s,onOutput:b.useCallback(h=>{v.current?.write(h)},[]),onExit:b.useCallback(h=>{v.current?.writeln(`\r
28
- \x1B[90m[Process exited with code ${h}]\x1B[0m`),o?.(h)},[o])}),{scheduleFit:w}=Ym({terminalRef:m,xtermRef:v,fitAddonRef:n,isVisible:r,onResize:_}),a=b.useCallback(h=>{v.current?.paste(h)},[]);return b.useEffect(()=>{r||v.current?.blur()},[r]),b.useEffect(()=>{if(!c)return;const h=v.current;h&&h.writeln(`\r
29
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),b.useLayoutEffect(()=>{if(!m.current)return;const h=new Um.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Gm,scrollback:5e3,convertEol:!0}),d=new Vm;return h.loadAddon(d),h.open(m.current),v.current=h,n.current=d,w(8),()=>{h.dispose(),v.current=null,n.current=null}},[w]),b.useEffect(()=>{i.current||(i.current=!0,g())},[g]),b.useEffect(()=>{const h=v.current;if(!h||!u)return;const d=h.onData(f=>{x(f)});return()=>d.dispose()},[x,u]),b.useEffect(()=>{u&&(w(4),p?.({sendInput:x,paste:a}))},[u,p,a,w,x]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!l&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:m,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Zm=le.memo(function({commands:s,onSelect:r}){const{t:o}=ae(),[p,m]=b.useState(!1),v=b.useRef(null),n=b.useRef(null);return b.useEffect(()=>{if(!p)return;const i=l=>{v.current&&!v.current.contains(l.target)&&n.current&&!n.current.contains(l.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[p]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:n,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Bd,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(wt,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((i,l)=>t.jsxs("button",{onClick:()=>{r(i.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(es,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:i.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},l))})})]})]})}),$l="\x1B",Jm="\x07",ep="œ";function tp(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function Ho(e,s){let r=s;for(;r<e.length;){if(e[r]===Jm||e[r]===ep)return r+1;if(e[r]===$l&&e[r+1]==="\\")return r+2;r+=1}return r}function $o(e,s){let r=s;for(;r<e.length&&!tp(e[r]);)r+=1;return r<e.length?r+1:r}function sp(e){let s="";for(let r=0;r<e.length;){if(e[r]==="›"){r=$o(e,r+1);continue}if(e[r]===""){r=Ho(e,r+1);continue}if(e[r]!==$l){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=$o(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=Ho(e,r+2);continue}for(r+=1;r<e.length;){const p=e.charCodeAt(r);if(p<32||p>47)break;r+=1}r<e.length&&(r+=1)}return s}const rp=200,ip=1e3,np=512*1024;function op(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>ip||s>np&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function ap(e,s){const r=!!e&&e.runtimeInstanceId!==s.runtimeInstanceId,o=r||s.reset,p=o?[]:e?.entries??[],m=new Set(p.map(i=>i.seq)),v=[...p,...s.entries.filter(i=>!m.has(i.seq))].sort((i,l)=>i.seq-l.seq),n=op(v);return{...s,entries:n.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||n.trimmed}}function Xn(e,s=!0){return jt({queryKey:ce.workspaceServices.list(e),queryFn:async()=>(await Ee.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:s&&!!e,refetchInterval:s&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function lp(e,s,r,o=!0){const p=bt(),m=ce.workspaceServices.logs(e,s);return jt({queryKey:m,queryFn:async()=>{const v=p.getQueryData(m),n=v?Math.max(0,v.nextSeq-1):0,i=v===void 0?r:v.runtimeInstanceId,l=new URLSearchParams({limit:String(rp)});i!==null&&l.set("runtimeInstanceId",i),l.set("afterSeq",String(n));const u=await Ee.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${l}`);return ap(v,u)},enabled:o&&!!e&&!!s,refetchInterval:v=>v.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const cp=[];function Ii(e){return JSON.stringify([e.command,...e.args])}function Uo(e,s,r){if(!e)return r;const o=new Date(e);return Number.isNaN(o.getTime())?r:new Intl.DateTimeFormat(s,{dateStyle:"medium",timeStyle:"medium"}).format(o)}function dp(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-emerald-400"};case"STARTING":return{label:"Starting",dotClassName:"bg-amber-400"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-amber-400"};case"FAILED":return{label:"Failed",dotClassName:"bg-red-400"};case"EXITED":return{label:"Exited",dotClassName:"bg-neutral-400"};default:return{label:"Stopped",dotClassName:"bg-neutral-500"}}}function qo({state:e}){const{t:s}=ae(),r=dp(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] text-neutral-300",children:[t.jsx("span",{className:te("h-1.5 w-1.5 rounded-full",r.dotClassName),"aria-hidden":"true"}),s(r.label)]})}function up({message:e,onRetry:s}){const{t:r}=ae();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-red-300",role:"alert",children:[t.jsx(js,{size:14,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-[#333] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",title:r("Retry"),"aria-label":r("Retry"),children:t.jsx(Ns,{size:13})})]})}function hp({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=ae(),p=Xn(e,s),m=p.data??cp,[v,n]=b.useState(null),i=m.find(x=>x.name===v)??m[0]??null,l=lp(e,i?.name??"",i?.runtimeInstanceId??null,s&&!!i),u=b.useMemo(()=>sp(l.data?.entries.map(x=>x.data).join("")??""),[l.data?.entries]),c=b.useRef(null),g=b.useRef(!0);return b.useEffect(()=>{g.current=!0},[i?.id,i?.runtimeInstanceId]),b.useEffect(()=>{const x=c.current;x&&g.current&&(x.scrollTop=x.scrollHeight)},[u]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-[#1e1e1e] text-neutral-200 md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-[#343434] bg-[#252526] md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-[#343434] px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Zi,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:o("Background services")})]}),!p.isLoading&&!p.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-neutral-500",children:m.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:p.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(up,{message:o("Failed to load background services."),onRetry:()=>{p.refetch()}}):m.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-neutral-500",children:[t.jsx(Zi,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:o("No background services")})]}):m.map(x=>{const _=x.name===i?.name;return t.jsxs("button",{type:"button",onClick:()=>n(x.name),"aria-pressed":_,className:te("block w-full border-b border-[#343434] px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",_?"bg-[#1e1e1e]":"hover:bg-[#2d2d2d]"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-100",children:x.name}),t.jsx(qo,{state:x.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:Ii(x),children:Ii(x)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(An,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:x.relativeCwd||"."})]}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(cs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:Uo(x.startedAt,r,o("Not started"))})]})]},x.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-[#1e1e1e]","aria-label":o("Background service logs"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-[#343434] bg-[#252526]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-neutral-100",children:i.name}),t.jsx(qo,{state:i.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",tabIndex:0,"aria-label":`${i.name} ${o("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-[10px] text-neutral-500 sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:Ii(i)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:i.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(cs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[o("Started"),":"]}),t.jsx("dd",{className:"truncate text-neutral-400",children:Uo(i.startedAt,r,o("Not started"))})]})]}),i.lastError&&t.jsx("p",{className:"mt-1.5 break-words text-[10px] text-red-300",role:"alert",children:i.lastError})]})]}),(l.data?.truncated||l.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-amber-400/20 bg-amber-400/10 px-3 py-1.5 text-[10px] text-amber-200",children:o("Earlier log output is unavailable.")}),l.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-400/20 bg-red-400/10 px-3 py-1.5 text-[10px] text-red-200",role:"alert",children:[t.jsx("span",{children:o("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{l.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-red-100 transition-colors hover:bg-red-300/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-200",title:o("Retry"),"aria-label":o("Retry"),children:t.jsx(Ns,{size:11})})]}),t.jsx("div",{ref:c,onScroll:x=>{const _=x.currentTarget;g.current=_.scrollHeight-_.scrollTop-_.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:l.isLoading&&!l.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading service logs...")]}):u?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:u}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-500",children:o("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-neutral-500",children:p.isLoading?o("Loading background services..."):o("Select a background service")})})]})}let Oi=0;function Ko(){return Oi+=1,{id:`shell-${Oi}`,order:Oi}}const fp=le.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=ae(),[v,n]=b.useState(()=>[Ko()]),[i,l]=b.useState(()=>v[0].id),[u,c]=b.useState(()=>new Set),[g,x]=b.useState(!1),[_,w]=b.useState(!1),[a,h]=b.useState(""),[d,f]=b.useState(null),[S,C]=b.useState("terminals"),k=b.useRef(new Map),E=o?S:"terminals",y=b.useCallback(M=>{k.current.delete(M),c(O=>{if(!O.has(M))return O;const $=new Set(O);return $.delete(M),$})},[]),j=b.useCallback(()=>{const M=Ko();n(O=>[...O,M]),l(M.id)},[]),R=b.useCallback((M,O)=>{O.stopPropagation(),y(M),n($=>{const K=$.filter(B=>B.id!==M);return M===i&&K.length>0&&l(K[K.length-1].id),K})},[i,y]),L=b.useCallback(M=>{y(M),n(O=>{const $=O.filter(K=>K.id!==M);return M===i&&$.length>0&&l($[$.length-1].id),$})},[i,y]),T=b.useCallback((M,O)=>{k.current.set(M,O),c($=>{if($.has(M))return $;const K=new Set($);return K.add(M),K})},[]),D=b.useCallback(M=>{const O=k.current.get(i);O&&O.sendInput(M+"\r")},[i]),F=b.useCallback((M,O="")=>{f(M),h(O),w(!0)},[]),I=b.useCallback((M,O)=>{const $=k.current.get(M);return $?($.paste(O),st.success(m("Pasted into terminal")),!0):(st.error(m("Terminal is not ready")),!1)},[m]),H=b.useCallback(async()=>{if(!k.current.has(i)){st.error(m("Terminal is not ready"));return}const M=navigator.clipboard;if(!M?.readText){F(i);return}x(!0);try{const O=await M.readText();if(!O||O.includes(`
30
- `)||O.includes("\r")){F(i,O);return}I(i,O)}catch{F(i)}finally{x(!1)}},[i,F,I,m]),q=b.useCallback(()=>{!a||!d||!I(d,a)||(w(!1),h(""),f(null))},[a,I,d]),A=b.useCallback(()=>{w(!1),h(""),f(null)},[]),P=u.has(i);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[o&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-[#343434] bg-[#202020] px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>C("terminals"),"aria-pressed":E==="terminals",className:te("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(lr,{size:12,"aria-hidden":"true"}),m("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>C("services"),"aria-pressed":E==="services",className:te("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(Zi,{size:12,"aria-hidden":"true"}),m("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:te("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:v.map(M=>t.jsxs("button",{onClick:()=>l(M.id),className:te("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",M.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(lr,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:M.order})}),v.length>1&&t.jsx("span",{onClick:O=>R(M.id,O),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(qt,{size:10})})]},M.id))}),v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:H,disabled:!P||g,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:m("Paste into terminal"),"aria-label":m("Paste into terminal"),children:g?t.jsx(ze,{size:18,className:"animate-spin"}):t.jsx(ru,{size:18})})]}),t.jsx("button",{type:"button",onClick:j,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:m("New Terminal"),"aria-label":m("New Terminal"),children:t.jsx(ls,{size:14})}),p.length>0&&t.jsx(Zm,{commands:p,onSelect:D})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:v.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(lr,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:j,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):v.map(M=>t.jsx("div",{"aria-hidden":M.id!==i,className:te("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",M.id===i?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(Qm,{cwd:s,isVisible:r&&E==="terminals"&&M.id===i,onExit:()=>L(M.id),onReady:O=>T(M.id,O)})},M.id))})]}),o&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(hp,{workspaceId:o,enabled:r})}),t.jsx(fs,{isOpen:_,onClose:A,title:m("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:A,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:m("Cancel")}),t.jsx("button",{type:"button",onClick:q,disabled:!a,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:m("Paste")})]}),children:t.jsx(qd,{autoFocus:!0,value:a,onChange:M=>h(M.target.value),placeholder:m("Paste terminal input here"),"aria-label":m("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function Vo(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function mp(e){if(Array.isArray(e))return e}function pp(e,s,r){return(s=Sp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function gp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,v,n=[],i=!0,l=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(i=(o=m.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(u){l=!0,p=u}finally{try{if(!i&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(l)throw p}}return n}}function vp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
31
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Yo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Xo(Object(r),!0).forEach(function(o){pp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function xp(e,s){if(e==null)return{};var r,o,p=bp(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(o=0;o<m.length;o++)r=m[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function bp(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function _p(e,s){return mp(e)||gp(e,s)||wp(e,s)||vp()}function yp(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Sp(e){var s=yp(e,"string");return typeof s=="symbol"?s:s+""}function wp(e,s){if(e){if(typeof e=="string")return Vo(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vo(e,s):void 0}}function Cp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Go(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Qo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Go(Object(r),!0).forEach(function(o){Cp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Go(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function kp(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(p,m){return m(p)},o)}}function ar(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(p,n))}}}function si(e){return{}.toString.call(e).includes("Object")}function Ep(e){return!Object.keys(e).length}function xr(e){return typeof e=="function"}function jp(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Np(e,s){return si(s)||us("changeType"),Object.keys(s).some(function(r){return!jp(e,r)})&&us("changeField"),s}function Rp(e){xr(e)||us("selectorType")}function Ap(e){xr(e)||si(e)||us("handlerType"),si(e)&&Object.values(e).some(function(s){return!xr(s)})&&us("handlersType")}function Tp(e){e||us("initialIsRequired"),si(e)||us("initialType"),Ep(e)&&us("initialContent")}function Mp(e,s){throw new Error(e[s]||e.default)}var Dp={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},us=ar(Mp)(Dp),Fr={changes:Np,selector:Rp,handler:Ap,initial:Tp};function Pp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Fr.initial(e),Fr.handler(s);var r={current:e},o=ar(Op)(r,s),p=ar(Ip)(r),m=ar(Fr.changes)(e),v=ar(Lp)(r);function n(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Fr.selector(l),l(r.current)}function i(l){kp(o,p,m,v)(l)}return[n,i]}function Lp(e,s){return xr(s)?s(e.current):s}function Ip(e,s){return e.current=Qo(Qo({},e.current),s),s}function Op(e,s,r){return xr(s)?s(e.current):Object.keys(r).forEach(function(o){var p;return(p=s[o])===null||p===void 0?void 0:p.call(s,e.current[o])}),r}var Bp={create:Pp},Fp={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function zp(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(p,n))}}}function Wp(e){return{}.toString.call(e).includes("Object")}function Hp(e){return e||Zo("configIsRequired"),Wp(e)||Zo("configType"),e.urls?($p(),{paths:{vs:e.urls.monacoBase}}):e}function $p(){console.warn(Ul.deprecation)}function Up(e,s){throw new Error(e[s]||e.default)}var Ul={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
27
+ `,d)}paste(h){this._core.paste(h)}refresh(h,d){this._verifyIntegers(h,d),this._core.refresh(h,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return n}_verifyIntegers(...h){for(const d of h)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const d of h)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=w})(),m})()))})(Ii)),Ii.exports}var qm=Um();var Km=2,Vm=1,Xm=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),v={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},n=v.top+v.bottom,i=v.right+v.left,l=o-n,u=p-i-s;return{cols:Math.max(Km,Math.floor(u/e.css.cell.width)),rows:Math.max(Vm,Math.floor(l/e.css.cell.height))}}};function Ym(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[v,n]=b.useState(null),[i,l]=b.useState(()=>os.isConnected()),[u,c]=b.useState(!1),[g,x]=b.useState(!1),[_,w]=b.useState(!1),a=b.useRef({onOutput:p,onExit:m});a.current={onOutput:p,onExit:m};const h=b.useRef(null);h.current=v,b.useEffect(()=>{if(!v)return;const k=os.getSocket(),E=()=>{l(!0),c(!1),n(null),w(!0)},y=()=>{l(!1),c(!1)},j=D=>{D.terminalId===v&&a.current.onOutput?.(D.data)},R=D=>{D.terminalId===v&&(c(!1),a.current.onExit?.(D.exitCode),n(null))},L=D=>{D.terminalId===v&&c(!0)},T=D=>{D.terminalId===v&&c(!1)};return k.on("connect",E),k.on("disconnect",y),k.on(lt.TERMINAL_STDOUT,j),k.on(lt.TERMINAL_EXIT,R),k.on(lt.TERMINAL_SUBSCRIBED,L),k.on(lt.TERMINAL_UNSUBSCRIBED,T),l(k.connected),k.connected&&k.emit(Os.SUBSCRIBE,{topic:"terminal",id:v},D=>{D.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",y),k.off(lt.TERMINAL_STDOUT,j),k.off(lt.TERMINAL_EXIT,R),k.off(lt.TERMINAL_SUBSCRIBED,L),k.off(lt.TERMINAL_UNSUBSCRIBED,T),k.emit(Os.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=b.useCallback(async()=>{const k=os.getSocket();if(!k.connected)return null;x(!0);try{const E=await Ee.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(E.terminalId),w(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{x(!1)}},[s,r,o]),f=b.useCallback(async()=>{const k=h.current;if(k){try{await Ee.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}n(null),c(!1)}},[]),S=b.useCallback(k=>{const E=h.current;if(!E)return;os.getSocket().emit(Os.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=b.useCallback((k,E)=>{const y=h.current;if(!y)return;os.getSocket().emit(Os.TERMINAL_RESIZE,{terminalId:y,cols:k,rows:E})},[]);return b.useEffect(()=>()=>{const k=h.current;k&&Ee.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:i,isAttached:u,isCreating:g,needsRecreate:_,create:d,destroy:f,sendInput:S,resize:C}}function Gm({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:p}){const m=b.useRef(null),v=b.useRef(null),n=b.useRef(0),i=b.useCallback(()=>{m.current!=null&&(window.clearTimeout(m.current),m.current=null),v.current!=null&&(window.cancelAnimationFrame(v.current),v.current=null)},[]),l=b.useCallback(()=>{const g=r.current,x=s.current,_=e.current;if(!g||!x||!_||_.clientWidth<=0||_.clientHeight<=0)return!1;try{return g.fit(),x.cols>0&&x.rows>0&&p(x.cols,x.rows),!0}catch{return!1}},[r,p,e,s]),u=b.useCallback((g=6)=>{i();const x=n.current+1;n.current=x;let _=0;const w=()=>{n.current===x&&(v.current=window.requestAnimationFrame(()=>{if(v.current=null,n.current!==x)return;const a=l(),h=_<2;_<g&&(!a||h)&&(_+=1,m.current=window.setTimeout(w,50))}))};w()},[i,l]),c=b.useCallback(()=>{n.current+=1,i()},[i]);return b.useEffect(()=>c,[c]),b.useEffect(()=>{o&&u(8)},[o,u]),b.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){u(8);return}const x=new ResizeObserver(()=>{u(4)});return x.observe(g),g.parentElement&&x.observe(g.parentElement),u(8),()=>{x.disconnect()}},[u,e]),{fitNow:l,scheduleFit:u}}const Qm={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},Zm=le.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=b.useRef(null),v=b.useRef(null),n=b.useRef(null),i=b.useRef(!1),{terminalId:l,isAttached:u,needsRecreate:c,create:g,sendInput:x,resize:_}=Ym({cwd:s,onOutput:b.useCallback(h=>{v.current?.write(h)},[]),onExit:b.useCallback(h=>{v.current?.writeln(`\r
28
+ \x1B[90m[Process exited with code ${h}]\x1B[0m`),o?.(h)},[o])}),{scheduleFit:w}=Gm({terminalRef:m,xtermRef:v,fitAddonRef:n,isVisible:r,onResize:_}),a=b.useCallback(h=>{v.current?.paste(h)},[]);return b.useEffect(()=>{r||v.current?.blur()},[r]),b.useEffect(()=>{if(!c)return;const h=v.current;h&&h.writeln(`\r
29
+ \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),b.useLayoutEffect(()=>{if(!m.current)return;const h=new qm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Qm,scrollback:5e3,convertEol:!0}),d=new Xm;return h.loadAddon(d),h.open(m.current),v.current=h,n.current=d,w(8),()=>{h.dispose(),v.current=null,n.current=null}},[w]),b.useEffect(()=>{i.current||(i.current=!0,g())},[g]),b.useEffect(()=>{const h=v.current;if(!h||!u)return;const d=h.onData(f=>{x(f)});return()=>d.dispose()},[x,u]),b.useEffect(()=>{u&&(w(4),p?.({sendInput:x,paste:a}))},[u,p,a,w,x]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!l&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:m,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Jm=le.memo(function({commands:s,onSelect:r}){const{t:o}=ae(),[p,m]=b.useState(!1),v=b.useRef(null),n=b.useRef(null);return b.useEffect(()=>{if(!p)return;const i=l=>{v.current&&!v.current.contains(l.target)&&n.current&&!n.current.contains(l.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[p]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:n,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Fd,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(wt,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((i,l)=>t.jsxs("button",{onClick:()=>{r(i.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(es,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:i.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},l))})})]})]})}),Ul="\x1B",ep="\x07",tp="œ";function sp(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function $o(e,s){let r=s;for(;r<e.length;){if(e[r]===ep||e[r]===tp)return r+1;if(e[r]===Ul&&e[r+1]==="\\")return r+2;r+=1}return r}function Uo(e,s){let r=s;for(;r<e.length&&!sp(e[r]);)r+=1;return r<e.length?r+1:r}function rp(e){let s="";for(let r=0;r<e.length;){if(e[r]==="›"){r=Uo(e,r+1);continue}if(e[r]===""){r=$o(e,r+1);continue}if(e[r]!==Ul){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=Uo(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=$o(e,r+2);continue}for(r+=1;r<e.length;){const p=e.charCodeAt(r);if(p<32||p>47)break;r+=1}r<e.length&&(r+=1)}return s}const ip=200,np=1e3,op=512*1024;function ap(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>np||s>op&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function lp(e,s){const r=!!e&&e.runtimeInstanceId!==s.runtimeInstanceId,o=r||s.reset,p=o?[]:e?.entries??[],m=new Set(p.map(i=>i.seq)),v=[...p,...s.entries.filter(i=>!m.has(i.seq))].sort((i,l)=>i.seq-l.seq),n=ap(v);return{...s,entries:n.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||n.trimmed}}function Yn(e,s=!0){return jt({queryKey:ce.workspaceServices.list(e),queryFn:async()=>(await Ee.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:s&&!!e,refetchInterval:s&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function cp(e,s,r,o=!0){const p=bt(),m=ce.workspaceServices.logs(e,s);return jt({queryKey:m,queryFn:async()=>{const v=p.getQueryData(m),n=v?Math.max(0,v.nextSeq-1):0,i=v===void 0?r:v.runtimeInstanceId,l=new URLSearchParams({limit:String(ip)});i!==null&&l.set("runtimeInstanceId",i),l.set("afterSeq",String(n));const u=await Ee.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${l}`);return lp(v,u)},enabled:o&&!!e&&!!s,refetchInterval:v=>v.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const dp=[];function Oi(e){return JSON.stringify([e.command,...e.args])}function qo(e,s,r){if(!e)return r;const o=new Date(e);return Number.isNaN(o.getTime())?r:new Intl.DateTimeFormat(s,{dateStyle:"medium",timeStyle:"medium"}).format(o)}function up(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-emerald-400"};case"STARTING":return{label:"Starting",dotClassName:"bg-amber-400"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-amber-400"};case"FAILED":return{label:"Failed",dotClassName:"bg-red-400"};case"EXITED":return{label:"Exited",dotClassName:"bg-neutral-400"};default:return{label:"Stopped",dotClassName:"bg-neutral-500"}}}function Ko({state:e}){const{t:s}=ae(),r=up(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] text-neutral-300",children:[t.jsx("span",{className:te("h-1.5 w-1.5 rounded-full",r.dotClassName),"aria-hidden":"true"}),s(r.label)]})}function hp({message:e,onRetry:s}){const{t:r}=ae();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-red-300",role:"alert",children:[t.jsx(js,{size:14,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-[#333] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",title:r("Retry"),"aria-label":r("Retry"),children:t.jsx(Ns,{size:13})})]})}function fp({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=ae(),p=Yn(e,s),m=p.data??dp,[v,n]=b.useState(null),i=m.find(x=>x.name===v)??m[0]??null,l=cp(e,i?.name??"",i?.runtimeInstanceId??null,s&&!!i),u=b.useMemo(()=>rp(l.data?.entries.map(x=>x.data).join("")??""),[l.data?.entries]),c=b.useRef(null),g=b.useRef(!0);return b.useEffect(()=>{g.current=!0},[i?.id,i?.runtimeInstanceId]),b.useEffect(()=>{const x=c.current;x&&g.current&&(x.scrollTop=x.scrollHeight)},[u]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-[#1e1e1e] text-neutral-200 md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-[#343434] bg-[#252526] md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-[#343434] px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ji,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:o("Background services")})]}),!p.isLoading&&!p.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-neutral-500",children:m.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:p.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(hp,{message:o("Failed to load background services."),onRetry:()=>{p.refetch()}}):m.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-neutral-500",children:[t.jsx(Ji,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:o("No background services")})]}):m.map(x=>{const _=x.name===i?.name;return t.jsxs("button",{type:"button",onClick:()=>n(x.name),"aria-pressed":_,className:te("block w-full border-b border-[#343434] px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",_?"bg-[#1e1e1e]":"hover:bg-[#2d2d2d]"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-100",children:x.name}),t.jsx(Ko,{state:x.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:Oi(x),children:Oi(x)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(Tn,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:x.relativeCwd||"."})]}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(cs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:qo(x.startedAt,r,o("Not started"))})]})]},x.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-[#1e1e1e]","aria-label":o("Background service logs"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-[#343434] bg-[#252526]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-neutral-100",children:i.name}),t.jsx(Ko,{state:i.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",tabIndex:0,"aria-label":`${i.name} ${o("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-[10px] text-neutral-500 sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:Oi(i)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:i.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(cs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[o("Started"),":"]}),t.jsx("dd",{className:"truncate text-neutral-400",children:qo(i.startedAt,r,o("Not started"))})]})]}),i.lastError&&t.jsx("p",{className:"mt-1.5 break-words text-[10px] text-red-300",role:"alert",children:i.lastError})]})]}),(l.data?.truncated||l.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-amber-400/20 bg-amber-400/10 px-3 py-1.5 text-[10px] text-amber-200",children:o("Earlier log output is unavailable.")}),l.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-400/20 bg-red-400/10 px-3 py-1.5 text-[10px] text-red-200",role:"alert",children:[t.jsx("span",{children:o("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{l.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-red-100 transition-colors hover:bg-red-300/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-200",title:o("Retry"),"aria-label":o("Retry"),children:t.jsx(Ns,{size:11})})]}),t.jsx("div",{ref:c,onScroll:x=>{const _=x.currentTarget;g.current=_.scrollHeight-_.scrollTop-_.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:l.isLoading&&!l.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading service logs...")]}):u?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:u}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-500",children:o("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-neutral-500",children:p.isLoading?o("Loading background services..."):o("Select a background service")})})]})}let Bi=0;function Vo(){return Bi+=1,{id:`shell-${Bi}`,order:Bi}}const mp=le.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=ae(),[v,n]=b.useState(()=>[Vo()]),[i,l]=b.useState(()=>v[0].id),[u,c]=b.useState(()=>new Set),[g,x]=b.useState(!1),[_,w]=b.useState(!1),[a,h]=b.useState(""),[d,f]=b.useState(null),[S,C]=b.useState("terminals"),k=b.useRef(new Map),E=o?S:"terminals",y=b.useCallback(M=>{k.current.delete(M),c(O=>{if(!O.has(M))return O;const $=new Set(O);return $.delete(M),$})},[]),j=b.useCallback(()=>{const M=Vo();n(O=>[...O,M]),l(M.id)},[]),R=b.useCallback((M,O)=>{O.stopPropagation(),y(M),n($=>{const K=$.filter(B=>B.id!==M);return M===i&&K.length>0&&l(K[K.length-1].id),K})},[i,y]),L=b.useCallback(M=>{y(M),n(O=>{const $=O.filter(K=>K.id!==M);return M===i&&$.length>0&&l($[$.length-1].id),$})},[i,y]),T=b.useCallback((M,O)=>{k.current.set(M,O),c($=>{if($.has(M))return $;const K=new Set($);return K.add(M),K})},[]),D=b.useCallback(M=>{const O=k.current.get(i);O&&O.sendInput(M+"\r")},[i]),F=b.useCallback((M,O="")=>{f(M),h(O),w(!0)},[]),I=b.useCallback((M,O)=>{const $=k.current.get(M);return $?($.paste(O),st.success(m("Pasted into terminal")),!0):(st.error(m("Terminal is not ready")),!1)},[m]),H=b.useCallback(async()=>{if(!k.current.has(i)){st.error(m("Terminal is not ready"));return}const M=navigator.clipboard;if(!M?.readText){F(i);return}x(!0);try{const O=await M.readText();if(!O||O.includes(`
30
+ `)||O.includes("\r")){F(i,O);return}I(i,O)}catch{F(i)}finally{x(!1)}},[i,F,I,m]),q=b.useCallback(()=>{!a||!d||!I(d,a)||(w(!1),h(""),f(null))},[a,I,d]),A=b.useCallback(()=>{w(!1),h(""),f(null)},[]),P=u.has(i);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[o&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-[#343434] bg-[#202020] px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>C("terminals"),"aria-pressed":E==="terminals",className:te("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(lr,{size:12,"aria-hidden":"true"}),m("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>C("services"),"aria-pressed":E==="services",className:te("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(Ji,{size:12,"aria-hidden":"true"}),m("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:te("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:v.map(M=>t.jsxs("button",{onClick:()=>l(M.id),className:te("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",M.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(lr,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:M.order})}),v.length>1&&t.jsx("span",{onClick:O=>R(M.id,O),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(qt,{size:10})})]},M.id))}),v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:H,disabled:!P||g,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:m("Paste into terminal"),"aria-label":m("Paste into terminal"),children:g?t.jsx(ze,{size:18,className:"animate-spin"}):t.jsx(iu,{size:18})})]}),t.jsx("button",{type:"button",onClick:j,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:m("New Terminal"),"aria-label":m("New Terminal"),children:t.jsx(ls,{size:14})}),p.length>0&&t.jsx(Jm,{commands:p,onSelect:D})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:v.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(lr,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:j,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):v.map(M=>t.jsx("div",{"aria-hidden":M.id!==i,className:te("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",M.id===i?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(Zm,{cwd:s,isVisible:r&&E==="terminals"&&M.id===i,onExit:()=>L(M.id),onReady:O=>T(M.id,O)})},M.id))})]}),o&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(fp,{workspaceId:o,enabled:r})}),t.jsx(fs,{isOpen:_,onClose:A,title:m("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:A,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:m("Cancel")}),t.jsx("button",{type:"button",onClick:q,disabled:!a,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:m("Paste")})]}),children:t.jsx(Kd,{autoFocus:!0,value:a,onChange:M=>h(M.target.value),placeholder:m("Paste terminal input here"),"aria-label":m("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function Xo(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function pp(e){if(Array.isArray(e))return e}function gp(e,s,r){return(s=wp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function vp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,v,n=[],i=!0,l=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(i=(o=m.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(u){l=!0,p=u}finally{try{if(!i&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(l)throw p}}return n}}function xp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
31
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Go(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Yo(Object(r),!0).forEach(function(o){gp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function bp(e,s){if(e==null)return{};var r,o,p=_p(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(o=0;o<m.length;o++)r=m[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function _p(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function yp(e,s){return pp(e)||vp(e,s)||Cp(e,s)||xp()}function Sp(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function wp(e){var s=Sp(e,"string");return typeof s=="symbol"?s:s+""}function Cp(e,s){if(e){if(typeof e=="string")return Xo(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xo(e,s):void 0}}function kp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Qo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Zo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Qo(Object(r),!0).forEach(function(o){kp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Ep(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(p,m){return m(p)},o)}}function ar(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(p,n))}}}function ri(e){return{}.toString.call(e).includes("Object")}function jp(e){return!Object.keys(e).length}function xr(e){return typeof e=="function"}function Np(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Rp(e,s){return ri(s)||us("changeType"),Object.keys(s).some(function(r){return!Np(e,r)})&&us("changeField"),s}function Ap(e){xr(e)||us("selectorType")}function Tp(e){xr(e)||ri(e)||us("handlerType"),ri(e)&&Object.values(e).some(function(s){return!xr(s)})&&us("handlersType")}function Mp(e){e||us("initialIsRequired"),ri(e)||us("initialType"),jp(e)&&us("initialContent")}function Dp(e,s){throw new Error(e[s]||e.default)}var Pp={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},us=ar(Dp)(Pp),Fr={changes:Rp,selector:Ap,handler:Tp,initial:Mp};function Lp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Fr.initial(e),Fr.handler(s);var r={current:e},o=ar(Bp)(r,s),p=ar(Op)(r),m=ar(Fr.changes)(e),v=ar(Ip)(r);function n(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Fr.selector(l),l(r.current)}function i(l){Ep(o,p,m,v)(l)}return[n,i]}function Ip(e,s){return xr(s)?s(e.current):s}function Op(e,s){return e.current=Zo(Zo({},e.current),s),s}function Bp(e,s,r){return xr(s)?s(e.current):Object.keys(r).forEach(function(o){var p;return(p=s[o])===null||p===void 0?void 0:p.call(s,e.current[o])}),r}var Fp={create:Lp},zp={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Wp(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(p,n))}}}function Hp(e){return{}.toString.call(e).includes("Object")}function $p(e){return e||Jo("configIsRequired"),Hp(e)||Jo("configType"),e.urls?(Up(),{paths:{vs:e.urls.monacoBase}}):e}function Up(){console.warn(ql.deprecation)}function qp(e,s){throw new Error(e[s]||e.default)}var ql={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
32
32
  You are using deprecated way of configuration.
33
33
 
34
34
  Instead of using
@@ -37,7 +37,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37
37
  monaco.config({ paths: { vs: '...' } })
38
38
 
39
39
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
40
- `},Zo=zp(Up)(Ul),qp={config:Hp},Kp=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(p){return r.reduceRight(function(m,v){return v(m)},p)}};function ql(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],ql(e[r],s[r]))}),Yo(Yo({},e),s)}var Vp={type:"cancelation",msg:"operation is manually canceled"};function Bi(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(Vp):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var Xp=["monaco"],Yp=Bp.create({config:Fp,isInitialized:!1,resolve:null,reject:null,monaco:null}),Kl=_p(Yp,2),Cr=Kl[0],vi=Kl[1];function Gp(e){var s=qp.config(e),r=s.monaco,o=xp(s,Xp);vi(function(p){return{config:ql(p.config,o),monaco:r}})}function Qp(){var e=Cr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(vi({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Bi(Fi);if(window.monaco&&window.monaco.editor)return Vl(window.monaco),e.resolve(window.monaco),Bi(Fi);Kp(Zp,eg)(tg)}return Bi(Fi)}function Zp(e){return document.body.appendChild(e)}function Jp(e){var s=document.createElement("script");return e&&(s.src=e),s}function eg(e){var s=Cr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=Jp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function tg(){var e=Cr(function(r){var o=r.config,p=r.resolve,m=r.reject;return{config:o,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;Vl(o),e.resolve(o)},function(r){e.reject(r)})}function Vl(e){Cr().monaco||vi({monaco:e})}function sg(){return Cr(function(e){var s=e.monaco;return s})}var Fi=new Promise(function(e,s){return vi({resolve:e,reject:s})}),Xl={config:Gp,init:Qp,__getMonacoInstance:sg},rg={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},zi=rg,ig={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},ng=ig;function og({children:e}){return le.createElement("div",{style:ng.container},e)}var ag=og,lg=ag;function cg({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:v}){return le.createElement("section",{style:{...zi.wrapper,width:e,height:s},...v},!r&&le.createElement(lg,null,o),le.createElement("div",{ref:p,style:{...zi.fullWidth,...!r&&zi.hide},className:m}))}var dg=cg,Yl=b.memo(dg);function ug(e){b.useEffect(e,[])}var Gl=ug;function hg(e,s,r=!0){let o=b.useRef(!0);b.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var Et=hg;function hr(){}function Bs(e,s,r,o){return fg(e,o)||mg(e,s,r,o)}function fg(e,s){return e.editor.getModel(Ql(e,s))}function mg(e,s,r,o){return e.editor.createModel(s,r,o?Ql(e,o):void 0)}function Ql(e,s){return e.Uri.parse(s)}function pg({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:u="Loading...",options:c={},height:g="100%",width:x="100%",className:_,wrapperProps:w={},beforeMount:a=hr,onMount:h=hr}){let[d,f]=b.useState(!1),[S,C]=b.useState(!0),k=b.useRef(null),E=b.useRef(null),y=b.useRef(null),j=b.useRef(h),R=b.useRef(a),L=b.useRef(!1);Gl(()=>{let I=Xl.init();return I.then(H=>(E.current=H)&&C(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>k.current?F():I.cancel()}),Et(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),H=Bs(E.current,e||"",o||r||"text",m||"");H!==I.getModel()&&I.setModel(H)}},[m],d),Et(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),H=Bs(E.current,s||"",p||r||"text",v||"");H!==I.getModel()&&I.setModel(H)}},[v],d),Et(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],d),Et(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),Et(()=>{let{original:I,modified:H}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage(H,p||r||"text")},[r,o,p],d),Et(()=>{E.current?.editor.setTheme(l)},[l],d),Et(()=>{k.current?.updateOptions(c)},[c],d);let T=b.useCallback(()=>{if(!E.current)return;R.current(E.current);let I=Bs(E.current,e||"",o||r||"text",m||""),H=Bs(E.current,s||"",p||r||"text",v||"");k.current?.setModel({original:I,modified:H})},[r,s,p,e,o,m,v]),D=b.useCallback(()=>{!L.current&&y.current&&(k.current=E.current.editor.createDiffEditor(y.current,{automaticLayout:!0,...c}),T(),E.current?.editor.setTheme(l),f(!0),L.current=!0)},[c,l,T]);b.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),b.useEffect(()=>{!S&&!d&&D()},[S,d,D]);function F(){let I=k.current?.getModel();n||I?.original?.dispose(),i||I?.modified?.dispose(),k.current?.dispose()}return le.createElement(Yl,{width:x,height:g,isEditorReady:d,loading:u,_ref:y,className:_,wrapperProps:w})}var gg=pg;b.memo(gg);function vg(e){let s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}var xg=vg,zr=new Map;function bg({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:v="light",line:n,loading:i="Loading...",options:l={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:g=!1,width:x="100%",height:_="100%",className:w,wrapperProps:a={},beforeMount:h=hr,onMount:d=hr,onChange:f,onValidate:S=hr}){let[C,k]=b.useState(!1),[E,y]=b.useState(!0),j=b.useRef(null),R=b.useRef(null),L=b.useRef(null),T=b.useRef(d),D=b.useRef(h),F=b.useRef(),I=b.useRef(o),H=xg(m),q=b.useRef(!1),A=b.useRef(!1);Gl(()=>{let O=Xl.init();return O.then($=>(j.current=$)&&y(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>R.current?M():O.cancel()}),Et(()=>{let O=Bs(j.current,e||o||"",s||p||"",m||r||"");O!==R.current?.getModel()&&(c&&zr.set(H,R.current?.saveViewState()),R.current?.setModel(O),c&&R.current?.restoreViewState(zr.get(m)))},[m],C),Et(()=>{R.current?.updateOptions(l)},[l],C),Et(()=>{!R.current||o===void 0||(R.current.getOption(j.current.editor.EditorOption.readOnly)?R.current.setValue(o):o!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[o],C),Et(()=>{let O=R.current?.getModel();O&&p&&j.current?.editor.setModelLanguage(O,p)},[p],C),Et(()=>{n!==void 0&&R.current?.revealLine(n)},[n],C),Et(()=>{j.current?.editor.setTheme(v)},[v],C);let P=b.useCallback(()=>{if(!(!L.current||!j.current)&&!q.current){D.current(j.current);let O=m||r,$=Bs(j.current,o||e||"",s||p||"",O||"");R.current=j.current?.editor.create(L.current,{model:$,automaticLayout:!0,...l},u),c&&R.current.restoreViewState(zr.get(O)),j.current.editor.setTheme(v),n!==void 0&&R.current.revealLine(n),k(!0),q.current=!0}},[e,s,r,o,p,m,l,u,c,v,n]);b.useEffect(()=>{C&&T.current(R.current,j.current)},[C]),b.useEffect(()=>{!E&&!C&&P()},[E,C,P]),I.current=o,b.useEffect(()=>{C&&f&&(F.current?.dispose(),F.current=R.current?.onDidChangeModelContent(O=>{A.current||f(R.current.getValue(),O)}))},[C,f]),b.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers($=>{let K=R.current.getModel()?.uri;if(K&&$.find(B=>B.path===K.path)){let B=j.current.editor.getModelMarkers({resource:K});S?.(B)}});return()=>{O?.dispose()}}return()=>{}},[C,S]);function M(){F.current?.dispose(),g?c&&zr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return le.createElement(Yl,{width:x,height:_,isEditorReady:C,loading:i,_ref:L,className:w,wrapperProps:a})}var _g=bg,yg=b.memo(_g),Sg=yg,Dt=function(e,s){return Number(e.toFixed(s))},wg=function(e,s){return typeof e=="number"?e:s},Ge=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Cg=function(e){return-Math.cos(e*Math.PI)/2+.5},kg=function(e){return e},Eg=function(e){return e*e},jg=function(e){return e*(2-e)},Ng=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Rg=function(e){return e*e*e},Ag=function(e){return--e*e*e+1},Tg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Mg=function(e){return e*e*e*e},Dg=function(e){return 1- --e*e*e*e},Pg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Lg=function(e){return e*e*e*e*e},Ig=function(e){return 1+--e*e*e*e*e},Og=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Zl={easeOut:Cg,linear:kg,easeInQuad:Eg,easeOutQuad:jg,easeInOutQuad:Ng,easeInCubic:Rg,easeOutCubic:Ag,easeInOutCubic:Tg,easeInQuart:Mg,easeOutQuart:Dg,easeInOutQuart:Pg,easeInQuint:Lg,easeOutQuint:Ig,easeInOutQuint:Og},Jl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Bt=function(e){e.mounted&&(Jl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function ec(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;Bt(e),e.animation=function(){if(!e.mounted)return Jl(e.animation);var v=new Date().getTime()-p,n=v/r,i=Zl[s],l=i(n);v>=r?(o(m),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Bg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function ps(e,s,r,o){var p=Bg(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,u=s.scale-n,c=s.positionX-i,g=s.positionY-l;r===0?m(s.scale,s.positionX,s.positionY):ec(e,o,r,function(x){var _=n+u*x,w=i+c*x,a=l+g*x;m(_,w,a)})}}function Fg(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,v=s.offsetHeight,n=m*r,i=v*r,l=o-n,u=p-i;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:n,newDiffWidth:l,newContentHeight:i,newDiffHeight:u}}var zg=function(e,s,r,o,p,m,v){var n=e>s?r*(v?1:.5):0,i=o>p?m*(v?1:.5):0,l=e-s-n,u=n,c=o-p-i,g=i;return{minPositionX:l,maxPositionX:u,minPositionY:c,maxPositionY:g}},Yn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var m=Fg(r,o,s),v=m.wrapperWidth,n=m.wrapperHeight,i=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=zg(v,i,l,n,u,c,!!p);return g},cn=function(e,s,r,o){return o?e<s?Dt(s,2):e>r?Dt(r,2):Dt(e,2):Dt(e,2)},ws=function(e,s){var r=Yn(e,s);return e.bounds=r,r};function kr(e,s,r,o,p,m,v){var n=r.minPositionX,i=r.minPositionY,l=r.maxPositionX,u=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var x=cn(e,n-c,l+c,o),_=cn(s,i-g,u+g,o);return{x,y:_}}function xi(e,s,r,o,p,m){var v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,u=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:l};var c=i-s*u,g=l-r*u,x=kr(c,g,p,m,0,0,null);return x}function Er(e,s,r,o,p){var m=p?o:0,v=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var Jo=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,p=e.wrapperComponent,m=s.target,v="shadowRoot"in m&&"composedPath"in s,n=v?s.composedPath().some(function(u){return u instanceof Element?p?.contains(u):!1}):p?.contains(m),i=o&&m&&n;if(!i)return!1;var l=bi(m,r);return!l},ea=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},Wg=function(e,s){var r=e.transformState,o=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,v=s.clientY;e.startCoords={x:m-o,y:v-p}},Hg=function(e,s){var r=s.touches,o=e.transformState,p=o.positionX,m=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-p,y:i-m}}};function $g(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,v=m.disabled,n=m.limitToBounds,i=m.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var u=e.bounds,c=u.maxPositionX,g=u.minPositionX,x=u.maxPositionY,_=u.minPositionY,w=r>c||r<g,a=o>x||o<_,h=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>x?l.offsetHeight:e.setup.minPositionY||0,f=xi(e,h,d,p,e.bounds,n||i),S=f.x,C=f.y;return{scale:p,positionX:w?S:r,positionY:a?C:o}}}function tc(e,s,r,o,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,l=i.scale,u=i.positionX,c=i.positionY;if(!(v===null||n===null||s===u&&r===c)){var g=kr(s,r,n,m,o,p,v),x=g.x,_=g.y;e.setTransformState(l,x,_)}}var Ug=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,n=m.lockAxisY,i=p.positionX,l=p.positionY;if(!o)return{x:i,y:l};var u=s-o.x,c=r-o.y,g=v?i:u,x=n?l:c;return{x:g,y:x}},ms=function(e,s){var r=e.setup,o=e.transformState,p=o.scale,m=r.minScale,v=r.disablePadding;return s>0&&p>=m&&!v?s:0},qg=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,n=!v||m>1||!o||s;return!!n},Kg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,n=e.transformState.scale,i=v.disabled,l=!i||n>1||!m||s;return!(!l||!r||!o)};function Vg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function ta(e,s,r,o,p,m,v,n,i,l){if(p){if(s>v&&r>v){var u=v+(e-v)*l;return u>i?i:u<v?v:u}if(s<m&&r<m){var u=m+(e-m)*l;return u<n?n:u>m?m:u}}return o?s:cn(e,m,v,p)}function Xg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function Yg(e,s){var r=qg(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,n=m.velocityAnimation.equalToMove,i=Date.now();if(o&&p&&v){var l=Xg(v,n),u=s.x-o.x,c=s.y-o.y,g=u/l,x=c/l,_=i-p,w=u*u+c*c,a=Math.sqrt(w)/_;e.velocity={velocityX:g,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function Gg(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=Kg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,n=s.velocityY,i=s.total,l=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,x=o.limitToBounds,_=o.alignmentAnimation,w=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,f=w.animationType,S=_.sizeX,C=_.sizeY,k=_.velocityAlignmentTime,E=k,y=Vg(e,i),j=Math.max(y,E),R=ms(e,S),L=ms(e,C),T=R*p.offsetWidth/100,D=L*p.offsetHeight/100,F=l+T,I=u-T,H=c+D,q=g-D,A=e.transformState,P=new Date().getTime();ec(e,f,j,function(M){var O=e.transformState,$=O.scale,K=O.positionX,B=O.positionY,z=new Date().getTime()-P,U=z/E,N=Zl[_.animationType],W=1-N(Math.min(1,U)),X=1-M,V=K+v*X,ie=B+n*X,ee=ta(V,A.positionX,K,d,x,u,l,I,F,W),me=ta(ie,A.positionY,B,h,x,g,c,q,H,W);(K!==V||B!==ie)&&e.setTransformState($,ee,me)})}}function sa(e,s){var r=e.transformState.scale;Bt(e),ws(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?Hg(e,s):Wg(e,s)}function Gn(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,v=m.disabled,n=m.sizeX,i=m.sizeY,l=m.animationTime,u=m.animationType,c=v||r<p||!n&&!i;if(!c){var g=$g(e);g&&ps(e,g,s??l,u)}}function ra(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,n=m.sizeY;if(o){var i=Ug(e,s,r),l=i.x,u=i.y,c=ms(e,v),g=ms(e,n);Yg(e,{x:l,y:u}),tc(e,l,u,c,g)}}function Qg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=o?.getBoundingClientRect(),v=p?.getBoundingClientRect(),n=m?.width||0,i=m?.height||0,l=v?.width||0,u=v?.height||0,c=n<l||i<u,g=!s&&r&&r?.total>.1&&c;g?Gg(e):Gn(e)}}function Qn(e,s,r,o){var p=e.setup,m=p.minScale,v=p.maxScale,n=p.limitToBounds,i=Er(Dt(s,2),m,v,0,!1),l=ws(e,i),u=xi(e,r,o,i,l,n),c=u.x,g=u.y;return{scale:i,positionX:c,positionY:g}}function sc(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,n=m.limitToBounds,i=m.zoomAnimation,l=i.disabled,u=i.animationTime,c=i.animationType,g=l||o>=v;if((o>=1||n)&&Gn(e),!(g||!p||!e.mounted)){var x=s||p.offsetWidth/2,_=r||p.offsetHeight/2,w=Qn(e,v,x,_);w&&ps(e,w,u,c)}}var hs=function(){return hs=Object.assign||function(s){for(var r,o=1,p=arguments.length;o<p;o++){r=arguments[o];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},hs.apply(this,arguments)};function ia(e,s,r){for(var o=0,p=s.length,m;o<p;o++)(m||!(o in s))&&(m||(m=Array.prototype.slice.call(s,0,o)),m[o]=s[o]);return e.concat(m||Array.prototype.slice.call(s))}var Wr={scale:1,positionX:0,positionY:0},nr={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},dn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},rc=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Wr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Wr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Wr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Wr.positionY}},na=function(e){var s=hs({},nr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof nr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(nr[r]),v=m==="[object Object]",n=m==="[object Array]";v?s[r]=hs(hs({},nr[r]),e[r]):n?s[r]=ia(ia([],nr[r],!0),e[r]):s[r]=e[r]}}),s},ic=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,n=m.minScale,i=m.zoomAnimation,l=m.smooth,u=i.size;if(!p)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,g=Er(Dt(c,3),n,v,u,!1);return g};function nc(e,s,r,o,p){var m=e.wrapperComponent,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY;if(!m)return console.error("No WrapperComponent found");var u=m.offsetWidth,c=m.offsetHeight,g=(u/2-i)/n,x=(c/2-l)/n,_=ic(e,s,r),w=Qn(e,_,g,x);if(!w)return console.error("Error during zoom event. New transformation state was not calculated.");ps(e,w,o,p)}function oc(e,s,r,o){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,n=rc(e.props),i=e.transformState,l=i.scale,u=i.positionX,c=i.positionY;if(m){var g=Yn(e,n.scale),x=kr(n.positionX,n.positionY,g,v,0,0,m),_={scale:n.scale,positionX:x.x,positionY:x.y};l===n.scale&&u===n.positionX&&c===n.positionY||(o?.(),ps(e,_,s,r))}}function Zg(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),v=r.getBoundingClientRect(),n=m.x*o.scale,i=m.y*o.scale;return{x:(p.x-v.x+n)/o.scale,y:(p.y-v.y+i)/o.scale}}function Jg(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,n=v.limitToBounds,i=v.minScale,l=v.maxScale;if(!o||!p)return m;var u=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=Zg(s,o,p,m),x=g.x,_=g.y,w=c.width/m.scale,a=c.height/m.scale,h=o.offsetWidth/w,d=o.offsetHeight/a,f=Er(r||Math.min(h,d),i,l,0,!1),S=(u.width-w*f)/2,C=(u.height-a*f)/2,k=(u.left-x)*f+S,E=(u.top-_)*f+C,y=Yn(e,f),j=kr(k,E,y,n,0,0,o),R=j.x,L=j.y;return{positionX:R,positionY:L,scale:f}}var ev=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),nc(e,1,s,r,o)}},tv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),nc(e,-1,s,r,o)}},sv=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,n=v.positionX,i=v.positionY,l=v.scale,u=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!c)){var x={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?l:o};ps(e,x,p,m)}}},rv=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),oc(e,s,r)}},iv=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var p=e.transformState,m=e.wrapperComponent,v=e.contentComponent;if(m&&v){var n=ac(s||p.scale,m,v);ps(e,n,r,o)}}},nv=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),Bt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var n=Jg(e,v,r);ps(e,n,o,p)}}},ri=function(e){return{instance:e,zoomIn:ev(e),zoomOut:tv(e),setTransform:sv(e),resetTransform:rv(e),centerView:iv(e),zoomToElement:nv(e)}},un=function(e){return{instance:e,state:e.transformState}},Ve=function(e){var s={};return Object.assign(s,un(e)),Object.assign(s,ri(e)),s},Wi=!1;function Hi(){try{var e={get passive(){return Wi=!0,!1}};return e}catch{return Wi=!1,Wi}}var Hr=".".concat(dn.wrapperClass),bi=function(e,s){return s.some(function(r){return e.matches("".concat(Hr," ").concat(r,", ").concat(Hr," .").concat(r,", ").concat(Hr," ").concat(r," *, ").concat(Hr," .").concat(r," *"))})},hn=function(e){e&&clearTimeout(e)},ov=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},ac=function(e,s,r){var o=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-o)/2,v=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:v}};function av(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var lv=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,n=e.isInitialized,i=e.isPanning,l=s.target,u=n&&!i&&!o&&l;if(!u||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=bi(l,v);return!c},cv=function(e){return e?e.deltaY<0?1:-1:0};function dv(e,s){var r=cv(e),o=wg(s,r);return o}function lc(e,s,r){var o=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-o.left)/r,m=(e.clientY-o.top)/r;else{var v=e.touches[0];p=(v.clientX-o.left)/r,m=(v.clientY-o.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var uv=function(e,s,r,o,p){var m=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,l=n.minScale,u=n.zoomAnimation,c=n.disablePadding,g=u.size,x=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var _=m+s*r,w=o?!1:!x,a=Er(Dt(_,3),l,i,g,w&&!c);return a},hv=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,p=e.setup,m=p.maxScale,v=p.minScale;return r?o<m||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},fv=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,v=s.target,n=m&&!o&&v;if(!n)return!1;var i=bi(v,p);return!i},mv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},pv=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Dt(p[0].clientX-o.left,5),v=Dt(p[0].clientY-o.top,5),n=Dt(p[1].clientX-o.left,5),i=Dt(p[1].clientY-o.top,5);return{x:(m+n)/2/s,y:(v+i)/2/s}},cc=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},gv=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,n=p.zoomAnimation,i=p.disablePadding,l=n.size,u=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,g=c*r;return Er(Dt(g,2),v,m,l,!u&&!i)},vv=160,xv=100,bv=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Bt(e),Ge(Ve(e),s,o),Ge(Ve(e),s,p))},_v=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,n=e.transformState,i=n.scale,l=v.limitToBounds,u=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,x=v.disablePadding,_=v.smooth,w=c.size,a=c.disabled,h=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=dv(s,null),S=_?d*Math.abs(s.deltaY):h,C=uv(e,f,S,!s.ctrlKey);if(i!==C){var k=ws(e,C),E=lc(s,m,i),y=a||w===0||u||x,j=l&&y,R=xi(e,E.x,E.y,C,k,j),L=R.x,T=R.y;e.previousWheelEvent=s,e.setTransformState(C,L,T),Ge(Ve(e),s,o),Ge(Ve(e),s,p)}},yv=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;hn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(sc(e,s.x,s.y),e.wheelAnimationTimer=null)},xv);var m=hv(e,s);m&&(hn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ge(Ve(e),s,o),Ge(Ve(e),s,p))},vv))},dc=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var p=s/2,m=r/2;return{x:p,y:m}},Sv=function(e,s){var r=cc(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=dc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Bt(e)},wv=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,n=v.limitToBounds,i=v.centerZoomedOut,l=v.zoomAnimation,u=v.alignmentAnimation,c=l.disabled,g=l.size;if(!(o===null||!r)){var x=pv(s,m,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var _=cc(s),w=gv(e,_),a=dc(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(w===m&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ws(e,w),S=c||g===0||i,C=n&&S,k=xi(e,x.x,x.y,w,f,C),E=k.x,y=k.y;e.pinchMidpoint=x,e.lastDistance=_;var j=u.sizeX,R=u.sizeY,L=ms(e,j),T=ms(e,R),D=E+h,F=y+d,I=kr(D,F,f,n,L,T,p),H=I.x,q=I.y;e.setTransformState(w,H,q)}}}},Cv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,sc(e,s?.x,s?.y)},uc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;hn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ge(Ve(e),s,r)},o)},kv=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,n=m.animationType;Ge(Ve(e),s,o),oc(e,v,n,function(){return Ge(Ve(e),s,p)}),uc(e,s)};function Ev(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function jv(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,n=e.props,i=n.onZoomStart,l=n.onZoom,u=r.doubleClick,c=u.disabled,g=u.mode,x=u.step,_=u.animationTime,w=u.animationType;if(!c&&!o){if(g==="reset")return kv(e,s);if(!m)return console.error("No ContentComponent found");var a=Ev(g,e.transformState.scale),h=ic(e,a,x);if(v!==h){Ge(Ve(e),s,i);var d=lc(s,m,v),f=Qn(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ge(Ve(e),s,l),ps(e,f,_,w),uc(e,s)}}}var Nv=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,v=m.disabled,n=m.excluded,i=s.target,l=p?.contains(i),u=r&&i&&l&&!v;if(!u)return!1;var c=bi(i,n);return!c},Rv=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,ws(r,r.transformState.scale),r.setup=na(o)},this.initializeWindowEvents=function(){var o,p,m=Hi(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),n?.addEventListener("mousedown",r.onPanningStart,m),n?.addEventListener("mousemove",r.onPanning,m),n?.addEventListener("mouseup",r.onPanningStop,m),v?.addEventListener("mouseleave",r.clearPanning,m),n?.addEventListener("keyup",r.setKeyUnPressed,m),n?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=Hi(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,m),n?.removeEventListener("mousemove",r.onPanning,m),n?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),n?.removeEventListener("keyup",r.setKeyUnPressed,m),n?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),Bt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=Hi();o.addEventListener("wheel",r.onWheelZoom,p),o.addEventListener("dblclick",r.onDoubleClick,p),o.addEventListener("touchstart",r.onTouchPanningStart,p),o.addEventListener("touchmove",r.onTouchPanning,p),o.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(o,p){var m=!1,v=r.setup.centerOnInit,n=function(i,l){for(var u=0,c=i;u<c.length;u++){var g=c[u];if(g.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(Ve(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,p))if(v&&!m){var l=p.offsetWidth,u=p.offsetHeight;(l>0||u>0)&&(m=!0,r.setCenter())}else Bt(r),ws(r,r.transformState.scale),Gn(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=lv(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(bv(r,o),_v(r,o),yv(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,v=p.wheel,n=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,l=i.positionX,u=i.positionY,c=l-o.deltaX,g=u-o.deltaY,x=n.lockAxisX?l:c,_=n.lockAxisY?u:g,w=r.setup.alignmentAnimation,a=w.sizeX,h=w.sizeY,d=ms(r,a),f=ms(r,h);x===l&&_===u||tc(r,x,_,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Jo(r,o);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),Bt(r),sa(r,o),Ge(Ve(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=ea(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),ra(r,o.clientX,o.clientY),Ge(Ve(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(Qg(r),Ge(Ve(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,n=m.onZoomStart;if(!p){var i=fv(r,o);i&&(Sv(r,o),Bt(r),Ge(Ve(r),o,v),Ge(Ve(r),o,n))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinching,n=m.onZoom;if(!p){var i=mv(r);i&&(o.preventDefault(),o.stopPropagation(),wv(r,o),Ge(Ve(r),o,v),Ge(Ve(r),o,n))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(Cv(r),Ge(Ve(r),o,m),Ge(Ve(r),o,v))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Jo(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,Bt(r);var i=o.touches,l=i.length===1,u=i.length===2;l&&(Bt(r),sa(r,o),Ge(Ve(r),o,m)),u&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(p)return;var v=ea(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];ra(r,n.clientX,n.clientY),Ge(Ve(r),o,m)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var p=r.setup.disabled;if(!p){var m=Nv(r,o);m&&jv(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(o,p,m){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(p)&&!Number.isNaN(m)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var n=Ve(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Ge(n,{scale:o,positionX:p,positionY:m},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=ac(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,p,m){return r.props.customTransform?r.props.customTransform(o,p,m):ov(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,v=o.positionY,n=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=n}},this.getContext=function(){return Ve(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,p){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=p,ws(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ve(r);Ge(m,void 0,r.props.onInit)},this.props=s,this.setup=na(this.props),this.transformState=rc(this.props)}return e})(),_i=le.createContext(null),Av=function(e,s){return typeof e=="function"?e(s):e},Tv=le.forwardRef(function(e,s){var r=b.useRef(new Rv(e)).current,o=Av(e.children,ri(r));return b.useImperativeHandle(s,function(){return ri(r)},[r]),b.useEffect(function(){r.update(e)},[r,e]),le.createElement(_i.Provider,{value:r},o)});le.forwardRef(function(e,s){var r=b.useRef(null),o=b.useContext(_i);return b.useEffect(function(){return o.onChange(function(p){if(r.current){var m=0,v=0;r.current.style.transform=o.handleTransformStyles(m,v,1/p.instance.transformState.scale)}})},[o]),le.createElement("div",hs({},e,{ref:av([r,s])}))});function Mv(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&o.firstChild?o.insertBefore(p,o.firstChild):o.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var Dv=`.transform-component-module_wrapper__SPB86 {
40
+ `},Jo=Wp(qp)(ql),Kp={config:$p},Vp=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(p){return r.reduceRight(function(m,v){return v(m)},p)}};function Kl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Kl(e[r],s[r]))}),Go(Go({},e),s)}var Xp={type:"cancelation",msg:"operation is manually canceled"};function Fi(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(Xp):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var Yp=["monaco"],Gp=Fp.create({config:zp,isInitialized:!1,resolve:null,reject:null,monaco:null}),Vl=yp(Gp,2),Cr=Vl[0],xi=Vl[1];function Qp(e){var s=Kp.config(e),r=s.monaco,o=bp(s,Yp);xi(function(p){return{config:Kl(p.config,o),monaco:r}})}function Zp(){var e=Cr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(xi({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Fi(zi);if(window.monaco&&window.monaco.editor)return Xl(window.monaco),e.resolve(window.monaco),Fi(zi);Vp(Jp,tg)(sg)}return Fi(zi)}function Jp(e){return document.body.appendChild(e)}function eg(e){var s=document.createElement("script");return e&&(s.src=e),s}function tg(e){var s=Cr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=eg("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function sg(){var e=Cr(function(r){var o=r.config,p=r.resolve,m=r.reject;return{config:o,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;Xl(o),e.resolve(o)},function(r){e.reject(r)})}function Xl(e){Cr().monaco||xi({monaco:e})}function rg(){return Cr(function(e){var s=e.monaco;return s})}var zi=new Promise(function(e,s){return xi({resolve:e,reject:s})}),Yl={config:Qp,init:Zp,__getMonacoInstance:rg},ig={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Wi=ig,ng={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},og=ng;function ag({children:e}){return le.createElement("div",{style:og.container},e)}var lg=ag,cg=lg;function dg({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:v}){return le.createElement("section",{style:{...Wi.wrapper,width:e,height:s},...v},!r&&le.createElement(cg,null,o),le.createElement("div",{ref:p,style:{...Wi.fullWidth,...!r&&Wi.hide},className:m}))}var ug=dg,Gl=b.memo(ug);function hg(e){b.useEffect(e,[])}var Ql=hg;function fg(e,s,r=!0){let o=b.useRef(!0);b.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var Et=fg;function hr(){}function Bs(e,s,r,o){return mg(e,o)||pg(e,s,r,o)}function mg(e,s){return e.editor.getModel(Zl(e,s))}function pg(e,s,r,o){return e.editor.createModel(s,r,o?Zl(e,o):void 0)}function Zl(e,s){return e.Uri.parse(s)}function gg({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:u="Loading...",options:c={},height:g="100%",width:x="100%",className:_,wrapperProps:w={},beforeMount:a=hr,onMount:h=hr}){let[d,f]=b.useState(!1),[S,C]=b.useState(!0),k=b.useRef(null),E=b.useRef(null),y=b.useRef(null),j=b.useRef(h),R=b.useRef(a),L=b.useRef(!1);Ql(()=>{let I=Yl.init();return I.then(H=>(E.current=H)&&C(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>k.current?F():I.cancel()}),Et(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),H=Bs(E.current,e||"",o||r||"text",m||"");H!==I.getModel()&&I.setModel(H)}},[m],d),Et(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),H=Bs(E.current,s||"",p||r||"text",v||"");H!==I.getModel()&&I.setModel(H)}},[v],d),Et(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],d),Et(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),Et(()=>{let{original:I,modified:H}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage(H,p||r||"text")},[r,o,p],d),Et(()=>{E.current?.editor.setTheme(l)},[l],d),Et(()=>{k.current?.updateOptions(c)},[c],d);let T=b.useCallback(()=>{if(!E.current)return;R.current(E.current);let I=Bs(E.current,e||"",o||r||"text",m||""),H=Bs(E.current,s||"",p||r||"text",v||"");k.current?.setModel({original:I,modified:H})},[r,s,p,e,o,m,v]),D=b.useCallback(()=>{!L.current&&y.current&&(k.current=E.current.editor.createDiffEditor(y.current,{automaticLayout:!0,...c}),T(),E.current?.editor.setTheme(l),f(!0),L.current=!0)},[c,l,T]);b.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),b.useEffect(()=>{!S&&!d&&D()},[S,d,D]);function F(){let I=k.current?.getModel();n||I?.original?.dispose(),i||I?.modified?.dispose(),k.current?.dispose()}return le.createElement(Gl,{width:x,height:g,isEditorReady:d,loading:u,_ref:y,className:_,wrapperProps:w})}var vg=gg;b.memo(vg);function xg(e){let s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}var bg=xg,zr=new Map;function _g({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:v="light",line:n,loading:i="Loading...",options:l={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:g=!1,width:x="100%",height:_="100%",className:w,wrapperProps:a={},beforeMount:h=hr,onMount:d=hr,onChange:f,onValidate:S=hr}){let[C,k]=b.useState(!1),[E,y]=b.useState(!0),j=b.useRef(null),R=b.useRef(null),L=b.useRef(null),T=b.useRef(d),D=b.useRef(h),F=b.useRef(),I=b.useRef(o),H=bg(m),q=b.useRef(!1),A=b.useRef(!1);Ql(()=>{let O=Yl.init();return O.then($=>(j.current=$)&&y(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>R.current?M():O.cancel()}),Et(()=>{let O=Bs(j.current,e||o||"",s||p||"",m||r||"");O!==R.current?.getModel()&&(c&&zr.set(H,R.current?.saveViewState()),R.current?.setModel(O),c&&R.current?.restoreViewState(zr.get(m)))},[m],C),Et(()=>{R.current?.updateOptions(l)},[l],C),Et(()=>{!R.current||o===void 0||(R.current.getOption(j.current.editor.EditorOption.readOnly)?R.current.setValue(o):o!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[o],C),Et(()=>{let O=R.current?.getModel();O&&p&&j.current?.editor.setModelLanguage(O,p)},[p],C),Et(()=>{n!==void 0&&R.current?.revealLine(n)},[n],C),Et(()=>{j.current?.editor.setTheme(v)},[v],C);let P=b.useCallback(()=>{if(!(!L.current||!j.current)&&!q.current){D.current(j.current);let O=m||r,$=Bs(j.current,o||e||"",s||p||"",O||"");R.current=j.current?.editor.create(L.current,{model:$,automaticLayout:!0,...l},u),c&&R.current.restoreViewState(zr.get(O)),j.current.editor.setTheme(v),n!==void 0&&R.current.revealLine(n),k(!0),q.current=!0}},[e,s,r,o,p,m,l,u,c,v,n]);b.useEffect(()=>{C&&T.current(R.current,j.current)},[C]),b.useEffect(()=>{!E&&!C&&P()},[E,C,P]),I.current=o,b.useEffect(()=>{C&&f&&(F.current?.dispose(),F.current=R.current?.onDidChangeModelContent(O=>{A.current||f(R.current.getValue(),O)}))},[C,f]),b.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers($=>{let K=R.current.getModel()?.uri;if(K&&$.find(B=>B.path===K.path)){let B=j.current.editor.getModelMarkers({resource:K});S?.(B)}});return()=>{O?.dispose()}}return()=>{}},[C,S]);function M(){F.current?.dispose(),g?c&&zr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return le.createElement(Gl,{width:x,height:_,isEditorReady:C,loading:i,_ref:L,className:w,wrapperProps:a})}var yg=_g,Sg=b.memo(yg),wg=Sg,Dt=function(e,s){return Number(e.toFixed(s))},Cg=function(e,s){return typeof e=="number"?e:s},Ge=function(e,s,r){r&&typeof r=="function"&&r(e,s)},kg=function(e){return-Math.cos(e*Math.PI)/2+.5},Eg=function(e){return e},jg=function(e){return e*e},Ng=function(e){return e*(2-e)},Rg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Ag=function(e){return e*e*e},Tg=function(e){return--e*e*e+1},Mg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Dg=function(e){return e*e*e*e},Pg=function(e){return 1- --e*e*e*e},Lg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Ig=function(e){return e*e*e*e*e},Og=function(e){return 1+--e*e*e*e*e},Bg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Jl={easeOut:kg,linear:Eg,easeInQuad:jg,easeOutQuad:Ng,easeInOutQuad:Rg,easeInCubic:Ag,easeOutCubic:Tg,easeInOutCubic:Mg,easeInQuart:Dg,easeOutQuart:Pg,easeInOutQuart:Lg,easeInQuint:Ig,easeOutQuint:Og,easeInOutQuint:Bg},ec=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Bt=function(e){e.mounted&&(ec(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function tc(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;Bt(e),e.animation=function(){if(!e.mounted)return ec(e.animation);var v=new Date().getTime()-p,n=v/r,i=Jl[s],l=i(n);v>=r?(o(m),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Fg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function ps(e,s,r,o){var p=Fg(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,u=s.scale-n,c=s.positionX-i,g=s.positionY-l;r===0?m(s.scale,s.positionX,s.positionY):tc(e,o,r,function(x){var _=n+u*x,w=i+c*x,a=l+g*x;m(_,w,a)})}}function zg(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,v=s.offsetHeight,n=m*r,i=v*r,l=o-n,u=p-i;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:n,newDiffWidth:l,newContentHeight:i,newDiffHeight:u}}var Wg=function(e,s,r,o,p,m,v){var n=e>s?r*(v?1:.5):0,i=o>p?m*(v?1:.5):0,l=e-s-n,u=n,c=o-p-i,g=i;return{minPositionX:l,maxPositionX:u,minPositionY:c,maxPositionY:g}},Gn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var m=zg(r,o,s),v=m.wrapperWidth,n=m.wrapperHeight,i=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=Wg(v,i,l,n,u,c,!!p);return g},dn=function(e,s,r,o){return o?e<s?Dt(s,2):e>r?Dt(r,2):Dt(e,2):Dt(e,2)},ws=function(e,s){var r=Gn(e,s);return e.bounds=r,r};function kr(e,s,r,o,p,m,v){var n=r.minPositionX,i=r.minPositionY,l=r.maxPositionX,u=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var x=dn(e,n-c,l+c,o),_=dn(s,i-g,u+g,o);return{x,y:_}}function bi(e,s,r,o,p,m){var v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,u=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:l};var c=i-s*u,g=l-r*u,x=kr(c,g,p,m,0,0,null);return x}function Er(e,s,r,o,p){var m=p?o:0,v=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var ea=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,p=e.wrapperComponent,m=s.target,v="shadowRoot"in m&&"composedPath"in s,n=v?s.composedPath().some(function(u){return u instanceof Element?p?.contains(u):!1}):p?.contains(m),i=o&&m&&n;if(!i)return!1;var l=_i(m,r);return!l},ta=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},Hg=function(e,s){var r=e.transformState,o=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,v=s.clientY;e.startCoords={x:m-o,y:v-p}},$g=function(e,s){var r=s.touches,o=e.transformState,p=o.positionX,m=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-p,y:i-m}}};function Ug(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,v=m.disabled,n=m.limitToBounds,i=m.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var u=e.bounds,c=u.maxPositionX,g=u.minPositionX,x=u.maxPositionY,_=u.minPositionY,w=r>c||r<g,a=o>x||o<_,h=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>x?l.offsetHeight:e.setup.minPositionY||0,f=bi(e,h,d,p,e.bounds,n||i),S=f.x,C=f.y;return{scale:p,positionX:w?S:r,positionY:a?C:o}}}function sc(e,s,r,o,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,l=i.scale,u=i.positionX,c=i.positionY;if(!(v===null||n===null||s===u&&r===c)){var g=kr(s,r,n,m,o,p,v),x=g.x,_=g.y;e.setTransformState(l,x,_)}}var qg=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,n=m.lockAxisY,i=p.positionX,l=p.positionY;if(!o)return{x:i,y:l};var u=s-o.x,c=r-o.y,g=v?i:u,x=n?l:c;return{x:g,y:x}},ms=function(e,s){var r=e.setup,o=e.transformState,p=o.scale,m=r.minScale,v=r.disablePadding;return s>0&&p>=m&&!v?s:0},Kg=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,n=!v||m>1||!o||s;return!!n},Vg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,n=e.transformState.scale,i=v.disabled,l=!i||n>1||!m||s;return!(!l||!r||!o)};function Xg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function sa(e,s,r,o,p,m,v,n,i,l){if(p){if(s>v&&r>v){var u=v+(e-v)*l;return u>i?i:u<v?v:u}if(s<m&&r<m){var u=m+(e-m)*l;return u<n?n:u>m?m:u}}return o?s:dn(e,m,v,p)}function Yg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function Gg(e,s){var r=Kg(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,n=m.velocityAnimation.equalToMove,i=Date.now();if(o&&p&&v){var l=Yg(v,n),u=s.x-o.x,c=s.y-o.y,g=u/l,x=c/l,_=i-p,w=u*u+c*c,a=Math.sqrt(w)/_;e.velocity={velocityX:g,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function Qg(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=Vg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,n=s.velocityY,i=s.total,l=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,x=o.limitToBounds,_=o.alignmentAnimation,w=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,f=w.animationType,S=_.sizeX,C=_.sizeY,k=_.velocityAlignmentTime,E=k,y=Xg(e,i),j=Math.max(y,E),R=ms(e,S),L=ms(e,C),T=R*p.offsetWidth/100,D=L*p.offsetHeight/100,F=l+T,I=u-T,H=c+D,q=g-D,A=e.transformState,P=new Date().getTime();tc(e,f,j,function(M){var O=e.transformState,$=O.scale,K=O.positionX,B=O.positionY,z=new Date().getTime()-P,U=z/E,N=Jl[_.animationType],W=1-N(Math.min(1,U)),X=1-M,V=K+v*X,ie=B+n*X,ee=sa(V,A.positionX,K,d,x,u,l,I,F,W),me=sa(ie,A.positionY,B,h,x,g,c,q,H,W);(K!==V||B!==ie)&&e.setTransformState($,ee,me)})}}function ra(e,s){var r=e.transformState.scale;Bt(e),ws(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?$g(e,s):Hg(e,s)}function Qn(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,v=m.disabled,n=m.sizeX,i=m.sizeY,l=m.animationTime,u=m.animationType,c=v||r<p||!n&&!i;if(!c){var g=Ug(e);g&&ps(e,g,s??l,u)}}function ia(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,n=m.sizeY;if(o){var i=qg(e,s,r),l=i.x,u=i.y,c=ms(e,v),g=ms(e,n);Gg(e,{x:l,y:u}),sc(e,l,u,c,g)}}function Zg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=o?.getBoundingClientRect(),v=p?.getBoundingClientRect(),n=m?.width||0,i=m?.height||0,l=v?.width||0,u=v?.height||0,c=n<l||i<u,g=!s&&r&&r?.total>.1&&c;g?Qg(e):Qn(e)}}function Zn(e,s,r,o){var p=e.setup,m=p.minScale,v=p.maxScale,n=p.limitToBounds,i=Er(Dt(s,2),m,v,0,!1),l=ws(e,i),u=bi(e,r,o,i,l,n),c=u.x,g=u.y;return{scale:i,positionX:c,positionY:g}}function rc(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,n=m.limitToBounds,i=m.zoomAnimation,l=i.disabled,u=i.animationTime,c=i.animationType,g=l||o>=v;if((o>=1||n)&&Qn(e),!(g||!p||!e.mounted)){var x=s||p.offsetWidth/2,_=r||p.offsetHeight/2,w=Zn(e,v,x,_);w&&ps(e,w,u,c)}}var hs=function(){return hs=Object.assign||function(s){for(var r,o=1,p=arguments.length;o<p;o++){r=arguments[o];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},hs.apply(this,arguments)};function na(e,s,r){for(var o=0,p=s.length,m;o<p;o++)(m||!(o in s))&&(m||(m=Array.prototype.slice.call(s,0,o)),m[o]=s[o]);return e.concat(m||Array.prototype.slice.call(s))}var Wr={scale:1,positionX:0,positionY:0},nr={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},un={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},ic=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Wr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Wr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Wr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Wr.positionY}},oa=function(e){var s=hs({},nr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof nr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(nr[r]),v=m==="[object Object]",n=m==="[object Array]";v?s[r]=hs(hs({},nr[r]),e[r]):n?s[r]=na(na([],nr[r],!0),e[r]):s[r]=e[r]}}),s},nc=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,n=m.minScale,i=m.zoomAnimation,l=m.smooth,u=i.size;if(!p)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,g=Er(Dt(c,3),n,v,u,!1);return g};function oc(e,s,r,o,p){var m=e.wrapperComponent,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY;if(!m)return console.error("No WrapperComponent found");var u=m.offsetWidth,c=m.offsetHeight,g=(u/2-i)/n,x=(c/2-l)/n,_=nc(e,s,r),w=Zn(e,_,g,x);if(!w)return console.error("Error during zoom event. New transformation state was not calculated.");ps(e,w,o,p)}function ac(e,s,r,o){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,n=ic(e.props),i=e.transformState,l=i.scale,u=i.positionX,c=i.positionY;if(m){var g=Gn(e,n.scale),x=kr(n.positionX,n.positionY,g,v,0,0,m),_={scale:n.scale,positionX:x.x,positionY:x.y};l===n.scale&&u===n.positionX&&c===n.positionY||(o?.(),ps(e,_,s,r))}}function Jg(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),v=r.getBoundingClientRect(),n=m.x*o.scale,i=m.y*o.scale;return{x:(p.x-v.x+n)/o.scale,y:(p.y-v.y+i)/o.scale}}function ev(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,n=v.limitToBounds,i=v.minScale,l=v.maxScale;if(!o||!p)return m;var u=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=Jg(s,o,p,m),x=g.x,_=g.y,w=c.width/m.scale,a=c.height/m.scale,h=o.offsetWidth/w,d=o.offsetHeight/a,f=Er(r||Math.min(h,d),i,l,0,!1),S=(u.width-w*f)/2,C=(u.height-a*f)/2,k=(u.left-x)*f+S,E=(u.top-_)*f+C,y=Gn(e,f),j=kr(k,E,y,n,0,0,o),R=j.x,L=j.y;return{positionX:R,positionY:L,scale:f}}var tv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),oc(e,1,s,r,o)}},sv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),oc(e,-1,s,r,o)}},rv=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,n=v.positionX,i=v.positionY,l=v.scale,u=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!c)){var x={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?l:o};ps(e,x,p,m)}}},iv=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),ac(e,s,r)}},nv=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var p=e.transformState,m=e.wrapperComponent,v=e.contentComponent;if(m&&v){var n=lc(s||p.scale,m,v);ps(e,n,r,o)}}},ov=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),Bt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var n=ev(e,v,r);ps(e,n,o,p)}}},ii=function(e){return{instance:e,zoomIn:tv(e),zoomOut:sv(e),setTransform:rv(e),resetTransform:iv(e),centerView:nv(e),zoomToElement:ov(e)}},hn=function(e){return{instance:e,state:e.transformState}},Ve=function(e){var s={};return Object.assign(s,hn(e)),Object.assign(s,ii(e)),s},Hi=!1;function $i(){try{var e={get passive(){return Hi=!0,!1}};return e}catch{return Hi=!1,Hi}}var Hr=".".concat(un.wrapperClass),_i=function(e,s){return s.some(function(r){return e.matches("".concat(Hr," ").concat(r,", ").concat(Hr," .").concat(r,", ").concat(Hr," ").concat(r," *, ").concat(Hr," .").concat(r," *"))})},fn=function(e){e&&clearTimeout(e)},av=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},lc=function(e,s,r){var o=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-o)/2,v=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:v}};function lv(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var cv=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,n=e.isInitialized,i=e.isPanning,l=s.target,u=n&&!i&&!o&&l;if(!u||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=_i(l,v);return!c},dv=function(e){return e?e.deltaY<0?1:-1:0};function uv(e,s){var r=dv(e),o=Cg(s,r);return o}function cc(e,s,r){var o=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-o.left)/r,m=(e.clientY-o.top)/r;else{var v=e.touches[0];p=(v.clientX-o.left)/r,m=(v.clientY-o.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var hv=function(e,s,r,o,p){var m=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,l=n.minScale,u=n.zoomAnimation,c=n.disablePadding,g=u.size,x=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var _=m+s*r,w=o?!1:!x,a=Er(Dt(_,3),l,i,g,w&&!c);return a},fv=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,p=e.setup,m=p.maxScale,v=p.minScale;return r?o<m||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},mv=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,v=s.target,n=m&&!o&&v;if(!n)return!1;var i=_i(v,p);return!i},pv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},gv=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Dt(p[0].clientX-o.left,5),v=Dt(p[0].clientY-o.top,5),n=Dt(p[1].clientX-o.left,5),i=Dt(p[1].clientY-o.top,5);return{x:(m+n)/2/s,y:(v+i)/2/s}},dc=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},vv=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,n=p.zoomAnimation,i=p.disablePadding,l=n.size,u=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,g=c*r;return Er(Dt(g,2),v,m,l,!u&&!i)},xv=160,bv=100,_v=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Bt(e),Ge(Ve(e),s,o),Ge(Ve(e),s,p))},yv=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,n=e.transformState,i=n.scale,l=v.limitToBounds,u=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,x=v.disablePadding,_=v.smooth,w=c.size,a=c.disabled,h=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=uv(s,null),S=_?d*Math.abs(s.deltaY):h,C=hv(e,f,S,!s.ctrlKey);if(i!==C){var k=ws(e,C),E=cc(s,m,i),y=a||w===0||u||x,j=l&&y,R=bi(e,E.x,E.y,C,k,j),L=R.x,T=R.y;e.previousWheelEvent=s,e.setTransformState(C,L,T),Ge(Ve(e),s,o),Ge(Ve(e),s,p)}},Sv=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;fn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(rc(e,s.x,s.y),e.wheelAnimationTimer=null)},bv);var m=fv(e,s);m&&(fn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ge(Ve(e),s,o),Ge(Ve(e),s,p))},xv))},uc=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var p=s/2,m=r/2;return{x:p,y:m}},wv=function(e,s){var r=dc(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=uc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Bt(e)},Cv=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,n=v.limitToBounds,i=v.centerZoomedOut,l=v.zoomAnimation,u=v.alignmentAnimation,c=l.disabled,g=l.size;if(!(o===null||!r)){var x=gv(s,m,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var _=dc(s),w=vv(e,_),a=uc(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(w===m&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ws(e,w),S=c||g===0||i,C=n&&S,k=bi(e,x.x,x.y,w,f,C),E=k.x,y=k.y;e.pinchMidpoint=x,e.lastDistance=_;var j=u.sizeX,R=u.sizeY,L=ms(e,j),T=ms(e,R),D=E+h,F=y+d,I=kr(D,F,f,n,L,T,p),H=I.x,q=I.y;e.setTransformState(w,H,q)}}}},kv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,rc(e,s?.x,s?.y)},hc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;fn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ge(Ve(e),s,r)},o)},Ev=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,n=m.animationType;Ge(Ve(e),s,o),ac(e,v,n,function(){return Ge(Ve(e),s,p)}),hc(e,s)};function jv(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Nv(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,n=e.props,i=n.onZoomStart,l=n.onZoom,u=r.doubleClick,c=u.disabled,g=u.mode,x=u.step,_=u.animationTime,w=u.animationType;if(!c&&!o){if(g==="reset")return Ev(e,s);if(!m)return console.error("No ContentComponent found");var a=jv(g,e.transformState.scale),h=nc(e,a,x);if(v!==h){Ge(Ve(e),s,i);var d=cc(s,m,v),f=Zn(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ge(Ve(e),s,l),ps(e,f,_,w),hc(e,s)}}}var Rv=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,v=m.disabled,n=m.excluded,i=s.target,l=p?.contains(i),u=r&&i&&l&&!v;if(!u)return!1;var c=_i(i,n);return!c},Av=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,ws(r,r.transformState.scale),r.setup=oa(o)},this.initializeWindowEvents=function(){var o,p,m=$i(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),n?.addEventListener("mousedown",r.onPanningStart,m),n?.addEventListener("mousemove",r.onPanning,m),n?.addEventListener("mouseup",r.onPanningStop,m),v?.addEventListener("mouseleave",r.clearPanning,m),n?.addEventListener("keyup",r.setKeyUnPressed,m),n?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=$i(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,m),n?.removeEventListener("mousemove",r.onPanning,m),n?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),n?.removeEventListener("keyup",r.setKeyUnPressed,m),n?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),Bt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=$i();o.addEventListener("wheel",r.onWheelZoom,p),o.addEventListener("dblclick",r.onDoubleClick,p),o.addEventListener("touchstart",r.onTouchPanningStart,p),o.addEventListener("touchmove",r.onTouchPanning,p),o.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(o,p){var m=!1,v=r.setup.centerOnInit,n=function(i,l){for(var u=0,c=i;u<c.length;u++){var g=c[u];if(g.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(Ve(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,p))if(v&&!m){var l=p.offsetWidth,u=p.offsetHeight;(l>0||u>0)&&(m=!0,r.setCenter())}else Bt(r),ws(r,r.transformState.scale),Qn(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=cv(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(_v(r,o),yv(r,o),Sv(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,v=p.wheel,n=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,l=i.positionX,u=i.positionY,c=l-o.deltaX,g=u-o.deltaY,x=n.lockAxisX?l:c,_=n.lockAxisY?u:g,w=r.setup.alignmentAnimation,a=w.sizeX,h=w.sizeY,d=ms(r,a),f=ms(r,h);x===l&&_===u||sc(r,x,_,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=ea(r,o);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),Bt(r),ra(r,o),Ge(Ve(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=ta(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),ia(r,o.clientX,o.clientY),Ge(Ve(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(Zg(r),Ge(Ve(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,n=m.onZoomStart;if(!p){var i=mv(r,o);i&&(wv(r,o),Bt(r),Ge(Ve(r),o,v),Ge(Ve(r),o,n))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinching,n=m.onZoom;if(!p){var i=pv(r);i&&(o.preventDefault(),o.stopPropagation(),Cv(r,o),Ge(Ve(r),o,v),Ge(Ve(r),o,n))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(kv(r),Ge(Ve(r),o,m),Ge(Ve(r),o,v))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=ea(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,Bt(r);var i=o.touches,l=i.length===1,u=i.length===2;l&&(Bt(r),ra(r,o),Ge(Ve(r),o,m)),u&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(p)return;var v=ta(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];ia(r,n.clientX,n.clientY),Ge(Ve(r),o,m)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var p=r.setup.disabled;if(!p){var m=Rv(r,o);m&&Nv(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(o,p,m){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(p)&&!Number.isNaN(m)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var n=Ve(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Ge(n,{scale:o,positionX:p,positionY:m},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=lc(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,p,m){return r.props.customTransform?r.props.customTransform(o,p,m):av(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,v=o.positionY,n=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=n}},this.getContext=function(){return Ve(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,p){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=p,ws(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ve(r);Ge(m,void 0,r.props.onInit)},this.props=s,this.setup=oa(this.props),this.transformState=ic(this.props)}return e})(),yi=le.createContext(null),Tv=function(e,s){return typeof e=="function"?e(s):e},Mv=le.forwardRef(function(e,s){var r=b.useRef(new Av(e)).current,o=Tv(e.children,ii(r));return b.useImperativeHandle(s,function(){return ii(r)},[r]),b.useEffect(function(){r.update(e)},[r,e]),le.createElement(yi.Provider,{value:r},o)});le.forwardRef(function(e,s){var r=b.useRef(null),o=b.useContext(yi);return b.useEffect(function(){return o.onChange(function(p){if(r.current){var m=0,v=0;r.current.style.transform=o.handleTransformStyles(m,v,1/p.instance.transformState.scale)}})},[o]),le.createElement("div",hs({},e,{ref:lv([r,s])}))});function Dv(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&o.firstChild?o.insertBefore(p,o.firstChild):o.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var Pv=`.transform-component-module_wrapper__SPB86 {
41
41
  position: relative;
42
42
  width: -moz-fit-content;
43
43
  width: fit-content;
@@ -68,23 +68,23 @@ 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
- `,oa={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Mv(Dv);var Pv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,u=e.contentProps,c=u===void 0?{}:u,g=b.useContext(_i),x=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),a=b.useRef(null);return b.useEffect(function(){var h=w.current,d=a.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){_?.()}},[]),le.createElement("div",hs({},l,{ref:w,className:"".concat(dn.wrapperClass," ").concat(oa.wrapper," ").concat(o),style:v}),le.createElement("div",hs({},c,{ref:a,className:"".concat(dn.contentClass," ").concat(oa.content," ").concat(m),style:n}),s))},hc=function(){var e=b.useContext(_i);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Lv=function(){var e=hc();return ri(e)};function Iv(e){var s=hc(),r=b.useState(e(un(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,v=s.onChange(function(n){m&&p(e(un(n.instance)))});return function(){v(),m=!1}},[e,s]),o}function Ov(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 Bv(e,s){return jt({queryKey:ce.files.tree(e||"",s),queryFn:()=>Ee.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Fv(e,s){return jt({queryKey:ce.files.content(e||"",s||""),queryFn:()=>Ee.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function zv(e){const s=bt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Wv(){const e=bt();return zt({mutationFn:s=>Ee.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||Ov(r.path)})}})}function Hv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function $v(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const Uv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function qv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&Uv.has(s)?Ba:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Yr:s==="json"?uu:s==="md"||s==="mdx"||s==="txt"?Oa:$d}const aa=({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})]}),fc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:n}=ae(),{data:i,isLoading:l,isError:u}=Bv(e,s),c=b.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=Hv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(aa,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Pt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(di,{size:14,className:"text-amber-500"}):t.jsx(An,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(fc,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const x=$v(s,g.name),_=qv(g),w=v===x,a=_===Ba;return t.jsx(aa,{depth:r,active:w,onClick:()=>m(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},x)})})},Kv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ae(),[v,n]=b.useState(()=>new Set),i=zv(e),l=b.useCallback(u=>{n(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),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:i,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(Ns,{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(yu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(fc,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},Vv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Xv(e){const s=e.split(".").pop()?.toLowerCase();return s?Vv.has(s):!1}function Yv(e,s){const r=br(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Gv=({filePath:e})=>{const{t:s}=ae(),{zoomIn:r,zoomOut:o,centerView:p}=Lv(),m=Iv(n=>n.state.scale),v=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(Iu,{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:[v,"%"]}),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(Pu,{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(bu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Qv=({workingDir:e,filePath:s})=>{const{t:r}=ae(),[o,p]=b.useState(!1),m=Yv(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(Tv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Gv,{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(Pv,{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 Zv(e){const s=e.split("/");return s[s.length-1]||e}function Jv(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 e0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ae();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(qt,{size:12})})]})},t0=le.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=ae(),[v,n]=b.useState([]),[i,l]=b.useState(null),[u,c]=b.useState(!1),[g,x]=b.useState(!1),[_,w]=b.useState(0),[a,h]=b.useState(null),d=b.useRef(null),f=Wv();b.useEffect(()=>{let B=!1;return vd(async()=>{const{preloadMonaco:z}=await import("./monaco-C5uCiSc1.js").then(U=>U.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{B||c(!0)}).catch(()=>{B||x(!0)}),()=>{B=!0}},[]);const[S,C]=b.useState(280),[k,E]=b.useState(!1),[y,j]=b.useState(!1),R=b.useRef(280),L=b.useCallback(()=>{E(B=>(B?C(R.current):R.current=S,!B))},[S]),T=b.useCallback(B=>{B.preventDefault(),j(!0);const z=B.clientX,U=S,N=X=>{const V=X.clientX-z,ie=Math.min(480,Math.max(160,U+V));C(ie)},W=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",W)},[S]);b.useEffect(()=>{n([]),l(null),h(null)},[s]);const D=b.useMemo(()=>v.find(B=>B.path===i)||null,[v,i]),{data:F,isFetching:I,isError:H,error:q}=Fv(s,D?.isImage?null:i);b.useEffect(()=>{!i||!F||n(B=>B.map(z=>z.path!==i||z.isDirty||z.loaded?z:{...z,language:F.language||z.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[i,F]);const A=b.useCallback((B,z,U)=>{n(N=>{if(N.find(V=>V.path===B))return N;const X=Xv(B);return[...N,{path:B,name:Zv(B),language:Jv(B),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(B),h(z?{path:B,line:z,column:U}:null)},[]);le.useImperativeHandle(p,()=>({openFile:A}),[A]);const P=b.useCallback(B=>{n(z=>{const U=z.filter(N=>N.path!==B);return l(N=>N!==B?N:U.length?U[U.length-1].path:null),U})},[]),M=b.useCallback(B=>{n(z=>z.map(U=>{if(U.path!==i)return U;const N=B!==U.savedContent;return{...U,content:B,isDirty:N}}))},[i]),O=b.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(B=>B.map(z=>z.path===D.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[D,o,f,s]),$=b.useRef(()=>{});b.useEffect(()=>{$.current=()=>{O().catch(()=>{})}},[O]),b.useEffect(()=>{const B=z=>{o||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),$.current())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[o]);const K=b.useCallback((B,z)=>{d.current=B,w(U=>U+1),B.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{$.current()})},[]);return b.useEffect(()=>{if(!a||a.path!==i||!D?.loaded)return;const B=d.current,z=B?.getModel();if(!B||!z)return;const U=Math.min(a.line,z.getLineCount()),N=Math.min(a.column??1,z.getLineMaxColumn(U)),W={lineNumber:U,column:N};B.setPosition(W),B.revealPositionInCenter(W),B.focus(),h(null)},[i,D?.loaded,_,a]),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:L,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(wu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(Kv,{workingDir:s,onFileSelect:A,selectedFilePath:D?.path||null,onCollapse:L},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,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:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):v.map(B=>t.jsx(e0,{active:B.path===i,name:B.name,isDirty:B.isDirty,onClick:()=>l(B.path),onClose:z=>{z.stopPropagation(),P(B.path)}},B.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(ze,{size:14,className:"animate-spin"}),m("Saving")]}),D?.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?D?D.isImage?t.jsx(Qv,{workingDir:s,filePath:D.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):u?t.jsxs(t.Fragment,{children:[t.jsx(Sg,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:B=>M(B??""),onMount:K,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.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(ze,{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(ze,{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 yi(e,s={}){const r=Es(p=>p.visibleContext),o=jl(e,r);return jt({queryKey:ce.git.changes(e||""),queryFn:()=>Ee.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function mc(e,s,r){const o=Es(m=>m.visibleContext),p=jl(e,o);return jt({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>Ee.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 Zn(e,s){return jt({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>Ee.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Jn(e,s,r){return jt({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ee.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const s0=new Set(["STARTING","RUNNING","STOPPING"]);function pc(e){return s0.has(e.runtimeState)||e.runtimeInstanceId!==null}function gc(e){return e instanceof oi&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function r0({services:e,isLoading:s,isError:r}){const{t:o}=ae();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(ze,{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(js,{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 vc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:v,isCheckingServices:n,serviceCheckFailed:i,error:l,onConfirm:u}){const{t:c}=ae(),[g,x]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),x(p??""))},[e]),b.useEffect(()=>{_||!e||x(p??"")},[p,_,e]);const a=()=>{m||s()};return t.jsx(fs,{isOpen:e,onClose:a,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:a,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:()=>u(g.trim()||void 0,v.length>0),disabled:m||n,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||n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"}),n?c("正在检查后台服务..."):v.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Xr,{size:14}),v.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(sl,{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:h=>{w(!0),x(h.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(r0,{services:v,isLoading:n,isError:i}),l&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:l})]})})}function Ls(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function xc(e){if(!(e instanceof oi)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==fr.REBASE&&s.conflictOp!==fr.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:Ls(s,"sourceBranch"),targetBranch:Ls(s,"targetBranch"),sourceWorktreePath:Ls(s,"sourceWorktreePath"),targetWorktreePath:Ls(s,"targetWorktreePath"),sourceWorkspaceId:Ls(s,"sourceWorkspaceId"),targetWorkspaceId:Ls(s,"targetWorkspaceId")}}function la(e,s,r,o){const p=xc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function bc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:n}){const{t:i}=ae(),{data:l,isLoading:u}=Hn(e),c=Al(),g=Rl(),x=$n(),[_,w]=b.useState(!1),[a,h]=b.useState(null),d=Xn(e,_),f=(d.data??[]).filter(pc);if(b.useEffect(()=>{_&&m?.()},[_,m]),u||!l)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(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const S=l.conflictedFiles.length>0,C=l.operation!=="idle",k=l.hasUncommittedChanges||l.untrackedCount>0,E=l.uncommittedCount+l.untrackedCount,y=!S&&!C&&!k,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!k&&!S,R=()=>{h(null),c.mutate(e,{onError:F=>{la(F,i("更新失败,请稍后重试"),I=>v(I),h)}})},L=()=>{h(null),w(!0)},T=(F,I)=>{h(null),g.mutate({id:e,commitMessage:F,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(gc(H)){h(i("后台服务仍在运行,请确认停止服务后再提交。"));return}la(H,i("提交失败,请稍后重试"),q=>{w(!1),v(q)},h)}})},D=()=>{g.isPending||(w(!1),h(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(xd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):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:[a&&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:a}),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(mu,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{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(js,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,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:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.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:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),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(ze,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.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(bd,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!S&&!C&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.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(Ns,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!k?t.jsxs("button",{onClick:L,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(Xr,{size:12}),i("提交变更")]}):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:i(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Xr,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(vc,{isOpen:_,onClose:D,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:a,onConfirm:T})]})}const $i=50,Ui=400,ca={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"},da={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function _c(e){const s=e.split("/");return s[s.length-1]||e}function i0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function n0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Ur(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const fn=({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"})]}),o0=({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})]})},yc=({diff:e})=>{const{t:s}=ae(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
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>Ui,v=m?p.slice(0,Ui):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(o0,{line:n,lineNum:i+1},i)),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-Ui})})]})},a0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=mc(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(yc,{diff:m?.diff||""})},l0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=Jn(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(yc,{diff:m?.diff||""})},qi=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,v]=b.useState(!1),[n,i]=b.useState(!1),l=b.useRef(null),u=Ur(s,e.path);b.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),b.useEffect(()=>{const x=l.current;if(!x||n)return;const _=new IntersectionObserver(w=>{w.some(a=>a.isIntersecting)&&(i(!0),_.disconnect())},{rootMargin:"300px 0px"});return _.observe(x),()=>_.disconnect()},[n]);const c=ca[e.status]||ca.M,g=i0(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,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:()=>v(x=>!x),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(Pt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(wt,{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:_c(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(fn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(a0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(l0,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function c0(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 v=o[m];p.dirs.has(v)||p.dirs.set(v,{name:v,path:p.path?`${p.path}/${v}`:v,dirs:new Map,files:[]}),p=p.dirs.get(v)}p.files.push(r)}return Sc(s)}function Sc(e){const s=new Map;for(const r of e.dirs.values()){let o=Sc(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 d0=({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(v=>!v),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(di,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(An,{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(wc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},wc=({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(d0,{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",da[p.status]||da.M)}),t.jsx("span",{className:te("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:_c(p.path)})]},p.cardKey)})]}),u0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ae(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=Tn({queryKey:ce.git.log(e),queryFn:({pageParam:u=0})=>Ee.get("/git/log",{params:{workingDir:e,limit:String($i),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<$i?void 0:c.length*$i}),l=p?.pages.flatMap(u=>u.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(ze,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.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:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),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:u.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:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",n0(u.timestamp)]})]})]},u.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,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:i?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},h0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:l}=ae(),[u,c]=b.useState({kind:"overview"}),[g,x]=b.useState(""),[_,w]=b.useState(null),[a,h]=b.useState(null),{data:d,isLoading:f,isError:S}=yi(e),C=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:E}=Zn(e,C),y=b.useRef(new Map),j=b.useRef(null),R=b.useRef(null),L=b.useCallback((B,z)=>{z?y.current.set(B,z):y.current.delete(B)},[]),{uncommitted:T,committed:D,commitFiles:F}=b.useMemo(()=>{const B=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const N={kind:"commit",hash:u.commit.hash},W=(k?.files||[]).filter(B).map(X=>({...X,cardKey:Ur(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const z=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:Ur({kind:"working",diffType:"uncommitted"},N.path)})),U=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:Ur({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:z,committed:U,commitFiles:[]}},[u,d,k,g]),I=u.kind==="commit"?F:[...T,...D],H=b.useMemo(()=>c0(I),[I]),q=b.useMemo(()=>{let B=0,z=0;for(const U of I)B+=U.additions??0,z+=U.deletions??0;return{additions:B,deletions:z,files:I.length}},[I]),A=b.useCallback(()=>{const B=j.current;if(!B)return;const z=B.getBoundingClientRect().top;let U=null,N=Number.NEGATIVE_INFINITY;for(const[W,X]of y.current){const V=X.getBoundingClientRect().top-z;V<=48&&V>N&&(N=V,U=W)}if(!U){let W=null,X=Number.POSITIVE_INFINITY;for(const[V,ie]of y.current){const ee=ie.getBoundingClientRect().top-z;ee<X&&(X=ee,W=V)}U=W}w(U)},[]);b.useEffect(()=>{const B=j.current;if(!B)return;let z=0;const U=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(A)};return B.addEventListener("scroll",U,{passive:!0}),()=>{B.removeEventListener("scroll",U),cancelAnimationFrame(z)}},[A]);const P=b.useCallback(B=>{const z=y.current.get(B.cardKey);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),w(B.cardKey),h(B.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),M=b.useCallback(B=>{c(z=>z.kind==="commit"&&z.commit.hash===B.hash?{kind:"overview"}:{kind:"commit",commit:B}),x(""),w(null),j.current?.scrollTo({top:0})},[]),O=b.useCallback(()=>{c({kind:"overview"}),x(""),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:l("未选择工作区")});const $=m&&s&&r&&o,K=u.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[$&&n&&i&&t.jsx(bc,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Vs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:q.files})}),t.jsx(fn,{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($s,{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:O,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($s,{size:12}),l("全部变更")]}),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:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(fn,{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:K?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(B=>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"})]})]},B))}):S&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Yr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:F.map(B=>t.jsx(qi,{entry:B,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[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:l("未提交")}),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(B=>t.jsx(qi,{entry:B,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))})]}),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:l("已提交")}),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(B=>t.jsx(qi,{entry:B,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.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(Sn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:B=>x(B.target.value),placeholder:l("筛选文件..."),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()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(wc,{node:H,depth:0,activeKey:_,onSelect:P})}),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(Us,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(u0,{workingDir:e,selectedHash:C,onSelectCommit:M})})]})]})]})]})},Ki=50,ua={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 f0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function m0(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):""}const g0=({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})]})},v0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ae(),{data:p,isLoading:m,isError:v}=Jn(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.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 i=n.split(`
73
- `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((l,u)=>t.jsx(g0,{line:l,lineNum:u+1},u))})},x0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ae(),{data:m,isLoading:v}=Zn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(ze,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const n=m?.files||[];return n.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:n.map(i=>{const l=ua[i.status]||ua.M,u=p0(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:te("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.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",l),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:m0(i.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},i.path)})})},b0=({workingDir:e})=>{const{t:s}=ae(),r=Es(E=>E.visibleContext),o=wf(e,r),{data:p,isLoading:m,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:l}=Tn({queryKey:ce.git.log(e||""),queryFn:({pageParam:E=0})=>Ee.get("/git/log",{params:{workingDir:e||"",limit:String(Ki),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,y)=>E.commits.length<Ki?void 0:y.length*Ki,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),u=p?.pages.flatMap(E=>E.commits)||[],[c,g]=b.useState(null),[x,_]=b.useState(null),[w,a]=b.useState(280),[h,d]=b.useState(!1),f=b.useCallback(E=>{E.preventDefault(),d(!0);const y=E.clientX,j=w,R=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-y)));a(D)},L=()=>{d(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",L)},[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(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(v)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(u.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(Us,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=u.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{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(Us,{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:u.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[u.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(Pt,{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:f0(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(x0,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:_})]})]},E.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>n(),disabled:l,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:l?t.jsxs(t.Fragment,{children:[t.jsx(ze,{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",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:x&&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(Yr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:x}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(v0,{workingDir:e,hash:c,filePath:x})]}):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(Yr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},ha=br();function _0(e){if(!ha)return e;try{const s=new URL(ha);return new URL(e,s.origin).toString()}catch{return e}}function Cc(e){return{...e,viewUrl:e.viewUrl?_0(e.viewUrl):null}}function y0(e,s=!0){return jt({queryKey:ce.previews.status(e??""),queryFn:async()=>{const r=await Ee.get(`/previews/${e}/status`);return Cc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function S0(e){const s=bt();return zt({mutationFn:async r=>{const o=await Ee.put(`/previews/${e}/config`,{target:r});return Cc(o)},onSuccess:r=>{e&&(s.setQueryData(ce.previews.status(e),r),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function w0(){return window.location.protocol==="https:"?"remote":"local"}function C0(e,s,r=!0){const[o,p]=b.useState(null),[m,v]=b.useState(!1),[n,i]=b.useState(null),[l,u]=b.useState(0);return b.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),v(!1),i(null);return}let c=!1,g=null,x=null;p(null);const _=a=>{Ee.delete(`/previews/${e}/sessions/${a}`).catch(()=>{})};return(async()=>{v(!0),i(null);try{const a={mode:w0(),localHostname:window.location.hostname},h=await Ee.post(`/previews/${e}/sessions`,a);if(c){_(h.id);return}g=h.id,p(h),x=window.setInterval(async()=>{if(g)try{const d=await Ee.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),i(null))}catch(d){!c&&d instanceof oi&&d.status===404?u(f=>f+1):c||i(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(a){c||(p(null),i(a instanceof Error?a:new Error("Failed to open preview session")))}finally{c||v(!1)}})(),()=>{c=!0,x!==null&&window.clearInterval(x),g&&_(g)}},[r,l,s?.ready,s?.target,e]),{session:o,isOpening:m,error:n,retry:()=>u(c=>c+1)}}const k0="agent-tower-preview",E0="agent-tower-preview-host";function j0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function N0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function R0(e){return t.jsx(A0,{...e},e.workspaceId??"no-workspace")}function A0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=ae(),[m,v]=b.useState(null),i=!(r?.source.kind==="visualization")&&!m,{data:l,isLoading:u,refetch:c,isFetching:g}=y0(e,i),x=S0(e),{session:_,isOpening:w,error:a,retry:h}=C0(e,l,i),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,L]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),T=N0(_?.viewUrl),D=l&&R.target!==l.target?{target:l.target,address:l.target??"",iframeSrc:null,isFrameLoading:!1}:l&&!l.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,F=b.useCallback(K=>{L(B=>({...l&&B.target!==l.target?{target:l.target,address:l.target??"",iframeSrc:null,isFrameLoading:!1}:B,...K}))},[l]);b.useEffect(()=>{if(!_||_.target!==l?.target)return;const K=k.current!==T;k.current=T,L(B=>{const z=r?.source.kind==="web"&&E.current!==r.id?Ir(r.source.url,_.target,_.viewUrl):null;if(!K&&B.iframeSrc&&B.target===_.target&&z?.kind!=="proxy")return B;let U=B.iframeSrc;if(z?.kind==="proxy")U=z.url;else if(!U||B.target!==_.target||K){const W=S.current;if(W)U=Dd(_.viewUrl,W);else{const X=Ir(B.address||_.target,_.target,_.viewUrl);U=X?.kind==="proxy"?X.url:_.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&U&&N.location.replace(U),C.current=null,{target:_.target,address:z?.kind==="proxy"?r?.source.kind==="web"?r.source.url:B.address:B.address||_.target,iframeSrc:U,isFrameLoading:!!U}})},[r,_,T,l?.target]),b.useEffect(()=>()=>{C.current?.close()},[]);const I=b.useCallback(async(K,B=!1)=>{const z=Ir(K,l?.target??null,_?.viewUrl??null);if(!z||!e)return;if(v(null),z.kind==="proxy"){if(B){window.open(z.url,"_blank","noopener,noreferrer");return}L({target:l?.target??null,address:K,iframeSrc:z.url,isFrameLoading:!0});return}if(s)return;const U=B?window.open("about:blank","_blank"):null;U&&(U.opener=null);try{S.current=z.path,C.current=U;const N=await x.mutateAsync(z.target);L({target:N.target,address:K.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(W=>W+1),st.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 W=N instanceof Error?N.message:p("Failed to save preview target");st.error(W)}},[_?.viewUrl,s,l?.target,p,x,e]);b.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&u)return;const K=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(v({source:r.source,iframeSrc:Pd(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(B=>B+1)):(v(null),I(r.source.url))},0);return()=>window.clearTimeout(K)},[u,I,r,o]),b.useEffect(()=>{if(m)return;const K=B=>{if(B.source!==d.current?.contentWindow)return;const z=B.data;if(!(!z||z.source!==k0)){if(z.type==="location"&&typeof z.href=="string"){const U=Ld(l?.target??null,_?.viewUrl??null,z.href,window.location.href);U&&document.activeElement!==f.current&&F({target:l?.target??D.target,address:U,isFrameLoading:!1});return}z.type==="navigate-loopback"&&typeof z.href=="string"&&I(z.href,z.newTab===!0)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[D.target,I,F,_?.viewUrl,l?.target,m]);const H=K=>{d.current?.contentWindow?.postMessage({source:E0,action:K},"*")},q=K=>{K.preventDefault(),I(D.address)},A=async()=>{if(m){v(B=>B&&{...B,isFrameLoading:!0}),j(B=>B+1);return}const K=await c();if(!K.data?.ready){F({target:K.data?.target??D.target,iframeSrc:null,isFrameLoading:!1});return}if(!_||!D.iframeSrc){h();return}F({isFrameLoading:!0}),H("reload")},P=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!_?.viewUrl)return;const K=Ir(D.address||_.target,_.target,_.viewUrl),B=K?.kind==="proxy"?K.url:_.viewUrl;window.open(B,"_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??D.iframeSrc,O=!!m,$=!O&&(u||g||x.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(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{O?v(null):H("back")},disabled:!O&&!D.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx($s,{})}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>H("forward"),disabled:O||!D.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(sl,{})}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:!O&&D.isFrameLoading?()=>{H("stop"),F({isFrameLoading:!1})}:A,disabled:!O&&!D.isFrameLoading&&g,title:!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!O&&D.isFrameLoading?t.jsx(qt,{}):g?t.jsx(ze,{className:"animate-spin"}):t.jsx(Ns,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:q,children:[t.jsx(lu,{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??D.address,onChange:K=>F({address:K.target.value}),onKeyDown:K=>{K.key==="Enter"&&K.nativeEvent.isComposing&&K.preventDefault()},disabled:O||s||x.isPending,placeholder:j0(),"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(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:P,disabled:!M,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(gn,{})})]}),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:O?p("Viewing agent visualization"):$?p("Checking preview target..."):a?a.message:l?.ready?`${p("Proxying")} ${l.target}`:l?.configured?`${p("Preview target is not reachable")}${l.error?`: ${l.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(O?"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:O?"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:()=>{O?v(K=>K&&{...K,isFrameLoading:!1}):F({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:l?.configured?l.ready&&w?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function T0(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function fa(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 M0(e){return e.length<=34?e:`...${e.slice(-31)}`}function kc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:n}=ae(),[i,l]=b.useState(!1),u=b.useRef(null),c=b.useMemo(()=>Kn(e,s),[e,s]),g=c.find(x=>x.workspace.id===r)??c[0];return b.useEffect(()=>{if(!i)return;const x=_=>{u.current&&!u.current.contains(_.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:u,className:te("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),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",v),title:n("Workspace"),children:[t.jsx(Hs,{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",fa(g.roleLabel)),children:n(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:M0(qs(g.workspace))}),t.jsx(wt,{size:13,className:te("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&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(x=>{const _=x.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!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(Kt,{size:13}):t.jsx(Ka,{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:n(x.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",fa(x.roleLabel)),children:n(x.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",T0(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:qs(x.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:[x.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const D0=[{key:"review",label:"Changes",icon:t.jsx(Vs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ci,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(lr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(qa,{size:14})}],P0=[{key:"history",label:"History",icon:t.jsx(Us,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ci,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(lr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(qa,{size:14})}],L0=({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})]}),I0=({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}),Ec=le.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:l,teamRun:u,teamStatus:c,gitProps:g,workspaces:x,selectedWorkspaceId:_,onSelectWorkspace:w,variant:a="tabs",expanded:h,onExpandedChange:d,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=ae(),y=Es(G=>G.setVisibleContext),j=a==="rail",[R,L]=b.useState(!1),T=j?h??R:!0,D=b.useCallback(G=>{h===void 0&&L(G),d?.(G)},[h,d]),F=b.useMemo(()=>{const G=v?P0:D0,pe=n?G:G.filter(We=>We.key!=="review"&&We.key!=="history"),oe=i?pe.filter(We=>We.key!=="terminal"):pe;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(Cs,{size:14})},...oe]:oe},[n,v,i,u]),[I,H]=b.useState(()=>C?"preview":n?v?"history":"review":"editor"),q=b.useRef(null),A=b.useRef(0),[P,M]=b.useState(),O=b.useCallback(G=>{H(G),j&&D(!0)},[j,D]);b.useImperativeHandle(S,()=>({setTab:G=>O(G),openFile:(G,pe,oe)=>{O("editor"),requestAnimationFrame(()=>q.current?.openFile(G,pe,oe))},openPreview:(G,pe)=>{A.current+=1,M({id:A.current,source:G,workspaceId:pe}),O("preview")}}),[O]);const $=C??P,K=$?.workspaceId&&$.workspaceId!==o?void 0:$,B=b.useCallback(G=>{M(pe=>pe?.id===G?void 0:pe),k?.(G)},[k]),{data:z}=Kd(m??""),U=b.useMemo(()=>{if(!z?.quickCommands)return[];try{return JSON.parse(z.quickCommands)}catch{return[]}},[z?.quickCommands]),[N,W]=b.useState([]),X=b.useRef(void 0);b.useEffect(()=>{p&&p!==X.current&&(X.current=p,W(G=>G.includes(p)?G:[...G,p]))},[p]),b.useEffect(()=>{F.some(G=>G.key===I)||H(F[0]?.key??"editor")},[I,F]),b.useEffect(()=>{if(j&&!T)return;const G=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!G){y(null);return}return y({workspaceId:o,workingDir:p,tab:G}),()=>{y(null)}},[I,T,j,y,p,o]);const V=!!w&&Kn(x,u).length>1,ie=F.find(G=>G.key===I)??F[0],ee=ie?E(ie.label):"",me=i?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(l?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,he=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[V&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(kc,{workspaces:x,teamRun:u,selectedWorkspaceId:_,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&u&&c,I==="editor"&&t.jsx(t0,{ref:q,workingDir:p,readOnly:i}),N.map(G=>{const pe=I==="terminal"&&p===G;return t.jsx("div",{"aria-hidden":!pe,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:pe?"block":"none"},children:t.jsx(fp,{cwd:G,workspaceId:pe?o:void 0,isVisible:pe,quickCommands:U})},G)}),I==="preview"&&t.jsx(R0,{workspaceId:o,readOnly:i,navigationRequest:K,onNavigationRequestHandled:B}),I==="review"&&t.jsx(h0,{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(b0,{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:F.map(G=>t.jsx(I0,{active:T&&I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[me,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:ie?.icon}),t.jsx("span",{className:"truncate",children:ee})]}),t.jsx("button",{type:"button",onClick:()=>D(!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(ku,{size:15})})]}),he]})]}):t.jsxs("div",{className:te("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&me,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:F.map(G=>t.jsx(L0,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),he]})}),ma=1500,O0=3e3;function B0(e){const[s,r]=b.useState(null),o=b.useRef(0),p=b.useRef(null),m=b.useRef(null);return b.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},n=os.connect(),i=u=>{r(u),m.current=setTimeout(()=>r(null),O0)},l=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),p.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const g=o.current>0?Date.now()-o.current:0,x=ma-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>i(c),ma)):x>0?(p.current=c,v(),m.current=setTimeout(()=>i(c),x)):i(c)};return n.on(lt.WORKSPACE_SETUP_PROGRESS,l),()=>{n.off(lt.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,p.current=null}},[e]),s}function jc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:l=!0,projectGitReason:u}){const{t:c}=ae(),[g,x]=b.useState(""),[_,w]=b.useState(""),[a,h]=b.useState(_t.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,E]=b.useState(null),y=bt(),j=Nl(o),R=kn(),L=Vd(),{data:T,isLoading:D}=Ks(),F=d?.isGitRepo??i,I=d?.worktreeReady??l,H=d?.reason??u,q=F!==!1&&I!==!1;b.useEffect(()=>{if(!e||!T)return;const N=T.find(W=>W.availability.type!=="NOT_FOUND");N&&x(N.provider.id)},[e,T]),b.useEffect(()=>{if(e){const N=[m];v&&N.push(v),w(n?.trim()||N.join(`
71
+ `,aa={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Dv(Pv);var Lv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,u=e.contentProps,c=u===void 0?{}:u,g=b.useContext(yi),x=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),a=b.useRef(null);return b.useEffect(function(){var h=w.current,d=a.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){_?.()}},[]),le.createElement("div",hs({},l,{ref:w,className:"".concat(un.wrapperClass," ").concat(aa.wrapper," ").concat(o),style:v}),le.createElement("div",hs({},c,{ref:a,className:"".concat(un.contentClass," ").concat(aa.content," ").concat(m),style:n}),s))},fc=function(){var e=b.useContext(yi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Iv=function(){var e=fc();return ii(e)};function Ov(e){var s=fc(),r=b.useState(e(hn(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,v=s.onChange(function(n){m&&p(e(hn(n.instance)))});return function(){v(),m=!1}},[e,s]),o}function Bv(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 Fv(e,s){return jt({queryKey:ce.files.tree(e||"",s),queryFn:()=>Ee.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function zv(e,s){return jt({queryKey:ce.files.content(e||"",s||""),queryFn:()=>Ee.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function Wv(e){const s=bt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Hv(){const e=bt();return zt({mutationFn:s=>Ee.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||Bv(r.path)})}})}function $v(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function Uv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const qv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Kv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&qv.has(s)?Fa:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Gr:s==="json"?hu:s==="md"||s==="mdx"||s==="txt"?Ba:Ud}const la=({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})]}),mc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:n}=ae(),{data:i,isLoading:l,isError:u}=Fv(e,s),c=b.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=$v(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(la,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Pt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(ui,{size:14,className:"text-amber-500"}):t.jsx(Tn,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(mc,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const x=Uv(s,g.name),_=Kv(g),w=v===x,a=_===Fa;return t.jsx(la,{depth:r,active:w,onClick:()=>m(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},x)})})},Vv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ae(),[v,n]=b.useState(()=>new Set),i=Wv(e),l=b.useCallback(u=>{n(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),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:i,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(Ns,{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(Su,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(mc,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},Xv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Yv(e){const s=e.split(".").pop()?.toLowerCase();return s?Xv.has(s):!1}function Gv(e,s){const r=br(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Qv=({filePath:e})=>{const{t:s}=ae(),{zoomIn:r,zoomOut:o,centerView:p}=Iv(),m=Ov(n=>n.state.scale),v=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(Ou,{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:[v,"%"]}),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(Lu,{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(_u,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Zv=({workingDir:e,filePath:s})=>{const{t:r}=ae(),[o,p]=b.useState(!1),m=Gv(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(Mv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Qv,{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(Lv,{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 Jv(e){const s=e.split("/");return s[s.length-1]||e}function e0(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 t0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ae();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(qt,{size:12})})]})},s0=le.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=ae(),[v,n]=b.useState([]),[i,l]=b.useState(null),[u,c]=b.useState(!1),[g,x]=b.useState(!1),[_,w]=b.useState(0),[a,h]=b.useState(null),d=b.useRef(null),f=Hv();b.useEffect(()=>{let B=!1;return xd(async()=>{const{preloadMonaco:z}=await import("./monaco-B4gWh5LA.js").then(U=>U.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{B||c(!0)}).catch(()=>{B||x(!0)}),()=>{B=!0}},[]);const[S,C]=b.useState(280),[k,E]=b.useState(!1),[y,j]=b.useState(!1),R=b.useRef(280),L=b.useCallback(()=>{E(B=>(B?C(R.current):R.current=S,!B))},[S]),T=b.useCallback(B=>{B.preventDefault(),j(!0);const z=B.clientX,U=S,N=X=>{const V=X.clientX-z,ie=Math.min(480,Math.max(160,U+V));C(ie)},W=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",W)},[S]);b.useEffect(()=>{n([]),l(null),h(null)},[s]);const D=b.useMemo(()=>v.find(B=>B.path===i)||null,[v,i]),{data:F,isFetching:I,isError:H,error:q}=zv(s,D?.isImage?null:i);b.useEffect(()=>{!i||!F||n(B=>B.map(z=>z.path!==i||z.isDirty||z.loaded?z:{...z,language:F.language||z.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[i,F]);const A=b.useCallback((B,z,U)=>{n(N=>{if(N.find(V=>V.path===B))return N;const X=Yv(B);return[...N,{path:B,name:Jv(B),language:e0(B),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(B),h(z?{path:B,line:z,column:U}:null)},[]);le.useImperativeHandle(p,()=>({openFile:A}),[A]);const P=b.useCallback(B=>{n(z=>{const U=z.filter(N=>N.path!==B);return l(N=>N!==B?N:U.length?U[U.length-1].path:null),U})},[]),M=b.useCallback(B=>{n(z=>z.map(U=>{if(U.path!==i)return U;const N=B!==U.savedContent;return{...U,content:B,isDirty:N}}))},[i]),O=b.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(B=>B.map(z=>z.path===D.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[D,o,f,s]),$=b.useRef(()=>{});b.useEffect(()=>{$.current=()=>{O().catch(()=>{})}},[O]),b.useEffect(()=>{const B=z=>{o||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),$.current())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[o]);const K=b.useCallback((B,z)=>{d.current=B,w(U=>U+1),B.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{$.current()})},[]);return b.useEffect(()=>{if(!a||a.path!==i||!D?.loaded)return;const B=d.current,z=B?.getModel();if(!B||!z)return;const U=Math.min(a.line,z.getLineCount()),N=Math.min(a.column??1,z.getLineMaxColumn(U)),W={lineNumber:U,column:N};B.setPosition(W),B.revealPositionInCenter(W),B.focus(),h(null)},[i,D?.loaded,_,a]),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:L,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(Cu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(Vv,{workingDir:s,onFileSelect:A,selectedFilePath:D?.path||null,onCollapse:L},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,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:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):v.map(B=>t.jsx(t0,{active:B.path===i,name:B.name,isDirty:B.isDirty,onClick:()=>l(B.path),onClose:z=>{z.stopPropagation(),P(B.path)}},B.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(ze,{size:14,className:"animate-spin"}),m("Saving")]}),D?.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?D?D.isImage?t.jsx(Zv,{workingDir:s,filePath:D.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):u?t.jsxs(t.Fragment,{children:[t.jsx(wg,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:B=>M(B??""),onMount:K,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.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(ze,{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(ze,{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 Si(e,s={}){const r=Es(p=>p.visibleContext),o=Nl(e,r);return jt({queryKey:ce.git.changes(e||""),queryFn:()=>Ee.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function pc(e,s,r){const o=Es(m=>m.visibleContext),p=Nl(e,o);return jt({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>Ee.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 Jn(e,s){return jt({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>Ee.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function eo(e,s,r){return jt({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ee.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const r0=new Set(["STARTING","RUNNING","STOPPING"]);function gc(e){return r0.has(e.runtimeState)||e.runtimeInstanceId!==null}function vc(e){return e instanceof ai&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function i0({services:e,isLoading:s,isError:r}){const{t:o}=ae();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(ze,{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(js,{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 xc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:v,isCheckingServices:n,serviceCheckFailed:i,error:l,onConfirm:u}){const{t:c}=ae(),[g,x]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),x(p??""))},[e]),b.useEffect(()=>{_||!e||x(p??"")},[p,_,e]);const a=()=>{m||s()};return t.jsx(fs,{isOpen:e,onClose:a,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:a,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:()=>u(g.trim()||void 0,v.length>0),disabled:m||n,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||n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"}),n?c("正在检查后台服务..."):v.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Yr,{size:14}),v.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(rl,{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:h=>{w(!0),x(h.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(i0,{services:v,isLoading:n,isError:i}),l&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:l})]})})}function Ls(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function bc(e){if(!(e instanceof ai)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==fr.REBASE&&s.conflictOp!==fr.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:Ls(s,"sourceBranch"),targetBranch:Ls(s,"targetBranch"),sourceWorktreePath:Ls(s,"sourceWorktreePath"),targetWorktreePath:Ls(s,"targetWorktreePath"),sourceWorkspaceId:Ls(s,"sourceWorkspaceId"),targetWorkspaceId:Ls(s,"targetWorkspaceId")}}function ca(e,s,r,o){const p=bc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function _c({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:n}){const{t:i}=ae(),{data:l,isLoading:u}=$n(e),c=Tl(),g=Al(),x=Un(),[_,w]=b.useState(!1),[a,h]=b.useState(null),d=Yn(e,_),f=(d.data??[]).filter(gc);if(b.useEffect(()=>{_&&m?.()},[_,m]),u||!l)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(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const S=l.conflictedFiles.length>0,C=l.operation!=="idle",k=l.hasUncommittedChanges||l.untrackedCount>0,E=l.uncommittedCount+l.untrackedCount,y=!S&&!C&&!k,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!k&&!S,R=()=>{h(null),c.mutate(e,{onError:F=>{ca(F,i("更新失败,请稍后重试"),I=>v(I),h)}})},L=()=>{h(null),w(!0)},T=(F,I)=>{h(null),g.mutate({id:e,commitMessage:F,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(vc(H)){h(i("后台服务仍在运行,请确认停止服务后再提交。"));return}ca(H,i("提交失败,请稍后重试"),q=>{w(!1),v(q)},h)}})},D=()=>{g.isPending||(w(!1),h(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(bd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):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:[a&&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:a}),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(pu,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{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(js,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,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:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.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:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),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(ze,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.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(_d,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!S&&!C&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.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(Ns,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!k?t.jsxs("button",{onClick:L,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(Yr,{size:12}),i("提交变更")]}):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:i(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Yr,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(xc,{isOpen:_,onClose:D,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:a,onConfirm:T})]})}const Ui=50,qi=400,da={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"},ua={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function yc(e){const s=e.split("/");return s[s.length-1]||e}function n0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function o0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Ur(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const mn=({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"})]}),a0=({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})]})},Sc=({diff:e})=>{const{t:s}=ae(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
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>qi,v=m?p.slice(0,qi):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(a0,{line:n,lineNum:i+1},i)),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-qi})})]})},l0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=pc(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Sc,{diff:m?.diff||""})},c0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=eo(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Sc,{diff:m?.diff||""})},Ki=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,v]=b.useState(!1),[n,i]=b.useState(!1),l=b.useRef(null),u=Ur(s,e.path);b.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),b.useEffect(()=>{const x=l.current;if(!x||n)return;const _=new IntersectionObserver(w=>{w.some(a=>a.isIntersecting)&&(i(!0),_.disconnect())},{rootMargin:"300px 0px"});return _.observe(x),()=>_.disconnect()},[n]);const c=da[e.status]||da.M,g=n0(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,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:()=>v(x=>!x),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(Pt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(wt,{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:yc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(mn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(l0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(c0,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function d0(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 v=o[m];p.dirs.has(v)||p.dirs.set(v,{name:v,path:p.path?`${p.path}/${v}`:v,dirs:new Map,files:[]}),p=p.dirs.get(v)}p.files.push(r)}return wc(s)}function wc(e){const s=new Map;for(const r of e.dirs.values()){let o=wc(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 u0=({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(v=>!v),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(ui,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Tn,{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(Cc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Cc=({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(u0,{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",ua[p.status]||ua.M)}),t.jsx("span",{className:te("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:yc(p.path)})]},p.cardKey)})]}),h0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ae(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=Mn({queryKey:ce.git.log(e),queryFn:({pageParam:u=0})=>Ee.get("/git/log",{params:{workingDir:e,limit:String(Ui),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Ui?void 0:c.length*Ui}),l=p?.pages.flatMap(u=>u.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(ze,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.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:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),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:u.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:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",o0(u.timestamp)]})]})]},u.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,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:i?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},f0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:l}=ae(),[u,c]=b.useState({kind:"overview"}),[g,x]=b.useState(""),[_,w]=b.useState(null),[a,h]=b.useState(null),{data:d,isLoading:f,isError:S}=Si(e),C=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:E}=Jn(e,C),y=b.useRef(new Map),j=b.useRef(null),R=b.useRef(null),L=b.useCallback((B,z)=>{z?y.current.set(B,z):y.current.delete(B)},[]),{uncommitted:T,committed:D,commitFiles:F}=b.useMemo(()=>{const B=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const N={kind:"commit",hash:u.commit.hash},W=(k?.files||[]).filter(B).map(X=>({...X,cardKey:Ur(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const z=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:Ur({kind:"working",diffType:"uncommitted"},N.path)})),U=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:Ur({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:z,committed:U,commitFiles:[]}},[u,d,k,g]),I=u.kind==="commit"?F:[...T,...D],H=b.useMemo(()=>d0(I),[I]),q=b.useMemo(()=>{let B=0,z=0;for(const U of I)B+=U.additions??0,z+=U.deletions??0;return{additions:B,deletions:z,files:I.length}},[I]),A=b.useCallback(()=>{const B=j.current;if(!B)return;const z=B.getBoundingClientRect().top;let U=null,N=Number.NEGATIVE_INFINITY;for(const[W,X]of y.current){const V=X.getBoundingClientRect().top-z;V<=48&&V>N&&(N=V,U=W)}if(!U){let W=null,X=Number.POSITIVE_INFINITY;for(const[V,ie]of y.current){const ee=ie.getBoundingClientRect().top-z;ee<X&&(X=ee,W=V)}U=W}w(U)},[]);b.useEffect(()=>{const B=j.current;if(!B)return;let z=0;const U=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(A)};return B.addEventListener("scroll",U,{passive:!0}),()=>{B.removeEventListener("scroll",U),cancelAnimationFrame(z)}},[A]);const P=b.useCallback(B=>{const z=y.current.get(B.cardKey);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),w(B.cardKey),h(B.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),M=b.useCallback(B=>{c(z=>z.kind==="commit"&&z.commit.hash===B.hash?{kind:"overview"}:{kind:"commit",commit:B}),x(""),w(null),j.current?.scrollTo({top:0})},[]),O=b.useCallback(()=>{c({kind:"overview"}),x(""),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:l("未选择工作区")});const $=m&&s&&r&&o,K=u.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[$&&n&&i&&t.jsx(_c,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Vs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:q.files})}),t.jsx(mn,{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(Hs,{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:O,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(Hs,{size:12}),l("全部变更")]}),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:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(mn,{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:K?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(B=>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"})]})]},B))}):S&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Gr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:F.map(B=>t.jsx(Ki,{entry:B,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[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:l("未提交")}),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(B=>t.jsx(Ki,{entry:B,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))})]}),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:l("已提交")}),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(B=>t.jsx(Ki,{entry:B,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.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(wn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:B=>x(B.target.value),placeholder:l("筛选文件..."),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()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(Cc,{node:H,depth:0,activeKey:_,onSelect:P})}),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(Us,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(h0,{workingDir:e,selectedHash:C,onSelectCommit:M})})]})]})]})]})},Vi=50,ha={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 m0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function p0(e){const s=e.split("/");return s[s.length-1]||e}function g0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const 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})]})},x0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ae(),{data:p,isLoading:m,isError:v}=eo(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.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 i=n.split(`
73
+ `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((l,u)=>t.jsx(v0,{line:l,lineNum:u+1},u))})},b0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ae(),{data:m,isLoading:v}=Jn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(ze,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const n=m?.files||[];return n.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:n.map(i=>{const l=ha[i.status]||ha.M,u=g0(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:te("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.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",l),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:p0(i.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},i.path)})})},_0=({workingDir:e})=>{const{t:s}=ae(),r=Es(E=>E.visibleContext),o=Cf(e,r),{data:p,isLoading:m,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:l}=Mn({queryKey:ce.git.log(e||""),queryFn:({pageParam:E=0})=>Ee.get("/git/log",{params:{workingDir:e||"",limit:String(Vi),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,y)=>E.commits.length<Vi?void 0:y.length*Vi,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),u=p?.pages.flatMap(E=>E.commits)||[],[c,g]=b.useState(null),[x,_]=b.useState(null),[w,a]=b.useState(280),[h,d]=b.useState(!1),f=b.useCallback(E=>{E.preventDefault(),d(!0);const y=E.clientX,j=w,R=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-y)));a(D)},L=()=>{d(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",L)},[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(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(v)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(u.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(Us,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=u.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{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(Us,{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:u.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[u.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(Pt,{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:m0(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(b0,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:_})]})]},E.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>n(),disabled:l,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:l?t.jsxs(t.Fragment,{children:[t.jsx(ze,{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",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:x&&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(Gr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:x}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(x0,{workingDir:e,hash:c,filePath:x})]}):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(Gr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},fa=br();function y0(e){if(!fa)return e;try{const s=new URL(fa);return new URL(e,s.origin).toString()}catch{return e}}function kc(e){return{...e,viewUrl:e.viewUrl?y0(e.viewUrl):null}}function S0(e,s=!0){return jt({queryKey:ce.previews.status(e??""),queryFn:async()=>{const r=await Ee.get(`/previews/${e}/status`);return kc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function w0(e){const s=bt();return zt({mutationFn:async r=>{const o=await Ee.put(`/previews/${e}/config`,{target:r});return kc(o)},onSuccess:r=>{e&&(s.setQueryData(ce.previews.status(e),r),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function C0(){return window.location.protocol==="https:"?"remote":"local"}function k0(e,s,r=!0){const[o,p]=b.useState(null),[m,v]=b.useState(!1),[n,i]=b.useState(null),[l,u]=b.useState(0);return b.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),v(!1),i(null);return}let c=!1,g=null,x=null;p(null);const _=a=>{Ee.delete(`/previews/${e}/sessions/${a}`).catch(()=>{})};return(async()=>{v(!0),i(null);try{const a={mode:C0(),localHostname:window.location.hostname},h=await Ee.post(`/previews/${e}/sessions`,a);if(c){_(h.id);return}g=h.id,p(h),x=window.setInterval(async()=>{if(g)try{const d=await Ee.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),i(null))}catch(d){!c&&d instanceof ai&&d.status===404?u(f=>f+1):c||i(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(a){c||(p(null),i(a instanceof Error?a:new Error("Failed to open preview session")))}finally{c||v(!1)}})(),()=>{c=!0,x!==null&&window.clearInterval(x),g&&_(g)}},[r,l,s?.ready,s?.target,e]),{session:o,isOpening:m,error:n,retry:()=>u(c=>c+1)}}const E0="agent-tower-preview",j0="agent-tower-preview-host";function N0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function R0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function A0(e){return t.jsx(T0,{...e},e.workspaceId??"no-workspace")}function T0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=ae(),[m,v]=b.useState(null),i=!(r?.source.kind==="visualization")&&!m,{data:l,isLoading:u,refetch:c,isFetching:g}=S0(e,i),x=w0(e),{session:_,isOpening:w,error:a,retry:h}=k0(e,l,i),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,L]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),T=R0(_?.viewUrl),D=l&&R.target!==l.target?{target:l.target,address:l.target??"",iframeSrc:null,isFrameLoading:!1}:l&&!l.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,F=b.useCallback(K=>{L(B=>({...l&&B.target!==l.target?{target:l.target,address:l.target??"",iframeSrc:null,isFrameLoading:!1}:B,...K}))},[l]);b.useEffect(()=>{if(!_||_.target!==l?.target)return;const K=k.current!==T;k.current=T,L(B=>{const z=r?.source.kind==="web"&&E.current!==r.id?Ir(r.source.url,_.target,_.viewUrl):null;if(!K&&B.iframeSrc&&B.target===_.target&&z?.kind!=="proxy")return B;let U=B.iframeSrc;if(z?.kind==="proxy")U=z.url;else if(!U||B.target!==_.target||K){const W=S.current;if(W)U=Pd(_.viewUrl,W);else{const X=Ir(B.address||_.target,_.target,_.viewUrl);U=X?.kind==="proxy"?X.url:_.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&U&&N.location.replace(U),C.current=null,{target:_.target,address:z?.kind==="proxy"?r?.source.kind==="web"?r.source.url:B.address:B.address||_.target,iframeSrc:U,isFrameLoading:!!U}})},[r,_,T,l?.target]),b.useEffect(()=>()=>{C.current?.close()},[]);const I=b.useCallback(async(K,B=!1)=>{const z=Ir(K,l?.target??null,_?.viewUrl??null);if(!z||!e)return;if(v(null),z.kind==="proxy"){if(B){window.open(z.url,"_blank","noopener,noreferrer");return}L({target:l?.target??null,address:K,iframeSrc:z.url,isFrameLoading:!0});return}if(s)return;const U=B?window.open("about:blank","_blank"):null;U&&(U.opener=null);try{S.current=z.path,C.current=U;const N=await x.mutateAsync(z.target);L({target:N.target,address:K.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(W=>W+1),st.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 W=N instanceof Error?N.message:p("Failed to save preview target");st.error(W)}},[_?.viewUrl,s,l?.target,p,x,e]);b.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&u)return;const K=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(v({source:r.source,iframeSrc:Ld(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(B=>B+1)):(v(null),I(r.source.url))},0);return()=>window.clearTimeout(K)},[u,I,r,o]),b.useEffect(()=>{if(m)return;const K=B=>{if(B.source!==d.current?.contentWindow)return;const z=B.data;if(!(!z||z.source!==E0)){if(z.type==="location"&&typeof z.href=="string"){const U=Id(l?.target??null,_?.viewUrl??null,z.href,window.location.href);U&&document.activeElement!==f.current&&F({target:l?.target??D.target,address:U,isFrameLoading:!1});return}z.type==="navigate-loopback"&&typeof z.href=="string"&&I(z.href,z.newTab===!0)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[D.target,I,F,_?.viewUrl,l?.target,m]);const H=K=>{d.current?.contentWindow?.postMessage({source:j0,action:K},"*")},q=K=>{K.preventDefault(),I(D.address)},A=async()=>{if(m){v(B=>B&&{...B,isFrameLoading:!0}),j(B=>B+1);return}const K=await c();if(!K.data?.ready){F({target:K.data?.target??D.target,iframeSrc:null,isFrameLoading:!1});return}if(!_||!D.iframeSrc){h();return}F({isFrameLoading:!0}),H("reload")},P=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!_?.viewUrl)return;const K=Ir(D.address||_.target,_.target,_.viewUrl),B=K?.kind==="proxy"?K.url:_.viewUrl;window.open(B,"_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??D.iframeSrc,O=!!m,$=!O&&(u||g||x.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(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{O?v(null):H("back")},disabled:!O&&!D.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx(Hs,{})}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>H("forward"),disabled:O||!D.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(rl,{})}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:!O&&D.isFrameLoading?()=>{H("stop"),F({isFrameLoading:!1})}:A,disabled:!O&&!D.isFrameLoading&&g,title:!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!O&&D.isFrameLoading?t.jsx(qt,{}):g?t.jsx(ze,{className:"animate-spin"}):t.jsx(Ns,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:q,children:[t.jsx(cu,{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??D.address,onChange:K=>F({address:K.target.value}),onKeyDown:K=>{K.key==="Enter"&&K.nativeEvent.isComposing&&K.preventDefault()},disabled:O||s||x.isPending,placeholder:N0(),"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(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:P,disabled:!M,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(vn,{})})]}),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:O?p("Viewing agent visualization"):$?p("Checking preview target..."):a?a.message:l?.ready?`${p("Proxying")} ${l.target}`:l?.configured?`${p("Preview target is not reachable")}${l.error?`: ${l.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(O?"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:O?"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:()=>{O?v(K=>K&&{...K,isFrameLoading:!1}):F({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:l?.configured?l.ready&&w?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function M0(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ma(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 D0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Ec({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:n}=ae(),[i,l]=b.useState(!1),u=b.useRef(null),c=b.useMemo(()=>Vn(e,s),[e,s]),g=c.find(x=>x.workspace.id===r)??c[0];return b.useEffect(()=>{if(!i)return;const x=_=>{u.current&&!u.current.contains(_.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:u,className:te("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),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",v),title:n("Workspace"),children:[t.jsx($s,{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",ma(g.roleLabel)),children:n(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:D0(qs(g.workspace))}),t.jsx(wt,{size:13,className:te("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&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(x=>{const _=x.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!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(Kt,{size:13}):t.jsx(Va,{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:n(x.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ma(x.roleLabel)),children:n(x.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",M0(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:qs(x.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:[x.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const P0=[{key:"review",label:"Changes",icon:t.jsx(Vs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(di,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(lr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ka,{size:14})}],L0=[{key:"history",label:"History",icon:t.jsx(Us,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(di,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(lr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ka,{size:14})}],I0=({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})]}),O0=({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}),jc=le.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:l,teamRun:u,teamStatus:c,gitProps:g,workspaces:x,selectedWorkspaceId:_,onSelectWorkspace:w,variant:a="tabs",expanded:h,onExpandedChange:d,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=ae(),y=Es(G=>G.setVisibleContext),j=a==="rail",[R,L]=b.useState(!1),T=j?h??R:!0,D=b.useCallback(G=>{h===void 0&&L(G),d?.(G)},[h,d]),F=b.useMemo(()=>{const G=v?L0:P0,pe=n?G:G.filter(We=>We.key!=="review"&&We.key!=="history"),oe=i?pe.filter(We=>We.key!=="terminal"):pe;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(Cs,{size:14})},...oe]:oe},[n,v,i,u]),[I,H]=b.useState(()=>C?"preview":n?v?"history":"review":"editor"),q=b.useRef(null),A=b.useRef(0),[P,M]=b.useState(),O=b.useCallback(G=>{H(G),j&&D(!0)},[j,D]);b.useImperativeHandle(S,()=>({setTab:G=>O(G),openFile:(G,pe,oe)=>{O("editor"),requestAnimationFrame(()=>q.current?.openFile(G,pe,oe))},openPreview:(G,pe)=>{A.current+=1,M({id:A.current,source:G,workspaceId:pe}),O("preview")}}),[O]);const $=C??P,K=$?.workspaceId&&$.workspaceId!==o?void 0:$,B=b.useCallback(G=>{M(pe=>pe?.id===G?void 0:pe),k?.(G)},[k]),{data:z}=Vd(m??""),U=b.useMemo(()=>{if(!z?.quickCommands)return[];try{return JSON.parse(z.quickCommands)}catch{return[]}},[z?.quickCommands]),[N,W]=b.useState([]),X=b.useRef(void 0);b.useEffect(()=>{p&&p!==X.current&&(X.current=p,W(G=>G.includes(p)?G:[...G,p]))},[p]),b.useEffect(()=>{F.some(G=>G.key===I)||H(F[0]?.key??"editor")},[I,F]),b.useEffect(()=>{if(j&&!T)return;const G=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!G){y(null);return}return y({workspaceId:o,workingDir:p,tab:G}),()=>{y(null)}},[I,T,j,y,p,o]);const V=!!w&&Vn(x,u).length>1,ie=F.find(G=>G.key===I)??F[0],ee=ie?E(ie.label):"",me=i?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(l?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,he=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[V&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Ec,{workspaces:x,teamRun:u,selectedWorkspaceId:_,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&u&&c,I==="editor"&&t.jsx(s0,{ref:q,workingDir:p,readOnly:i}),N.map(G=>{const pe=I==="terminal"&&p===G;return t.jsx("div",{"aria-hidden":!pe,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:pe?"block":"none"},children:t.jsx(mp,{cwd:G,workspaceId:pe?o:void 0,isVisible:pe,quickCommands:U})},G)}),I==="preview"&&t.jsx(A0,{workspaceId:o,readOnly:i,navigationRequest:K,onNavigationRequestHandled:B}),I==="review"&&t.jsx(f0,{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(_0,{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:F.map(G=>t.jsx(O0,{active:T&&I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[me,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:ie?.icon}),t.jsx("span",{className:"truncate",children:ee})]}),t.jsx("button",{type:"button",onClick:()=>D(!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(Eu,{size:15})})]}),he]})]}):t.jsxs("div",{className:te("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&me,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:F.map(G=>t.jsx(I0,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),he]})}),pa=1500,B0=3e3;function F0(e){const[s,r]=b.useState(null),o=b.useRef(0),p=b.useRef(null),m=b.useRef(null);return b.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},n=os.connect(),i=u=>{r(u),m.current=setTimeout(()=>r(null),B0)},l=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),p.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const g=o.current>0?Date.now()-o.current:0,x=pa-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>i(c),pa)):x>0?(p.current=c,v(),m.current=setTimeout(()=>i(c),x)):i(c)};return n.on(lt.WORKSPACE_SETUP_PROGRESS,l),()=>{n.off(lt.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,p.current=null}},[e]),s}function Nc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:l=!0,projectGitReason:u}){const{t:c}=ae(),[g,x]=b.useState(""),[_,w]=b.useState(""),[a,h]=b.useState(_t.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,E]=b.useState(null),y=bt(),j=Rl(o),R=En(),L=Xd(),{data:T,isLoading:D}=Ks(),F=d?.isGitRepo??i,I=d?.worktreeReady??l,H=d?.reason??u,q=F!==!1&&I!==!1;b.useEffect(()=>{if(!e||!T)return;const N=T.find(W=>W.availability.type!=="NOT_FOUND");N&&x(N.provider.id)},[e,T]),b.useEffect(()=>{if(e){const N=[m];v&&N.push(v),w(n?.trim()||N.join(`
74
74
 
75
- `)),f(null),h(i!==!1&&l!==!1?_t.WORKTREE:_t.MAIN_DIRECTORY),C("idle"),E(null)}},[e,i,l,o,m,v,n]),b.useEffect(()=>{q||h(_t.MAIN_DIRECTORY)},[q]);const A=async()=>{if(!p||L.isPending)return;const N=await L.mutateAsync({id:p});f(N),N.worktreeReady&&h(_t.WORKTREE)},P=S!=="idle",M=async()=>{if(!(!g||!_.trim())){E(null);try{C("creating-workspace");const N=await j.mutateAsync({workspaceKind:q?a:_t.MAIN_DIRECTORY});C("creating-session");const W=await Ee.post(`/workspaces/${N.id}/sessions`,{providerId:g,prompt:_.trim()});C("starting-session"),await R.mutateAsync(W.id),await y.invalidateQueries({queryKey:ce.workspaces.list(o)}),C("idle"),r?.(),s()}catch(N){C("idle"),E(N instanceof Error?N.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},$=(T??[]).map(({provider:N,availability:W})=>{const X=W.type!=="NOT_FOUND";return{value:N.id,label:X?N.name:`${N.name}${c(" (不可用)")}`,icon:t.jsx(li,{agentType:N.agentType,className:"size-4"}),disabled:!X}}),K=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),B=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),z=c(H==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),U=[{value:_t.WORKTREE,label:c("工作树模式"),description:K,disabled:!q},{value:_t.MAIN_DIRECTORY,label:c("本地模式"),description:B}];return t.jsx(fs,{isOpen:e,onClose:P?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{variant:"outline",onClick:s,disabled:P,children:c("取消")}),t.jsx(Me,{onClick:M,disabled:P||!g||!_.trim(),children:O[S]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("Agent")}),t.jsx(as,{value:g,onChange:x,options:$,placeholder:c(D?"加载中...":"选择 Agent"),disabled:P||D})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("模式")}),q?t.jsx(as,{value:a,onChange:N=>h(N),options:U,disabled:P}):t.jsx(Id,{side:"bottom",className:"w-full",content:z,children:t.jsxs("div",{tabIndex:0,"aria-label":z,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(as,{value:a,onChange:N=>h(N),options:U,disabled:!0}),t.jsx("button",{type:"button",onClick:A,disabled:P||L.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:L.isPending?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:_,onChange:N=>w(N.target.value),rows:5,disabled:P,placeholder:c("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function Nc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function F0(e,s,r){const o=e?.providerId??r?.providerId??null,p=o?s?.find(i=>i.provider.id===o)?.provider:null,m=p?.name??o??e?.agentType??r?.agentType??null;if(!m)return null;const v=e?.agentType??p?.agentType??r?.agentType??null,n=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:n,agentType:v}}function Rc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:v="top"}){const{t:n}=ae(),i=F0(e,s,{providerId:p,agentType:m});return!i&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[i&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${n("Provider")}: ${i.title}`,children:[t.jsx(li,{agentType:i.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:_d(i.label,o?12:18)})]}),t.jsx(En,{usage:r,tooltipSide:v})]})}function z0({isOpen:e,onClose:s,taskId:r}){const{t:o}=ae(),[p,m]=b.useState("AUTO"),[v,n]=b.useState(null),[i,l]=b.useState([]),[u,c]=b.useState(null),g=Da();b.useEffect(()=>{e&&(m("AUTO"),n(null),l([]),c(null))},[e]);const x=g.isPending,_=!!v||i.length>0,w=async()=>{if(!x){if(!v&&i.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...v?{teamTemplateId:v}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(h){if(h instanceof oi&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=x||!_;return t.jsxs(fs,{isOpen:e,onClose:x?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{type:"button",variant:"outline",onClick:s,disabled:x,children:o("取消")}),t.jsx(Me,{type:"button",onClick:w,disabled:a,children:o(x?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(Fd,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:l,disabled:x}),u&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u})]})}function W0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ae(),p=$n();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(js,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Me,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Ac(e){return e.length>0?e.map(s=>`- ${s}`).join(`
76
- `):"- 未获取到冲突文件列表"}function Tc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function H0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function $0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function U0(e,s,r,o,p){const m=Ac(r),v=Tc(p);return o===fr.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
77
- `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...H0(e,p)].join(`
78
- `)}function q0(e){const s=e.conflictOp===fr.REBASE?"Rebase":"Merge",r=Ac(e.conflictedFiles),o=[...Tc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===fr.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":$0(e)].join(`
79
- `)}function K0(e){if(e.teamRunId)return{type:"team_room",message:q0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:U0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Mc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:_,sessions:w,currentSessionId:a,teamRunId:h}){const{t:d}=ae(),[f,S]=b.useState(""),C=jn(),k=vn(h??""),E=Wn(),y=!!h,j=a||f,R=y?k.isPending:C.isPending,L=()=>{const H=K0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:_,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(H.type==="team_room"){k.mutate({content:H.message,kind:"chat"},{onSuccess:()=>{st.success(d("已发送到 Team Room")),s(!1)}});return}H.type==="session"&&C.mutate({id:H.sessionId,message:H.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",F=!y&&!a&&w.length>0,I=y||!!j;return t.jsx(fs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Me,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Me,{onClick:L,disabled:!I||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(H=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:H},H))})]}),y&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),F&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:H=>S(H.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),w.map(H=>t.jsxs("option",{value:H.id,children:[H.agentType," — ",H.status]},H.id))]})]}),!y&&!j&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function V0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function pa(e,s,r,o){const p=xc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Dc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:l,onConflict:u,className:c}){const{t:g}=ae(),x=Al(),_=Rl(),w=$n(),[a,h]=b.useState(!1),[d,f]=b.useState(null),S=Xn(e,a),C=(S.data??[]).filter(pc),k=b.useMemo(()=>V0(p),[p]),E=k.additions+k.deletions,y=k.files>0&&E>0,j=(m?.conflictedFiles.length??0)>0,R=!!(m&&m.operation!=="idle"),L=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),T=(m?.uncommittedCount??0)+(m?.untrackedCount??0),D=(m?.behind??0)>0,F=(m?.ahead??0)>0,I=v||!m&&n,H=!!(n&&e&&m&&D&&!j&&!R&&!L),q=!!(n&&e&&m&&F&&!D&&!j&&!R&&!L);if(b.useEffect(()=>{a&&l?.()},[a,l]),!y)return null;const A=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):T>0?g("{count} 未提交",{count:T}):D?g("落后 {count}",{count:m?.behind??0}):g(F?"可合并":"已是最新"),P=g("{files} 个文件 · {lines} 行",{files:k.files,lines:E}),M=()=>{H&&(f(null),x.mutate(e,{onError:B=>{pa(B,g("更新失败,请稍后重试"),z=>u(z),f)}}))},O=()=>{q&&(f(null),h(!0))},$=(B,z)=>{f(null),_.mutate({id:e,commitMessage:B,stopActiveServices:z},{onSuccess:()=>h(!1),onError:U=>{if(gc(U)){f(g("后台服务仍在运行,请确认停止服务后再提交。"));return}pa(U,g("提交失败,请稍后重试"),N=>{h(!1),u(N)},f)}})},K=()=>{_.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:te("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:i,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":g("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Vs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:P}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[k.additions>0&&t.jsxs("span",{className:"text-success",children:["+",k.additions]}),k.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",k.deletions]})]}),j&&t.jsx(js,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:A})]}),t.jsx(Pt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[R&&t.jsx("button",{type:"button",onClick:()=>w.mutate(e),disabled:w.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:w.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:M,disabled:!H||x.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(D?"同步更新":"已是最新"),children:[x.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(Ns,{size:12}),t.jsx("span",{children:x.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!q||_.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:q?g("合并到 {target}",{target:r}):g("提交变更"),children:[_.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(Xr,{size:12}),t.jsx("span",{children:_.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(vc,{isOpen:a,onClose:K,branchName:s,targetBranch:r,commitMessage:o,isPending:_.isPending,activeServices:C,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:d,onConfirm:$})]})}function X0({agentType:e,workingDir:s}){return jt({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await Ee.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===kt.CODEX,staleTime:3e4})}function Y0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Pc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[n,i]=b.useState(0),{data:l=[]}=X0({agentType:e,workingDir:s}),c=b.useMemo(()=>e===kt.CODEX?uo(r):null,[e,r])?.query??null,g=b.useMemo(()=>c===null?[]:zd(l,c),[c,l]),x=b.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);b.useEffect(()=>{i(0)},[e,c]),b.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const _=b.useCallback(a=>{const h=uo(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),w=b.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+g.length)%g.length),!0):Y0(a)?(a.preventDefault(),_(g[n]??g[0]),!0):!1,[_,g,c,n]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:n,setSelectedIndex:i,applySkill:_,handleKeyDown:w}}const Vi=200,G0=180;function Lc({taskId:e,title:s,readOnly:r=!1,onTitleChange:o,className:p,titleClassName:m,compact:v=!1}){const{t:n}=ae(),[i,l]=b.useState(!1),[u,c]=b.useState(s),[g,x]=b.useState(!1),_=b.useRef(null),w=b.useRef(null),a=yd();b.useEffect(()=>{i||c(s)},[s,i]),b.useEffect(()=>{i&&_.current&&(_.current.focus(),_.current.select())},[i]),b.useEffect(()=>{if(!i)return;const j=R=>{w.current&&!w.current.contains(R.target)&&f()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[i,u]);const h=b.useCallback(()=>{r||(l(!0),c(s))},[r,s]),d=b.useCallback(()=>{l(!1),c(s)},[s]),f=b.useCallback(async()=>{const j=u.trim();if(!j){c(s),l(!1);return}if(j===s){l(!1);return}try{await a.mutateAsync({id:e,title:j}),o?.(j),l(!1)}catch(R){console.error("Failed to update task title:",R),c(s)}},[u,s,e,a,o]),S=b.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),f()):j.key==="Escape"&&(j.preventDefault(),d())},[f,d]),C=b.useCallback(j=>{const R=j.target.value;R.length<=Vi&&c(R)},[]),k=u.length,E=k>=G0,y=k>=Vi;return i?t.jsxs("div",{ref:w,className:te("flex flex-col gap-2",p),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:_,type:"text",value:u,onChange:C,onKeyDown:S,disabled:a.isPending,className:te("flex-1 min-w-0 px-2 py-1 text-lg font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",v&&"text-base py-0.5",m),placeholder:n("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Me,{size:v?"sm":"default",variant:"ghost",onClick:f,disabled:a.isPending||!u.trim(),className:"h-8 w-8 p-0",children:a.isPending?t.jsx(ze,{size:16,className:"animate-spin"}):t.jsx(Kt,{size:16})}),t.jsx(Me,{size:v?"sm":"default",variant:"ghost",onClick:d,disabled:a.isPending,className:"h-8 w-8 p-0",children:t.jsx(qt,{size:16})})]})]}),E&&t.jsxs("div",{className:te("text-xs",y?"text-destructive":"text-muted-foreground"),children:[k," / ",Vi," ",n("字符")]})]}):t.jsxs("div",{ref:w,className:te("group flex items-center gap-2 min-w-0",p),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[t.jsx("h2",{onClick:h,className:te("flex-1 min-w-0 text-lg font-semibold text-foreground break-words line-clamp-2",!r&&"cursor-text hover:text-foreground/80 transition-colors",v&&"text-base",m),children:s}),!r&&g&&t.jsx(Me,{size:"sm",variant:"ghost",onClick:h,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:n("编辑标题"),children:t.jsx(Gd,{size:14})})]})}const Q0=br(),Z0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Q0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Is=520,Xi=48,J0=4,ex=420;function tx(){const{t:e}=ae();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ga=[{status:we.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ua,{className:"w-3 h-3"})},{status:we.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx($a,{className:"w-3 h-3"})},{status:we.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Ha,{className:"w-3 h-3"})},{status:we.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Wa,{className:"w-3 h-3"})},{status:we.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(za,{className:"w-3 h-3"})}];function sx({status:e,onChangeStatus:s}){const{t:r}=ae(),[o,p]=b.useState(!1),m=b.useRef(null);b.useEffect(()=>{if(!o)return;const n=i=>{m.current&&!m.current.contains(i.target)&&p(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=ga.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ga.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function va({state:e,onRetry:s}){const{t:r}=ae(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(es,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function rx({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),[n,i]=b.useState(""),[l,u]=b.useState(!1),[c,g]=b.useState(!1),[x,_]=b.useState(!1),[w,a]=b.useState(!1),[h,d]=b.useState(!1),[f,S]=b.useState(!1),[C,k]=b.useState(null),E=b.useRef(null),[y,j]=b.useState(!1),[R,L]=b.useState(null),[T,D]=b.useState(void 0),[F,I]=b.useState(!1),H=b.useRef(null),q=b.useRef(null),A=b.useRef(null),P=b.useRef(null),{scrollRef:M,contentRef:O,isAtBottom:$,scrollToBottom:K,stopScroll:B}=wn({resize:"smooth",initial:"instant"}),[z,U]=b.useState(!1),[N,W]=b.useState(Is),[X,V]=b.useState(!1),ie=b.useRef(0),ee=b.useRef(Is),me=b.useRef(null),he=b.useCallback((Q,re,Ie)=>{E.current?.openFile(Q,re,Ie)},[]),{data:G,isLoading:pe}=zn(e?.id??""),oe=B0(e?.id),{data:We}=Pa(e?.id??""),{data:ut}=La(We?.id??""),Oe=vn(We?.id??""),be=We??null,Ue=!!be,Be=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,tt=We===null&&Be,Ye=!!(e?.id&&We===null),{data:Ze,isLoading:Xe}=Ia(e?.id??"",Ye);b.useEffect(()=>{I(!1),L(null),D(void 0)},[e?.id]);const Ne=b.useMemo(()=>Il(G,be,T),[T,be,G]);b.useEffect(()=>{T&&!G?.some(Q=>Q.id===T)&&D(void 0)},[T,G]);const Ae=b.useMemo(()=>G?.find(Q=>Q.id===Ne),[Ne,G]),ve=Ae?.status===Mt.ACTIVE?Ae.id:void 0,He=Be&&Ol(Ae,be);b.useEffect(()=>{if(!F||!G)return;G.some(re=>re.status==="ACTIVE"&&re.sessions&&re.sessions.length>0)&&I(!1)},[G,F]);const _e=b.useMemo(()=>{if(F||!G)return null;const Q=mt=>{const Ni=mt.createdAt,rr=mt.endedAt??mt.startedAt??Ni;if(!rr)return 0;const Ds=Date.parse(rr);return Number.isNaN(Ds)?0:Ds},re=(mt,Ni)=>{const rr=mt.filter(Ds=>Ni.includes(Ds.status));return rr.length===0?null:rr.sort((Ds,nd)=>Q(nd)-Q(Ds))[0]??null},Ie=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=re(Ie,[ct.RUNNING])??re(Ie,[ct.PENDING])??re(Ie,[ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(ht)return ht;const ft=G.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return re(ft,[ct.COMPLETED,ct.FAILED,ct.CANCELLED])},[G,F]),pt=_e?.id??"",Je=Ue?R??"":pt,Lt=b.useMemo(()=>{if(!R||!G)return null;for(const Q of G){const re=Q.sessions?.find(Ie=>Ie.id===R);if(re)return re}return null},[R,G]),J=b.useMemo(()=>{if(!R||!be?.invocations)return null;const Q=be.invocations.filter(re=>re.sessionId===R);return Q.length===0?null:Q.sort((re,Ie)=>{const ht=Date.parse(re.updatedAt??re.createdAt??""),ft=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(ft)?0:ft)-(Number.isNaN(ht)?0:ht)})[0]??null},[R,be?.invocations]),fe=b.useMemo(()=>!J?.memberId||!be?.members?null:be.members.find(Q=>Q.id===J.memberId)??null,[J?.memberId,be?.members]),ue=R?Lt:_e??null,ge=ue?.id,Ce=b.useMemo(()=>{if(ue?.workspaceId)return ue.workspaceId;if(!(!ue||!G))return G.find(Q=>Q.sessions?.some(re=>re.id===ue.id))?.id},[ue,G]),Y=b.useCallback((Q,re)=>{const ht=(re&&G?.some(ft=>ft.id===re)?re:void 0)??Ce??Ne??void 0;ht&&D(ht),E.current?.openPreview(Q,ht)},[Ce,Ne,G]),se=b.useCallback((Q,re)=>{Y({kind:"web",url:Q},re)},[Y]),ne=b.useCallback((Q,re,Ie)=>{Y({kind:"visualization",sessionId:Q,file:re},Ie)},[Y]),ke=b.useCallback(Q=>{se(Q,Ce)},[Ce,se]),xe=b.useCallback(Q=>{ge&&ne(ge,Q,Ce)},[ge,Ce,ne]),{isActive:je,isCancelling:Te}=Va(ge??"",ue?.status),ye=!!e?.projectArchivedAt,Le=!!e?.projectRepoDeletedAt,Se=v(Le?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:De}=Ks(),[Qe,rt]=b.useState(null);b.useEffect(()=>{rt(_e?.providerId??null)},[_e?.providerId]);const Ct=b.useMemo(()=>!_e||!G?!1:!G.some(re=>re.status==="ACTIVE"&&re.sessions?.some(Ie=>Ie.id===_e.id)),[_e,G]),it=b.useMemo(()=>{if(!(!G||F)){if(Ae)return ds(Ae);for(const Q of G)if(Q.status==="ACTIVE"&&ds(Q))return ds(Q);return ds(G[0])}},[F,Ae,G]),nt=Xa({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),gt=Pc({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),Vt=Es(Q=>Q.setVisibleContext),Xt=!!(He&&ve&&it&&!ye),{data:Nt,isLoading:Yt}=Hn(ve??"",{enabled:Xt}),{data:Gt}=yi(it,{enabled:Xt});b.useEffect(()=>{if(!(z||!Xt||!ve||!it))return Vt({workspaceId:ve,workingDir:it,tab:"changes"}),()=>{Vt(null)}},[z,ve,Vt,Xt,it]);const Rs=Ae?.sessions??[],ss=qs(Ae),Gs=Ae?.commitMessage,Rt=b.useMemo(()=>Bl(Ae,G,e?.mainBranch??""),[Ae,e?.mainBranch,G]),vt=b.useMemo(()=>Nt?.conflictOp&&Nt.conflictedFiles.length>0?{conflictOp:Nt.conflictOp,conflictedFiles:Nt.conflictedFiles}:C,[Nt?.conflictOp,Nt?.conflictedFiles,C]),Qs=vt?.targetWorkspaceId??ve,jr=vt?.targetWorktreePath??Ae?.worktreePath,Nr=vt?.sourceBranch??ss,gs=vt?.targetBranch??Rt,at=bt(),Qt=b.useCallback(async()=>e?.id?at.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}):null,[at,e?.id]),vs=b.useCallback(()=>e?.id?at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,at]);b.useEffect(()=>{if(!y)return;const Q=re=>{q.current&&!q.current.contains(re.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[y]);const As=jn(),xs=Wn(),Rr=Sd(),Zs=Nl(e?.id??""),Js=kn(),Zt=Cf(),Wt=b.useMemo(()=>!G||G.some(re=>re.status==="ACTIVE")?null:G.find(re=>re.status==="HIBERNATED")??null,[G]),er=b.useRef(null);b.useEffect(()=>{Wt&&er.current!==Wt.id&&(Zt.isPending||(er.current=Wt.id,Zt.mutate(Wt.id,{onSettled:()=>{er.current=null}})))},[Wt,Zt]);const Ar=b.useCallback(async()=>{if(!e?.id)return;const Q=_e?.providerId??De?.find(re=>re.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),d(!0);try{const Ie=(await Qt())?.prompt??e.title;await Rr.mutateAsync(e.id),I(!0);const ht=await Zs.mutateAsync({workspaceKind:Be?void 0:_t.MAIN_DIRECTORY}),ft=await Ee.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Ie});await Js.mutateAsync(ft.id),await at.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(re){console.error("[retry] failed:",re),I(!1)}finally{d(!1)}}},[e?.id,e?.title,Be,_e?.providerId,De,Qt,Rr,Zs,Js,at]),Ts=b.useCallback(async()=>{e?.id&&(await Qt(),u(!0))},[Qt,e?.id]),tr=b.useCallback(()=>{Ae?.id&&xs.mutate({workspaceId:Ae.id})},[xs,Ae?.id]),Tr=b.useCallback(()=>{!e?.id||!s||(s(e.id),_(!1))},[e?.id,s]),Mr=b.useCallback(Q=>{L(Q),requestAnimationFrame(()=>{K()})},[K]),Si=b.useCallback(()=>{L(null)},[]),bs=b.useCallback(Q=>{k(Q??null),S(!0)},[]),wi=b.useCallback(Q=>Oe.mutateAsync(Q),[Oe]),rs=b.useCallback(()=>{at.invalidateQueries({queryKey:wd.all})},[at]),{isConnected:sr,isLoadingSnapshot:Dr,isOutputActive:Pr,lastExitAt:Lr,logs:_s,entries:ys,attach:Z}=Ja({sessionId:Je,sessionStatus:ue?.status,sessionStartedAt:ue?.startedAt??ue?.createdAt,sessionEndedAt:ue?.endedAt??(je?null:ue?.updatedAt),onExit:b.useCallback(()=>{at.invalidateQueries({queryKey:["workspaces"]})},[at])});b.useEffect(()=>{if(!e?.id)return;const Q=os.connect();Q.emit(Os.SUBSCRIBE,{topic:"task",id:e.id});const re=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:["tasks"]}),rs())},Ie=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),rs())},ht=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),rs())};return Q.on(lt.TASK_UPDATED,re),Q.on(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.on(lt.WORKSPACE_HIBERNATED,ht),()=>{Q.off(lt.TASK_UPDATED,re),Q.off(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.off(lt.WORKSPACE_HIBERNATED,ht),Q.emit(Os.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,at,rs]),b.useEffect(()=>{if(!Je)return;const Q=os.connect(),re=Ie=>{Ie.sessionId===Je&&(at.invalidateQueries({queryKey:["workspaces"]}),rs())};return Q.on(lt.SESSION_COMPLETED,re),()=>{Q.off(lt.SESSION_COMPLETED,re)}},[Je,at,rs]);const{todos:de}=el(ys),{files:Fe,addFiles:Pe,removeFile:St,clear:It,buildMarkdownLinks:$e,hasFiles:At,isUploading:Ot}=xn(),Ms=b.useMemo(()=>Nc(ue),[ue?.tokenUsage]),to=Ya(_s,Ms);b.useEffect(()=>{Je&&sr&&Z()},[Je,sr,Z]);const so=b.useRef(e?.id);b.useEffect(()=>{if(so.current!==e?.id&&M.current){const Q=M.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}so.current=e?.id},[e?.id,M]);const is=Ga(),Ci=b.useRef(!1),ro=b.useCallback(async()=>{if(!n.trim()&&!At||!Je||Ci.current||is.isPending||Te||Ot)return;Ci.current=!0;const Q=$e(),re=[n.trim(),Q].filter(Boolean).join(`
75
+ `)),f(null),h(i!==!1&&l!==!1?_t.WORKTREE:_t.MAIN_DIRECTORY),C("idle"),E(null)}},[e,i,l,o,m,v,n]),b.useEffect(()=>{q||h(_t.MAIN_DIRECTORY)},[q]);const A=async()=>{if(!p||L.isPending)return;const N=await L.mutateAsync({id:p});f(N),N.worktreeReady&&h(_t.WORKTREE)},P=S!=="idle",M=async()=>{if(!(!g||!_.trim())){E(null);try{C("creating-workspace");const N=await j.mutateAsync({workspaceKind:q?a:_t.MAIN_DIRECTORY});C("creating-session");const W=await Ee.post(`/workspaces/${N.id}/sessions`,{providerId:g,prompt:_.trim()});C("starting-session"),await R.mutateAsync(W.id),await y.invalidateQueries({queryKey:ce.workspaces.list(o)}),C("idle"),r?.(),s()}catch(N){C("idle"),E(N instanceof Error?N.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},$=(T??[]).map(({provider:N,availability:W})=>{const X=W.type!=="NOT_FOUND";return{value:N.id,label:X?N.name:`${N.name}${c(" (不可用)")}`,icon:t.jsx(ci,{agentType:N.agentType,className:"size-4"}),disabled:!X}}),K=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),B=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),z=c(H==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),U=[{value:_t.WORKTREE,label:c("工作树模式"),description:K,disabled:!q},{value:_t.MAIN_DIRECTORY,label:c("本地模式"),description:B}];return t.jsx(fs,{isOpen:e,onClose:P?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{variant:"outline",onClick:s,disabled:P,children:c("取消")}),t.jsx(Me,{onClick:M,disabled:P||!g||!_.trim(),children:O[S]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("Agent")}),t.jsx(as,{value:g,onChange:x,options:$,placeholder:c(D?"加载中...":"选择 Agent"),disabled:P||D})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("模式")}),q?t.jsx(as,{value:a,onChange:N=>h(N),options:U,disabled:P}):t.jsx(Od,{side:"bottom",className:"w-full",content:z,children:t.jsxs("div",{tabIndex:0,"aria-label":z,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(as,{value:a,onChange:N=>h(N),options:U,disabled:!0}),t.jsx("button",{type:"button",onClick:A,disabled:P||L.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:L.isPending?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:_,onChange:N=>w(N.target.value),rows:5,disabled:P,placeholder:c("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function Rc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function z0(e,s,r){const o=e?.providerId??r?.providerId??null,p=o?s?.find(i=>i.provider.id===o)?.provider:null,m=p?.name??o??e?.agentType??r?.agentType??null;if(!m)return null;const v=e?.agentType??p?.agentType??r?.agentType??null,n=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:n,agentType:v}}function Ac({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:v="top"}){const{t:n}=ae(),i=z0(e,s,{providerId:p,agentType:m});return!i&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[i&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${n("Provider")}: ${i.title}`,children:[t.jsx(ci,{agentType:i.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:yd(i.label,o?12:18)})]}),t.jsx(jn,{usage:r,tooltipSide:v})]})}function W0({isOpen:e,onClose:s,taskId:r}){const{t:o}=ae(),[p,m]=b.useState("AUTO"),[v,n]=b.useState(null),[i,l]=b.useState([]),[u,c]=b.useState(null),g=Pa();b.useEffect(()=>{e&&(m("AUTO"),n(null),l([]),c(null))},[e]);const x=g.isPending,_=!!v||i.length>0,w=async()=>{if(!x){if(!v&&i.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...v?{teamTemplateId:v}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(h){if(h instanceof ai&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=x||!_;return t.jsxs(fs,{isOpen:e,onClose:x?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{type:"button",variant:"outline",onClick:s,disabled:x,children:o("取消")}),t.jsx(Me,{type:"button",onClick:w,disabled:a,children:o(x?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(zd,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:l,disabled:x}),u&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u})]})}function H0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ae(),p=Un();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(js,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Me,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Tc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
76
+ `):"- 未获取到冲突文件列表"}function Mc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function $0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function U0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function q0(e,s,r,o,p){const m=Tc(r),v=Mc(p);return o===fr.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
77
+ `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...$0(e,p)].join(`
78
+ `)}function K0(e){const s=e.conflictOp===fr.REBASE?"Rebase":"Merge",r=Tc(e.conflictedFiles),o=[...Mc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===fr.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":U0(e)].join(`
79
+ `)}function V0(e){if(e.teamRunId)return{type:"team_room",message:K0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:q0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Dc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:_,sessions:w,currentSessionId:a,teamRunId:h}){const{t:d}=ae(),[f,S]=b.useState(""),C=Nn(),k=xn(h??""),E=Hn(),y=!!h,j=a||f,R=y?k.isPending:C.isPending,L=()=>{const H=V0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:_,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(H.type==="team_room"){k.mutate({content:H.message,kind:"chat"},{onSuccess:()=>{st.success(d("已发送到 Team Room")),s(!1)}});return}H.type==="session"&&C.mutate({id:H.sessionId,message:H.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",F=!y&&!a&&w.length>0,I=y||!!j;return t.jsx(fs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Me,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Me,{onClick:L,disabled:!I||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(H=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:H},H))})]}),y&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),F&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:H=>S(H.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),w.map(H=>t.jsxs("option",{value:H.id,children:[H.agentType," — ",H.status]},H.id))]})]}),!y&&!j&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function X0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function ga(e,s,r,o){const p=bc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Pc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:l,onConflict:u,className:c}){const{t:g}=ae(),x=Tl(),_=Al(),w=Un(),[a,h]=b.useState(!1),[d,f]=b.useState(null),S=Yn(e,a),C=(S.data??[]).filter(gc),k=b.useMemo(()=>X0(p),[p]),E=k.additions+k.deletions,y=k.files>0&&E>0,j=(m?.conflictedFiles.length??0)>0,R=!!(m&&m.operation!=="idle"),L=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),T=(m?.uncommittedCount??0)+(m?.untrackedCount??0),D=(m?.behind??0)>0,F=(m?.ahead??0)>0,I=v||!m&&n,H=!!(n&&e&&m&&D&&!j&&!R&&!L),q=!!(n&&e&&m&&F&&!D&&!j&&!R&&!L);if(b.useEffect(()=>{a&&l?.()},[a,l]),!y)return null;const A=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):T>0?g("{count} 未提交",{count:T}):D?g("落后 {count}",{count:m?.behind??0}):g(F?"可合并":"已是最新"),P=g("{files} 个文件 · {lines} 行",{files:k.files,lines:E}),M=()=>{H&&(f(null),x.mutate(e,{onError:B=>{ga(B,g("更新失败,请稍后重试"),z=>u(z),f)}}))},O=()=>{q&&(f(null),h(!0))},$=(B,z)=>{f(null),_.mutate({id:e,commitMessage:B,stopActiveServices:z},{onSuccess:()=>h(!1),onError:U=>{if(vc(U)){f(g("后台服务仍在运行,请确认停止服务后再提交。"));return}ga(U,g("提交失败,请稍后重试"),N=>{h(!1),u(N)},f)}})},K=()=>{_.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:te("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:i,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":g("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Vs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:P}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[k.additions>0&&t.jsxs("span",{className:"text-success",children:["+",k.additions]}),k.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",k.deletions]})]}),j&&t.jsx(js,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:A})]}),t.jsx(Pt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[R&&t.jsx("button",{type:"button",onClick:()=>w.mutate(e),disabled:w.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:w.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:M,disabled:!H||x.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(D?"同步更新":"已是最新"),children:[x.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(Ns,{size:12}),t.jsx("span",{children:x.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!q||_.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:q?g("合并到 {target}",{target:r}):g("提交变更"),children:[_.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(Yr,{size:12}),t.jsx("span",{children:_.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(xc,{isOpen:a,onClose:K,branchName:s,targetBranch:r,commitMessage:o,isPending:_.isPending,activeServices:C,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:d,onConfirm:$})]})}function Y0({agentType:e,workingDir:s}){return jt({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await Ee.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===kt.CODEX,staleTime:3e4})}function G0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Lc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[n,i]=b.useState(0),{data:l=[]}=Y0({agentType:e,workingDir:s}),c=b.useMemo(()=>e===kt.CODEX?ho(r):null,[e,r])?.query??null,g=b.useMemo(()=>c===null?[]:Wd(l,c),[c,l]),x=b.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);b.useEffect(()=>{i(0)},[e,c]),b.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const _=b.useCallback(a=>{const h=ho(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),w=b.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+g.length)%g.length),!0):G0(a)?(a.preventDefault(),_(g[n]??g[0]),!0):!1,[_,g,c,n]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:n,setSelectedIndex:i,applySkill:_,handleKeyDown:w}}const Xi=200,Q0=180;function Ic({taskId:e,title:s,readOnly:r=!1,onTitleChange:o,className:p,titleClassName:m,compact:v=!1}){const{t:n}=ae(),[i,l]=b.useState(!1),[u,c]=b.useState(s),[g,x]=b.useState(!1),_=b.useRef(null),w=b.useRef(null),a=Sd();b.useEffect(()=>{i||c(s)},[s,i]),b.useEffect(()=>{i&&_.current&&(_.current.focus(),_.current.select())},[i]),b.useEffect(()=>{if(!i)return;const j=R=>{w.current&&!w.current.contains(R.target)&&f()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[i,u]);const h=b.useCallback(()=>{r||(l(!0),c(s))},[r,s]),d=b.useCallback(()=>{l(!1),c(s)},[s]),f=b.useCallback(async()=>{const j=u.trim();if(!j){c(s),l(!1);return}if(j===s){l(!1);return}try{await a.mutateAsync({id:e,title:j}),o?.(j),l(!1)}catch(R){console.error("Failed to update task title:",R),c(s)}},[u,s,e,a,o]),S=b.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),f()):j.key==="Escape"&&(j.preventDefault(),d())},[f,d]),C=b.useCallback(j=>{const R=j.target.value;R.length<=Xi&&c(R)},[]),k=u.length,E=k>=Q0,y=k>=Xi;return i?t.jsxs("div",{ref:w,className:te("flex flex-col gap-2",p),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:_,type:"text",value:u,onChange:C,onKeyDown:S,disabled:a.isPending,className:te("flex-1 min-w-0 px-2 py-1 text-lg font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",v&&"text-base py-0.5",m),placeholder:n("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Me,{size:v?"sm":"default",variant:"ghost",onClick:f,disabled:a.isPending||!u.trim(),className:"h-8 w-8 p-0",children:a.isPending?t.jsx(ze,{size:16,className:"animate-spin"}):t.jsx(Kt,{size:16})}),t.jsx(Me,{size:v?"sm":"default",variant:"ghost",onClick:d,disabled:a.isPending,className:"h-8 w-8 p-0",children:t.jsx(qt,{size:16})})]})]}),E&&t.jsxs("div",{className:te("text-xs",y?"text-destructive":"text-muted-foreground"),children:[k," / ",Xi," ",n("字符")]})]}):t.jsxs("div",{ref:w,className:te("group flex items-center gap-2 min-w-0",p),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[t.jsx("h2",{onClick:h,className:te("flex-1 min-w-0 text-lg font-semibold text-foreground break-words line-clamp-2",!r&&"cursor-text hover:text-foreground/80 transition-colors",v&&"text-base",m),children:s}),!r&&g&&t.jsx(Me,{size:"sm",variant:"ghost",onClick:h,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:n("编辑标题"),children:t.jsx(Qd,{size:14})})]})}const Z0=br(),J0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Z0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Is=520,Yi=48,ex=4,tx=420;function sx(){const{t:e}=ae();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const va=[{status:we.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(qa,{className:"w-3 h-3"})},{status:we.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Ua,{className:"w-3 h-3"})},{status:we.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx($a,{className:"w-3 h-3"})},{status:we.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Ha,{className:"w-3 h-3"})},{status:we.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(Wa,{className:"w-3 h-3"})}];function rx({status:e,onChangeStatus:s}){const{t:r}=ae(),[o,p]=b.useState(!1),m=b.useRef(null);b.useEffect(()=>{if(!o)return;const n=i=>{m.current&&!m.current.contains(i.target)&&p(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=va.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:va.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function xa({state:e,onRetry:s}){const{t:r}=ae(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(es,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function ix({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),[n,i]=b.useState(""),[l,u]=b.useState(!1),[c,g]=b.useState(!1),[x,_]=b.useState(!1),[w,a]=b.useState(!1),[h,d]=b.useState(!1),[f,S]=b.useState(!1),[C,k]=b.useState(null),E=b.useRef(null),[y,j]=b.useState(!1),[R,L]=b.useState(null),[T,D]=b.useState(void 0),[F,I]=b.useState(!1),H=b.useRef(null),q=b.useRef(null),A=b.useRef(null),P=b.useRef(null),{scrollRef:M,contentRef:O,isAtBottom:$,scrollToBottom:K,stopScroll:B}=Cn({resize:"smooth",initial:"instant"}),[z,U]=b.useState(!1),[N,W]=b.useState(Is),[X,V]=b.useState(!1),ie=b.useRef(0),ee=b.useRef(Is),me=b.useRef(null),he=b.useCallback((Q,re,Ie)=>{E.current?.openFile(Q,re,Ie)},[]),{data:G,isLoading:pe}=Wn(e?.id??""),oe=F0(e?.id),{data:We}=La(e?.id??""),{data:ut}=Ia(We?.id??""),Oe=xn(We?.id??""),be=We??null,Ue=!!be,Be=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,tt=We===null&&Be,Ye=!!(e?.id&&We===null),{data:Ze,isLoading:Xe}=Oa(e?.id??"",Ye);b.useEffect(()=>{I(!1),L(null),D(void 0)},[e?.id]);const Ne=b.useMemo(()=>Ol(G,be,T),[T,be,G]);b.useEffect(()=>{T&&!G?.some(Q=>Q.id===T)&&D(void 0)},[T,G]);const Ae=b.useMemo(()=>G?.find(Q=>Q.id===Ne),[Ne,G]),ve=Ae?.status===Mt.ACTIVE?Ae.id:void 0,He=Be&&Bl(Ae,be);b.useEffect(()=>{if(!F||!G)return;G.some(re=>re.status==="ACTIVE"&&re.sessions&&re.sessions.length>0)&&I(!1)},[G,F]);const _e=b.useMemo(()=>{if(F||!G)return null;const Q=mt=>{const Ri=mt.createdAt,rr=mt.endedAt??mt.startedAt??Ri;if(!rr)return 0;const Ds=Date.parse(rr);return Number.isNaN(Ds)?0:Ds},re=(mt,Ri)=>{const rr=mt.filter(Ds=>Ri.includes(Ds.status));return rr.length===0?null:rr.sort((Ds,od)=>Q(od)-Q(Ds))[0]??null},Ie=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=re(Ie,[ct.RUNNING])??re(Ie,[ct.PENDING])??re(Ie,[ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(ht)return ht;const ft=G.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return re(ft,[ct.COMPLETED,ct.FAILED,ct.CANCELLED])},[G,F]),pt=_e?.id??"",Je=Ue?R??"":pt,Lt=b.useMemo(()=>{if(!R||!G)return null;for(const Q of G){const re=Q.sessions?.find(Ie=>Ie.id===R);if(re)return re}return null},[R,G]),J=b.useMemo(()=>{if(!R||!be?.invocations)return null;const Q=be.invocations.filter(re=>re.sessionId===R);return Q.length===0?null:Q.sort((re,Ie)=>{const ht=Date.parse(re.updatedAt??re.createdAt??""),ft=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(ft)?0:ft)-(Number.isNaN(ht)?0:ht)})[0]??null},[R,be?.invocations]),fe=b.useMemo(()=>!J?.memberId||!be?.members?null:be.members.find(Q=>Q.id===J.memberId)??null,[J?.memberId,be?.members]),ue=R?Lt:_e??null,ge=ue?.id,Ce=b.useMemo(()=>{if(ue?.workspaceId)return ue.workspaceId;if(!(!ue||!G))return G.find(Q=>Q.sessions?.some(re=>re.id===ue.id))?.id},[ue,G]),Y=b.useCallback((Q,re)=>{const ht=(re&&G?.some(ft=>ft.id===re)?re:void 0)??Ce??Ne??void 0;ht&&D(ht),E.current?.openPreview(Q,ht)},[Ce,Ne,G]),se=b.useCallback((Q,re)=>{Y({kind:"web",url:Q},re)},[Y]),ne=b.useCallback((Q,re,Ie)=>{Y({kind:"visualization",sessionId:Q,file:re},Ie)},[Y]),ke=b.useCallback(Q=>{se(Q,Ce)},[Ce,se]),xe=b.useCallback(Q=>{ge&&ne(ge,Q,Ce)},[ge,Ce,ne]),{isActive:je,isCancelling:Te}=Xa(ge??"",ue?.status),ye=!!e?.projectArchivedAt,Le=!!e?.projectRepoDeletedAt,Se=v(Le?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:De}=Ks(),[Qe,rt]=b.useState(null);b.useEffect(()=>{rt(_e?.providerId??null)},[_e?.providerId]);const Ct=b.useMemo(()=>!_e||!G?!1:!G.some(re=>re.status==="ACTIVE"&&re.sessions?.some(Ie=>Ie.id===_e.id)),[_e,G]),it=b.useMemo(()=>{if(!(!G||F)){if(Ae)return ds(Ae);for(const Q of G)if(Q.status==="ACTIVE"&&ds(Q))return ds(Q);return ds(G[0])}},[F,Ae,G]),nt=Ya({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),gt=Lc({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),Vt=Es(Q=>Q.setVisibleContext),Xt=!!(He&&ve&&it&&!ye),{data:Nt,isLoading:Yt}=$n(ve??"",{enabled:Xt}),{data:Gt}=Si(it,{enabled:Xt});b.useEffect(()=>{if(!(z||!Xt||!ve||!it))return Vt({workspaceId:ve,workingDir:it,tab:"changes"}),()=>{Vt(null)}},[z,ve,Vt,Xt,it]);const Rs=Ae?.sessions??[],ss=qs(Ae),Gs=Ae?.commitMessage,Rt=b.useMemo(()=>Fl(Ae,G,e?.mainBranch??""),[Ae,e?.mainBranch,G]),vt=b.useMemo(()=>Nt?.conflictOp&&Nt.conflictedFiles.length>0?{conflictOp:Nt.conflictOp,conflictedFiles:Nt.conflictedFiles}:C,[Nt?.conflictOp,Nt?.conflictedFiles,C]),Qs=vt?.targetWorkspaceId??ve,jr=vt?.targetWorktreePath??Ae?.worktreePath,Nr=vt?.sourceBranch??ss,gs=vt?.targetBranch??Rt,at=bt(),Qt=b.useCallback(async()=>e?.id?at.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}):null,[at,e?.id]),vs=b.useCallback(()=>e?.id?at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,at]);b.useEffect(()=>{if(!y)return;const Q=re=>{q.current&&!q.current.contains(re.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[y]);const As=Nn(),xs=Hn(),Rr=wd(),Zs=Rl(e?.id??""),Js=En(),Zt=kf(),Wt=b.useMemo(()=>!G||G.some(re=>re.status==="ACTIVE")?null:G.find(re=>re.status==="HIBERNATED")??null,[G]),er=b.useRef(null);b.useEffect(()=>{Wt&&er.current!==Wt.id&&(Zt.isPending||(er.current=Wt.id,Zt.mutate(Wt.id,{onSettled:()=>{er.current=null}})))},[Wt,Zt]);const Ar=b.useCallback(async()=>{if(!e?.id)return;const Q=_e?.providerId??De?.find(re=>re.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),d(!0);try{const Ie=(await Qt())?.prompt??e.title;await Rr.mutateAsync(e.id),I(!0);const ht=await Zs.mutateAsync({workspaceKind:Be?void 0:_t.MAIN_DIRECTORY}),ft=await Ee.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Ie});await Js.mutateAsync(ft.id),await at.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(re){console.error("[retry] failed:",re),I(!1)}finally{d(!1)}}},[e?.id,e?.title,Be,_e?.providerId,De,Qt,Rr,Zs,Js,at]),Ts=b.useCallback(async()=>{e?.id&&(await Qt(),u(!0))},[Qt,e?.id]),tr=b.useCallback(()=>{Ae?.id&&xs.mutate({workspaceId:Ae.id})},[xs,Ae?.id]),Tr=b.useCallback(()=>{!e?.id||!s||(s(e.id),_(!1))},[e?.id,s]),Mr=b.useCallback(Q=>{L(Q),requestAnimationFrame(()=>{K()})},[K]),wi=b.useCallback(()=>{L(null)},[]),bs=b.useCallback(Q=>{k(Q??null),S(!0)},[]),Ci=b.useCallback(Q=>Oe.mutateAsync(Q),[Oe]),rs=b.useCallback(()=>{at.invalidateQueries({queryKey:Cd.all})},[at]),{isConnected:sr,isLoadingSnapshot:Dr,isOutputActive:Pr,lastExitAt:Lr,logs:_s,entries:ys,attach:Z}=el({sessionId:Je,sessionStatus:ue?.status,sessionStartedAt:ue?.startedAt??ue?.createdAt,sessionEndedAt:ue?.endedAt??(je?null:ue?.updatedAt),onExit:b.useCallback(()=>{at.invalidateQueries({queryKey:["workspaces"]})},[at])});b.useEffect(()=>{if(!e?.id)return;const Q=os.connect();Q.emit(Os.SUBSCRIBE,{topic:"task",id:e.id});const re=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:["tasks"]}),rs())},Ie=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),rs())},ht=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),rs())};return Q.on(lt.TASK_UPDATED,re),Q.on(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.on(lt.WORKSPACE_HIBERNATED,ht),()=>{Q.off(lt.TASK_UPDATED,re),Q.off(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.off(lt.WORKSPACE_HIBERNATED,ht),Q.emit(Os.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,at,rs]),b.useEffect(()=>{if(!Je)return;const Q=os.connect(),re=Ie=>{Ie.sessionId===Je&&(at.invalidateQueries({queryKey:["workspaces"]}),rs())};return Q.on(lt.SESSION_COMPLETED,re),()=>{Q.off(lt.SESSION_COMPLETED,re)}},[Je,at,rs]);const{todos:de}=tl(ys),{files:Fe,addFiles:Pe,removeFile:St,clear:It,buildMarkdownLinks:$e,hasFiles:At,isUploading:Ot}=bn(),Ms=b.useMemo(()=>Rc(ue),[ue?.tokenUsage]),so=Ga(_s,Ms);b.useEffect(()=>{Je&&sr&&Z()},[Je,sr,Z]);const ro=b.useRef(e?.id);b.useEffect(()=>{if(ro.current!==e?.id&&M.current){const Q=M.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}ro.current=e?.id},[e?.id,M]);const is=Qa(),ki=b.useRef(!1),io=b.useCallback(async()=>{if(!n.trim()&&!At||!Je||ki.current||is.isPending||Te||Ot)return;ki.current=!0;const Q=$e(),re=[n.trim(),Q].filter(Boolean).join(`
80
80
 
81
- `);i(""),It(),A.current&&(A.current.style.height="60px"),As.mutate({id:Je,message:re,providerId:Qe??void 0},{onSuccess:()=>{Z()},onError:()=>{i(Ie=>Ie||re)},onSettled:()=>{Ci.current=!1}})},[n,Je,As,Z,At,Ot,$e,It,Qe,is.isPending,Te]),Gc=b.useCallback(()=>{!Je||is.isPending||is.mutate(Je)},[Je,is]),Qc=b.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&Pe(Array.from(re)),Q.target.value=""},[Pe]),Zc=b.useCallback(Q=>{const re=Q.clipboardData.items,Ie=[];for(const ht of re)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Ie.push(ft)}Ie.length>0&&(Q.preventDefault(),Pe(Ie))},[Pe]),[io,ki]=b.useState(!1),Jc=b.useCallback(Q=>{Q.preventDefault(),ki(!0)},[]),ed=b.useCallback(Q=>{Q.preventDefault(),ki(!1)},[]),td=b.useCallback(Q=>{Q.preventDefault(),ki(!1);const re=Q.dataTransfer.files;re.length>0&&Pe(Array.from(re))},[Pe]),Jt=b.useCallback(Q=>{const re=me.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=re?Math.max(Is,re-Xi-J0-ex):Is;return Math.max(Is,Math.min(Math.round(Q),Ie))},[]),Ei=b.useCallback(Q=>{const re=Q.clientX-ie.current;W(Jt(ee.current-re))},[Jt]),ji=b.useCallback(()=>{V(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);b.useEffect(()=>{if(X)return document.addEventListener("mousemove",Ei),document.addEventListener("mouseup",ji),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Ei),document.removeEventListener("mouseup",ji),document.body.style.cursor="",document.body.style.userSelect=""}},[ji,Ei,X]);const sd=b.useCallback(Q=>{Q.preventDefault(),ie.current=Q.clientX,ee.current=N,V(!0)},[N]);b.useEffect(()=>{!z||X||W(Q=>Jt(Q))},[Jt,z,X]),b.useEffect(()=>{if(!z)return;const Q=()=>{W(re=>Jt(re))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Jt,z]);const rd=b.useCallback(()=>{W(Q=>Jt(Q)),U(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Jt]),id=b.useCallback(Q=>{i(Q.target.value);const re=Q.target;re.style.height="auto";const Ie=re.scrollHeight;re.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]),no=Xt&&ve?t.jsx(Dc,{workspaceId:ve,branchName:ss,targetBranch:Rt,commitMessage:Gs,changes:Gt,gitStatus:Nt,isGitStatusLoading:Yt,canRunGitOperations:He,onOpenChanges:rd,onRefreshCommitMessage:vs,onConflict:bs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx(Lc,{taskId:e.id,title:e.title,readOnly:ye})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(sx,{status:e.status,onChangeStatus:!ye&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:tr,disabled:!it||ye,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(ci,{size:16})}),(s||tt)&&!ye&&t.jsxs("div",{className:"relative",ref:q,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(il,{size:16})}),y&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[tt&&t.jsxs("button",{onClick:()=>{g(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ls,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Cd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{_(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(Rn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),He&&ve&&Nt&&t.jsx(W0,{workspaceId:ve,gitStatus:Nt,onResolve:()=>bs()}),t.jsxs("div",{ref:me,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ue&&be?R?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:R})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Rc,{session:ue,providers:De,usage:to,providerIdFallback:fe?.providerId,agentTypeFallback:ue?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:Si,children:[t.jsx($s,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,scrollElementRef:M,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe})})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Vr,{todos:de})})})]}):t.jsx(Ll,{teamRun:be,messages:ut??be.messages??[],readOnly:ye,readOnlyMessage:Se,onSendMessage:wi,onViewInvocationSession:Mr,changeSummaryBar:no,centered:!0,workingDir:it,onOpenWorkspaceFile:he,onOpenPreviewUrl:se,onOpenVisualization:ne}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Xe||Ze?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Xe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ze?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(_n,{urlTransform:Z0,components:Fa,children:Ze.body})}):null}),oe&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[oe.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:oe.currentIndex,total:oe.totalCommands,command:oe.currentCommand})})]}),oe.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),oe.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:oe.error})})]}),!ye&&p&&(pe||pt)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(va,{state:p,onRetry:p.status==="failed"?Ts:void 0})}):null,pe?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):pt?Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,scrollElementRef:M,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(es,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(ye?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:ye?Se:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!ye&&p?t.jsx(va,{state:p}):null,!ye&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Me,{onClick:Ts,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),tt&&t.jsxs(Me,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ls,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Vr,{todos:de})})}),ye?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:Se})})}):Ct?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:Ts,children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Jc,onDragLeave:ed,onDrop:td,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[no,Je?t.jsx(Qa,{sessionId:Je}):null,t.jsxs("div",{ref:H,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${io?"border-info bg-info/5":"border-border"}`,children:[t.jsx(bn,{files:Fe,onRemove:St}),t.jsx("textarea",{ref:A,value:n,onChange:id,onPaste:Zc,onKeyDown:Q=>{gt.handleKeyDown(Q)||nt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),ro())},rows:1,placeholder:v(io?"Drop files here...":pt&&!je?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:Qc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>P.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(Nn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[_e&&De&&t.jsx(Za,{providers:De,currentProviderId:Qe,agentType:_e.agentType,runtimeType:_e.runtimeType,onSelect:rt}),t.jsx(En,{usage:to}),je&&!n.trim()&&!At?t.jsx("button",{onClick:Gc,disabled:is.isPending||Te,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ws,{size:14})}):t.jsx("button",{onClick:ro,disabled:!n.trim()&&!At||Ot||As.isPending||is.isPending||Te,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||At)&&!Ot&&!As.isPending&&!is.isPending&&!Te?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Cn,{size:18})})]})]})]})]}),t.jsx(Kr,{open:nt.query!==null,anchorRef:H,commands:nt.filteredCommands,selectedIndex:nt.selectedIndex,query:nt.query??"",hasCatalog:nt.allCommands.length>0,onSelect:nt.applyCommand}),t.jsx(Kr,{open:gt.query!==null,anchorRef:H,commands:gt.filteredSkills,selectedIndex:gt.selectedIndex,query:gt.query??"",hasCatalog:gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:gt.applySkill})]})]})}),z&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:sd,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:z?Xi+N:Xi},children:t.jsx(Ec,{sessionId:pt||void 0,workspaceId:Ne,workingDir:it,projectId:e.projectId,readOnly:ye,repoDeleted:Le,teamRun:be,teamStatus:be?t.jsx(Wl,{teamRun:be,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,onViewInvocationSession:Mr}):void 0,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,variant:"rail",expanded:z,onExpandedChange:Q=>{Q&&W(re=>Jt(re)),U(Q)},minContentWidth:Is,tabRef:E,gitAvailable:Be,gitProps:He&&ve?{branchName:ss,targetBranch:Rt,commitMessage:Gs,canRunGitOperations:!0,onRefreshCommitMessage:vs,onConflict:bs,onResolveConflicts:()=>bs()}:void 0})})]}),!ye&&t.jsx(jc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ze?.title??e.title,taskDescription:Ze?.body??"",taskPrompt:Ze?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),tt&&!ye&&t.jsx(z0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),He&&Qs&&vt&&t.jsx(Mc,{open:f,onOpenChange:Q=>{S(Q),Q||k(null)},workspaceId:Qs,conflictOp:vt.conflictOp,conflictedFiles:vt.conflictedFiles,sourceBranch:Nr,targetBranch:gs,operation:Nt?.operation,worktreePath:jr,mergeAborted:vt.mergeAborted,mergeStrategy:vt.mergeStrategy,sourceWorkspaceId:vt.sourceWorkspaceId,targetWorkspaceId:vt.targetWorkspaceId,sourceWorktreePath:vt.sourceWorktreePath,targetWorktreePath:vt.targetWorktreePath,sessions:Rs,currentSessionId:Ue?void 0:pt,teamRunId:be?.id}),t.jsx(yn,{isOpen:w,onClose:()=>a(!1),onConfirm:Ar,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Un,{isOpen:x,onClose:()=>_(!1),onConfirm:Tr,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(tx,{})}function eo(e){switch(e){case $t.TODO:return we.Pending;case $t.IN_PROGRESS:return we.Running;case $t.IN_REVIEW:return we.Review;case $t.DONE:return we.Done;case $t.CANCELLED:return we.Cancelled}}function ix(e){switch(e){case we.Pending:return $t.TODO;case we.Running:return $t.IN_PROGRESS;case we.Review:return $t.IN_REVIEW;case we.Done:return $t.DONE;case we.Cancelled:return $t.CANCELLED}}function nx(e){switch(e){case kt.CLAUDE_CODE:return"Claude Code";case kt.GEMINI_CLI:return"Gemini CLI";case kt.CURSOR_AGENT:return"Cursor Agent";case kt.CODEX:return"Codex";case kt.QWEN_CODE:return"Qwen Code";case kt.KIRO_CLI:return"Kiro CLI";case kt.OPENCODE:return"OpenCode";case kt.PI_CODING_AGENT:return"Pi Coding Agent";case kt.GROK_BUILD:return"Grok Build";case kt.MINION_CODE:return"Minion Code";case kt.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const ii=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Ic(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function ox(e){return{id:e.id,name:e.name,color:e.color||ii[Ic(e.name,ii.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function ax(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:eo(e.status),agent:e.latestAgentType?nx(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function lx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||ii[Ic(s.name,ii.length)],title:e.title,status:eo(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const xa={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 cx(e){const s=e.split("/");return s[s.length-1]||e}function dx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function ux({workingDir:e,filePath:s,type:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=mc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
82
- `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function hx({entry:e,type:s,workingDir:r}){const[o,p]=b.useState(!1),m=xa[e.status]||xa.M,v=dx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:te("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:cx(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsx(ux,{workingDir:r,filePath:e.path,type:s})]})}function ba({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ae(),[v,n]=b.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(hx,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function fx({workingDir:e}){const{t:s}=ae(),{data:r,isLoading:o,isError:p}=yi(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],v=r?.committed||[];return m.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Vs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(ba,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(ba,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Yi=50,_a={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 mx(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function px(e){const s=e.split("/");return s[s.length-1]||e}function gx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function vx({workingDir:e,hash:s,filePath:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=Jn(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
83
- `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function xx({entry:e,workingDir:s,hash:r}){const[o,p]=b.useState(!1),m=_a[e.status]||_a.M,v=gx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:te("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:px(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsx(vx,{workingDir:s,hash:r,filePath:e.path})]})}function bx({commit:e,workingDir:s}){const{t:r}=ae(),[o,p]=b.useState(!1),{data:m,isLoading:v}=Zn(s,o?e.hash:null),n=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:te("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:te("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:mx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(xx,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function _x({workingDir:e}){const{t:s}=ae(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:n}=Tn({queryKey:ce.git.log(e||""),queryFn:({pageParam:l=0})=>Ee.get("/git/log",{params:{workingDir:e||"",limit:String(Yi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Yi?void 0:u.length*Yi,enabled:!!e}),i=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Us,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(l=>t.jsx(bx,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:n,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const yx=br(),Sx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${yx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function wx({status:e}){const s={[we.Running]:"bg-blue-500",[we.Review]:"bg-amber-500",[we.Pending]:"bg-neutral-400",[we.Done]:"bg-emerald-500",[we.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const Cx=[{key:"chat",label:"Chat",icon:ai},{key:"changes",label:"Changes",icon:Vs},{key:"history",label:"History",icon:Us},{key:"workspace",label:"Workspace",icon:di}],kx=[{key:"chat",label:"Team room",icon:ai},{key:"team-status",label:"Team Status",icon:Cs},{key:"changes",label:"Changes",icon:Vs},{key:"workspace",label:"Workspace",icon:di}];function ya({state:e,onRetry:s}){const{t:r}=ae(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(es,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function Ex({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),n=Es(Z=>Z.setVisibleContext),[i,l]=b.useState("chat"),[u,c]=b.useState(""),[g,x]=b.useState(!1),[_,w]=b.useState(!1),[a,h]=b.useState(!1),[d,f]=b.useState(null),[S,C]=b.useState(void 0),k=b.useRef(0),[E,y]=b.useState(),j=b.useRef(null),R=b.useRef(null),L=b.useRef(null),T=b.useRef(null),{scrollRef:D,contentRef:F,isAtBottom:I,scrollToBottom:H,stopScroll:q}=wn({resize:"smooth",initial:"instant"}),A=bt();b.useEffect(()=>{if(!a)return;const Z=de=>{R.current&&!R.current.contains(de.target)&&h(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[a]);const{data:P,isLoading:M}=zn(e.id),{data:O}=Pa(e.id),{data:$}=La(O?.id??""),K=vn(O?.id??""),B=O??null,z=e.isGitRepo!==!1&&e.worktreeReady!==!1,U=b.useMemo(()=>(B?kx:Cx).filter(Z=>z||Z.key!=="changes"&&Z.key!=="history"),[z,B]),N=O===null,{data:W,isLoading:X}=Ia(e.id,N),V=!!e.projectArchivedAt,ie=!!e.projectRepoDeletedAt,ee=v(ie?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");b.useEffect(()=>{C(void 0),f(null),y(void 0)},[e.id]),b.useEffect(()=>{B&&i==="history"&&l("chat"),!B&&i==="team-status"&&l("chat"),U.some(Z=>Z.key===i)||l("chat")},[i,U,B]);const me=b.useMemo(()=>Il(P,B,S),[S,B,P]);b.useEffect(()=>{S&&!P?.some(Z=>Z.id===S)&&C(void 0)},[S,P]);const he=b.useMemo(()=>P?.find(Z=>Z.id===me),[me,P]),G=b.useMemo(()=>{if(P){if(he)return ds(he);for(const Z of P)if(Z.status==="ACTIVE"&&ds(Z))return ds(Z);return ds(P[0])}},[he,P]),pe=he?.status===Mt.ACTIVE?he.id:void 0,oe=z&&Ol(he,B),We=he?.branchName??"",ut=he?.commitMessage,Oe=b.useMemo(()=>Bl(he,P,e?.mainBranch??""),[he,e?.mainBranch,P]),be=!!(oe&&pe&&G&&!V),{data:Ue,isLoading:Be}=Hn(pe??"",{enabled:be}),{data:tt}=yi(G,{enabled:be}),Ye=tt?.committed?.length,[Ze,Xe]=b.useState(!1),[Ne,Ae]=b.useState(null);b.useEffect(()=>{const Z=z&&(i==="changes"||i==="chat"&&be)?"changes":z&&i==="history"?"history":null;if(!pe||!G||!Z){n(null);return}return n({workspaceId:pe,workingDir:G,tab:Z}),()=>{n(null)}},[i,z,pe,n,be,G]);const ve=b.useMemo(()=>Ue?.conflictOp&&Ue.conflictedFiles.length>0?{conflictOp:Ue.conflictOp,conflictedFiles:Ue.conflictedFiles}:Ne,[Ue?.conflictOp,Ue?.conflictedFiles,Ne]),He=ve?.targetWorkspaceId??pe,_e=ve?.targetWorktreePath??he?.worktreePath,pt=ve?.sourceBranch??We,Je=ve?.targetBranch??Oe,Lt=he?.sessions??[],J=b.useCallback(Z=>{Ae(Z??null),Xe(!0)},[]),fe=b.useCallback(()=>e?.id?A.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,A]),ue=b.useCallback(async()=>A.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}),[A,e.id]),ge=b.useMemo(()=>{if(!P)return null;const Z=P.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),de=$e=>{const At=$e.createdAt,Ot=$e.endedAt??$e.startedAt??At;if(!Ot)return 0;const Ms=Date.parse(Ot);return Number.isNaN(Ms)?0:Ms},Fe=$e=>{const At=Z.filter(Ot=>$e.includes(Ot.status));return At.length===0?null:At.sort((Ot,Ms)=>de(Ms)-de(Ot))[0]??null},Pe=Fe([ct.RUNNING])??Fe([ct.PENDING])??Fe([ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(Pe)return Pe;const It=P.filter($e=>($e.status==="ABANDONED"||$e.status==="MERGED"||$e.status==="HIBERNATED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]).filter($e=>[ct.COMPLETED,ct.FAILED,ct.CANCELLED].includes($e.status));return It.length===0?null:It.sort(($e,At)=>de(At)-de($e))[0]??null},[P]),Ce=ge?.id??"",Y=B?d??"":Ce,se=b.useMemo(()=>{if(!d||!P)return null;for(const Z of P){const de=Z.sessions?.find(Fe=>Fe.id===d);if(de)return de}return null},[d,P]),ne=b.useMemo(()=>{if(!d||!B?.invocations)return null;const Z=B.invocations.filter(de=>de.sessionId===d);return Z.length===0?null:Z.sort((de,Fe)=>{const Pe=Date.parse(de.updatedAt??de.createdAt??""),St=Date.parse(Fe.updatedAt??Fe.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(Pe)?0:Pe)})[0]??null},[d,B?.invocations]),ke=b.useMemo(()=>!ne?.memberId||!B?.members?null:B.members.find(Z=>Z.id===ne.memberId)??null,[ne?.memberId,B?.members]),xe=d?se:ge??null,je=xe?.id,Te=b.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!P))return P.find(Z=>Z.sessions?.some(de=>de.id===xe.id))?.id},[xe,P]),ye=b.useCallback((Z,de)=>{const Pe=(de&&P?.some(St=>St.id===de)?de:void 0)??Te??me??void 0;Pe&&C(Pe),k.current+=1,y({id:k.current,source:Z,workspaceId:Pe}),l("workspace")},[Te,me,P]),Le=b.useCallback((Z,de)=>{ye({kind:"web",url:Z},de)},[ye]),Se=b.useCallback((Z,de,Fe)=>{ye({kind:"visualization",sessionId:Z,file:de},Fe)},[ye]),De=b.useCallback(Z=>{Le(Z,Te)},[Te,Le]),Qe=b.useCallback(Z=>{je&&Se(je,Z,Te)},[je,Te,Se]),{isActive:rt,isCancelling:Ct}=Va(je??"",xe?.status),it=b.useMemo(()=>!ge||!P?!1:!P.some(de=>de.status==="ACTIVE"&&de.sessions?.some(Fe=>Fe.id===ge.id)),[ge,P]),{data:nt}=Ks(),[gt,Vt]=b.useState(null),Xt=gt?.sessionId===Ce?gt.providerId:ge?.providerId??null,Nt=b.useCallback(Z=>{Vt({sessionId:Ce,providerId:Z})},[Ce]),Yt=Xa({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Gt=Pc({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Rs=G&&he?he.id:void 0,ss=jn(),Gs=Wn(),Rt=Ga(),{isConnected:vt,isLoadingSnapshot:Qs,isOutputActive:jr,lastExitAt:Nr,logs:gs,entries:at,attach:Qt}=Ja({sessionId:Y,sessionStatus:xe?.status,sessionStartedAt:xe?.startedAt??xe?.createdAt,sessionEndedAt:xe?.endedAt??(rt?null:xe?.updatedAt),onExit:b.useCallback(()=>{A.invalidateQueries({queryKey:["workspaces"]})},[A])}),{todos:vs}=el(at),{files:As,addFiles:xs,removeFile:Rr,clear:Zs,buildMarkdownLinks:Js,hasFiles:Zt,isUploading:Wt}=xn(),er=b.useMemo(()=>Nc(xe),[xe?.tokenUsage]),Ar=Ya(gs,er);b.useEffect(()=>{Y&&vt&&Qt()},[Y,vt,Qt]);const Ts=b.useRef(null);b.useEffect(()=>{if(Ts.current!==e.id&&D.current){const Z=D.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Ts.current=e.id},[e.id,D]);const tr=b.useRef(!1),Tr=b.useCallback(async()=>{if(!u.trim()&&!Zt||!Ce||tr.current||Rt.isPending||Ct||Wt)return;tr.current=!0;const Z=Js(),de=[u.trim(),Z].filter(Boolean).join(`
81
+ `);i(""),It(),A.current&&(A.current.style.height="60px"),As.mutate({id:Je,message:re,providerId:Qe??void 0},{onSuccess:()=>{Z()},onError:()=>{i(Ie=>Ie||re)},onSettled:()=>{ki.current=!1}})},[n,Je,As,Z,At,Ot,$e,It,Qe,is.isPending,Te]),Qc=b.useCallback(()=>{!Je||is.isPending||is.mutate(Je)},[Je,is]),Zc=b.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&Pe(Array.from(re)),Q.target.value=""},[Pe]),Jc=b.useCallback(Q=>{const re=Q.clipboardData.items,Ie=[];for(const ht of re)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Ie.push(ft)}Ie.length>0&&(Q.preventDefault(),Pe(Ie))},[Pe]),[no,Ei]=b.useState(!1),ed=b.useCallback(Q=>{Q.preventDefault(),Ei(!0)},[]),td=b.useCallback(Q=>{Q.preventDefault(),Ei(!1)},[]),sd=b.useCallback(Q=>{Q.preventDefault(),Ei(!1);const re=Q.dataTransfer.files;re.length>0&&Pe(Array.from(re))},[Pe]),Jt=b.useCallback(Q=>{const re=me.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=re?Math.max(Is,re-Yi-ex-tx):Is;return Math.max(Is,Math.min(Math.round(Q),Ie))},[]),ji=b.useCallback(Q=>{const re=Q.clientX-ie.current;W(Jt(ee.current-re))},[Jt]),Ni=b.useCallback(()=>{V(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);b.useEffect(()=>{if(X)return document.addEventListener("mousemove",ji),document.addEventListener("mouseup",Ni),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ji),document.removeEventListener("mouseup",Ni),document.body.style.cursor="",document.body.style.userSelect=""}},[Ni,ji,X]);const rd=b.useCallback(Q=>{Q.preventDefault(),ie.current=Q.clientX,ee.current=N,V(!0)},[N]);b.useEffect(()=>{!z||X||W(Q=>Jt(Q))},[Jt,z,X]),b.useEffect(()=>{if(!z)return;const Q=()=>{W(re=>Jt(re))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Jt,z]);const id=b.useCallback(()=>{W(Q=>Jt(Q)),U(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Jt]),nd=b.useCallback(Q=>{i(Q.target.value);const re=Q.target;re.style.height="auto";const Ie=re.scrollHeight;re.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]),oo=Xt&&ve?t.jsx(Pc,{workspaceId:ve,branchName:ss,targetBranch:Rt,commitMessage:Gs,changes:Gt,gitStatus:Nt,isGitStatusLoading:Yt,canRunGitOperations:He,onOpenChanges:id,onRefreshCommitMessage:vs,onConflict:bs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx(Ic,{taskId:e.id,title:e.title,readOnly:ye})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(rx,{status:e.status,onChangeStatus:!ye&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:tr,disabled:!it||ye,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(di,{size:16})}),(s||tt)&&!ye&&t.jsxs("div",{className:"relative",ref:q,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(nl,{size:16})}),y&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[tt&&t.jsxs("button",{onClick:()=>{g(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ls,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(kd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{_(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(An,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),He&&ve&&Nt&&t.jsx(H0,{workspaceId:ve,gitStatus:Nt,onResolve:()=>bs()}),t.jsxs("div",{ref:me,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ue&&be?R?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:R})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Ac,{session:ue,providers:De,usage:so,providerIdFallback:fe?.providerId,agentTypeFallback:ue?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:wi,children:[t.jsx(Hs,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Vr,{children:t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,scrollElementRef:M,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe})})})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Xr,{todos:de})})})]}):t.jsx(Il,{teamRun:be,messages:ut??be.messages??[],readOnly:ye,readOnlyMessage:Se,onSendMessage:Ci,onViewInvocationSession:Mr,changeSummaryBar:oo,centered:!0,workingDir:it,onOpenWorkspaceFile:he,onOpenPreviewUrl:se,onOpenVisualization:ne}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Xe||Ze?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Xe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ze?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(yn,{urlTransform:J0,components:za,children:Ze.body})}):null}),oe&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[oe.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:oe.currentIndex,total:oe.totalCommands,command:oe.currentCommand})})]}),oe.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),oe.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:oe.error})})]}),!ye&&p&&(pe||pt)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(xa,{state:p,onRetry:p.status==="failed"?Ts:void 0})}):null,pe?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):pt?Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Vr,{children:t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,scrollElementRef:M,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe})}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(es,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(ye?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:ye?Se:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!ye&&p?t.jsx(xa,{state:p}):null,!ye&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Me,{onClick:Ts,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),tt&&t.jsxs(Me,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ls,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Xr,{todos:de})})}),ye?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:Se})})}):Ct?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:Ts,children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:ed,onDragLeave:td,onDrop:sd,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[oo,Je?t.jsx(Za,{sessionId:Je}):null,t.jsxs("div",{ref:H,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${no?"border-info bg-info/5":"border-border"}`,children:[t.jsx(_n,{files:Fe,onRemove:St}),t.jsx("textarea",{ref:A,value:n,onChange:nd,onPaste:Jc,onKeyDown:Q=>{gt.handleKeyDown(Q)||nt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),io())},rows:1,placeholder:v(no?"Drop files here...":pt&&!je?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:Zc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>P.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(Rn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[_e&&De&&t.jsx(Ja,{providers:De,currentProviderId:Qe,agentType:_e.agentType,runtimeType:_e.runtimeType,onSelect:rt}),t.jsx(jn,{usage:so}),je&&!n.trim()&&!At?t.jsx("button",{onClick:Qc,disabled:is.isPending||Te,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ws,{size:14})}):t.jsx("button",{onClick:io,disabled:!n.trim()&&!At||Ot||As.isPending||is.isPending||Te,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||At)&&!Ot&&!As.isPending&&!is.isPending&&!Te?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(kn,{size:18})})]})]})]})]}),t.jsx(Kr,{open:nt.query!==null,anchorRef:H,commands:nt.filteredCommands,selectedIndex:nt.selectedIndex,query:nt.query??"",hasCatalog:nt.allCommands.length>0,onSelect:nt.applyCommand}),t.jsx(Kr,{open:gt.query!==null,anchorRef:H,commands:gt.filteredSkills,selectedIndex:gt.selectedIndex,query:gt.query??"",hasCatalog:gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:gt.applySkill})]})]})}),z&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:rd,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:z?Yi+N:Yi},children:t.jsx(jc,{sessionId:pt||void 0,workspaceId:Ne,workingDir:it,projectId:e.projectId,readOnly:ye,repoDeleted:Le,teamRun:be,teamStatus:be?t.jsx(Hl,{teamRun:be,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,onViewInvocationSession:Mr}):void 0,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,variant:"rail",expanded:z,onExpandedChange:Q=>{Q&&W(re=>Jt(re)),U(Q)},minContentWidth:Is,tabRef:E,gitAvailable:Be,gitProps:He&&ve?{branchName:ss,targetBranch:Rt,commitMessage:Gs,canRunGitOperations:!0,onRefreshCommitMessage:vs,onConflict:bs,onResolveConflicts:()=>bs()}:void 0})})]}),!ye&&t.jsx(Nc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ze?.title??e.title,taskDescription:Ze?.body??"",taskPrompt:Ze?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),tt&&!ye&&t.jsx(W0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),He&&Qs&&vt&&t.jsx(Dc,{open:f,onOpenChange:Q=>{S(Q),Q||k(null)},workspaceId:Qs,conflictOp:vt.conflictOp,conflictedFiles:vt.conflictedFiles,sourceBranch:Nr,targetBranch:gs,operation:Nt?.operation,worktreePath:jr,mergeAborted:vt.mergeAborted,mergeStrategy:vt.mergeStrategy,sourceWorkspaceId:vt.sourceWorkspaceId,targetWorkspaceId:vt.targetWorkspaceId,sourceWorktreePath:vt.sourceWorktreePath,targetWorktreePath:vt.targetWorktreePath,sessions:Rs,currentSessionId:Ue?void 0:pt,teamRunId:be?.id}),t.jsx(Sn,{isOpen:w,onClose:()=>a(!1),onConfirm:Ar,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(qn,{isOpen:x,onClose:()=>_(!1),onConfirm:Tr,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(sx,{})}function to(e){switch(e){case $t.TODO:return we.Pending;case $t.IN_PROGRESS:return we.Running;case $t.IN_REVIEW:return we.Review;case $t.DONE:return we.Done;case $t.CANCELLED:return we.Cancelled}}function nx(e){switch(e){case we.Pending:return $t.TODO;case we.Running:return $t.IN_PROGRESS;case we.Review:return $t.IN_REVIEW;case we.Done:return $t.DONE;case we.Cancelled:return $t.CANCELLED}}function ox(e){switch(e){case kt.CLAUDE_CODE:return"Claude Code";case kt.GEMINI_CLI:return"Gemini CLI";case kt.CURSOR_AGENT:return"Cursor Agent";case kt.CODEX:return"Codex";case kt.QWEN_CODE:return"Qwen Code";case kt.KIRO_CLI:return"Kiro CLI";case kt.OPENCODE:return"OpenCode";case kt.PI_CODING_AGENT:return"Pi Coding Agent";case kt.GROK_BUILD:return"Grok Build";case kt.MINION_CODE:return"Minion Code";case kt.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const ni=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Oc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function ax(e){return{id:e.id,name:e.name,color:e.color||ni[Oc(e.name,ni.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function lx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:to(e.status),agent:e.latestAgentType?ox(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function cx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||ni[Oc(s.name,ni.length)],title:e.title,status:to(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const ba={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 dx(e){const s=e.split("/");return s[s.length-1]||e}function ux(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function hx({workingDir:e,filePath:s,type:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=pc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
82
+ `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function fx({entry:e,type:s,workingDir:r}){const[o,p]=b.useState(!1),m=ba[e.status]||ba.M,v=ux(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:te("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:dx(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsx(hx,{workingDir:r,filePath:e.path,type:s})]})}function _a({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ae(),[v,n]=b.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(fx,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function mx({workingDir:e}){const{t:s}=ae(),{data:r,isLoading:o,isError:p}=Si(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],v=r?.committed||[];return m.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Vs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(_a,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(_a,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Gi=50,ya={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 px(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function gx(e){const s=e.split("/");return s[s.length-1]||e}function vx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function xx({workingDir:e,hash:s,filePath:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=eo(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
83
+ `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function bx({entry:e,workingDir:s,hash:r}){const[o,p]=b.useState(!1),m=ya[e.status]||ya.M,v=vx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:te("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:gx(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsx(xx,{workingDir:s,hash:r,filePath:e.path})]})}function _x({commit:e,workingDir:s}){const{t:r}=ae(),[o,p]=b.useState(!1),{data:m,isLoading:v}=Jn(s,o?e.hash:null),n=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:te("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:te("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:px(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(bx,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function yx({workingDir:e}){const{t:s}=ae(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:n}=Mn({queryKey:ce.git.log(e||""),queryFn:({pageParam:l=0})=>Ee.get("/git/log",{params:{workingDir:e||"",limit:String(Gi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Gi?void 0:u.length*Gi,enabled:!!e}),i=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Us,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(l=>t.jsx(_x,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:n,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const Sx=br(),wx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Sx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Cx({status:e}){const s={[we.Running]:"bg-blue-500",[we.Review]:"bg-amber-500",[we.Pending]:"bg-neutral-400",[we.Done]:"bg-emerald-500",[we.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const kx=[{key:"chat",label:"Chat",icon:li},{key:"changes",label:"Changes",icon:Vs},{key:"history",label:"History",icon:Us},{key:"workspace",label:"Workspace",icon:ui}],Ex=[{key:"chat",label:"Team room",icon:li},{key:"team-status",label:"Team Status",icon:Cs},{key:"changes",label:"Changes",icon:Vs},{key:"workspace",label:"Workspace",icon:ui}];function Sa({state:e,onRetry:s}){const{t:r}=ae(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(es,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function jx({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),n=Es(Z=>Z.setVisibleContext),[i,l]=b.useState("chat"),[u,c]=b.useState(""),[g,x]=b.useState(!1),[_,w]=b.useState(!1),[a,h]=b.useState(!1),[d,f]=b.useState(null),[S,C]=b.useState(void 0),k=b.useRef(0),[E,y]=b.useState(),j=b.useRef(null),R=b.useRef(null),L=b.useRef(null),T=b.useRef(null),{scrollRef:D,contentRef:F,isAtBottom:I,scrollToBottom:H,stopScroll:q}=Cn({resize:"smooth",initial:"instant"}),A=bt();b.useEffect(()=>{if(!a)return;const Z=de=>{R.current&&!R.current.contains(de.target)&&h(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[a]);const{data:P,isLoading:M}=Wn(e.id),{data:O}=La(e.id),{data:$}=Ia(O?.id??""),K=xn(O?.id??""),B=O??null,z=e.isGitRepo!==!1&&e.worktreeReady!==!1,U=b.useMemo(()=>(B?Ex:kx).filter(Z=>z||Z.key!=="changes"&&Z.key!=="history"),[z,B]),N=O===null,{data:W,isLoading:X}=Oa(e.id,N),V=!!e.projectArchivedAt,ie=!!e.projectRepoDeletedAt,ee=v(ie?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");b.useEffect(()=>{C(void 0),f(null),y(void 0)},[e.id]),b.useEffect(()=>{B&&i==="history"&&l("chat"),!B&&i==="team-status"&&l("chat"),U.some(Z=>Z.key===i)||l("chat")},[i,U,B]);const me=b.useMemo(()=>Ol(P,B,S),[S,B,P]);b.useEffect(()=>{S&&!P?.some(Z=>Z.id===S)&&C(void 0)},[S,P]);const he=b.useMemo(()=>P?.find(Z=>Z.id===me),[me,P]),G=b.useMemo(()=>{if(P){if(he)return ds(he);for(const Z of P)if(Z.status==="ACTIVE"&&ds(Z))return ds(Z);return ds(P[0])}},[he,P]),pe=he?.status===Mt.ACTIVE?he.id:void 0,oe=z&&Bl(he,B),We=he?.branchName??"",ut=he?.commitMessage,Oe=b.useMemo(()=>Fl(he,P,e?.mainBranch??""),[he,e?.mainBranch,P]),be=!!(oe&&pe&&G&&!V),{data:Ue,isLoading:Be}=$n(pe??"",{enabled:be}),{data:tt}=Si(G,{enabled:be}),Ye=tt?.committed?.length,[Ze,Xe]=b.useState(!1),[Ne,Ae]=b.useState(null);b.useEffect(()=>{const Z=z&&(i==="changes"||i==="chat"&&be)?"changes":z&&i==="history"?"history":null;if(!pe||!G||!Z){n(null);return}return n({workspaceId:pe,workingDir:G,tab:Z}),()=>{n(null)}},[i,z,pe,n,be,G]);const ve=b.useMemo(()=>Ue?.conflictOp&&Ue.conflictedFiles.length>0?{conflictOp:Ue.conflictOp,conflictedFiles:Ue.conflictedFiles}:Ne,[Ue?.conflictOp,Ue?.conflictedFiles,Ne]),He=ve?.targetWorkspaceId??pe,_e=ve?.targetWorktreePath??he?.worktreePath,pt=ve?.sourceBranch??We,Je=ve?.targetBranch??Oe,Lt=he?.sessions??[],J=b.useCallback(Z=>{Ae(Z??null),Xe(!0)},[]),fe=b.useCallback(()=>e?.id?A.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,A]),ue=b.useCallback(async()=>A.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}),[A,e.id]),ge=b.useMemo(()=>{if(!P)return null;const Z=P.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),de=$e=>{const At=$e.createdAt,Ot=$e.endedAt??$e.startedAt??At;if(!Ot)return 0;const Ms=Date.parse(Ot);return Number.isNaN(Ms)?0:Ms},Fe=$e=>{const At=Z.filter(Ot=>$e.includes(Ot.status));return At.length===0?null:At.sort((Ot,Ms)=>de(Ms)-de(Ot))[0]??null},Pe=Fe([ct.RUNNING])??Fe([ct.PENDING])??Fe([ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(Pe)return Pe;const It=P.filter($e=>($e.status==="ABANDONED"||$e.status==="MERGED"||$e.status==="HIBERNATED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]).filter($e=>[ct.COMPLETED,ct.FAILED,ct.CANCELLED].includes($e.status));return It.length===0?null:It.sort(($e,At)=>de(At)-de($e))[0]??null},[P]),Ce=ge?.id??"",Y=B?d??"":Ce,se=b.useMemo(()=>{if(!d||!P)return null;for(const Z of P){const de=Z.sessions?.find(Fe=>Fe.id===d);if(de)return de}return null},[d,P]),ne=b.useMemo(()=>{if(!d||!B?.invocations)return null;const Z=B.invocations.filter(de=>de.sessionId===d);return Z.length===0?null:Z.sort((de,Fe)=>{const Pe=Date.parse(de.updatedAt??de.createdAt??""),St=Date.parse(Fe.updatedAt??Fe.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(Pe)?0:Pe)})[0]??null},[d,B?.invocations]),ke=b.useMemo(()=>!ne?.memberId||!B?.members?null:B.members.find(Z=>Z.id===ne.memberId)??null,[ne?.memberId,B?.members]),xe=d?se:ge??null,je=xe?.id,Te=b.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!P))return P.find(Z=>Z.sessions?.some(de=>de.id===xe.id))?.id},[xe,P]),ye=b.useCallback((Z,de)=>{const Pe=(de&&P?.some(St=>St.id===de)?de:void 0)??Te??me??void 0;Pe&&C(Pe),k.current+=1,y({id:k.current,source:Z,workspaceId:Pe}),l("workspace")},[Te,me,P]),Le=b.useCallback((Z,de)=>{ye({kind:"web",url:Z},de)},[ye]),Se=b.useCallback((Z,de,Fe)=>{ye({kind:"visualization",sessionId:Z,file:de},Fe)},[ye]),De=b.useCallback(Z=>{Le(Z,Te)},[Te,Le]),Qe=b.useCallback(Z=>{je&&Se(je,Z,Te)},[je,Te,Se]),{isActive:rt,isCancelling:Ct}=Xa(je??"",xe?.status),it=b.useMemo(()=>!ge||!P?!1:!P.some(de=>de.status==="ACTIVE"&&de.sessions?.some(Fe=>Fe.id===ge.id)),[ge,P]),{data:nt}=Ks(),[gt,Vt]=b.useState(null),Xt=gt?.sessionId===Ce?gt.providerId:ge?.providerId??null,Nt=b.useCallback(Z=>{Vt({sessionId:Ce,providerId:Z})},[Ce]),Yt=Ya({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Gt=Lc({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Rs=G&&he?he.id:void 0,ss=Nn(),Gs=Hn(),Rt=Qa(),{isConnected:vt,isLoadingSnapshot:Qs,isOutputActive:jr,lastExitAt:Nr,logs:gs,entries:at,attach:Qt}=el({sessionId:Y,sessionStatus:xe?.status,sessionStartedAt:xe?.startedAt??xe?.createdAt,sessionEndedAt:xe?.endedAt??(rt?null:xe?.updatedAt),onExit:b.useCallback(()=>{A.invalidateQueries({queryKey:["workspaces"]})},[A])}),{todos:vs}=tl(at),{files:As,addFiles:xs,removeFile:Rr,clear:Zs,buildMarkdownLinks:Js,hasFiles:Zt,isUploading:Wt}=bn(),er=b.useMemo(()=>Rc(xe),[xe?.tokenUsage]),Ar=Ga(gs,er);b.useEffect(()=>{Y&&vt&&Qt()},[Y,vt,Qt]);const Ts=b.useRef(null);b.useEffect(()=>{if(Ts.current!==e.id&&D.current){const Z=D.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Ts.current=e.id},[e.id,D]);const tr=b.useRef(!1),Tr=b.useCallback(async()=>{if(!u.trim()&&!Zt||!Ce||tr.current||Rt.isPending||Ct||Wt)return;tr.current=!0;const Z=Js(),de=[u.trim(),Z].filter(Boolean).join(`
84
84
 
85
- `);c(""),Zs(),L.current&&(L.current.style.height="40px"),ss.mutate({id:Ce,message:de,providerId:Xt??void 0},{onSuccess:()=>Qt(),onError:()=>c(Fe=>Fe||de),onSettled:()=>{tr.current=!1}})},[u,Ce,ss,Qt,Zt,Wt,Js,Zs,Xt,Rt.isPending,Ct]),Mr=b.useCallback(()=>{!Ce||Rt.isPending||Rt.mutate(Ce)},[Ce,Rt]),Si=b.useCallback(Z=>K.mutateAsync(Z),[K]),bs=b.useCallback(Z=>{f(Z),l("chat"),requestAnimationFrame(()=>{H()})},[H]),wi=b.useCallback(()=>{f(null)},[]),rs=b.useCallback(()=>{l("changes")},[]),sr=be&&pe?t.jsx(Dc,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,changes:tt,gitStatus:Ue,isGitStatusLoading:Be,canRunGitOperations:oe,onOpenChanges:rs,onRefreshCommitMessage:fe,onConflict:J,className:"mb-2"}):null,Dr=b.useCallback(Z=>{const de=Z.target.files;de&&de.length>0&&xs(Array.from(de)),Z.target.value=""},[xs]),Pr=b.useCallback(Z=>{const de=Z.clipboardData.items,Fe=[];for(const Pe of de)if(Pe.kind==="file"){const St=Pe.getAsFile();St&&Fe.push(St)}Fe.length>0&&(Z.preventDefault(),xs(Fe))},[xs]),Lr=b.useCallback(Z=>{c(Z.target.value);const de=Z.target;de.style.height="auto",de.style.height=`${Math.max(40,Math.min(de.scrollHeight,140))}px`},[]),_s=b.useCallback(()=>{Rs&&Gs.mutate({workspaceId:Rs})},[Gs,Rs]),ys=b.useRef(null);return b.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let de=!1;const Fe=()=>{ys.current&&(ys.current.style.height=`${Z.height}px`,ys.current.style.top=`${Z.offsetTop}px`)},Pe=()=>Fe(),St=()=>{de||Fe()},It=()=>{de=!0},$e=()=>{de=!1,requestAnimationFrame(Fe)};return Z.addEventListener("resize",Pe),Z.addEventListener("scroll",St),document.addEventListener("touchstart",It,{passive:!0}),document.addEventListener("touchend",$e,{passive:!0}),document.addEventListener("touchcancel",$e,{passive:!0}),()=>{Z.removeEventListener("resize",Pe),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",It),document.removeEventListener("touchend",$e),document.removeEventListener("touchcancel",$e)}},[]),b.useEffect(()=>{const Z=ys.current;if(!Z)return;const de=Fe=>{let Pe=Fe.target;for(;Pe&&Pe!==Z;){if(Pe.tagName==="TEXTAREA"){if(Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement;continue}const It=window.getComputedStyle(Pe).overflowY;if((It==="auto"||It==="scroll")&&Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement}Fe.preventDefault()};return Z.addEventListener("touchmove",de,{passive:!1}),()=>Z.removeEventListener("touchmove",de)},[]),t.jsxs("div",{ref:ys,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx($s,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(Lc,{taskId:e.id,title:e.title,readOnly:V,titleClassName:"text-[13px] font-bold text-neutral-900 truncate leading-tight",compact:!0}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(wx,{status:e.status}),t.jsx("button",{onClick:_s,disabled:!Rs||V,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(ci,{size:16})}),r&&!V&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>h(Z=>!Z),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(il,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{w(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(Rn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:U.map(({key:Z,label:de,icon:Fe})=>t.jsxs("button",{onClick:()=>l(Z),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===Z?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Fe,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(de)})]},Z))})]}),i==="chat"&&(B?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Rc,{session:xe,providers:nt,usage:Ar,compact:!0,providerIdFallback:ke?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:wi,children:[t.jsx($s,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:F,children:Qs?t.jsx(Gi,{label:v("Loading logs...")}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(rt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,scrollElementRef:D,onOpenPreviewUrl:De,onOpenVisualization:Qe})})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Vr,{todos:vs,compact:!0})})]}):t.jsx(Ll,{teamRun:B,messages:$??B.messages??[],readOnly:V,readOnlyMessage:ee,onSendMessage:Si,onViewInvocationSession:bs,changeSummaryBar:sr,compactComposer:!0,workingDir:G,onOpenPreviewUrl:Le,onOpenVisualization:Se})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:F,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):W?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(_n,{urlTransform:Sx,components:Fa,children:W.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!V&&p&&(M||Ce)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(ya,{state:p,onRetry:p.status==="failed"?async()=>{await ue(),x(!0)}:void 0})}):null,M?t.jsx(Gi,{label:"Loading..."}):Ce?Qs?t.jsx(Gi,{label:"Loading logs..."}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:rt?"Waiting for agent output...":"No logs recorded."}):t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,scrollElementRef:D,onOpenPreviewUrl:De,onOpenVisualization:Qe}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(es,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:V?ee:v("选择一个 Agent 来执行此任务")}),!V&&p?t.jsx(ya,{state:p}):null,!V&&t.jsxs(Me,{onClick:async()=>{await ue(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Vr,{todos:vs,compact:!0})}),V?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ee})}):it?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:async()=>{await ue(),x(!0)},children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):Ce&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[sr,t.jsx(Qa,{sessionId:Y||Ce,compact:!0}),t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(bn,{files:As,onRemove:Rr}),t.jsx("textarea",{ref:L,value:u,onChange:Lr,onPaste:Pr,onKeyDown:Z=>{Gt.handleKeyDown(Z)||Yt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Tr())},rows:1,placeholder:rt?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:Dr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Nn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ge&&nt&&t.jsx(Za,{providers:nt,currentProviderId:Xt,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Nt}),t.jsx(En,{usage:Ar}),rt&&!u.trim()&&!Zt?t.jsx("button",{onClick:Mr,disabled:Rt.isPending||Ct,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ws,{size:12})}):t.jsx("button",{onClick:Tr,disabled:!u.trim()&&!Zt||Wt||ss.isPending||Rt.isPending||Ct,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Zt)&&!Wt&&!ss.isPending&&!Rt.isPending&&!Ct?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Cn,{size:15})})]})]})]}),t.jsx(Kr,{open:Yt.query!==null,anchorRef:j,commands:Yt.filteredCommands,selectedIndex:Yt.selectedIndex,query:Yt.query??"",hasCatalog:Yt.allCommands.length>0,compact:!0,onSelect:Yt.applyCommand}),t.jsx(Kr,{open:Gt.query!==null,anchorRef:j,commands:Gt.filteredSkills,selectedIndex:Gt.selectedIndex,query:Gt.query??"",hasCatalog:Gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Gt.applySkill})]})]})),i==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Wl,{teamRun:B,workspaces:P,selectedWorkspaceId:me,onSelectWorkspace:C,onViewInvocationSession:bs})}),i==="changes"&&z&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[P&&P.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(kc,{workspaces:P,teamRun:B,selectedWorkspaceId:me,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),oe&&pe&&t.jsx("div",{className:"shrink-0",children:t.jsx(bc,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,committedFileCount:Ye,onRefreshCommitMessage:fe,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(fx,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(_x,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Ec,{sessionId:Ce||void 0,workspaceId:me,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:z,readOnly:V,repoDeleted:ie,previewRequest:E,onPreviewRequestHandled:Z=>{y(de=>de?.id===Z?void 0:de)}})}),!V&&t.jsx(jc,{isOpen:g,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:W?.title??e.title,taskDescription:W?.body??"",taskPrompt:W?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),t.jsx(Un,{isOpen:_,onClose:()=>w(!1),onConfirm:()=>{r?.(e.id),w(!1)},taskId:e.id,taskTitle:e.title,workspaces:P,isLoading:o}),Ze&&ve&&He&&t.jsx(Mc,{open:Ze,onOpenChange:Z=>{Xe(Z),Z||Ae(null)},workspaceId:He,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:pt,targetBranch:Je,operation:Ue?.operation,worktreePath:_e,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Lt,currentSessionId:B?void 0:Ce,teamRunId:B?.id})]})}function Gi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var jx=Object.defineProperty,ni=Object.getOwnPropertySymbols,Oc=Object.prototype.hasOwnProperty,Bc=Object.prototype.propertyIsEnumerable,Sa=(e,s,r)=>s in e?jx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,mn=(e,s)=>{for(var r in s||(s={}))Oc.call(s,r)&&Sa(e,r,s[r]);if(ni)for(var r of ni(s))Bc.call(s,r)&&Sa(e,r,s[r]);return e},pn=(e,s)=>{var r={};for(var o in e)Oc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ni)for(var o of ni(e))s.indexOf(o)<0&&Bc.call(e,o)&&(r[o]=e[o]);return r};var ks;(e=>{const s=class Re{constructor(i,l,u,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let g=[];for(let _=0;_<this.size;_++)g.push(!1);for(let _=0;_<this.size;_++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(u);if(this.drawCodewords(x),c==-1){let _=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const a=this.getPenaltyScore();a<_&&(c=w,_=a),this.applyMask(w)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const u=e.QrSegment.makeSegments(i);return Re.encodeSegments(u,l)}static encodeBinary(i,l){const u=e.QrSegment.makeBytes(i);return Re.encodeSegments([u],l)}static encodeSegments(i,l,u=1,c=40,g=-1,x=!0){if(!(Re.MIN_VERSION<=u&&u<=c&&c<=Re.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let _,w;for(_=u;;_++){const f=Re.getNumDataCodewords(_,l)*8,S=v.getTotalBits(i,_);if(S<=f){w=S;break}if(_>=c)throw new RangeError("Data too long")}for(const f of[Re.Ecc.MEDIUM,Re.Ecc.QUARTILE,Re.Ecc.HIGH])x&&w<=Re.getNumDataCodewords(_,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(_),a);for(const S of f.getData())a.push(S)}p(a.length==w);const h=Re.getNumDataCodewords(_,l)*8;p(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,S)=>d[S>>>3]|=f<<7-(S&7)),new Re(_,l,d,g)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(i[u],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let u=0;u<12;u++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;p(l>>>18==0);for(let u=0;u<18;u++){const c=o(l,u),g=this.size-11+u%3,x=Math.floor(u/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,g,c)}}drawFinderPattern(i,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),x=i+c,_=l+u;0<=x&&x<this.size&&0<=_&&_<this.size&&this.setFunctionModule(x,_,g!=2&&g!=4)}}drawAlignmentPattern(i,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(i,l,u){this.modules[l][i]=u,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,u=this.errorCorrectionLevel;if(i.length!=Re.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=Re.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=Re.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],x=Math.floor(Re.getNumRawDataModules(l)/8),_=c-x%c,w=Math.floor(x/c);let a=[];const h=Re.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=i.slice(S,S+w-g+(f<_?0:1));S+=C.length;const k=Re.reedSolomonComputeRemainder(C,h);f<_&&C.push(0),a.push(C.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((S,C)=>{(f!=w-g||C>=_)&&d.push(S[f])});return p(d.length==x),d}drawCodewords(i){if(i.length!=Math.floor(Re.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const x=u-g,w=(u+1&2)==0?this.size-1-c:c;!this.isFunction[w][x]&&l<i.length*8&&(this.modules[w][x]=o(i[l>>>3],7-(l&7)),l++)}}p(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(i){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[g][a],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[a][g],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const _=this.modules[g][x];_==this.modules[g][x+1]&&_==this.modules[g+1][x]&&_==this.modules[g+1][x+1]&&(i+=Re.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((x,_)=>x+(_?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),i+=c*Re.PENALTY_N4,p(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let u=[6];for(let c=this.size-7;u.length<i;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(i){if(i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const u=Math.floor(i/7)+2;l-=(25*u-10)*u-55,i>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(Re.getNumRawDataModules(i)/8)-Re.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*Re.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<i;c++){for(let g=0;g<l.length;g++)l[g]=Re.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=Re.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(i,l){let u=l.map(c=>0);for(const c of i){const g=c^u.shift();u.push(0),l.forEach((x,_)=>u[_]^=Re.reedSolomonMultiply(x,g))}return u}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*i;return p(u>>>8==0),u}finderPenaltyCountPatterns(i){const l=i[1];p(l<=this.size*3);const u=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(u&&i[0]>=l*4&&i[6]>=l?1:0)+(u&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,u){return i&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let u=i-1;u>=0;u--)l.push(n>>>u&1)}function o(n,i){return(n>>>i&1)!=0}function p(n){if(!n)throw new Error("Assertion error")}const m=class et{constructor(i,l,u){if(this.mode=i,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(i){let l=[];for(const u of i)r(u,8,l);return new et(et.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!et.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<i.length;){const c=Math.min(i.length-u,3);r(parseInt(i.substring(u,u+c),10),c*3+1,l),u+=c}return new et(et.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!et.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=i.length;u+=2){let c=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u))*45;c+=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u+1)),r(c,11,l)}return u<i.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u)),6,l),new et(et.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:et.isNumeric(i)?[et.makeNumeric(i)]:et.isAlphanumeric(i)?[et.makeAlphanumeric(i)]:[et.makeBytes(et.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,l)}static isNumeric(i){return et.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return et.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let u=0;for(const c of i){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let u=0;u<i.length;u++)i.charAt(u)!="%"?l.push(i.charCodeAt(u)):(l.push(parseInt(i.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(ks||(ks={}));var Fs=ks;var Nx={L:Fs.QrCode.Ecc.LOW,M:Fs.QrCode.Ecc.MEDIUM,Q:Fs.QrCode.Ecc.QUARTILE,H:Fs.QrCode.Ecc.HIGH},Fc=128,zc="L",Wc="#FFFFFF",Hc="#000000",$c=!1,Uc=1,Rx=4,Ax=0,Tx=.1;function qc(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(v,n){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${n-m}v1H${m+s}z`),m=null;return}if(n===o.length-1){if(!v)return;m===null?r.push(`M${n+s},${p+s} h1v1H${n+s}z`):r.push(`M${m+s},${p+s} h${n+1-m}v1H${m+s}z`);return}v&&m===null&&(m=n)})}),r.join("")}function Kc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function Mx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Tx),v=p/s,n=(o.width||m)*v,i=(o.height||m)*v,l=o.x==null?e.length/2-n/2:o.x*v,u=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let _=Math.floor(l),w=Math.floor(u),a=Math.ceil(n+l-_),h=Math.ceil(i+u-w);g={x:_,y:w,w:a,h}}const x=o.crossOrigin;return{x:l,y:u,h:i,w:n,excavation:g,opacity:c,crossOrigin:x}}function Dx(e,s){return s!=null?Math.max(Math.floor(s),0):e?Rx:Ax}function Vc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:n}){let i=le.useMemo(()=>{const _=(Array.isArray(e)?e:[e]).reduce((w,a)=>(w.push(...Fs.QrSegment.makeSegments(a)),w),[]);return Fs.QrCode.encodeSegments(_,Nx[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=le.useMemo(()=>{let x=i.getModules();const _=Dx(o,p),w=x.length+_*2,a=Mx(x,v,_,m);return{cells:x,margin:_,numCells:w,calculatedImageSettings:a}},[i,v,m,o,p]);return{qrcode:i,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var Px=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Lx=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Fc,level:v=zc,bgColor:n=Wc,fgColor:i=Hc,includeMargin:l=$c,minVersion:u=Uc,boostLevel:c,marginSize:g,imageSettings:x}=o,w=pn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=w,h=pn(w,["style"]),d=x?.src,f=le.useRef(null),S=le.useRef(null),C=le.useCallback(F=>{f.current=F,typeof r=="function"?r(F):r&&(r.current=F)},[r]),[k,E]=le.useState(!1),{margin:y,cells:j,numCells:R,calculatedImageSettings:L}=Vc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:x,size:m});le.useEffect(()=>{if(f.current!=null){const F=f.current,I=F.getContext("2d");if(!I)return;let H=j;const q=S.current,A=L!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;A&&L.excavation!=null&&(H=Kc(j,L.excavation));const P=window.devicePixelRatio||1;F.height=F.width=m*P;const M=m/R*P;I.scale(M,M),I.fillStyle=n,I.fillRect(0,0,R,R),I.fillStyle=i,Px?I.fill(new Path2D(qc(H,y))):j.forEach(function(O,$){O.forEach(function(K,B){K&&I.fillRect(B+y,$+y,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(q,L.x+y,L.y+y,L.w,L.h)}}),le.useEffect(()=>{E(!1)},[d]);const T=mn({height:m,width:m},a);let D=null;return d!=null&&(D=le.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:S,crossOrigin:L?.crossOrigin})),le.createElement(le.Fragment,null,le.createElement("canvas",mn({style:T,height:m,width:m,ref:C,role:"img"},h)),D)});Lx.displayName="QRCodeCanvas";var Xc=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Fc,level:v=zc,bgColor:n=Wc,fgColor:i=Hc,includeMargin:l=$c,minVersion:u=Uc,boostLevel:c,title:g,marginSize:x,imageSettings:_}=o,w=pn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=Vc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:_,size:m});let S=h,C=null;_!=null&&f!=null&&(f.excavation!=null&&(S=Kc(h,f.excavation)),C=le.createElement("image",{href:_.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=qc(S,a);return le.createElement("svg",mn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&le.createElement("title",null,g),le.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),le.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});Xc.displayName="QRCodeSVG";function Yc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Ix(){return jt({queryKey:ce.tunnel.status,queryFn:()=>Ee.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Ox(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/start",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Bx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/regenerate",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Fx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function zx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function Wx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function Hx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function wa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function or(e){const s=e?.trim();return s||null}function $x(e){if(!e)return"";const s=[or(e.lastLocalError),or(e.lastRemoteError),or(e.lastError)].filter(p=>p!==null),r=or(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!or(e.lastError));return r&&o&&s.push(r),s.join(`
86
- `)}function Ca(){const{t:e}=ae(),{data:s}=Ix(),r=Ox(),o=Fx(),p=Bx(),[m,v]=b.useState(!1),[n,i]=b.useState(null),l=b.useRef(null),[u,c]=b.useState({top:0,right:0}),[g,x]=b.useState(!1),[_,w]=b.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,S=s?.token,C=zx(s),k=Wx(s),E=$x(s);b.useEffect(()=>{if(m&&l.current){const F=l.current.getBoundingClientRect();c({top:F.bottom+8,right:window.innerWidth-F.right})}},[m]);const y=b.useCallback(()=>{v(!0)},[a]),j=b.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),R=b.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),L=b.useCallback(()=>{S&&(navigator.clipboard.writeText(S),i("token"),setTimeout(()=>i(null),2e3))},[S]),T=b.useCallback(()=>{o.mutate(),v(!1),x(!1),w(!1)},[o]),D=b.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{w(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:y,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(ze,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(js,{size:16}):t.jsx(go,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!a&&Ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(go,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(qt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(ze,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&Ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(Hx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(qt,{size:14})})]}),S&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(Wd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Xc,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:F=>F.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(Kt,{size:14,className:"text-emerald-500"}):t.jsx(mo,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:wa(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:wa(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),S&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>x(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:S}),t.jsx("button",{onClick:L,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:n==="token"?t.jsx(Kt,{size:14,className:"text-emerald-500"}):t.jsx(mo,{size:14})})]})]}),_&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!_&&t.jsxs("button",{onClick:()=>w(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(Ns,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Qi({isOpen:e,onClose:s}){const{t:r}=ae(),o=Xd(),[p,m]=b.useState(""),[v,n]=b.useState(""),[i,l]=b.useState(null),[u,c]=b.useState(!1),[g,x]=b.useState(!1),_=p.trim(),w=v.trim(),a=u||o.isPending,h=b.useMemo(()=>!!(_&&w&&!a),[_,w,a]),d=b.useCallback(()=>{m(""),n(""),l(null),x(!1)},[]),f=b.useCallback(()=>{a||(d(),s())},[a,s,d]);b.useEffect(()=>{e||d()},[e,d]);const S=b.useCallback(async y=>{try{await o.mutateAsync({name:_,repoPath:w,initEmptyRepo:y}),d(),s()}catch(j){const R=j instanceof Error?j.message:r("Failed to create project");l(R),st.error(R)}},[o,s,d,r,_,w]),C=b.useCallback(async()=>{if(!(!_||!w||a)){l(null),c(!0);try{const y=await Ee.get("/filesystem/validate",{params:{path:w}});if(!y.valid){l(y.error??r("Selected path is not a valid directory"));return}if(y.isGitRepo){await S(!1);return}if(y.reason==="no_git"&&y.isEmpty){x(!0);return}if(y.reason==="no_git"){await S(!1);return}await S(!1)}catch(y){l(y instanceof Error?y.message:r("Could not check project path"))}finally{c(!1)}}},[S,a,r,_,w]),k=b.useCallback(()=>{x(!1),S(!1)},[S]),E=b.useCallback(()=>{x(!1),S(!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx(fs,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:y=>m(y.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(Ud,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(fs,{isOpen:g,onClose:()=>{o.isPending||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function ka(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Ux(e){return e.map((s,r)=>({project:s,index:r,activityTime:ka(s.lastActivityAt??s.createdAt),createdTime:ka(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const p=r.createdTime-s.createdTime;return p!==0?p:s.index-r.index}).map(({project:s})=>s)}function Ea({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ae(),[v,n]=b.useState(!1),i=e.filter(u=>!u.archivedAt),l=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:te("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>n(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Hs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:m("All Projects")}),t.jsx(wt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>n(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Hs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(Kt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:i.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:u.name}),c?t.jsx(Kt,{size:14,className:"text-foreground shrink-0"}):null]},u.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{n(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(ls,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function ja(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const qx=260,Kx=600,Na=400,Vx=100,Xx=1e3;function Yx(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,...s?{preferredWorkspace:{...s.workspaceKind===_t.MAIN_DIRECTORY?{workspaceKind:_t.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(p=>p.status==="RUNNING"||p.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function Gx(){const{t:e,locale:s}=ae(),[r,o]=b.useState(null),[p,m]=b.useState(null),[v,n]=b.useState(Na),[i,l]=b.useState(!1),[u,c]=b.useState("idle"),[g,x]=b.useState({}),_=b.useRef(!1),w=b.useRef(0),a=b.useRef(Na),h=b.useRef(null),d=bt(),{data:f,isLoading:S}=Ks(),{data:C,isLoading:k}=Yd({limit:Vx}),E=b.useMemo(()=>C?.data??[],[C?.data]),y=p&&E.some(J=>J.id===p)?p:null,{data:j,isLoading:R}=kd({...y?{projectId:y}:{},limit:Xx}),L=b.useMemo(()=>j?.data??[],[j?.data]),[T,D]=b.useState([]),F=b.useMemo(()=>{if(T.length===0)return L;const J=new Set(L.map(fe=>fe.id));return[...T.filter(fe=>!J.has(fe.id)),...L]},[L,T]),[I,H]=b.useState(null),q=b.useMemo(()=>r&&F.some(J=>J.id===r)?r:I&&r===I?I:null,[r,F,I]);b.useEffect(()=>{I&&F.some(J=>J.id===I)&&H(null)},[I,F]),b.useEffect(()=>{if(T.length===0)return;const J=new Set(L.map(fe=>fe.id));T.some(fe=>J.has(fe.id))&&D(fe=>fe.filter(ue=>!J.has(ue.id)))},[L,T]);const A=b.useMemo(()=>Ux(E),[E]),P=b.useMemo(()=>A.map(ox),[A]),M=b.useMemo(()=>A.filter(J=>!J.archivedAt),[A]),O=b.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),fe=J?JSON.parse(J):{};return[...f].sort((ue,ge)=>{const Ce=ue.availability.type!=="NOT_FOUND",Y=ge.availability.type!=="NOT_FOUND";if(Ce!==Y)return Ce?-1:1;const se=fe[ue.provider.id]??0;return(fe[ge.provider.id]??0)-se})},[f]),$=b.useMemo(()=>F.map(J=>ax(J,E.find(fe=>fe.id===J.projectId))),[E,F]),K=b.useMemo(()=>{if(!q)return null;const J=F.find(ue=>ue.id===q);if(!J)return null;const fe=E.find(ue=>ue.id===J.projectId);if(!fe){const ue=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:eo(J.status),branch:ue,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return lx(J,fe)},[q,F,E]),B=Da(),z=Ed(),U=jd(),N=kn(),W=b.useCallback(J=>{const fe=Yx(J);D(ue=>ue.some(ge=>ge.id===J.id)?ue.map(ge=>ge.id===J.id?fe:ge):[fe,...ue]),d.setQueryData(ce.tasks.detail(J.id),J),H(J.id),o(J.id)},[d]),X=b.useCallback((J,fe,ue)=>{const ge=J.id,Ce=[J.title,J.description].filter(Boolean).join(`
85
+ `);c(""),Zs(),L.current&&(L.current.style.height="40px"),ss.mutate({id:Ce,message:de,providerId:Xt??void 0},{onSuccess:()=>Qt(),onError:()=>c(Fe=>Fe||de),onSettled:()=>{tr.current=!1}})},[u,Ce,ss,Qt,Zt,Wt,Js,Zs,Xt,Rt.isPending,Ct]),Mr=b.useCallback(()=>{!Ce||Rt.isPending||Rt.mutate(Ce)},[Ce,Rt]),wi=b.useCallback(Z=>K.mutateAsync(Z),[K]),bs=b.useCallback(Z=>{f(Z),l("chat"),requestAnimationFrame(()=>{H()})},[H]),Ci=b.useCallback(()=>{f(null)},[]),rs=b.useCallback(()=>{l("changes")},[]),sr=be&&pe?t.jsx(Pc,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,changes:tt,gitStatus:Ue,isGitStatusLoading:Be,canRunGitOperations:oe,onOpenChanges:rs,onRefreshCommitMessage:fe,onConflict:J,className:"mb-2"}):null,Dr=b.useCallback(Z=>{const de=Z.target.files;de&&de.length>0&&xs(Array.from(de)),Z.target.value=""},[xs]),Pr=b.useCallback(Z=>{const de=Z.clipboardData.items,Fe=[];for(const Pe of de)if(Pe.kind==="file"){const St=Pe.getAsFile();St&&Fe.push(St)}Fe.length>0&&(Z.preventDefault(),xs(Fe))},[xs]),Lr=b.useCallback(Z=>{c(Z.target.value);const de=Z.target;de.style.height="auto",de.style.height=`${Math.max(40,Math.min(de.scrollHeight,140))}px`},[]),_s=b.useCallback(()=>{Rs&&Gs.mutate({workspaceId:Rs})},[Gs,Rs]),ys=b.useRef(null);return b.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let de=!1;const Fe=()=>{ys.current&&(ys.current.style.height=`${Z.height}px`,ys.current.style.top=`${Z.offsetTop}px`)},Pe=()=>Fe(),St=()=>{de||Fe()},It=()=>{de=!0},$e=()=>{de=!1,requestAnimationFrame(Fe)};return Z.addEventListener("resize",Pe),Z.addEventListener("scroll",St),document.addEventListener("touchstart",It,{passive:!0}),document.addEventListener("touchend",$e,{passive:!0}),document.addEventListener("touchcancel",$e,{passive:!0}),()=>{Z.removeEventListener("resize",Pe),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",It),document.removeEventListener("touchend",$e),document.removeEventListener("touchcancel",$e)}},[]),b.useEffect(()=>{const Z=ys.current;if(!Z)return;const de=Fe=>{let Pe=Fe.target;for(;Pe&&Pe!==Z;){if(Pe.tagName==="TEXTAREA"){if(Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement;continue}const It=window.getComputedStyle(Pe).overflowY;if((It==="auto"||It==="scroll")&&Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement}Fe.preventDefault()};return Z.addEventListener("touchmove",de,{passive:!1}),()=>Z.removeEventListener("touchmove",de)},[]),t.jsxs("div",{ref:ys,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Hs,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(Ic,{taskId:e.id,title:e.title,readOnly:V,titleClassName:"text-[13px] font-bold text-neutral-900 truncate leading-tight",compact:!0}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(Cx,{status:e.status}),t.jsx("button",{onClick:_s,disabled:!Rs||V,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(di,{size:16})}),r&&!V&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>h(Z=>!Z),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(nl,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{w(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(An,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:U.map(({key:Z,label:de,icon:Fe})=>t.jsxs("button",{onClick:()=>l(Z),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===Z?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Fe,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(de)})]},Z))})]}),i==="chat"&&(B?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Ac,{session:xe,providers:nt,usage:Ar,compact:!0,providerIdFallback:ke?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:Ci,children:[t.jsx(Hs,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:F,children:Qs?t.jsx(Qi,{label:v("Loading logs...")}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(rt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Vr,{children:t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,scrollElementRef:D,onOpenPreviewUrl:De,onOpenVisualization:Qe})})})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Xr,{todos:vs,compact:!0})})]}):t.jsx(Il,{teamRun:B,messages:$??B.messages??[],readOnly:V,readOnlyMessage:ee,onSendMessage:wi,onViewInvocationSession:bs,changeSummaryBar:sr,compactComposer:!0,workingDir:G,onOpenPreviewUrl:Le,onOpenVisualization:Se})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:F,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):W?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(yn,{urlTransform:wx,components:za,children:W.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!V&&p&&(M||Ce)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(Sa,{state:p,onRetry:p.status==="failed"?async()=>{await ue(),x(!0)}:void 0})}):null,M?t.jsx(Qi,{label:"Loading..."}):Ce?Qs?t.jsx(Qi,{label:"Loading logs..."}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:rt?"Waiting for agent output...":"No logs recorded."}):t.jsx(Vr,{children:t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,scrollElementRef:D,onOpenPreviewUrl:De,onOpenVisualization:Qe})}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(es,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:V?ee:v("选择一个 Agent 来执行此任务")}),!V&&p?t.jsx(Sa,{state:p}):null,!V&&t.jsxs(Me,{onClick:async()=>{await ue(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Xr,{todos:vs,compact:!0})}),V?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ee})}):it?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:async()=>{await ue(),x(!0)},children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):Ce&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[sr,t.jsx(Za,{sessionId:Y||Ce,compact:!0}),t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(_n,{files:As,onRemove:Rr}),t.jsx("textarea",{ref:L,value:u,onChange:Lr,onPaste:Pr,onKeyDown:Z=>{Gt.handleKeyDown(Z)||Yt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Tr())},rows:1,placeholder:rt?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:Dr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Rn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ge&&nt&&t.jsx(Ja,{providers:nt,currentProviderId:Xt,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Nt}),t.jsx(jn,{usage:Ar}),rt&&!u.trim()&&!Zt?t.jsx("button",{onClick:Mr,disabled:Rt.isPending||Ct,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ws,{size:12})}):t.jsx("button",{onClick:Tr,disabled:!u.trim()&&!Zt||Wt||ss.isPending||Rt.isPending||Ct,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Zt)&&!Wt&&!ss.isPending&&!Rt.isPending&&!Ct?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(kn,{size:15})})]})]})]}),t.jsx(Kr,{open:Yt.query!==null,anchorRef:j,commands:Yt.filteredCommands,selectedIndex:Yt.selectedIndex,query:Yt.query??"",hasCatalog:Yt.allCommands.length>0,compact:!0,onSelect:Yt.applyCommand}),t.jsx(Kr,{open:Gt.query!==null,anchorRef:j,commands:Gt.filteredSkills,selectedIndex:Gt.selectedIndex,query:Gt.query??"",hasCatalog:Gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Gt.applySkill})]})]})),i==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Hl,{teamRun:B,workspaces:P,selectedWorkspaceId:me,onSelectWorkspace:C,onViewInvocationSession:bs})}),i==="changes"&&z&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[P&&P.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Ec,{workspaces:P,teamRun:B,selectedWorkspaceId:me,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),oe&&pe&&t.jsx("div",{className:"shrink-0",children:t.jsx(_c,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,committedFileCount:Ye,onRefreshCommitMessage:fe,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(mx,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(yx,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(jc,{sessionId:Ce||void 0,workspaceId:me,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:z,readOnly:V,repoDeleted:ie,previewRequest:E,onPreviewRequestHandled:Z=>{y(de=>de?.id===Z?void 0:de)}})}),!V&&t.jsx(Nc,{isOpen:g,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:W?.title??e.title,taskDescription:W?.body??"",taskPrompt:W?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),t.jsx(qn,{isOpen:_,onClose:()=>w(!1),onConfirm:()=>{r?.(e.id),w(!1)},taskId:e.id,taskTitle:e.title,workspaces:P,isLoading:o}),Ze&&ve&&He&&t.jsx(Dc,{open:Ze,onOpenChange:Z=>{Xe(Z),Z||Ae(null)},workspaceId:He,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:pt,targetBranch:Je,operation:Ue?.operation,worktreePath:_e,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Lt,currentSessionId:B?void 0:Ce,teamRunId:B?.id})]})}function Qi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var Nx=Object.defineProperty,oi=Object.getOwnPropertySymbols,Bc=Object.prototype.hasOwnProperty,Fc=Object.prototype.propertyIsEnumerable,wa=(e,s,r)=>s in e?Nx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,pn=(e,s)=>{for(var r in s||(s={}))Bc.call(s,r)&&wa(e,r,s[r]);if(oi)for(var r of oi(s))Fc.call(s,r)&&wa(e,r,s[r]);return e},gn=(e,s)=>{var r={};for(var o in e)Bc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&oi)for(var o of oi(e))s.indexOf(o)<0&&Fc.call(e,o)&&(r[o]=e[o]);return r};var ks;(e=>{const s=class Re{constructor(i,l,u,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let g=[];for(let _=0;_<this.size;_++)g.push(!1);for(let _=0;_<this.size;_++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(u);if(this.drawCodewords(x),c==-1){let _=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const a=this.getPenaltyScore();a<_&&(c=w,_=a),this.applyMask(w)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const u=e.QrSegment.makeSegments(i);return Re.encodeSegments(u,l)}static encodeBinary(i,l){const u=e.QrSegment.makeBytes(i);return Re.encodeSegments([u],l)}static encodeSegments(i,l,u=1,c=40,g=-1,x=!0){if(!(Re.MIN_VERSION<=u&&u<=c&&c<=Re.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let _,w;for(_=u;;_++){const f=Re.getNumDataCodewords(_,l)*8,S=v.getTotalBits(i,_);if(S<=f){w=S;break}if(_>=c)throw new RangeError("Data too long")}for(const f of[Re.Ecc.MEDIUM,Re.Ecc.QUARTILE,Re.Ecc.HIGH])x&&w<=Re.getNumDataCodewords(_,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(_),a);for(const S of f.getData())a.push(S)}p(a.length==w);const h=Re.getNumDataCodewords(_,l)*8;p(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,S)=>d[S>>>3]|=f<<7-(S&7)),new Re(_,l,d,g)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(i[u],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let u=0;u<12;u++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;p(l>>>18==0);for(let u=0;u<18;u++){const c=o(l,u),g=this.size-11+u%3,x=Math.floor(u/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,g,c)}}drawFinderPattern(i,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),x=i+c,_=l+u;0<=x&&x<this.size&&0<=_&&_<this.size&&this.setFunctionModule(x,_,g!=2&&g!=4)}}drawAlignmentPattern(i,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(i,l,u){this.modules[l][i]=u,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,u=this.errorCorrectionLevel;if(i.length!=Re.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=Re.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=Re.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],x=Math.floor(Re.getNumRawDataModules(l)/8),_=c-x%c,w=Math.floor(x/c);let a=[];const h=Re.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=i.slice(S,S+w-g+(f<_?0:1));S+=C.length;const k=Re.reedSolomonComputeRemainder(C,h);f<_&&C.push(0),a.push(C.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((S,C)=>{(f!=w-g||C>=_)&&d.push(S[f])});return p(d.length==x),d}drawCodewords(i){if(i.length!=Math.floor(Re.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const x=u-g,w=(u+1&2)==0?this.size-1-c:c;!this.isFunction[w][x]&&l<i.length*8&&(this.modules[w][x]=o(i[l>>>3],7-(l&7)),l++)}}p(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(i){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[g][a],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[a][g],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const _=this.modules[g][x];_==this.modules[g][x+1]&&_==this.modules[g+1][x]&&_==this.modules[g+1][x+1]&&(i+=Re.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((x,_)=>x+(_?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),i+=c*Re.PENALTY_N4,p(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let u=[6];for(let c=this.size-7;u.length<i;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(i){if(i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const u=Math.floor(i/7)+2;l-=(25*u-10)*u-55,i>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(Re.getNumRawDataModules(i)/8)-Re.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*Re.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<i;c++){for(let g=0;g<l.length;g++)l[g]=Re.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=Re.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(i,l){let u=l.map(c=>0);for(const c of i){const g=c^u.shift();u.push(0),l.forEach((x,_)=>u[_]^=Re.reedSolomonMultiply(x,g))}return u}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*i;return p(u>>>8==0),u}finderPenaltyCountPatterns(i){const l=i[1];p(l<=this.size*3);const u=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(u&&i[0]>=l*4&&i[6]>=l?1:0)+(u&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,u){return i&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let u=i-1;u>=0;u--)l.push(n>>>u&1)}function o(n,i){return(n>>>i&1)!=0}function p(n){if(!n)throw new Error("Assertion error")}const m=class et{constructor(i,l,u){if(this.mode=i,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(i){let l=[];for(const u of i)r(u,8,l);return new et(et.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!et.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<i.length;){const c=Math.min(i.length-u,3);r(parseInt(i.substring(u,u+c),10),c*3+1,l),u+=c}return new et(et.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!et.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=i.length;u+=2){let c=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u))*45;c+=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u+1)),r(c,11,l)}return u<i.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u)),6,l),new et(et.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:et.isNumeric(i)?[et.makeNumeric(i)]:et.isAlphanumeric(i)?[et.makeAlphanumeric(i)]:[et.makeBytes(et.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,l)}static isNumeric(i){return et.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return et.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let u=0;for(const c of i){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let u=0;u<i.length;u++)i.charAt(u)!="%"?l.push(i.charCodeAt(u)):(l.push(parseInt(i.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(ks||(ks={}));var Fs=ks;var Rx={L:Fs.QrCode.Ecc.LOW,M:Fs.QrCode.Ecc.MEDIUM,Q:Fs.QrCode.Ecc.QUARTILE,H:Fs.QrCode.Ecc.HIGH},zc=128,Wc="L",Hc="#FFFFFF",$c="#000000",Uc=!1,qc=1,Ax=4,Tx=0,Mx=.1;function Kc(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(v,n){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${n-m}v1H${m+s}z`),m=null;return}if(n===o.length-1){if(!v)return;m===null?r.push(`M${n+s},${p+s} h1v1H${n+s}z`):r.push(`M${m+s},${p+s} h${n+1-m}v1H${m+s}z`);return}v&&m===null&&(m=n)})}),r.join("")}function Vc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function Dx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Mx),v=p/s,n=(o.width||m)*v,i=(o.height||m)*v,l=o.x==null?e.length/2-n/2:o.x*v,u=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let _=Math.floor(l),w=Math.floor(u),a=Math.ceil(n+l-_),h=Math.ceil(i+u-w);g={x:_,y:w,w:a,h}}const x=o.crossOrigin;return{x:l,y:u,h:i,w:n,excavation:g,opacity:c,crossOrigin:x}}function Px(e,s){return s!=null?Math.max(Math.floor(s),0):e?Ax:Tx}function Xc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:n}){let i=le.useMemo(()=>{const _=(Array.isArray(e)?e:[e]).reduce((w,a)=>(w.push(...Fs.QrSegment.makeSegments(a)),w),[]);return Fs.QrCode.encodeSegments(_,Rx[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=le.useMemo(()=>{let x=i.getModules();const _=Px(o,p),w=x.length+_*2,a=Dx(x,v,_,m);return{cells:x,margin:_,numCells:w,calculatedImageSettings:a}},[i,v,m,o,p]);return{qrcode:i,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var Lx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ix=le.forwardRef(function(s,r){const o=s,{value:p,size:m=zc,level:v=Wc,bgColor:n=Hc,fgColor:i=$c,includeMargin:l=Uc,minVersion:u=qc,boostLevel:c,marginSize:g,imageSettings:x}=o,w=gn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=w,h=gn(w,["style"]),d=x?.src,f=le.useRef(null),S=le.useRef(null),C=le.useCallback(F=>{f.current=F,typeof r=="function"?r(F):r&&(r.current=F)},[r]),[k,E]=le.useState(!1),{margin:y,cells:j,numCells:R,calculatedImageSettings:L}=Xc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:x,size:m});le.useEffect(()=>{if(f.current!=null){const F=f.current,I=F.getContext("2d");if(!I)return;let H=j;const q=S.current,A=L!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;A&&L.excavation!=null&&(H=Vc(j,L.excavation));const P=window.devicePixelRatio||1;F.height=F.width=m*P;const M=m/R*P;I.scale(M,M),I.fillStyle=n,I.fillRect(0,0,R,R),I.fillStyle=i,Lx?I.fill(new Path2D(Kc(H,y))):j.forEach(function(O,$){O.forEach(function(K,B){K&&I.fillRect(B+y,$+y,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(q,L.x+y,L.y+y,L.w,L.h)}}),le.useEffect(()=>{E(!1)},[d]);const T=pn({height:m,width:m},a);let D=null;return d!=null&&(D=le.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:S,crossOrigin:L?.crossOrigin})),le.createElement(le.Fragment,null,le.createElement("canvas",pn({style:T,height:m,width:m,ref:C,role:"img"},h)),D)});Ix.displayName="QRCodeCanvas";var Yc=le.forwardRef(function(s,r){const o=s,{value:p,size:m=zc,level:v=Wc,bgColor:n=Hc,fgColor:i=$c,includeMargin:l=Uc,minVersion:u=qc,boostLevel:c,title:g,marginSize:x,imageSettings:_}=o,w=gn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=Xc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:_,size:m});let S=h,C=null;_!=null&&f!=null&&(f.excavation!=null&&(S=Vc(h,f.excavation)),C=le.createElement("image",{href:_.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=Kc(S,a);return le.createElement("svg",pn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&le.createElement("title",null,g),le.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),le.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});Yc.displayName="QRCodeSVG";function Gc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Ox(){return jt({queryKey:ce.tunnel.status,queryFn:()=>Ee.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Bx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/start",{port:Gc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Fx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/regenerate",{port:Gc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function zx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Wx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function Hx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function $x(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function Ca(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function or(e){const s=e?.trim();return s||null}function Ux(e){if(!e)return"";const s=[or(e.lastLocalError),or(e.lastRemoteError),or(e.lastError)].filter(p=>p!==null),r=or(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!or(e.lastError));return r&&o&&s.push(r),s.join(`
86
+ `)}function ka(){const{t:e}=ae(),{data:s}=Ox(),r=Bx(),o=zx(),p=Fx(),[m,v]=b.useState(!1),[n,i]=b.useState(null),l=b.useRef(null),[u,c]=b.useState({top:0,right:0}),[g,x]=b.useState(!1),[_,w]=b.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,S=s?.token,C=Wx(s),k=Hx(s),E=Ux(s);b.useEffect(()=>{if(m&&l.current){const F=l.current.getBoundingClientRect();c({top:F.bottom+8,right:window.innerWidth-F.right})}},[m]);const y=b.useCallback(()=>{v(!0)},[a]),j=b.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),R=b.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),L=b.useCallback(()=>{S&&(navigator.clipboard.writeText(S),i("token"),setTimeout(()=>i(null),2e3))},[S]),T=b.useCallback(()=>{o.mutate(),v(!1),x(!1),w(!1)},[o]),D=b.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{w(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:y,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(ze,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(js,{size:16}):t.jsx(vo,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!a&&Ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(vo,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(qt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(ze,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&Ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e($x(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(qt,{size:14})})]}),S&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(Hd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Yc,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:F=>F.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(Kt,{size:14,className:"text-emerald-500"}):t.jsx(po,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Ca(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Ca(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),S&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>x(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:S}),t.jsx("button",{onClick:L,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:n==="token"?t.jsx(Kt,{size:14,className:"text-emerald-500"}):t.jsx(po,{size:14})})]})]}),_&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!_&&t.jsxs("button",{onClick:()=>w(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(Ns,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Zi({isOpen:e,onClose:s}){const{t:r}=ae(),o=Yd(),[p,m]=b.useState(""),[v,n]=b.useState(""),[i,l]=b.useState(null),[u,c]=b.useState(!1),[g,x]=b.useState(!1),_=p.trim(),w=v.trim(),a=u||o.isPending,h=b.useMemo(()=>!!(_&&w&&!a),[_,w,a]),d=b.useCallback(()=>{m(""),n(""),l(null),x(!1)},[]),f=b.useCallback(()=>{a||(d(),s())},[a,s,d]);b.useEffect(()=>{e||d()},[e,d]);const S=b.useCallback(async y=>{try{await o.mutateAsync({name:_,repoPath:w,initEmptyRepo:y}),d(),s()}catch(j){const R=j instanceof Error?j.message:r("Failed to create project");l(R),st.error(R)}},[o,s,d,r,_,w]),C=b.useCallback(async()=>{if(!(!_||!w||a)){l(null),c(!0);try{const y=await Ee.get("/filesystem/validate",{params:{path:w}});if(!y.valid){l(y.error??r("Selected path is not a valid directory"));return}if(y.isGitRepo){await S(!1);return}if(y.reason==="no_git"&&y.isEmpty){x(!0);return}if(y.reason==="no_git"){await S(!1);return}await S(!1)}catch(y){l(y instanceof Error?y.message:r("Could not check project path"))}finally{c(!1)}}},[S,a,r,_,w]),k=b.useCallback(()=>{x(!1),S(!1)},[S]),E=b.useCallback(()=>{x(!1),S(!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx(fs,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:y=>m(y.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(qd,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(fs,{isOpen:g,onClose:()=>{o.isPending||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function Ea(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function qx(e){return e.map((s,r)=>({project:s,index:r,activityTime:Ea(s.lastActivityAt??s.createdAt),createdTime:Ea(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const p=r.createdTime-s.createdTime;return p!==0?p:s.index-r.index}).map(({project:s})=>s)}function ja({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ae(),[v,n]=b.useState(!1),i=e.filter(u=>!u.archivedAt),l=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:te("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>n(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx($s,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:m("All Projects")}),t.jsx(wt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>n(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx($s,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(Kt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:i.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:u.name}),c?t.jsx(Kt,{size:14,className:"text-foreground shrink-0"}):null]},u.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{n(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(ls,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function Na(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const Kx=260,Vx=600,Ra=400,Xx=100,Yx=1e3;function Gx(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,...s?{preferredWorkspace:{...s.workspaceKind===_t.MAIN_DIRECTORY?{workspaceKind:_t.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(p=>p.status==="RUNNING"||p.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function Qx(){const{t:e,locale:s}=ae(),[r,o]=b.useState(null),[p,m]=b.useState(null),[v,n]=b.useState(Ra),[i,l]=b.useState(!1),[u,c]=b.useState("idle"),[g,x]=b.useState({}),_=b.useRef(!1),w=b.useRef(0),a=b.useRef(Ra),h=b.useRef(null),d=bt(),{data:f,isLoading:S}=Ks(),{data:C,isLoading:k}=Gd({limit:Xx}),E=b.useMemo(()=>C?.data??[],[C?.data]),y=p&&E.some(J=>J.id===p)?p:null,{data:j,isLoading:R}=Ed({...y?{projectId:y}:{},limit:Yx}),L=b.useMemo(()=>j?.data??[],[j?.data]),[T,D]=b.useState([]),F=b.useMemo(()=>{if(T.length===0)return L;const J=new Set(L.map(fe=>fe.id));return[...T.filter(fe=>!J.has(fe.id)),...L]},[L,T]),[I,H]=b.useState(null),q=b.useMemo(()=>r&&F.some(J=>J.id===r)?r:I&&r===I?I:null,[r,F,I]);b.useEffect(()=>{I&&F.some(J=>J.id===I)&&H(null)},[I,F]),b.useEffect(()=>{if(T.length===0)return;const J=new Set(L.map(fe=>fe.id));T.some(fe=>J.has(fe.id))&&D(fe=>fe.filter(ue=>!J.has(ue.id)))},[L,T]);const A=b.useMemo(()=>qx(E),[E]),P=b.useMemo(()=>A.map(ax),[A]),M=b.useMemo(()=>A.filter(J=>!J.archivedAt),[A]),O=b.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),fe=J?JSON.parse(J):{};return[...f].sort((ue,ge)=>{const Ce=ue.availability.type!=="NOT_FOUND",Y=ge.availability.type!=="NOT_FOUND";if(Ce!==Y)return Ce?-1:1;const se=fe[ue.provider.id]??0;return(fe[ge.provider.id]??0)-se})},[f]),$=b.useMemo(()=>F.map(J=>lx(J,E.find(fe=>fe.id===J.projectId))),[E,F]),K=b.useMemo(()=>{if(!q)return null;const J=F.find(ue=>ue.id===q);if(!J)return null;const fe=E.find(ue=>ue.id===J.projectId);if(!fe){const ue=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:to(J.status),branch:ue,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return cx(J,fe)},[q,F,E]),B=Pa(),z=jd(),U=Nd(),N=En(),W=b.useCallback(J=>{const fe=Gx(J);D(ue=>ue.some(ge=>ge.id===J.id)?ue.map(ge=>ge.id===J.id?fe:ge):[fe,...ue]),d.setQueryData(ce.tasks.detail(J.id),J),H(J.id),o(J.id)},[d]),X=b.useCallback((J,fe,ue)=>{const ge=J.id,Ce=[J.title,J.description].filter(Boolean).join(`
87
87
 
88
- `);x(Y=>({...Y,[ge]:{status:"creating-workspace"}})),(async()=>{try{const Y=await Ee.post(`/tasks/${ge}/workspaces`,{workspaceKind:ue});x(ne=>({...ne,[ge]:{status:"creating-session"}}));const se=await Ee.post(`/workspaces/${Y.id}/sessions`,{providerId:fe,prompt:Ce});x(ne=>({...ne,[ge]:{status:"starting-session"}})),await N.mutateAsync(se.id),await d.invalidateQueries({queryKey:ce.workspaces.list(ge)}),await d.invalidateQueries({queryKey:ce.tasks.all}),x(ne=>{const{[ge]:ke,...xe}=ne;return xe})}catch(Y){const se=Y instanceof Error?Y.message:e("启动 Agent 失败");x(ne=>({...ne,[ge]:{status:"failed",error:se}})),st.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ce.workspaces.list(ge)}),d.invalidateQueries({queryKey:ce.tasks.all})}})()},[d,N,e]),V=b.useCallback(J=>{x(fe=>{const{[J]:ue,...ge}=fe;return ge}),d.invalidateQueries({queryKey:ce.workspaces.list(J)}),d.invalidateQueries({queryKey:ce.tasks.all})},[d]),ie=b.useCallback(J=>{z.mutate(J,{onSuccess:()=>{q===J&&o(null),x(fe=>{const{[J]:ue,...ge}=fe;return ge}),D(fe=>fe.filter(ue=>ue.id!==J)),d.invalidateQueries({queryKey:ce.tasks.all})},onError:()=>{st.error(e("删除任务失败"))}})},[z,q,d,e]),ee=b.useCallback((J,fe)=>{U.mutate({id:J,status:ix(fe)},{onError:()=>{st.error(e("状态变更失败,该操作不被允许"))}})},[U,e]),me=b.useCallback(J=>{J.preventDefault(),_.current=!0,w.current=J.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);b.useEffect(()=>{const J=ue=>{if(!_.current)return;const ge=ue.clientX-w.current,Ce=Math.max(qx,Math.min(Kx,a.current+ge));n(Ce)},fe=()=>{_.current&&(_.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",fe),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",fe)}},[]);const he=b.useCallback(()=>{l(!0)},[]),G=b.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[M,e]),pe=b.useCallback(()=>{l(!1)},[]),oe=b.useCallback(async J=>{const{title:fe,description:ue,projectId:ge,providerId:Ce,mode:Y,workspaceMode:se,teamRunMode:ne,teamTemplateId:ke,memberPresetIds:xe,attachmentLinks:je}=J,Te=[ue,je].filter(Boolean).join(`
88
+ `);x(Y=>({...Y,[ge]:{status:"creating-workspace"}})),(async()=>{try{const Y=await Ee.post(`/tasks/${ge}/workspaces`,{workspaceKind:ue});x(ne=>({...ne,[ge]:{status:"creating-session"}}));const se=await Ee.post(`/workspaces/${Y.id}/sessions`,{providerId:fe,prompt:Ce});x(ne=>({...ne,[ge]:{status:"starting-session"}})),await N.mutateAsync(se.id),await d.invalidateQueries({queryKey:ce.workspaces.list(ge)}),await d.invalidateQueries({queryKey:ce.tasks.all}),x(ne=>{const{[ge]:ke,...xe}=ne;return xe})}catch(Y){const se=Y instanceof Error?Y.message:e("启动 Agent 失败");x(ne=>({...ne,[ge]:{status:"failed",error:se}})),st.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ce.workspaces.list(ge)}),d.invalidateQueries({queryKey:ce.tasks.all})}})()},[d,N,e]),V=b.useCallback(J=>{x(fe=>{const{[J]:ue,...ge}=fe;return ge}),d.invalidateQueries({queryKey:ce.workspaces.list(J)}),d.invalidateQueries({queryKey:ce.tasks.all})},[d]),ie=b.useCallback(J=>{z.mutate(J,{onSuccess:()=>{q===J&&o(null),x(fe=>{const{[J]:ue,...ge}=fe;return ge}),D(fe=>fe.filter(ue=>ue.id!==J)),d.invalidateQueries({queryKey:ce.tasks.all})},onError:()=>{st.error(e("删除任务失败"))}})},[z,q,d,e]),ee=b.useCallback((J,fe)=>{U.mutate({id:J,status:nx(fe)},{onError:()=>{st.error(e("状态变更失败,该操作不被允许"))}})},[U,e]),me=b.useCallback(J=>{J.preventDefault(),_.current=!0,w.current=J.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);b.useEffect(()=>{const J=ue=>{if(!_.current)return;const ge=ue.clientX-w.current,Ce=Math.max(Kx,Math.min(Vx,a.current+ge));n(Ce)},fe=()=>{_.current&&(_.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",fe),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",fe)}},[]);const he=b.useCallback(()=>{l(!0)},[]),G=b.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[M,e]),pe=b.useCallback(()=>{l(!1)},[]),oe=b.useCallback(async J=>{const{title:fe,description:ue,projectId:ge,providerId:Ce,mode:Y,workspaceMode:se,teamRunMode:ne,teamTemplateId:ke,memberPresetIds:xe,attachmentLinks:je}=J,Te=[ue,je].filter(Boolean).join(`
89
89
 
90
- `);let ye=null;try{if(c("creating-task"),ye=await Ee.post(`/projects/${ge}/tasks`,{title:fe,description:Te||void 0}),localStorage.setItem("lastSelectedProjectId",ge),Y==="SOLO"&&Ce){localStorage.setItem("lastSelectedProviderId",Ce);const Se=localStorage.getItem("providerUsageCount"),De=Se?JSON.parse(Se):{};De[Ce]=(De[Ce]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(De))}Y==="TEAM"?(c("creating-teamrun"),await B.mutateAsync({taskId:ye.id,mode:ne,...ke?{teamTemplateId:ke}:{},...xe.length>0?{memberPresetIds:xe}:{}})):Ce&&X(ye,Ce,se),y&&ge!==y&&m(null),W(ye),c("idle"),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all})}catch(Le){if(c("idle"),ye&&Y==="TEAM"){try{await z.mutateAsync(ye.id)}catch{}throw st.error(e("TeamRun 创建失败,请检查团队配置后重试")),Le}else if(ye)y&&ge!==y&&m(null),W(ye),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all});else throw st.error(Le instanceof Error?Le.message:e("Failed to create task")),Le}},[M,B,X,z,d,e,y,W]),We=k||R,ut=b.useMemo(()=>M.map(J=>({id:J.id,name:J.name,color:P.find(fe=>fe.id===J.id)?.color,repoPath:J.repoPath,isGitRepo:J.isGitRepo,worktreeReady:J.worktreeReady,reason:J.reason})),[M,P]),Oe=b.useMemo(()=>O.map(({provider:J,availability:fe})=>({id:J.id,name:J.name,agentType:J.agentType,available:fe.type!=="NOT_FOUND"})),[O]),be=b.useMemo(()=>{if(y&&M.find(fe=>fe.id===y))return y;const J=localStorage.getItem("lastSelectedProjectId");return J&&M.find(fe=>fe.id===J)?J:M[0]?.id??""},[M,y]),[Ue,Be]=b.useState(be);b.useEffect(()=>{Be(be)},[be]);const tt=b.useMemo(()=>M.find(J=>J.id===Ue)?.name??M.find(J=>J.id===be)?.name??e("Project"),[M,Ue,be,e]),Ye=s==="zh-CN"?`你需要在 ${tt} 中做点什么?`:`What do you need to do in ${tt}?`,Ze=b.useMemo(()=>{const J=localStorage.getItem("lastSelectedProviderId");return J&&O.find(ue=>ue.provider.id===J&&ue.availability.type!=="NOT_FOUND")?J:O.find(ue=>ue.availability.type!=="NOT_FOUND")?.provider.id??""},[O]),Xe=El(),[Ne,Ae]=b.useState(!1),{usesIntegratedTitlebar:ve,desktopPlatform:He,hasMacTrafficLights:_e}=Ra(),pt=ve&&He==="win32",Je=b.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}Ae(!0)},[M,e]),Lt=b.useCallback(async J=>{await oe(J),Ae(!1)},[oe]);return Xe?Ne?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Ae(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:Ye}),t.jsx(ho,{projects:ut,providers:Oe,isProvidersLoading:S,onSubmit:Lt,defaultProjectId:be,defaultProviderId:Ze,onProjectChange:Be,createStep:u})]})]}):q&&K?t.jsxs(t.Fragment,{children:[t.jsx(Ex,{task:K,onBack:()=>o(null),onDeleteTask:K.projectArchivedAt?void 0:ie,isDeleting:z.isPending,autoStartState:g[K.id]??null,onAutoStartRecovered:V}),t.jsx(Qi,{isOpen:i,onClose:pe})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(fo,{}),t.jsx(Ea,{projects:P,filterProjectId:y,setFilterProjectId:m,onCreateProject:he})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Ca,{}),t.jsx("button",{onClick:()=>lo.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(ao,{size:16})})]})]}),We&&$.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ja,{})}):t.jsx(Ro,{tasks:$,projects:P,selectedTaskId:null,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:"100%",onCreateTask:Je,onCreateProject:he,onTaskStatusChange:ee})]}),t.jsx(Qi,{isOpen:i,onClose:pe})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:te("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",ve&&"app-region-drag",pt&&"pr-[150px]"),children:[t.jsxs("div",{className:te("flex items-center gap-2 min-w-0",_e&&"pl-[72px]"),children:[t.jsx(fo,{}),t.jsx(Ea,{projects:P,filterProjectId:y,setFilterProjectId:m,onCreateProject:he,className:ve?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:te("flex items-center gap-1",ve&&"app-region-no-drag"),children:[t.jsx("div",{className:ve?"app-region-no-drag":void 0,children:t.jsx(Ca,{})}),t.jsx("button",{onClick:()=>lo.getState().openSettings(),className:te("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",ve&&"app-region-no-drag"),children:t.jsx(ao,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[We&&$.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(ja,{})}):t.jsx(Ro,{tasks:$,projects:P,selectedTaskId:q,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:v,onCreateTask:G,onCreateProject:he,isCreateActive:!q,onTaskStatusChange:ee,onDeleteTask:ie}),t.jsx("div",{onMouseDown:me,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:q&&K?t.jsx(rx,{task:K,onDeleteTask:K.projectArchivedAt?void 0:ie,isDeleting:z.isPending,onTaskStatusChange:K.projectArchivedAt?void 0:ee,autoStartState:g[K.id]??null,onAutoStartRecovered:V}):q&&!K?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:Ye}),t.jsx(ho,{projects:ut,providers:Oe,isProvidersLoading:S,onSubmit:oe,defaultProjectId:be,defaultProviderId:Ze,onProjectChange:Be,createStep:u})]})})})]}),t.jsx(Qi,{isOpen:i,onClose:pe})]})}const Cb=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:Gx},Symbol.toStringTag,{value:"Module"}));export{Cb as P,Xl as l};
90
+ `);let ye=null;try{if(c("creating-task"),ye=await Ee.post(`/projects/${ge}/tasks`,{title:fe,description:Te||void 0}),localStorage.setItem("lastSelectedProjectId",ge),Y==="SOLO"&&Ce){localStorage.setItem("lastSelectedProviderId",Ce);const Se=localStorage.getItem("providerUsageCount"),De=Se?JSON.parse(Se):{};De[Ce]=(De[Ce]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(De))}Y==="TEAM"?(c("creating-teamrun"),await B.mutateAsync({taskId:ye.id,mode:ne,...ke?{teamTemplateId:ke}:{},...xe.length>0?{memberPresetIds:xe}:{}})):Ce&&X(ye,Ce,se),y&&ge!==y&&m(null),W(ye),c("idle"),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all})}catch(Le){if(c("idle"),ye&&Y==="TEAM"){try{await z.mutateAsync(ye.id)}catch{}throw st.error(e("TeamRun 创建失败,请检查团队配置后重试")),Le}else if(ye)y&&ge!==y&&m(null),W(ye),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all});else throw st.error(Le instanceof Error?Le.message:e("Failed to create task")),Le}},[M,B,X,z,d,e,y,W]),We=k||R,ut=b.useMemo(()=>M.map(J=>({id:J.id,name:J.name,color:P.find(fe=>fe.id===J.id)?.color,repoPath:J.repoPath,isGitRepo:J.isGitRepo,worktreeReady:J.worktreeReady,reason:J.reason})),[M,P]),Oe=b.useMemo(()=>O.map(({provider:J,availability:fe})=>({id:J.id,name:J.name,agentType:J.agentType,available:fe.type!=="NOT_FOUND"})),[O]),be=b.useMemo(()=>{if(y&&M.find(fe=>fe.id===y))return y;const J=localStorage.getItem("lastSelectedProjectId");return J&&M.find(fe=>fe.id===J)?J:M[0]?.id??""},[M,y]),[Ue,Be]=b.useState(be);b.useEffect(()=>{Be(be)},[be]);const tt=b.useMemo(()=>M.find(J=>J.id===Ue)?.name??M.find(J=>J.id===be)?.name??e("Project"),[M,Ue,be,e]),Ye=s==="zh-CN"?`你需要在 ${tt} 中做点什么?`:`What do you need to do in ${tt}?`,Ze=b.useMemo(()=>{const J=localStorage.getItem("lastSelectedProviderId");return J&&O.find(ue=>ue.provider.id===J&&ue.availability.type!=="NOT_FOUND")?J:O.find(ue=>ue.availability.type!=="NOT_FOUND")?.provider.id??""},[O]),Xe=jl(),[Ne,Ae]=b.useState(!1),{usesIntegratedTitlebar:ve,desktopPlatform:He,hasMacTrafficLights:_e}=Aa(),pt=ve&&He==="win32",Je=b.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}Ae(!0)},[M,e]),Lt=b.useCallback(async J=>{await oe(J),Ae(!1)},[oe]);return Xe?Ne?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Ae(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:Ye}),t.jsx(fo,{projects:ut,providers:Oe,isProvidersLoading:S,onSubmit:Lt,defaultProjectId:be,defaultProviderId:Ze,onProjectChange:Be,createStep:u})]})]}):q&&K?t.jsxs(t.Fragment,{children:[t.jsx(jx,{task:K,onBack:()=>o(null),onDeleteTask:K.projectArchivedAt?void 0:ie,isDeleting:z.isPending,autoStartState:g[K.id]??null,onAutoStartRecovered:V}),t.jsx(Zi,{isOpen:i,onClose:pe})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(mo,{}),t.jsx(ja,{projects:P,filterProjectId:y,setFilterProjectId:m,onCreateProject:he})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ka,{}),t.jsx("button",{onClick:()=>co.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(lo,{size:16})})]})]}),We&&$.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Na,{})}):t.jsx(Ao,{tasks:$,projects:P,selectedTaskId:null,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:"100%",onCreateTask:Je,onCreateProject:he,onTaskStatusChange:ee})]}),t.jsx(Zi,{isOpen:i,onClose:pe})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:te("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",ve&&"app-region-drag",pt&&"pr-[150px]"),children:[t.jsxs("div",{className:te("flex items-center gap-2 min-w-0",_e&&"pl-[72px]"),children:[t.jsx(mo,{}),t.jsx(ja,{projects:P,filterProjectId:y,setFilterProjectId:m,onCreateProject:he,className:ve?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:te("flex items-center gap-1",ve&&"app-region-no-drag"),children:[t.jsx("div",{className:ve?"app-region-no-drag":void 0,children:t.jsx(ka,{})}),t.jsx("button",{onClick:()=>co.getState().openSettings(),className:te("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",ve&&"app-region-no-drag"),children:t.jsx(lo,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[We&&$.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(Na,{})}):t.jsx(Ao,{tasks:$,projects:P,selectedTaskId:q,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:v,onCreateTask:G,onCreateProject:he,isCreateActive:!q,onTaskStatusChange:ee,onDeleteTask:ie}),t.jsx("div",{onMouseDown:me,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:q&&K?t.jsx(ix,{task:K,onDeleteTask:K.projectArchivedAt?void 0:ie,isDeleting:z.isPending,onTaskStatusChange:K.projectArchivedAt?void 0:ee,autoStartState:g[K.id]??null,onAutoStartRecovered:V}):q&&!K?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:Ye}),t.jsx(fo,{projects:ut,providers:Oe,isProvidersLoading:S,onSubmit:oe,defaultProjectId:be,defaultProviderId:Ze,onProjectChange:Be,createStep:u})]})})})]}),t.jsx(Zi,{isOpen:i,onClose:pe})]})}const Cb=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:Qx},Symbol.toStringTag,{value:"Module"}));export{Cb as P,Yl as l};