agent-tower 0.6.0-beta.8 → 0.6.0-beta.9
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.
- package/dist/web/assets/{AgentDemoPage-121Vdmg2.js → AgentDemoPage-aLGw8pYk.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-BLQvILTp.js → AgentEnvironmentSettingsPage-BYcH_wMz.js} +1 -1
- package/dist/web/assets/{AgentLogo-DKyk6Tug.js → AgentLogo-Dyqxcj5s.js} +1 -1
- package/dist/web/assets/{ConversationPage-KYJaRufy.js → ConversationPage-BBnK1qA_.js} +1 -1
- package/dist/web/assets/{CreateTaskInput-BuOrQdzX.js → CreateTaskInput-B11wGhDW.js} +1 -1
- package/dist/web/assets/{DemoPage-7vKmpFI2.js → DemoPage-m92AArTk.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-DiCNFgoG.js → GeneralSettingsPage-P5HcwCXo.js} +1 -1
- package/dist/web/assets/{Icons-B4ayBr1Z.js → Icons-BFOphLw-.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-BAJfvvP4.js → LoadingPreviewPage-CfT4FIyb.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-DU-XVT-K.js → McpSettingsPage-BI_b78L_.js} +1 -1
- package/dist/web/assets/{MemberAvatar-BHpfGaeT.js → MemberAvatar-1UlgMZMM.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-DGGn_rYx.js → NotificationSettingsPage-CQCyq9QZ.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-Cx65zYgj.js → ProfileSettingsPage-ojhJXLWb.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-DkNalVWe.js → ProjectKanbanPage-DK3rZJzY.js} +37 -37
- package/dist/web/assets/{ProjectSettingsPage-1qxW8tba.js → ProjectSettingsPage-MGB631ia.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-CvYtXhzO.js → ProviderSettingsPage-CMZvEWMa.js} +1 -1
- package/dist/web/assets/{SettingsMasterDetail-CtmgXnjL.js → SettingsMasterDetail-9CnCBuNZ.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-DByUrR3L.js → TeamSettingsPage-BUXKd5UF.js} +1 -1
- package/dist/web/assets/{arc-C7PIksH_.js → arc-2leUEhVa.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-gEUpxvUc.js → architectureDiagram-3BPJPVTR-CDgYR44L.js} +1 -1
- package/dist/web/assets/{arrow-left-DJne1iCP.js → arrow-left-Jn-v17JF.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-C56-hDft.js → blockDiagram-GPEHLZMM-CzfIh31g.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-BlrLzKR6.js → c4Diagram-AAUBKEIU-BzzBXKEF.js} +1 -1
- package/dist/web/assets/channel-XuYe6lH7.js +1 -0
- package/dist/web/assets/check-FwR4dMNY.js +1 -0
- package/dist/web/assets/{chevron-down-BrHeUdnT.js → chevron-down-CpKODb7Y.js} +1 -1
- package/dist/web/assets/{chevron-right-ClCTr1OP.js → chevron-right-CBoUSXVq.js} +1 -1
- package/dist/web/assets/{chevron-up-Cu1m42hx.js → chevron-up-KZ1hsL8y.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-DA9vwc1D.js → chunk-2J33WTMH-GJE6LCGS.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-DVb7E2f3.js → chunk-4BX2VUAB-Bw_ITp1Q.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-BEVmB6Bb.js → chunk-55IACEB6-DQ-XuWbD.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-DeZOyHvn.js → chunk-727SXJPM-BgL49Dtw.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-xKSXjjJ5.js → chunk-AQP2D5EJ-dRTVohoy.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-ciPLDbAS.js → chunk-FMBD7UC4-BZtRjoH7.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-2ReRFo_l.js → chunk-ND2GUHAM-CN3wND6y.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-CTYcDhch.js → chunk-QZHKN3VN-CMwbobMj.js} +1 -1
- package/dist/web/assets/{circle-alert-CPz_VCJC.js → circle-alert-kELlE07n.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DWSNJHiT.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DWSNJHiT.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-DMWztYUo.js → code-block-OCS4YCEC-B1YC7dLa.js} +1 -1
- package/dist/web/assets/{confirm-dialog-BN-QsQ30.js → confirm-dialog-DDWlvtJs.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-cKGd6G-z.js → cose-bilkent-S5V4N54A-C6xD7kmY.js} +1 -1
- package/dist/web/assets/cssMode-lB5vNGvS.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-A8nK1ze3.js → dagre-BM42HDAG-BqTCYMO6.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-D7msfvrP.js → diagram-2AECGRRQ-BsMq3s5l.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-BvXkL8LL.js → diagram-5GNKFQAL-l4izpv7Z.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-BLN52R9o.js → diagram-KO2AKTUF-uWDq6Yzo.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-mtF_5aJL.js → diagram-LMA3HP47-Dbd4fnFa.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-CZ8IjTKx.js → diagram-OG6HWLK6-BC-27mkr.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-CW4gNQnJ.js → erDiagram-TEJ5UH35-DrCP0Xt8.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-BFWepqRF.js → flowDiagram-I6XJVG4X-BqNsQuUr.js} +1 -1
- package/dist/web/assets/{folder-picker-BsuXw4Lz.js → folder-picker-CBVEWiuS.js} +1 -1
- package/dist/web/assets/{freemarker2-CFCpnL6n.js → freemarker2-Bos_2jdw.js} +2 -2
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-CPCVjLvp.js → ganttDiagram-6RSMTGT7-CZOrG-5M.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-C-yjS3d_.js → gitGraphDiagram-PVQCEYII-Dp3i5ehs.js} +1 -1
- package/dist/web/assets/handlebars-C7Elz3nH.js +1 -0
- package/dist/web/assets/html-EvsHOk5n.js +1 -0
- package/dist/web/assets/htmlMode-CTlhNZgJ.js +1 -0
- package/dist/web/assets/{index-5mnxm7I2.js → index-BGajgi5H.js} +8 -8
- package/dist/web/assets/index-CVgeXPf_.css +1 -0
- package/dist/web/assets/{index-WA-EeR-W.js → index-hPp73HMS.js} +4 -4
- package/dist/web/assets/{infoDiagram-5YYISTIA-CyhsOl9n.js → infoDiagram-5YYISTIA-C6NnR_Zb.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DiuB4kq5.js → ishikawaDiagram-YF4QCWOH-C1SOf-Ko.js} +1 -1
- package/dist/web/assets/javascript-Desq1P0G.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-D8hn7DGX.js → journeyDiagram-JHISSGLW--GKMSbPz.js} +1 -1
- package/dist/web/assets/{jsonMode-DKLNvzZk.js → jsonMode-Bbh3Gbb8.js} +4 -4
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BojfaPhM.js → kanban-definition-UN3LZRKU-Car5iy0R.js} +1 -1
- package/dist/web/assets/{layers-DzEkeGQJ.js → layers-WOwm63Fo.js} +1 -1
- package/dist/web/assets/{linear-BH5S1_K_.js → linear-ChUj9SvT.js} +1 -1
- package/dist/web/assets/liquid-BXFWITFq.js +1 -0
- package/dist/web/assets/{lspLanguageFeatures-m1ILESjk.js → lspLanguageFeatures-DQ2CrOBI.js} +1 -1
- package/dist/web/assets/mdx-vHLpslzI.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-BdwTD9oT.js → mermaid-NOHMQCX5-CzwPLFrI.js} +4 -4
- package/dist/web/assets/{message-square-CprUAZwY.js → message-square-DgdFa1Kc.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-BgQiNSqF.js → mindmap-definition-RKZ34NQL-CfzbnHY_.js} +1 -1
- package/dist/web/assets/{modal-BqHJvAk-.js → modal-QnCJhV9P.js} +1 -1
- package/dist/web/assets/{monaco-Fm9Q8Oob.js → monaco-CbFQByO7.js} +3 -3
- package/dist/web/assets/{pencil-DtsyfpXV.js → pencil-CNVU3zfM.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-C4RL8jaZ.js → pieDiagram-4H26LBE5-CDqYJneU.js} +1 -1
- package/dist/web/assets/python-BhFSY_J2.js +1 -0
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-DbWEWLfK.js → quadrantDiagram-W4KKPZXB-B6ChDIx2.js} +1 -1
- package/dist/web/assets/razor-Cx_DrE-V.js +1 -0
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-oUROuUzd.js → requirementDiagram-4Y6WPE33-DefLT9NZ.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-OpKVDNcA.js → sankeyDiagram-5OEKKPKP-CQHnovPz.js} +1 -1
- package/dist/web/assets/{select-CB8ESe4Q.js → select-CmbeAAVh.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-XHCjU2T9.js → sequenceDiagram-3UESZ5HK-DZuaKm7C.js} +1 -1
- package/dist/web/assets/{server-DDG7bNWF.js → server-BUivqMYo.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-DECbzSmA.js → stateDiagram-AJRCARHV-DvxpChEC.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BbrRYMxK.js +1 -0
- package/dist/web/assets/{switch-DRLI98Hg.js → switch-CiOyM13e.js} +1 -1
- package/dist/web/assets/{textarea-CdNSB2r_.js → textarea-D4HkYa3u.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-CFRKRagZ.js → timeline-definition-PNZ67QCA-BRu-tS-p.js} +1 -1
- package/dist/web/assets/{trash-2-fcaDNTJq.js → trash-2-DPxBnxJM.js} +1 -1
- package/dist/web/assets/{tsMode-DSzQjJK3.js → tsMode-CHcZwUmC.js} +2 -2
- package/dist/web/assets/typescript-CvtjMxoq.js +1 -0
- package/dist/web/assets/{upload-B8oz6oGE.js → upload-YmLtnZsU.js} +1 -1
- package/dist/web/assets/{use-profiles-BKSY6QPb.js → use-profiles-OJAwfc90.js} +1 -1
- package/dist/web/assets/{use-projects-BYOiz-wd.js → use-projects-iob5C7Xk.js} +1 -1
- package/dist/web/assets/{use-providers-Dy7qGK5B.js → use-providers-Cj9S9_2q.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-DZrbmlsd.js → useNormalizedLogs-BhN4AN4f.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-D-75YMZP.js → vennDiagram-CIIHVFJN-CtZ_3Ld0.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-C61gThmp.js → wardley-L42UT6IY-h9yfTmIn.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CK097L4L.js → wardleyDiagram-YWT4CUSO-CWXtZtix.js} +1 -1
- package/dist/web/assets/xml-DhyGRwiG.js +1 -0
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-L-SbiODs.js → xychartDiagram-2RQKCTM6-BLuWVWlL.js} +1 -1
- package/dist/web/assets/yaml-Cpi6SvoR.js +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/channel-H8WfXT65.js +0 -1
- package/dist/web/assets/check-DDmXMNyc.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DEwghyUA.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DEwghyUA.js +0 -1
- package/dist/web/assets/cssMode-xnMD2U0i.js +0 -1
- package/dist/web/assets/handlebars-DJjXbRRE.js +0 -1
- package/dist/web/assets/html-y2wveTmH.js +0 -1
- package/dist/web/assets/htmlMode-vnWUx-PF.js +0 -1
- package/dist/web/assets/index-C57t30O_.css +0 -1
- package/dist/web/assets/javascript-Celpalfe.js +0 -1
- package/dist/web/assets/liquid-D2dl2VpD.js +0 -1
- package/dist/web/assets/mdx-FVgkhpIC.js +0 -1
- package/dist/web/assets/python-DJXVEHrw.js +0 -1
- package/dist/web/assets/razor-BzoF3oIs.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CnVs5X53.js +0 -1
- package/dist/web/assets/typescript-DUwWh7XI.js +0 -1
- package/dist/web/assets/xml-BpIKzb-V.js +0 -1
- package/dist/web/assets/yaml-DjL8Not3.js +0 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-
|
|
2
|
-
import{ah as id,ai as no,aj as nd,ak as od,al as ad,k as Ke,r as b,am as le,z as _s,m as kt,an as Cs,n as Bt,p as Ee,o as bt,q as ce,u as ae,j as t,a9 as xt,Y as Na,Z as ld,l as te,$ as Fs,B as De,ao as Ra,ap as Aa,aq as Ta,af as Ss,X as Zt,ar as pn,as as cd,O as vr,at as dd,D as ud,au as hd,av as fd,aw as md,T as ks,t as st,U as rs,V as lt,W as Ls,P as He,ax as Es,Q as or,ay as pd,az as ni,ag as gd,ad as vd,ae as xd,aA as Ma,aB as gn,aC as Da,aD as Pa,aE as La,aF as bd,aG as _d,a2 as yd,aH as Sd,aI as wd,aJ as Cd,_ as oo,a8 as ao}from"./index-5mnxm7I2.js";import{S as ct,u as vn,A as xn,l as kd,F as Ia,p as Ed,m as jd,o as Nd,Q as bn,q as Rd,r as At,W as _t,t as Oa,C as ur,v as Lr,w as Ad,x as Td,y as Md,T as Dd,h as Nt,b as Ur,z as Ba,B as Wt}from"./mermaid-NOHMQCX5-BdwTD9oT.js";import{C as _n}from"./confirm-dialog-BN-QsQ30.js";import{c as Fa,a as za,b as Wa,I as Ha,d as $a,A as lo,G as Ua}from"./Icons-B4ayBr1Z.js";import{C as wt}from"./chevron-down-BrHeUdnT.js";import{C as Mt}from"./chevron-right-ClCTr1OP.js";import{d as yn,S as Pd,u as Sn,A as hr,c as wn,G as qa,Z as Ld,e as Cn,T as kn,f as Id,g as En,h as co,i as Od,b as Ka,j as Va,a as Xa,k as Ya,R as Ga,P as Qa,l as qr,m as Bd,C as uo,B as ho}from"./CreateTaskInput-BuOrQdzX.js";import{a as Fd,F as zd,b as Wd}from"./folder-picker-BsuXw4Lz.js";import{M as oi}from"./message-square-CprUAZwY.js";import{L as zs}from"./layers-DzEkeGQJ.js";import{P as jn,u as Za,a as Ja,T as Kr}from"./useNormalizedLogs-DZrbmlsd.js";import{u as Us}from"./use-providers-Dy7qGK5B.js";import{A as ai}from"./AgentLogo-DKyk6Tug.js";import{M as Ht}from"./MemberAvatar-BHpfGaeT.js";import{C as el}from"./chevron-up-Cu1m42hx.js";import{C as Jt}from"./check-DDmXMNyc.js";import{M as ds}from"./modal-BqHJvAk-.js";import{S as is}from"./select-CB8ESe4Q.js";import{P as ns,T as Nn}from"./trash-2-fcaDNTJq.js";import{T as Hd}from"./textarea-CdNSB2r_.js";import{S as Qi,C as fo}from"./server-DDG7bNWF.js";import{F as Rn,e as $d,d as Ud,f as qd,u as Kd}from"./use-projects-BYOiz-wd.js";import{U as Vr}from"./upload-B8oz6oGE.js";import{A as Ws}from"./arrow-left-DJne1iCP.js";var Vd=class extends id{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:no()})}getOptimisticResult(e){return e.behavior=no(),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",h=p&&i==="forward",c=v&&i==="backward",g=p&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:od(s,r.data),hasPreviousPage:nd(s,r.data),isFetchNextPageError:l,isFetchingNextPage:h,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:n&&!l&&!c,isRefetching:m&&!h&&!g}}};function An(e,s){return ad(e,Vd)}const Xd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],tl=Ke("arrow-right",Xd);const Yd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],sl=Ke("ban",Yd);const Gd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Qd=Ke("chevron-left",Gd);const Zd=[["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"}]],Jd=Ke("clipboard-paste",Zd);const eu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],os=Ke("clock-3",eu);const tu=[["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"}]],li=Ke("code-xml",tu);const su=[["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"}]],mo=Ke("copy-plus",su);const ru=[["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"}]],iu=Ke("earth",ru);const nu=[["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"}]],rl=Ke("ellipsis-vertical",nu);const ou=[["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"}]],au=Ke("file-braces-corner",ou);const lu=[["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"}]],Xr=Ke("file-code-corner",lu);const cu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],du=Ke("file-exclamation-point",cu);const uu=[["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"}]],ci=Ke("folder-open",uu);const hu=[["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"}]],qs=Ke("git-graph",hu);const fu=[["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"}]],Hs=Ke("history",fu);const mu=[["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"}]],pu=Ke("maximize",mu);const gu=[["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"}]],vu=Ke("panel-left-close",gu);const xu=[["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"}]],bu=Ke("panel-left-open",xu);const _u=[["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"}]],yu=Ke("panel-right-close",_u);const Su=[["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"}]],Zi=Ke("panel-right-open",Su);const wu=[["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"}]],Cu=Ke("pen-line",wu);const ku=[["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"}]],Qt=Ke("play",ku);const Eu=[["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"}]],il=Ke("settings-2",Eu);const ju=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],po=Ke("smartphone",ju);const Nu=[["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"}]],Ir=Ke("user-plus",Nu);const Ru=[["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"}]],Au=Ke("zoom-in",Ru);const Tu=[["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"}]],Mu=Ke("zoom-out",Tu),di=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ks(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Tn(e){return"nodeType"in e}function yt(e){var s,r;return e?Ks(e)?e:Tn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Mn(e){const{Document:s}=yt(e);return e instanceof s}function xr(e){return Ks(e)?!1:e instanceof yt(e).HTMLElement}function nl(e){return e instanceof yt(e).SVGElement}function Vs(e){return e?Ks(e)?e.document:Tn(e)?Mn(e)?e:xr(e)||nl(e)?e.ownerDocument:document:document:document}const es=di?b.useLayoutEffect:b.useEffect;function ui(e){const s=b.useRef(e);return es(()=>{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 Du(){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 fr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return es(()=>{r.current!==e&&(r.current=e)},s),r}function br(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Yr(e){const s=ui(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Gr(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Ri={};function hi(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 ol(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 h=m[i];h!=null&&(m[i]=h+e*l)}return m},{...s})}}const Bs=ol(1),Qr=ol(-1);function Pu(e){return"clientX"in e&&"clientY"in e}function Dn(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function Lu(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function Zr(e){if(Lu(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 Pu(e)?{x:e.clientX,y:e.clientY}:null}const mr=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[mr.Translate.toString(e),mr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),go="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Iu(e){return e.matches(go)?e:e.querySelector(go)}const Ou={display:"none"};function Bu(e){let{id:s,value:r}=e;return le.createElement("div",{id:s,style:Ou},r)}function Fu(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 zu(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const al=b.createContext(null);function Wu(e){const s=b.useContext(al);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Hu(){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 $u={draggable:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-CbFQByO7.js","assets/index-BGajgi5H.js","assets/index-CVgeXPf_.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 _s,m as kt,an as Cs,n as Bt,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 Fs,B as Te,ao as Aa,ap as Ta,aq as Ma,af as Ss,X as $t,ar as gn,as as ud,O as vr,at as hd,D as fd,au as md,av as pd,aw as gd,T as ks,t as st,U as rs,V as lt,W as Ls,P as Fe,ax as Es,Q as or,ay as vd,az as ni,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-BGajgi5H.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 At,W as _t,t as Ba,C as ur,v as Lr,w as Dd,x as Pd,y as Ld,T as Id,h as Nt,b as Ur,z as Fa,B as Wt}from"./mermaid-NOHMQCX5-CzwPLFrI.js";import{C as yn}from"./confirm-dialog-DDWlvtJs.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-BFOphLw-.js";import{C as wt}from"./chevron-down-CpKODb7Y.js";import{C as Mt}from"./chevron-right-CBoUSXVq.js";import{d as Sn,S as Od,u as wn,A as hr,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 qr,m as Wd,C as ho,B as fo}from"./CreateTaskInput-B11wGhDW.js";import{a as Hd,F as $d,b as Ud}from"./folder-picker-CBVEWiuS.js";import{M as oi}from"./message-square-DgdFa1Kc.js";import{L as zs}from"./layers-WOwm63Fo.js";import{P as Nn,u as Ja,a as el,T as Kr}from"./useNormalizedLogs-BhN4AN4f.js";import{u as Us}from"./use-providers-Cj9S9_2q.js";import{A as ai}from"./AgentLogo-Dyqxcj5s.js";import{M as Ht}from"./MemberAvatar-1UlgMZMM.js";import{C as tl}from"./chevron-up-KZ1hsL8y.js";import{C as Ut}from"./check-FwR4dMNY.js";import{M as ds}from"./modal-QnCJhV9P.js";import{S as is}from"./select-CmbeAAVh.js";import{P as ns,T as Rn}from"./trash-2-DPxBnxJM.js";import{T as qd}from"./textarea-D4HkYa3u.js";import{S as Zi,C as mo}from"./server-BUivqMYo.js";import{F as An,e as Kd,d as Vd,f as Xd,u as Yd}from"./use-projects-iob5C7Xk.js";import{U as Vr}from"./upload-YmLtnZsU.js";import{A as Ws}from"./arrow-left-Jn-v17JF.js";import{P as Gd}from"./pencil-CNVU3zfM.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"}]],os=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"}]],li=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"}]],Xr=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"}]],ci=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"}]],qs=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"}]],Hs=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"}]],Jt=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"}]],Ir=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),di=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ks(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?Ks(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 xr(e){return Ks(e)?!1:e instanceof yt(e).HTMLElement}function ol(e){return e instanceof yt(e).SVGElement}function Vs(e){return e?Ks(e)?e.document:Mn(e)?Dn(e)?e:xr(e)||ol(e)?e.ownerDocument:document:document:document}const es=di?b.useLayoutEffect:b.useEffect;function ui(e){const s=b.useRef(e);return es(()=>{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 fr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return es(()=>{r.current!==e&&(r.current=e)},s),r}function br(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Yr(e){const s=ui(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Gr(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Ri={};function hi(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 Bs=al(1),Qr=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 Zr(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 mr=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[mr.Translate.toString(e),mr.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:`
|
|
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
|
-
`},Uu={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 qu(e){let{announcements:s=Uu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=$u}=e;const{announce:m,announcement:v}=zu(),n=hi("DndLiveRegion"),[i,l]=b.useState(!1);if(b.useEffect(()=>{l(!0)},[]),Wu(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 h=le.createElement(le.Fragment,null,le.createElement(Bu,{id:o,value:p.draggable}),le.createElement(Fu,{id:n,announcement:v}));return r?_s.createPortal(h,r):h}var at;(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"})(at||(at={}));function Jr(){}function Ku(e,s){return b.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Vu(){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 Ot=Object.freeze({x:0,y:0});function Xu(e,s){const r=Zr(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 Yu(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Gu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Qu(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,h=v*n,c=h/(i+l-h);return Number(c.toFixed(4))}return 0}const Zu=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=Qu(n,s);i>0&&p.push({id:v,data:{droppableContainer:m,value:i}})}}return p.sort(Yu)};function Ju(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function ll(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ot}function eh(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 th=eh(1);function cl(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 sh(e,s,r){const o=cl(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)),h=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:h,height:c,top:l,right:i+h,bottom:l+c,left:i}}const rh={ignoreTransform:!1};function _r(e,s){s===void 0&&(s=rh);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:h}=yt(e).getComputedStyle(e);l&&(r=sh(r,l,h))}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 vo(e){return _r(e,{ignoreTransform:!0})}function ih(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function nh(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function oh(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 Pn(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Mn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!xr(p)||nl(p)||r.includes(p))return r;const m=yt(e).getComputedStyle(p);return p!==e&&oh(p,m)&&r.push(p),nh(p,m)?r:o(p.parentNode)}return e?o(e):r}function dl(e){const[s]=Pn(e,1);return s??null}function Ai(e){return!di||!e?null:Ks(e)?e:Tn(e)?Mn(e)||e===Vs(e).scrollingElement?window:xr(e)?e:null:null}function ul(e){return Ks(e)?e.scrollX:e.scrollLeft}function hl(e){return Ks(e)?e.scrollY:e.scrollTop}function Ji(e){return{x:ul(e),y:hl(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function fl(e){return!di||!e?!1:e===document.scrollingElement}function ml(e){const s={x:0,y:0},r=fl(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 ah={x:.2,y:.2};function lh(e,s,r,o,p){let{top:m,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),p===void 0&&(p=ah);const{isTop:l,isBottom:h,isLeft:c,isRight:g}=ml(e),x={x:0,y:0},y={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.y=o*Math.abs((s.top+w.height-m)/w.height)):!h&&i>=s.bottom-w.height&&(x.y=dt.Forward,y.y=o*Math.abs((s.bottom-w.height-i)/w.height)),!g&&n>=s.right-w.width?(x.x=dt.Forward,y.x=o*Math.abs((s.right-w.width-n)/w.width)):!c&&v<=s.left+w.width&&(x.x=dt.Backward,y.x=o*Math.abs((s.left+w.width-v)/w.width)),{direction:x,speed:y}}function ch(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 pl(e){return e.reduce((s,r)=>Bs(s,Ji(r)),Ot)}function dh(e){return e.reduce((s,r)=>s+ul(r),0)}function uh(e){return e.reduce((s,r)=>s+hl(r),0)}function gl(e,s){if(s===void 0&&(s=_r),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);dl(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const hh=[["x",["left","right"],dh],["y",["top","bottom"],uh]];class Ln{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=Pn(r),p=pl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,n]of hh)for(const i of v)Object.defineProperty(this,i,{get:()=>{const l=n(o),h=p[m]-l;return this.rect[i]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ar{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 fh(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Vs(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 Rt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rt||(Rt={}));function xo(e){e.preventDefault()}function mh(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 vl={start:[qe.Space,qe.Enter],cancel:[qe.Esc],end:[qe.Space,qe.Enter,qe.Tab]},ph=(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 xl{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 ar(Vs(r)),this.windowListeners=new ar(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&gl(o),r(Ot)}handleKeyDown(s){if(Dn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=vl,coordinateGetter:v=ph,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,h=l?{x:l.left,y:l.top}:Ot;this.referenceCoordinates||(this.referenceCoordinates=h);const c=v(s,{active:r,context:o.current,currentCoordinates:h});if(c){const g=Qr(c,h),x={x:0,y:0},{scrollableAncestors:y}=o.current;for(const w of y){const a=s.code,{isTop:u,isRight:d,isLeft:f,isBottom:S,maxScroll:C,minScroll:k}=ml(w),E=ch(w),_={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&&!u;if(j&&_.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!==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,Bs(Qr(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()}}xl.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=vl,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 bo(e){return!!(e&&"distance"in e)}function _o(e){return!!(e&&"delay"in e)}class In{constructor(s,r,o){var p;o===void 0&&(o=fh(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=Vs(v),this.documentListeners=new ar(this.document),this.listeners=new ar(o),this.windowListeners=new ar(yt(v)),this.initialCoordinates=(p=Zr(m))!=null?p:Ot,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(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,xo),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,xo),this.documentListeners.add(Rt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(_o(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(bo(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(Rt.Click,mh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.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=Zr(s))!=null?r:Ot,l=Qr(p,i);if(!o&&n){if(bo(n)){if(n.tolerance!=null&&Ti(l,n.tolerance))return this.handleCancel();if(Ti(l,n.distance))return this.handleStart()}if(_o(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 gh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class On extends In{constructor(s){const{event:r}=s,o=Vs(r.target);super(s,gh,o)}}On.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 vh={move:{name:"mousemove"},end:{name:"mouseup"}};var en;(function(e){e[e.RightClick=2]="RightClick"})(en||(en={}));class xh extends In{constructor(s){super(s,vh,Vs(s.event.target))}}xh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===en.RightClick?!1:(o?.({event:r}),!0)}}];const Mi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class bh extends In{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(){}}}bh.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 lr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(lr||(lr={}));var ei;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ei||(ei={}));function _h(e){let{acceleration:s,activator:r=lr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:n=ei.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:h,delta:c,threshold:g}=e;const x=Sh({delta:c,disabled:!m}),[y,w]=Du(),a=b.useRef({x:0,y:0}),u=b.useRef({x:0,y:0}),d=b.useMemo(()=>{switch(r){case lr.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case lr.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*u.current.x,_=a.current.y*u.current.y;k.scrollBy(E,_)},[]),C=b.useMemo(()=>n===ei.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),_=h[E];if(!_)continue;const{direction:j,speed:R}=lh(k,_,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,y(S,v),a.current=R,u.current=j;return}}a.current={x:0,y:0},u.current={x:0,y:0},w()},[s,S,o,w,m,v,JSON.stringify(d),JSON.stringify(x),y,l,C,h,JSON.stringify(g)])}const yh={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function Sh(e){let{delta:s,disabled:r}=e;const o=Gr(s);return br(p=>{if(r||!o||!p)return yh;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 wh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return br(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function Ch(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 pr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(pr||(pr={}));var tn;(function(e){e.Optimized="optimized"})(tn||(tn={}));const yo=new Map;function kh(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,v]=b.useState(null),{frequency:n,measure:i,strategy:l}=p,h=b.useRef(e),c=a(),g=fr(c),x=b.useCallback(function(u){u===void 0&&(u=[]),!g.current&&v(d=>d===null?u:d.concat(u.filter(f=>!d.includes(f))))},[g]),y=b.useRef(null),w=br(u=>{if(c&&!r)return yo;if(!u||u===yo||h.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 Ln(i(S),S):null;f.rect.current=C,C&&d.set(f.id,C)}return d}return u},[e,m,r,c,i]);return b.useEffect(()=>{h.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"||y.current!==null||(y.current=setTimeout(()=>{x(),y.current=null},n))},[n,c,x,...o]),{droppableRects:w,measureDroppableContainers:x,measuringScheduled:m!=null};function a(){switch(l){case pr.Always:return!1;case pr.BeforeDragging:return r;default:return!r}}}function Bn(e,s){return br(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Eh(e,s){return Bn(e,s)}function jh(e){let{callback:s,disabled:r}=e;const o=ui(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 fi(e){let{callback:s,disabled:r}=e;const o=ui(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 Nh(e){return new Ln(_r(e),e)}function So(e,s,r){s===void 0&&(s=Nh);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 h=s(e);return JSON.stringify(i)===JSON.stringify(h)?i:h})}const v=jh({callback(i){if(e)for(const l of i){const{type:h,target:c}=l;if(h==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),n=fi({callback:m});return es(()=>{m(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function Rh(e){const s=Bn(e);return ll(e,s)}const wo=[];function Ah(e){const s=b.useRef(e),r=br(o=>e?o&&o!==wo&&e&&s.current&&e.parentNode===s.current.parentNode?o:Pn(e):wo,[e]);return b.useEffect(()=>{s.current=e},[e]),r}function Th(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,Ji(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,Ji(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)=>Bs(m,v),Ot):pl(e):Ot,[e,s])}function Co(e,s){s===void 0&&(s=[]);const r=b.useRef(null);return b.useEffect(()=>{r.current=null},s),b.useEffect(()=>{const o=e!==Ot;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Qr(e,r.current):Ot}function Mh(e){b.useEffect(()=>{if(!di)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 Dh(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 bl(e){return b.useMemo(()=>e?ih(e):null,[e])}const ko=[];function Ph(e,s){s===void 0&&(s=_r);const[r]=e,o=bl(r?yt(r):null),[p,m]=b.useState(ko);function v(){m(()=>e.length?e.map(i=>fl(i)?o:new Ln(s(i),i)):ko)}const n=fi({callback:v});return es(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),p}function _l(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return xr(s)?s:e}function Lh(e){let{measure:s}=e;const[r,o]=b.useState(null),p=b.useCallback(l=>{for(const{target:h}of l)if(xr(h)){o(c=>{const g=s(h);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=fi({callback:p}),v=b.useCallback(l=>{const h=_l(l);m?.disconnect(),h&&m?.observe(h),o(h?s(h):null)},[s,m]),[n,i]=Yr(v);return b.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const Ih=[{sensor:On,options:{}},{sensor:xl,options:{}}],Oh={current:{}},Hr={draggable:{measure:vo},droppable:{measure:vo,strategy:pr.WhileDragging,frequency:tn.Optimized},dragOverlay:{measure:_r}};class cr 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 Bh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new cr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Hr,measureDroppableContainers:Jr,windowRect:null,measuringScheduled:!1},yl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Jr,draggableNodes:new Map,over:null,measureDroppableContainers:Jr},yr=b.createContext(yl),Sl=b.createContext(Bh);function Fh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new cr}}}function zh(e,s){switch(s.type){case at.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case at.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 at.DragEnd:case at.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case at.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new cr(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case at.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 cr(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case at.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new cr(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function Wh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=b.useContext(yr),m=Gr(o),v=Gr(r?.id);return b.useEffect(()=>{if(!s&&!o&&m&&v!=null){if(!Dn(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 h of[i.current,l.current]){if(!h)continue;const c=Iu(h);if(c){c.focus();break}}})}},[o,s,p,v,m]),null}function wl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function Hh(e){return b.useMemo(()=>({draggable:{...Hr.draggable,...e?.draggable},droppable:{...Hr.droppable,...e?.droppable},dragOverlay:{...Hr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function $h(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;es(()=>{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 h=r(l),c=ll(h,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=dl(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,n,o,r])}const mi=b.createContext({...Ot,scaleX:1,scaleY:1});var ss;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ss||(ss={}));const Uh=b.memo(function(s){var r,o,p,m;let{id:v,accessibility:n,autoScroll:i=!0,children:l,sensors:h=Ih,collisionDetection:c=Zu,measuring:g,modifiers:x,...y}=s;const w=b.useReducer(zh,void 0,Fh),[a,u]=w,[d,f]=Hu(),[S,C]=b.useState(ss.Uninitialized),k=S===ss.Initialized,{draggable:{active:E,nodes:_,translate:j},droppable:{containers:R}}=a,L=E!=null?_.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:Oh,rect:T}:null},[E,L]),F=b.useRef(null),[I,H]=b.useState(null),[q,A]=b.useState(null),P=fr(y,Object.values(y)),M=hi("DndDescribedBy",v),O=b.useMemo(()=>R.getEnabled(),[R]),$=Hh(g),{droppableRects:K,measureDroppableContainers:B,measuringScheduled:z}=kh(O,{dragging:k,dependencies:[j.x,j.y],config:$.droppable}),U=wh(_,E),N=b.useMemo(()=>q?Zr(q):null,[q]),W=Y(),X=Eh(U,$.draggable.measure);$h({activeNode:E!=null?_.get(E):null,config:W.layoutShiftCompensation,initialRect:X,measure:$.draggable.measure});const V=So(U,$.draggable.measure,X),ie=So(U?U.parentElement:null),ee=b.useRef({activatorEvent:null,active:null,activeNode:U,collisionRect:null,collisions:null,droppableRects:K,draggableNodes:_,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),me=R.getNodeFor((r=ee.current.over)==null?void 0:r.id),he=Lh({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),Fe=Rh(oe?null:V),ut=bl(G?yt(G):null),Ie=Ah(k?me??U:null),be=Ph(Ie),$e=wl(x,{transform:{x:j.x-Fe.x,y:j.y-Fe.y,scaleX:1,scaleY:1},activatorEvent:q,active:D,activeNodeRect:V,containerNodeRect:ie,draggingNodeRect:pe,over:ee.current.over,overlayNodeRect:he.rect,scrollableAncestors:Ie,scrollableAncestorRects:be,windowRect:ut}),Oe=N?Bs(N,j):null,tt=Th(Ie),Ye=Co(tt),Ze=Co(tt,[V]),Xe=Bs($e,Ye),Ne=pe?th(pe,$e):null,Ae=D&&Ne?c({active:D,collisionRect:Ne,droppableRects:K,droppableContainers:O,pointerCoordinates:Oe}):null,ve=Gu(Ae,"id"),[ze,_e]=b.useState(null),pt=oe?$e:Bs($e,Ze),Je=Ju(pt,(m=ze?.rect)!=null?m:null,V),Dt=b.useRef(null),J=b.useCallback((se,ne)=>{let{sensor:ke,options:xe}=ne;if(F.current==null)return;const je=_.get(F.current);if(!je)return;const Pe=se.nativeEvent,ye=new ke({active:F.current,activeNode:je,event:Pe,options:xe,context:ee,onAbort(Se){if(!_.get(Se))return;const{onDragAbort:Qe}=P.current,rt={id:Se};Qe?.(rt),d({type:"onDragAbort",event:rt})},onPending(Se,Te,Qe,rt){if(!_.get(Se))return;const{onDragPending:it}=P.current,nt={id:Se,constraint:Te,initialCoordinates:Qe,offset:rt};it?.(nt),d({type:"onDragPending",event:nt})},onStart(Se){const Te=F.current;if(Te==null)return;const Qe=_.get(Te);if(!Qe)return;const{onDragStart:rt}=P.current,$t={activatorEvent:Pe,active:{id:Te,data:Qe.data,rect:T}};_s.unstable_batchedUpdates(()=>{rt?.($t),C(ss.Initializing),u({type:at.DragStart,initialCoordinates:Se,active:Te}),d({type:"onDragStart",event:$t}),H(Dt.current),A(Pe)})},onMove(Se){u({type:at.DragMove,coordinates:Se})},onEnd:Le(at.DragEnd),onCancel:Le(at.DragCancel)});Dt.current=ye;function Le(Se){return async function(){const{active:Qe,collisions:rt,over:$t,scrollAdjustedTranslate:it}=ee.current;let nt=null;if(Qe&&it){const{cancelDrop:gt}=P.current;nt={activatorEvent:Pe,active:Qe,collisions:rt,delta:it,over:$t},Se===at.DragEnd&&typeof gt=="function"&&await Promise.resolve(gt(nt))&&(Se=at.DragCancel)}F.current=null,_s.unstable_batchedUpdates(()=>{u({type:Se}),C(ss.Uninitialized),_e(null),H(null),A(null),Dt.current=null;const gt=Se===at.DragEnd?"onDragEnd":"onDragCancel";if(nt){const Ut=P.current[gt];Ut?.(nt),d({type:gt,event:nt})}})}}},[_]),fe=b.useCallback((se,ne)=>(ke,xe)=>{const je=ke.nativeEvent,Pe=_.get(xe);if(F.current!==null||!Pe||je.dndKit||je.defaultPrevented)return;const ye={active:Pe};se(ke,ne.options,ye)===!0&&(je.dndKit={capturedBy:ne.sensor},F.current=xe,J(ke,ne))},[_,J]),de=Ch(h,fe);Mh(h),es(()=>{V&&S===ss.Initializing&&C(ss.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 Pe={active:ne,activatorEvent:ke,collisions:xe,delta:{x:Xe.x,y:Xe.y},over:je};_s.unstable_batchedUpdates(()=>{se?.(Pe),d({type:"onDragMove",event:Pe})})},[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:Pe}=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};_s.unstable_batchedUpdates(()=>{_e(Le),Pe?.(Se),d({type:"onDragOver",event:Se})})},[ve]),es(()=>{ee.current={activatorEvent:q,active:D,activeNode:U,collisionRect:Ne,collisions:Ae,droppableRects:K,draggableNodes:_,draggingNode:G,draggingNodeRect:pe,droppableContainers:R,over:ze,scrollableAncestors:Ie,scrollAdjustedTranslate:Xe},T.current={initial:pe,translated:Ne}},[D,U,Ae,Ne,_,G,pe,K,R,ze,Ie,Xe]),_h({...W,delta:j,draggingRect:Ne,pointerCoordinates:Oe,scrollableAncestors:Ie,scrollableAncestorRects:be});const ge=b.useMemo(()=>({active:D,activeNode:U,activeNodeRect:V,activatorEvent:q,collisions:Ae,containerNodeRect:ie,dragOverlay:he,draggableNodes:_,droppableContainers:R,droppableRects:K,over:ze,measureDroppableContainers:B,scrollableAncestors:Ie,scrollableAncestorRects:be,measuringConfiguration:$,measuringScheduled:z,windowRect:ut}),[D,U,V,q,Ae,ie,he,_,R,K,ze,B,Ie,be,$,z,ut]),Ce=b.useMemo(()=>({activatorEvent:q,activators:de,active:D,activeNodeRect:V,ariaDescribedById:{draggable:M},dispatch:u,draggableNodes:_,over:ze,measureDroppableContainers:B}),[q,de,D,V,u,M,_,ze,B]);return le.createElement(al.Provider,{value:f},le.createElement(yr.Provider,{value:Ce},le.createElement(Sl.Provider,{value:ge},le.createElement(mi.Provider,{value:Je},l)),le.createElement(Wh,{disabled:n?.restoreFocus===!1})),le.createElement(qu,{...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}}}),qh=b.createContext(null),Eo="button",Kh="Draggable";function Vh(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=hi(Kh),{activators:v,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:h,draggableNodes:c,over:g}=b.useContext(yr),{role:x=Eo,roleDescription:y="draggable",tabIndex:w=0}=p??{},a=i?.id===s,u=b.useContext(a?mi:qh),[d,f]=Yr(),[S,C]=Yr(),k=Dh(v,s),E=fr(r);es(()=>(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 _=b.useMemo(()=>({role:x,tabIndex:w,"aria-disabled":o,"aria-pressed":a&&x===Eo?!0:void 0,"aria-roledescription":y,"aria-describedby":h.draggable}),[o,x,w,a,y,h.draggable]);return{active:i,activatorEvent:n,activeNodeRect:l,attributes:_,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:C,transform:u}}function Xh(){return b.useContext(Sl)}const Yh="Droppable",Gh={timeout:25};function Qh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=hi(Yh),{active:v,dispatch:n,over:i,measureDroppableContainers:l}=b.useContext(yr),h=b.useRef({disabled:r}),c=b.useRef(!1),g=b.useRef(null),x=b.useRef(null),{disabled:y,updateMeasurementsFor:w,timeout:a}={...Gh,...p},u=fr(w??o),d=b.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(u.current)?u.current:[u.current]),x.current=null},a)},[a]),f=fi({callback:d,disabled:y||!v}),S=b.useCallback((_,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),_&&f.observe(_))},[f]),[C,k]=Yr(S),E=fr(s);return b.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),b.useEffect(()=>(n({type:at.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:E}}),()=>n({type:at.UnregisterDroppable,key:m,id:o})),[o]),b.useEffect(()=>{r!==h.current.disabled&&(n({type:at.SetDroppableDisabled,id:o,key:m,disabled:r}),h.current.disabled=r)},[o,m,r,n]),{active:v,rect:g,isOver:i?.id===o,node:C,over:i,setNodeRef:k}}function Zh(e){let{animation:s,children:r}=e;const[o,p]=b.useState(null),[m,v]=b.useState(null),n=Gr(r);return!r&&!o&&n&&p(n),es(()=>{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 Jh={x:0,y:0,scaleX:1,scaleY:1};function ef(e){let{children:s}=e;return le.createElement(yr.Provider,{value:yl},le.createElement(mi.Provider,{value:Jh},s))}const tf={position:"fixed",touchAction:"none"},sf=e=>Dn(e)?"transform 250ms ease":void 0,rf=b.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:v,rect:n,style:i,transform:l,transition:h=sf}=e;if(!n)return null;const c=p?l:{...l,scaleX:1,scaleY:1},g={...tf,width:n.width,height:n.height,top:n.top,left:n.left,transform:mr.Transform.toString(c),transformOrigin:p&&o?Xu(o,n):void 0,transition:typeof h=="function"?h(o):h,...i};return le.createElement(r,{className:v,style:g,ref:s},m)}),nf=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)}},of=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:mr.Transform.toString(s)},{transform:mr.Transform.toString(r)}]},af={duration:250,easing:"ease",keyframes:of,sideEffects:nf({styles:{active:{opacity:"0"}}})};function lf(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return ui((m,v)=>{if(s===null)return;const n=r.get(m);if(!n)return;const i=n.node.current;if(!i)return;const l=_l(v);if(!l)return;const{transform:h}=yt(v).getComputedStyle(v),c=cl(h);if(!c)return;const g=typeof s=="function"?s:cf(s);return gl(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 cf(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...af,...e};return m=>{let{active:v,dragOverlay:n,transform:i,...l}=m;if(!s)return;const h={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-h.x,y:i.y-h.y,...c},x=p({...l,active:v,dragOverlay:n,transform:{initial:i,final:g}}),[y]=x,w=x[x.length-1];if(JSON.stringify(y)===JSON.stringify(w))return;const a=o?.({active:v,dragOverlay:n,...l}),u=n.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{u.onfinish=()=>{a?.(),d()}})}}let jo=0;function df(e){return b.useMemo(()=>{if(e!=null)return jo++,jo},[e])}const uf=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:h,active:c,activeNodeRect:g,containerNodeRect:x,draggableNodes:y,droppableContainers:w,dragOverlay:a,over:u,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:S,windowRect:C}=Xh(),k=b.useContext(mi),E=df(c?.id),_=wl(v,{activatorEvent:h,active:c,activeNodeRect:g,containerNodeRect:x,draggingNodeRect:a.rect,over:u,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:S,transform:k,windowRect:C}),j=Bn(g),R=lf({config:o,draggableNodes:y,droppableContainers:w,measuringConfiguration:d}),L=j?a.setRef:void 0;return le.createElement(ef,null,le.createElement(Zh,{animation:R},c&&E?le.createElement(rf,{key:E,id:c.id,ref:L,as:n,activatorEvent:h,adjustScale:s,className:i,transition:m,rect:j,style:{zIndex:l,...p},transform:_},r):null))}),Cl=768;function hf(e){const s=window.matchMedia(`(max-width: ${Cl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function ff(){return window.innerWidth<Cl}function mf(){return!1}function kl(){return b.useSyncExternalStore(hf,ff,mf)}const pf=1500,gf=2e3,vf=5e3;function El(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?pf:!1}function xf(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?gf:!1}function bf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?vf:!1}function Fn(e){return kt({queryKey:ce.workspaces.list(e),queryFn:()=>Ee.get(`/tasks/${e}/workspaces`),enabled:!!e})}function jl(e){const s=bt();return Bt({mutationFn:r=>Ee.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ce.workspaces.list(e)}),s.invalidateQueries({queryKey:ce.tasks.all})}})}function Nl(){const e=bt();return Bt({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 _f(){const e=bt();return Bt({mutationFn:s=>Ee.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function zn(){return Bt({mutationFn:({workspaceId:e,editorType:s})=>Ee.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Wn(e,s={}){const r=Cs(p=>p.visibleContext),o=xf(e,r);return kt({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 Rl(){const e=bt();return Bt({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 Hn(){const e=bt();return Bt({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 yf(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 $n({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:v}){const{t:n}=ae(),{data:i,isLoading:l}=Fn(m===void 0&&e?o:""),h=m??i,c=m===void 0&&e&&l,g=b.useMemo(()=>yf(h,n),[h,n]);return t.jsx(_n,{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,y)=>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})]},y))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||c})}const we={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},sn={[we.Review]:{label:"Review",icon:$a,iconClass:"text-warning",accentClass:"text-warning"},[we.Running]:{label:"Running",icon:Ha,iconClass:"text-info",accentClass:"text-info"},[we.Pending]:{label:"Pending",icon:Wa,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[we.Done]:{label:"Done",icon:za,iconClass:"text-success/80",accentClass:"text-success"},[we.Cancelled]:{label:"Cancelled",icon:Fa,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},Sf=[we.Review,we.Running,we.Pending,we.Done,we.Cancelled],Al=b.createContext(null),wf=3e4;function Cf(e=wf){const[,s]=b.useState(0);b.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function kf(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 Ef({task:e,status:s,isSelected:r,project:o,onSelectTask:p,onTaskStatusChange:m,onDeleteTask:v,disableDrag:n}){const{t:i}=ae(),l=b.useContext(Al),h=b.useRef(null),c=!!e.projectArchivedAt,g=c||!!n,{attributes:x,listeners:y,setNodeRef:w,isDragging:a}=Vh({id:e.id,data:{task:e,fromStatus:s},disabled:g}),u=b.useCallback(T=>{h.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),_=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:u,onClick:()=>p(e.id),onContextMenu:_,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
|
+
`},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=hi("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?_s.createPortal(u,r):u}var at;(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"})(at||(at={}));function Jr(){}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 Ot=Object.freeze({x:0,y:0});function Zu(e,s){const r=Zr(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}:Ot}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 _r(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 _r(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(!xr(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!di||!e?null:Ks(e)?e:Mn(e)?Dn(e)||e===Vs(e).scrollingElement?window:xr(e)?e:null:null}function hl(e){return Ks(e)?e.scrollX:e.scrollLeft}function fl(e){return Ks(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!di||!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)=>Bs(s,en(r)),Ot)}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=_r),!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 ar{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:Vs(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 Rt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rt||(Rt={}));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 ar(Vs(r)),this.windowListeners=new ar(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&vl(o),r(Ot)}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}:Ot;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Qr(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,Bs(Qr(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=Vs(v),this.documentListeners=new ar(this.document),this.listeners=new ar(o),this.windowListeners=new ar(yt(v)),this.initialCoordinates=(p=Zr(m))!=null?p:Ot,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(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,bo),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,bo),this.documentListeners.add(Rt.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(Rt.Click,xh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.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=Zr(s))!=null?r:Ot,l=Qr(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=Vs(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,Vs(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 lr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(lr||(lr={}));var ei;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ei||(ei={}));function Ch(e){let{acceleration:s,activator:r=lr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:n=ei.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 lr.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case lr.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===ei.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=Gr(s);return br(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 br(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 pr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(pr||(pr={}));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=fr(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=br(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 pr.Always:return!1;case pr.BeforeDragging:return r;default:return!r}}}function Fn(e,s){return br(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=ui(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 fi(e){let{callback:s,disabled:r}=e;const o=ui(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(_r(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=fi({callback:m});return es(()=>{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=br(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)=>Bs(m,v),Ot):gl(e):Ot,[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!==Ot;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Qr(e,r.current):Ot}function Ih(e){b.useEffect(()=>{if(!di)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=_r);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=fi({callback:v});return es(()=>{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 xr(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(xr(u)){o(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=fi({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]=Yr(v);return b.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const zh=[{sensor:Bn,options:{}},{sensor:bl,options:{}}],Wh={current:{}},Hr={draggable:{measure:xo},droppable:{measure:xo,strategy:pr.WhileDragging,frequency:sn.Optimized},dragOverlay:{measure:_r}};class cr 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 cr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Hr,measureDroppableContainers:Jr,windowRect:null,measuringScheduled:!1},Sl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Jr,draggableNodes:new Map,over:null,measureDroppableContainers:Jr},yr=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 cr}}}function Uh(e,s){switch(s.type){case at.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case at.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 at.DragEnd:case at.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case at.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new cr(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case at.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 cr(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case at.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new cr(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(yr),m=Gr(o),v=Gr(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:{...Hr.draggable,...e?.draggable},droppable:{...Hr.droppable,...e?.droppable},dragOverlay:{...Hr.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;es(()=>{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 mi=b.createContext({...Ot,scaleX:1,scaleY:1});var ss;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ss||(ss={}));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(ss.Uninitialized),k=S===ss.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=fr(_,Object.values(_)),M=hi("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?Zr(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),ze=Dh(oe?null:V),ut=_l(G?yt(G):null),Ie=Ph(k?me??U:null),be=Bh(Ie),$e=Cl(x,{transform:{x:j.x-ze.x,y:j.y-ze.y,scaleX:1,scaleY:1},activatorEvent:q,active:D,activeNodeRect:V,containerNodeRect:ie,draggingNodeRect:pe,over:ee.current.over,overlayNodeRect:he.rect,scrollableAncestors:Ie,scrollableAncestorRects:be,windowRect:ut}),Oe=N?Bs(N,j):null,tt=Lh(Ie),Ye=ko(tt),Ze=ko(tt,[V]),Xe=Bs($e,Ye),Ne=pe?nh(pe,$e):null,Ae=D&&Ne?c({active:D,collisionRect:Ne,droppableRects:K,droppableContainers:O,pointerCoordinates:Oe}):null,ve=eh(Ae,"id"),[We,_e]=b.useState(null),pt=oe?$e:Bs($e,Ze),Je=rh(pt,(m=We?.rect)!=null?m:null,V),Dt=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 Pe=se.nativeEvent,ye=new ke({active:F.current,activeNode:je,event:Pe,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,Me,Qe,rt){if(!y.get(Se))return;const{onDragPending:it}=P.current,nt={id:Se,constraint:Me,initialCoordinates:Qe,offset:rt};it?.(nt),d({type:"onDragPending",event:nt})},onStart(Se){const Me=F.current;if(Me==null)return;const Qe=y.get(Me);if(!Qe)return;const{onDragStart:rt}=P.current,qt={activatorEvent:Pe,active:{id:Me,data:Qe.data,rect:T}};_s.unstable_batchedUpdates(()=>{rt?.(qt),C(ss.Initializing),h({type:at.DragStart,initialCoordinates:Se,active:Me}),d({type:"onDragStart",event:qt}),H(Dt.current),A(Pe)})},onMove(Se){h({type:at.DragMove,coordinates:Se})},onEnd:Le(at.DragEnd),onCancel:Le(at.DragCancel)});Dt.current=ye;function Le(Se){return async function(){const{active:Qe,collisions:rt,over:qt,scrollAdjustedTranslate:it}=ee.current;let nt=null;if(Qe&&it){const{cancelDrop:gt}=P.current;nt={activatorEvent:Pe,active:Qe,collisions:rt,delta:it,over:qt},Se===at.DragEnd&&typeof gt=="function"&&await Promise.resolve(gt(nt))&&(Se=at.DragCancel)}F.current=null,_s.unstable_batchedUpdates(()=>{h({type:Se}),C(ss.Uninitialized),_e(null),H(null),A(null),Dt.current=null;const gt=Se===at.DragEnd?"onDragEnd":"onDragCancel";if(nt){const Kt=P.current[gt];Kt?.(nt),d({type:gt,event:nt})}})}}},[y]),fe=b.useCallback((se,ne)=>(ke,xe)=>{const je=ke.nativeEvent,Pe=y.get(xe);if(F.current!==null||!Pe||je.dndKit||je.defaultPrevented)return;const ye={active:Pe};se(ke,ne.options,ye)===!0&&(je.dndKit={capturedBy:ne.sensor},F.current=xe,J(ke,ne))},[y,J]),de=Nh(u,fe);Ih(u),es(()=>{V&&S===ss.Initializing&&C(ss.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 Pe={active:ne,activatorEvent:ke,collisions:xe,delta:{x:Xe.x,y:Xe.y},over:je};_s.unstable_batchedUpdates(()=>{se?.(Pe),d({type:"onDragMove",event:Pe})})},[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:Pe}=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};_s.unstable_batchedUpdates(()=>{_e(Le),Pe?.(Se),d({type:"onDragOver",event:Se})})},[ve]),es(()=>{ee.current={activatorEvent:q,active:D,activeNode:U,collisionRect:Ne,collisions:Ae,droppableRects:K,draggableNodes:y,draggingNode:G,draggingNodeRect:pe,droppableContainers:R,over:We,scrollableAncestors:Ie,scrollAdjustedTranslate:Xe},T.current={initial:pe,translated:Ne}},[D,U,Ae,Ne,y,G,pe,K,R,We,Ie,Xe]),Ch({...W,delta:j,draggingRect:Ne,pointerCoordinates:Oe,scrollableAncestors:Ie,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:We,measureDroppableContainers:B,scrollableAncestors:Ie,scrollableAncestorRects:be,measuringConfiguration:$,measuringScheduled:z,windowRect:ut}),[D,U,V,q,Ae,ie,he,y,R,K,We,B,Ie,be,$,z,ut]),Ce=b.useMemo(()=>({activatorEvent:q,activators:de,active:D,activeNodeRect:V,ariaDescribedById:{draggable:M},dispatch:h,draggableNodes:y,over:We,measureDroppableContainers:B}),[q,de,D,V,h,M,y,We,B]);return le.createElement(ll.Provider,{value:f},le.createElement(yr.Provider,{value:Ce},le.createElement(wl.Provider,{value:ge},le.createElement(mi.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=hi(Gh),{activators:v,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=b.useContext(yr),{role:x=jo,roleDescription:_="draggable",tabIndex:w=0}=p??{},a=i?.id===s,h=b.useContext(a?mi:Yh),[d,f]=Yr(),[S,C]=Yr(),k=Oh(v,s),E=fr(r);es(()=>(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=hi(Jh),{active:v,dispatch:n,over:i,measureDroppableContainers:l}=b.useContext(yr),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=fr(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=fi({callback:d,disabled:_||!v}),S=b.useCallback((y,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),y&&f.observe(y))},[f]),[C,k]=Yr(S),E=fr(s);return b.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),b.useEffect(()=>(n({type:at.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:E}}),()=>n({type:at.UnregisterDroppable,key:m,id:o})),[o]),b.useEffect(()=>{r!==u.current.disabled&&(n({type:at.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=Gr(r);return!r&&!o&&n&&p(n),es(()=>{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(yr.Provider,{value:Sl},le.createElement(mi.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:mr.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:mr.Transform.toString(s)},{transform:mr.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 ui((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(mi),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 kt({queryKey:ce.workspaces.list(e),queryFn:()=>Ee.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Nl(e){const s=bt();return Bt({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 Bt({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 Bt({mutationFn:s=>Ee.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function Wn(){return Bt({mutationFn:({workspaceId:e,editorType:s})=>Ee.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Hn(e,s={}){const r=Cs(p=>p.visibleContext),o=Sf(e,r);return kt({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 Bt({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 Bt({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
|
|
7
7
|
${a?"opacity-30":""}
|
|
8
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,...g?{}:
|
|
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:
|
|
10
|
-
${S&&!
|
|
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(
|
|
12
|
-
${w===i?"bg-accent":""}`,children:[t.jsx(
|
|
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(
|
|
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(Mt,{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
|
+
${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
|
+
${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(oi,{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(zs,{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 pi=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=>pi.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(_=>pi.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(Ht,{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(Fs,{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(Te,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:()=>p(w.id,!1),children:[t.jsx(Fs,{size:11}),t.jsx("span",{children:l(S?"Stopping":"Stop only")})]}),t.jsxs(Te,{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=vr(),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(`
|
|
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
|
|
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($t,{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(Mt,{size:24,"aria-hidden":!0})})]})}function pm({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 hm({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:h}=ae(),c=b.useId(),g=b.useRef(null),[x,y]=b.useState(null),[w,a]=b.useState(!1),[u,d]=b.useState(null),f=dd(e.teamRunId,e.id,!1),S=f.data?.content,C=S?nn(S,r):void 0,E=!!(C&&C!==s)?C:s,_=!!(e.isTruncated&&!Ml(e)),j=x?.messageId===e.id&&x.content===E&&x.expanded,R=b.useCallback(()=>{const I=g.current;I&&a(Bf(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){y({messageId:e.id,content:E,expanded:!1});return}if(_&&!S){const I=await f.refetch();if(I.error){d(on(I.error,h("Failed to load full message")));return}const H=I.data?.content?nn(I.data.content,r):E;y({messageId:e.id,content:H,expanded:!0});return}y({messageId:e.id,content:E,expanded:!0})},[r,_,S,f,j,e.id,E,h]),T=(w||_)&&!j,D=w||_,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:Tl}:void 0,children:[t.jsx(am,{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":h(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(el,{size:13}):t.jsx(wt,{size:13}),t.jsx("span",{children:h(F?"Loading":j?"Collapse message":"Expand full message")})]}),u&&t.jsx("div",{className:te("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:u})]})}function Dl({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(Ht,{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(os,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Jf(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(Ht,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function fm({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(ai,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function mm({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l,onOpenVisualization:h,previewWorkspaceId:c,previewSessionId:g}){const{t:x}=ae(),y=e.senderType==="user",w=e.senderType==="system",a=Ml(e)?e.pendingStatus:null,u=e.mentions??[],d=e.workRequestIds?.length??0,f=e.visibility==="PRIVATE",S=b.useCallback(_=>{l?.(_,c)},[l,c]),C=b.useCallback(_=>{g&&h?.(g,_,c)},[h,g,c]),k=f?im(e,p):[],E=t.jsxs(t.Fragment,{children:[!y&&!w&&o&&t.jsx(fm,{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(cd,{size:10}),t.jsxs("span",{className:"truncate",children:[x("Private"),k.length>0?`: ${k.join(", ")}`:""]})]}),!w&&d>0&&u.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(Dl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:y,isSystem:w,headerAddon:E,bubbleClassName:y&&a==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:a==="sending",children:t.jsx(cm,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:y&&a!=="failed",tone:w?"system":void 0,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l?S:void 0,onOpenVisualization:h&&g?C:void 0,downloadSessionId:g})})}function pm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:n}=ae();return t.jsx(Dl,{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(os,{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??em(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(De,{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(Jt,{size:12}),t.jsx("span",{children:n(m?"Approving":"Approve")})]}),t.jsxs(De,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(Zt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function Pl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:n,centered:i,workingDir:l,onOpenWorkspaceFile:h,onOpenPreviewUrl:c,onOpenVisualization:g}){const{t:x}=ae(),y=Ra(e.id),w=Aa(e.id),a=Ta(e.id),[u,d]=b.useState(""),[f,S]=b.useState(!1),[C,k]=b.useState(null),[E,_]=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}=vn(),X=O.some(Y=>Y.status==="done"&&Y.attachment),[V,ie]=b.useState(null),{scrollRef:ee,contentRef:me,isAtBottom:he,scrollToBottom:G}=Sn({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:Fe}=Us(),ut=b.useMemo(()=>{const Y=new Map;for(const se of Fe??[])Y.set(se.provider.id,se.provider);return Y},[Fe]),Ie=b.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),be=b.useMemo(()=>(e.members??[]).filter(To),[e.members]),$e=b.useMemo(()=>new Map((e.invocations??[]).map(Y=>[Y.id,Y])),[e.invocations]),Oe=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(()=>Hf(Oe,e.workRequests??[],e.invocations??[]),[Oe,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=>pi.has(Y.status)),[e.invocations]),Xe=b.useMemo(()=>j.map(Y=>Ie.get(Y)).filter(Y=>!!Y).filter(To),[Ie,j]),Ne=b.useMemo(()=>{const Y=C?.query??"";return be.filter(se=>sm(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(tm(Y,se)),_(0)},[]),ze=b.useCallback(Y=>{R(je=>Ff(je,Y.id));const se=`@${Y.name} `;if(C){const je=`${u.slice(0,C.start)}${se}${u.slice(C.end)}`,Pe=C.start+se.length;d(je),k(null),S(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(Pe,Pe)});return}const ne=u.length===0||/\s$/.test(u)?"":" ",ke=`${u}${ne}${se}`,xe=ke.length;d(ke),S(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(xe,xe)})},[u,C]),_e=b.useCallback(Y=>{R(se=>zf(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=""},[$]),Dt=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=Wf(j,be),ke=um({draft:u,attachmentMarkdown:Y,attachmentIds:se,mentions:ne});if(!ke||!u.trim()&&!X)return;const xe=Gf(e.id,ke),je=u,Pe=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(Te=>Te.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(Te=>Te.map(Qe=>Qe.id===xe.id?{...Qe,pendingStatus:"failed",error:Se}:Qe)),d(Te=>Te.length===0?je:Te),R(Te=>Te.length===0?Pe:Te),z(ye),F(Se),requestAnimationFrame(()=>G())}finally{T(!1)}},[be,O,U,B,n,u,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(),_(ne=>(ne+1)%Ne.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),_(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&&ze(ne);return}if(Y.key==="Escape"){Y.preventDefault(),k(null),S(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!se&&(Y.preventDefault(),J())},[ze,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 de=y.isError?y.error:w.isError?w.error:null,ge=y.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(dm,{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(Ss,{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,Te=Ie.get(Se.targetMemberId),Qe=y.isPending&&y.variables===Se.id,rt=w.isPending&&w.variables===Se.id;return t.jsx(pm,{request:Se,member:Te,onApprove:()=>y.mutate(Se.id),onReject:()=>w.mutate(Se.id),isActionPending:ge,isApprovePending:Qe,isRejectPending:rt},Y.key)}const se=Y.message,ne=om(se,Ie,$e),ke=se.senderType==="user"?x("你"):se.senderType==="system"?x("System"):ne?.name??x("Agent"),xe=nm(se,Ie),je=ne?.providerId?ut.get(ne.providerId)??null:null,Pe=se.senderInvocationId?$e.get(se.senderInvocationId):void 0,ye=Pe?.workspaceId??void 0,Le=Pe?.sessionId??void 0;return t.jsx(mm,{message:se,senderName:ke,senderMember:ne,senderProvider:je,memberById:Ie,displayContent:xe,onOpenImage:(Se,Te)=>ie({images:Se,index:Te}),workingDir:l,onOpenWorkspaceFile:h,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:ye,previewSessionId:Le},Y.key)}),de&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:on(de,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:on(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(hr,{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(Xf,{invocations:Ze,memberById:Ie,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:()=>_(se),onMouseDown:xe=>{xe.preventDefault(),ze(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(Ht,{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(lo,{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(Zt,{size:12})})]},Y.id))}),t.jsx(xn,{files:O,onRemove:K}),t.jsx("textarea",{ref:P,value:u,rows:n?1:void 0,onChange:pt,onKeyDown:fe,onPaste:Dt,onClick:Y=>ve(u,Y.currentTarget.selectionStart),onSelect:Y=>ve(u,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(jn,{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(lo,{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||!u.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",(u.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(wn,{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 gm(e){return e?e.slice(0,8):""}function Mo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Un(e){return e?.workspaceKind===_t.MAIN_DIRECTORY}function $s(e){return e?Un(e)?"Project directory":e.branchName:"—"}function as(e){return e?.workingDir||e?.worktreePath||void 0}function qn(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",h=n?.name??(m.ownerMemberId?`Member ${gm(m.ownerMemberId)}`:void 0),c=Un(m)?"Project directory":i?"Main workspace":l==="child"?h?`${h} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:l,roleLabel:i?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:h,parentBranchName:v?$s(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:Mo(m.workspace.createdAt)-Mo(v.workspace.createdAt)})}function Ll(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===At.ACTIVE)?.id??e[0]?.id}function Il(e,s){return!e||e.status!==At.ACTIVE||Un(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Ol(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Kn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},vm=[{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:"合并工作区"}],Bl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],xm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Fl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],bm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function sr(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Kn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Ms(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Kn,...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:{...Kn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function _m(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function ym(e){return{name:e.name.trim(),aliases:_m(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 Do(e,s){return e instanceof Error?e.message:s}function Po(e){return e.membershipStatus!=="REMOVED"}function an(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Lo(e){return an(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Io(e){return Bl.find(s=>s.value===e)?.label??e}function Sm(e){return Fl.find(s=>s.value===e)?.label??e}function zt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Oo({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 wm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ae(),{data:p=[]}=ud(),{data:m=[]}=Us(),v=hd(r.id),n=fd(r.id),i=md(r.id),l=b.useRef(!1),[h,c]=b.useState("edit"),[g,x]=b.useState(null),[y,w]=b.useState(""),[a,u]=b.useState(sr()),[d,f]=b.useState(null),[S,C]=b.useState(null),k=r.members??[],E=b.useMemo(()=>k.filter(Po),[k]),_=b.useMemo(()=>S&&Po(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=y?p.find(U=>U.id===y)??null:null,T=v.isPending||n.isPending||i.isPending,D=_.filter(an).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(ai,{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=_[0]??null;c(U?"edit":"add-preset"),x(U?.id??null),w(""),u(U?Ms(U):sr()),f(null)},[_,e]),b.useEffect(()=>{S&&E.some(U=>U.id===S.id)&&C(null)},[S,E]),b.useEffect(()=>{h==="add-preset"&&L&&u(Di(L))},[h,L]);const I=(U,N)=>{u(W=>({...W,[U]:N}))},H=(U,N)=>{u(W=>({...W,capabilities:{...W.capabilities,[U]:N}}))},q=U=>{c("edit"),x(U.id),w(""),u(Ms(U))},A=()=>{c("add-preset"),x(null);const U=L??p[0]??null;w(U?.id??""),u(U?Di(U):sr())},P=()=>{c("add-custom"),x(null),w(""),u(sr())},M=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),O=h==="add-preset"?!!y:h==="edit"?!!(R&&M):M,$=async()=>{try{if(h==="add-preset"){if(!y)return;const N=await v.mutateAsync({memberPresetId:y});st.success(o("Member added")),C(N),c("edit"),x(N.id),w(""),u(Ms(N));return}const U=ym(a);if(!U.name||!U.providerId||!U.rolePrompt){st.error(o("Name, provider, and role prompt are required"));return}if(h==="add-custom"){const N=await v.mutateAsync({member:U});st.success(o("Member added")),C(N),c("edit"),x(N.id),u(Ms(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),u(Ms(N))}}catch(U){st.error(Do(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=_.find(N=>N.id!==d.id)??null;x(U?.id??null),c(U?"edit":"add-preset"),u(U?Ms(U):sr())}C(U=>U?.id===d.id?null:U),f(null),st.success(o("Member removed"))}catch(U){st.error(Do(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(Ir,{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(De,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(mo,{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(Oo,{icon:t.jsx(Ir,{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(De,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(ns,{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=y===U.id;return t.jsxs("button",{type:"button",onClick:()=>{w(U.id),u(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(Ht,{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(Io(U.workspacePolicy))," · ",o(Sm(U.sessionPolicy))]})]}),N?t.jsx(Jt,{size:16,className:"shrink-0 text-neutral-900"}):null]},U.id)})})})]}),z=()=>{const U=h==="edit";return U&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Oo,{icon:t.jsx(Ss,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(De,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(ns,{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(il,{size:15,className:"text-neutral-500"}):t.jsx(ns,{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(De,{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(Nn,{size:13}),o("Remove")]}):t.jsxs(De,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(Ir,{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(Ht,{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",Lo(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(Io(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(zt,{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(zt,{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(zt,{children:o("Provider")}),t.jsx(is,{value:a.providerId,onChange:N=>I("providerId",N),options:F})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{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(zt,{children:o("Workspace policy")}),t.jsx(is,{value:a.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:Bl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Trigger policy")}),t.jsx(is,{value:a.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:xm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Session policy")}),t.jsx(is,{value:a.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:Fl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Queue policy")}),t.jsx(is,{value:a.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:bm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{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(zt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:vm.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(ds,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(De,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(De,{type:"button",onClick:$,disabled:T||!O,children:o(T?"Processing...":h==="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(Ss,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[_.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(De,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(ns,{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:_.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:_.map(U=>{const N=h==="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(Ht,{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",Lo(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(Cu,{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",h==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Ir,{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",h==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(mo,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:h==="add-preset"?B():z()})]})}),t.jsx(_n,{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&&an(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(ks,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Cm=[],km=[],Em=[],jm=240;function Nm(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 Bo={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 Fo(e,s){return e instanceof Error?e.message:s}function Rm(e,s=jm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Or(e){return e?e.instructionPreview??Rm(e.instruction):""}function Am(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 Tm(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 Mm(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 Dm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Pm(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 Lm(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Im(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 Om(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Bm(e,s){return s.find(r=>r.memberId===e.id&&pi.has(r.status))}function zl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ae(),v=Ra(e.id),n=Aa(e.id),i=Ta(e.id),[l,h]=b.useState(null),[c,g]=b.useState(null),[x,y]=b.useState(!1),[w,a]=b.useState(!1),u=e.members??Cm,d=b.useMemo(()=>u.filter(I=>I.membershipStatus!=="REMOVED"),[u]),f=e.workRequests??km,S=e.invocations??Em,C=b.useMemo(()=>qn(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]),_=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(()=>[...u].map(I=>({member:I,status:Nm(I.status)})).sort((I,H)=>Bo[I.status]-Bo[H.status]),[u]),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(wm,{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(zs,{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(oi,{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(Ss,{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"})]}),_.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(os,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:_.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(os,{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(os,{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=u.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(Ht,{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:Or(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(Dm(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(Jt,{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(Zt,{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:Fo(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(Ss,{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(il,{size:13})})]}),u.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=Bm(I,S),A=Om(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(Ht,{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",Mm(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",Tm(H)),children:m(Am(H))})]}),O&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Or(P)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>h(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(Fs,{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(Zi,{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(Mt,{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:()=>h(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(Fs,{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:()=>h(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(sl,{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",Pm(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:Or(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(Zi,{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:Fo(i.error,m("Failed to stop member work"))})]}),_.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(os,{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:_.length})]}),t.jsx("div",{className:"space-y-1",children:_.map(I=>{const H=u.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(Ht,{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:Or(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:()=>y(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(zs,{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:$s(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(Mt,{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",Im(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",Lm(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:$s(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(Jt,{size:11}):t.jsx(qa,{size:11}),t.jsx("span",{children:m(H?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&_.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:{}},zo;function Fm(){return zo||(zo=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,_=arguments.length,j=_<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=(_<3?E(j):_>3?E(S,C,j):E(S,C))||j);return _>3&&j&&Object.defineProperty(S,C,j),j},h=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),y=i(844),w=i(5596),a=i(4725),u=i(3656);let d=n.AccessibilityManager=class extends y.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
|
-
`)))),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,
|
|
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 _=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),R=this._rowElements[E];R&&(_.length===0?R.innerText=" ":R.textContent=_,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,_;if(S===0?(E=C,_=this._rowElements.pop(),this._rowContainer.removeChild(_)):(E=this._rowElements.shift(),_=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),_.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([h(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 h(g,x,y,w){g=l(g=i(g),y.decPrivateModes.bracketedPasteMode&&w.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),x.value=""}function c(g,x,y){const w=y.getBoundingClientRect(),a=g.clientX-w.left-10,u=g.clientY-w.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${a}px`,x.style.top=`${u}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,y,w){g.stopPropagation(),g.clipboardData&&h(g.clipboardData.getData("text/plain"),x,y,w)},n.paste=h,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(g,x,y,w,a){c(g,x,y),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(h,c,g){this._css.set(h,c,g)}getCss(h,c){return this._css.get(h,c)}setColor(h,c,g){this._color.set(h,c,g)}getColor(h,c){return this._color.get(h,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,h,c){i.addEventListener(l,h,c);let g=!1;return{dispose:()=>{g||(g=!0,i.removeEventListener(l,h,c))}}}},6465:function(v,n,i){var l=this&&this.__decorate||function(a,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,u,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(a,u){return function(d,f){u(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const c=i(3656),g=i(8460),x=i(844),y=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 u=this._linkProviders.indexOf(a);u!==-1&&this._linkProviders.splice(u,1)}}}attachToDom(a,u,d){this._element=a,this._mouseService=u,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 u=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!u)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&&u.x===this._lastBufferCell.x&&u.y===this._lastBufferCell.y||(this._handleHover(u),this._lastBufferCell=u)}_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,u){var d,f;this._activeProviderReplies&&u||((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())u?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(S=this._checkLinkProviderResult(C,a,S)):k.provideLinks(a.y,(E=>{var _,j;if(this._isMouseOut)return;const R=E?.map((L=>({link:L})));(_=this._activeProviderReplies)===null||_===void 0||_.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,u){const d=new Set;for(let f=0;f<u.size;f++){const S=u.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,_=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=_;j++){if(d.has(j)){S.splice(C--,1);break}d.add(j)}}}}_checkLinkProviderResult(a,u,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,u)));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((_=>this._linkAtPosition(_.link,u)));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 u=this._positionFromMouseEvent(a,this._element,this._mouseService);u&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,u)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,u){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!u||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=u)&&(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 u=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);u&&this._linkAtPosition(a.link,u)&&(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,u,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(u,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),u.hover&&u.hover(d,u.text)}_fireUnderlineEvent(a,u){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);(u?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(S)}_linkLeave(a,u,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(u,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),u.leave&&u.leave(d,u.text)}_linkAtPosition(a,u){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=u.y*this._bufferService.cols+u.x;return d<=S&&S<=f}_positionFromMouseEvent(a,u,d){const f=d.getCoords(a,u,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,u,d,f,S){return{x1:a,y1:u,x2:d,y2:f,cols:this._bufferService.cols,fg:S}}};n.Linkifier2=w=l([h(0,y.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,u,d){var f,S=arguments.length,C=S<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,a,u,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(a,u,C):f(a,u))||C);return S>3&&C&&Object.defineProperty(a,u,C),C},h=this&&this.__param||function(w,a){return function(u,d){a(u,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,u){this._bufferService=w,this._optionsService=a,this._oscLinkService=u}provideLinks(w,a){var u;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,_=-1,j=!1;for(let R=0;R<k;R++)if(_!==-1||d.hasContent(R)){if(d.loadCell(R,C),C.hasExtendedAttrs()&&C.extended.urlId){if(_===-1){_=R,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else _!==-1&&(j=!0);if(j||_!==-1&&R===k-1){const L=(u=this._oscLinkService.getLinkData(E))===null||u===void 0?void 0:u.uri;if(L){const T={start:{x:_+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):y(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?(_=R,E=C.extended.urlId):(_=-1,E=-1)}}a(f)}};function y(w,a){if(confirm(`Do you want to navigate to ${a}?
|
|
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(Ht,{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(os,{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(Ht,{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(ai,{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(os,{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(Te,{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(Ut,{size:12}),t.jsx("span",{children:n(m?"Approving":"Approve")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx($t,{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:ze}=Us(),ut=b.useMemo(()=>{const Y=new Map;for(const se of ze??[])Y.set(se.provider.id,se.provider);return Y},[ze]),Ie=b.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),be=b.useMemo(()=>(e.members??[]).filter(Mo),[e.members]),$e=b.useMemo(()=>new Map((e.invocations??[]).map(Y=>[Y.id,Y])),[e.invocations]),Oe=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(Oe,e.workRequests??[],e.invocations??[]),[Oe,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=>pi.has(Y.status)),[e.invocations]),Xe=b.useMemo(()=>j.map(Y=>Ie.get(Y)).filter(Y=>!!Y).filter(Mo),[Ie,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)},[]),We=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)}`,Pe=C.start+se.length;d(je),k(null),S(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(Pe,Pe)});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=""},[$]),Dt=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,Pe=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(Me=>Me.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(Me=>Me.map(Qe=>Qe.id===xe.id?{...Qe,pendingStatus:"failed",error:Se}:Qe)),d(Me=>Me.length===0?je:Me),R(Me=>Me.length===0?Pe:Me),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&&We(ne);return}if(Y.key==="Escape"){Y.preventDefault(),k(null),S(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!se&&(Y.preventDefault(),J())},[We,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 de=_.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(Ss,{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,Me=Ie.get(Se.targetMemberId),Qe=_.isPending&&_.variables===Se.id,rt=w.isPending&&w.variables===Se.id;return t.jsx(bm,{request:Se,member:Me,onApprove:()=>_.mutate(Se.id),onReject:()=>w.mutate(Se.id),isActionPending:ge,isApprovePending:Qe,isRejectPending:rt},Y.key)}const se=Y.message,ne=dm(se,Ie,$e),ke=se.senderType==="user"?x("你"):se.senderType==="system"?x("System"):ne?.name??x("Agent"),xe=cm(se,Ie),je=ne?.providerId?ut.get(ne.providerId)??null:null,Pe=se.senderInvocationId?$e.get(se.senderInvocationId):void 0,ye=Pe?.workspaceId??void 0,Le=Pe?.sessionId??void 0;return t.jsx(xm,{message:se,senderName:ke,senderMember:ne,senderProvider:je,memberById:Ie,displayContent:xe,onOpenImage:(Se,Me)=>ie({images:Se,index:Me}),workingDir:l,onOpenWorkspaceFile:u,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:ye,previewSessionId:Le},Y.key)}),de&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:an(de,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(hr,{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:Ie,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(),We(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(Ht,{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($t,{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:Dt,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 $s(e){return e?qn(e)?"Project directory":e.branchName:"—"}function as(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?$s(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===At.ACTIVE)?.id??e[0]?.id}function Ol(e,s){return!e||e.status!==At.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 sr(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Vn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Ms(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 zt({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=[]}=Us(),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(sr()),[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(ai,{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?Ms(U):sr()),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(Ms(U))},A=()=>{c("add-preset"),x(null);const U=L??p[0]??null;w(U?.id??""),h(U?Di(U):sr())},P=()=>{c("add-custom"),x(null),w(""),h(sr())},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(Ms(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(Ms(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(Ms(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?Ms(U):sr())}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(Ir,{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(Te,{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(Ir,{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(Te,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(ns,{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(Ht,{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(Ut,{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(Ss,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(ns,{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(ns,{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(Te,{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(Te,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(Ir,{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(Ht,{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(zt,{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(zt,{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(zt,{children:o("Provider")}),t.jsx(is,{value:a.providerId,onChange:N=>I("providerId",N),options:F})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{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(zt,{children:o("Workspace policy")}),t.jsx(is,{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(zt,{children:o("Trigger policy")}),t.jsx(is,{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(zt,{children:o("Session policy")}),t.jsx(is,{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(zt,{children:o("Queue policy")}),t.jsx(is,{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(zt,{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(zt,{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(ds,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Te,{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(Ss,{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(Te,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(ns,{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(Ht,{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(Ir,{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(ks,{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 Or(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 At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.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&&pi.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(zs,{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(oi,{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(Ss,{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(os,{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(os,{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(os,{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(Ht,{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:Or(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(Ut,{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($t,{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(Ss,{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(Ht,{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:Or(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(Fs,{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(Mt,{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(Fs,{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:Or(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(os,{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(Ht,{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:Or(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(zs,{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:$s(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(Mt,{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:$s(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(Ut,{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(`
|
|
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
|
+
`&&(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 u=window.open();if(u){try{u.opener=null}catch{}u.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=x=l([h(0,g.IBufferService),h(1,g.IOptionsService),h(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,h){this._rowCount=h,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 h 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=h},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const l=i(3614),h=i(3656),c=i(6465),g=i(9042),x=i(3730),y=i(1680),w=i(3107),a=i(5744),u=i(2950),d=i(1296),f=i(428),S=i(4269),C=i(5114),k=i(8934),E=i(3230),_=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,h.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,h.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,h.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(W=>{W.button===2&&(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,h.addDisposableDomListener)(this.element,"contextmenu",(W=>{(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,h.addDisposableDomListener)(this.element,"auxclick",(W=>{W.button===1&&(0,l.moveTextAreaUnderMouseCursor)(W,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,h.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,h.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,h.addDisposableDomListener)(this.textarea,"focus",(V=>this._handleTextAreaFocus(V)))),this.register((0,h.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(u.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(y.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(_.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,h.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,h.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,h.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,h.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,h.addDisposableDomListener)(W,"touchstart",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ee),this.cancel(ee)}),{passive:!0})),this.register((0,h.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,h){this._rowCount=h,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(u,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(u,d,f,S);else for(var _=u.length-1;_>=0;_--)(C=u[_])&&(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},h=this&&this.__param||function(u,d){return function(f,S){d(f,S,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),g=i(4725),x=i(8460),y=i(844),w=i(2585);let a=n.Viewport=class extends y.Disposable{constructor(u,d,f,S,C,k,E,_){super(),this._viewportElement=u,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(_.colors),this.register(_.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(u){this._viewportElement.style.backgroundColor=u.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(u){if(u)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 u=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==u&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=u),this._refreshAnimationFrame=null}syncScrollArea(u=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(u);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(u)}_handleScroll(u){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 u=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(u*(this._smoothScrollState.target-this._smoothScrollState.origin)),u<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(u,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(u.cancelable&&u.preventDefault(),!1)}handleWheel(u){const d=this._getPixelsScrolled(u);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(u,d))}scrollLines(u){if(u!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=u*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:u,suppressScrollEvent:!1})}_getPixelsScrolled(u){if(u.deltaY===0||u.shiftKey)return 0;let d=this._applyScrollModifier(u.deltaY,u);return u.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:u.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(u,d){var f;let S,C="";const k=[],E=d??this._bufferService.buffer.lines.length,_=this._bufferService.buffer.lines;for(let j=u;j<E;j++){const R=_.get(j);if(!R)continue;const L=(f=_.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=R.translateToString(!L),!L||j===_.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(u){if(u.deltaY===0||u.shiftKey)return 0;let d=this._applyScrollModifier(u.deltaY,u);return u.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):u.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(u,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?u*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:u*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(u){this._lastTouchY=u.touches[0].pageY}handleTouchMove(u){const d=this._lastTouchY-u.touches[0].pageY;return this._lastTouchY=u.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(u,d))}};n.Viewport=a=l([h(2,w.IBufferService),h(3,w.IOptionsService),h(4,g.ICharSizeService),h(5,g.IRenderService),h(6,g.ICoreBrowserService),h(7,g.IThemeService)],a)},3107:function(v,n,i){var l=this&&this.__decorate||function(a,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,u,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(a,u){return function(d,f){u(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),g=i(4725),x=i(844),y=i(2585);let w=n.BufferDecorationRenderer=class extends x.Disposable{constructor(a,u,d,f){super(),this._screenElement=a,this._bufferService=u,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 u,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((u=a?.options)===null||u===void 0?void 0:u.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 u=a.marker.line-this._bufferService.buffers.active.ydisp;if(u<0||u>=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=u*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,u=a.element){var d;if(!u)return;const f=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?u.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":u.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var u;(u=this._decorationElements.get(a))===null||u===void 0||u.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=w=l([h(1,y.IBufferService),h(2,y.IDecorationService),h(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,h){return l>=i.startBufferLine-this._linePadding[h||"full"]&&l<=i.endBufferLine+this._linePadding[h||"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 _,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--)(_=S[L])&&(R=(j<3?_(R):j>3?_(C,k,R):_(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},h=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),y=i(844),w=i(2585),a={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(S,C,k,E,_,j,R){var L;super(),this._viewportElement=S,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=_,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,y.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);u.full=this._canvas.width,u.left=S,u.center=C,u.right=S,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=u.left,d.right=u.left+u.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),u[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([h(2,w.IBufferService),h(3,w.IDecorationService),h(4,x.IRenderService),h(5,w.IOptionsService),h(6,x.ICoreBrowserService)],f)},2950:function(v,n,i){var l=this&&this.__decorate||function(w,a,u,d){var f,S=arguments.length,C=S<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,a,u,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(a,u,C):f(a,u))||C);return S>3&&C&&Object.defineProperty(a,u,C),C},h=this&&this.__param||function(w,a){return function(u,d){a(u,d,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),g=i(2585),x=i(2584);let y=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(w,a,u,d,f,S){this._textarea=w,this._compositionView=a,this._bufferService=u,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 u;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,u=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),u.length>0&&this._coreService.triggerDataEvent(u,!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,u=a.replace(w,"");this._dataAlreadySent=u,a.length>w.length?this._coreService.triggerDataEvent(u,!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),u=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=u+"px",this._compositionView.style.lineHeight=u+"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=y=l([h(2,g.IBufferService),h(3,g.IOptionsService),h(4,g.ICoreService),h(5,c.IRenderService)],y)},9806:(v,n)=>{function i(l,h,c){const g=c.getBoundingClientRect(),x=l.getComputedStyle(c),y=parseInt(x.getPropertyValue("padding-left")),w=parseInt(x.getPropertyValue("padding-top"));return[h.clientX-g.left-y,h.clientY-g.top-w]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(l,h,c,g,x,y,w,a,u){if(!y)return;const d=i(l,h,c);return d?(d[0]=Math.ceil((d[0]+(u?w/2:0))/w),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(u?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 h(a,u,d,f){const S=a-c(a,d),C=u-c(u,d),k=Math.abs(S-C)-(function(E,_,j){let R=0;const L=E-c(E,j),T=_-c(_,j);for(let D=0;D<Math.abs(L-T);D++){const F=g(E,_)==="A"?-1:1,I=j.buffer.lines.get(L+F*D);I?.isWrapped&&R++}return R})(a,u,d);return w(k,y(g(a,u),f))}function c(a,u){let d=0,f=u.buffer.lines.get(a),S=f?.isWrapped;for(;S&&a>=0&&a<u.rows;)d++,f=u.buffer.lines.get(--a),S=f?.isWrapped;return d}function g(a,u){return a>u?"A":"B"}function x(a,u,d,f,S,C){let k=a,E=u,_="";for(;k!==d||E!==f;)k+=S?1:-1,S&&k>C.cols-1?(_+=C.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!S&&k<0&&(_+=C.buffer.translateBufferLineToString(E,!1,0,a+1),k=C.cols-1,a=k,E--);return _+C.buffer.translateBufferLineToString(E,!1,a,k)}function y(a,u){const d=u?"O":"[";return l.C0.ESC+d+a}function w(a,u){a=Math.floor(a);let d="";for(let f=0;f<a;f++)d+=u;return d}n.moveToCellSequence=function(a,u,d,f){const S=d.buffer.x,C=d.buffer.y;if(!d.buffer.hasScrollback)return(function(_,j,R,L,T,D){return h(j,L,T,D).length===0?"":w(x(_,j,_,j-c(j,T),!1,T).length,y("D",D))})(S,C,0,u,d,f)+h(C,u,d,f)+(function(_,j,R,L,T,D){let F;F=h(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=h(P,M,O,$).length>0?M-c(M,O):A,q<P&&K<=M||q>=P&&K<M?"C":"D"})(_,j,R,L,T,D);return w(x(_,F,R,I,H==="C",T).length,y(H,D))})(S,C,a,u,d,f);let k;if(C===u)return k=S>a?"D":"C",w(Math.abs(S-a),y(k,f));k=C>u?"D":"C";const E=Math.abs(C-u);return w((function(_,j){return j.cols-_})(C>u?a:S,d)+(E-1)*d.cols+1+((C>u?S:a)-1),y(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},h=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),y=i(6171),w=i(4725),a=i(8055),u=i(8460),d=i(844),f=i(2585),S="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",_="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 u.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,y.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}.${_} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${_} .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(_)}handleFocus(){this._rowContainer.classList.add(_),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([h(4,f.IInstantiationService),h(5,w.ICharSizeService),h(6,f.IOptionsService),h(7,f.IBufferService),h(8,w.ICoreBrowserService),h(9,w.IThemeService)],L)},3787:function(v,n,i){var l=this&&this.__decorate||function(k,E,_,j){var R,L=arguments.length,T=L<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,_,j);else for(var D=k.length-1;D>=0;D--)(R=k[D])&&(T=(L<3?R(T):L>3?R(E,_,T):R(E,_))||T);return L>3&&T&&Object.defineProperty(E,_,T),T},h=this&&this.__param||function(k,E){return function(_,j){E(_,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),g=i(643),x=i(511),y=i(2585),w=i(8055),a=i(4725),u=i(4269),d=i(6171),f=i(3734);let S=n.DomRendererRowFactory=class{constructor(k,E,_,j,R,L,T){this._document=k,this._characterJoinerService=E,this._optionsService=_,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,_){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=_}createRow(k,E,_,j,R,L,T,D,F,I,H){const q=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let M,O=k.getNoBgTrimmedLength();_&&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 u.JoinedCellData(this._workCell,k.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),pe=_e[1]-1,he=oe.getWidth()}const Fe=this._isCellInSelection(me,E),ut=_&&me===L,Ie=ee&&me>=I&&me<=H;let be=!1;this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{be=!0}));let $e=oe.getChars()||g.WHITESPACE_CELL_CHAR;if($e===" "&&(oe.isUnderline()||oe.isOverline())&&($e=" "),V=he*D-F.get($e,oe.isBold(),oe.isItalic()),M){if($&&(Fe&&X||!Fe&&!X&&oe.bg===B)&&(Fe&&X&&P.selectionForeground||oe.fg===z)&&oe.extended.ext===U&&Ie===N&&V===W&&!ut&&!G&&!be){K+=$e,$++;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=Ie,W=V,X=Fe,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"),Ie&&(M.style.textDecoration="underline");let Oe=oe.getFgColor(),tt=oe.getFgColorMode(),Ye=oe.getBgColor(),Ze=oe.getBgColorMode();const Xe=!!oe.isInverse();if(Xe){const _e=Oe;Oe=Ye,Ye=_e;const pt=tt;tt=Ze,Ze=pt}let Ne,Ae,ve,ze=!1;switch(this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{_e.options.layer!=="top"&&ze||(_e.backgroundColorRGB&&(Ze=50331648,Ye=_e.backgroundColorRGB.rgba>>8&16777215,Ne=_e.backgroundColorRGB),_e.foregroundColorRGB&&(tt=50331648,Oe=_e.foregroundColorRGB.rgba>>8&16777215,Ae=_e.foregroundColorRGB),ze=_e.options.layer==="top")})),!ze&&Fe&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,Ye=Ne.rgba>>8&16777215,Ze=50331648,ze=!0,P.selectionForeground&&(tt=50331648,Oe=P.selectionForeground.rgba>>8&16777215,Ae=P.selectionForeground)),ze&&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()&&Oe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Oe+=8),this._applyMinimumContrast(M,ve,P.ansi[Oe],oe,Ne,void 0)||ie.push(`xterm-fg-${Oe}`);break;case 50331648:const _e=w.rgba.toColor(Oe>>16&255,Oe>>8&255,255&Oe);this._applyMinimumContrast(M,ve,_e,oe,Ne,Ae)||this._addStyle(M,`color:#${C(Oe.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,_,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,_.rgba)),D===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=w.color.ensureContrastRatio(R||E,L||_,F),T.setColor((R||E).rgba,(L||_).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 _=this._selectionStart,j=this._selectionEnd;return!(!_||!j)&&(this._columnSelectMode?_[0]<=j[0]?k>=_[0]&&E>=_[1]&&k<j[0]&&E<=j[1]:k<_[0]&&E>=_[1]&&k>=j[0]&&E<=j[1]:E>_[1]&&E<j[1]||_[1]===j[1]&&E===_[1]&&k>=_[0]&&k<j[0]||_[1]<j[1]&&E===j[1]&&k<j[0]||_[1]<j[1]&&E===_[1]&&k>=_[0])}};function C(k,E,_){for(;k.length<_;)k=E+k;return k}n.DomRendererRowFactory=S=l([h(1,a.ICharacterJoinerService),h(2,y.IOptionsService),h(3,a.ICoreBrowserService),h(4,y.ICoreService),h(5,y.IDecorationService),h(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"),h=i.createElement("span");h.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,h,c,g],this._container.appendChild(l),this._container.appendChild(h),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,h,c){i===this._font&&l===this._fontSize&&h===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=l,this._weight=h,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${h}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${h}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,l,h){let c=0;if(!l&&!h&&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"),h&&(g+="I");let x=this._holey.get(g);if(x===void 0){let y=0;l&&(y|=1),h&&(y|=2),x=this._measure(i,y),this._holey.set(g,x)}return x}_measure(i,l){const h=this._measureElements[l];return h.textContent=i.repeat(32),h.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(h){return 9472<=h&&h<=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,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,u,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(a,u){return function(d,f){u(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),g=i(8460),x=i(844);let y=n.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,u,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,u,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=y=l([h(2,c.IOptionsService)],y);class w{constructor(u,d,f){this._document=u,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 u={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return u.width!==0&&u.height!==0&&(this._result.width=u.width/32,this._result.height=Math.ceil(u.height)),this._result}}},4269:function(v,n,i){var l=this&&this.__decorate||function(u,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(u,d,f,S);else for(var _=u.length-1;_>=0;_--)(C=u[_])&&(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},h=this&&this.__param||function(u,d){return function(f,S){d(f,S,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),g=i(643),x=i(511),y=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 Wl{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,_=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,_,E,f,k);for(let D=0;D<T.length;D++)S.push(T[D])}k=L,_=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,_,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 _=[];try{_=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++)Wl._mergeRanges(_,R[L])}catch(R){console.error(R)}return this._stringRangesToCellRanges(_,C,k),_}_stringRangesToCellRanges(d,f,S){let C=0,k=!1,E=0,_=d[C];if(_){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&&_[0]<=E&&(_[0]=j,k=!0),_[1]<=E){if(_[1]=j,_=d[++C],!_)break;_[0]<=E?(_[0]=j,k=!0):k=!1}E+=L}}_&&(_[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([h(0,y.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(y,w,a,u){var d,f=arguments.length,S=f<3?w:u===null?u=Object.getOwnPropertyDescriptor(w,a):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(y,w,a,u);else for(var C=y.length-1;C>=0;C--)(d=y[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},h=this&&this.__param||function(y,w){return function(a,u){w(a,u,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),g=i(9806);let x=n.MouseService=class{constructor(y,w){this._renderService=y,this._charSizeService=w}getCoords(y,w,a,u,d){return(0,g.getCoords)(window,y,w,a,u,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,w){const a=(0,g.getCoordsRelativeToElement)(window,y,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([h(0,c.IRenderService),h(1,c.ICharSizeService)],x)},3230:function(v,n,i){var l=this&&this.__decorate||function(S,C,k,E){var _,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--)(_=S[L])&&(R=(j<3?_(R):j>3?_(C,k,R):_(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},h=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),y=i(4725),w=i(8460),a=i(844),u=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,_,j,R,L){if(super(),this._rowCount=S,this._charSizeService=E,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new u.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(_.onDecorationRegistered((()=>this._fullRefresh()))),this.register(_.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([h(2,d.IOptionsService),h(3,y.ICharSizeService),h(4,d.IDecorationService),h(5,d.IBufferService),h(6,y.ICoreBrowserService),h(7,y.IThemeService)],f)},9312:function(v,n,i){var l=this&&this.__decorate||function(_,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(_,j,R,L);else for(var I=_.length-1;I>=0;I--)(T=_[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},h=this&&this.__param||function(_,j){return function(R,L){j(R,L,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),g=i(9504),x=i(456),y=i(4725),w=i(8460),a=i(844),u=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(_,j,R,L,T,D,F,I,H){super(),this._element=_,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 _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!_||!j||_[0]===j[0]&&_[1]===j[1])}get selectionText(){const _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!_||!j)return"";const R=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(_[0]===j[0])return"";const T=_[0]<j[0]?_[0]:j[0],D=_[0]<j[0]?j[0]:_[0];for(let F=_[1];F<=j[1];F++){const I=R.translateBufferLineToString(F,!0,T,D);L.push(I)}}else{const T=_[1]===j[1]?j[0]:void 0;L.push(R.translateBufferLineToString(_[1],!0,_[0],T));for(let D=_[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(_[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(u.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 ze=this._isCellInSelection(me,E),ut=y&&me===L,Ie=ee&&me>=I&&me<=H;let be=!1;this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{be=!0}));let $e=oe.getChars()||g.WHITESPACE_CELL_CHAR;if($e===" "&&(oe.isUnderline()||oe.isOverline())&&($e=" "),V=he*D-F.get($e,oe.isBold(),oe.isItalic()),M){if($&&(ze&&X||!ze&&!X&&oe.bg===B)&&(ze&&X&&P.selectionForeground||oe.fg===z)&&oe.extended.ext===U&&Ie===N&&V===W&&!ut&&!G&&!be){K+=$e,$++;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=Ie,W=V,X=ze,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"),Ie&&(M.style.textDecoration="underline");let Oe=oe.getFgColor(),tt=oe.getFgColorMode(),Ye=oe.getBgColor(),Ze=oe.getBgColorMode();const Xe=!!oe.isInverse();if(Xe){const _e=Oe;Oe=Ye,Ye=_e;const pt=tt;tt=Ze,Ze=pt}let Ne,Ae,ve,We=!1;switch(this._decorationService.forEachDecorationAtCell(me,E,void 0,(_e=>{_e.options.layer!=="top"&&We||(_e.backgroundColorRGB&&(Ze=50331648,Ye=_e.backgroundColorRGB.rgba>>8&16777215,Ne=_e.backgroundColorRGB),_e.foregroundColorRGB&&(tt=50331648,Oe=_e.foregroundColorRGB.rgba>>8&16777215,Ae=_e.foregroundColorRGB),We=_e.options.layer==="top")})),!We&&ze&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,Ye=Ne.rgba>>8&16777215,Ze=50331648,We=!0,P.selectionForeground&&(tt=50331648,Oe=P.selectionForeground.rgba>>8&16777215,Ae=P.selectionForeground)),We&&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()&&Oe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Oe+=8),this._applyMinimumContrast(M,ve,P.ansi[Oe],oe,Ne,void 0)||ie.push(`xterm-fg-${Oe}`);break;case 50331648:const _e=w.rgba.toColor(Oe>>16&255,Oe>>8&255,255&Oe);this._applyMinimumContrast(M,ve,_e,oe,Ne,Ae)||this._addStyle(M,`color:#${C(Oe.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
|
|
24
24
|
`:`
|
|
25
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(_){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),u.isLinux&&_&&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(_){const j=this._getMouseBufferCoords(_),R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(R&&L&&j)&&this._areCoordsInSelection(j,R,L)}isCellInSelection(_,j){const R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!R||!L)&&this._areCoordsInSelection([_,j],R,L)}_areCoordsInSelection(_,j,R){return _[1]>j[1]&&_[1]<R[1]||j[1]===R[1]&&_[1]===j[1]&&_[0]>=j[0]&&_[0]<R[0]||j[1]<R[1]&&_[1]===R[1]&&_[0]<R[0]||j[1]<R[1]&&_[1]===j[1]&&_[0]>=j[0]}_selectWordAtCursor(_,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(_);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(_,j){this._model.clearSelection(),_=Math.max(_,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,_],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(_){this._model.handleTrim(_)&&this.refresh()}_getMouseBufferCoords(_){const j=this._mouseService.getCoords(_,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(_){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,_,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(_){return u.isMac?_.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:_.shiftKey}handleMouseDown(_){if(this._mouseDownTimeStamp=_.timeStamp,(_.button!==2||!this.hasSelection)&&_.button===0){if(!this._enabled){if(!this.shouldForceSelection(_))return;_.stopPropagation()}_.preventDefault(),this._dragScrollAmount=0,this._enabled&&_.shiftKey?this._handleIncrementalClick(_):_.detail===1?this._handleSingleClick(_):_.detail===2?this._handleDoubleClick(_):_.detail===3&&this._handleTripleClick(_),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(_){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(_))}_handleSingleClick(_){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(_)?3:0,this._model.selectionStart=this._getMouseBufferCoords(_),!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(_){this._selectWordAtCursor(_,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(_){const j=this._getMouseBufferCoords(_);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(_){return _.altKey&&!(u.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(_){if(_.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(_),!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(_),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 _=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(_.ydisp+this._bufferService.rows,_.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=_.ydisp),this.refresh()}}_handleMouseUp(_){const j=_.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&_.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(_,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 _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,R=!(!_||!j||_[0]===j[0]&&_[1]===j[1]);R?_&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&_[0]===this._oldSelectionStart[0]&&_[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(_,j,R)):this._oldHasSelection&&this._fireOnSelectionChange(_,j,R)}_fireOnSelectionChange(_,j,R){this._oldSelectionStart=_,this._oldSelectionEnd=j,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(_){this.clearSelection(),this._trimListener.dispose(),this._trimListener=_.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(_,j){let R=j;for(let L=0;j>=L;L++){const T=_.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:T>1&&j!==L&&(R+=T-1)}return R}setSelection(_,j,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[_,j],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(_){this._isClickInSelection(_)||(this._selectWordAtCursor(_,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(_,j,R=!0,L=!0){if(_[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,D=T.lines.get(_[1]);if(!D)return;const F=T.translateBufferLineToString(_[1],!1);let I=this._convertViewportColToCharacterIndex(D,_[0]),H=I;const q=_[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=_[0],z=_[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(_[1]-1);if(B&&D.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){const z=this._getWordAt([this._bufferService.cols-1,_[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(_[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){const z=this._getWordAt([0,_[1]+1],!1,!1,!0);z&&(K+=z.length)}}return{start:$,length:K}}}_selectWordAt(_,j){const R=this._getWordAt(_,j);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,_[1]--;this._model.selectionStart=[R.start,_[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(_){const j=this._getWordAt(_,!0);if(j){let R=_[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(_){return _.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(_.getChars())>=0}_selectLineAt(_){const j=this._bufferService.buffer.getWrappedRangeForLine(_),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([h(3,S.IBufferService),h(4,S.ICoreService),h(5,y.IMouseService),h(6,S.IOptionsService),h(7,y.IRenderService),h(8,y.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,_,j,R){var L,T=arguments.length,D=T<3?_:R===null?R=Object.getOwnPropertyDescriptor(_,j):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,_,j,R);else for(var F=E.length-1;F>=0;F--)(L=E[F])&&(D=(T<3?L(D):T>3?L(_,j,D):L(_,j))||D);return T>3&&D&&Object.defineProperty(_,j,D),D},h=this&&this.__param||function(E,_){return function(j,R){_(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),y=i(844),w=i(2585),a=g.css.toColor("#ffffff"),u=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")],_=[0,95,135,175,215,255];for(let j=0;j<216;j++){const R=_[j/36%6|0],L=_[j/6%6|0],T=_[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 y.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:u,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:S,selectionBackgroundOpaque:g.color.blend(u,S),selectionInactiveBackgroundTransparent:S,selectionInactiveBackgroundOpaque:g.color.blend(u,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 _=this._colors;if(_.foreground=k(E.foreground,a),_.background=k(E.background,u),_.cursor=k(E.cursor,d),_.cursorAccent=k(E.cursorAccent,f),_.selectionBackgroundTransparent=k(E.selectionBackground,S),_.selectionBackgroundOpaque=g.color.blend(_.background,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundOpaque=g.color.blend(_.background,_.selectionInactiveBackgroundTransparent),_.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,_.selectionForeground===g.NULL_COLOR&&(_.selectionForeground=void 0),g.color.isOpaque(_.selectionBackgroundTransparent)&&(_.selectionBackgroundTransparent=g.color.opacity(_.selectionBackgroundTransparent,.3)),g.color.isOpaque(_.selectionInactiveBackgroundTransparent)&&(_.selectionInactiveBackgroundTransparent=g.color.opacity(_.selectionInactiveBackgroundTransparent,.3)),_.ansi=n.DEFAULT_ANSI_COLORS.slice(),_.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),_.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),_.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),_.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),_.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),_.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),_.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),_.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),_.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),_.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),_.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),_.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),_.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),_.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),_.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),_.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(_.ansi.length-16,E.extendedAnsi.length);for(let R=0;R<j;R++)_.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 _=0;_<this._restoreColors.ansi.length;++_)this._colors.ansi[_]=this._restoreColors.ansi[_]}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,_){if(E!==void 0)try{return g.css.toColor(E)}catch{}return _}n.ThemeService=C=l([h(0,w.IOptionsService)],C)},6349:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const l=i(8460),h=i(844);class c extends h.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 y=new Array(x);for(let w=0;w<Math.min(x,this.length);w++)y[w]=this._array[this._getCyclicIndex(w)];this._array=y,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let y=this._length;y<x;y++)this._array[y]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,y){this._array[this._getCyclicIndex(x)]=y}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,y,...w){if(y){for(let a=x;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:x,amount:y})}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,y,w){if(!(y<=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 u=y-1;u>=0;u--)this.set(x+u+w,this.get(x+u));const a=x+y+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<y;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,h=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const g in l)c[g]=h<=1?l[g]:l[g]&&i(l[g],h-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 h=0,c=0,g=0,x=0;var y,w,a,u,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,_,j){return j!==void 0?`#${f(k)}${f(E)}${f(_)}${f(j)}`:`#${f(k)}${f(E)}${f(_)}`},C.toRgba=function(k,E,_,j=255){return(k<<24|E<<16|_<<8|j)>>>0}})(y||(n.channels=y={})),(function(C){function k(E,_){return x=Math.round(255*_),[h,c,g]=d.toChannels(E.rgba),{css:y.toCss(h,c,g,x),rgba:y.toRgba(h,c,g,x)}}C.blend=function(E,_){if(x=(255&_.rgba)/255,x===1)return{css:_.css,rgba:_.rgba};const j=_.rgba>>24&255,R=_.rgba>>16&255,L=_.rgba>>8&255,T=E.rgba>>24&255,D=E.rgba>>16&255,F=E.rgba>>8&255;return h=T+Math.round((j-T)*x),c=D+Math.round((R-D)*x),g=F+Math.round((L-F)*x),{css:y.toCss(h,c,g),rgba:y.toRgba(h,c,g)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,_,j){const R=d.ensureContrastRatio(E.rgba,_.rgba,j);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},C.opaque=function(E){const _=(255|E.rgba)>>>0;return[h,c,g]=d.toChannels(_),{css:y.toCss(h,c,g),rgba:_}},C.opacity=k,C.multiplyOpacity=function(E,_){return x=255&E.rgba,k(E,x*_/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 _=document.createElement("canvas");_.width=1,_.height=1;const j=_.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(_){if(_.match(/#[\da-f]{3,8}/i))switch(_.length){case 4:return h=parseInt(_.slice(1,2).repeat(2),16),c=parseInt(_.slice(2,3).repeat(2),16),g=parseInt(_.slice(3,4).repeat(2),16),d.toColor(h,c,g);case 5:return h=parseInt(_.slice(1,2).repeat(2),16),c=parseInt(_.slice(2,3).repeat(2),16),g=parseInt(_.slice(3,4).repeat(2),16),x=parseInt(_.slice(4,5).repeat(2),16),d.toColor(h,c,g,x);case 7:return{css:_,rgba:(parseInt(_.slice(1),16)<<8|255)>>>0};case 9:return{css:_,rgba:parseInt(_.slice(1),16)>>>0}}const j=_.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 h=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(h,c,g,x);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=_,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[h,c,g,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(h,c,g,x),css:_}}})(a||(n.css=a={})),(function(C){function k(E,_,j){const R=E/255,L=_/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})(u||(n.rgb=u={})),(function(C){function k(_,j,R){const L=_>>24&255,T=_>>16&255,D=_>>8&255;let F=j>>24&255,I=j>>16&255,H=j>>8&255,q=S(u.relativeLuminance2(F,I,H),u.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(u.relativeLuminance2(F,I,H),u.relativeLuminance2(L,T,D));return(F<<24|I<<16|H<<8|255)>>>0}function E(_,j,R){const L=_>>24&255,T=_>>16&255,D=_>>8&255;let F=j>>24&255,I=j>>16&255,H=j>>8&255,q=S(u.relativeLuminance2(F,I,H),u.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(u.relativeLuminance2(F,I,H),u.relativeLuminance2(L,T,D));return(F<<24|I<<16|H<<8|255)>>>0}C.ensureContrastRatio=function(_,j,R){const L=u.relativeLuminance(_>>8),T=u.relativeLuminance(j>>8);if(S(L,T)<R){if(T<L){const I=k(_,j,R),H=S(L,u.relativeLuminance(I>>8));if(H<R){const q=E(_,j,R);return H>S(L,u.relativeLuminance(q>>8))?I:q}return I}const D=E(_,j,R),F=S(L,u.relativeLuminance(D>>8));if(F<R){const I=k(_,j,R);return F>S(L,u.relativeLuminance(I>>8))?D:I}return D}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(_){return[_>>24&255,_>>16&255,_>>8&255,255&_]},C.toColor=function(_,j,R,L){return{css:y.toCss(_,j,R,L),rgba:y.toRgba(_,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),h=i(2585),c=i(4348),g=i(7866),x=i(744),y=i(7302),w=i(6975),a=i(8460),u=i(1753),d=i(1480),f=i(7994),S=i(9282),C=i(5435),k=i(5981),E=i(2660);let _=!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 y.OptionsService(L)),this._instantiationService.setService(h.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(h.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(h.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(w.CoreService)),this._instantiationService.setService(h.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(u.CoreMouseService)),this._instantiationService.setService(h.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(h.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(h.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(h.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<=h.LogLevelEnum.WARN&&!_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),_=!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 h=[];for(let c=0;c<this._listeners.length;c++)h.push(this._listeners[c]);for(let c=0;c<h.length;c++)h[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((h=>l.fire(h)))}},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},h=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),y=i(844),w=i(482),a=i(8437),u=i(8460),d=i(643),f=i(511),S=i(3734),C=i(2585),k=i(6242),E=i(6351),_=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 y.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 u.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new u.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new u.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new u.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new u.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new u.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new u.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new u.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new u.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new u.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new u.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new u.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new u.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,_.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,_.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([h(0,C.IBufferService)],I)},844:(v,n)=>{function i(l){for(const h of l)h.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 h=this._disposables.indexOf(l);h!==-1&&this._disposables.splice(h,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var h;this._isDisposed||l===this._value||((h=this._value)===null||h===void 0||h.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(h,c,g){this._data[h]||(this._data[h]={}),this._data[h][c]=g}get(h,c){return this._data[h]?this._data[h][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(l,h,c,g,x){this._data.get(l,h)||this._data.set(l,h,new i),this._data.get(l,h).set(c,g,x)}get(l,h,c,g){var x;return(x=this._data.get(l,h))===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 h=i.match(/Version\/(\d+)/);return h===null||h.length<2?0:parseInt(h[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 h=this._getKey(l);if(h===void 0||(i=this._search(h),i===-1)||this._getKey(this._array[i])!==h)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])===h);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,h){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do h(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===l)}values(){return[...this._array].values()}_search(l){let h=0,c=this._array.length-1;for(;c>=h;){let g=h+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}h=g+1}}return h}}},7226:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const l=i(6114);class h{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 y=0,w=0,a=x.timeRemaining(),u=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),w=Math.max(y,w),u=x.timeRemaining(),1.5*w>u)return a-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-y))}ms`),void this._start();a=u}this.clear()}}class c extends h{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const y=Date.now()+x;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends h{_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(h){const c=h.buffer.lines.get(h.buffer.ybase+h.buffer.y-1),g=c?.get(h.cols-1),x=h.buffer.lines.get(h.buffer.ybase+h.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),h=i(7226),c=i(3734),g=i(8437),x=i(4634),y=i(511),w=i(643),a=i(4863),u=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=u.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,w.NULL_CELL_CHAR,w.NULL_CELL_WIDTH,w.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,w.WHITESPACE_CELL_CHAR,w.WHITESPACE_CELL_WIDTH,w.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new h.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 _=0;_<this.lines.length;_++)C+=+this.lines.get(_).resize(d,S);let E=0;if(this._rows<f)for(let _=this._rows;_<f;_++)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 _=this._rows;_>f;_--)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 _=this.lines.length-k;_>0&&(this.lines.trimStart(_),this.ybase=Math.max(this.ybase-_,0),this.ydisp=Math.max(this.ydisp-_,0),this.savedY=Math.max(this.savedY-_,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 _=this.lines.get(E);if(!_||!_.isWrapped&&_.getTrimmedLength()<=d)continue;const j=[_];for(;_.isWrapped&&E>0;)_=this.lines.get(--E),j.unshift(_);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=[],_=[];for(let H=0;H<this.lines.length;H++)_.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,_[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),h=i(511),c=i(643),g=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let x=0;class y{constructor(a,u,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=u||h.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 u=this._data[3*a+0],d=2097151&u;return[this._data[3*a+1],2097152&u?this._combined[a]:d?(0,g.stringFromCodePoint)(d):"",u>>22,2097152&u?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,u){this._data[3*a+1]=u[c.CHAR_DATA_ATTR_INDEX],u[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=u[1],this._data[3*a+0]=2097152|a|u[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=u[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|u[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 u=this._data[3*a+0];return 2097152&u?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&u}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const u=this._data[3*a+0];return 2097152&u?this._combined[a]:2097151&u?(0,g.stringFromCodePoint)(2097151&u):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,u){return x=3*a,u.content=this._data[x+0],u.fg=this._data[x+1],u.bg=this._data[x+2],2097152&u.content&&(u.combinedData=this._combined[a]),268435456&u.bg&&(u.extended=this._extendedAttrs[a]),u}setCell(a,u){2097152&u.content&&(this._combined[a]=u.combinedData),268435456&u.bg&&(this._extendedAttrs[a]=u.extended),this._data[3*a+0]=u.content,this._data[3*a+1]=u.fg,this._data[3*a+2]=u.bg}setCellFromCodePoint(a,u,d,f,S,C){268435456&S&&(this._extendedAttrs[a]=C),this._data[3*a+0]=u|d<<22,this._data[3*a+1]=f,this._data[3*a+2]=S}addCodepointToCell(a,u){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,g.stringFromCodePoint)(u):(2097151&d?(this._combined[a]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(u),d&=-2097152,d|=2097152):d=u|4194304,this._data[3*a+0]=d)}insertCells(a,u,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),u<this.length-a){const S=new h.CellData;for(let C=this.length-a-u-1;C>=0;--C)this.setCell(a+u+C,this.loadCell(a+C,S));for(let C=0;C<u;++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,u,d,f){if(a%=this.length,u<this.length-a){const S=new h.CellData;for(let C=0;C<this.length-a-u;++C)this.setCell(a+C,this.loadCell(a+u+C,S));for(let C=this.length-u;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,u,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),u<this.length&&this.getWidth(u-1)===2&&!this.isProtected(u)&&this.setCellFromCodePoint(u,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<u&&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),u<this.length&&this.getWidth(u-1)===2&&this.setCellFromCodePoint(u,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<u&&a<this.length;)this.setCell(a++,d)}resize(a,u){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,u)}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,u=!1){if(u)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 u in a._combined)this._combined[u]=a._combined[u];this._extendedAttrs={};for(const u in a._extendedAttrs)this._extendedAttrs[u]=a._extendedAttrs[u];this.isWrapped=a.isWrapped}clone(){const a=new y(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const u in this._combined)a._combined[u]=this._combined[u];for(const u in this._extendedAttrs)a._extendedAttrs[u]=this._extendedAttrs[u];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,u,d,f,S){const C=a._data;if(S)for(let E=f-1;E>=0;E--){for(let _=0;_<3;_++)this._data[3*(d+E)+_]=C[3*(u+E)+_];268435456&C[3*(u+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[u+E])}else for(let E=0;E<f;E++){for(let _=0;_<3;_++)this._data[3*(d+E)+_]=C[3*(u+E)+_];268435456&C[3*(u+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[u+E])}const k=Object.keys(a._combined);for(let E=0;E<k.length;E++){const _=parseInt(k[E],10);_>=u&&(this._combined[_-u+d]=a._combined[_])}}translateToString(a=!1,u=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;u<d;){const S=this._data[3*u+0],C=2097151&S;f+=2097152&S?this._combined[u]:C?(0,g.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,u+=S>>22||1}return f}}n.BufferLine=y},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,h,c){if(h===l.length-1)return l[h].getTrimmedLength();const g=!l[h].hasContent(c-1)&&l[h].getWidth(c-1)===1,x=l[h+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,h,c,g,x){const y=[];for(let w=0;w<l.length-1;w++){let a=w,u=l.get(++a);if(!u.isWrapped)continue;const d=[l.get(w)];for(;a<l.length&&u.isWrapped;)d.push(u),u=l.get(++a);if(g>=w&&g<a){w+=d.length-1;continue}let f=0,S=i(d,f,h),C=1,k=0;for(;C<d.length;){const _=i(d,C,h),j=_-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===_&&(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 _=d.length-1;_>0&&(_>f||d[_].getTrimmedLength()===0);_--)E++;E>0&&(y.push(w+d.length-E),y.push(E)),w+=d.length-1}return y},n.reflowLargerCreateNewLayout=function(l,h){const c=[];let g=0,x=h[g],y=0;for(let w=0;w<l.length;w++)if(x===w){const a=h[++g];l.onDeleteEmitter.fire({index:w-y,amount:a}),w+=a-1,y+=a,x=h[++g]}else c.push(w);return{layout:c,countRemoved:y}},n.reflowLargerApplyNewLayout=function(l,h){const c=[];for(let g=0;g<h.length;g++)c.push(l.get(h[g]));for(let g=0;g<c.length;g++)l.set(g,c[g]);l.length=h.length},n.reflowSmallerGetNewLineLengths=function(l,h,c){const g=[],x=l.map(((u,d)=>i(l,d,h))).reduce(((u,d)=>u+d));let y=0,w=0,a=0;for(;a<x;){if(x-a<c){g.push(x-a);break}y+=c;const u=i(l,w,h);y>u&&(y-=u,w++);const d=l[w].getWidth(y-1)===2;d&&y--;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),h=i(844),c=i(9092);class g extends h.Disposable{constructor(y,w){super(),this._optionsService=y,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(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),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(y,w){this._normal.resize(y,w),this._alt.resize(y,w),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}n.BufferSet=g},511:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const l=i(482),h=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(y){const w=new g;return w.setFromCharData(y),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(y){this.fg=y[h.CHAR_DATA_ATTR_INDEX],this.bg=0;let w=!1;if(y[h.CHAR_DATA_CHAR_INDEX].length>2)w=!0;else if(y[h.CHAR_DATA_CHAR_INDEX].length===2){const a=y[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const u=y[h.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=u&&u<=57343?this.content=1024*(a-55296)+u-56320+65536|y[h.CHAR_DATA_WIDTH_INDEX]<<22:w=!0}else w=!0}else this.content=y[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[h.CHAR_DATA_WIDTH_INDEX]<<22;w&&(this.combinedData=y[h.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[h.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),h=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,h.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,h;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
|
-
`,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}\\`})(h||(n.C1_ESCAPED=h={}))},7399:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const l=i(2584),h={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,y){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&&!y||!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 u=h[c.keyCode],d=u?.[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,h=i.length){let c="";for(let g=l;g<h;++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 h=i.length;if(!h)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<h;++x){const y=i.charCodeAt(x);if(55296<=y&&y<=56319){if(++x>=h)return this._interim=y,c;const w=i.charCodeAt(x);56320<=w&&w<=57343?l[c++]=1024*(y-55296)+w-56320+65536:(l[c++]=y,l[c++]=w)}else y!==65279&&(l[c++]=y)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,l){const h=i.length;if(!h)return 0;let c,g,x,y,w=0,a=0,u=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 _=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=_-E;for(;u<j;){if(u>=h)return 0;if(k=i[u++],(192&k)!=128){u--,S=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}S||(_===2?C<128?u--:l[w++]=C:_===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=h-4;let f=u;for(;f<h;){for(;!(!(f<d)||128&(c=i[f])||128&(g=i[f+1])||128&(x=i[f+2])||128&(y=i[f+3]));)l[w++]=c,l[w++]=g,l[w++]=x,l[w++]=y,f+=4;if(c=i[f++],c<128)l[w++]=c;else if((224&c)==192){if(f>=h)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>=h)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=h)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>=h)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,w;if(x=i[f++],(192&x)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=x,w;if(y=i[f++],(192&y)!=128){f--;continue}if(a=(7&c)<<18|(63&g)<<12|(63&x)<<6|63&y,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 h;n.UnicodeV6=class{constructor(){if(this.version="6",!h){h=new Uint8Array(65536),h.fill(1),h[0]=0,h.fill(0,1,32),h.fill(0,127,160),h.fill(2,4352,4448),h[9001]=2,h[9002]=2,h.fill(2,11904,42192),h[12351]=1,h.fill(2,44032,55204),h.fill(2,63744,64256),h.fill(2,65040,65050),h.fill(2,65072,65136),h.fill(2,65280,65377),h.fill(2,65504,65511);for(let c=0;c<i.length;++c)h.fill(0,i[c][0],i[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?h[c]:(function(g,x){let y,w=0,a=x.length-1;if(g<x[0][0]||g>x[a][1])return!1;for(;a>=w;)if(y=w+a>>1,g>x[y][1])w=y+1;else{if(!(g<x[y][0]))return!0;a=y-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),h=i(844);class c extends h.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,y){if(y!==void 0&&this._syncCalls>y)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,y){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(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(y)}_innerWrite(x=0,y=!0){const w=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],u=this._action(a,y);if(u){const f=S=>Date.now()-w>=12?setTimeout((()=>this._innerWrite(0,S))):this._innerWrite(w,S);return void u.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 h(c,g){const x=c.toString(16),y=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}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 y=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/y*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/y*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/y*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,y=[0,0,0];for(let w=0;w<3;++w){const a=parseInt(g.slice(x*w,x*w+x),16);y[w]=x===1?a<<4:x===2?a:x===3?a>>4:a>>8}return y}},n.toRgbString=function(c,g=16){const[x,y,w]=c;return`rgb:${h(x,g)}/${h(y,g)}/${h(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),h=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(y,w){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(w),{dispose:()=>{const u=a.indexOf(w);u!==-1&&a.splice(u,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,w){if(this.reset(),this._ident=y,this._active=this._handlers[y]||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(y,w,a){if(this._active.length)for(let u=this._active.length-1;u>=0;u--)this._active[u].put(y,w,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(y,w,a))}unhook(y,w=!0){if(this._active.length){let a=!1,u=this._active.length-1,d=!1;if(this._stack.paused&&(u=this._stack.loopPosition-1,a=w,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;u>=0&&(a=this._active[u].unhook(y),a!==!0);u--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!1,a;u--}for(;u>=0;u--)if(a=this._active[u].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const x=new h.Params;x.addParam(0),n.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=x,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():x,this._data="",this._hitLimit=!1}put(y,w,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(y,w,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let w=!1;if(this._hitLimit)w=!1;else if(y&&(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),h=i(8742),c=i(6242),g=i(6351);class x{constructor(u){this.table=new Uint8Array(u)}setDefault(u,d){this.table.fill(u<<4|d)}add(u,d,f,S){this.table[d<<8|u]=f<<4|S}addMany(u,d,f,S){for(let C=0;C<u.length;C++)this.table[d<<8|u[C]]=f<<4|S}}n.TransitionTable=x;const y=160;n.VT500_TRANSITION_TABLE=(function(){const a=new x(4095),u=Array.apply(null,Array(256)).map(((E,_)=>_)),d=(E,_)=>u.slice(E,_),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(y,0,2,0),a.add(y,8,5,8),a.add(y,6,0,6),a.add(y,11,0,11),a.add(y,13,13,13),a})();class w extends l.Disposable{constructor(u=n.VT500_TRANSITION_TABLE){super(),this._transitions=u,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new h.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(u,d=[64,126]){let f=0;if(u.prefix){if(u.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=u.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(u.intermediates){if(u.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<u.intermediates.length;++C){const k=u.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(u.final.length!==1)throw new Error("final must be a single byte");const S=u.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(u){const d=[];for(;u;)d.push(String.fromCharCode(255&u)),u>>=8;return d.reverse().join("")}setPrintHandler(u){this._printHandler=u}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(u,d){const f=this._identifier(u,[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(u){this._escHandlers[this._identifier(u,[48,126])]&&delete this._escHandlers[this._identifier(u,[48,126])]}setEscHandlerFallback(u){this._escHandlerFb=u}setExecuteHandler(u,d){this._executeHandlers[u.charCodeAt(0)]=d}clearExecuteHandler(u){this._executeHandlers[u.charCodeAt(0)]&&delete this._executeHandlers[u.charCodeAt(0)]}setExecuteHandlerFallback(u){this._executeHandlerFb=u}registerCsiHandler(u,d){const f=this._identifier(u);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(u){this._csiHandlers[this._identifier(u)]&&delete this._csiHandlers[this._identifier(u)]}setCsiHandlerFallback(u){this._csiHandlerFb=u}registerDcsHandler(u,d){return this._dcsParser.registerHandler(this._identifier(u),d)}clearDcsHandler(u){this._dcsParser.clearHandler(this._identifier(u))}setDcsHandlerFallback(u){this._dcsParser.setHandlerFallback(u)}registerOscHandler(u,d){return this._oscParser.registerHandler(u,d)}clearOscHandler(u){this._oscParser.clearHandler(u)}setOscHandlerFallback(u){this._oscParser.setHandlerFallback(u)}setErrorHandler(u){this._errorHandler=u}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(u,d,f,S,C){this._parseStack.state=u,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=S,this._parseStack.chunkPos=C}parse(u,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 _=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(S=_[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=_[j](),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 6:if(C=u[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=u[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 _=E;_<d;++_){switch(C=u[_],k=this._transitions.table[this.currentState<<8|(C<160?C:y)],k>>4){case 2:for(let D=_+1;;++D){if(D>=d||(C=u[D])<32||C>126&&C<y){this._printHandler(u,_,D),_=D-1;break}if(++D>=d||(C=u[D])<32||C>126&&C<y){this._printHandler(u,_,D),_=D-1;break}if(++D>=d||(C=u[D])<32||C>126&&C<y){this._printHandler(u,_,D),_=D-1;break}if(++D>=d||(C=u[D])<32||C>126&&C<y){this._printHandler(u,_,D),_=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:_,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,_),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(++_<d&&(C=u[_])>47&&C<60);_--;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,_),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=_+1;;++D)if(D>=d||(C=u[D])===24||C===26||C===27||C>127&&C<y){this._dcsParser.put(u,_,D),_=D-1;break}break;case 14:if(S=this._dcsParser.unhook(C!==24&&C!==26),S)return this._preserveStack(6,[],0,k,_),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=_+1;;D++)if(D>=d||(C=u[D])<32||C>127&&C<y){this._oscParser.put(u,_,D),_=D-1;break}break;case 6:if(S=this._oscParser.end(C!==24&&C!==26),S)return this._preserveStack(5,[],0,k,_),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),h=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 y=this._handlers[g];return y.push(x),{dispose:()=>{const w=y.indexOf(x);w!==-1&&y.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,y){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(g,x,y);else this._handlerFb(this._id,"PUT",(0,h.utf32ToString)(g,x,y))}start(){this.reset(),this._state=1}put(g,x,y){if(this._state!==3){if(this._state===1)for(;x<y;){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&&y-x>0&&this._put(g,x,y)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,w=this._active.length-1,a=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,y=x,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;w>=0&&(y=this._active[w].end(g),y!==!0);w--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,y;w--}for(;w>=0;w--)if(y=this._active[w].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,y}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,y){this._hitLimit||(this._data+=(0,h.utf32ToString)(g,x,y),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((y=>(this._data="",this._hitLimit=!1,y)));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 y=c[x];if(Array.isArray(y))for(let w=0;w<y.length;++w)g.addSubParam(y[w]);else g.addParam(y)}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,y=255&this._subParamsIdx[g];y-x>0&&c.push(Array.prototype.slice.call(this._subParams,x,y))}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,y=255&this._subParamsIdx[g];y-x>0&&(c[g]=this._subParams.slice(x,y))}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,y=x[g-1];x[g-1]=~y?Math.min(10*y+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 h={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(h),l.dispose=()=>this._wrappedAddonDispose(h),l.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let l=-1;for(let h=0;h<this._addons.length;h++)if(this._addons[h]===i){l=h;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),h=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 h.CellData}}},3785:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const l=i(511);n.BufferLineApiView=class{constructor(h){this._line=h}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(h,c){if(!(h<0||h>=this._line.length))return c?(this._line.loadCell(h,c),c):this._line.loadCell(h,new l.CellData)}translateToString(h,c,g){return this._line.translateToString(h,c,g)}}},8285:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const l=i(8771),h=i(8460),c=i(844);class g extends c.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new h.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,(h=>l(h.toArray())))}addCsiHandler(i,l){return this.registerCsiHandler(i,l)}registerDcsHandler(i,l){return this._core.registerDcsHandler(i,((h,c)=>l(h,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,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,u,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(a,u){return function(d,f){u(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),y=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,u){this.cols=a,this.rows=u,this.buffers.resize(a,u),this._onResize.fire({cols:a,rows:u})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,u=!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,u),this._cachedBlankLine=f),f.isWrapped=u;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,u,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&&(u||this._onScroll.fire(f.ydisp))}};n.BufferService=w=l([h(0,y.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,_=arguments.length,j=_<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=(_<3?E(j):_>3?E(S,C,j):E(S,C))||j);return _>3&&j&&Object.defineProperty(S,C,j),j},h=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),y={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,u={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(y))this.addProtocol(C,y[C]);for(const C of Object.keys(u))this.addEncoding(C,u[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([h(0,c.IBufferService),h(1,c.ICoreService)],d)},6975:function(v,n,i){var l=this&&this.__decorate||function(d,f,S,C){var k,E=arguments.length,_=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,S):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(d,f,S,C);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(_=(E<3?k(_):E>3?k(f,S,_):k(f,S))||_);return E>3&&_&&Object.defineProperty(f,S,_),_},h=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),y=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 u=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=u=l([h(0,y.IBufferService),h(1,y.ILogService),h(2,y.IOptionsService)],u)},9074:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const l=i(8055),h=i(8460),c=i(844),g=i(6106);let x=0,y=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 h.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new h.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 _=0,j=0;for(const R of this._decorations.getKeyIterator(f))_=(C=R.options.x)!==null&&C!==void 0?C:0,j=_+((k=R.options.width)!==null&&k!==void 0?k:1),d>=_&&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,_,j;x=(E=k.options.x)!==null&&E!==void 0?E:0,y=x+((_=k.options.width)!==null&&_!==void 0?_:1),d>=x&&d<y&&(!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 h.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new h.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),h=i(8343);class c{constructor(...x){this._entries=new Map;for(const[y,w]of x)this.set(y,w)}set(x,y){const w=this._entries.get(x);return this._entries.set(x,y),w}forEach(x){for(const[y,w]of this._entries.entries())x(y,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 y=(0,h.getServiceDependencies)(g).sort(((u,d)=>u.index-d.index)),w=[];for(const u of y){const d=this._services.get(u.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${u.id}.`);w.push(d)}const a=y.length>0?y[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,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,u,d,f);else for(var E=a.length-1;E>=0;E--)(S=a[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(a,u){return function(d,f){u(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 y,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()))),y=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let u=0;u<a.length;u++)typeof a[u]=="function"&&(a[u]=a[u]())}_log(a,u,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+u,...d)}trace(a,...u){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,u)}debug(a,...u){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,u)}info(a,...u){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,u)}warn(a,...u){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,u)}error(a,...u){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,u)}};n.LogService=w=l([h(0,g.IOptionsService)],w),n.setTraceLogger=function(a){y=a},n.traceCall=function(a,u,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...S){if(y.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,S);y.trace(`GlyphRenderer#${f.name}(${S.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,S);return y.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),h=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 h.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 u in w)if(u in a)try{const d=w[u];a[u]=this._sanitizeAndValidateOption(u,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(w,a){return this.onOptionChange((u=>{u===w&&a(this.rawOptions[w])}))}onMultipleOptionChange(w,a){return this.onOptionChange((u=>{w.indexOf(u)!==-1&&a()}))}_setupOptions(){const w=u=>{if(!(u in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${u}"`);return this.rawOptions[u]},a=(u,d)=>{if(!(u in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${u}"`);d=this._sanitizeAndValidateOption(u,d),this.rawOptions[u]!==d&&(this.rawOptions[u]=d,this._onOptionChange.fire(u))};for(const u in this.rawOptions){const d={get:w.bind(this,u),set:a.bind(this,u)};Object.defineProperty(this.options,u,d)}}_sanitizeAndValidateOption(w,a){switch(w){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[w]),!(function(u){return u==="block"||u==="underline"||u==="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,y,w,a){var u,d=arguments.length,f=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,w):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(x,y,w,a);else for(var S=x.length-1;S>=0;S--)(u=x[S])&&(f=(d<3?u(f):d>3?u(y,w,f):u(y,w))||f);return d>3&&f&&Object.defineProperty(y,w,f),f},h=this&&this.__param||function(x,y){return function(w,a){y(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 y=this._bufferService.buffer;if(x.id===void 0){const S=y.addMarker(y.ybase+y.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),u=this._entriesWithId.get(a);if(u)return this.addLineToLink(u.id,y.ybase+y.y),u.id;const d=y.addMarker(y.ybase+y.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,y){const w=this._dataByLinkId.get(x);if(w&&w.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);w.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(w,a)))}}getLinkData(x){var y;return(y=this._dataByLinkId.get(x))===null||y===void 0?void 0:y.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,y){const w=x.lines.indexOf(y);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([h(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(h){return h[l]||[]},n.createDecorator=function(h){if(n.serviceRegistry.has(h))return n.serviceRegistry.get(h);const c=function(g,x,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(w,a,u){a[i]===a?a[l].push({id:w,index:u}):(a[l]=[{id:w,index:u}],a[i]=a)})(c,g,y)};return c.toString=()=>h,n.serviceRegistry.set(h,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 h;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"})(h||(n.LogLevelEnum=h={})),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),h=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 h.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 y=0;y<x;++y){let w=c.charCodeAt(y);if(55296<=w&&w<=56319){if(++y>=x)return g+this.wcwidth(w);const a=c.charCodeAt(y);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),h=p(5741),c=p(8285),g=p(7975),x=p(7090),y=["cols","rows"];class w extends l.Disposable{constructor(u){super(),this._core=this.register(new i.Terminal(u)),this._addonManager=this.register(new h.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(u){if(y.includes(u))throw new Error(`Option "${u}" 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 u=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:u.applicationCursorKeys,applicationKeypadMode:u.applicationKeypad,bracketedPasteMode:u.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:u.origin,reverseWraparoundMode:u.reverseWraparound,sendFocusMode:u.sendFocus,wraparoundMode:u.wraparound}}get options(){return this._publicOptions}set options(u){for(const d in u)this._publicOptions[d]=u[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(u,d){this._verifyIntegers(u,d),this._core.resize(u,d)}open(u){this._core.open(u)}attachCustomKeyEventHandler(u){this._core.attachCustomKeyEventHandler(u)}registerLinkProvider(u){return this._core.registerLinkProvider(u)}registerCharacterJoiner(u){return this._checkProposedApi(),this._core.registerCharacterJoiner(u)}deregisterCharacterJoiner(u){this._checkProposedApi(),this._core.deregisterCharacterJoiner(u)}registerMarker(u=0){return this._verifyIntegers(u),this._core.registerMarker(u)}registerDecoration(u){var d,f,S;return this._checkProposedApi(),this._verifyPositiveIntegers((d=u.x)!==null&&d!==void 0?d:0,(f=u.width)!==null&&f!==void 0?f:0,(S=u.height)!==null&&S!==void 0?S:0),this._core.registerDecoration(u)}hasSelection(){return this._core.hasSelection()}select(u,d,f){this._verifyIntegers(u,d,f),this._core.select(u,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(u,d){this._verifyIntegers(u,d),this._core.selectLines(u,d)}dispose(){super.dispose()}scrollLines(u){this._verifyIntegers(u),this._core.scrollLines(u)}scrollPages(u){this._verifyIntegers(u),this._core.scrollPages(u)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(u){this._verifyIntegers(u),this._core.scrollToLine(u)}clear(){this._core.clear()}write(u,d){this._core.write(u,d)}writeln(u,d){this._core.write(u),this._core.write(`\r
|
|
27
|
-
`,d)}paste(
|
|
28
|
-
\x1B[90m[Process exited with code ${
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),b.useLayoutEffect(()=>{if(!m.current)return;const u=new zm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Km,scrollback:5e3,convertEol:!0}),d=new $m;return u.loadAddon(d),u.open(m.current),v.current=u,n.current=d,w(8),()=>{u.dispose(),v.current=null,n.current=null}},[w]),b.useEffect(()=>{i.current||(i.current=!0,g())},[g]),b.useEffect(()=>{const u=v.current;if(!u||!h)return;const d=u.onData(f=>{x(f)});return()=>d.dispose()},[x,h]),b.useEffect(()=>{h&&(w(4),p?.({sendInput:x,paste:a}))},[h,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"})]})}),Xm=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(Ld,{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(Qt,{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))})})]})]})}),Hl="\x1B",Ym="\x07",Gm="";function Qm(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function Wo(e,s){let r=s;for(;r<e.length;){if(e[r]===Ym||e[r]===Gm)return r+1;if(e[r]===Hl&&e[r+1]==="\\")return r+2;r+=1}return r}function Ho(e,s){let r=s;for(;r<e.length&&!Qm(e[r]);)r+=1;return r<e.length?r+1:r}function Zm(e){let s="";for(let r=0;r<e.length;){if(e[r]===""){r=Ho(e,r+1);continue}if(e[r]===""){r=Wo(e,r+1);continue}if(e[r]!==Hl){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=Ho(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=Wo(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 Jm=200,ep=1e3,tp=512*1024;function sp(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>ep||s>tp&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function rp(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=sp(v);return{...s,entries:n.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||n.trimmed}}function Vn(e,s=!0){return kt({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 ip(e,s,r,o=!0){const p=bt(),m=ce.workspaceServices.logs(e,s);return kt({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(Jm)});i!==null&&l.set("runtimeInstanceId",i),l.set("afterSeq",String(n));const h=await Ee.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${l}`);return rp(v,h)},enabled:o&&!!e&&!!s,refetchInterval:v=>v.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const np=[];function Ii(e){return JSON.stringify([e.command,...e.args])}function $o(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 op(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 Uo({state:e}){const{t:s}=ae(),r=op(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 ap({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(ks,{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(Es,{size:13})})]})}function lp({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=ae(),p=Vn(e,s),m=p.data??np,[v,n]=b.useState(null),i=m.find(x=>x.name===v)??m[0]??null,l=ip(e,i?.name??"",i?.runtimeInstanceId??null,s&&!!i),h=b.useMemo(()=>Zm(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)},[h]),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(Qi,{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(He,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(ap,{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(Qi,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:o("No background services")})]}):m.map(x=>{const y=x.name===i?.name;return t.jsxs("button",{type:"button",onClick:()=>n(x.name),"aria-pressed":y,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",y?"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(Uo,{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(Rn,{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(os,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:$o(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(Uo,{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(os,{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:$o(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(Es,{size:11})})]}),t.jsx("div",{ref:c,onScroll:x=>{const y=x.currentTarget;g.current=y.scrollHeight-y.scrollTop-y.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(He,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading service logs...")]}):h?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:h}):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 qo(){return Oi+=1,{id:`shell-${Oi}`,order:Oi}}const cp=le.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=ae(),[v,n]=b.useState(()=>[qo()]),[i,l]=b.useState(()=>v[0].id),[h,c]=b.useState(()=>new Set),[g,x]=b.useState(!1),[y,w]=b.useState(!1),[a,u]=b.useState(""),[d,f]=b.useState(null),[S,C]=b.useState("terminals"),k=b.useRef(new Map),E=o?S:"terminals",_=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=qo();n(O=>[...O,M]),l(M.id)},[]),R=b.useCallback((M,O)=>{O.stopPropagation(),_(M),n($=>{const K=$.filter(B=>B.id!==M);return M===i&&K.length>0&&l(K[K.length-1].id),K})},[i,_]),L=b.useCallback(M=>{_(M),n(O=>{const $=O.filter(K=>K.id!==M);return M===i&&$.length>0&&l($[$.length-1].id),$})},[i,_]),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),u(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),
|
|
31
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
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
|
+
`,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(()=>rs.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=rs.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(Ls.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(Ls.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=b.useCallback(async()=>{const k=rs.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;rs.getSocket().emit(Ls.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=b.useCallback((k,E)=>{const y=h.current;if(!y)return;rs.getSocket().emit(Ls.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(Jt,{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 kt({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 kt({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(ks,{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(Es,{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(Fe,{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(os,{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(os,{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(Es,{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(Fe,{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(or,{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(or,{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($t,{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(Fe,{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(ns,{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(or,{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(ds,{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 nr(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 ti(e){return{}.toString.call(e).includes("Object")}function Ep(e){return!Object.keys(e).length}function gr(e){return typeof e=="function"}function jp(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Np(e,s){return ti(s)||ls("changeType"),Object.keys(s).some(function(r){return!jp(e,r)})&&ls("changeField"),s}function Rp(e){gr(e)||ls("selectorType")}function Ap(e){gr(e)||ti(e)||ls("handlerType"),ti(e)&&Object.values(e).some(function(s){return!gr(s)})&&ls("handlersType")}function Tp(e){e||ls("initialIsRequired"),ti(e)||ls("initialType"),Ep(e)&&ls("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"},ls=nr(Mp)(Dp),Br={changes:Np,selector:Rp,handler:Ap,initial:Tp};function Pp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Br.initial(e),Br.handler(s);var r={current:e},o=nr(Op)(r,s),p=nr(Ip)(r),m=nr(Br.changes)(e),v=nr(Lp)(r);function n(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Br.selector(l),l(r.current)}function i(l){kp(o,p,m,v)(l)}return[n,i]}function Lp(e,s){return gr(s)?s(e.current):s}function Ip(e,s){return e.current=Qo(Qo({},e.current),s),s}function Op(e,s,r){return gr(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!
|
|
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
|
-
`},Qo=Ip(zp)($l),Wp={config:Bp},Hp=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 Ul(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Ul(e[r],s[r]))}),Xo(Xo({},e),s)}var $p={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($p):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var Up=["monaco"],qp=Pp.create({config:Lp,isInitialized:!1,resolve:null,reject:null,monaco:null}),ql=gp(qp,2),Sr=ql[0],gi=ql[1];function Kp(e){var s=Wp.config(e),r=s.monaco,o=mp(s,Up);gi(function(p){return{config:Ul(p.config,o),monaco:r}})}function Vp(){var e=Sr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(gi({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Bi(Fi);if(window.monaco&&window.monaco.editor)return Kl(window.monaco),e.resolve(window.monaco),Bi(Fi);Hp(Xp,Gp)(Qp)}return Bi(Fi)}function Xp(e){return document.body.appendChild(e)}function Yp(e){var s=document.createElement("script");return e&&(s.src=e),s}function Gp(e){var s=Sr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=Yp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Qp(){var e=Sr(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;Kl(o),e.resolve(o)},function(r){e.reject(r)})}function Kl(e){Sr().monaco||gi({monaco:e})}function Zp(){return Sr(function(e){var s=e.monaco;return s})}var Fi=new Promise(function(e,s){return gi({resolve:e,reject:s})}),Vl={config:Kp,init:Vp,__getMonacoInstance:Zp},Jp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},zi=Jp,eg={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},tg=eg;function sg({children:e}){return le.createElement("div",{style:tg.container},e)}var rg=sg,ig=rg;function ng({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(ig,null,o),le.createElement("div",{ref:p,style:{...zi.fullWidth,...!r&&zi.hide},className:m}))}var og=ng,Xl=b.memo(og);function ag(e){b.useEffect(e,[])}var Yl=ag;function lg(e,s,r=!0){let o=b.useRef(!0);b.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var Ct=lg;function dr(){}function Is(e,s,r,o){return cg(e,o)||dg(e,s,r,o)}function cg(e,s){return e.editor.getModel(Gl(e,s))}function dg(e,s,r,o){return e.editor.createModel(s,r,o?Gl(e,o):void 0)}function Gl(e,s){return e.Uri.parse(s)}function ug({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:h="Loading...",options:c={},height:g="100%",width:x="100%",className:y,wrapperProps:w={},beforeMount:a=dr,onMount:u=dr}){let[d,f]=b.useState(!1),[S,C]=b.useState(!0),k=b.useRef(null),E=b.useRef(null),_=b.useRef(null),j=b.useRef(u),R=b.useRef(a),L=b.useRef(!1);Yl(()=>{let I=Vl.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()}),Ct(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),H=Is(E.current,e||"",o||r||"text",m||"");H!==I.getModel()&&I.setModel(H)}},[m],d),Ct(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),H=Is(E.current,s||"",p||r||"text",v||"");H!==I.getModel()&&I.setModel(H)}},[v],d),Ct(()=>{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),Ct(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),Ct(()=>{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),Ct(()=>{E.current?.editor.setTheme(l)},[l],d),Ct(()=>{k.current?.updateOptions(c)},[c],d);let T=b.useCallback(()=>{if(!E.current)return;R.current(E.current);let I=Is(E.current,e||"",o||r||"text",m||""),H=Is(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&&_.current&&(k.current=E.current.editor.createDiffEditor(_.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(Xl,{width:x,height:g,isEditorReady:d,loading:h,_ref:_,className:y,wrapperProps:w})}var hg=ug;b.memo(hg);function fg(e){let s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}var mg=fg,Fr=new Map;function pg({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:v="light",line:n,loading:i="Loading...",options:l={},overrideServices:h={},saveViewState:c=!0,keepCurrentModel:g=!1,width:x="100%",height:y="100%",className:w,wrapperProps:a={},beforeMount:u=dr,onMount:d=dr,onChange:f,onValidate:S=dr}){let[C,k]=b.useState(!1),[E,_]=b.useState(!0),j=b.useRef(null),R=b.useRef(null),L=b.useRef(null),T=b.useRef(d),D=b.useRef(u),F=b.useRef(),I=b.useRef(o),H=mg(m),q=b.useRef(!1),A=b.useRef(!1);Yl(()=>{let O=Vl.init();return O.then($=>(j.current=$)&&_(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>R.current?M():O.cancel()}),Ct(()=>{let O=Is(j.current,e||o||"",s||p||"",m||r||"");O!==R.current?.getModel()&&(c&&Fr.set(H,R.current?.saveViewState()),R.current?.setModel(O),c&&R.current?.restoreViewState(Fr.get(m)))},[m],C),Ct(()=>{R.current?.updateOptions(l)},[l],C),Ct(()=>{!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),Ct(()=>{let O=R.current?.getModel();O&&p&&j.current?.editor.setModelLanguage(O,p)},[p],C),Ct(()=>{n!==void 0&&R.current?.revealLine(n)},[n],C),Ct(()=>{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,$=Is(j.current,o||e||"",s||p||"",O||"");R.current=j.current?.editor.create(L.current,{model:$,automaticLayout:!0,...l},h),c&&R.current.restoreViewState(Fr.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,h,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&&Fr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return le.createElement(Xl,{width:x,height:y,isEditorReady:C,loading:i,_ref:L,className:w,wrapperProps:a})}var gg=pg,vg=b.memo(gg),xg=vg,Tt=function(e,s){return Number(e.toFixed(s))},bg=function(e,s){return typeof e=="number"?e:s},Ge=function(e,s,r){r&&typeof r=="function"&&r(e,s)},_g=function(e){return-Math.cos(e*Math.PI)/2+.5},yg=function(e){return e},Sg=function(e){return e*e},wg=function(e){return e*(2-e)},Cg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},kg=function(e){return e*e*e},Eg=function(e){return--e*e*e+1},jg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Ng=function(e){return e*e*e*e},Rg=function(e){return 1- --e*e*e*e},Ag=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Tg=function(e){return e*e*e*e*e},Mg=function(e){return 1+--e*e*e*e*e},Dg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Ql={easeOut:_g,linear:yg,easeInQuad:Sg,easeOutQuad:wg,easeInOutQuad:Cg,easeInCubic:kg,easeOutCubic:Eg,easeInOutCubic:jg,easeInQuart:Ng,easeOutQuart:Rg,easeInOutQuart:Ag,easeInQuint:Tg,easeOutQuint:Mg,easeInOutQuint:Dg},Zl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},It=function(e){e.mounted&&(Zl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Jl(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;It(e),e.animation=function(){if(!e.mounted)return Zl(e.animation);var v=new Date().getTime()-p,n=v/r,i=Ql[s],l=i(n);v>=r?(o(m),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Pg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function hs(e,s,r,o){var p=Pg(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,h=s.scale-n,c=s.positionX-i,g=s.positionY-l;r===0?m(s.scale,s.positionX,s.positionY):Jl(e,o,r,function(x){var y=n+h*x,w=i+c*x,a=l+g*x;m(y,w,a)})}}function Lg(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,h=p-i;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:n,newDiffWidth:l,newContentHeight:i,newDiffHeight:h}}var Ig=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,h=n,c=o-p-i,g=i;return{minPositionX:l,maxPositionX:h,minPositionY:c,maxPositionY:g}},Xn=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=Lg(r,o,s),v=m.wrapperWidth,n=m.wrapperHeight,i=m.newContentWidth,l=m.newDiffWidth,h=m.newContentHeight,c=m.newDiffHeight,g=Ig(v,i,l,n,h,c,!!p);return g},ln=function(e,s,r,o){return o?e<s?Tt(s,2):e>r?Tt(r,2):Tt(e,2):Tt(e,2)},ys=function(e,s){var r=Xn(e,s);return e.bounds=r,r};function wr(e,s,r,o,p,m,v){var n=r.minPositionX,i=r.minPositionY,l=r.maxPositionX,h=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var x=ln(e,n-c,l+c,o),y=ln(s,i-g,h+g,o);return{x,y}}function vi(e,s,r,o,p,m){var v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,h=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*h,g=l-r*h,x=wr(c,g,p,m,0,0,null);return x}function Cr(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 Zo=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(h){return h instanceof Element?p?.contains(h):!1}):p?.contains(m),i=o&&m&&n;if(!i)return!1;var l=xi(m,r);return!l},Jo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},Og=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}},Bg=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 Fg(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 h=e.bounds,c=h.maxPositionX,g=h.minPositionX,x=h.maxPositionY,y=h.minPositionY,w=r>c||r<g,a=o>x||o<y,u=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>x?l.offsetHeight:e.setup.minPositionY||0,f=vi(e,u,d,p,e.bounds,n||i),S=f.x,C=f.y;return{scale:p,positionX:w?S:r,positionY:a?C:o}}}function ec(e,s,r,o,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,l=i.scale,h=i.positionX,c=i.positionY;if(!(v===null||n===null||s===h&&r===c)){var g=wr(s,r,n,m,o,p,v),x=g.x,y=g.y;e.setTransformState(l,x,y)}}var zg=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 h=s-o.x,c=r-o.y,g=v?i:h,x=n?l:c;return{x:g,y:x}},us=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},Wg=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},Hg=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 $g(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function ea(e,s,r,o,p,m,v,n,i,l){if(p){if(s>v&&r>v){var h=v+(e-v)*l;return h>i?i:h<v?v:h}if(s<m&&r<m){var h=m+(e-m)*l;return h<n?n:h>m?m:h}}return o?s:ln(e,m,v,p)}function Ug(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function qg(e,s){var r=Wg(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=Ug(v,n),h=s.x-o.x,c=s.y-o.y,g=h/l,x=c/l,y=i-p,w=h*h+c*c,a=Math.sqrt(w)/y;e.velocity={velocityX:g,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function Kg(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=Hg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,n=s.velocityY,i=s.total,l=r.maxPositionX,h=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,x=o.limitToBounds,y=o.alignmentAnimation,w=o.zoomAnimation,a=o.panning,u=a.lockAxisY,d=a.lockAxisX,f=w.animationType,S=y.sizeX,C=y.sizeY,k=y.velocityAlignmentTime,E=k,_=$g(e,i),j=Math.max(_,E),R=us(e,S),L=us(e,C),T=R*p.offsetWidth/100,D=L*p.offsetHeight/100,F=l+T,I=h-T,H=c+D,q=g-D,A=e.transformState,P=new Date().getTime();Jl(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=Ql[y.animationType],W=1-N(Math.min(1,U)),X=1-M,V=K+v*X,ie=B+n*X,ee=ea(V,A.positionX,K,d,x,h,l,I,F,W),me=ea(ie,A.positionY,B,u,x,g,c,q,H,W);(K!==V||B!==ie)&&e.setTransformState($,ee,me)})}}function ta(e,s){var r=e.transformState.scale;It(e),ys(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?Bg(e,s):Og(e,s)}function Yn(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,h=m.animationType,c=v||r<p||!n&&!i;if(!c){var g=Fg(e);g&&hs(e,g,s??l,h)}}function sa(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,n=m.sizeY;if(o){var i=zg(e,s,r),l=i.x,h=i.y,c=us(e,v),g=us(e,n);qg(e,{x:l,y:h}),ec(e,l,h,c,g)}}function Vg(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,h=v?.height||0,c=n<l||i<h,g=!s&&r&&r?.total>.1&&c;g?Kg(e):Yn(e)}}function Gn(e,s,r,o){var p=e.setup,m=p.minScale,v=p.maxScale,n=p.limitToBounds,i=Cr(Tt(s,2),m,v,0,!1),l=ys(e,i),h=vi(e,r,o,i,l,n),c=h.x,g=h.y;return{scale:i,positionX:c,positionY:g}}function tc(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,h=i.animationTime,c=i.animationType,g=l||o>=v;if((o>=1||n)&&Yn(e),!(g||!p||!e.mounted)){var x=s||p.offsetWidth/2,y=r||p.offsetHeight/2,w=Gn(e,v,x,y);w&&hs(e,w,h,c)}}var cs=function(){return cs=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},cs.apply(this,arguments)};function ra(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 zr={scale:1,positionX:0,positionY:0},rr={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}},cn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},sc=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:zr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:zr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:zr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:zr.positionY}},ia=function(e){var s=cs({},rr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof rr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(rr[r]),v=m==="[object Object]",n=m==="[object Array]";v?s[r]=cs(cs({},rr[r]),e[r]):n?s[r]=ra(ra([],rr[r],!0),e[r]):s[r]=e[r]}}),s},rc=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,h=i.size;if(!p)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,g=Cr(Tt(c,3),n,v,h,!1);return g};function ic(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 h=m.offsetWidth,c=m.offsetHeight,g=(h/2-i)/n,x=(c/2-l)/n,y=rc(e,s,r),w=Gn(e,y,g,x);if(!w)return console.error("Error during zoom event. New transformation state was not calculated.");hs(e,w,o,p)}function nc(e,s,r,o){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,n=sc(e.props),i=e.transformState,l=i.scale,h=i.positionX,c=i.positionY;if(m){var g=Xn(e,n.scale),x=wr(n.positionX,n.positionY,g,v,0,0,m),y={scale:n.scale,positionX:x.x,positionY:x.y};l===n.scale&&h===n.positionX&&c===n.positionY||(o?.(),hs(e,y,s,r))}}function Xg(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 Yg(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 h=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=Xg(s,o,p,m),x=g.x,y=g.y,w=c.width/m.scale,a=c.height/m.scale,u=o.offsetWidth/w,d=o.offsetHeight/a,f=Cr(r||Math.min(u,d),i,l,0,!1),S=(h.width-w*f)/2,C=(h.height-a*f)/2,k=(h.left-x)*f+S,E=(h.top-y)*f+C,_=Xn(e,f),j=wr(k,E,_,n,0,0,o),R=j.x,L=j.y;return{positionX:R,positionY:L,scale:f}}var Gg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),ic(e,1,s,r,o)}},Qg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),ic(e,-1,s,r,o)}},Zg=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,h=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!h||!c)){var x={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?l:o};hs(e,x,p,m)}}},Jg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),nc(e,s,r)}},ev=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=oc(s||p.scale,m,v);hs(e,n,r,o)}}},tv=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),It(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var n=Yg(e,v,r);hs(e,n,o,p)}}},si=function(e){return{instance:e,zoomIn:Gg(e),zoomOut:Qg(e),setTransform:Zg(e),resetTransform:Jg(e),centerView:ev(e),zoomToElement:tv(e)}},dn=function(e){return{instance:e,state:e.transformState}},Ve=function(e){var s={};return Object.assign(s,dn(e)),Object.assign(s,si(e)),s},Wi=!1;function Hi(){try{var e={get passive(){return Wi=!0,!1}};return e}catch{return Wi=!1,Wi}}var Wr=".".concat(cn.wrapperClass),xi=function(e,s){return s.some(function(r){return e.matches("".concat(Wr," ").concat(r,", ").concat(Wr," .").concat(r,", ").concat(Wr," ").concat(r," *, ").concat(Wr," .").concat(r," *"))})},un=function(e){e&&clearTimeout(e)},sv=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},oc=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 rv(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var iv=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,h=n&&!i&&!o&&l;if(!h||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=xi(l,v);return!c},nv=function(e){return e?e.deltaY<0?1:-1:0};function ov(e,s){var r=nv(e),o=bg(s,r);return o}function ac(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 av=function(e,s,r,o,p){var m=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,l=n.minScale,h=n.zoomAnimation,c=n.disablePadding,g=h.size,x=h.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=m+s*r,w=o?!1:!x,a=Cr(Tt(y,3),l,i,g,w&&!c);return a},lv=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},cv=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=xi(v,p);return!i},dv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},uv=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Tt(p[0].clientX-o.left,5),v=Tt(p[0].clientY-o.top,5),n=Tt(p[1].clientX-o.left,5),i=Tt(p[1].clientY-o.top,5);return{x:(m+n)/2/s,y:(v+i)/2/s}},lc=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))},hv=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,h=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 Cr(Tt(g,2),v,m,l,!h&&!i)},fv=160,mv=100,pv=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(It(e),Ge(Ve(e),s,o),Ge(Ve(e),s,p))},gv=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,h=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,x=v.disablePadding,y=v.smooth,w=c.size,a=c.disabled,u=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=ov(s,null),S=y?d*Math.abs(s.deltaY):u,C=av(e,f,S,!s.ctrlKey);if(i!==C){var k=ys(e,C),E=ac(s,m,i),_=a||w===0||h||x,j=l&&_,R=vi(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)}},vv=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;un(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(tc(e,s.x,s.y),e.wheelAnimationTimer=null)},mv);var m=lv(e,s);m&&(un(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ge(Ve(e),s,o),Ge(Ve(e),s,p))},fv))},cc=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}},xv=function(e,s){var r=lc(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=cc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,It(e)},bv=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,h=v.alignmentAnimation,c=l.disabled,g=l.size;if(!(o===null||!r)){var x=uv(s,m,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var y=lc(s),w=hv(e,y),a=cc(s),u=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(w===m&&u===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ys(e,w),S=c||g===0||i,C=n&&S,k=vi(e,x.x,x.y,w,f,C),E=k.x,_=k.y;e.pinchMidpoint=x,e.lastDistance=y;var j=h.sizeX,R=h.sizeY,L=us(e,j),T=us(e,R),D=E+u,F=_+d,I=wr(D,F,f,n,L,T,p),H=I.x,q=I.y;e.setTransformState(w,H,q)}}}},_v=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,tc(e,s?.x,s?.y)},dc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;un(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ge(Ve(e),s,r)},o)},yv=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),nc(e,v,n,function(){return Ge(Ve(e),s,p)}),dc(e,s)};function Sv(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function wv(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,h=r.doubleClick,c=h.disabled,g=h.mode,x=h.step,y=h.animationTime,w=h.animationType;if(!c&&!o){if(g==="reset")return yv(e,s);if(!m)return console.error("No ContentComponent found");var a=Sv(g,e.transformState.scale),u=rc(e,a,x);if(v!==u){Ge(Ve(e),s,i);var d=ac(s,m,v),f=Gn(e,u,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ge(Ve(e),s,l),hs(e,f,y,w),dc(e,s)}}}var Cv=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),h=r&&i&&l&&!v;if(!h)return!1;var c=xi(i,n);return!c},kv=(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,ys(r,r.transformState.scale),r.setup=ia(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),It(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 h=0,c=i;h<c.length;h++){var g=c[h];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,h=p.offsetHeight;(l>0||h>0)&&(m=!0,r.setCenter())}else It(r),ys(r,r.transformState.scale),Yn(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=iv(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(pv(r,o),gv(r,o),vv(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,h=i.positionY,c=l-o.deltaX,g=h-o.deltaY,x=n.lockAxisX?l:c,y=n.lockAxisY?h:g,w=r.setup.alignmentAnimation,a=w.sizeX,u=w.sizeY,d=us(r,a),f=us(r,u);x===l&&y===h||ec(r,x,y,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Zo(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(),It(r),ta(r,o),Ge(Ve(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=Jo(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),sa(r,o.clientX,o.clientY),Ge(Ve(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(Vg(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=cv(r,o);i&&(xv(r,o),It(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=dv(r);i&&(o.preventDefault(),o.stopPropagation(),bv(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&&(_v(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=Zo(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,It(r);var i=o.touches,l=i.length===1,h=i.length===2;l&&(It(r),ta(r,o),Ge(Ve(r),o,m)),h&&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=Jo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];sa(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=Cv(r,o);m&&wv(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=oc(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):sv(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,ys(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=ia(this.props),this.transformState=sc(this.props)}return e})(),bi=le.createContext(null),Ev=function(e,s){return typeof e=="function"?e(s):e},jv=le.forwardRef(function(e,s){var r=b.useRef(new kv(e)).current,o=Ev(e.children,si(r));return b.useImperativeHandle(s,function(){return si(r)},[r]),b.useEffect(function(){r.update(e)},[r,e]),le.createElement(bi.Provider,{value:r},o)});le.forwardRef(function(e,s){var r=b.useRef(null),o=b.useContext(bi);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",cs({},e,{ref:rv([r,s])}))});function Nv(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 Rv=`.transform-component-module_wrapper__SPB86 {
|
|
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),Sr=Kl[0],gi=Kl[1];function Gp(e){var s=qp.config(e),r=s.monaco,o=xp(s,Xp);gi(function(p){return{config:ql(p.config,o),monaco:r}})}function Qp(){var e=Sr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(gi({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=Sr(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=Sr(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){Sr().monaco||gi({monaco:e})}function sg(){return Sr(function(e){var s=e.monaco;return s})}var Fi=new Promise(function(e,s){return gi({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 Ct=hg;function dr(){}function Is(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=dr,onMount:h=dr}){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()}),Ct(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),H=Is(E.current,e||"",o||r||"text",m||"");H!==I.getModel()&&I.setModel(H)}},[m],d),Ct(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),H=Is(E.current,s||"",p||r||"text",v||"");H!==I.getModel()&&I.setModel(H)}},[v],d),Ct(()=>{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),Ct(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),Ct(()=>{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),Ct(()=>{E.current?.editor.setTheme(l)},[l],d),Ct(()=>{k.current?.updateOptions(c)},[c],d);let T=b.useCallback(()=>{if(!E.current)return;R.current(E.current);let I=Is(E.current,e||"",o||r||"text",m||""),H=Is(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,Fr=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=dr,onMount:d=dr,onChange:f,onValidate:S=dr}){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()}),Ct(()=>{let O=Is(j.current,e||o||"",s||p||"",m||r||"");O!==R.current?.getModel()&&(c&&Fr.set(H,R.current?.saveViewState()),R.current?.setModel(O),c&&R.current?.restoreViewState(Fr.get(m)))},[m],C),Ct(()=>{R.current?.updateOptions(l)},[l],C),Ct(()=>{!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),Ct(()=>{let O=R.current?.getModel();O&&p&&j.current?.editor.setModelLanguage(O,p)},[p],C),Ct(()=>{n!==void 0&&R.current?.revealLine(n)},[n],C),Ct(()=>{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,$=Is(j.current,o||e||"",s||p||"",O||"");R.current=j.current?.editor.create(L.current,{model:$,automaticLayout:!0,...l},u),c&&R.current.restoreViewState(Fr.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&&Fr.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,Tt=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)},It=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;It(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 hs(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?Tt(s,2):e>r?Tt(r,2):Tt(e,2):Tt(e,2)},ys=function(e,s){var r=Yn(e,s);return e.bounds=r,r};function wr(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 vi(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=wr(c,g,p,m,0,0,null);return x}function Cr(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=xi(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=vi(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=wr(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}},us=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=us(e,S),L=us(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;It(e),ys(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&&hs(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=us(e,v),g=us(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=Cr(Tt(s,2),m,v,0,!1),l=ys(e,i),u=vi(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&&hs(e,w,u,c)}}var cs=function(){return cs=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},cs.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 zr={scale:1,positionX:0,positionY:0},rr={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:zr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:zr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:zr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:zr.positionY}},na=function(e){var s=cs({},rr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof rr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(rr[r]),v=m==="[object Object]",n=m==="[object Array]";v?s[r]=cs(cs({},rr[r]),e[r]):n?s[r]=ia(ia([],rr[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=Cr(Tt(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.");hs(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=wr(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?.(),hs(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=Cr(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=wr(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};hs(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);hs(e,n,r,o)}}},nv=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),It(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);hs(e,n,o,p)}}},si=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,si(e)),s},Wi=!1;function Hi(){try{var e={get passive(){return Wi=!0,!1}};return e}catch{return Wi=!1,Wi}}var Wr=".".concat(dn.wrapperClass),xi=function(e,s){return s.some(function(r){return e.matches("".concat(Wr," ").concat(r,", ").concat(Wr," .").concat(r,", ").concat(Wr," ").concat(r," *, ").concat(Wr," .").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=xi(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=Cr(Tt(_,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=xi(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=Tt(p[0].clientX-o.left,5),v=Tt(p[0].clientY-o.top,5),n=Tt(p[1].clientX-o.left,5),i=Tt(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 Cr(Tt(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||(It(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=ys(e,C),E=lc(s,m,i),y=a||w===0||u||x,j=l&&y,R=vi(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,It(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=ys(e,w),S=c||g===0||i,C=n&&S,k=vi(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=us(e,j),T=us(e,R),D=E+h,F=y+d,I=wr(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),hs(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=xi(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,ys(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),It(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 It(r),ys(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=us(r,a),f=us(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(),It(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),It(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,It(r);var i=o.touches,l=i.length===1,u=i.length===2;l&&(It(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,ys(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})(),bi=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,si(r));return b.useImperativeHandle(s,function(){return si(r)},[r]),b.useEffect(function(){r.update(e)},[r,e]),le.createElement(bi.Provider,{value:r},o)});le.forwardRef(function(e,s){var r=b.useRef(null),o=b.useContext(bi);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",cs({},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 {
|
|
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
|
-
`,na={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Nv(Rv);var Av=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,h=e.contentProps,c=h===void 0?{}:h,g=b.useContext(bi),x=g.init,y=g.cleanupWindowEvents,w=b.useRef(null),a=b.useRef(null);return b.useEffect(function(){var u=w.current,d=a.current;return u!==null&&d!==null&&x&&x?.(u,d),function(){y?.()}},[]),le.createElement("div",cs({},l,{ref:w,className:"".concat(cn.wrapperClass," ").concat(na.wrapper," ").concat(o),style:v}),le.createElement("div",cs({},c,{ref:a,className:"".concat(cn.contentClass," ").concat(na.content," ").concat(m),style:n}),s))},uc=function(){var e=b.useContext(bi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Tv=function(){var e=uc();return si(e)};function Mv(e){var s=uc(),r=b.useState(e(dn(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,v=s.onChange(function(n){m&&p(e(dn(n.instance)))});return function(){v(),m=!1}},[e,s]),o}function Dv(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 Pv(e,s){return kt({queryKey:ce.files.tree(e||"",s),queryFn:()=>Ee.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Lv(e,s){return kt({queryKey:ce.files.content(e||"",s||""),queryFn:()=>Ee.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function Iv(e){const s=bt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Ov(){const e=bt();return Bt({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||Dv(r.path)})}})}function Bv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function Fv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const zv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Wv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&zv.has(s)?Oa:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Xr:s==="json"?au:s==="md"||s==="mdx"||s==="txt"?Ia:zd}const oa=({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})]}),hc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:n}=ae(),{data:i,isLoading:l,isError:h}=Pv(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...")}):h?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 u=Bv(s,g.name),d=o.has(u);return t.jsxs("div",{children:[t.jsx(oa,{depth:r,onClick:()=>p(u),rightIcon:d?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(ci,{size:14,className:"text-amber-500"}):t.jsx(Rn,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(hc,{workingDir:e,path:u,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},u)}const x=Fv(s,g.name),y=Wv(g),w=v===x,a=y===Oa;return t.jsx(oa,{depth:r,active:w,onClick:()=>m(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?t.jsx(y,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},x)})})},Hv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ae(),[v,n]=b.useState(()=>new Set),i=Iv(e),l=b.useCallback(h=>{n(c=>{const g=new Set(c);return g.has(h)?g.delete(h):g.add(h),g})},[]);return t.jsxs("div",{className:te("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick: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(Es,{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(vu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(hc,{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.")})})]})},$v=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Uv(e){const s=e.split(".").pop()?.toLowerCase();return s?$v.has(s):!1}function qv(e,s){const r=vr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Kv=({filePath:e})=>{const{t:s}=ae(),{zoomIn:r,zoomOut:o,centerView:p}=Tv(),m=Mv(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(Mu,{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(Au,{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(pu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Vv=({workingDir:e,filePath:s})=>{const{t:r}=ae(),[o,p]=b.useState(!1),m=qv(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(jv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Kv,{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(Av,{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 Xv(e){const s=e.split("/");return s[s.length-1]||e}function Yv(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 Gv=({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(Zt,{size:12})})]})},Qv=le.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=ae(),[v,n]=b.useState([]),[i,l]=b.useState(null),[h,c]=b.useState(!1),[g,x]=b.useState(!1),[y,w]=b.useState(0),[a,u]=b.useState(null),d=b.useRef(null),f=Ov();b.useEffect(()=>{let B=!1;return pd(async()=>{const{preloadMonaco:z}=await import("./monaco-Fm9Q8Oob.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),[_,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),u(null)},[s]);const D=b.useMemo(()=>v.find(B=>B.path===i)||null,[v,i]),{data:F,isFetching:I,isError:H,error:q}=Lv(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=Uv(B);return[...N,{path:B,name:Xv(B),language:Yv(B),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(B),u(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(),u(null)},[i,D?.loaded,y,a]),t.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",r),style:_?{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:_?"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(bu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(Hv,{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",_?"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(Gv,{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(He,{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(Vv,{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.")}):h?t.jsxs(t.Fragment,{children:[t.jsx(xg,{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(He,{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(He,{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 _i(e,s={}){const r=Cs(p=>p.visibleContext),o=El(e,r);return kt({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 fc(e,s,r){const o=Cs(m=>m.visibleContext),p=El(e,o);return kt({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 Qn(e,s){return kt({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>Ee.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Zn(e,s,r){return kt({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 Zv=new Set(["STARTING","RUNNING","STOPPING"]);function mc(e){return Zv.has(e.runtimeState)||e.runtimeInstanceId!==null}function pc(e){return e instanceof ni&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function Jv({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(He,{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(ks,{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 gc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:v,isCheckingServices:n,serviceCheckFailed:i,error:l,onConfirm:h}){const{t:c}=ae(),[g,x]=b.useState(""),[y,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),x(p??""))},[e]),b.useEffect(()=>{y||!e||x(p??"")},[p,y,e]);const a=()=>{m||s()};return t.jsx(ds,{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:()=>h(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(He,{size:14,className:"animate-spin"}),n?c("正在检查后台服务..."):v.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vr,{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(tl,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:c("提交消息")}),t.jsx("textarea",{value:g,onChange:u=>{w(!0),x(u.target.value)},placeholder:c("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:c("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!g.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:c("留空将使用默认消息")})]}),t.jsx(Jv,{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 Ds(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function vc(e){if(!(e instanceof ni)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==ur.REBASE&&s.conflictOp!==ur.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:Ds(s,"sourceBranch"),targetBranch:Ds(s,"targetBranch"),sourceWorktreePath:Ds(s,"sourceWorktreePath"),targetWorktreePath:Ds(s,"targetWorktreePath"),sourceWorkspaceId:Ds(s,"sourceWorkspaceId"),targetWorkspaceId:Ds(s,"targetWorkspaceId")}}function aa(e,s,r,o){const p=vc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function xc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:n}){const{t:i}=ae(),{data:l,isLoading:h}=Wn(e),c=Rl(),g=Nl(),x=Hn(),[y,w]=b.useState(!1),[a,u]=b.useState(null),d=Vn(e,y),f=(d.data??[]).filter(mc);if(b.useEffect(()=>{y&&m?.()},[y,m]),h||!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(He,{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,_=!S&&!C&&!k,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!k&&!S,R=()=>{u(null),c.mutate(e,{onError:F=>{aa(F,i("更新失败,请稍后重试"),I=>v(I),u)}})},L=()=>{u(null),w(!0)},T=(F,I)=>{u(null),g.mutate({id:e,commitMessage:F,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(pc(H)){u(i("后台服务仍在运行,请确认停止服务后再提交。"));return}aa(H,i("提交失败,请稍后重试"),q=>{w(!1),v(q)},u)}})},D=()=>{g.isPending||(w(!1),u(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(gd,{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(du,{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(ks,{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(He,{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(vd,{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:!_||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(Es,{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(Vr,{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(Vr,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(gc,{isOpen:y,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,la={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"},ca={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function bc(e){const s=e.split("/");return s[s.length-1]||e}function e0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function t0(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 $r(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const hn=({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"})]}),s0=({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})]})},_c=({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(s0,{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})})]})},r0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=fc(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(He,{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(_c,{diff:m?.diff||""})},i0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=Zn(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(He,{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(_c,{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),h=$r(s,e.path);b.useEffect(()=>(p(h,l.current),()=>p(h,null)),[h,p]),b.useEffect(()=>{const x=l.current;if(!x||n)return;const y=new IntersectionObserver(w=>{w.some(a=>a.isIntersecting)&&(i(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(x),()=>y.disconnect()},[n]);const c=la[e.status]||la.M,g=e0(e.path);return t.jsxs("div",{ref:l,"data-card-key":h,className:te("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>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(Mt,{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:bc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(hn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(r0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(i0,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function n0(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 yc(s)}function yc(e){const s=new Map;for(const r of e.dirs.values()){let o=yc(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 o0=({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(ci,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Rn,{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(Sc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Sc=({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(o0,{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",ca[p.status]||ca.M)}),t.jsx("span",{className:te("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:bc(p.path)})]},p.cardKey)})]}),a0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ae(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=An({queryKey:ce.git.log(e),queryFn:({pageParam:h=0})=>Ee.get("/git/log",{params:{workingDir:e,limit:String($i),skip:String(h)}}),initialPageParam:0,getNextPageParam:(h,c)=>h.commits.length<$i?void 0:c.length*$i}),l=p?.pages.flatMap(h=>h.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(He,{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(h=>{const c=s===h.hash;return t.jsxs("button",{type:"button",onClick:()=>r(h),className:te("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:h.message,children:[t.jsx("span",{className:te("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:te("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:h.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:h.shortHash})," · ",h.author," · ",t0(h.timestamp)]})]})]},h.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(He,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},l0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:l}=ae(),[h,c]=b.useState({kind:"overview"}),[g,x]=b.useState(""),[y,w]=b.useState(null),[a,u]=b.useState(null),{data:d,isLoading:f,isError:S}=_i(e),C=h.kind==="commit"?h.commit.hash:null,{data:k,isLoading:E}=Qn(e,C),_=b.useRef(new Map),j=b.useRef(null),R=b.useRef(null),L=b.useCallback((B,z)=>{z?_.current.set(B,z):_.current.delete(B)},[]),{uncommitted:T,committed:D,commitFiles:F}=b.useMemo(()=>{const B=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(h.kind==="commit"){const N={kind:"commit",hash:h.commit.hash},W=(k?.files||[]).filter(B).map(X=>({...X,cardKey:$r(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const z=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:$r({kind:"working",diffType:"uncommitted"},N.path)})),U=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:$r({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:z,committed:U,commitFiles:[]}},[h,d,k,g]),I=h.kind==="commit"?F:[...T,...D],H=b.useMemo(()=>n0(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 _.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 _.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=_.current.get(B.cardKey);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),w(B.cardKey),u(B.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>u(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=h.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(xc,{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:h.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(qs,{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(hn,{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(Ws,{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(Ws,{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:h.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:h.commit.message}),t.jsx(hn,{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&&h.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(Xr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):h.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):h.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:F.map(B=>t.jsx(qi,{entry:B,source:{kind:"commit",hash:h.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(yn,{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(Sc,{node:H,depth:0,activeKey:y,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(Hs,{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(a0,{workingDir:e,selectedHash:C,onSelectCommit:M})})]})]})]})]})},Ki=50,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"};function c0(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 d0(e){const s=e.split("/");return s[s.length-1]||e}function u0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const h0=({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})]})},f0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ae(),{data:p,isLoading:m,isError:v}=Zn(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(He,{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,h)=>t.jsx(h0,{line:l,lineNum:h+1},h))})},m0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ae(),{data:m,isLoading:v}=Qn(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(He,{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=da[i.status]||da.M,h=u0(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:d0(i.path)}),h&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:h})]},i.path)})})},p0=({workingDir:e})=>{const{t:s}=ae(),r=Cs(E=>E.visibleContext),o=bf(e,r),{data:p,isLoading:m,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:l}=An({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,_)=>E.commits.length<Ki?void 0:_.length*Ki,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),h=p?.pages.flatMap(E=>E.commits)||[],[c,g]=b.useState(null),[x,y]=b.useState(null),[w,a]=b.useState(280),[u,d]=b.useState(!1),f=b.useCallback(E=>{E.preventDefault(),d(!0);const _=E.clientX,j=w,R=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-_)));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),y(null)):(g(E),y(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(He,{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(h.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Hs,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=h.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:u?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:w},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Hs,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:h.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[h.map(E=>{const _=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",_?"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",_?"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(Mt,{size:12,className:te("shrink-0 text-muted-foreground/70 transition-transform",_&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:c0(E.timestamp)})]})]})]}),_&&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(m0,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:y})]})]},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(He,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:te("w-1 shrink-0 cursor-col-resize transition-colors",u?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children: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(Xr,{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(f0,{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(Xr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},ua=vr();function g0(e){if(!ua)return e;try{const s=new URL(ua);return new URL(e,s.origin).toString()}catch{return e}}function wc(e){return{...e,viewUrl:e.viewUrl?g0(e.viewUrl):null}}function v0(e,s=!0){return kt({queryKey:ce.previews.status(e??""),queryFn:async()=>{const r=await Ee.get(`/previews/${e}/status`);return wc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function x0(e){const s=bt();return Bt({mutationFn:async r=>{const o=await Ee.put(`/previews/${e}/config`,{target:r});return wc(o)},onSuccess:r=>{e&&(s.setQueryData(ce.previews.status(e),r),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function b0(){return window.location.protocol==="https:"?"remote":"local"}function _0(e,s,r=!0){const[o,p]=b.useState(null),[m,v]=b.useState(!1),[n,i]=b.useState(null),[l,h]=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 y=a=>{Ee.delete(`/previews/${e}/sessions/${a}`).catch(()=>{})};return(async()=>{v(!0),i(null);try{const a={mode:b0(),localHostname:window.location.hostname},u=await Ee.post(`/previews/${e}/sessions`,a);if(c){y(u.id);return}g=u.id,p(u),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 ni&&d.status===404?h(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&&y(g)}},[r,l,s?.ready,s?.target,e]),{session:o,isOpening:m,error:n,retry:()=>h(c=>c+1)}}const y0="agent-tower-preview",S0="agent-tower-preview-host";function w0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function C0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function k0(e){return t.jsx(E0,{...e},e.workspaceId??"no-workspace")}function E0({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:h,refetch:c,isFetching:g}=v0(e,i),x=x0(e),{session:y,isOpening:w,error:a,retry:u}=_0(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),[_,j]=b.useState(0),[R,L]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),T=C0(y?.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(!y||y.target!==l?.target)return;const K=k.current!==T;k.current=T,L(B=>{const z=r?.source.kind==="web"&&E.current!==r.id?Lr(r.source.url,y.target,y.viewUrl):null;if(!K&&B.iframeSrc&&B.target===y.target&&z?.kind!=="proxy")return B;let U=B.iframeSrc;if(z?.kind==="proxy")U=z.url;else if(!U||B.target!==y.target||K){const W=S.current;if(W)U=Ad(y.viewUrl,W);else{const X=Lr(B.address||y.target,y.target,y.viewUrl);U=X?.kind==="proxy"?X.url:y.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&U&&N.location.replace(U),C.current=null,{target:y.target,address:z?.kind==="proxy"?r?.source.kind==="web"?r.source.url:B.address:B.address||y.target,iframeSrc:U,isFrameLoading:!!U}})},[r,y,T,l?.target]),b.useEffect(()=>()=>{C.current?.close()},[]);const I=b.useCallback(async(K,B=!1)=>{const z=Lr(K,l?.target??null,y?.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)}},[y?.viewUrl,s,l?.target,p,x,e]);b.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&h)return;const K=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(v({source:r.source,iframeSrc:Td(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(B=>B+1)):(v(null),I(r.source.url))},0);return()=>window.clearTimeout(K)},[h,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!==y0)){if(z.type==="location"&&typeof z.href=="string"){const U=Md(l?.target??null,y?.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,y?.viewUrl,l?.target,m]);const H=K=>{d.current?.contentWindow?.postMessage({source:S0,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(!y||!D.iframeSrc){u();return}F({isFrameLoading:!0}),H("reload")},P=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!y?.viewUrl)return;const K=Lr(D.address||y.target,y.target,y.viewUrl),B=K?.kind==="proxy"?K.url:y.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&&(h||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(De,{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(Ws,{})}),t.jsx(De,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>H("forward"),disabled:O||!D.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(tl,{})}),t.jsx(De,{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(Zt,{}):g?t.jsx(He,{className:"animate-spin"}):t.jsx(Es,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:q,children:[t.jsx(iu,{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:w0(),"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(De,{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(pn,{})})]}),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})}},_):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 j0(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ha(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 N0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Cc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:n}=ae(),[i,l]=b.useState(!1),h=b.useRef(null),c=b.useMemo(()=>qn(e,s),[e,s]),g=c.find(x=>x.workspace.id===r)??c[0];return b.useEffect(()=>{if(!i)return;const x=y=>{h.current&&!h.current.contains(y.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:h,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(zs,{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",ha(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:N0($s(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 y=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",y&&"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:y?t.jsx(Jt,{size:13}):t.jsx(qa,{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",ha(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",j0(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:$s(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 R0=[{key:"review",label:"Changes",icon:t.jsx(qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(li,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(or,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ua,{size:14})}],A0=[{key:"history",label:"History",icon:t.jsx(Hs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(li,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(or,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ua,{size:14})}],T0=({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})]}),M0=({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}),kc=le.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:l,teamRun:h,teamStatus:c,gitProps:g,workspaces:x,selectedWorkspaceId:y,onSelectWorkspace:w,variant:a="tabs",expanded:u,onExpandedChange:d,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=ae(),_=Cs(G=>G.setVisibleContext),j=a==="rail",[R,L]=b.useState(!1),T=j?u??R:!0,D=b.useCallback(G=>{u===void 0&&L(G),d?.(G)},[u,d]),F=b.useMemo(()=>{const G=v?A0:R0,pe=n?G:G.filter(Fe=>Fe.key!=="review"&&Fe.key!=="history"),oe=i?pe.filter(Fe=>Fe.key!=="terminal"):pe;return h?[{key:"team-status",label:"Team Status",icon:t.jsx(Ss,{size:14})},...oe]:oe},[n,v,i,h]),[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}=$d(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){_(null);return}return _({workspaceId:o,workingDir:p,tab:G}),()=>{_(null)}},[I,T,j,_,p,o]);const V=!!w&&qn(x,h).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(Cc,{workspaces:x,teamRun:h,selectedWorkspaceId:y,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&h&&c,I==="editor"&&t.jsx(Qv,{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(cp,{cwd:G,workspaceId:pe?o:void 0,isVisible:pe,quickCommands:U})},G)}),I==="preview"&&t.jsx(k0,{workspaceId:o,readOnly:i,navigationRequest:K,onNavigationRequestHandled:B}),I==="review"&&t.jsx(l0,{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(p0,{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(M0,{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(yu,{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(T0,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),he]})}),fa=1500,D0=3e3;function P0(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=rs.connect(),i=h=>{r(h),m.current=setTimeout(()=>r(null),D0)},l=h=>{if(h.taskId!==e)return;const c={status:h.status,currentCommand:h.currentCommand,currentIndex:h.currentIndex,totalCommands:h.totalCommands,error:h.error};if(h.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=fa-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:h.totalCommands,currentIndex:h.totalCommands}),p.current=c,m.current=setTimeout(()=>i(c),fa)):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 Ec({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:l=!0,projectGitReason:h}){const{t:c}=ae(),[g,x]=b.useState(""),[y,w]=b.useState(""),[a,u]=b.useState(_t.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,E]=b.useState(null),_=bt(),j=jl(o),R=Cn(),L=Ud(),{data:T,isLoading:D}=Us(),F=d?.isGitRepo??i,I=d?.worktreeReady??l,H=d?.reason??h,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
|
+
`,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(bi),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",cs({},l,{ref:w,className:"".concat(dn.wrapperClass," ").concat(oa.wrapper," ").concat(o),style:v}),le.createElement("div",cs({},c,{ref:a,className:"".concat(dn.contentClass," ").concat(oa.content," ").concat(m),style:n}),s))},hc=function(){var e=b.useContext(bi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Lv=function(){var e=hc();return si(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 kt({queryKey:ce.files.tree(e||"",s),queryFn:()=>Ee.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Fv(e,s){return kt({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 Bt({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"?Xr: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(Mt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(ci,{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(Es,{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=vr(),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($t,{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-CbFQByO7.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(Fe,{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(Fe,{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(Fe,{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 _i(e,s={}){const r=Cs(p=>p.visibleContext),o=jl(e,r);return kt({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=Cs(m=>m.visibleContext),p=jl(e,o);return kt({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 kt({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 kt({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 ni&&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(Fe,{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(ks,{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(ds,{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(Fe,{size:14,className:"animate-spin"}),n?c("正在检查后台服务..."):v.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vr,{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 Ds(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function xc(e){if(!(e instanceof ni)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==ur.REBASE&&s.conflictOp!==ur.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:Ds(s,"sourceBranch"),targetBranch:Ds(s,"targetBranch"),sourceWorktreePath:Ds(s,"sourceWorktreePath"),targetWorktreePath:Ds(s,"targetWorktreePath"),sourceWorkspaceId:Ds(s,"sourceWorkspaceId"),targetWorkspaceId:Ds(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(Fe,{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(ks,{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(Fe,{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(Es,{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(Vr,{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(Vr,{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 $r(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(Fe,{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(Fe,{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=$r(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(Mt,{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(ci,{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(Fe,{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(Fe,{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}=_i(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:$r(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const z=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:$r({kind:"working",diffType:"uncommitted"},N.path)})),U=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:$r({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(qs,{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(Ws,{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(Ws,{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(Xr,{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(Hs,{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(Fe,{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(Fe,{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=Cs(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(Fe,{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(Hs,{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(Hs,{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(Mt,{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(Fe,{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(Xr,{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(Xr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},ha=vr();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 kt({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 Bt({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 ni&&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?Lr(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=Lr(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=Lr(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=Lr(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(Te,{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(Ws,{})}),t.jsx(Te,{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(Te,{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($t,{}):g?t.jsx(Fe,{className:"animate-spin"}):t.jsx(Es,{})}),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(Te,{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 At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.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(zs,{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($s(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(Ut,{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:$s(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(qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(li,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(or,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(qa,{size:14})}],P0=[{key:"history",label:"History",icon:t.jsx(Hs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(li,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(or,{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=Cs(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(ze=>ze.key!=="review"&&ze.key!=="history"),oe=i?pe.filter(ze=>ze.key!=="terminal"):pe;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(Ss,{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=rs.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}=Us(),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),
|
|
76
|
-
`):"- 未获取到冲突文件列表"}function
|
|
77
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...
|
|
78
|
-
`)}function
|
|
79
|
-
`)}function H0(e){if(e.teamRunId)return{type:"team_room",message:W0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:z0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Tc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:h,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:y,sessions:w,currentSessionId:a,teamRunId:u}){const{t:d}=ae(),[f,S]=b.useState(""),C=En(),k=gn(u??""),E=zn(),_=!!u,j=a||f,R=_?k.isPending:C.isPending,L=()=>{const H=H0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:h,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:y,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:u,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=!_&&!a&&w.length>0,I=_||!!j;return t.jsx(ds,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(De,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(De,{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))})]}),_&&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))]})]}),!_&&!j&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function $0(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 ma(e,s,r,o){const p=vc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Mc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:l,onConflict:h,className:c}){const{t:g}=ae(),x=Rl(),y=Nl(),w=Hn(),[a,u]=b.useState(!1),[d,f]=b.useState(null),S=Vn(e,a),C=(S.data??[]).filter(mc),k=b.useMemo(()=>$0(p),[p]),E=k.additions+k.deletions,_=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]),!_)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=>{ma(B,g("更新失败,请稍后重试"),z=>h(z),f)}}))},O=()=>{q&&(f(null),u(!0))},$=(B,z)=>{f(null),y.mutate({id:e,commitMessage:B,stopActiveServices:z},{onSuccess:()=>u(!1),onError:U=>{if(pc(U)){f(g("后台服务仍在运行,请确认停止服务后再提交。"));return}ma(U,g("提交失败,请稍后重试"),N=>{u(!1),h(N)},f)}})},K=()=>{y.isPending||(u(!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(qs,{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(ks,{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(Mt,{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(He,{size:12,className:"animate-spin"}):t.jsx(Es,{size:12}),t.jsx("span",{children:x.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!q||y.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:[y.isPending?t.jsx(He,{size:12,className:"animate-spin"}):t.jsx(Vr,{size:12}),t.jsx("span",{children:y.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(gc,{isOpen:a,onClose:K,branchName:s,targetBranch:r,commitMessage:o,isPending:y.isPending,activeServices:C,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:d,onConfirm:$})]})}function U0({agentType:e,workingDir:s}){return kt({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await Ee.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Nt.CODEX,staleTime:3e4})}function q0(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 Dc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[n,i]=b.useState(0),{data:l=[]}=U0({agentType:e,workingDir:s}),c=b.useMemo(()=>e===Nt.CODEX?co(r):null,[e,r])?.query??null,g=b.useMemo(()=>c===null?[]:Od(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 y=b.useCallback(a=>{const u=co(r);if(!u)return;const d=`${r.slice(0,u.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(u=>(u+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(u=>(u-1+g.length)%g.length),!0):q0(a)?(a.preventDefault(),y(g[n]??g[0]),!0):!1,[y,g,c,n]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:n,setSelectedIndex:i,applySkill:y,handleKeyDown:w}}const K0=vr(),V0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${K0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ps=520,Vi=48,X0=4,Y0=420;function G0(){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 pa=[{status:we.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx($a,{className:"w-3 h-3"})},{status:we.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Ha,{className:"w-3 h-3"})},{status:we.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Wa,{className:"w-3 h-3"})},{status:we.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(za,{className:"w-3 h-3"})},{status:we.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(Fa,{className:"w-3 h-3"})}];function Q0({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=pa.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:pa.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 ga({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(De,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Qt,{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 Z0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),[n,i]=b.useState(""),[l,h]=b.useState(!1),[c,g]=b.useState(!1),[x,y]=b.useState(!1),[w,a]=b.useState(!1),[u,d]=b.useState(!1),[f,S]=b.useState(!1),[C,k]=b.useState(null),E=b.useRef(null),[_,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}=Sn({resize:"smooth",initial:"instant"}),[z,U]=b.useState(!1),[N,W]=b.useState(Ps),[X,V]=b.useState(!1),ie=b.useRef(0),ee=b.useRef(Ps),me=b.useRef(null),he=b.useCallback((Q,re,Be)=>{E.current?.openFile(Q,re,Be)},[]),{data:G,isLoading:pe}=Fn(e?.id??""),oe=P0(e?.id),{data:Fe}=Da(e?.id??""),{data:ut}=Pa(Fe?.id??""),Ie=gn(Fe?.id??""),be=Fe??null,$e=!!be,Oe=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,tt=Fe===null&&Oe,Ye=!!(e?.id&&Fe===null),{data:Ze,isLoading:Xe}=La(e?.id??"",Ye);b.useEffect(()=>{I(!1),L(null),D(void 0)},[e?.id]);const Ne=b.useMemo(()=>Ll(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===At.ACTIVE?Ae.id:void 0,ze=Oe&&Il(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,tr=mt.endedAt??mt.startedAt??Ni;if(!tr)return 0;const Ts=Date.parse(tr);return Number.isNaN(Ts)?0:Ts},re=(mt,Ni)=>{const tr=mt.filter(Ts=>Ni.includes(Ts.status));return tr.length===0?null:tr.sort((Ts,rd)=>Q(rd)-Q(Ts))[0]??null},Be=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=re(Be,[ct.RUNNING])??re(Be,[ct.PENDING])??re(Be,[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=$e?R??"":pt,Dt=b.useMemo(()=>{if(!R||!G)return null;for(const Q of G){const re=Q.sessions?.find(Be=>Be.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,Be)=>{const ht=Date.parse(re.updatedAt??re.createdAt??""),ft=Date.parse(Be.updatedAt??Be.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]),de=R?Dt:_e??null,ge=de?.id,Ce=b.useMemo(()=>{if(de?.workspaceId)return de.workspaceId;if(!(!de||!G))return G.find(Q=>Q.sessions?.some(re=>re.id===de.id))?.id},[de,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,Be)=>{Y({kind:"visualization",sessionId:Q,file:re},Be)},[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:Pe}=Ka(ge??"",de?.status),ye=!!e?.projectArchivedAt,Le=!!e?.projectRepoDeletedAt,Se=v(Le?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Te}=Us(),[Qe,rt]=b.useState(null);b.useEffect(()=>{rt(_e?.providerId??null)},[_e?.providerId]);const $t=b.useMemo(()=>!_e||!G?!1:!G.some(re=>re.status==="ACTIVE"&&re.sessions?.some(Be=>Be.id===_e.id)),[_e,G]),it=b.useMemo(()=>{if(!(!G||F)){if(Ae)return as(Ae);for(const Q of G)if(Q.status==="ACTIVE"&&as(Q))return as(Q);return as(G[0])}},[F,Ae,G]),nt=Va({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),gt=Dc({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),Ut=Cs(Q=>Q.setVisibleContext),qt=!!(ze&&ve&&it&&!ye),{data:Et,isLoading:Kt}=Wn(ve??"",{enabled:qt}),{data:Vt}=_i(it,{enabled:qt});b.useEffect(()=>{if(!(z||!qt||!ve||!it))return Ut({workspaceId:ve,workingDir:it,tab:"changes"}),()=>{Ut(null)}},[z,ve,Ut,qt,it]);const js=Ae?.sessions??[],Ns=$s(Ae),Xs=Ae?.commitMessage,fs=b.useMemo(()=>Ol(Ae,G,e?.mainBranch??""),[Ae,e?.mainBranch,G]),vt=b.useMemo(()=>Et?.conflictOp&&Et.conflictedFiles.length>0?{conflictOp:Et.conflictOp,conflictedFiles:Et.conflictedFiles}:C,[Et?.conflictOp,Et?.conflictedFiles,C]),Ys=vt?.targetWorkspaceId??ve,kr=vt?.targetWorktreePath??Ae?.worktreePath,Er=vt?.sourceBranch??Ns,ms=vt?.targetBranch??fs,ot=bt(),Xt=b.useCallback(async()=>e?.id?ot.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}):null,[ot,e?.id]),ps=b.useCallback(()=>e?.id?ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,ot]);b.useEffect(()=>{if(!_)return;const Q=re=>{q.current&&!q.current.contains(re.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[_]);const jr=En(),gs=zn(),Nr=bd(),Gs=jl(e?.id??""),Qs=Cn(),Yt=_f(),Ft=b.useMemo(()=>!G||G.some(re=>re.status==="ACTIVE")?null:G.find(re=>re.status==="HIBERNATED")??null,[G]),Zs=b.useRef(null);b.useEffect(()=>{Ft&&Zs.current!==Ft.id&&(Yt.isPending||(Zs.current=Ft.id,Yt.mutate(Ft.id,{onSettled:()=>{Zs.current=null}})))},[Ft,Yt]);const Rr=b.useCallback(async()=>{if(!e?.id)return;const Q=_e?.providerId??Te?.find(re=>re.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),d(!0);try{const Be=(await Xt())?.prompt??e.title;await Nr.mutateAsync(e.id),I(!0);const ht=await Gs.mutateAsync({workspaceKind:Oe?void 0:_t.MAIN_DIRECTORY}),ft=await Ee.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Be});await Qs.mutateAsync(ft.id),await ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(re){console.error("[retry] failed:",re),I(!1)}finally{d(!1)}}},[e?.id,e?.title,Oe,_e?.providerId,Te,Xt,Nr,Gs,Qs,ot]),Rs=b.useCallback(async()=>{e?.id&&(await Xt(),h(!0))},[Xt,e?.id]),Js=b.useCallback(()=>{Ae?.id&&gs.mutate({workspaceId:Ae.id})},[gs,Ae?.id]),Ar=b.useCallback(()=>{!e?.id||!s||(s(e.id),y(!1))},[e?.id,s]),Tr=b.useCallback(Q=>{L(Q),requestAnimationFrame(()=>{K()})},[K]),yi=b.useCallback(()=>{L(null)},[]),vs=b.useCallback(Q=>{k(Q??null),S(!0)},[]),Si=b.useCallback(Q=>Ie.mutateAsync(Q),[Ie]),ts=b.useCallback(()=>{ot.invalidateQueries({queryKey:_d.all})},[ot]),{isConnected:er,isLoadingSnapshot:Mr,isOutputActive:Dr,lastExitAt:Pr,logs:xs,entries:bs,attach:Z}=Za({sessionId:Je,sessionStatus:de?.status,sessionStartedAt:de?.startedAt??de?.createdAt,sessionEndedAt:de?.endedAt??(je?null:de?.updatedAt),onExit:b.useCallback(()=>{ot.invalidateQueries({queryKey:["workspaces"]})},[ot])});b.useEffect(()=>{if(!e?.id)return;const Q=rs.connect();Q.emit(Ls.SUBSCRIBE,{topic:"task",id:e.id});const re=ft=>{ft.taskId===e.id&&(ot.invalidateQueries({queryKey:["tasks"]}),ts())},Be=ft=>{ft.taskId===e.id&&(ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ts())},ht=ft=>{ft.taskId===e.id&&(ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ts())};return Q.on(lt.TASK_UPDATED,re),Q.on(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.on(lt.WORKSPACE_HIBERNATED,ht),()=>{Q.off(lt.TASK_UPDATED,re),Q.off(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.off(lt.WORKSPACE_HIBERNATED,ht),Q.emit(Ls.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,ot,ts]),b.useEffect(()=>{if(!Je)return;const Q=rs.connect(),re=Be=>{Be.sessionId===Je&&(ot.invalidateQueries({queryKey:["workspaces"]}),ts())};return Q.on(lt.SESSION_COMPLETED,re),()=>{Q.off(lt.SESSION_COMPLETED,re)}},[Je,ot,ts]);const{todos:ue}=Ja(bs),{files:Ue,addFiles:Me,removeFile:St,clear:Pt,buildMarkdownLinks:We,hasFiles:jt,isUploading:Lt}=vn(),As=b.useMemo(()=>jc(de),[de?.tokenUsage]),eo=Xa(xs,As);b.useEffect(()=>{Je&&er&&Z()},[Je,er,Z]);const to=b.useRef(e?.id);b.useEffect(()=>{if(to.current!==e?.id&&M.current){const Q=M.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}to.current=e?.id},[e?.id,M]);const wi=Ya(),Ci=b.useRef(!1),so=b.useCallback(async()=>{if(!n.trim()&&!jt||!Je||Ci.current||Lt)return;Ci.current=!0;const Q=We(),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(ai,{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(ds,{isOpen:e,onClose:P?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{variant:"outline",onClick:s,disabled:P,children:c("取消")}),t.jsx(Te,{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(is,{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(is,{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(is,{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(ai,{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 ni&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=x||!_;return t.jsxs(ds,{isOpen:e,onClose:x?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:x,children:o("取消")}),t.jsx(Te,{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(ks,{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(Te,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Te,{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===ur.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===ur.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===ur.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(ds,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Te,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Te,{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(qs,{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(ks,{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(Mt,{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(Fe,{size:12,className:"animate-spin"}):t.jsx(Es,{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(Fe,{size:12,className:"animate-spin"}):t.jsx(Vr,{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 kt({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await Ee.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Nt.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===Nt.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(Te,{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(Fe,{size:16,className:"animate-spin"}):t.jsx(Ut,{size:16})}),t.jsx(Te,{size:v?"sm":"default",variant:"ghost",onClick:d,disabled:a.isPending,className:"h-8 w-8 p-0",children:t.jsx($t,{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(Te,{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=vr(),Z0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Q0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ps=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(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Jt,{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(Ps),[X,V]=b.useState(!1),ie=b.useRef(0),ee=b.useRef(Ps),me=b.useRef(null),he=b.useCallback((Q,re,Be)=>{E.current?.openFile(Q,re,Be)},[]),{data:G,isLoading:pe}=zn(e?.id??""),oe=B0(e?.id),{data:ze}=Pa(e?.id??""),{data:ut}=La(ze?.id??""),Ie=vn(ze?.id??""),be=ze??null,$e=!!be,Oe=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,tt=ze===null&&Oe,Ye=!!(e?.id&&ze===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===At.ACTIVE?Ae.id:void 0,We=Oe&&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,tr=mt.endedAt??mt.startedAt??Ni;if(!tr)return 0;const Ts=Date.parse(tr);return Number.isNaN(Ts)?0:Ts},re=(mt,Ni)=>{const tr=mt.filter(Ts=>Ni.includes(Ts.status));return tr.length===0?null:tr.sort((Ts,nd)=>Q(nd)-Q(Ts))[0]??null},Be=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=re(Be,[ct.RUNNING])??re(Be,[ct.PENDING])??re(Be,[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=$e?R??"":pt,Dt=b.useMemo(()=>{if(!R||!G)return null;for(const Q of G){const re=Q.sessions?.find(Be=>Be.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,Be)=>{const ht=Date.parse(re.updatedAt??re.createdAt??""),ft=Date.parse(Be.updatedAt??Be.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]),de=R?Dt:_e??null,ge=de?.id,Ce=b.useMemo(()=>{if(de?.workspaceId)return de.workspaceId;if(!(!de||!G))return G.find(Q=>Q.sessions?.some(re=>re.id===de.id))?.id},[de,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,Be)=>{Y({kind:"visualization",sessionId:Q,file:re},Be)},[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:Pe}=Va(ge??"",de?.status),ye=!!e?.projectArchivedAt,Le=!!e?.projectRepoDeletedAt,Se=v(Le?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Me}=Us(),[Qe,rt]=b.useState(null);b.useEffect(()=>{rt(_e?.providerId??null)},[_e?.providerId]);const qt=b.useMemo(()=>!_e||!G?!1:!G.some(re=>re.status==="ACTIVE"&&re.sessions?.some(Be=>Be.id===_e.id)),[_e,G]),it=b.useMemo(()=>{if(!(!G||F)){if(Ae)return as(Ae);for(const Q of G)if(Q.status==="ACTIVE"&&as(Q))return as(Q);return as(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}),Kt=Cs(Q=>Q.setVisibleContext),Vt=!!(We&&ve&&it&&!ye),{data:Et,isLoading:Xt}=Hn(ve??"",{enabled:Vt}),{data:Yt}=_i(it,{enabled:Vt});b.useEffect(()=>{if(!(z||!Vt||!ve||!it))return Kt({workspaceId:ve,workingDir:it,tab:"changes"}),()=>{Kt(null)}},[z,ve,Kt,Vt,it]);const js=Ae?.sessions??[],Ns=$s(Ae),Xs=Ae?.commitMessage,fs=b.useMemo(()=>Bl(Ae,G,e?.mainBranch??""),[Ae,e?.mainBranch,G]),vt=b.useMemo(()=>Et?.conflictOp&&Et.conflictedFiles.length>0?{conflictOp:Et.conflictOp,conflictedFiles:Et.conflictedFiles}:C,[Et?.conflictOp,Et?.conflictedFiles,C]),Ys=vt?.targetWorkspaceId??ve,kr=vt?.targetWorktreePath??Ae?.worktreePath,Er=vt?.sourceBranch??Ns,ms=vt?.targetBranch??fs,ot=bt(),Gt=b.useCallback(async()=>e?.id?ot.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}):null,[ot,e?.id]),ps=b.useCallback(()=>e?.id?ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,ot]);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 jr=jn(),gs=Wn(),Nr=Sd(),Gs=Nl(e?.id??""),Qs=kn(),Qt=Cf(),Ft=b.useMemo(()=>!G||G.some(re=>re.status==="ACTIVE")?null:G.find(re=>re.status==="HIBERNATED")??null,[G]),Zs=b.useRef(null);b.useEffect(()=>{Ft&&Zs.current!==Ft.id&&(Qt.isPending||(Zs.current=Ft.id,Qt.mutate(Ft.id,{onSettled:()=>{Zs.current=null}})))},[Ft,Qt]);const Rr=b.useCallback(async()=>{if(!e?.id)return;const Q=_e?.providerId??Me?.find(re=>re.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),d(!0);try{const Be=(await Gt())?.prompt??e.title;await Nr.mutateAsync(e.id),I(!0);const ht=await Gs.mutateAsync({workspaceKind:Oe?void 0:_t.MAIN_DIRECTORY}),ft=await Ee.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Be});await Qs.mutateAsync(ft.id),await ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(re){console.error("[retry] failed:",re),I(!1)}finally{d(!1)}}},[e?.id,e?.title,Oe,_e?.providerId,Me,Gt,Nr,Gs,Qs,ot]),Rs=b.useCallback(async()=>{e?.id&&(await Gt(),u(!0))},[Gt,e?.id]),Js=b.useCallback(()=>{Ae?.id&&gs.mutate({workspaceId:Ae.id})},[gs,Ae?.id]),Ar=b.useCallback(()=>{!e?.id||!s||(s(e.id),_(!1))},[e?.id,s]),Tr=b.useCallback(Q=>{L(Q),requestAnimationFrame(()=>{K()})},[K]),yi=b.useCallback(()=>{L(null)},[]),vs=b.useCallback(Q=>{k(Q??null),S(!0)},[]),Si=b.useCallback(Q=>Ie.mutateAsync(Q),[Ie]),ts=b.useCallback(()=>{ot.invalidateQueries({queryKey:wd.all})},[ot]),{isConnected:er,isLoadingSnapshot:Mr,isOutputActive:Dr,lastExitAt:Pr,logs:xs,entries:bs,attach:Z}=Ja({sessionId:Je,sessionStatus:de?.status,sessionStartedAt:de?.startedAt??de?.createdAt,sessionEndedAt:de?.endedAt??(je?null:de?.updatedAt),onExit:b.useCallback(()=>{ot.invalidateQueries({queryKey:["workspaces"]})},[ot])});b.useEffect(()=>{if(!e?.id)return;const Q=rs.connect();Q.emit(Ls.SUBSCRIBE,{topic:"task",id:e.id});const re=ft=>{ft.taskId===e.id&&(ot.invalidateQueries({queryKey:["tasks"]}),ts())},Be=ft=>{ft.taskId===e.id&&(ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ts())},ht=ft=>{ft.taskId===e.id&&(ot.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ts())};return Q.on(lt.TASK_UPDATED,re),Q.on(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.on(lt.WORKSPACE_HIBERNATED,ht),()=>{Q.off(lt.TASK_UPDATED,re),Q.off(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.off(lt.WORKSPACE_HIBERNATED,ht),Q.emit(Ls.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,ot,ts]),b.useEffect(()=>{if(!Je)return;const Q=rs.connect(),re=Be=>{Be.sessionId===Je&&(ot.invalidateQueries({queryKey:["workspaces"]}),ts())};return Q.on(lt.SESSION_COMPLETED,re),()=>{Q.off(lt.SESSION_COMPLETED,re)}},[Je,ot,ts]);const{todos:ue}=el(bs),{files:Ue,addFiles:De,removeFile:St,clear:Pt,buildMarkdownLinks:He,hasFiles:jt,isUploading:Lt}=xn(),As=b.useMemo(()=>Nc(de),[de?.tokenUsage]),to=Ya(xs,As);b.useEffect(()=>{Je&&er&&Z()},[Je,er,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 wi=Ga(),Ci=b.useRef(!1),ro=b.useCallback(async()=>{if(!n.trim()&&!jt||!Je||Ci.current||Lt)return;Ci.current=!0;const Q=He(),re=[n.trim(),Q].filter(Boolean).join(`
|
|
80
80
|
|
|
81
|
-
`);i(""),Pt(),A.current&&(A.current.style.height="60px"),jr.mutate({id:Je,message:re,providerId:Qe??void 0},{onSuccess:()=>{Z()},onSettled:()=>{Ci.current=!1}})},[n,Je,jr,Z,jt,Lt,We,Pt,Qe]),Xc=b.useCallback(async()=>{Je&&(await wi.mutateAsync(Je),ot.invalidateQueries({queryKey:["workspaces"]}))},[Je,wi,ot]),Yc=b.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&Me(Array.from(re)),Q.target.value=""},[Me]),Gc=b.useCallback(Q=>{const re=Q.clipboardData.items,Be=[];for(const ht of re)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Be.push(ft)}Be.length>0&&(Q.preventDefault(),Me(Be))},[Me]),[ro,ki]=b.useState(!1),Qc=b.useCallback(Q=>{Q.preventDefault(),ki(!0)},[]),Zc=b.useCallback(Q=>{Q.preventDefault(),ki(!1)},[]),Jc=b.useCallback(Q=>{Q.preventDefault(),ki(!1);const re=Q.dataTransfer.files;re.length>0&&Me(Array.from(re))},[Me]),Gt=b.useCallback(Q=>{const re=me.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Be=re?Math.max(Ps,re-Vi-X0-Y0):Ps;return Math.max(Ps,Math.min(Math.round(Q),Be))},[]),Ei=b.useCallback(Q=>{const re=Q.clientX-ie.current;W(Gt(ee.current-re))},[Gt]),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 ed=b.useCallback(Q=>{Q.preventDefault(),ie.current=Q.clientX,ee.current=N,V(!0)},[N]);b.useEffect(()=>{!z||X||W(Q=>Gt(Q))},[Gt,z,X]),b.useEffect(()=>{if(!z)return;const Q=()=>{W(re=>Gt(re))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Gt,z]);const td=b.useCallback(()=>{W(Q=>Gt(Q)),U(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Gt]),sd=b.useCallback(Q=>{i(Q.target.value);const re=Q.target;re.style.height="auto";const Be=re.scrollHeight;re.style.height=`${Math.max(60,Math.min(Be,300))}px`},[]),io=qt&&ve?t.jsx(Mc,{workspaceId:ve,branchName:Ns,targetBranch:fs,commitMessage:Xs,changes:Vt,gitStatus:Et,isGitStatusLoading:Kt,canRunGitOperations:ze,onOpenChanges:td,onRefreshCommitMessage:ps,onConflict:vs,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("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(Q0,{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:Js,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(li,{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(rl,{size:16})}),_&&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(ns,{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(yd,{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:()=>{y(!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(Nn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),ze&&ve&&Et&&t.jsx(O0,{workspaceId:ve,gitStatus:Et,onResolve:()=>vs()}),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:$e&&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(Nc,{session:de,providers:Te,usage:eo,providerIdFallback:fe?.providerId,agentTypeFallback:de?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(De,{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:yi,children:[t.jsx(Ws,{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:Mr?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...")})]}):xs.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(Ur,{logs:xs,downloadSessionId:ge,isOutputActive:Dr,lastExitAt:Pr,onUserToggleDetails:B,workingDir:it,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(hr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),ue.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(Kr,{todos:ue})})})]}):t.jsx(Pl,{teamRun:be,messages:ut??be.messages??[],readOnly:ye,readOnlyMessage:Se,onSendMessage:Si,onViewInvocationSession:Tr,changeSummaryBar:io,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(bn,{urlTransform:V0,components:Ba,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(ga,{state:p,onRetry:p.status==="failed"?Rs: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?Mr?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...")})]}):xs.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(Ur,{logs:xs,downloadSessionId:ge,isOutputActive:Dr,lastExitAt:Pr,onUserToggleDetails:B,workingDir:it,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(Qt,{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(ga,{state:p}):null,!ye&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(De,{onClick:Rs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Qt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),tt&&t.jsxs(De,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ns,{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(hr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),ue.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(Kr,{todos:ue})})}),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})})}):$t?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(De,{size:"sm",onClick:Rs,children:[t.jsx(Qt,{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:Qc,onDragLeave:Zc,onDrop:Jc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[io,Je?t.jsx(Ga,{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 ${ro?"border-info bg-info/5":"border-border"}`,children:[t.jsx(xn,{files:Ue,onRemove:St}),t.jsx("textarea",{ref:A,value:n,onChange:sd,onPaste:Gc,onKeyDown:Q=>{gt.handleKeyDown(Q)||nt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),so())},rows:1,placeholder:v(ro?"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:Yc}),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(jn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[_e&&Te&&t.jsx(Qa,{providers:Te,currentProviderId:Qe,agentType:_e.agentType,runtimeType:_e.runtimeType,onSelect:rt}),t.jsx(kn,{usage:eo}),je&&!n.trim()&&!jt?t.jsx("button",{onClick:Xc,disabled:wi.isPending||Pe,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Fs,{size:14})}):t.jsx("button",{onClick:so,disabled:!n.trim()&&!jt||Lt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||jt)&&!Lt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(wn,{size:18})})]})]})]})]}),t.jsx(qr,{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(qr,{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:ed,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:z?Vi+N:Vi},children:t.jsx(kc,{sessionId:pt||void 0,workspaceId:Ne,workingDir:it,projectId:e.projectId,readOnly:ye,repoDeleted:Le,teamRun:be,teamStatus:be?t.jsx(zl,{teamRun:be,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,onViewInvocationSession:Tr}):void 0,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,variant:"rail",expanded:z,onExpandedChange:Q=>{Q&&W(re=>Gt(re)),U(Q)},minContentWidth:Ps,tabRef:E,gitAvailable:Oe,gitProps:ze&&ve?{branchName:Ns,targetBranch:fs,commitMessage:Xs,canRunGitOperations:!0,onRefreshCommitMessage:ps,onConflict:vs,onResolveConflicts:()=>vs()}:void 0})})]}),!ye&&t.jsx(Ec,{isOpen:l,onClose:()=>h(!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(I0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),ze&&Ys&&vt&&t.jsx(Tc,{open:f,onOpenChange:Q=>{S(Q),Q||k(null)},workspaceId:Ys,conflictOp:vt.conflictOp,conflictedFiles:vt.conflictedFiles,sourceBranch:Er,targetBranch:ms,operation:Et?.operation,worktreePath:kr,mergeAborted:vt.mergeAborted,mergeStrategy:vt.mergeStrategy,sourceWorkspaceId:vt.sourceWorkspaceId,targetWorkspaceId:vt.targetWorkspaceId,sourceWorktreePath:vt.sourceWorktreePath,targetWorktreePath:vt.targetWorktreePath,sessions:js,currentSessionId:$e?void 0:pt,teamRunId:be?.id}),t.jsx(_n,{isOpen:w,onClose:()=>a(!1),onConfirm:Rr,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:u}),t.jsx($n,{isOpen:x,onClose:()=>y(!1),onConfirm:Ar,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(G0,{})}function Jn(e){switch(e){case Wt.TODO:return we.Pending;case Wt.IN_PROGRESS:return we.Running;case Wt.IN_REVIEW:return we.Review;case Wt.DONE:return we.Done;case Wt.CANCELLED:return we.Cancelled}}function J0(e){switch(e){case we.Pending:return Wt.TODO;case we.Running:return Wt.IN_PROGRESS;case we.Review:return Wt.IN_REVIEW;case we.Done:return Wt.DONE;case we.Cancelled:return Wt.CANCELLED}}function ex(e){switch(e){case Nt.CLAUDE_CODE:return"Claude Code";case Nt.GEMINI_CLI:return"Gemini CLI";case Nt.CURSOR_AGENT:return"Cursor Agent";case Nt.CODEX:return"Codex";case Nt.QWEN_CODE:return"Qwen Code";case Nt.KIRO_CLI:return"Kiro CLI";case Nt.OPENCODE:return"OpenCode";case Nt.PI_CODING_AGENT:return"Pi Coding Agent";case Nt.GROK_BUILD:return"Grok Build";case Nt.MINION_CODE:return"Minion Code"}}const ri=["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 Pc(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 tx(e){return{id:e.id,name:e.name,color:e.color||ri[Pc(e.name,ri.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function sx(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:Jn(e.status),agent:e.latestAgentType?ex(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 rx(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||ri[Pc(s.name,ri.length)],title:e.title,status:Jn(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 va={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function ix(e){const s=e.split("/");return s[s.length-1]||e}function nx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function ox({workingDir:e,filePath:s,type:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=fc(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(He,{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,
|
|
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,h)=>{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},h)})})}function fx({entry:e,workingDir:s,hash: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-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: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(Mt,{size:14})})]}),o&&t.jsx(hx,{workingDir:s,hash:r,filePath:e.path})]})}function mx({commit:e,workingDir:s}){const{t:r}=ae(),[o,p]=b.useState(!1),{data:m,isLoading:v}=Qn(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:cx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{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(He,{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(fx,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function px({workingDir:e}){const{t:s}=ae(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:n}=An({queryKey:ce.git.log(e||""),queryFn:({pageParam:l=0})=>Ee.get("/git/log",{params:{workingDir:e||"",limit:String(Xi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,h)=>l.commits.length<Xi?void 0:h.length*Xi,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(He,{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(Hs,{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(mx,{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(He,{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 gx=vr(),vx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${gx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function xx({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 bx=[{key:"chat",label:"Chat",icon:oi},{key:"changes",label:"Changes",icon:qs},{key:"history",label:"History",icon:Hs},{key:"workspace",label:"Workspace",icon:ci}],_x=[{key:"chat",label:"Team room",icon:oi},{key:"team-status",label:"Team Status",icon:Ss},{key:"changes",label:"Changes",icon:qs},{key:"workspace",label:"Workspace",icon:ci}];function _a({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(De,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Qt,{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 yx({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),n=Cs(Z=>Z.setVisibleContext),[i,l]=b.useState("chat"),[h,c]=b.useState(""),[g,x]=b.useState(!1),[y,w]=b.useState(!1),[a,u]=b.useState(!1),[d,f]=b.useState(null),[S,C]=b.useState(void 0),k=b.useRef(0),[E,_]=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}=Sn({resize:"smooth",initial:"instant"}),A=bt();b.useEffect(()=>{if(!a)return;const Z=ue=>{R.current&&!R.current.contains(ue.target)&&u(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[a]);const{data:P,isLoading:M}=Fn(e.id),{data:O}=Da(e.id),{data:$}=Pa(O?.id??""),K=gn(O?.id??""),B=O??null,z=e.isGitRepo!==!1&&e.worktreeReady!==!1,U=b.useMemo(()=>(B?_x:bx).filter(Z=>z||Z.key!=="changes"&&Z.key!=="history"),[z,B]),N=O===null,{data:W,isLoading:X}=La(e.id,N),V=!!e.projectArchivedAt,ie=!!e.projectRepoDeletedAt,ee=v(ie?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");b.useEffect(()=>{C(void 0),f(null),_(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(()=>Ll(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 as(he);for(const Z of P)if(Z.status==="ACTIVE"&&as(Z))return as(Z);return as(P[0])}},[he,P]),pe=he?.status===At.ACTIVE?he.id:void 0,oe=z&&Il(he,B),Fe=he?.branchName??"",ut=he?.commitMessage,Ie=b.useMemo(()=>Ol(he,P,e?.mainBranch??""),[he,e?.mainBranch,P]),be=!!(oe&&pe&&G&&!V),{data:$e,isLoading:Oe}=Wn(pe??"",{enabled:be}),{data:tt}=_i(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(()=>$e?.conflictOp&&$e.conflictedFiles.length>0?{conflictOp:$e.conflictOp,conflictedFiles:$e.conflictedFiles}:Ne,[$e?.conflictOp,$e?.conflictedFiles,Ne]),ze=ve?.targetWorkspaceId??pe,_e=ve?.targetWorktreePath??he?.worktreePath,pt=ve?.sourceBranch??Fe,Je=ve?.targetBranch??Ie,Dt=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]),de=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(We=>We.status==="ACTIVE"&&Array.isArray(We.sessions)).flatMap(We=>We.sessions??[]),ue=We=>{const jt=We.createdAt,Lt=We.endedAt??We.startedAt??jt;if(!Lt)return 0;const As=Date.parse(Lt);return Number.isNaN(As)?0:As},Ue=We=>{const jt=Z.filter(Lt=>We.includes(Lt.status));return jt.length===0?null:jt.sort((Lt,As)=>ue(As)-ue(Lt))[0]??null},Me=Ue([ct.RUNNING])??Ue([ct.PENDING])??Ue([ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(Me)return Me;const Pt=P.filter(We=>(We.status==="ABANDONED"||We.status==="MERGED"||We.status==="HIBERNATED")&&Array.isArray(We.sessions)).flatMap(We=>We.sessions??[]).filter(We=>[ct.COMPLETED,ct.FAILED,ct.CANCELLED].includes(We.status));return Pt.length===0?null:Pt.sort((We,jt)=>ue(jt)-ue(We))[0]??null},[P]),Ce=ge?.id??"",Y=B?d??"":Ce,se=b.useMemo(()=>{if(!d||!P)return null;for(const Z of P){const ue=Z.sessions?.find(Ue=>Ue.id===d);if(ue)return ue}return null},[d,P]),ne=b.useMemo(()=>{if(!d||!B?.invocations)return null;const Z=B.invocations.filter(ue=>ue.sessionId===d);return Z.length===0?null:Z.sort((ue,Ue)=>{const Me=Date.parse(ue.updatedAt??ue.createdAt??""),St=Date.parse(Ue.updatedAt??Ue.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(Me)?0:Me)})[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,Pe=b.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!P))return P.find(Z=>Z.sessions?.some(ue=>ue.id===xe.id))?.id},[xe,P]),ye=b.useCallback((Z,ue)=>{const Me=(ue&&P?.some(St=>St.id===ue)?ue:void 0)??Pe??me??void 0;Me&&C(Me),k.current+=1,_({id:k.current,source:Z,workspaceId:Me}),l("workspace")},[Pe,me,P]),Le=b.useCallback((Z,ue)=>{ye({kind:"web",url:Z},ue)},[ye]),Se=b.useCallback((Z,ue,Ue)=>{ye({kind:"visualization",sessionId:Z,file:ue},Ue)},[ye]),Te=b.useCallback(Z=>{Le(Z,Pe)},[Pe,Le]),Qe=b.useCallback(Z=>{je&&Se(je,Z,Pe)},[je,Pe,Se]),{isActive:rt,isCancelling:$t}=Ka(je??"",xe?.status),it=b.useMemo(()=>!ge||!P?!1:!P.some(ue=>ue.status==="ACTIVE"&&ue.sessions?.some(Ue=>Ue.id===ge.id)),[ge,P]),{data:nt}=Us(),[gt,Ut]=b.useState(null),qt=gt?.sessionId===Ce?gt.providerId:ge?.providerId??null,Et=b.useCallback(Z=>{Ut({sessionId:Ce,providerId:Z})},[Ce]),Kt=Va({agentType:ge?.agentType,workingDir:G,input:h,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Vt=Dc({agentType:ge?.agentType,workingDir:G,input:h,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),js=G&&he?he.id:void 0,Ns=En(),Xs=zn(),fs=Ya(),{isConnected:vt,isLoadingSnapshot:Ys,isOutputActive:kr,lastExitAt:Er,logs:ms,entries:ot,attach:Xt}=Za({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:ps}=Ja(ot),{files:jr,addFiles:gs,removeFile:Nr,clear:Gs,buildMarkdownLinks:Qs,hasFiles:Yt,isUploading:Ft}=vn(),Zs=b.useMemo(()=>jc(xe),[xe?.tokenUsage]),Rr=Xa(ms,Zs);b.useEffect(()=>{Y&&vt&&Xt()},[Y,vt,Xt]);const Rs=b.useRef(null);b.useEffect(()=>{if(Rs.current!==e.id&&D.current){const Z=D.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Rs.current=e.id},[e.id,D]);const Js=b.useRef(!1),Ar=b.useCallback(async()=>{if(!h.trim()&&!Yt||!Ce||Js.current||Ft)return;Js.current=!0;const Z=Qs(),ue=[h.trim(),Z].filter(Boolean).join(`
|
|
81
|
+
`);i(""),Pt(),A.current&&(A.current.style.height="60px"),jr.mutate({id:Je,message:re,providerId:Qe??void 0},{onSuccess:()=>{Z()},onSettled:()=>{Ci.current=!1}})},[n,Je,jr,Z,jt,Lt,He,Pt,Qe]),Gc=b.useCallback(async()=>{Je&&(await wi.mutateAsync(Je),ot.invalidateQueries({queryKey:["workspaces"]}))},[Je,wi,ot]),Qc=b.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&De(Array.from(re)),Q.target.value=""},[De]),Zc=b.useCallback(Q=>{const re=Q.clipboardData.items,Be=[];for(const ht of re)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Be.push(ft)}Be.length>0&&(Q.preventDefault(),De(Be))},[De]),[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&&De(Array.from(re))},[De]),Zt=b.useCallback(Q=>{const re=me.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Be=re?Math.max(Ps,re-Xi-J0-ex):Ps;return Math.max(Ps,Math.min(Math.round(Q),Be))},[]),Ei=b.useCallback(Q=>{const re=Q.clientX-ie.current;W(Zt(ee.current-re))},[Zt]),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=>Zt(Q))},[Zt,z,X]),b.useEffect(()=>{if(!z)return;const Q=()=>{W(re=>Zt(re))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Zt,z]);const rd=b.useCallback(()=>{W(Q=>Zt(Q)),U(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Zt]),id=b.useCallback(Q=>{i(Q.target.value);const re=Q.target;re.style.height="auto";const Be=re.scrollHeight;re.style.height=`${Math.max(60,Math.min(Be,300))}px`},[]),no=Vt&&ve?t.jsx(Dc,{workspaceId:ve,branchName:Ns,targetBranch:fs,commitMessage:Xs,changes:Yt,gitStatus:Et,isGitStatusLoading:Xt,canRunGitOperations:We,onOpenChanges:rd,onRefreshCommitMessage:ps,onConflict:vs,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:Js,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(li,{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(ns,{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("删除任务")})]})]})]})]})]})]})]}),We&&ve&&Et&&t.jsx(W0,{workspaceId:ve,gitStatus:Et,onResolve:()=>vs()}),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:$e&&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:de,providers:Me,usage:to,providerIdFallback:fe?.providerId,agentTypeFallback:de?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{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:yi,children:[t.jsx(Ws,{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:Mr?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...")})]}):xs.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(Ur,{logs:xs,downloadSessionId:ge,isOutputActive:Dr,lastExitAt:Pr,onUserToggleDetails:B,workingDir:it,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(hr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),ue.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(Kr,{todos:ue})})})]}):t.jsx(Ll,{teamRun:be,messages:ut??be.messages??[],readOnly:ye,readOnlyMessage:Se,onSendMessage:Si,onViewInvocationSession:Tr,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"?Rs: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?Mr?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...")})]}):xs.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(Ur,{logs:xs,downloadSessionId:ge,isOutputActive:Dr,lastExitAt:Pr,onUserToggleDetails:B,workingDir:it,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(Jt,{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(Te,{onClick:Rs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Jt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),tt&&t.jsxs(Te,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ns,{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(hr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),ue.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(Kr,{todos:ue})})}),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})})}):qt?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(Te,{size:"sm",onClick:Rs,children:[t.jsx(Jt,{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:Ue,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&&Me&&t.jsx(Za,{providers:Me,currentProviderId:Qe,agentType:_e.agentType,runtimeType:_e.runtimeType,onSelect:rt}),t.jsx(En,{usage:to}),je&&!n.trim()&&!jt?t.jsx("button",{onClick:Gc,disabled:wi.isPending||Pe,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Fs,{size:14})}):t.jsx("button",{onClick:ro,disabled:!n.trim()&&!jt||Lt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||jt)&&!Lt?"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(qr,{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(qr,{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:Tr}):void 0,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,variant:"rail",expanded:z,onExpandedChange:Q=>{Q&&W(re=>Zt(re)),U(Q)},minContentWidth:Ps,tabRef:E,gitAvailable:Oe,gitProps:We&&ve?{branchName:Ns,targetBranch:fs,commitMessage:Xs,canRunGitOperations:!0,onRefreshCommitMessage:ps,onConflict:vs,onResolveConflicts:()=>vs()}: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}),We&&Ys&&vt&&t.jsx(Mc,{open:f,onOpenChange:Q=>{S(Q),Q||k(null)},workspaceId:Ys,conflictOp:vt.conflictOp,conflictedFiles:vt.conflictedFiles,sourceBranch:Er,targetBranch:ms,operation:Et?.operation,worktreePath:kr,mergeAborted:vt.mergeAborted,mergeStrategy:vt.mergeStrategy,sourceWorkspaceId:vt.sourceWorkspaceId,targetWorkspaceId:vt.targetWorkspaceId,sourceWorktreePath:vt.sourceWorktreePath,targetWorktreePath:vt.targetWorktreePath,sessions:js,currentSessionId:$e?void 0:pt,teamRunId:be?.id}),t.jsx(yn,{isOpen:w,onClose:()=>a(!1),onConfirm:Rr,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Un,{isOpen:x,onClose:()=>_(!1),onConfirm:Ar,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(tx,{})}function eo(e){switch(e){case Wt.TODO:return we.Pending;case Wt.IN_PROGRESS:return we.Running;case Wt.IN_REVIEW:return we.Review;case Wt.DONE:return we.Done;case Wt.CANCELLED:return we.Cancelled}}function ix(e){switch(e){case we.Pending:return Wt.TODO;case we.Running:return Wt.IN_PROGRESS;case we.Review:return Wt.IN_REVIEW;case we.Done:return Wt.DONE;case we.Cancelled:return Wt.CANCELLED}}function nx(e){switch(e){case Nt.CLAUDE_CODE:return"Claude Code";case Nt.GEMINI_CLI:return"Gemini CLI";case Nt.CURSOR_AGENT:return"Cursor Agent";case Nt.CODEX:return"Codex";case Nt.QWEN_CODE:return"Qwen Code";case Nt.KIRO_CLI:return"Kiro CLI";case Nt.OPENCODE:return"OpenCode";case Nt.PI_CODING_AGENT:return"Pi Coding Agent";case Nt.GROK_BUILD:return"Grok Build";case Nt.MINION_CODE:return"Minion Code"}}const ri=["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||ri[Ic(e.name,ri.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||ri[Ic(s.name,ri.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(Fe,{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(Mt,{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(Mt,{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}=_i(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(Fe,{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(qs,{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(Fe,{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(Mt,{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(Mt,{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(Fe,{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(Fe,{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(Hs,{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(Fe,{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=vr(),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:oi},{key:"changes",label:"Changes",icon:qs},{key:"history",label:"History",icon:Hs},{key:"workspace",label:"Workspace",icon:ci}],kx=[{key:"chat",label:"Team room",icon:oi},{key:"team-status",label:"Team Status",icon:Ss},{key:"changes",label:"Changes",icon:qs},{key:"workspace",label:"Workspace",icon:ci}];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(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Jt,{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=Cs(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=ue=>{R.current&&!R.current.contains(ue.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 as(he);for(const Z of P)if(Z.status==="ACTIVE"&&as(Z))return as(Z);return as(P[0])}},[he,P]),pe=he?.status===At.ACTIVE?he.id:void 0,oe=z&&Ol(he,B),ze=he?.branchName??"",ut=he?.commitMessage,Ie=b.useMemo(()=>Bl(he,P,e?.mainBranch??""),[he,e?.mainBranch,P]),be=!!(oe&&pe&&G&&!V),{data:$e,isLoading:Oe}=Hn(pe??"",{enabled:be}),{data:tt}=_i(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(()=>$e?.conflictOp&&$e.conflictedFiles.length>0?{conflictOp:$e.conflictOp,conflictedFiles:$e.conflictedFiles}:Ne,[$e?.conflictOp,$e?.conflictedFiles,Ne]),We=ve?.targetWorkspaceId??pe,_e=ve?.targetWorktreePath??he?.worktreePath,pt=ve?.sourceBranch??ze,Je=ve?.targetBranch??Ie,Dt=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]),de=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(He=>He.status==="ACTIVE"&&Array.isArray(He.sessions)).flatMap(He=>He.sessions??[]),ue=He=>{const jt=He.createdAt,Lt=He.endedAt??He.startedAt??jt;if(!Lt)return 0;const As=Date.parse(Lt);return Number.isNaN(As)?0:As},Ue=He=>{const jt=Z.filter(Lt=>He.includes(Lt.status));return jt.length===0?null:jt.sort((Lt,As)=>ue(As)-ue(Lt))[0]??null},De=Ue([ct.RUNNING])??Ue([ct.PENDING])??Ue([ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(De)return De;const Pt=P.filter(He=>(He.status==="ABANDONED"||He.status==="MERGED"||He.status==="HIBERNATED")&&Array.isArray(He.sessions)).flatMap(He=>He.sessions??[]).filter(He=>[ct.COMPLETED,ct.FAILED,ct.CANCELLED].includes(He.status));return Pt.length===0?null:Pt.sort((He,jt)=>ue(jt)-ue(He))[0]??null},[P]),Ce=ge?.id??"",Y=B?d??"":Ce,se=b.useMemo(()=>{if(!d||!P)return null;for(const Z of P){const ue=Z.sessions?.find(Ue=>Ue.id===d);if(ue)return ue}return null},[d,P]),ne=b.useMemo(()=>{if(!d||!B?.invocations)return null;const Z=B.invocations.filter(ue=>ue.sessionId===d);return Z.length===0?null:Z.sort((ue,Ue)=>{const De=Date.parse(ue.updatedAt??ue.createdAt??""),St=Date.parse(Ue.updatedAt??Ue.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(De)?0:De)})[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,Pe=b.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!P))return P.find(Z=>Z.sessions?.some(ue=>ue.id===xe.id))?.id},[xe,P]),ye=b.useCallback((Z,ue)=>{const De=(ue&&P?.some(St=>St.id===ue)?ue:void 0)??Pe??me??void 0;De&&C(De),k.current+=1,y({id:k.current,source:Z,workspaceId:De}),l("workspace")},[Pe,me,P]),Le=b.useCallback((Z,ue)=>{ye({kind:"web",url:Z},ue)},[ye]),Se=b.useCallback((Z,ue,Ue)=>{ye({kind:"visualization",sessionId:Z,file:ue},Ue)},[ye]),Me=b.useCallback(Z=>{Le(Z,Pe)},[Pe,Le]),Qe=b.useCallback(Z=>{je&&Se(je,Z,Pe)},[je,Pe,Se]),{isActive:rt,isCancelling:qt}=Va(je??"",xe?.status),it=b.useMemo(()=>!ge||!P?!1:!P.some(ue=>ue.status==="ACTIVE"&&ue.sessions?.some(Ue=>Ue.id===ge.id)),[ge,P]),{data:nt}=Us(),[gt,Kt]=b.useState(null),Vt=gt?.sessionId===Ce?gt.providerId:ge?.providerId??null,Et=b.useCallback(Z=>{Kt({sessionId:Ce,providerId:Z})},[Ce]),Xt=Xa({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Yt=Pc({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),js=G&&he?he.id:void 0,Ns=jn(),Xs=Wn(),fs=Ga(),{isConnected:vt,isLoadingSnapshot:Ys,isOutputActive:kr,lastExitAt:Er,logs:ms,entries:ot,attach:Gt}=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:ps}=el(ot),{files:jr,addFiles:gs,removeFile:Nr,clear:Gs,buildMarkdownLinks:Qs,hasFiles:Qt,isUploading:Ft}=xn(),Zs=b.useMemo(()=>Nc(xe),[xe?.tokenUsage]),Rr=Ya(ms,Zs);b.useEffect(()=>{Y&&vt&&Gt()},[Y,vt,Gt]);const Rs=b.useRef(null);b.useEffect(()=>{if(Rs.current!==e.id&&D.current){const Z=D.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Rs.current=e.id},[e.id,D]);const Js=b.useRef(!1),Ar=b.useCallback(async()=>{if(!u.trim()&&!Qt||!Ce||Js.current||Ft)return;Js.current=!0;const Z=Qs(),ue=[u.trim(),Z].filter(Boolean).join(`
|
|
84
84
|
|
|
85
|
-
`);c(""),Gs(),L.current&&(L.current.style.height="40px"),Ns.mutate({id:Ce,message:ue,providerId:qt??void 0},{onSuccess:()=>Xt(),onSettled:()=>{Js.current=!1}})},[h,Ce,Ns,Xt,Yt,Ft,Qs,Gs,qt]),Tr=b.useCallback(async()=>{Ce&&(await fs.mutateAsync(Ce),A.invalidateQueries({queryKey:["workspaces"]}))},[Ce,fs,A]),yi=b.useCallback(Z=>K.mutateAsync(Z),[K]),vs=b.useCallback(Z=>{f(Z),l("chat"),requestAnimationFrame(()=>{H()})},[H]),Si=b.useCallback(()=>{f(null)},[]),ts=b.useCallback(()=>{l("changes")},[]),er=be&&pe?t.jsx(Mc,{workspaceId:pe,branchName:Fe,targetBranch:Ie,commitMessage:ut,changes:tt,gitStatus:$e,isGitStatusLoading:Oe,canRunGitOperations:oe,onOpenChanges:ts,onRefreshCommitMessage:fe,onConflict:J,className:"mb-2"}):null,Mr=b.useCallback(Z=>{const ue=Z.target.files;ue&&ue.length>0&&gs(Array.from(ue)),Z.target.value=""},[gs]),Dr=b.useCallback(Z=>{const ue=Z.clipboardData.items,Ue=[];for(const Me of ue)if(Me.kind==="file"){const St=Me.getAsFile();St&&Ue.push(St)}Ue.length>0&&(Z.preventDefault(),gs(Ue))},[gs]),Pr=b.useCallback(Z=>{c(Z.target.value);const ue=Z.target;ue.style.height="auto",ue.style.height=`${Math.max(40,Math.min(ue.scrollHeight,140))}px`},[]),xs=b.useCallback(()=>{js&&Xs.mutate({workspaceId:js})},[Xs,js]),bs=b.useRef(null);return b.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let ue=!1;const Ue=()=>{bs.current&&(bs.current.style.height=`${Z.height}px`,bs.current.style.top=`${Z.offsetTop}px`)},Me=()=>Ue(),St=()=>{ue||Ue()},Pt=()=>{ue=!0},We=()=>{ue=!1,requestAnimationFrame(Ue)};return Z.addEventListener("resize",Me),Z.addEventListener("scroll",St),document.addEventListener("touchstart",Pt,{passive:!0}),document.addEventListener("touchend",We,{passive:!0}),document.addEventListener("touchcancel",We,{passive:!0}),()=>{Z.removeEventListener("resize",Me),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",Pt),document.removeEventListener("touchend",We),document.removeEventListener("touchcancel",We)}},[]),b.useEffect(()=>{const Z=bs.current;if(!Z)return;const ue=Ue=>{let Me=Ue.target;for(;Me&&Me!==Z;){if(Me.tagName==="TEXTAREA"){if(Me.scrollHeight>Me.clientHeight)return;Me=Me.parentElement;continue}const Pt=window.getComputedStyle(Me).overflowY;if((Pt==="auto"||Pt==="scroll")&&Me.scrollHeight>Me.clientHeight)return;Me=Me.parentElement}Ue.preventDefault()};return Z.addEventListener("touchmove",ue,{passive:!1}),()=>Z.removeEventListener("touchmove",ue)},[]),t.jsxs("div",{ref:bs,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(Ws,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),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(xx,{status:e.status}),t.jsx("button",{onClick:xs,disabled:!js||V,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(li,{size:16})}),r&&!V&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>u(Z=>!Z),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(rl,{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),u(!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(Nn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:U.map(({key:Z,label:ue,icon:Ue})=>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(Ue,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(ue)})]},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(Nc,{session:xe,providers:nt,usage:Rr,compact:!0,providerIdFallback:ke?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(De,{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:Si,children:[t.jsx(Ws,{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:Ys?t.jsx(Yi,{label:v("Loading logs...")}):ms.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(Ur,{logs:ms,downloadSessionId:je,isOutputActive:kr,lastExitAt:Er,onUserToggleDetails:q,onOpenPreviewUrl:Te,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(hr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ps.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(Kr,{todos:ps,compact:!0})})]}):t.jsx(Pl,{teamRun:B,messages:$??B.messages??[],readOnly:V,readOnlyMessage:ee,onSendMessage:yi,onViewInvocationSession:vs,changeSummaryBar:er,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(bn,{urlTransform:vx,components:Ba,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(_a,{state:p,onRetry:p.status==="failed"?async()=>{await de(),x(!0)}:void 0})}):null,M?t.jsx(Yi,{label:"Loading..."}):Ce?Ys?t.jsx(Yi,{label:"Loading logs..."}):ms.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(Ur,{logs:ms,downloadSessionId:je,isOutputActive:kr,lastExitAt:Er,onUserToggleDetails:q,onOpenPreviewUrl:Te,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(Qt,{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(_a,{state:p}):null,!V&&t.jsxs(De,{onClick:async()=>{await de(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Qt,{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(hr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ps.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(Kr,{todos:ps,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(De,{size:"sm",onClick:async()=>{await de(),x(!0)},children:[t.jsx(Qt,{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:[er,t.jsx(Ga,{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(xn,{files:jr,onRemove:Nr}),t.jsx("textarea",{ref:L,value:h,onChange:Pr,onPaste:Dr,onKeyDown:Z=>{Vt.handleKeyDown(Z)||Kt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Ar())},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:Mr}),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(jn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ge&&nt&&t.jsx(Qa,{providers:nt,currentProviderId:qt,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Et}),t.jsx(kn,{usage:Rr}),rt&&!h.trim()&&!Yt?t.jsx("button",{onClick:Tr,disabled:fs.isPending||$t,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Fs,{size:12})}):t.jsx("button",{onClick:Ar,disabled:!h.trim()&&!Yt||Ft,className:`p-1.5 rounded-lg transition-colors ${(h.trim()||Yt)&&!Ft?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(wn,{size:15})})]})]})]}),t.jsx(qr,{open:Kt.query!==null,anchorRef:j,commands:Kt.filteredCommands,selectedIndex:Kt.selectedIndex,query:Kt.query??"",hasCatalog:Kt.allCommands.length>0,compact:!0,onSelect:Kt.applyCommand}),t.jsx(qr,{open:Vt.query!==null,anchorRef:j,commands:Vt.filteredSkills,selectedIndex:Vt.selectedIndex,query:Vt.query??"",hasCatalog:Vt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Vt.applySkill})]})]})),i==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(zl,{teamRun:B,workspaces:P,selectedWorkspaceId:me,onSelectWorkspace:C,onViewInvocationSession:vs})}),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(Cc,{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(xc,{workspaceId:pe,branchName:Fe,targetBranch:Ie,commitMessage:ut,committedFileCount:Ye,onRefreshCommitMessage:fe,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(lx,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(px,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(kc,{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=>{_(ue=>ue?.id===Z?void 0:ue)}})}),!V&&t.jsx(Ec,{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($n,{isOpen:y,onClose:()=>w(!1),onConfirm:()=>{r?.(e.id),w(!1)},taskId:e.id,taskTitle:e.title,workspaces:P,isLoading:o}),Ze&&ve&&ze&&t.jsx(Tc,{open:Ze,onOpenChange:Z=>{Xe(Z),Z||Ae(null)},workspaceId:ze,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:pt,targetBranch:Je,operation:$e?.operation,worktreePath:_e,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Dt,currentSessionId:B?void 0:Ce,teamRunId:B?.id})]})}function Yi({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 Sx=Object.defineProperty,ii=Object.getOwnPropertySymbols,Lc=Object.prototype.hasOwnProperty,Ic=Object.prototype.propertyIsEnumerable,ya=(e,s,r)=>s in e?Sx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,fn=(e,s)=>{for(var r in s||(s={}))Lc.call(s,r)&&ya(e,r,s[r]);if(ii)for(var r of ii(s))Ic.call(s,r)&&ya(e,r,s[r]);return e},mn=(e,s)=>{var r={};for(var o in e)Lc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ii)for(var o of ii(e))s.indexOf(o)<0&&Ic.call(e,o)&&(r[o]=e[o]);return r};var ws;(e=>{const s=class Re{constructor(i,l,h,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 y=0;y<this.size;y++)g.push(!1);for(let y=0;y<this.size;y++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(h);if(this.drawCodewords(x),c==-1){let y=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const a=this.getPenaltyScore();a<y&&(c=w,y=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 h=e.QrSegment.makeSegments(i);return Re.encodeSegments(h,l)}static encodeBinary(i,l){const h=e.QrSegment.makeBytes(i);return Re.encodeSegments([h],l)}static encodeSegments(i,l,h=1,c=40,g=-1,x=!0){if(!(Re.MIN_VERSION<=h&&h<=c&&c<=Re.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,w;for(y=h;;y++){const f=Re.getNumDataCodewords(y,l)*8,S=v.getTotalBits(i,y);if(S<=f){w=S;break}if(y>=c)throw new RangeError("Data too long")}for(const f of[Re.Ecc.MEDIUM,Re.Ecc.QUARTILE,Re.Ecc.HIGH])x&&w<=Re.getNumDataCodewords(y,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(y),a);for(const S of f.getData())a.push(S)}p(a.length==w);const u=Re.getNumDataCodewords(y,l)*8;p(a.length<=u),r(0,Math.min(4,u-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<u;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(y,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 h=0;h<this.size;h++)this.setFunctionModule(6,h,h%2==0),this.setFunctionModule(h,6,h%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 h=0;h<l;h++)for(let c=0;c<l;c++)h==0&&c==0||h==0&&c==l-1||h==l-1&&c==0||this.drawAlignmentPattern(i[h],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let h=l;for(let g=0;g<10;g++)h=h<<1^(h>>>9)*1335;const c=(l<<10|h)^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 h=0;h<12;h++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;p(l>>>18==0);for(let h=0;h<18;h++){const c=o(l,h),g=this.size-11+h%3,x=Math.floor(h/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,g,c)}}drawFinderPattern(i,l){for(let h=-4;h<=4;h++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(h)),x=i+c,y=l+h;0<=x&&x<this.size&&0<=y&&y<this.size&&this.setFunctionModule(x,y,g!=2&&g!=4)}}drawAlignmentPattern(i,l){for(let h=-2;h<=2;h++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+h,Math.max(Math.abs(c),Math.abs(h))!=1)}setFunctionModule(i,l,h){this.modules[l][i]=h,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,h=this.errorCorrectionLevel;if(i.length!=Re.getNumDataCodewords(l,h))throw new RangeError("Invalid argument");const c=Re.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][l],g=Re.ECC_CODEWORDS_PER_BLOCK[h.ordinal][l],x=Math.floor(Re.getNumRawDataModules(l)/8),y=c-x%c,w=Math.floor(x/c);let a=[];const u=Re.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=i.slice(S,S+w-g+(f<y?0:1));S+=C.length;const k=Re.reedSolomonComputeRemainder(C,u);f<y&&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>=y)&&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 h=this.size-1;h>=1;h-=2){h==6&&(h=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const x=h-g,w=(h+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 h=0;h<this.size;h++){let c;switch(i){case 0:c=(h+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=h%3==0;break;case 3:c=(h+l)%3==0;break;case 4:c=(Math.floor(h/3)+Math.floor(l/2))%2==0;break;case 5:c=h*l%2+h*l%3==0;break;case 6:c=(h*l%2+h*l%3)%2==0;break;case 7:c=((h+l)%2+h*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][h]&&c&&(this.modules[l][h]=!this.modules[l][h])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let x=!1,y=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(y++,y==5?i+=Re.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[g][a],y=1);i+=this.finderPenaltyTerminateAndCount(x,y,w)*Re.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,y=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(y++,y==5?i+=Re.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[a][g],y=1);i+=this.finderPenaltyTerminateAndCount(x,y,w)*Re.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const y=this.modules[g][x];y==this.modules[g][x+1]&&y==this.modules[g+1][x]&&y==this.modules[g+1][x+1]&&(i+=Re.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((x,y)=>x+(y?1:0),l);const h=this.size*this.size,c=Math.ceil(Math.abs(l*20-h*10)/h)-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 h=[6];for(let c=this.size-7;h.length<i;c-=l)h.splice(1,0,c);return h}}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 h=Math.floor(i/7)+2;l-=(25*h-10)*h-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 h=1;for(let c=0;c<i;c++){for(let g=0;g<l.length;g++)l[g]=Re.reedSolomonMultiply(l[g],h),g+1<l.length&&(l[g]^=l[g+1]);h=Re.reedSolomonMultiply(h,2)}return l}static reedSolomonComputeRemainder(i,l){let h=l.map(c=>0);for(const c of i){const g=c^h.shift();h.push(0),l.forEach((x,y)=>h[y]^=Re.reedSolomonMultiply(x,g))}return h}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let h=0;for(let c=7;c>=0;c--)h=h<<1^(h>>>7)*285,h^=(l>>>c&1)*i;return p(h>>>8==0),h}finderPenaltyCountPatterns(i){const l=i[1];p(l<=this.size*3);const h=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(h&&i[0]>=l*4&&i[6]>=l?1:0)+(h&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,h){return i&&(this.finderPenaltyAddHistory(l,h),l=0),l+=this.size,this.finderPenaltyAddHistory(l,h),this.finderPenaltyCountPatterns(h)}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 h=i-1;h>=0;h--)l.push(n>>>h&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,h){if(this.mode=i,this.numChars=l,this.bitData=h,l<0)throw new RangeError("Invalid argument");this.bitData=h.slice()}static makeBytes(i){let l=[];for(const h of i)r(h,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 h=0;h<i.length;){const c=Math.min(i.length-h,3);r(parseInt(i.substring(h,h+c),10),c*3+1,l),h+=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=[],h;for(h=0;h+2<=i.length;h+=2){let c=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(h))*45;c+=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(h+1)),r(c,11,l)}return h<i.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(h)),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 h=0;for(const c of i){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;h+=4+g+c.bitData.length}return h}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let h=0;h<i.length;h++)i.charAt(h)!="%"?l.push(i.charCodeAt(h)):(l.push(parseInt(i.substring(h+1,h+3),16)),h+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(ws||(ws={}));(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={}))})(ws||(ws={}));(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={}))})(ws||(ws={}));var Os=ws;var wx={L:Os.QrCode.Ecc.LOW,M:Os.QrCode.Ecc.MEDIUM,Q:Os.QrCode.Ecc.QUARTILE,H:Os.QrCode.Ecc.HIGH},Oc=128,Bc="L",Fc="#FFFFFF",zc="#000000",Wc=!1,Hc=1,Cx=4,kx=0,Ex=.1;function $c(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 Uc(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 jx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Ex),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,h=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 y=Math.floor(l),w=Math.floor(h),a=Math.ceil(n+l-y),u=Math.ceil(i+h-w);g={x:y,y:w,w:a,h:u}}const x=o.crossOrigin;return{x:l,y:h,h:i,w:n,excavation:g,opacity:c,crossOrigin:x}}function Nx(e,s){return s!=null?Math.max(Math.floor(s),0):e?Cx:kx}function qc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:n}){let i=le.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((w,a)=>(w.push(...Os.QrSegment.makeSegments(a)),w),[]);return Os.QrCode.encodeSegments(y,wx[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:h,numCells:c,calculatedImageSettings:g}=le.useMemo(()=>{let x=i.getModules();const y=Nx(o,p),w=x.length+y*2,a=jx(x,v,y,m);return{cells:x,margin:y,numCells:w,calculatedImageSettings:a}},[i,v,m,o,p]);return{qrcode:i,margin:h,cells:l,numCells:c,calculatedImageSettings:g}}var Rx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ax=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Oc,level:v=Bc,bgColor:n=Fc,fgColor:i=zc,includeMargin:l=Wc,minVersion:h=Hc,boostLevel:c,marginSize:g,imageSettings:x}=o,w=mn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=w,u=mn(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:_,cells:j,numCells:R,calculatedImageSettings:L}=qc({value:p,level:v,minVersion:h,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=Uc(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,Rx?I.fill(new Path2D($c(H,_))):j.forEach(function(O,$){O.forEach(function(K,B){K&&I.fillRect(B+_,$+_,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(q,L.x+_,L.y+_,L.w,L.h)}}),le.useEffect(()=>{E(!1)},[d]);const T=fn({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",fn({style:T,height:m,width:m,ref:C,role:"img"},u)),D)});Ax.displayName="QRCodeCanvas";var Kc=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Oc,level:v=Bc,bgColor:n=Fc,fgColor:i=zc,includeMargin:l=Wc,minVersion:h=Hc,boostLevel:c,title:g,marginSize:x,imageSettings:y}=o,w=mn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:u,numCells:d,calculatedImageSettings:f}=qc({value:p,level:v,minVersion:h,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:y,size:m});let S=u,C=null;y!=null&&f!=null&&(f.excavation!=null&&(S=Uc(u,f.excavation)),C=le.createElement("image",{href:y.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=$c(S,a);return le.createElement("svg",fn({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)});Kc.displayName="QRCodeSVG";function Vc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Tx(){return kt({queryKey:ce.tunnel.status,queryFn:()=>Ee.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Mx(){const e=bt();return Bt({mutationFn:()=>Ee.post("/tunnel/start",{port:Vc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Dx(){const e=bt();return Bt({mutationFn:()=>Ee.post("/tunnel/regenerate",{port:Vc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Px(){const e=bt();return Bt({mutationFn:()=>Ee.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Lx(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 Ix(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 Ox(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 Sa(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 ir(e){const s=e?.trim();return s||null}function Bx(e){if(!e)return"";const s=[ir(e.lastLocalError),ir(e.lastRemoteError),ir(e.lastError)].filter(p=>p!==null),r=ir(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!ir(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
86
|
-
`)}function wa(){const{t:e}=ae(),{data:s}=Tx(),r=Mx(),o=Px(),p=Dx(),[m,v]=b.useState(!1),[n,i]=b.useState(null),l=b.useRef(null),[h,c]=b.useState({top:0,right:0}),[g,x]=b.useState(!1),[y,w]=b.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",u=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,S=s?.token,C=Lx(s),k=Ix(s),E=Bx(s);b.useEffect(()=>{if(m&&l.current){const F=l.current.getBoundingClientRect();c({top:F.bottom+8,right:window.innerWidth-F.right})}},[m]);const _=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:_,disabled:u,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:u?t.jsx(He,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(ks,{size:16}):t.jsx(po,{size:16})}),a&&!u&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!a&&_s.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:h.top,right:h.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(po,{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(Zt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:u,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:[u&&t.jsx(He,{size:13,className:"animate-spin"}),e(u?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&_s.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:h.top,right:h.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(Ox(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Zt,{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(Bd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Kc,{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(Jt,{size:14,className:"text-emerald-500"}):t.jsx(fo,{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:Sa(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:Sa(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(Jt,{size:14,className:"text-emerald-500"}):t.jsx(fo,{size:14})})]})]}),y&&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")})]})]}),!y&&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(Es,{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 Gi({isOpen:e,onClose:s}){const{t:r}=ae(),o=qd(),[p,m]=b.useState(""),[v,n]=b.useState(""),[i,l]=b.useState(null),[h,c]=b.useState(!1),[g,x]=b.useState(!1),y=p.trim(),w=v.trim(),a=h||o.isPending,u=b.useMemo(()=>!!(y&&w&&!a),[y,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 _=>{try{await o.mutateAsync({name:y,repoPath:w,initEmptyRepo:_}),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,y,w]),C=b.useCallback(async()=>{if(!(!y||!w||a)){l(null),c(!0);try{const _=await Ee.get("/filesystem/validate",{params:{path:w}});if(!_.valid){l(_.error??r("Selected path is not a valid directory"));return}if(_.isGitRepo){await S(!1);return}if(_.reason==="no_git"&&_.isEmpty){x(!0);return}if(_.reason==="no_git"){await S(!1);return}await S(!1)}catch(_){l(_ instanceof Error?_.message:r("Could not check project path"))}finally{c(!1)}}},[S,a,r,y,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(ds,{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:!u,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${u?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:h?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:_=>m(_.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(Wd,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(ds,{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 Ca(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Fx(e){return e.map((s,r)=>({project:s,index:r,activityTime:Ca(s.lastActivityAt??s.createdAt),createdTime:Ca(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 ka({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ae(),[v,n]=b.useState(!1),i=e.filter(h=>!h.archivedAt),l=s?e.find(h=>h.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(h=>!h),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(zs,{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(zs,{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(Jt,{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(h=>{const c=s===h.id;return t.jsxs("button",{onClick:()=>{r(h.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 ${h.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:h.name}),c?t.jsx(Jt,{size:14,className:"text-foreground shrink-0"}):null]},h.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(ns,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function Ea(){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 zx=260,Wx=600,ja=400,Hx=100,$x=1e3;function Ux(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(ja),[i,l]=b.useState(!1),[h,c]=b.useState("idle"),[g,x]=b.useState({}),y=b.useRef(!1),w=b.useRef(0),a=b.useRef(ja),u=b.useRef(null),d=bt(),{data:f,isLoading:S}=Us(),{data:C,isLoading:k}=Kd({limit:Hx}),E=b.useMemo(()=>C?.data??[],[C?.data]),_=p&&E.some(J=>J.id===p)?p:null,{data:j,isLoading:R}=Sd({..._?{projectId:_}:{},limit:$x}),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(de=>!J.has(de.id)))},[L,T]);const A=b.useMemo(()=>Fx(E),[E]),P=b.useMemo(()=>A.map(tx),[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((de,ge)=>{const Ce=de.availability.type!=="NOT_FOUND",Y=ge.availability.type!=="NOT_FOUND";if(Ce!==Y)return Ce?-1:1;const se=fe[de.provider.id]??0;return(fe[ge.provider.id]??0)-se})},[f]),$=b.useMemo(()=>F.map(J=>sx(J,E.find(fe=>fe.id===J.projectId))),[E,F]),K=b.useMemo(()=>{if(!q)return null;const J=F.find(de=>de.id===q);if(!J)return null;const fe=E.find(de=>de.id===J.projectId);if(!fe){const de=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:Jn(J.status),branch:de,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return rx(J,fe)},[q,F,E]),B=Ma(),z=wd(),U=Cd(),N=Cn(),W=b.useCallback(J=>{const fe=Ux(J);D(de=>de.some(ge=>ge.id===J.id)?de.map(ge=>ge.id===J.id?fe:ge):[fe,...de]),d.setQueryData(ce.tasks.detail(J.id),J),H(J.id),o(J.id)},[d]),X=b.useCallback((J,fe,de)=>{const ge=J.id,Ce=[J.title,J.description].filter(Boolean).join(`
|
|
85
|
+
`);c(""),Gs(),L.current&&(L.current.style.height="40px"),Ns.mutate({id:Ce,message:ue,providerId:Vt??void 0},{onSuccess:()=>Gt(),onSettled:()=>{Js.current=!1}})},[u,Ce,Ns,Gt,Qt,Ft,Qs,Gs,Vt]),Tr=b.useCallback(async()=>{Ce&&(await fs.mutateAsync(Ce),A.invalidateQueries({queryKey:["workspaces"]}))},[Ce,fs,A]),yi=b.useCallback(Z=>K.mutateAsync(Z),[K]),vs=b.useCallback(Z=>{f(Z),l("chat"),requestAnimationFrame(()=>{H()})},[H]),Si=b.useCallback(()=>{f(null)},[]),ts=b.useCallback(()=>{l("changes")},[]),er=be&&pe?t.jsx(Dc,{workspaceId:pe,branchName:ze,targetBranch:Ie,commitMessage:ut,changes:tt,gitStatus:$e,isGitStatusLoading:Oe,canRunGitOperations:oe,onOpenChanges:ts,onRefreshCommitMessage:fe,onConflict:J,className:"mb-2"}):null,Mr=b.useCallback(Z=>{const ue=Z.target.files;ue&&ue.length>0&&gs(Array.from(ue)),Z.target.value=""},[gs]),Dr=b.useCallback(Z=>{const ue=Z.clipboardData.items,Ue=[];for(const De of ue)if(De.kind==="file"){const St=De.getAsFile();St&&Ue.push(St)}Ue.length>0&&(Z.preventDefault(),gs(Ue))},[gs]),Pr=b.useCallback(Z=>{c(Z.target.value);const ue=Z.target;ue.style.height="auto",ue.style.height=`${Math.max(40,Math.min(ue.scrollHeight,140))}px`},[]),xs=b.useCallback(()=>{js&&Xs.mutate({workspaceId:js})},[Xs,js]),bs=b.useRef(null);return b.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let ue=!1;const Ue=()=>{bs.current&&(bs.current.style.height=`${Z.height}px`,bs.current.style.top=`${Z.offsetTop}px`)},De=()=>Ue(),St=()=>{ue||Ue()},Pt=()=>{ue=!0},He=()=>{ue=!1,requestAnimationFrame(Ue)};return Z.addEventListener("resize",De),Z.addEventListener("scroll",St),document.addEventListener("touchstart",Pt,{passive:!0}),document.addEventListener("touchend",He,{passive:!0}),document.addEventListener("touchcancel",He,{passive:!0}),()=>{Z.removeEventListener("resize",De),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",Pt),document.removeEventListener("touchend",He),document.removeEventListener("touchcancel",He)}},[]),b.useEffect(()=>{const Z=bs.current;if(!Z)return;const ue=Ue=>{let De=Ue.target;for(;De&&De!==Z;){if(De.tagName==="TEXTAREA"){if(De.scrollHeight>De.clientHeight)return;De=De.parentElement;continue}const Pt=window.getComputedStyle(De).overflowY;if((Pt==="auto"||Pt==="scroll")&&De.scrollHeight>De.clientHeight)return;De=De.parentElement}Ue.preventDefault()};return Z.addEventListener("touchmove",ue,{passive:!1}),()=>Z.removeEventListener("touchmove",ue)},[]),t.jsxs("div",{ref:bs,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(Ws,{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:xs,disabled:!js||V,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(li,{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:ue,icon:Ue})=>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(Ue,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(ue)})]},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:Rr,compact:!0,providerIdFallback:ke?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{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:Si,children:[t.jsx(Ws,{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:Ys?t.jsx(Gi,{label:v("Loading logs...")}):ms.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(Ur,{logs:ms,downloadSessionId:je,isOutputActive:kr,lastExitAt:Er,onUserToggleDetails:q,onOpenPreviewUrl:Me,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(hr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ps.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(Kr,{todos:ps,compact:!0})})]}):t.jsx(Ll,{teamRun:B,messages:$??B.messages??[],readOnly:V,readOnlyMessage:ee,onSendMessage:yi,onViewInvocationSession:vs,changeSummaryBar:er,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 de(),x(!0)}:void 0})}):null,M?t.jsx(Gi,{label:"Loading..."}):Ce?Ys?t.jsx(Gi,{label:"Loading logs..."}):ms.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(Ur,{logs:ms,downloadSessionId:je,isOutputActive:kr,lastExitAt:Er,onUserToggleDetails:q,onOpenPreviewUrl:Me,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(Jt,{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(Te,{onClick:async()=>{await de(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Jt,{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(hr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ps.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(Kr,{todos:ps,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(Te,{size:"sm",onClick:async()=>{await de(),x(!0)},children:[t.jsx(Jt,{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:[er,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:jr,onRemove:Nr}),t.jsx("textarea",{ref:L,value:u,onChange:Pr,onPaste:Dr,onKeyDown:Z=>{Yt.handleKeyDown(Z)||Xt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Ar())},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:Mr}),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:Vt,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Et}),t.jsx(En,{usage:Rr}),rt&&!u.trim()&&!Qt?t.jsx("button",{onClick:Tr,disabled:fs.isPending||qt,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Fs,{size:12})}):t.jsx("button",{onClick:Ar,disabled:!u.trim()&&!Qt||Ft,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Qt)&&!Ft?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Cn,{size:15})})]})]})]}),t.jsx(qr,{open:Xt.query!==null,anchorRef:j,commands:Xt.filteredCommands,selectedIndex:Xt.selectedIndex,query:Xt.query??"",hasCatalog:Xt.allCommands.length>0,compact:!0,onSelect:Xt.applyCommand}),t.jsx(qr,{open:Yt.query!==null,anchorRef:j,commands:Yt.filteredSkills,selectedIndex:Yt.selectedIndex,query:Yt.query??"",hasCatalog:Yt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Yt.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:vs})}),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:ze,targetBranch:Ie,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(ue=>ue?.id===Z?void 0:ue)}})}),!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&&We&&t.jsx(Mc,{open:Ze,onOpenChange:Z=>{Xe(Z),Z||Ae(null)},workspaceId:We,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:pt,targetBranch:Je,operation:$e?.operation,worktreePath:_e,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Dt,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,ii=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(ii)for(var r of ii(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&&ii)for(var o of ii(e))s.indexOf(o)<0&&Bc.call(e,o)&&(r[o]=e[o]);return r};var ws;(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})(ws||(ws={}));(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={}))})(ws||(ws={}));(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={}))})(ws||(ws={}));var Os=ws;var Nx={L:Os.QrCode.Ecc.LOW,M:Os.QrCode.Ecc.MEDIUM,Q:Os.QrCode.Ecc.QUARTILE,H:Os.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(...Os.QrSegment.makeSegments(a)),w),[]);return Os.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 kt({queryKey:ce.tunnel.status,queryFn:()=>Ee.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Ox(){const e=bt();return Bt({mutationFn:()=>Ee.post("/tunnel/start",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Bx(){const e=bt();return Bt({mutationFn:()=>Ee.post("/tunnel/regenerate",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Fx(){const e=bt();return Bt({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 ir(e){const s=e?.trim();return s||null}function $x(e){if(!e)return"";const s=[ir(e.lastLocalError),ir(e.lastRemoteError),ir(e.lastError)].filter(p=>p!==null),r=ir(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!ir(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(Fe,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(ks,{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&&_s.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($t,{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(Fe,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&_s.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($t,{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(Ut,{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(Ut,{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(Es,{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(ds,{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(ds,{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(zs,{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(zs,{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(Ut,{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(Ut,{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(ns,{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}=Us(),{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(de=>!J.has(de.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((de,ge)=>{const Ce=de.availability.type!=="NOT_FOUND",Y=ge.availability.type!=="NOT_FOUND";if(Ce!==Y)return Ce?-1:1;const se=fe[de.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(de=>de.id===q);if(!J)return null;const fe=E.find(de=>de.id===J.projectId);if(!fe){const de=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:de,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(de=>de.some(ge=>ge.id===J.id)?de.map(ge=>ge.id===J.id?fe:ge):[fe,...de]),d.setQueryData(ce.tasks.detail(J.id),J),H(J.id),o(J.id)},[d]),X=b.useCallback((J,fe,de)=>{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:de});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]:de,...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]:de,...ge}=fe;return ge}),D(fe=>fe.filter(de=>de.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:
|
|
88
|
+
`);x(Y=>({...Y,[ge]:{status:"creating-workspace"}})),(async()=>{try{const Y=await Ee.post(`/tasks/${ge}/workspaces`,{workspaceKind:de});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]:de,...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]:de,...ge}=fe;return ge}),D(fe=>fe.filter(de=>de.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=de=>{if(!_.current)return;const ge=de.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:de,projectId:ge,providerId:Ce,mode:Y,workspaceMode:se,teamRunMode:ne,teamTemplateId:ke,memberPresetIds:xe,attachmentLinks:je}=J,Pe=[de,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:Pe||void 0}),localStorage.setItem("lastSelectedProjectId",ge),Y==="SOLO"&&Ce){localStorage.setItem("lastSelectedProviderId",Ce);const Se=localStorage.getItem("providerUsageCount"),
|
|
90
|
+
`);let ye=null;try{if(c("creating-task"),ye=await Ee.post(`/projects/${ge}/tasks`,{title:fe,description:Pe||void 0}),localStorage.setItem("lastSelectedProjectId",ge),Y==="SOLO"&&Ce){localStorage.setItem("lastSelectedProviderId",Ce);const Se=localStorage.getItem("providerUsageCount"),Me=Se?JSON.parse(Se):{};Me[Ce]=(Me[Ce]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Me))}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]),ze=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]),Ie=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]),[$e,Oe]=b.useState(be);b.useEffect(()=>{Oe(be)},[be]);const tt=b.useMemo(()=>M.find(J=>J.id===$e)?.name??M.find(J=>J.id===be)?.name??e("Project"),[M,$e,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(de=>de.provider.id===J&&de.availability.type!=="NOT_FOUND")?J:O.find(de=>de.availability.type!=="NOT_FOUND")?.provider.id??""},[O]),Xe=El(),[Ne,Ae]=b.useState(!1),{usesIntegratedTitlebar:ve,desktopPlatform:We,hasMacTrafficLights:_e}=Ra(),pt=ve&&We==="win32",Je=b.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}Ae(!0)},[M,e]),Dt=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:Ie,isProvidersLoading:S,onSubmit:Dt,defaultProjectId:be,defaultProviderId:Ze,onProjectChange:Oe,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})})]})]}),ze&&$.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:[ze&&$.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:Ie,isProvidersLoading:S,onSubmit:oe,defaultProjectId:be,defaultProviderId:Ze,onProjectChange:Oe,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};
|