agent-tower 0.5.2-beta.2 → 0.5.2-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +22 -2
  3. package/dist/app.js.map +1 -1
  4. package/dist/app.test.js +67 -0
  5. package/dist/app.test.js.map +1 -1
  6. package/dist/cli.js +2 -0
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/container.d.ts +2 -0
  9. package/dist/core/container.d.ts.map +1 -1
  10. package/dist/core/container.js +9 -1
  11. package/dist/core/container.js.map +1 -1
  12. package/dist/core/event-bus.d.ts +2 -1
  13. package/dist/core/event-bus.d.ts.map +1 -1
  14. package/dist/core/event-bus.js.map +1 -1
  15. package/dist/executors/__tests__/base.executor.test.d.ts +2 -0
  16. package/dist/executors/__tests__/base.executor.test.d.ts.map +1 -0
  17. package/dist/executors/__tests__/base.executor.test.js +264 -0
  18. package/dist/executors/__tests__/base.executor.test.js.map +1 -0
  19. package/dist/executors/__tests__/codex.executor.test.js +18 -1
  20. package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
  21. package/dist/executors/base.executor.d.ts.map +1 -1
  22. package/dist/executors/base.executor.js +61 -33
  23. package/dist/executors/base.executor.js.map +1 -1
  24. package/dist/executors/codex.executor.d.ts.map +1 -1
  25. package/dist/executors/codex.executor.js +3 -4
  26. package/dist/executors/codex.executor.js.map +1 -1
  27. package/dist/executors/execution-env.d.ts +7 -1
  28. package/dist/executors/execution-env.d.ts.map +1 -1
  29. package/dist/executors/execution-env.js +41 -2
  30. package/dist/executors/execution-env.js.map +1 -1
  31. package/dist/git/git-cli.d.ts +5 -3
  32. package/dist/git/git-cli.d.ts.map +1 -1
  33. package/dist/git/git-cli.js +3 -1
  34. package/dist/git/git-cli.js.map +1 -1
  35. package/dist/git/worktree.manager.js +1 -1
  36. package/dist/git/worktree.manager.js.map +1 -1
  37. package/dist/git/worktree.manager.test.js +69 -0
  38. package/dist/git/worktree.manager.test.js.map +1 -1
  39. package/dist/index.js +2 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/mcp/http-client.d.ts +1 -0
  42. package/dist/mcp/http-client.d.ts.map +1 -1
  43. package/dist/mcp/http-client.js +3 -0
  44. package/dist/mcp/http-client.js.map +1 -1
  45. package/dist/mcp/server.d.ts.map +1 -1
  46. package/dist/mcp/server.js +27 -2
  47. package/dist/mcp/server.js.map +1 -1
  48. package/dist/mcp/types.d.ts +6 -6
  49. package/dist/routes/__tests__/tasks.test.js +179 -0
  50. package/dist/routes/__tests__/tasks.test.js.map +1 -1
  51. package/dist/routes/git.d.ts.map +1 -1
  52. package/dist/routes/git.js +41 -1
  53. package/dist/routes/git.js.map +1 -1
  54. package/dist/routes/tasks.d.ts.map +1 -1
  55. package/dist/routes/tasks.js +10 -2
  56. package/dist/routes/tasks.js.map +1 -1
  57. package/dist/routes/team-runs.d.ts.map +1 -1
  58. package/dist/routes/team-runs.js +9 -0
  59. package/dist/routes/team-runs.js.map +1 -1
  60. package/dist/services/__tests__/project.service.test.js +85 -1
  61. package/dist/services/__tests__/project.service.test.js.map +1 -1
  62. package/dist/services/__tests__/session-manager.team-run.test.js +84 -1
  63. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
  64. package/dist/services/__tests__/task.service.test.js +190 -0
  65. package/dist/services/__tests__/task.service.test.js.map +1 -1
  66. package/dist/services/__tests__/team-reconciler.service.test.js +122 -2
  67. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
  68. package/dist/services/__tests__/team-run.service.test.js +105 -1
  69. package/dist/services/__tests__/team-run.service.test.js.map +1 -1
  70. package/dist/services/__tests__/team-scheduler.service.test.js +46 -5
  71. package/dist/services/__tests__/team-scheduler.service.test.js.map +1 -1
  72. package/dist/services/__tests__/workspace-git-watcher.service.test.d.ts +2 -0
  73. package/dist/services/__tests__/workspace-git-watcher.service.test.d.ts.map +1 -0
  74. package/dist/services/__tests__/workspace-git-watcher.service.test.js +287 -0
  75. package/dist/services/__tests__/workspace-git-watcher.service.test.js.map +1 -0
  76. package/dist/services/__tests__/workspace.service.test.js +43 -1
  77. package/dist/services/__tests__/workspace.service.test.js.map +1 -1
  78. package/dist/services/project.service.d.ts +28 -24
  79. package/dist/services/project.service.d.ts.map +1 -1
  80. package/dist/services/project.service.js +11 -0
  81. package/dist/services/project.service.js.map +1 -1
  82. package/dist/services/session-manager.d.ts +44 -43
  83. package/dist/services/session-manager.d.ts.map +1 -1
  84. package/dist/services/session-manager.js +19 -3
  85. package/dist/services/session-manager.js.map +1 -1
  86. package/dist/services/task-cleanup.service.d.ts +3 -1
  87. package/dist/services/task-cleanup.service.d.ts.map +1 -1
  88. package/dist/services/task-cleanup.service.js +6 -1
  89. package/dist/services/task-cleanup.service.js.map +1 -1
  90. package/dist/services/task.service.d.ts +96 -65
  91. package/dist/services/task.service.d.ts.map +1 -1
  92. package/dist/services/task.service.js +208 -15
  93. package/dist/services/task.service.js.map +1 -1
  94. package/dist/services/team-run.service.d.ts +3 -0
  95. package/dist/services/team-run.service.d.ts.map +1 -1
  96. package/dist/services/team-run.service.js +77 -16
  97. package/dist/services/team-run.service.js.map +1 -1
  98. package/dist/services/team-scheduler.service.d.ts.map +1 -1
  99. package/dist/services/team-scheduler.service.js +16 -4
  100. package/dist/services/team-scheduler.service.js.map +1 -1
  101. package/dist/services/workspace-git-watcher.service.d.ts +67 -0
  102. package/dist/services/workspace-git-watcher.service.d.ts.map +1 -0
  103. package/dist/services/workspace-git-watcher.service.js +413 -0
  104. package/dist/services/workspace-git-watcher.service.js.map +1 -0
  105. package/dist/services/workspace.service.d.ts +99 -108
  106. package/dist/services/workspace.service.d.ts.map +1 -1
  107. package/dist/services/workspace.service.js +43 -6
  108. package/dist/services/workspace.service.js.map +1 -1
  109. package/dist/socket/events.d.ts +1 -1
  110. package/dist/socket/events.d.ts.map +1 -1
  111. package/dist/socket/events.js.map +1 -1
  112. package/dist/socket/index.d.ts.map +1 -1
  113. package/dist/socket/index.js +12 -0
  114. package/dist/socket/index.js.map +1 -1
  115. package/dist/socket/socket-gateway.d.ts.map +1 -1
  116. package/dist/socket/socket-gateway.js +5 -1
  117. package/dist/socket/socket-gateway.js.map +1 -1
  118. package/dist/web/assets/AgentDemoPage-BIMA7LtG.js +1 -0
  119. package/dist/web/assets/{DemoPage-PD8AX5pI.js → DemoPage-Ck0jATn9.js} +3 -3
  120. package/dist/web/assets/GeneralSettingsPage-C5KUTpFg.js +1 -0
  121. package/dist/web/assets/{MemberAvatar-BDXmryjB.js → MemberAvatar-CKkPlE4w.js} +1 -1
  122. package/dist/web/assets/NotificationSettingsPage-Dl2nJ6Kj.js +1 -0
  123. package/dist/web/assets/ProfileSettingsPage-D_YQBJqm.js +3 -0
  124. package/dist/web/assets/ProjectKanbanPage-D2_609qP.js +89 -0
  125. package/dist/web/assets/ProjectSettingsPage-DpewUnnG.js +2 -0
  126. package/dist/web/assets/ProviderSettingsPage-BbruFhJJ.js +54 -0
  127. package/dist/web/assets/SettingsMasterDetail-zGxTmEVL.js +1 -0
  128. package/dist/web/assets/TeamSettingsPage-B3dBegBu.js +1 -0
  129. package/dist/web/assets/arrow-left-DTTqavaj.js +1 -0
  130. package/dist/web/assets/check-N8co_7vS.js +1 -0
  131. package/dist/web/assets/chevron-down-CXD7aP1s.js +1 -0
  132. package/dist/web/assets/chevron-right-DSp9sZpx.js +1 -0
  133. package/dist/web/assets/{chevron-up-BEHjZ-SB.js → chevron-up-DAXQrjEz.js} +1 -1
  134. package/dist/web/assets/{code-block-OCS4YCEC-6FHTyCN2.js → code-block-OCS4YCEC-Cwwrn6vr.js} +1 -1
  135. package/dist/web/assets/{confirm-dialog-B_wk_zqm.js → confirm-dialog-DnHo_qsz.js} +1 -1
  136. package/dist/web/assets/folder-picker-TUuS8jPV.js +1 -0
  137. package/dist/web/assets/index-JZcaQb4r.css +1 -0
  138. package/dist/web/assets/index-X6FFd4Oy.js +13 -0
  139. package/dist/web/assets/input-CWSScfQB.js +1 -0
  140. package/dist/web/assets/layers-DMovMRW4.js +1 -0
  141. package/dist/web/assets/loader-circle-CvnvXNY6.js +1 -0
  142. package/dist/web/assets/{mermaid-NOHMQCX5-fubZbKyF.js → mermaid-NOHMQCX5-CmO9pIR-.js} +4 -4
  143. package/dist/web/assets/message-square-tazyMedo.js +1 -0
  144. package/dist/web/assets/modal-D9LZcnXe.js +1 -0
  145. package/dist/web/assets/{pencil-uRBgB4qA.js → pencil-Cfcl8xtO.js} +1 -1
  146. package/dist/web/assets/rotate-ccw-BCxAIasK.js +1 -0
  147. package/dist/web/assets/{select-BMlH2AuL.js → select-wCJbdjbF.js} +1 -1
  148. package/dist/web/assets/switch-BpVaaZIq.js +1 -0
  149. package/dist/web/assets/textarea-CqAqQ-DJ.js +1 -0
  150. package/dist/web/assets/{upload-B-Mpvu9j.js → upload-Doc6mqhw.js} +1 -1
  151. package/dist/web/assets/{use-profiles-D6cZwU1R.js → use-profiles-CLbwBXdL.js} +1 -1
  152. package/dist/web/assets/{use-providers-DVP6emIi.js → use-providers-C8Rfahov.js} +1 -1
  153. package/dist/web/favicon.ico +0 -0
  154. package/dist/web/index.html +4 -4
  155. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +10 -0
  156. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
  157. package/node_modules/@agent-tower/shared/dist/socket/events.js +1 -0
  158. package/node_modules/@agent-tower/shared/dist/socket/events.js.map +1 -1
  159. package/node_modules/@agent-tower/shared/dist/types.d.ts +21 -0
  160. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  161. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  162. package/node_modules/@prisma/client/.prisma/client/edge.js +2 -2
  163. package/node_modules/@prisma/client/.prisma/client/index.js +2 -2
  164. package/package.json +1 -1
  165. package/dist/web/assets/AgentDemoPage-Co63rtls.js +0 -1
  166. package/dist/web/assets/GeneralSettingsPage-C5eiEeTZ.js +0 -1
  167. package/dist/web/assets/NotificationSettingsPage-BjjPan2M.js +0 -1
  168. package/dist/web/assets/ProfileSettingsPage-BRpeNq6u.js +0 -3
  169. package/dist/web/assets/ProjectKanbanPage-DUUu2EYy.js +0 -89
  170. package/dist/web/assets/ProjectSettingsPage-avctMKfk.js +0 -2
  171. package/dist/web/assets/ProviderSettingsPage-BIUYN2e0.js +0 -54
  172. package/dist/web/assets/SettingsSection-pLJ3msrT.js +0 -1
  173. package/dist/web/assets/TeamSettingsPage-BjKW9nT8.js +0 -1
  174. package/dist/web/assets/arrow-left-lFz8nyZM.js +0 -1
  175. package/dist/web/assets/button-BUA8P726.js +0 -1
  176. package/dist/web/assets/check-BYuuXc71.js +0 -1
  177. package/dist/web/assets/chevron-down-B931AgE2.js +0 -1
  178. package/dist/web/assets/chevron-right-F9i4wey6.js +0 -1
  179. package/dist/web/assets/circle-check-C7xXtl8B.js +0 -1
  180. package/dist/web/assets/folder-picker-BEHS3b2Q.js +0 -1
  181. package/dist/web/assets/index-DEQhT5sD.css +0 -1
  182. package/dist/web/assets/index-RxbHMWXV.js +0 -13
  183. package/dist/web/assets/loader-circle-stJcjnm-.js +0 -1
  184. package/dist/web/assets/message-square-C8lb-TDo.js +0 -1
  185. package/dist/web/assets/modal-UGrjU63G.js +0 -1
  186. package/dist/web/assets/rotate-ccw-CWaMrTz4.js +0 -1
@@ -1,89 +0,0 @@
1
- import{Q as Ii,G as jn,H as dc,I as uc,J as hc,K as Ci,M as fc,N as mc,g as tt,O as pc,P as gc,r as C,R as vc,T as xc,U as _c,V as bc,W as Nn,Y as Rn,Z as yc,_ as Sc,$ as wc,e as ge,a0 as oe,A as Qt,f as wt,h as pt,i as Se,q as de,u as ce,j as t,X as Ft,d as J,a1 as Go,a2 as Qo,a3 as Zo,a4 as ss,k as Jo,a5 as Cc,a6 as kc,a7 as Ec,t as at,w as Gt,S as nt,C as ps,a8 as ea,E as Zt,a9 as ki,l as jc,L as An,aa as ta,ab as Mn,ac as Bi,ad as sa,ae as ra,af as Nc,ag as Rc,ah as Ac,ai as Mc,aj as Tc,x as Tn,ak as Dn}from"./index-RxbHMWXV.js";import{S as Ze,W as it,a as jt,C as Bs,A as It,T as Ot}from"./log-adapter-CtvxzS4j.js";import{f as Fi,b as zi,d as Hi,c as Wi,h as $i,S as bs,A as Ln,P as jr,Q as Ui,s as qi,G as ia,u as na,a as oa,e as ur,T as hr}from"./mermaid-NOHMQCX5-fubZbKyF.js";import{C as Nr}from"./confirm-dialog-B_wk_zqm.js";import{C as dt}from"./chevron-down-B931AgE2.js";import{C as zt}from"./chevron-right-F9i4wey6.js";import{C as ft}from"./check-BYuuXc71.js";import{P as Bt,M as ws,a as Rr,T as Ki}from"./modal-UGrjU63G.js";import{B as Pe}from"./button-BUA8P726.js";import{L as Ke}from"./loader-circle-stJcjnm-.js";import{M as Rt}from"./MemberAvatar-BDXmryjB.js";import{C as aa}from"./chevron-up-BEHjZ-SB.js";import{S as os}from"./select-BMlH2AuL.js";import{u as Cs}from"./use-providers-DVP6emIi.js";import{M as Xi}from"./message-square-C8lb-TDo.js";import{a as Dc,F as Lc,f as Pc,g as Oc,e as Ic,u as Bc}from"./folder-picker-BEHS3b2Q.js";import{C as Fc,U as ri}from"./upload-B-Mpvu9j.js";import{R as zc}from"./rotate-ccw-CWaMrTz4.js";import{A as Ei}from"./arrow-left-lFz8nyZM.js";var Hc=class extends Ii{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:jn()})}getOptimisticResult(e){return e.behavior=jn(),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:m,isRefetching:p,isError:x,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,c=x&&i==="forward",f=m&&i==="forward",l=x&&i==="backward",g=m&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:uc(s,r.data),hasPreviousPage:dc(s,r.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:l,isFetchingPreviousPage:g,isRefetchError:n&&!c&&!l,isRefetching:p&&!f&&!g}}};function Pn(e,s){const r=new Set(s);return e.filter(o=>!r.has(o))}function Wc(e,s,r){const o=e.slice(0);return o[s]=r,o}var $c=class extends hc{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#f(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#i=e,this.#n=s,Ci.batch(()=>{const r=this.#t,o=this.#h(this.#i);o.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=o.map(f=>f.observer),p=m.map(f=>f.getCurrentResult()),x=r.length!==m.length,n=m.some((f,l)=>f!==r[l]),i=x||n,c=i?!0:p.some((f,l)=>{const g=this.#e[l];return!g||!fc(f,g)});!i&&!c||(i&&(this.#c=o,this.#t=m),this.#e=p,this.hasListeners()&&(i&&(Pn(r,m).forEach(f=>{f.destroy()}),Pn(m,r).forEach(f=>{f.subscribe(l=>{this.#f(f,l)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#h(e),o=r.map(p=>p.observer.getOptimisticResult(p.defaultedQueryOptions)),m=r.map(p=>p.defaultedQueryOptions.queryHash);return[o,p=>this.#u(p??o,s,m),()=>this.#d(o,r)]}#d(e,s){return s.map((r,o)=>{const m=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?m:r.observer.trackResult(m,p=>{s.forEach(x=>{x.observer.trackProp(p)})})})}#u(e,s,r){if(s){const o=this.#l,m=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((p,x)=>p!==o[x]));return(!this.#s||this.#e!==this.#a||m||s!==this.#o)&&(this.#o=s,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=mc(this.#s,s(e))),this.#s}return e}#h(e){const s=new Map;this.#t.forEach(o=>{const m=o.options.queryHash;if(!m)return;const p=s.get(m);p?p.push(o):s.set(m,[o])});const r=[];return e.forEach(o=>{const m=this.#r.defaultQueryOptions(o),x=s.get(m.queryHash)?.shift()??new Ii(this.#r,m);r.push({defaultedQueryOptions:m,observer:x})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=Wc(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#d(this.#e,this.#c),r=this.#u(s,this.#n?.combine);e!==r&&Ci.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function Uc({queries:e,...s},r){const o=tt(),m=pc(),p=gc(),x=C.useMemo(()=>e.map(v=>{const a=o.defaultQueryOptions(v);return a._optimisticResults=m?"isRestoring":"optimistic",a}),[e,o,m]);x.forEach(v=>{vc(v);const a=o.getQueryCache().get(v.queryHash);xc(v,p,a)}),_c(p);const[n]=C.useState(()=>new $c(o,x,s)),[i,c,f]=n.getOptimisticResult(x,s.combine),l=!m&&s.subscribed!==!1;C.useSyncExternalStore(C.useCallback(v=>l?n.subscribe(Ci.batchCalls(v)):bc,[n,l]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),C.useEffect(()=>{n.setQueries(x,s)},[x,s,n]);const _=i.some((v,a)=>Nn(x[a],v))?i.flatMap((v,a)=>{const h=x[a];if(h){const d=new Ii(o,h);if(Nn(h,v))return Rn(h,d,p);yc(v,m)&&Rn(h,d,p)}return[]}):[];if(_.length>0)throw Promise.all(_);const w=i.find((v,a)=>{const h=x[a];return h&&Sc({result:v,errorResetBoundary:p,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(w?.error)throw w.error;return c(f())}function la(e,s){return wc(e,Hc)}const qc=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Fs=ge("arrow-down",qc);const Kc=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Xc=ge("arrow-right",Kc);const Yc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ar=ge("arrow-up",Yc);const Vc=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ca=ge("ban",Vc);const Gc=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Qc=ge("bot",Gc);const Zc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jc=ge("chevron-left",Zc);const ed=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],gs=ge("clock-3",ed);const td=[["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"}]],Ks=ge("code-xml",td);const sd=[["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"}]],On=ge("copy-plus",sd);const rd=[["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"}]],In=ge("copy",rd);const id=[["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"}]],da=ge("ellipsis-vertical",id);const nd=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Yi=ge("external-link",nd);const od=[["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"}]],ad=ge("file-braces-corner",od);const ld=[["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"}]],zs=ge("file-code-corner",ld);const cd=[["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"}]],dd=ge("file-exclamation-point",cd);const ud=[["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:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Vi=ge("file-text",ud);const hd=[["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"}]],Mr=ge("folder-open",hd);const fd=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],md=ge("gauge",fd);const pd=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Gi=ge("git-branch",pd);const gd=[["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"}]],ys=ge("git-graph",gd);const vd=[["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"}]],Ss=ge("history",vd);const xd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Qi=ge("image",xd);const _d=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],bd=ge("info",_d);const yd=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Hs=ge("layers",yd);const Sd=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],wd=ge("lock-keyhole",Sd);const Cd=[["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"}]],kd=ge("maximize",Cd);const Ed=[["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"}]],jd=ge("panel-left-close",Ed);const Nd=[["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"}]],Rd=ge("panel-left-open",Nd);const Ad=[["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"}]],Md=ge("panel-right-close",Ad);const Td=[["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"}]],fr=ge("panel-right-open",Td);const Dd=[["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"}]],Ld=ge("pen-line",Dd);const Pd=[["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"}]],as=ge("play",Pd);const Od=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Tr=ge("refresh-cw",Od);const Id=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Bd=ge("save",Id);const Fd=[["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"}]],ua=ge("settings-2",Fd);const zd=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ha=ge("shield",zd);const Hd=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Bn=ge("smartphone",Hd);const Wd=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],mr=ge("terminal",Wd);const $d=[["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"}]],rr=ge("user-plus",$d);const Ud=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],fa=ge("zap",Ud);const qd=[["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"}]],Kd=ge("zoom-in",qd);const Xd=[["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"}]],Yd=ge("zoom-out",Xd),Dr=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 Zi(e){return"nodeType"in e}function mt(e){var s,r;return e?ks(e)?e:Zi(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Ji(e){const{Document:s}=mt(e);return e instanceof s}function Xs(e){return ks(e)?!1:e instanceof mt(e).HTMLElement}function ma(e){return e instanceof mt(e).SVGElement}function Es(e){return e?ks(e)?e.document:Zi(e)?Ji(e)?e:Xs(e)||ma(e)?e.ownerDocument:document:document:document}const $t=Dr?C.useLayoutEffect:C.useEffect;function Lr(e){const s=C.useRef(e);return $t(()=>{s.current=e}),C.useCallback(function(){for(var r=arguments.length,o=new Array(r),m=0;m<r;m++)o[m]=arguments[m];return s.current==null?void 0:s.current(...o)},[])}function Vd(){const e=C.useRef(null),s=C.useCallback((o,m)=>{e.current=setInterval(o,m)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Ws(e,s){s===void 0&&(s=[e]);const r=C.useRef(e);return $t(()=>{r.current!==e&&(r.current=e)},s),r}function Ys(e,s){const r=C.useRef();return C.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function pr(e){const s=Lr(e),r=C.useRef(null),o=C.useCallback(m=>{m!==r.current&&s?.(m,r.current),r.current=m},[]);return[r,o]}function gr(e){const s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}let ii={};function Pr(e,s){return C.useMemo(()=>{if(s)return s;const r=ii[e]==null?0:ii[e]+1;return ii[e]=r,e+"-"+r},[e,s])}function pa(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),m=1;m<r;m++)o[m-1]=arguments[m];return o.reduce((p,x)=>{const n=Object.entries(x);for(const[i,c]of n){const f=p[i];f!=null&&(p[i]=f+e*c)}return p},{...s})}}const _s=pa(1),vr=pa(-1);function Gd(e){return"clientX"in e&&"clientY"in e}function en(e){if(!e)return!1;const{KeyboardEvent:s}=mt(e.target);return s&&e instanceof s}function Qd(e){if(!e)return!1;const{TouchEvent:s}=mt(e.target);return s&&e instanceof s}function xr(e){if(Qd(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 Gd(e)?{x:e.clientX,y:e.clientY}:null}const $s=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[$s.Translate.toString(e),$s.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),Fn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Zd(e){return e.matches(Fn)?e:e.querySelector(Fn)}const Jd={display:"none"};function eu(e){let{id:s,value:r}=e;return oe.createElement("div",{id:s,style:Jd},r)}function tu(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const m={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 oe.createElement("div",{id:s,style:m,role:"status","aria-live":o,"aria-atomic":!0},r)}function su(){const[e,s]=C.useState("");return{announce:C.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const ga=C.createContext(null);function ru(e){const s=C.useContext(ga);C.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function iu(){const[e]=C.useState(()=>new Set),s=C.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[C.useCallback(o=>{let{type:m,event:p}=o;e.forEach(x=>{var n;return(n=x[m])==null?void 0:n.call(x,p)})},[e]),s]}const nu={draggable:`
2
- To pick up a draggable item, press the space bar.
3
- While dragging, use the arrow keys to move the item.
4
- Press space again to drop the item in its new position, or press escape to cancel.
5
- `},ou={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 au(e){let{announcements:s=ou,container:r,hiddenTextDescribedById:o,screenReaderInstructions:m=nu}=e;const{announce:p,announcement:x}=su(),n=Pr("DndLiveRegion"),[i,c]=C.useState(!1);if(C.useEffect(()=>{c(!0)},[]),ru(C.useMemo(()=>({onDragStart(l){let{active:g}=l;p(s.onDragStart({active:g}))},onDragMove(l){let{active:g,over:_}=l;s.onDragMove&&p(s.onDragMove({active:g,over:_}))},onDragOver(l){let{active:g,over:_}=l;p(s.onDragOver({active:g,over:_}))},onDragEnd(l){let{active:g,over:_}=l;p(s.onDragEnd({active:g,over:_}))},onDragCancel(l){let{active:g,over:_}=l;p(s.onDragCancel({active:g,over:_}))}}),[p,s])),!i)return null;const f=oe.createElement(oe.Fragment,null,oe.createElement(eu,{id:o,value:m.draggable}),oe.createElement(tu,{id:n,announcement:x}));return r?Qt.createPortal(f,r):f}var et;(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"})(et||(et={}));function _r(){}function lu(e,s){return C.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function cu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return C.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Dt=Object.freeze({x:0,y:0});function du(e,s){const r=xr(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 uu(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function hu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function fu(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),m=Math.min(s.left+s.width,e.left+e.width),p=Math.min(s.top+s.height,e.top+e.height),x=m-o,n=p-r;if(o<m&&r<p){const i=s.width*s.height,c=e.width*e.height,f=x*n,l=f/(i+c-f);return Number(l.toFixed(4))}return 0}const mu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const m=[];for(const p of o){const{id:x}=p,n=r.get(x);if(n){const i=fu(n,s);i>0&&m.push({id:x,data:{droppableContainer:p,value:i}})}}return m.sort(uu)};function pu(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function va(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Dt}function gu(e){return function(r){for(var o=arguments.length,m=new Array(o>1?o-1:0),p=1;p<o;p++)m[p-1]=arguments[p];return m.reduce((x,n)=>({...x,top:x.top+e*n.y,bottom:x.bottom+e*n.y,left:x.left+e*n.x,right:x.right+e*n.x}),{...r})}}const vu=gu(1);function xa(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 xu(e,s,r){const o=xa(s);if(!o)return e;const{scaleX:m,scaleY:p,x,y:n}=o,i=e.left-x-(1-m)*parseFloat(r),c=e.top-n-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),f=m?e.width/m:e.width,l=p?e.height/p:e.height;return{width:f,height:l,top:c,right:i+f,bottom:c+l,left:i}}const _u={ignoreTransform:!1};function Vs(e,s){s===void 0&&(s=_u);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:c,transformOrigin:f}=mt(e).getComputedStyle(e);c&&(r=xu(r,c,f))}const{top:o,left:m,width:p,height:x,bottom:n,right:i}=r;return{top:o,left:m,width:p,height:x,bottom:n,right:i}}function zn(e){return Vs(e,{ignoreTransform:!0})}function bu(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function yu(e,s){return s===void 0&&(s=mt(e).getComputedStyle(e)),s.position==="fixed"}function Su(e,s){s===void 0&&(s=mt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const p=s[m];return typeof p=="string"?r.test(p):!1})}function tn(e,s){const r=[];function o(m){if(s!=null&&r.length>=s||!m)return r;if(Ji(m)&&m.scrollingElement!=null&&!r.includes(m.scrollingElement))return r.push(m.scrollingElement),r;if(!Xs(m)||ma(m)||r.includes(m))return r;const p=mt(e).getComputedStyle(m);return m!==e&&Su(m,p)&&r.push(m),yu(m,p)?r:o(m.parentNode)}return e?o(e):r}function _a(e){const[s]=tn(e,1);return s??null}function ni(e){return!Dr||!e?null:ks(e)?e:Zi(e)?Ji(e)||e===Es(e).scrollingElement?window:Xs(e)?e:null:null}function ba(e){return ks(e)?e.scrollX:e.scrollLeft}function ya(e){return ks(e)?e.scrollY:e.scrollTop}function ji(e){return{x:ba(e),y:ya(e)}}var ot;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ot||(ot={}));function Sa(e){return!Dr||!e?!1:e===document.scrollingElement}function wa(e){const s={x:0,y:0},r=Sa(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},m=e.scrollTop<=s.y,p=e.scrollLeft<=s.x,x=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:m,isLeft:p,isBottom:x,isRight:n,maxScroll:o,minScroll:s}}const wu={x:.2,y:.2};function Cu(e,s,r,o,m){let{top:p,left:x,right:n,bottom:i}=r;o===void 0&&(o=10),m===void 0&&(m=wu);const{isTop:c,isBottom:f,isLeft:l,isRight:g}=wa(e),_={x:0,y:0},w={x:0,y:0},v={height:s.height*m.y,width:s.width*m.x};return!c&&p<=s.top+v.height?(_.y=ot.Backward,w.y=o*Math.abs((s.top+v.height-p)/v.height)):!f&&i>=s.bottom-v.height&&(_.y=ot.Forward,w.y=o*Math.abs((s.bottom-v.height-i)/v.height)),!g&&n>=s.right-v.width?(_.x=ot.Forward,w.x=o*Math.abs((s.right-v.width-n)/v.width)):!l&&x<=s.left+v.width&&(_.x=ot.Backward,w.x=o*Math.abs((s.left+v.width-x)/v.width)),{direction:_,speed:w}}function ku(e){if(e===document.scrollingElement){const{innerWidth:p,innerHeight:x}=window;return{top:0,left:0,right:p,bottom:x,width:p,height:x}}const{top:s,left:r,right:o,bottom:m}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:m,width:e.clientWidth,height:e.clientHeight}}function Ca(e){return e.reduce((s,r)=>_s(s,ji(r)),Dt)}function Eu(e){return e.reduce((s,r)=>s+ba(r),0)}function ju(e){return e.reduce((s,r)=>s+ya(r),0)}function ka(e,s){if(s===void 0&&(s=Vs),!e)return;const{top:r,left:o,bottom:m,right:p}=s(e);_a(e)&&(m<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Nu=[["x",["left","right"],Eu],["y",["top","bottom"],ju]];class sn{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=tn(r),m=Ca(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[p,x,n]of Nu)for(const i of x)Object.defineProperty(this,i,{get:()=>{const c=n(o),f=m[p]-c;return this.rect[i]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ls{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 m;(m=this.target)==null||m.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Ru(e){const{EventTarget:s}=mt(e);return e instanceof s?e:Es(e)}function oi(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 Et;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Et||(Et={}));function Hn(e){e.preventDefault()}function Au(e){e.stopPropagation()}var Ue;(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"})(Ue||(Ue={}));const Ea={start:[Ue.Space,Ue.Enter],cancel:[Ue.Esc],end:[Ue.Space,Ue.Enter,Ue.Tab]},Mu=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ue.Right:return{...r,x:r.x+25};case Ue.Left:return{...r,x:r.x-25};case Ue.Down:return{...r,y:r.y+25};case Ue.Up:return{...r,y:r.y-25}}};class ja{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 Ls(Es(r)),this.windowListeners=new Ls(mt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Et.Resize,this.handleCancel),this.windowListeners.add(Et.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Et.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&ka(o),r(Dt)}handleKeyDown(s){if(en(s)){const{active:r,context:o,options:m}=this.props,{keyboardCodes:p=Ea,coordinateGetter:x=Mu,scrollBehavior:n="smooth"}=m,{code:i}=s;if(p.end.includes(i)){this.handleEnd(s);return}if(p.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:c}=o.current,f=c?{x:c.left,y:c.top}:Dt;this.referenceCoordinates||(this.referenceCoordinates=f);const l=x(s,{active:r,context:o.current,currentCoordinates:f});if(l){const g=vr(l,f),_={x:0,y:0},{scrollableAncestors:w}=o.current;for(const v of w){const a=s.code,{isTop:h,isRight:d,isLeft:u,isBottom:b,maxScroll:y,minScroll:k}=wa(v),E=ku(v),S={x:Math.min(a===Ue.Right?E.right-E.width/2:E.right,Math.max(a===Ue.Right?E.left:E.left+E.width/2,l.x)),y:Math.min(a===Ue.Down?E.bottom-E.height/2:E.bottom,Math.max(a===Ue.Down?E.top:E.top+E.height/2,l.y))},j=a===Ue.Right&&!d||a===Ue.Left&&!u,N=a===Ue.Down&&!b||a===Ue.Up&&!h;if(j&&S.x!==l.x){const T=v.scrollLeft+g.x,M=a===Ue.Right&&T<=y.x||a===Ue.Left&&T>=k.x;if(M&&!g.y){v.scrollTo({left:T,behavior:n});return}M?_.x=v.scrollLeft-T:_.x=a===Ue.Right?v.scrollLeft-y.x:v.scrollLeft-k.x,_.x&&v.scrollBy({left:-_.x,behavior:n});break}else if(N&&S.y!==l.y){const T=v.scrollTop+g.y,M=a===Ue.Down&&T<=y.y||a===Ue.Up&&T>=k.y;if(M&&!g.x){v.scrollTo({top:T,behavior:n});return}M?_.y=v.scrollTop-T:_.y=a===Ue.Down?v.scrollTop-y.y:v.scrollTop-k.y,_.y&&v.scrollBy({top:-_.y,behavior:n});break}}this.handleMove(s,_s(vr(l,this.referenceCoordinates),_))}}}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()}}ja.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Ea,onActivation:m}=s,{active:p}=r;const{code:x}=e.nativeEvent;if(o.start.includes(x)){const n=p.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function Wn(e){return!!(e&&"distance"in e)}function $n(e){return!!(e&&"delay"in e)}class rn{constructor(s,r,o){var m;o===void 0&&(o=Ru(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:p}=s,{target:x}=p;this.props=s,this.events=r,this.document=Es(x),this.documentListeners=new Ls(this.document),this.listeners=new Ls(o),this.windowListeners=new Ls(mt(x)),this.initialCoordinates=(m=xr(p))!=null?m:Dt,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(Et.Resize,this.handleCancel),this.windowListeners.add(Et.DragStart,Hn),this.windowListeners.add(Et.VisibilityChange,this.handleCancel),this.windowListeners.add(Et.ContextMenu,Hn),this.documentListeners.add(Et.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if($n(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Wn(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:m}=this.props;m(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Et.Click,Au,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Et.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:m,props:p}=this,{onMove:x,options:{activationConstraint:n}}=p;if(!m)return;const i=(r=xr(s))!=null?r:Dt,c=vr(m,i);if(!o&&n){if(Wn(n)){if(n.tolerance!=null&&oi(c,n.tolerance))return this.handleCancel();if(oi(c,n.distance))return this.handleStart()}if($n(n)&&oi(c,n.tolerance))return this.handleCancel();this.handlePending(n,c);return}s.cancelable&&s.preventDefault(),x(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===Ue.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const Tu={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class nn extends rn{constructor(s){const{event:r}=s,o=Es(r.target);super(s,Tu,o)}}nn.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 Du={move:{name:"mousemove"},end:{name:"mouseup"}};var Ni;(function(e){e[e.RightClick=2]="RightClick"})(Ni||(Ni={}));class Lu extends rn{constructor(s){super(s,Du,Es(s.event.target))}}Lu.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Ni.RightClick?!1:(o?.({event:r}),!0)}}];const ai={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Pu extends rn{constructor(s){super(s,ai)}static setup(){return window.addEventListener(ai.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(ai.move.name,s)};function s(){}}}Pu.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:m}=r;return m.length>1?!1:(o?.({event:r}),!0)}}];var Ps;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ps||(Ps={}));var br;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(br||(br={}));function Ou(e){let{acceleration:s,activator:r=Ps.Pointer,canScroll:o,draggingRect:m,enabled:p,interval:x=5,order:n=br.TreeOrder,pointerCoordinates:i,scrollableAncestors:c,scrollableAncestorRects:f,delta:l,threshold:g}=e;const _=Bu({delta:l,disabled:!p}),[w,v]=Vd(),a=C.useRef({x:0,y:0}),h=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case Ps.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case Ps.DraggableRect:return m}},[r,m,i]),u=C.useRef(null),b=C.useCallback(()=>{const k=u.current;if(!k)return;const E=a.current.x*h.current.x,S=a.current.y*h.current.y;k.scrollBy(E,S)},[]),y=C.useMemo(()=>n===br.TreeOrder?[...c].reverse():c,[n,c]);C.useEffect(()=>{if(!p||!c.length||!d){v();return}for(const k of y){if(o?.(k)===!1)continue;const E=c.indexOf(k),S=f[E];if(!S)continue;const{direction:j,speed:N}=Cu(k,S,d,s,g);for(const T of["x","y"])_[T][j[T]]||(N[T]=0,j[T]=0);if(N.x>0||N.y>0){v(),u.current=k,w(b,x),a.current=N,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},v()},[s,b,o,v,p,x,JSON.stringify(d),JSON.stringify(_),w,c,y,f,JSON.stringify(g)])}const Iu={x:{[ot.Backward]:!1,[ot.Forward]:!1},y:{[ot.Backward]:!1,[ot.Forward]:!1}};function Bu(e){let{delta:s,disabled:r}=e;const o=gr(s);return Ys(m=>{if(r||!o||!m)return Iu;const p={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[ot.Backward]:m.x[ot.Backward]||p.x===-1,[ot.Forward]:m.x[ot.Forward]||p.x===1},y:{[ot.Backward]:m.y[ot.Backward]||p.y===-1,[ot.Forward]:m.y[ot.Forward]||p.y===1}}},[r,s,o])}function Fu(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return Ys(m=>{var p;return s==null?null:(p=o??m)!=null?p:null},[o,s])}function zu(e,s){return C.useMemo(()=>e.reduce((r,o)=>{const{sensor:m}=o,p=m.activators.map(x=>({eventName:x.eventName,handler:s(x.handler,o)}));return[...r,...p]},[]),[e,s])}var Us;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Us||(Us={}));var Ri;(function(e){e.Optimized="optimized"})(Ri||(Ri={}));const Un=new Map;function Hu(e,s){let{dragging:r,dependencies:o,config:m}=s;const[p,x]=C.useState(null),{frequency:n,measure:i,strategy:c}=m,f=C.useRef(e),l=a(),g=Ws(l),_=C.useCallback(function(h){h===void 0&&(h=[]),!g.current&&x(d=>d===null?h:d.concat(h.filter(u=>!d.includes(u))))},[g]),w=C.useRef(null),v=Ys(h=>{if(l&&!r)return Un;if(!h||h===Un||f.current!==e||p!=null){const d=new Map;for(let u of e){if(!u)continue;if(p&&p.length>0&&!p.includes(u.id)&&u.rect.current){d.set(u.id,u.rect.current);continue}const b=u.node.current,y=b?new sn(i(b),b):null;u.rect.current=y,y&&d.set(u.id,y)}return d}return h},[e,p,r,l,i]);return C.useEffect(()=>{f.current=e},[e]),C.useEffect(()=>{l||_()},[r,l]),C.useEffect(()=>{p&&p.length>0&&x(null)},[JSON.stringify(p)]),C.useEffect(()=>{l||typeof n!="number"||w.current!==null||(w.current=setTimeout(()=>{_(),w.current=null},n))},[n,l,_,...o]),{droppableRects:v,measureDroppableContainers:_,measuringScheduled:p!=null};function a(){switch(c){case Us.Always:return!1;case Us.BeforeDragging:return r;default:return!r}}}function on(e,s){return Ys(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Wu(e,s){return on(e,s)}function $u(e){let{callback:s,disabled:r}=e;const o=Lr(s),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function Or(e){let{callback:s,disabled:r}=e;const o=Lr(s),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function Uu(e){return new sn(Vs(e),e)}function qn(e,s,r){s===void 0&&(s=Uu);const[o,m]=C.useState(null);function p(){m(i=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=i??r)!=null?c:null}const f=s(e);return JSON.stringify(i)===JSON.stringify(f)?i:f})}const x=$u({callback(i){if(e)for(const c of i){const{type:f,target:l}=c;if(f==="childList"&&l instanceof HTMLElement&&l.contains(e)){p();break}}}}),n=Or({callback:p});return $t(()=>{p(),e?(n?.observe(e),x?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),x?.disconnect())},[e]),o}function qu(e){const s=on(e);return va(e,s)}const Kn=[];function Ku(e){const s=C.useRef(e),r=Ys(o=>e?o&&o!==Kn&&e&&s.current&&e.parentNode===s.current.parentNode?o:tn(e):Kn,[e]);return C.useEffect(()=>{s.current=e},[e]),r}function Xu(e){const[s,r]=C.useState(null),o=C.useRef(e),m=C.useCallback(p=>{const x=ni(p.target);x&&r(n=>n?(n.set(x,ji(x)),new Map(n)):null)},[]);return C.useEffect(()=>{const p=o.current;if(e!==p){x(p);const n=e.map(i=>{const c=ni(i);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,ji(c)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{x(e),x(p)};function x(n){n.forEach(i=>{const c=ni(i);c?.removeEventListener("scroll",m)})}},[m,e]),C.useMemo(()=>e.length?s?Array.from(s.values()).reduce((p,x)=>_s(p,x),Dt):Ca(e):Dt,[e,s])}function Xn(e,s){s===void 0&&(s=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},s),C.useEffect(()=>{const o=e!==Dt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?vr(e,r.current):Dt}function Yu(e){C.useEffect(()=>{if(!Dr)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 Vu(e,s){return C.useMemo(()=>e.reduce((r,o)=>{let{eventName:m,handler:p}=o;return r[m]=x=>{p(x,s)},r},{}),[e,s])}function Na(e){return C.useMemo(()=>e?bu(e):null,[e])}const Yn=[];function Gu(e,s){s===void 0&&(s=Vs);const[r]=e,o=Na(r?mt(r):null),[m,p]=C.useState(Yn);function x(){p(()=>e.length?e.map(i=>Sa(i)?o:new sn(s(i),i)):Yn)}const n=Or({callback:x});return $t(()=>{n?.disconnect(),x(),e.forEach(i=>n?.observe(i))},[e]),m}function Ra(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return Xs(s)?s:e}function Qu(e){let{measure:s}=e;const[r,o]=C.useState(null),m=C.useCallback(c=>{for(const{target:f}of c)if(Xs(f)){o(l=>{const g=s(f);return l?{...l,width:g.width,height:g.height}:g});break}},[s]),p=Or({callback:m}),x=C.useCallback(c=>{const f=Ra(c);p?.disconnect(),f&&p?.observe(f),o(f?s(f):null)},[s,p]),[n,i]=pr(x);return C.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const Zu=[{sensor:nn,options:{}},{sensor:ja,options:{}}],Ju={current:{}},dr={draggable:{measure:zn},droppable:{measure:zn,strategy:Us.WhileDragging,frequency:Ri.Optimized},dragOverlay:{measure:Vs}};class Os 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 eh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Os,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_r},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:dr,measureDroppableContainers:_r,windowRect:null,measuringScheduled:!1},Aa={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_r,draggableNodes:new Map,over:null,measureDroppableContainers:_r},Gs=C.createContext(Aa),Ma=C.createContext(eh);function th(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Os}}}function sh(e,s){switch(s.type){case et.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case et.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 et.DragEnd:case et.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case et.RegisterDroppable:{const{element:r}=s,{id:o}=r,m=new Os(e.droppable.containers);return m.set(o,r),{...e,droppable:{...e.droppable,containers:m}}}case et.SetDroppableDisabled:{const{id:r,key:o,disabled:m}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const x=new Os(e.droppable.containers);return x.set(r,{...p,disabled:m}),{...e,droppable:{...e.droppable,containers:x}}}case et.UnregisterDroppable:{const{id:r,key:o}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const p=new Os(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function rh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:m}=C.useContext(Gs),p=gr(o),x=gr(r?.id);return C.useEffect(()=>{if(!s&&!o&&p&&x!=null){if(!en(p)||document.activeElement===p.target)return;const n=m.get(x);if(!n)return;const{activatorNode:i,node:c}=n;if(!i.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[i.current,c.current]){if(!f)continue;const l=Zd(f);if(l){l.focus();break}}})}},[o,s,m,x,p]),null}function Ta(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((m,p)=>p({transform:m,...o}),r):r}function ih(e){return C.useMemo(()=>({draggable:{...dr.draggable,...e?.draggable},droppable:{...dr.droppable,...e?.droppable},dragOverlay:{...dr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function nh(e){let{activeNode:s,measure:r,initialRect:o,config:m=!0}=e;const p=C.useRef(!1),{x,y:n}=typeof m=="boolean"?{x:m,y:m}:m;$t(()=>{if(!x&&!n||!s){p.current=!1;return}if(p.current||!o)return;const c=s?.node.current;if(!c||c.isConnected===!1)return;const f=r(c),l=va(f,o);if(x||(l.x=0),n||(l.y=0),p.current=!0,Math.abs(l.x)>0||Math.abs(l.y)>0){const g=_a(c);g&&g.scrollBy({top:l.y,left:l.x})}},[s,x,n,o,r])}const Ir=C.createContext({...Dt,scaleX:1,scaleY:1});var Vt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Vt||(Vt={}));const oh=C.memo(function(s){var r,o,m,p;let{id:x,accessibility:n,autoScroll:i=!0,children:c,sensors:f=Zu,collisionDetection:l=mu,measuring:g,modifiers:_,...w}=s;const v=C.useReducer(sh,void 0,th),[a,h]=v,[d,u]=iu(),[b,y]=C.useState(Vt.Uninitialized),k=b===Vt.Initialized,{draggable:{active:E,nodes:S,translate:j},droppable:{containers:N}}=a,T=E!=null?S.get(E):null,M=C.useRef({initial:null,translated:null}),D=C.useMemo(()=>{var xe;return E!=null?{id:E,data:(xe=T?.data)!=null?xe:Ju,rect:M}:null},[E,T]),I=C.useRef(null),[L,F]=C.useState(null),[z,A]=C.useState(null),P=Ws(w,Object.values(w)),O=Pr("DndDescribedBy",x),B=C.useMemo(()=>N.getEnabled(),[N]),U=ih(g),{droppableRects:X,measureDroppableContainers:V,measuringScheduled:Z}=Hu(B,{dragging:k,dependencies:[j.x,j.y],config:U.droppable}),q=Fu(S,E),R=C.useMemo(()=>z?xr(z):null,[z]),H=Xe(),K=Wu(q,U.draggable.measure);nh({activeNode:E!=null?S.get(E):null,config:H.layoutShiftCompensation,initialRect:K,measure:U.draggable.measure});const W=qn(q,U.draggable.measure,K),Y=qn(q?q.parentElement:null),G=C.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ae=N.getNodeFor((r=G.current.over)==null?void 0:r.id),le=Qu({measure:U.dragOverlay.measure}),Te=(o=le.nodeRef.current)!=null?o:q,De=k?(m=le.rect)!=null?m:W:null,re=!!(le.nodeRef.current&&le.rect),We=qu(re?null:W),Be=Na(Te?mt(Te):null),Re=Ku(k?ae??q:null),ke=Gu(Re),Ee=Ta(_,{transform:{x:j.x-We.x,y:j.y-We.y,scaleX:1,scaleY:1},activatorEvent:z,active:D,activeNodeRect:W,containerNodeRect:Y,draggingNodeRect:De,over:G.current.over,overlayNodeRect:le.rect,scrollableAncestors:Re,scrollableAncestorRects:ke,windowRect:Be}),ve=R?_s(R,j):null,Q=Xu(Re),ye=Xn(Q),Ae=Xn(Q,[W]),te=_s(Ee,ye),ie=De?vu(De,Ee):null,me=D&&ie?l({active:D,collisionRect:ie,droppableRects:X,droppableContainers:B,pointerCoordinates:ve}):null,he=hu(me,"id"),[we,$]=C.useState(null),ne=re?Ee:_s(Ee,Ae),fe=pu(ne,(p=we?.rect)!=null?p:null,W),je=C.useRef(null),$e=C.useCallback((xe,Ge)=>{let{sensor:Je,options:gt}=Ge;if(I.current==null)return;const rt=S.get(I.current);if(!rt)return;const Ne=xe.nativeEvent,ut=new Je({active:I.current,activeNode:rt,event:Ne,options:gt,context:G,onAbort(Ye){if(!S.get(Ye))return;const{onDragAbort:Me}=P.current,xt={id:Ye};Me?.(xt),d({type:"onDragAbort",event:xt})},onPending(Ye,Ct,Me,xt){if(!S.get(Ye))return;const{onDragPending:Mt}=P.current,lt={id:Ye,constraint:Ct,initialCoordinates:Me,offset:xt};Mt?.(lt),d({type:"onDragPending",event:lt})},onStart(Ye){const Ct=I.current;if(Ct==null)return;const Me=S.get(Ct);if(!Me)return;const{onDragStart:xt}=P.current,At={activatorEvent:Ne,active:{id:Ct,data:Me.data,rect:M}};Qt.unstable_batchedUpdates(()=>{xt?.(At),y(Vt.Initializing),h({type:et.DragStart,initialCoordinates:Ye,active:Ct}),d({type:"onDragStart",event:At}),F(je.current),A(Ne)})},onMove(Ye){h({type:et.DragMove,coordinates:Ye})},onEnd:vt(et.DragEnd),onCancel:vt(et.DragCancel)});je.current=ut;function vt(Ye){return async function(){const{active:Me,collisions:xt,over:At,scrollAdjustedTranslate:Mt}=G.current;let lt=null;if(Me&&Mt){const{cancelDrop:_t}=P.current;lt={activatorEvent:Ne,active:Me,collisions:xt,delta:Mt,over:At},Ye===et.DragEnd&&typeof _t=="function"&&await Promise.resolve(_t(lt))&&(Ye=et.DragCancel)}I.current=null,Qt.unstable_batchedUpdates(()=>{h({type:Ye}),y(Vt.Uninitialized),$(null),F(null),A(null),je.current=null;const _t=Ye===et.DragEnd?"onDragEnd":"onDragCancel";if(lt){const Ut=P.current[_t];Ut?.(lt),d({type:_t,event:lt})}})}}},[S]),Fe=C.useCallback((xe,Ge)=>(Je,gt)=>{const rt=Je.nativeEvent,Ne=S.get(gt);if(I.current!==null||!Ne||rt.dndKit||rt.defaultPrevented)return;const ut={active:Ne};xe(Je,Ge.options,ut)===!0&&(rt.dndKit={capturedBy:Ge.sensor},I.current=gt,$e(Je,Ge))},[S,$e]),st=zu(f,Fe);Yu(f),$t(()=>{W&&b===Vt.Initializing&&y(Vt.Initialized)},[W,b]),C.useEffect(()=>{const{onDragMove:xe}=P.current,{active:Ge,activatorEvent:Je,collisions:gt,over:rt}=G.current;if(!Ge||!Je)return;const Ne={active:Ge,activatorEvent:Je,collisions:gt,delta:{x:te.x,y:te.y},over:rt};Qt.unstable_batchedUpdates(()=>{xe?.(Ne),d({type:"onDragMove",event:Ne})})},[te.x,te.y]),C.useEffect(()=>{const{active:xe,activatorEvent:Ge,collisions:Je,droppableContainers:gt,scrollAdjustedTranslate:rt}=G.current;if(!xe||I.current==null||!Ge||!rt)return;const{onDragOver:Ne}=P.current,ut=gt.get(he),vt=ut&&ut.rect.current?{id:ut.id,rect:ut.rect.current,data:ut.data,disabled:ut.disabled}:null,Ye={active:xe,activatorEvent:Ge,collisions:Je,delta:{x:rt.x,y:rt.y},over:vt};Qt.unstable_batchedUpdates(()=>{$(vt),Ne?.(Ye),d({type:"onDragOver",event:Ye})})},[he]),$t(()=>{G.current={activatorEvent:z,active:D,activeNode:q,collisionRect:ie,collisions:me,droppableRects:X,draggableNodes:S,draggingNode:Te,draggingNodeRect:De,droppableContainers:N,over:we,scrollableAncestors:Re,scrollAdjustedTranslate:te},M.current={initial:De,translated:ie}},[D,q,me,ie,S,Te,De,X,N,we,Re,te]),Ou({...H,delta:j,draggingRect:ie,pointerCoordinates:ve,scrollableAncestors:Re,scrollableAncestorRects:ke});const Le=C.useMemo(()=>({active:D,activeNode:q,activeNodeRect:W,activatorEvent:z,collisions:me,containerNodeRect:Y,dragOverlay:le,draggableNodes:S,droppableContainers:N,droppableRects:X,over:we,measureDroppableContainers:V,scrollableAncestors:Re,scrollableAncestorRects:ke,measuringConfiguration:U,measuringScheduled:Z,windowRect:Be}),[D,q,W,z,me,Y,le,S,N,X,we,V,Re,ke,U,Z,Be]),_e=C.useMemo(()=>({activatorEvent:z,activators:st,active:D,activeNodeRect:W,ariaDescribedById:{draggable:O},dispatch:h,draggableNodes:S,over:we,measureDroppableContainers:V}),[z,st,D,W,h,O,S,we,V]);return oe.createElement(ga.Provider,{value:u},oe.createElement(Gs.Provider,{value:_e},oe.createElement(Ma.Provider,{value:Le},oe.createElement(Ir.Provider,{value:fe},c)),oe.createElement(rh,{disabled:n?.restoreFocus===!1})),oe.createElement(au,{...n,hiddenTextDescribedById:O}));function Xe(){const xe=L?.autoScrollEnabled===!1,Ge=typeof i=="object"?i.enabled===!1:i===!1,Je=k&&!xe&&!Ge;return typeof i=="object"?{...i,enabled:Je}:{enabled:Je}}}),ah=C.createContext(null),Vn="button",lh="Draggable";function ch(e){let{id:s,data:r,disabled:o=!1,attributes:m}=e;const p=Pr(lh),{activators:x,activatorEvent:n,active:i,activeNodeRect:c,ariaDescribedById:f,draggableNodes:l,over:g}=C.useContext(Gs),{role:_=Vn,roleDescription:w="draggable",tabIndex:v=0}=m??{},a=i?.id===s,h=C.useContext(a?Ir:ah),[d,u]=pr(),[b,y]=pr(),k=Vu(x,s),E=Ws(r);$t(()=>(l.set(s,{id:s,key:p,node:d,activatorNode:b,data:E}),()=>{const j=l.get(s);j&&j.key===p&&l.delete(s)}),[l,s]);const S=C.useMemo(()=>({role:_,tabIndex:v,"aria-disabled":o,"aria-pressed":a&&_===Vn?!0:void 0,"aria-roledescription":w,"aria-describedby":f.draggable}),[o,_,v,a,w,f.draggable]);return{active:i,activatorEvent:n,activeNodeRect:c,attributes:S,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:u,setActivatorNodeRef:y,transform:h}}function dh(){return C.useContext(Ma)}const uh="Droppable",hh={timeout:25};function fh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:m}=e;const p=Pr(uh),{active:x,dispatch:n,over:i,measureDroppableContainers:c}=C.useContext(Gs),f=C.useRef({disabled:r}),l=C.useRef(!1),g=C.useRef(null),_=C.useRef(null),{disabled:w,updateMeasurementsFor:v,timeout:a}={...hh,...m},h=Ws(v??o),d=C.useCallback(()=>{if(!l.current){l.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{c(Array.isArray(h.current)?h.current:[h.current]),_.current=null},a)},[a]),u=Or({callback:d,disabled:w||!x}),b=C.useCallback((S,j)=>{u&&(j&&(u.unobserve(j),l.current=!1),S&&u.observe(S))},[u]),[y,k]=pr(b),E=Ws(s);return C.useEffect(()=>{!u||!y.current||(u.disconnect(),l.current=!1,u.observe(y.current))},[y,u]),C.useEffect(()=>(n({type:et.RegisterDroppable,element:{id:o,key:p,disabled:r,node:y,rect:g,data:E}}),()=>n({type:et.UnregisterDroppable,key:p,id:o})),[o]),C.useEffect(()=>{r!==f.current.disabled&&(n({type:et.SetDroppableDisabled,id:o,key:p,disabled:r}),f.current.disabled=r)},[o,p,r,n]),{active:x,rect:g,isOver:i?.id===o,node:y,over:i,setNodeRef:k}}function mh(e){let{animation:s,children:r}=e;const[o,m]=C.useState(null),[p,x]=C.useState(null),n=gr(r);return!r&&!o&&n&&m(n),$t(()=>{if(!p)return;const i=o?.key,c=o?.props.id;if(i==null||c==null){m(null);return}Promise.resolve(s(c,p)).then(()=>{m(null)})},[s,o,p]),oe.createElement(oe.Fragment,null,r,o?C.cloneElement(o,{ref:x}):null)}const ph={x:0,y:0,scaleX:1,scaleY:1};function gh(e){let{children:s}=e;return oe.createElement(Gs.Provider,{value:Aa},oe.createElement(Ir.Provider,{value:ph},s))}const vh={position:"fixed",touchAction:"none"},xh=e=>en(e)?"transform 250ms ease":void 0,_h=C.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:m,children:p,className:x,rect:n,style:i,transform:c,transition:f=xh}=e;if(!n)return null;const l=m?c:{...c,scaleX:1,scaleY:1},g={...vh,width:n.width,height:n.height,top:n.top,left:n.left,transform:$s.Transform.toString(l),transformOrigin:m&&o?du(o,n):void 0,transition:typeof f=="function"?f(o):f,...i};return oe.createElement(r,{className:x,style:g,ref:s},p)}),bh=e=>s=>{let{active:r,dragOverlay:o}=s;const m={},{styles:p,className:x}=e;if(p!=null&&p.active)for(const[n,i]of Object.entries(p.active))i!==void 0&&(m[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(p!=null&&p.dragOverlay)for(const[n,i]of Object.entries(p.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return x!=null&&x.active&&r.node.classList.add(x.active),x!=null&&x.dragOverlay&&o.node.classList.add(x.dragOverlay),function(){for(const[i,c]of Object.entries(m))r.node.style.setProperty(i,c);x!=null&&x.active&&r.node.classList.remove(x.active)}},yh=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:$s.Transform.toString(s)},{transform:$s.Transform.toString(r)}]},Sh={duration:250,easing:"ease",keyframes:yh,sideEffects:bh({styles:{active:{opacity:"0"}}})};function wh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:m}=e;return Lr((p,x)=>{if(s===null)return;const n=r.get(p);if(!n)return;const i=n.node.current;if(!i)return;const c=Ra(x);if(!c)return;const{transform:f}=mt(x).getComputedStyle(x),l=xa(f);if(!l)return;const g=typeof s=="function"?s:Ch(s);return ka(i,m.draggable.measure),g({active:{id:p,data:n.data,node:i,rect:m.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:x,rect:m.dragOverlay.measure(c)},droppableContainers:o,measuringConfiguration:m,transform:l})})}function Ch(e){const{duration:s,easing:r,sideEffects:o,keyframes:m}={...Sh,...e};return p=>{let{active:x,dragOverlay:n,transform:i,...c}=p;if(!s)return;const f={x:n.rect.left-x.rect.left,y:n.rect.top-x.rect.top},l={scaleX:i.scaleX!==1?x.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?x.rect.height*i.scaleY/n.rect.height:1},g={x:i.x-f.x,y:i.y-f.y,...l},_=m({...c,active:x,dragOverlay:n,transform:{initial:i,final:g}}),[w]=_,v=_[_.length-1];if(JSON.stringify(w)===JSON.stringify(v))return;const a=o?.({active:x,dragOverlay:n,...c}),h=n.node.animate(_,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let Gn=0;function kh(e){return C.useMemo(()=>{if(e!=null)return Gn++,Gn},[e])}const Eh=oe.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:m,transition:p,modifiers:x,wrapperElement:n="div",className:i,zIndex:c=999}=e;const{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:_,draggableNodes:w,droppableContainers:v,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:u,scrollableAncestorRects:b,windowRect:y}=dh(),k=C.useContext(Ir),E=kh(l?.id),S=Ta(x,{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:_,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:u,scrollableAncestorRects:b,transform:k,windowRect:y}),j=on(g),N=wh({config:o,draggableNodes:w,droppableContainers:v,measuringConfiguration:d}),T=j?a.setRef:void 0;return oe.createElement(gh,null,oe.createElement(mh,{animation:N},l&&E?oe.createElement(_h,{key:E,id:l.id,ref:T,as:n,activatorEvent:f,adjustScale:s,className:i,transition:p,rect:j,style:{zIndex:c,...m},transform:S},r):null))}),Da=768;function jh(e){const s=window.matchMedia(`(max-width: ${Da-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Nh(){return window.innerWidth<Da}function Rh(){return!1}function La(){return C.useSyncExternalStore(jh,Nh,Rh)}function an(e){return wt({queryKey:de.workspaces.list(e),queryFn:()=>Se.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Pa(e){const s=tt();return pt({mutationFn:r=>Se.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:de.workspaces.list(e)}),s.invalidateQueries({queryKey:de.tasks.all})}})}function Ah(){const e=tt();return pt({mutationFn:({id:s,commitMessage:r})=>Se.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.git.all})},onError:()=>{e.invalidateQueries({queryKey:de.git.all})}})}function Mh(){const e=tt();return pt({mutationFn:s=>Se.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function ln(){return pt({mutationFn:({workspaceId:e,editorType:s})=>Se.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function cn(e){return wt({queryKey:de.workspaces.gitStatus(e),queryFn:()=>Se.get(`/workspaces/${e}/git-status`),enabled:!!e})}function Th(){const e=tt();return pt({mutationFn:s=>Se.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function Oa(){const e=tt();return pt({mutationFn:s=>Se.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function Dh(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(p=>p.status==="ACTIVE");return e.some(p=>p.sessions?.some(x=>x.status===Ze.RUNNING||x.status===Ze.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function dn({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:m,workspaces:p,isLoading:x}){const{t:n}=ce(),{data:i,isLoading:c}=an(p===void 0&&e?o:""),f=p??i,l=p===void 0&&e&&c,g=C.useMemo(()=>Dh(f,n),[f,n]);return t.jsx(Nr,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:m})}),l?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((_,w)=>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:_})]},w))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:x||l})}const pe={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Lh=[{status:pe.Review,label:"Review",icon:Fi,color:"text-amber-600"},{status:pe.Running,label:"Running",icon:zi,color:"text-blue-600"},{status:pe.Pending,label:"Pending",icon:Hi,color:"text-neutral-600"},{status:pe.Done,label:"Done",icon:Wi,color:"text-emerald-600"},{status:pe.Cancelled,label:"Cancelled",icon:$i,color:"text-neutral-500"}];function Ph({task:e,status:s,isSelected:r,isAgentActive:o,project:m,onSelectTask:p,onTaskStatusChange:x,onDeleteTask:n,disableDrag:i}){const{t:c}=ce(),f=!!e.projectArchivedAt,l=f||!!i,{attributes:g,listeners:_,setNodeRef:w,isDragging:v}=ch({id:e.id,data:{task:e,fromStatus:s},disabled:l}),[a,h]=C.useState(null),[d,u]=C.useState(!1),b=C.useRef(null),y=C.useRef(null),k=C.useCallback(j=>{f||!x&&!n||(j.preventDefault(),h({x:j.clientX,y:j.clientY}))},[f,x,n]),E=C.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),S=C.useCallback(j=>{if(!i||f||!x&&!n)return;const N=j.touches[0];if(!N)return;const{clientX:T,clientY:M}=N;y.current=setTimeout(()=>{y.current=null,h({x:T,y:M})},500)},[i,f,x,n]);return C.useEffect(()=>{if(!a)return;const j=N=>{b.current&&!b.current.contains(N.target)&&h(null)};return document.addEventListener("mousedown",j),document.addEventListener("touchstart",j),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("touchstart",j)}},[a]),t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:w,onClick:()=>p(e.id),onContextMenu:k,onTouchStart:S,onTouchEnd:E,onTouchMove:E,className:`flex items-start pl-7 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
6
- ${v?"opacity-30":""}
7
- ${r?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...l?{}:_,...l?{}:g,children:[t.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${s===pe.Running?"text-blue-600":"text-neutral-500"}`,children:[s===pe.Review&&t.jsx(Fi,{className:r?"text-amber-600":"text-neutral-500"}),s===pe.Running&&t.jsx(zi,{className:"animate-pulse"}),s===pe.Pending&&t.jsx(Hi,{}),s===pe.Done&&t.jsx(Wi,{className:"text-neutral-400"}),s===pe.Cancelled&&t.jsx($i,{className:"text-neutral-400"})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"mb-0.5 flex min-w-0 items-center",children:[t.jsx("span",{className:`mr-1 max-w-[45%] shrink-0 truncate font-medium ${m?.color||"text-neutral-500"}`,title:m?.name,children:m?.name}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:"/"}),t.jsx("span",{className:`ml-1 min-w-0 flex-1 truncate ${r?"text-neutral-900":"text-neutral-700"}`,title:e.title,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"ml-1.5 inline-flex shrink-0 items-center rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),o&&t.jsxs("span",{className:"relative ml-1.5 inline-flex h-2 w-2 shrink-0 align-middle",children:[t.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),t.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),t.jsx("p",{className:`text-xs line-clamp-2 leading-relaxed ${r?"text-neutral-500":"text-neutral-400 group-hover:text-neutral-500"}`,children:e.description})]})]}),a&&t.jsxs("div",{ref:b,className:"fixed z-[100] w-44 bg-white rounded-lg border border-neutral-200 shadow-xl py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:a.x,top:a.y},children:[x&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:c("Move to")}),Lh.filter(j=>j.status!==s).map(j=>{const N=j.icon;return t.jsxs("button",{onClick:()=>{x(e.id,j.status),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[t.jsx(N,{className:`w-3.5 h-3.5 ${j.color}`}),t.jsx("span",{className:"text-neutral-700",children:c(j.label)})]},j.status)})]}),n&&t.jsxs(t.Fragment,{children:[x&&t.jsx("div",{className:"my-1 border-t border-neutral-100"}),t.jsxs("button",{onClick:()=>{u(!0),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-red-600 hover:bg-red-50 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:c("Delete Task")})]})]})]}),t.jsx(dn,{isOpen:d,onClose:()=>u(!1),onConfirm:()=>{n?.(e.id),u(!1)},taskId:e.id,taskTitle:e.title})]})}const Oh=C.memo(function({title:s,tasks:r,status:o,defaultOpen:m,selectedTaskId:p,onSelectTask:x,projects:n,activeTaskIds:i,isDragging:c,dragFromStatus:f,onTaskStatusChange:l,onDeleteTask:g,disableDrag:_}){const{t:w}=ce(),[v,a]=C.useState(m),h=r.length===0,d=c&&f===o,u=c&&f!==o,{setNodeRef:b,isOver:y}=fh({id:`group-${o}`,data:{status:o}}),k=o===pe.Review,E=w(s),S=c?d&&(v||!0):v;return t.jsxs("div",{className:"mb-2",children:[t.jsxs("button",{onClick:()=>!c&&a(j=>!j),className:"flex items-center w-full px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[t.jsx("span",{className:"mr-2 text-neutral-400",children:S?t.jsx(dt,{size:14}):t.jsx(zt,{size:14})}),t.jsx("span",{className:"flex-1 text-left",children:E}),k&&!h?t.jsx("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-bold rounded-full animate-hop",children:r.length}):t.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",r.length,")"]})]}),u&&t.jsx("div",{ref:b,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
8
- ${y?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:t.jsx("span",{className:"text-xs font-medium",children:y?w("Drop into {title}",{title:E}):w("Drop here")})}),S&&!u&&t.jsx("div",{ref:d?void 0:b,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
9
- ${y&&!d?"bg-blue-50 ring-1 ring-blue-200":""}
10
- ${h&&c?"border border-dashed border-neutral-300":""}`,children:h?t.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-7",children:w("No tasks")}):r.map(j=>{const N=n.find(D=>D.id===j.projectId),T=p===j.id,M=i?.has(j.id)??!1;return t.jsx(Ph,{task:j,status:o,isSelected:T,isAgentActive:M,project:N,onSelectTask:x,onTaskStatusChange:j.projectArchivedAt?void 0:l,onDeleteTask:j.projectArchivedAt?void 0:g,disableDrag:_},j.id)})})]})});function Ih(e){const s={[pe.Review]:[],[pe.Running]:[],[pe.Pending]:[],[pe.Done]:[],[pe.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const Bh=[{status:pe.Review,title:"Review",defaultOpen:!0},{status:pe.Running,title:"Running",defaultOpen:!0},{status:pe.Pending,title:"Pending",defaultOpen:!1},{status:pe.Done,title:"Done",defaultOpen:!1},{status:pe.Cancelled,title:"Cancelled",defaultOpen:!1}];function Qn({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:m,setFilterProjectId:p,width:x=320,onCreateProject:n,onCreateTask:i,activeTaskIds:c,onTaskStatusChange:f,onDeleteTask:l}){const{t:g}=ce(),_=La(),[w,v]=C.useState(!1),[a,h]=C.useState(null),[d,u]=C.useState(null),b=cu(lu(nn,{activationConstraint:{distance:8}})),y=C.useCallback(I=>{const L=I.active.data.current?.task,F=I.active.data.current?.fromStatus;L&&h(L),F&&u(F)},[]),k=C.useCallback(I=>{h(null),u(null);const{active:L,over:F}=I;if(!F)return;const z=L.data.current?.task,A=L.data.current?.fromStatus,P=F.data.current?.status;!z||!A||!P||z.projectArchivedAt||A!==P&&f?.(z.id,P)},[f]),E=m?e.filter(I=>I.projectId===m):e,S=m?s.find(I=>I.id===m)??null:null,j=s.filter(I=>!I.archivedAt),T=!!!S?.archivedAt,M=Ih(E),D=x==="100%";return t.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${D?"":"border-r border-neutral-200"}`,style:{width:x},children:[t.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[t.jsxs("div",{className:"relative flex-1 mr-2",children:[t.jsxs("button",{onClick:()=>v(I=>!I),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[m&&S?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${S.color.replace("text-","bg-")}`}),t.jsx("span",{className:"truncate",children:S.name})]}):t.jsxs(t.Fragment,{children:[t.jsx(Hs,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),t.jsx("span",{children:g("All Projects")})]}),t.jsx(dt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${w?"rotate-180":""}`})]}),w?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>v(!1)}),t.jsxs("div",{className:"absolute left-0 top-full mt-1 w-56 bg-white border border-neutral-200 rounded-lg shadow-xl shadow-neutral-200/50 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:g("Select View")}),t.jsxs("button",{onClick:()=>{p(null),v(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors group",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-5 h-5 flex items-center justify-center rounded border border-neutral-200 bg-neutral-50 text-neutral-500 group-hover:border-neutral-300",children:t.jsx(Hs,{size:12})}),t.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:g("All Projects")})]}),m===null?t.jsx(ft,{size:14,className:"text-neutral-900"}):null]}),t.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),j.map(I=>{const L=m===I.id,F=I.color.replace("text-","bg-");return t.jsxs("button",{onClick:()=>{p(I.id),v(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${F}`}),t.jsx("span",{className:L?"text-neutral-900 font-medium":"text-neutral-600",children:I.name})]}),L?t.jsx(ft,{size:14,className:"text-neutral-900"}):null]},I.id)}),t.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{v(!1),n?.()},className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[t.jsx(Bt,{size:14}),t.jsx("span",{children:g("Create New Project...")})]})]})]}):null]}),t.jsx("button",{onClick:i,disabled:!T,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0 disabled:opacity-30 disabled:cursor-not-allowed",title:g(T?"New Task":"Deleted projects are read-only"),children:t.jsx(Bt,{size:18})})]}),t.jsxs(oh,{sensors:b,onDragStart:y,onDragEnd:k,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin py-4 relative",children:Bh.map(({status:I,title:L,defaultOpen:F})=>t.jsx(Oh,{title:L,tasks:M[I],status:I,defaultOpen:F,selectedTaskId:r,onSelectTask:o,projects:s,activeTaskIds:c,isDragging:a!==null,dragFromStatus:d,onTaskStatusChange:f,onDeleteTask:l,disableDrag:_},I))}),t.jsx(Eh,{dropAnimation:null,children:a?t.jsx("div",{className:"bg-white shadow-lg rounded-md border border-neutral-200 px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-neutral-700",title:a.title,children:a.title})}):null})]}),E.length>0?t.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[t.jsx("span",{children:g("{count} tasks",{count:E.length})}),m?t.jsx("button",{onClick:()=>p(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:g("Clear filter")}):null]}):t.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:t.jsx("span",{children:g("{count} tasks",{count:0})})})]})}const Fh={damping:.7,stiffness:.05,mass:1.25},zh=70,Hh=1e3/60,Wh=350;let Br=!1;globalThis.document?.addEventListener("mousedown",()=>{Br=!0});globalThis.document?.addEventListener("mouseup",()=>{Br=!1});globalThis.document?.addEventListener("click",()=>{Br=!1});const un=(e={})=>{const[s,r]=C.useState(!1),[o,m]=C.useState(e.initial!==!1),[p,x]=C.useState(!1),n=C.useRef(null);n.current=e;const i=C.useCallback(()=>{if(!Br)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const u=d.getRangeAt(0);return u.commonAncestorContainer.contains(a.current)||a.current?.contains(u.commonAncestorContainer)},[]),c=C.useCallback(d=>{l.isAtBottom=d,m(d)},[]),f=C.useCallback(d=>{l.escapedFromLock=d,r(d)},[]),l=C.useMemo(()=>{let d;return{escapedFromLock:s,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return a.current?.scrollTop??0},set scrollTop(u){a.current&&(a.current.scrollTop=u,l.ignoreScrollToTop=a.current.scrollTop)},get targetScrollTop(){return!a.current||!h.current?0:a.current.scrollHeight-1-a.current.clientHeight},get calculatedTargetScrollTop(){if(!a.current||!h.current)return 0;const{targetScrollTop:u}=this;if(!e.targetScrollTop)return u;if(d?.targetScrollTop===u)return d.calculatedScrollTop;const b=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:a.current,contentElement:h.current}),u),0);return d={targetScrollTop:u,calculatedScrollTop:b},requestAnimationFrame(()=>{d=void 0}),b},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=zh}}},[]),g=C.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||c(!0);const u=Date.now()+(Number(d.wait)||0),b=ci(n.current,d.animation),{ignoreEscapes:y=!1}=d;let k,E=l.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{k=Date.now()}):k=u+(d.duration??0);const S=async()=>{const j=new Promise(requestAnimationFrame).then(()=>{if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:N}=l,T=performance.now(),M=(T-(l.lastTick??T))/Hh;if(l.animation||(l.animation={behavior:b,promise:j,ignoreEscapes:y}),l.animation.behavior===b&&(l.lastTick=T),i()||u>Date.now())return S();if(N<Math.min(E,l.calculatedTargetScrollTop)){if(l.animation?.behavior===b){if(b==="instant")return l.scrollTop=l.calculatedTargetScrollTop,S();l.velocity=(b.damping*l.velocity+b.stiffness*l.scrollDifference)/b.mass,l.accumulated+=l.velocity*M,l.scrollTop+=l.accumulated,l.scrollTop!==N&&(l.accumulated=0)}return S()}return k>Date.now()?(E=l.calculatedTargetScrollTop,S()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?g({animation:ci(n.current,n.current.resize),ignoreEscapes:y,duration:Math.max(0,k-Date.now())||void 0}):l.isAtBottom)});return j.then(N=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),N))};return d.wait!==!0&&(l.animation=void 0),l.animation?.behavior===b?l.animation.promise:S()},[c,i,l]),_=C.useCallback(()=>{f(!0),c(!1)},[f,c]),w=C.useCallback(({target:d})=>{if(d!==a.current)return;const{scrollTop:u,ignoreScrollToTop:b}=l;let{lastScrollTop:y=u}=l;l.lastScrollTop=u,l.ignoreScrollToTop=void 0,b&&b>u&&(y=b),x(l.isNearBottom),setTimeout(()=>{if(l.resizeDifference||u===b)return;if(i()){f(!0),c(!1);return}const k=u>y,E=u<y;if(l.animation?.ignoreEscapes){l.scrollTop=y;return}E&&(f(!0),c(!1)),k&&f(!1),!l.escapedFromLock&&l.isNearBottom&&c(!0)},1)},[f,c,i,l]),v=C.useCallback(({target:d,deltaY:u})=>{let b=d;for(;!["scroll","auto"].includes(getComputedStyle(b).overflow);){if(!b.parentElement)return;b=b.parentElement}b===a.current&&u<0&&a.current.scrollHeight>a.current.clientHeight&&!l.animation?.ignoreEscapes&&(f(!0),c(!1))},[f,c,l]),a=Zn(d=>{a.current?.removeEventListener("scroll",w),a.current?.removeEventListener("wheel",v),d?.addEventListener("scroll",w,{passive:!0}),d?.addEventListener("wheel",v,{passive:!0})},[]),h=Zn(d=>{if(l.resizeObserver?.disconnect(),!d)return;let u;l.resizeObserver=new ResizeObserver(([b])=>{const{height:y}=b.contentRect,k=y-(u??y);if(l.resizeDifference=k,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),x(l.isNearBottom),k>=0){const E=ci(n.current,u?n.current.resize:n.current.initial);g({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:Wh})}else l.isNearBottom&&(f(!1),c(!0));u=y,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===k&&(l.resizeDifference=0)},1)})}),l.resizeObserver?.observe(d)},[]);return{contentRef:h,scrollRef:a,scrollToBottom:g,stopScroll:_,isAtBottom:o||p,isNearBottom:p,escapedFromLock:s,state:l}};function Zn(e,s){const r=C.useCallback(o=>(r.current=o,e(o)),s);return r}const li=new Map;function ci(...e){const s={...Fh};let r=!1;for(const m of e){if(m==="instant"){r=!0;continue}typeof m=="object"&&(r=!1,s.damping=m.damping??s.damping,s.stiffness=m.stiffness??s.stiffness,s.mass=m.mass??s.mass)}const o=JSON.stringify(s);return li.has(o)||li.set(o,Object.freeze(s)),r?"instant":li.get(o)}function $h({content:e,children:s,className:r="",side:o="top"}){const m=o==="bottom"?"top-full mt-2":"bottom-full mb-2",p=o==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return t.jsxs("div",{className:`group/tooltip relative ${r}`,children:[s,t.jsxs("div",{className:`absolute ${m} left-1/2 -translate-x-1/2 px-3 py-2 bg-neutral-900 text-white text-xs rounded-lg opacity-0 group-hover/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-[100] shadow-lg`,children:[e,t.jsx("div",{className:`absolute ${p} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function ir(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Uh(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function hn({usage:e,tooltipSide:s="top"}){const{t:r}=ce();if(!e)return null;const o=e.modelContextWindow,m=o?e.totalTokens/o:0,p=o?Math.min(Math.round(m*100),100):null,x=o?Uh(m):"text-neutral-400",n=o?t.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:ir(e.totalTokens),max:ir(o)})}):t.jsx("span",{children:r("已使用: {used} tokens",{used:ir(e.totalTokens)})});return t.jsx($h,{content:n,side:s,children:t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[t.jsx(md,{size:14,className:x}),t.jsxs("span",{className:`tabular-nums ${x}`,children:[ir(e.totalTokens),p!==null&&t.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",p,"%"]})]})]})})}const qh="/api";async function Kh(e){const s=new FormData;s.append("file",e);const r=await fetch(`${qh}/attachments/upload`,{method:"POST",body:s});if(!r.ok){const o=await r.json().catch(()=>({}));throw new Error(o.error||`Upload failed (${r.status})`)}return r.json()}let Xh=0;function Fr(){const[e,s]=C.useState([]),r=C.useRef(e);r.current=e;const o=C.useCallback(async l=>{const g=l.map(_=>({tempId:`tmp-${++Xh}`,file:_,progress:0,status:"uploading"}));s(_=>[..._,...g]),await Promise.allSettled(g.map(async _=>{try{const w=await Kh(_.file);s(v=>v.map(a=>a.tempId===_.tempId?{...a,status:"done",progress:100,attachment:w}:a))}catch(w){s(v=>v.map(a=>a.tempId===_.tempId?{...a,status:"error",error:w instanceof Error?w.message:"Upload failed"}:a))}}))},[]),m=C.useCallback(()=>r.current.filter(l=>l.status==="done"&&l.attachment).map(l=>l.attachment),[]),p=C.useCallback(l=>{s(g=>g.filter(_=>_.tempId!==l))},[]),x=C.useCallback(()=>{s([])},[]),n=C.useCallback(l=>{l.length!==0&&s(g=>{const _=new Set(g.map(v=>v.attachment?.id??v.tempId)),w=l.filter(v=>{const a=v.attachment?.id??v.tempId;return _.has(a)?!1:(_.add(a),!0)});return w.length>0?[...g,...w]:g})},[]),i=C.useCallback(()=>{const l=m();return l.length===0?"":l.map(g=>`${g.mimeType.startsWith("image/")?"!":""}[${g.originalName}](${g.storagePath})`).join(`
11
- `)},[m]),c=e.length>0,f=e.some(l=>l.status==="uploading");return{files:e,addFiles:o,removeFile:p,clear:x,restoreFiles:n,buildMarkdownLinks:i,getDoneAttachments:m,hasFiles:c,isUploading:f}}function Yh(e){const s=C.useMemo(()=>Array.from(new Set(e.filter(Boolean))),[e]);return wt({queryKey:["attachments","metadata",s],queryFn:()=>Se.get("/attachments/metadata",{params:{ids:s.join(",")}}),enabled:s.length>0,staleTime:300*1e3})}const Vh="/api";function Gh(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function zr({files:e,onRemove:s}){return e.length===0?null:t.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(r=>t.jsx(Qh,{item:r,onRemove:s},r.tempId))})}function Qh({item:e,onRemove:s}){const r=e.file.type.startsWith("image/"),o=e.status==="error",m=e.status==="uploading";return t.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${o?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[r&&e.status==="done"&&e.attachment?t.jsx("img",{src:`${Vh}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):t.jsx("span",{className:"flex-shrink-0",children:m?t.jsx(Ke,{size:16,className:"animate-spin text-neutral-400"}):r?t.jsx(Qi,{size:16,className:"text-neutral-400"}):t.jsx(Vi,{size:16,className:"text-neutral-400"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate font-medium",children:e.file.name}),o?t.jsx("div",{className:"truncate text-red-500",children:e.error}):t.jsx("div",{className:"text-neutral-400",children:Gh(e.file.size)})]}),t.jsx("button",{onClick:()=>s(e.tempId),className:"absolute -top-1.5 -right-1.5 hidden group-hover:flex items-center justify-center w-5 h-5 rounded-full bg-neutral-700 text-white hover:bg-neutral-900 transition-colors",children:t.jsx(Ft,{size:10})})]})}const Zh=10,Jh=24,Ia=Zh*Jh,ef=8;function tf(e,s=Ia){return e>s+ef}function sf(e,s){return e.includes(s)?e:[...e,s]}function rf(e,s){return e.filter(r=>r!==s)}function nf(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 Hr=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function Jn(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function of(e,s=[],r=[]){const o=new Set(r.filter(p=>Hr.has(p.status)).map(p=>p.workRequestId));return[...e.map(p=>({kind:"message",key:`message:${p.id}`,sortTime:p.createdAt,order:0,message:p})),...s.filter(p=>p.status==="PENDING_APPROVAL").filter(p=>!o.has(p.id)).map(p=>({kind:"pendingApproval",key:`pending-approval:${p.id}`,sortTime:p.updatedAt??p.createdAt,order:1,request:p}))].sort((p,x)=>{const n=Jn(p.sortTime)-Jn(x.sortTime);return n!==0?n:p.order!==x.order?p.order-x.order:p.key.localeCompare(x.key)})}function af(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 lf(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 cf(e,s){const r=e.reduce((m,p)=>(m[p.status]=(m[p.status]??0)+1,m),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([m,p])=>{const x=r[m];return x?`${x} ${s(p)}`:null}).filter(m=>!!m).join(" · ")}function df(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function uf({status:e}){const{t:s}=ce();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(af(e))})}function hf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:m,isStopPending:p,stoppingMemberId:x,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:c}=ce(),[f,l]=C.useState(df),g=C.useMemo(()=>e.filter(w=>Hr.has(w.status)).sort((w,v)=>Date.parse(v.updatedAt??v.createdAt??"")-Date.parse(w.updatedAt??w.createdAt??"")),[e]);if(g.length===0)return null;const _=cf(g,c);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>l(w=>!w),"aria-expanded":f,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:c("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:_})]}),f?t.jsx(dt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(aa,{size:15,className:"shrink-0 text-neutral-400"})]}),f&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(w=>{const v=s.get(w.memberId),a=r.get(w.workRequestId),h=!!(w.sessionId&&o),d=!!v,u=n===w.id,b=p&&x===w.memberId,y=a?.instruction??w.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:y,className:J("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:()=>w.sessionId&&o?.(w.sessionId),onKeyDown:k=>{!h||!w.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(w.sessionId))},children:[t.jsx(Rt,{name:v?.name??c("Agent"),avatar:v?.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:v?.name??c("Agent")}),t.jsx("span",{className:J("shrink-0",lf(w.status)),children:t.jsx(uf,{status:w.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),w.sessionId&&o?.(w.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:c("View log"),"aria-label":`${c("View log")} ${v?.name??c("Agent")}`,children:t.jsx(fr,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(w.id)},onKeyDown:k=>k.stopPropagation(),disabled:b,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:c("Stop"),"aria-label":`${c("Stop")} ${v?.name??c("Agent")}`,children:t.jsx(bs,{size:12})})]}),d&&u&&v&&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:c("Stop running work?")}),t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:b,onClick:()=>m(v.id,!1),children:[t.jsx(bs,{size:11}),t.jsx("span",{children:c(b?"Stopping":"Stop only")})]}),t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:b,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>m(v.id,!0),children:[t.jsx(ca,{size:11}),t.jsx("span",{children:c(b?"Stopping":"Stop + clear queue")})]})]})]},w.id)})})]})}const yr="/api";let eo=0;function ff(e,s){return eo+=1,{id:`pending-room-message-${Date.now()}-${eo}`,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 mf(e){return"pendingStatus"in e}const pf=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${yr}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function gf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function vf(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function xf(e,s){if(s.length===0)return e;const r=new Set(s.map(vf));return e.split(`
12
- `).map(o=>{const m=o.match(/^\s*/)?.[0]??"",p=o.trimStart();for(const x of r){if(p===x)return null;if(p.startsWith(`${x} `)||p.startsWith(`${x} `))return`${m}${p.slice(x.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
13
- `).replace(/\n{3,}/g,`
14
-
15
- `).trim()}function _f(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function to(e,s){return e instanceof Error?e.message:s}function bf(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 yf(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(m=>m.toLowerCase().includes(r)):!0}function so(e){return e.membershipStatus!=="REMOVED"}function Sf(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function wf(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Cf(e,s){const r=e.mentions??[];if(r.length===0)return e.content;const o=r.map(p=>Sf(p,s)).filter(p=>p&&!e.content.includes(`@${p}`));if(o.length===0)return e.content;const m=o.map(p=>`@${p}`).join(" ");return e.content.trimEnd()?`${e.content.trimEnd()} ${m}`:m}function kf(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 Ef({content:e,isUser:s}){return t.jsx("div",{className:J("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(Ui,{urlTransform:pf,components:qi,children:e})})}function jf({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 m=s.filter(x=>x.mimeType.startsWith("image/")),p=new Map(m.map((x,n)=>[x.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(x=>{const n=`${yr}${x.url}`;if(x.mimeType.startsWith("image/")){const c=p.get(x.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(m,c),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:x.originalName,children:[t.jsx("img",{src:n,alt:x.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:x.originalName})]},x.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:x.originalName,children:[t.jsx(Vi,{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:x.originalName}),t.jsx("span",{className:"text-neutral-400",children:gf(x.sizeBytes)})]}),t.jsx(Yi,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},x.id)})})}function Nf({content:e,attachmentIds:s,isUser:r,tone:o,onOpenImage:m}){const p=C.useMemo(()=>Array.from(new Set(s??[])),[s]),{data:x=[],isLoading:n}=Yh(p),i=x.length>0?xf(e,x):e;return t.jsxs(t.Fragment,{children:[i.trim()&&t.jsx(Mf,{content:i,isUser:r,tone:o}),t.jsx(jf,{hasAttachmentIds:p.length>0,attachments:x,isLoading:n,onOpenImage:m})]})}function Rf({images:e,index:s,onClose:r,onSelect:o}){const m=e[s];if(!m)return null;const p=s>0,x=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(Ft,{size:20})}),p&&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(Jc,{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:`${yr}${m.url}`,alt:m.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:m.originalName}),t.jsxs("a",{href:`${yr}${m.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(Yi,{size:13,"aria-hidden":!0}),"Open"]})]})]}),x&&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(zt,{size:24,"aria-hidden":!0})})]})}function Af({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const p=[e.trim(),s].filter(Boolean).join(`
16
-
17
- `);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Mf({content:e,isUser:s,tone:r=s?"user":"agent"}){const{t:o}=ce(),m=C.useId(),p=C.useRef(null),[x,n]=C.useState(null),[i,c]=C.useState(!1),f=x?.content===e&&x.expanded,l=C.useCallback(()=>{const _=p.current;_&&c(tf(_.scrollHeight))},[]);C.useLayoutEffect(()=>{l();const _=p.current;if(!_)return;const w=window.requestAnimationFrame(l),v=typeof ResizeObserver>"u"?null:new ResizeObserver(l);return v?.observe(_),window.addEventListener("resize",l),()=>{window.cancelAnimationFrame(w),v?.disconnect(),window.removeEventListener("resize",l)}},[e,l]);const g=i&&!f;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:m,ref:p,onLoadCapture:l,className:J("relative transition-[max-height] duration-200 ease-out",g?"overflow-hidden":""),style:g?{maxHeight:Ia}:void 0,children:[t.jsx(Ef,{content:e,isUser:s}),g&&t.jsx("div",{className:J("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",r==="system"?"to-amber-50":r==="user"?"to-neutral-900":"to-neutral-100")})]}),i&&t.jsxs("button",{type:"button","aria-expanded":f,"aria-controls":m,"aria-label":o(f?"Collapse message":"Expand full message"),onClick:()=>n({content:e,expanded:!f}),className:J("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",r==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":r==="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"),children:[f?t.jsx(aa,{size:13}):t.jsx(dt,{size:13}),t.jsx("span",{children:o(f?"Collapse message":"Expand full message")})]})]})}function Ba({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:m,children:p,headerAddon:x,bubbleClassName:n,isPending:i}){return m?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:p})}):t.jsxs("div",{className:J("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(Rt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:J("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:J("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(gs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:_f(r)}),x]}),t.jsx("div",{className:J("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:p})]}),o&&t.jsx(Rt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Tf({message:e,senderName:s,senderMember:r,memberById:o,displayContent:m,onOpenImage:p}){const{t:x}=ce(),n=e.senderType==="user",i=e.senderType==="system",c=mf(e)?e.pendingStatus:null,f=e.mentions??[],l=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",_=g?wf(e,o):[],w=t.jsxs(t.Fragment,{children:[g&&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:_.join(", "),children:[t.jsx(wd,{size:10}),t.jsxs("span",{className:"truncate",children:[x("Private"),_.length>0?`: ${_.join(", ")}`:""]})]}),!i&&l>0&&f.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"),": ",l]}),c==="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("发送中...")}),c==="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(Ba,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:n,isSystem:i,headerAddon:w,bubbleClassName:n&&c==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:c==="sending",children:t.jsx(Nf,{content:m,attachmentIds:e.attachmentIds,isUser:n&&c!=="failed",tone:i?"system":void 0,onOpenImage:p})})}function Df({request:e,member:s,onApprove:r,onReject:o,isActionPending:m,isApprovePending:p,isRejectPending:x}){const{t:n}=ce();return t.jsx(Ba,{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(gs,{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.instruction}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:m,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(ft,{size:12}),t.jsx("span",{children:n(p?"Approving":"Approve")})]}),t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:m,onClick:o,children:[t.jsx(Ft,{size:12}),t.jsx("span",{children:n(x?"Rejecting":"Reject")})]})]})]})})}function Fa({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:m,onViewInvocationSession:p,compactComposer:x,centered:n}){const{t:i}=ce(),c=Go(e.id),f=Qo(e.id),l=Zo(e.id),[g,_]=C.useState(""),[w,v]=C.useState(!1),[a,h]=C.useState(null),[d,u]=C.useState(0),[b,y]=C.useState([]),[k,E]=C.useState(!1),[S,j]=C.useState(null),[N,T]=C.useState([]),[M,D]=C.useState(null),I=C.useRef(null),L=C.useRef(null),{files:F,addFiles:z,removeFile:A,clear:P,restoreFiles:O,buildMarkdownLinks:B,getDoneAttachments:U,isUploading:X}=Fr(),V=F.some($=>$.status==="done"&&$.attachment),[Z,q]=C.useState(null),{scrollRef:R,contentRef:H,isAtBottom:K,scrollToBottom:W}=un({resize:"smooth",initial:"instant"}),Y=C.useMemo(()=>new Map((e.members??[]).map($=>[$.id,$])),[e.members]),G=C.useMemo(()=>(e.members??[]).filter(so),[e.members]),ae=C.useMemo(()=>new Map((e.invocations??[]).map($=>[$.id,$])),[e.invocations]),le=C.useMemo(()=>{const $=new Set(s.map(fe=>fe.id)),ne=N.filter(fe=>!$.has(fe.id));return[...s,...ne].sort((fe,je)=>{const $e=Date.parse(fe.createdAt??""),Fe=Date.parse(je.createdAt??"");return(Number.isNaN($e)?0:$e)-(Number.isNaN(Fe)?0:Fe)})},[s,N]),Te=C.useMemo(()=>new Map((e.workRequests??[]).map($=>[$.id,$])),[e.workRequests]),De=C.useMemo(()=>of(le,e.workRequests??[],e.invocations??[]),[le,e.invocations,e.workRequests]),re=C.useMemo(()=>(e.invocations??[]).filter($=>Hr.has($.status)),[e.invocations]),We=C.useMemo(()=>b.map($=>Y.get($)).filter($=>!!$).filter(so),[Y,b]),Be=C.useMemo(()=>{const $=a?.query??"";return G.filter(ne=>yf(ne,$)).sort((ne,fe)=>{const je=b.includes(ne.id),$e=b.includes(fe.id);return je!==$e?je?1:-1:ne.name.localeCompare(fe.name)})},[G,a?.query,b]),Re=!r&&(w||!!a)&&Be.length>0,ke=C.useCallback(($,ne)=>{if(ne==null){h(null);return}h(bf($,ne)),u(0)},[]),Ee=C.useCallback($=>{y(Fe=>sf(Fe,$.id));const ne=`@${$.name} `;if(a){const Fe=`${g.slice(0,a.start)}${ne}${g.slice(a.end)}`,st=a.start+ne.length;_(Fe),h(null),v(!1),requestAnimationFrame(()=>{I.current?.focus(),I.current?.setSelectionRange(st,st)});return}const fe=g.length===0||/\s$/.test(g)?"":" ",je=`${g}${fe}${ne}`,$e=je.length;_(je),v(!1),requestAnimationFrame(()=>{I.current?.focus(),I.current?.setSelectionRange($e,$e)})},[g,a]),ve=C.useCallback($=>{y(ne=>rf(ne,$))},[]),Q=C.useCallback($=>{const ne=$.target.value;_(ne),j(null);const fe=$.target;fe.style.height="auto",fe.style.height=`${Math.max(x?40:72,Math.min(fe.scrollHeight,x?140:240))}px`,v(!1),ke(ne,fe.selectionStart)},[x,ke]),ye=C.useCallback($=>{const ne=$.target.files;ne&&ne.length>0&&(z(Array.from(ne)),j(null)),$.target.value=""},[z]),Ae=C.useCallback($=>{const ne=[];for(const fe of $.clipboardData.items)if(fe.kind==="file"){const je=fe.getAsFile();je&&ne.push(je)}ne.length>0&&($.preventDefault(),z(ne),j(null))},[z]),te=C.useCallback(async()=>{if(r||k||X)return;const $=B(),ne=U().map(_e=>_e.id),fe=nf(b,G),je=Af({draft:g,attachmentMarkdown:$,attachmentIds:ne,mentions:fe});if(!je||!g.trim()&&!V)return;const $e=ff(e.id,je),Fe=g,st=b,Le=F;T(_e=>[..._e,$e]),_(""),y([]),v(!1),h(null),P(),I.current&&(I.current.style.height=x?"40px":"72px"),requestAnimationFrame(()=>W()),E(!0),j(null);try{const _e=await m(je);T(Xe=>Xe.filter(xe=>xe.id!==$e.id)),_e&&typeof _e=="object"&&"id"in _e&&requestAnimationFrame(()=>W())}catch(_e){const Xe=_e instanceof Error?_e.message:"Failed to send room message";T(xe=>xe.map(Ge=>Ge.id===$e.id?{...Ge,pendingStatus:"failed",error:Xe}:Ge)),_(xe=>xe.length===0?Fe:xe),y(xe=>xe.length===0?st:xe),O(Le),j(Xe),requestAnimationFrame(()=>W())}finally{E(!1)}},[G,F,B,P,x,g,U,V,k,X,m,r,O,W,b,e.id]),ie=C.useCallback($=>{const ne=$.nativeEvent.isComposing||$.nativeEvent.keyCode===229;if(Re){if($.key==="ArrowDown"){$.preventDefault(),u(fe=>(fe+1)%Be.length);return}if($.key==="ArrowUp"){$.preventDefault(),u(fe=>(fe-1+Be.length)%Be.length);return}if($.key==="Enter"&&!ne||$.key==="Tab"){$.preventDefault();const fe=Be[d]??Be[0];fe&&Ee(fe);return}if($.key==="Escape"){$.preventDefault(),h(null),v(!1);return}}$.key==="Enter"&&!$.shiftKey&&!$.repeat&&!ne&&($.preventDefault(),te())},[Ee,te,d,Be,Re]);C.useEffect(()=>{_(""),y([]),v(!1),h(null),j(null),T([]),P(),D(null),I.current&&(I.current.style.height=x?"40px":"72px")},[P,x,e.id]);const me=c.isError?c.error:f.isError?f.error:null,he=c.isPending||f.isPending,we=C.useCallback(($,ne)=>{l.mutate({memberId:$,cancelQueued:ne},{onSuccess:()=>D(null)})},[l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[Z&&t.jsx(Rf,{images:Z.images,index:Z.index,onClose:()=>q(null),onSelect:$=>q(ne=>ne&&{...ne,index:$})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:J("h-full overflow-y-auto scrollbar-app-thin bg-white",x?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:H,className:J(x?"space-y-2.5":"space-y-3",n&&"max-w-5xl mx-auto"),children:[De.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:i("No room messages yet")})]}):De.map($=>{if($.kind==="pendingApproval"){const Fe=$.request,st=Y.get(Fe.targetMemberId),Le=c.isPending&&c.variables===Fe.id,_e=f.isPending&&f.variables===Fe.id;return t.jsx(Df,{request:Fe,member:st,onApprove:()=>c.mutate(Fe.id),onReject:()=>f.mutate(Fe.id),isActionPending:he,isApprovePending:Le,isRejectPending:_e},$.key)}const ne=$.message,fe=kf(ne,Y,ae),je=ne.senderType==="user"?i("你"):ne.senderType==="system"?i("System"):fe?.name??i("Agent"),$e=Cf(ne,Y);return t.jsx(Tf,{message:ne,senderName:je,senderMember:fe,memberById:Y,displayContent:$e,onOpenImage:(Fe,st)=>q({images:Fe,index:st})},$.key)}),me&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:to(me,i("Failed to update work request"))}),l.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:to(l.error,i("Failed to stop member work"))})]})}),!K&&t.jsxs("button",{type:"button",onClick:()=>W(),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(Fs,{size:14}),t.jsx("span",{children:i("Back to bottom")})]})]}),t.jsx("div",{className:J("shrink-0 border-t border-transparent bg-white",x?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:J(n&&"max-w-5xl mx-auto"),children:[t.jsx(hf,{invocations:re,memberById:Y,workRequestById:Te,onViewInvocationSession:p,onStopMember:we,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:M,onToggleStopConfirm:$=>D(ne=>ne===$?null:$)}),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??i("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:[Re&&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:i(a?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Be.map(($,ne)=>{const fe=b.includes($.id),je=ne===d;return t.jsxs("button",{type:"button",onMouseEnter:()=>u(ne),onMouseDown:$e=>{$e.preventDefault(),Ee($)},className:J("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",je?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Rt,{name:$.name,avatar:$.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:$.name}),fe&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:i("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[$.providerId,$.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(Ln,{size:15,className:"text-neutral-400"})]},$.id)})})]}),We.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:We.map($=>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:["@",$.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:$.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>ve($.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:i("Remove mention"),"aria-label":`${i("Remove mention")} ${$.name}`,children:t.jsx(Ft,{size:12})})]},$.id))}),t.jsx(zr,{files:F,onRemove:A}),t.jsx("textarea",{ref:I,value:g,rows:x?1:void 0,onChange:Q,onKeyDown:ie,onPaste:Ae,onClick:$=>ke(g,$.currentTarget.selectionStart),onSelect:$=>ke(g,$.currentTarget.selectionStart),placeholder:i("Message the team room..."),className:J("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",x?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:x?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:J("flex items-center justify-between",x?"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:L,type:"file",multiple:!0,className:"hidden",onChange:ye}),t.jsx("button",{type:"button",onClick:()=>L.current?.click(),title:i("Upload file"),"aria-label":i("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(jr,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{v($=>!$),h(null),requestAnimationFrame(()=>I.current?.focus())},disabled:We.length===0&&G.length===0,title:i("Mention members"),"aria-label":i("Mention members"),className:J("rounded-lg transition-colors",x?"p-1.5":"p-2",w?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",We.length===0&&G.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Ln,{size:x?15:18})}),We.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[We.length," ",i("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{te()},disabled:r||k||X||!g.trim()&&!V,title:i(X?"Uploading...":k?"发送中...":"发送"),"aria-label":i(X?"Uploading...":k?"发送中...":"发送"),className:J("rounded-lg transition-all duration-200",x?"p-1.5":"p-2",(g.trim()||V)&&!r&&!k&&!X?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",k||X?"opacity-70":""),children:t.jsx(Ar,{size:x?15:18})})]}),S&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:S})]})]})})]})}function Lf(e){return e?e.slice(0,8):""}function ro(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function fn(e){return e?.workspaceKind===it.MAIN_DIRECTORY}function cs(e){return e?fn(e)?"Project directory":e.branchName:"—"}function Jt(e){return e?.workingDir||e?.worktreePath||void 0}function mn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),m=s?.mainWorkspaceId??null;return e.map(p=>{const x=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,n=p.ownerMemberId?r.get(p.ownerMemberId):void 0,i=!!(m&&p.id===m),c=i?"main":p.parentWorkspaceId?"child":"root",f=n?.name??(p.ownerMemberId?`Member ${Lf(p.ownerMemberId)}`:void 0),l=fn(p)?"Project directory":i?"Main workspace":c==="child"?f?`${f} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:p,kind:c,roleLabel:i?"Main":c==="child"?"Child":"Root",displayName:l,ownerName:f,parentBranchName:x?cs(x):void 0,isMain:i}}).sort((p,x)=>{const n=c=>c.kind==="main"?0:c.kind==="child"?1:2,i=n(p)-n(x);return i!==0?i:ro(p.workspace.createdAt)-ro(x.workspace.createdAt)})}function za(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===jt.ACTIVE)?.id??e[0]?.id}function Ha(e,s){return!e||e.status!==jt.ACTIVE||fn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Wa(e,s,r){return e?.parentWorkspaceId?s?.find(m=>m.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const pn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Pf=[{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:"合并工作区"}],$a=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Of=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Ua=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],If=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function As(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...pn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function fs(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...pn,...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:{...pn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Bf(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function Ff(e){return{name:e.name.trim(),aliases:Bf(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 io(e,s){return e instanceof Error?e.message:s}function no(e){return e.membershipStatus!=="REMOVED"}function Ai(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function oo(e){return Ai(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function ao(e){return $a.find(s=>s.value===e)?.label??e}function zf(e){return Ua.find(s=>s.value===e)?.label??e}function Pt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function lo({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 Hf({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ce(),{data:m=[]}=Jo(),{data:p=[]}=Cs(),x=Cc(r.id),n=kc(r.id),i=Ec(r.id),c=C.useRef(!1),[f,l]=C.useState("edit"),[g,_]=C.useState(null),[w,v]=C.useState(""),[a,h]=C.useState(As()),[d,u]=C.useState(null),[b,y]=C.useState(null),k=r.members??[],E=C.useMemo(()=>k.filter(no),[k]),S=C.useMemo(()=>b&&no(b)&&!E.some(q=>q.id===b.id)?[...E,b]:E,[b,E]),j=g?E.find(q=>q.id===g)??null:null,N=b?.id===g?b:j,T=w?m.find(q=>q.id===w)??null:null,M=x.isPending||n.isPending||i.isPending,D=S.filter(Ai).length,I=C.useMemo(()=>{const q=p.map(({provider:R,availability:H})=>({value:R.id,label:R.name+(H.type==="NOT_FOUND"?o(" (不可用)"):""),disabled:H.type==="NOT_FOUND"}));return a.providerId&&!q.some(R=>R.value===a.providerId)&&q.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),q},[a.providerId,p,o]);C.useEffect(()=>{if(!e){c.current=!1,y(null);return}if(c.current)return;c.current=!0;const q=S[0]??null;l(q?"edit":"add-preset"),_(q?.id??null),v(""),h(q?fs(q):As()),u(null)},[S,e]),C.useEffect(()=>{b&&E.some(q=>q.id===b.id)&&y(null)},[b,E]),C.useEffect(()=>{f==="add-preset"&&T&&h(di(T))},[f,T]);const L=(q,R)=>{h(H=>({...H,[q]:R}))},F=(q,R)=>{h(H=>({...H,capabilities:{...H.capabilities,[q]:R}}))},z=q=>{l("edit"),_(q.id),v(""),h(fs(q))},A=()=>{l("add-preset"),_(null);const q=T??m[0]??null;v(q?.id??""),h(q?di(q):As())},P=()=>{l("add-custom"),_(null),v(""),h(As())},O=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),B=f==="add-preset"?!!w:f==="edit"?!!(N&&O):O,U=async()=>{try{if(f==="add-preset"){if(!w)return;const R=await x.mutateAsync({memberPresetId:w});at.success(o("Member added")),y(R),l("edit"),_(R.id),v(""),h(fs(R));return}const q=Ff(a);if(!q.name||!q.providerId||!q.rolePrompt){at.error(o("Name, provider, and role prompt are required"));return}if(f==="add-custom"){const R=await x.mutateAsync({member:q});at.success(o("Member added")),y(R),l("edit"),_(R.id),h(fs(R));return}if(N){const R=await n.mutateAsync({memberId:N.id,data:q});at.success(o("Member updated")),y(H=>H?.id===R.id?R:H),_(R.id),h(fs(R))}}catch(q){at.error(io(q,o("Failed to save member")))}},X=async()=>{if(d)try{if(await i.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const q=S.find(R=>R.id!==d.id)??null;_(q?.id??null),l(q?"edit":"add-preset"),h(q?fs(q):As())}y(q=>q?.id===d.id?null:q),u(null),at.success(o("Member removed"))}catch(q){at.error(io(q,o("Failed to remove member")))}},V=()=>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(rr,{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(Pe,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:M,children:[t.jsx(On,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:m.length===0?t.jsx(lo,{icon:t.jsx(rr,{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(Pe,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:M,children:[t.jsx(Bt,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:m.map(q=>{const R=w===q.id;return t.jsxs("button",{type:"button",onClick:()=>{v(q.id),h(di(q))},className:J("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",R?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Rt,{name:q.name,avatar:q.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:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(ao(q.workspacePolicy))," · ",o(zf(q.sessionPolicy))]})]}),R?t.jsx(ft,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),Z=()=>{const q=f==="edit";return q&&!N?t.jsx("div",{className:"p-5",children:t.jsx(lo,{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(Pe,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(Bt,{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:[q?t.jsx(ua,{size:15,className:"text-neutral-500"}):t.jsx(Bt,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&N?t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",onClick:()=>u(N),disabled:M,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(Ki,{size:13}),o("Remove")]}):t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(rr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&N?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(Rt,{name:N.name,avatar:N.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:J("h-2 w-2 shrink-0 rounded-full",oo(N))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:N.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[N.providerId," · ",o(ao(N.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(Pt,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:R=>L("name",R.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(Pt,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:R=>L("aliasesText",R.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("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Provider")}),t.jsx(os,{value:a.providerId,onChange:R=>L("providerId",R),options:I})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:R=>L("avatar",R.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(Pt,{children:o("Workspace policy")}),t.jsx(os,{value:a.workspacePolicy,onChange:R=>L("workspacePolicy",R),options:$a.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Trigger policy")}),t.jsx(os,{value:a.triggerPolicy,onChange:R=>L("triggerPolicy",R),options:Of.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Session policy")}),t.jsx(os,{value:a.sessionPolicy,onChange:R=>L("sessionPolicy",R),options:Ua.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Queue policy")}),t.jsx(os,{value:a.queueManagementPolicy,onChange:R=>L("queueManagementPolicy",R),options:If.map(R=>({value:R.value,label:o(R.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:R=>L("rolePrompt",R.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(Pt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Pf.map(R=>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[R.key],onChange:H=>F(R.key,H.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(R.label)})]},R.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(ws,{isOpen:e,onClose:M?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Pe,{type:"button",variant:"outline",onClick:s,disabled:M,children:o("Close")}),t.jsx(Pe,{type:"button",onClick:U,disabled:M||!B,children:o(M?"Processing...":f==="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:[S.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Pe,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:M,title:o("Add member"),children:t.jsx(Bt,{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:S.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:S.map(q=>{const R=f==="edit"&&g===q.id;return t.jsxs("button",{type:"button",onClick:()=>z(q),className:J("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",R?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Rt,{name:q.name,avatar:q.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:J("h-1.5 w-1.5 shrink-0 rounded-full",oo(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(Ld,{size:13,className:J("shrink-0 text-neutral-300 transition-opacity",R?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.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:M,className:J("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",f==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(rr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:P,disabled:M,className:J("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",f==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(On,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:f==="add-preset"?V():Z()})]})}),t.jsx(Nr,{isOpen:!!d,onClose:()=>u(null),onConfirm:X,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&&Ai(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(Rr,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Wf=[],$f=[],Uf=[];function qf(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 co={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function ui(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 uo(e,s){return e instanceof Error?e.message:s}function Kf(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 Xf(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 Yf(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 Vf(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Gf(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 Qf(e){switch(e){case jt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case jt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case jt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case jt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Zf(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 Jf(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function em(e,s){return s.find(r=>r.memberId===e.id&&Hr.has(r.status))}function qa({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:m}){const{t:p}=ce(),x=Go(e.id),n=Qo(e.id),i=Zo(e.id),[c,f]=C.useState(null),[l,g]=C.useState(null),[_,w]=C.useState(!1),[v,a]=C.useState(!1),h=e.members??Wf,d=C.useMemo(()=>h.filter(L=>L.membershipStatus!=="REMOVED"),[h]),u=e.workRequests??$f,b=e.invocations??Uf,y=C.useMemo(()=>mn(s,e),[e,s]),k=C.useMemo(()=>new Map(u.map(L=>[L.id,L])),[u]),E=C.useMemo(()=>[...u].filter(L=>L.status==="PENDING_APPROVAL").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[u]),S=C.useMemo(()=>[...u].filter(L=>L.status==="QUEUED").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[u]),j=C.useMemo(()=>[...h].map(L=>({member:L,status:qf(L.status)})).sort((L,F)=>co[L.status]-co[F.status]),[h]),N=x.isError?x.error:n.isError?n.error:null,T=x.isPending||n.isPending,M=y.find(L=>L.workspace.id===r),D=e.messages??[],I=j.filter(({status:L})=>L==="running"||L==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(Hf,{isOpen:v,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Hs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("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:p("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:p("Messages"),children:[t.jsx(Xi,{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:p("Members"),children:[t.jsx(ss,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:I>0?`${I}/${d.length}`:d.length}),I>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),S.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[t.jsx(gs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:S.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[t.jsx(gs,{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(gs,{size:13}),t.jsx("span",{children:p("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(L=>{const F=h.find(P=>P.id===L.targetMemberId),z=x.isPending&&x.variables===L.id,A=n.isPending&&n.variables===L.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(Rt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:L.instruction})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:p(Vf(L.requesterType))}),t.jsx("span",{children:ui(L.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>x.mutate(L.id),disabled:T,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(ft,{size:11}),t.jsx("span",{className:"truncate",children:p(z?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(L.id),disabled:T,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(Ft,{size:11}),t.jsx("span",{className:"truncate",children:p(A?"Rejecting":"Reject")})]})]})]},L.id)})}),N&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:uo(N,p("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:p("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:p("Manage Team Members"),"aria-label":p("Manage Team Members"),children:t.jsx(ua,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:L,status:F})=>{const z=em(L,b),A=Jf(b.filter(Z=>Z.memberId===L.id)),P=z?k.get(z.workRequestId):void 0,O=l===L.id,B=F==="running"||F==="waiting room reply",U=B&&!!z,X=c===L.id,V=i.isPending&&i.variables?.memberId===L.id;return t.jsxs("div",{className:J("bg-white",O&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Rt,{name:L.name,avatar:L.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:J("h-1.5 w-1.5 shrink-0 rounded-full",Yf(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:L.name}),t.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Xf(F)),children:p(Kf(F))})]}),B&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:P.instruction})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[U&&t.jsx("button",{type:"button",onClick:()=>f(X?null:L.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:p("Stop"),"aria-label":p("Stop"),children:t.jsx(bs,{size:12})}),z?.sessionId&&m&&t.jsx("button",{type:"button",onClick:()=>m(z.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("View log"),"aria-label":p("View log"),children:t.jsx(fr,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(O?null:L.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:p("Details"),"aria-label":p("Details"),"aria-expanded":O,children:O?t.jsx(dt,{size:13}):t.jsx(zt,{size:13})})]})]}),U&&X&&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:p("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:L.id,cancelQueued:!1},{onSuccess:()=>f(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(bs,{size:10}),t.jsx("span",{children:V&&i.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:L.id,cancelQueued:!0},{onSuccess:()=>f(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(ca,{size:10}),t.jsx("span",{children:V&&i.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),O&&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:L.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.sessionPolicy==="resume_last"?p("Resume last session"):p("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:p("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:p("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(Z=>{const q=k.get(Z.workRequestId),R=!!(Z.sessionId&&m);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:J("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Gf(Z.status)),children:Z.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:ui(Z.updatedAt??Z.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:q?.instruction??Z.workRequestId})]}),R&&t.jsxs("button",{type:"button",onClick:()=>Z.sessionId&&m?.(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:p("View log"),"aria-label":p("View log"),children:[t.jsx(fr,{size:10}),t.jsx("span",{children:p("Log")})]})]})},Z.id)})})]}),j[j.length-1]?.member.id!==L.id&&!O&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},L.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:uo(i.error,p("Failed to stop member work"))})]}),S.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(gs,{size:13}),t.jsx("span",{children:p("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:S.length})]}),t.jsx("div",{className:"space-y-1",children:S.map(L=>{const F=h.find(z=>z.id===L.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(Rt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:L.instruction})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:ui(L.createdAt)})]})},L.id)})})]}),y.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w(L=>!L),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":_,"aria-label":p("Workspaces"),children:[t.jsx(Hs,{size:13}),t.jsx("span",{children:p("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[M&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:cs(M.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:y.length}),_?t.jsx(dt,{size:13,className:"text-neutral-400"}):t.jsx(zt,{size:13,className:"text-neutral-400"})]})]}),_&&t.jsx("div",{className:"space-y-1.5",children:y.map(L=>{const F=r===L.workspace.id;return t.jsx("div",{className:J("rounded-md border bg-white px-3 py-2",F?"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:p(L.displayName)}),t.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Zf(L.roleLabel)),children:p(L.roleLabel)}),t.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Qf(L.workspace.status)),children:L.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:cs(L.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:[L.ownerName&&t.jsxs("span",{children:[p("Owner"),": ",L.ownerName]}),L.parentBranchName&&t.jsxs("span",{children:[p("Parent"),": ",L.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(L.workspace.id),disabled:!o||F,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:p("View workspace"),children:[F?t.jsx(ft,{size:11}):t.jsx(Gi,{size:11}),t.jsx("span",{children:p(F?"Selected":"Select")})]})]})},L.workspace.id)})})]}),E.length===0&&S.length===0&&j.every(({status:L})=>L==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var hi={exports:{}},ho;function tm(){return ho||(ho=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(x,n,i){var c=this&&this.__decorate||function(u,b,y,k){var E,S=arguments.length,j=S<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,b,y,k);else for(var N=u.length-1;N>=0;N--)(E=u[N])&&(j=(S<3?E(j):S>3?E(b,y,j):E(b,y))||j);return S>3&&j&&Object.defineProperty(b,y,j),j},f=this&&this.__param||function(u,b){return function(y,k){b(y,k,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const l=i(9042),g=i(6114),_=i(9924),w=i(844),v=i(5596),a=i(4725),h=i(3656);let d=n.AccessibilityManager=class extends w.Disposable{constructor(u,b){super(),this._terminal=u,this._renderService=b,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 y=0;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);if(this._topBoundaryFocusListener=y=>this._handleBoundaryFocus(y,0),this._bottomBoundaryFocusListener=y=>this._handleBoundaryFocus(y,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 _.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((y=>this._handleResize(y.rows)))),this.register(this._terminal.onRender((y=>this._refreshRows(y.start,y.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((y=>this._handleChar(y)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
18
- `)))),this.register(this._terminal.onA11yTab((y=>this._handleTab(y)))),this.register(this._terminal.onKey((y=>this._handleKey(y.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new v.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,w.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(u){for(let b=0;b<u;b++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
19
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=l.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(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,b){this._liveRegionDebouncer.refresh(u,b,this._terminal.rows)}_renderRows(u,b){const y=this._terminal.buffer,k=y.lines.length.toString();for(let E=u;E<=b;E++){const S=y.translateBufferLineToString(y.ydisp+E,!0),j=(y.ydisp+E+1).toString(),N=this._rowElements[E];N&&(S.length===0?N.innerText=" ":N.textContent=S,N.setAttribute("aria-posinset",j),N.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,b){const y=u.target,k=this._rowElements[b===0?1:this._rowElements.length-2];if(y.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==k)return;let E,S;if(b===0?(E=y,S=this._rowElements.pop(),this._rowContainer.removeChild(S)):(E=this._rowElements.shift(),S=y,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),S.removeEventListener("focus",this._bottomBoundaryFocusListener),b===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(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>u;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const u=document.createElement("div");return u.setAttribute("role","listitem"),u.tabIndex=-1,this._refreshRowDimensions(u),u}_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 u=0;u<this._terminal.rows;u++)this._refreshRowDimensions(this._rowElements[u])}}_refreshRowDimensions(u){u.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=d=c([f(1,a.IRenderService)],d)},3614:(x,n)=>{function i(g){return g.replace(/\r?\n/g,"\r")}function c(g,_){return _?"\x1B[200~"+g+"\x1B[201~":g}function f(g,_,w,v){g=c(g=i(g),w.decPrivateModes.bracketedPasteMode&&v.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(g,!0),_.value=""}function l(g,_,w){const v=w.getBoundingClientRect(),a=g.clientX-v.left-10,h=g.clientY-v.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${a}px`,_.style.top=`${h}px`,_.style.zIndex="1000",_.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=c,n.copyHandler=function(g,_){g.clipboardData&&g.clipboardData.setData("text/plain",_.selectionText),g.preventDefault()},n.handlePasteEvent=function(g,_,w,v){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),_,w,v)},n.paste=f,n.moveTextAreaUnderMouseCursor=l,n.rightClickHandler=function(g,_,w,v,a){l(g,_,w),a&&v.rightClickSelect(g),_.value=v.selectionText,_.select()}},7239:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const c=i(1505);n.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,l,g){this._css.set(f,l,g)}getCss(f,l){return this._css.get(f,l)}setColor(f,l,g){this._color.set(f,l,g)}getColor(f,l){return this._color.get(f,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,c,f,l){i.addEventListener(c,f,l);let g=!1;return{dispose:()=>{g||(g=!0,i.removeEventListener(c,f,l))}}}},6465:function(x,n,i){var c=this&&this.__decorate||function(a,h,d,u){var b,y=arguments.length,k=y<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(y<3?b(k):y>3?b(h,d,k):b(h,d))||k);return y>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const l=i(3656),g=i(8460),_=i(844),w=i(2585);let v=n.Linkifier2=class extends _.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,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.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,l.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,l.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,l.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 u=0;u<d.length;u++){const b=d[u];if(b.classList.contains("xterm"))break;if(b.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,u;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((y=>{y?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[y,k]of this._linkProviders.entries())h?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(y)&&(b=this._checkLinkProviderResult(y,a,b)):k.provideLinks(a.y,(E=>{var S,j;if(this._isMouseOut)return;const N=E?.map((T=>({link:T})));(S=this._activeProviderReplies)===null||S===void 0||S.set(y,N),b=this._checkLinkProviderResult(y,a,b),((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 u=0;u<h.size;u++){const b=h.get(u);if(b)for(let y=0;y<b.length;y++){const k=b[y],E=k.link.range.start.y<a?0:k.link.range.start.x,S=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=S;j++){if(d.has(j)){b.splice(y--,1);break}d.add(j)}}}}_checkLinkProviderResult(a,h,d){var u;if(!this._activeProviderReplies)return d;const b=this._activeProviderReplies.get(a);let y=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(y=!0);if(!y&&b){const k=b.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=(u=this._activeProviderReplies.get(k))===null||u===void 0?void 0:u.find((S=>this._linkAtPosition(S.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,_.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,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:d=>{var u,b;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((b=this._element)===null||b===void 0||b.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.underline},set:d=>{var u,b,y;!((u=this._currentLink)===null||u===void 0)&&u.state&&((y=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||y===void 0?void 0:y.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 u=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(u,b),this._lastMouseEvent&&this._element)){const y=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);y&&this._askForLink(y,!1)}}))))}_linkHover(a,h,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.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,u=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-u-1,d.end.x,d.end.y-u-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(a,h,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.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,u=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return d<=b&&b<=u}_positionFromMouseEvent(a,h,d){const u=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,u,b){return{x1:a,y1:h,x2:d,y2:u,cols:this._bufferService.cols,fg:b}}};n.Linkifier2=v=c([f(0,w.IBufferService)],v)},9042:(x,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(x,n,i){var c=this&&this.__decorate||function(v,a,h,d){var u,b=arguments.length,y=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,a,h,d);else for(var k=v.length-1;k>=0;k--)(u=v[k])&&(y=(b<3?u(y):b>3?u(a,h,y):u(a,h))||y);return b>3&&y&&Object.defineProperty(a,h,y),y},f=this&&this.__param||function(v,a){return function(h,d){a(h,d,v)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const l=i(511),g=i(2585);let _=n.OscLinkProvider=class{constructor(v,a,h){this._bufferService=v,this._optionsService=a,this._oscLinkService=h}provideLinks(v,a){var h;const d=this._bufferService.buffer.lines.get(v-1);if(!d)return void a(void 0);const u=[],b=this._optionsService.rawOptions.linkHandler,y=new l.CellData,k=d.getTrimmedLength();let E=-1,S=-1,j=!1;for(let N=0;N<k;N++)if(S!==-1||d.hasContent(N)){if(d.loadCell(N,y),y.hasExtendedAttrs()&&y.extended.urlId){if(S===-1){S=N,E=y.extended.urlId;continue}j=y.extended.urlId!==E}else S!==-1&&(j=!0);if(j||S!==-1&&N===k-1){const T=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(T){const M={start:{x:S+1,y:v},end:{x:N+(j||N!==k-1?0:1),y:v}};let D=!1;if(!b?.allowNonHttpProtocols)try{const I=new URL(T);["http:","https:"].includes(I.protocol)||(D=!0)}catch{D=!0}D||u.push({text:T,range:M,activate:(I,L)=>b?b.activate(I,L,M):w(0,L),hover:(I,L)=>{var F;return(F=b?.hover)===null||F===void 0?void 0:F.call(b,I,L,M)},leave:(I,L)=>{var F;return(F=b?.leave)===null||F===void 0?void 0:F.call(b,I,L,M)}})}j=!1,y.hasExtendedAttrs()&&y.extended.urlId?(S=N,E=y.extended.urlId):(S=-1,E=-1)}}a(u)}};function w(v,a){if(confirm(`Do you want to navigate to ${a}?
20
-
21
- 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=_=c([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],_)},6193:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,c){this._parentWindow=i,this._renderCallback=c,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,c,f){this._rowCount=f,i=i!==void 0?i:0,c=c!==void 0?c: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,c):c,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),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const c=i(844);class f extends c.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,c.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=f},3236:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const c=i(3614),f=i(3656),l=i(6465),g=i(9042),_=i(3730),w=i(1680),v=i(3107),a=i(5744),h=i(2950),d=i(1296),u=i(428),b=i(4269),y=i(5114),k=i(8934),E=i(3230),S=i(9312),j=i(4725),N=i(6731),T=i(8055),M=i(8969),D=i(8460),I=i(844),L=i(6114),F=i(8437),z=i(2584),A=i(7399),P=i(5941),O=i(9074),B=i(2585),U=i(5435),X=i(4567),V=typeof window<"u"?window.document:null;class Z extends M.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(R={}){super(R),this.browser=L,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.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(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,K)=>this.refresh(H,K)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),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((H=>this._afterResize(H.cols,H.rows)))),this.register((0,I.toDisposable)((()=>{var H,K;this._customKeyEventHandler=void 0,(K=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||K===void 0||K.removeChild(this.element)})))}_handleColorEvent(R){if(this._themeService)for(const H of R){let K,W="";switch(H.index){case 256:K="foreground",W="10";break;case 257:K="background",W="11";break;case 258:K="cursor",W="12";break;default:K="ansi",W="4;"+H.index}switch(H.type){case 0:const Y=T.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${W};${(0,P.toRgbString)(Y)}${z.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((G=>G.ansi[H.index]=T.rgba.toColor(...H.color)));else{const G=K;this._themeService.modifyColors((ae=>ae[G]=T.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(R){R?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(R){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(R),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var R;return(R=this.textarea)===null||R===void 0?void 0:R.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.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 R=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(R);if(!H)return;const K=Math.min(this.buffer.x,this.cols-1),W=this._renderService.dimensions.css.cell.height,Y=H.getWidth(K),G=this._renderService.dimensions.css.cell.width*Y,ae=this.buffer.y*this._renderService.dimensions.css.cell.height,le=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=le+"px",this.textarea.style.top=ae+"px",this.textarea.style.width=G+"px",this.textarea.style.height=W+"px",this.textarea.style.lineHeight=W+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,c.copyHandler)(H,this._selectionService)})));const R=H=>(0,c.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",R)),this.register((0,f.addDisposableDomListener)(this.element,"paste",R)),L.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),L.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,c.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(R=>this._keyUp(R)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(R=>this._keyDown(R)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(R=>this._keyPress(R)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(R=>this._compositionHelper.compositionupdate(R)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(R=>this._inputEvent(R)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(R){var H;if(!R)throw new Error("Terminal requires a parent element.");R.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=R.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),R.appendChild(this.element);const K=V.createDocumentFragment();this._viewportElement=V.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),K.appendChild(this._viewportElement),this._viewportScrollArea=V.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=V.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=V.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),K.appendChild(this.screenElement),this.textarea=V.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),L.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(y.CoreBrowserService,this.textarea,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(W=>this._handleTextAreaFocus(W)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(u.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(N.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.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((W=>this._onRender.fire(W)))),this.onResize((W=>this._renderService.resize(W.cols,W.rows))),this._compositionView=V.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(K);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(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((W=>this.scrollLines(W.amount,W.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(S.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((W=>this.scrollLines(W.amount,W.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((W=>this._renderService.handleSelectionChanged(W.start,W.end,W.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((W=>{this.textarea.value=W,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((W=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(v.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(W=>this._selectionService.handleMouseDown(W)))),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(X.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(W=>this._handleScreenReaderModeOptionChange(W)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(W=>{!this._overviewRulerRenderer&&W&&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 R=this,H=this.element;function K(G){const ae=R._mouseService.getMouseReportCoords(G,R.screenElement);if(!ae)return!1;let le,Te;switch(G.overrideType||G.type){case"mousemove":Te=32,G.buttons===void 0?(le=3,G.button!==void 0&&(le=G.button<3?G.button:3)):le=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":Te=0,le=G.button<3?G.button:3;break;case"mousedown":Te=1,le=G.button<3?G.button:3;break;case"wheel":if(R.viewport.getLinesScrolled(G)===0)return!1;Te=G.deltaY<0?0:1,le=4;break;default:return!1}return!(Te===void 0||le===void 0||le>4)&&R.coreMouseService.triggerMouseEvent({col:ae.col,row:ae.row,x:ae.x,y:ae.y,button:le,action:Te,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const W={mouseup:null,wheel:null,mousedrag:null,mousemove:null},Y={mouseup:G=>(K(G),G.buttons||(this._document.removeEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.removeEventListener("mousemove",W.mousedrag)),this.cancel(G)),wheel:G=>(K(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&K(G)},mousemove:G=>{G.buttons||K(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),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&G?W.mousemove||(H.addEventListener("mousemove",Y.mousemove),W.mousemove=Y.mousemove):(H.removeEventListener("mousemove",W.mousemove),W.mousemove=null),16&G?W.wheel||(H.addEventListener("wheel",Y.wheel,{passive:!1}),W.wheel=Y.wheel):(H.removeEventListener("wheel",W.wheel),W.wheel=null),2&G?W.mouseup||(H.addEventListener("mouseup",Y.mouseup),W.mouseup=Y.mouseup):(this._document.removeEventListener("mouseup",W.mouseup),H.removeEventListener("mouseup",W.mouseup),W.mouseup=null),4&G?W.mousedrag||(W.mousedrag=Y.mousedrag):(this._document.removeEventListener("mousemove",W.mousedrag),W.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(H,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return K(G),W.mouseup&&this._document.addEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.addEventListener("mousemove",W.mousedrag),this.cancel(G)}))),this.register((0,f.addDisposableDomListener)(H,"wheel",(G=>{if(!W.wheel){if(!this.buffer.hasScrollback){const ae=this.viewport.getLinesScrolled(G);if(ae===0)return;const le=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let Te="";for(let De=0;De<Math.abs(ae);De++)Te+=le;return this.coreService.triggerDataEvent(Te,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(H,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(H,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(R,H){var K;(K=this._renderService)===null||K===void 0||K.refreshRows(R,H)}updateCursorStyle(R){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(R)?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(R,H,K=0){var W;K===1?(super.scrollLines(R,H,K),this.refresh(0,this.rows-1)):(W=this.viewport)===null||W===void 0||W.scrollLines(R)}paste(R){(0,c.paste)(R,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(R){this._customKeyEventHandler=R}registerLinkProvider(R){return this.linkifier2.registerLinkProvider(R)}registerCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(R);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(R)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(R){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+R)}registerDecoration(R){return this._decorationService.registerDecoration(R)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(R,H,K){this._selectionService.setSelection(R,H,K)}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 R;(R=this._selectionService)===null||R===void 0||R.clearSelection()}selectAll(){var R;(R=this._selectionService)===null||R===void 0||R.selectAll()}selectLines(R,H){var K;(K=this._selectionService)===null||K===void 0||K.selectLines(R,H)}_keyDown(R){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&R.altKey;if(!H&&!this._compositionHelper.keydown(R))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||R.key!=="Dead"&&R.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const K=(0,A.evaluateKeyboardEvent)(R,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(R),K.type===3||K.type===2){const W=this.rows-1;return this.scrollLines(K.type===2?-W:W),this.cancel(R,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,R)||(K.cancel&&this.cancel(R,!0),!K.key||!!(R.key&&!R.ctrlKey&&!R.altKey&&!R.metaKey&&R.key.length===1&&R.key.charCodeAt(0)>=65&&R.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(K.key!==z.C0.ETX&&K.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||R.altKey||R.ctrlKey?this.cancel(R,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(R,H){const K=R.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||R.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||R.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?K:K&&(!H.keyCode||H.keyCode>47)}_keyUp(R){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(R)||this.focus(),this.updateCursorStyle(R),this._keyPressHandled=!1)}_keyPress(R){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;if(this.cancel(R),R.charCode)H=R.charCode;else if(R.which===null||R.which===void 0)H=R.keyCode;else{if(R.which===0||R.charCode===0)return!1;H=R.which}return!(!H||(R.altKey||R.ctrlKey||R.metaKey)&&!this._isThirdLevelShift(this.browser,R)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(R){if(R.data&&R.inputType==="insertText"&&(!R.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=R.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(R),!0}return!1}resize(R,H){R!==this.cols||H!==this.rows?super.resize(R,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(R,H){var K,W;(K=this._charSizeService)===null||K===void 0||K.measure(),(W=this.viewport)===null||W===void 0||W.syncScrollArea(!0)}clear(){var R;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 H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(R=this.viewport)===null||R===void 0||R.reset(),this.refresh(0,this.rows-1)}}reset(){var R,H;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(R=this._selectionService)===null||R===void 0||R.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var R;(R=this._renderService)===null||R===void 0||R.clearTextureAtlas()}_reportFocus(){var R;!((R=this.element)===null||R===void 0)&&R.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(R){if(this._renderService)switch(R){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${K};${H}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const W=this._renderService.dimensions.css.cell.width.toFixed(0),Y=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${Y};${W}t`)}}cancel(R,H){if(this.options.cancelEvents||H)return R.preventDefault(),R.stopPropagation(),!1}}n.Terminal=Z},9924:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,c=1e3){this._renderCallback=i,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,c,f){this._rowCount=f,i=i!==void 0?i:0,c=c!==void 0?c: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,c):c;const l=Date.now();if(l-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=l,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=l-this._lastRefreshMs,_=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,c)}}},1680:function(x,n,i){var c=this&&this.__decorate||function(h,d,u,b){var y,k=arguments.length,E=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,u):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,u,b);else for(var S=h.length-1;S>=0;S--)(y=h[S])&&(E=(k<3?y(E):k>3?y(d,u,E):y(d,u))||E);return k>3&&E&&Object.defineProperty(d,u,E),E},f=this&&this.__param||function(h,d){return function(u,b){d(u,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const l=i(3656),g=i(4725),_=i(8460),w=i(844),v=i(2585);let a=n.Viewport=class extends w.Disposable{constructor(h,d,u,b,y,k,E,S){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=u,this._optionsService=b,this._charSizeService=y,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 _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,l.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(S.colors),this.register(S.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 u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&u<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 u;let b,y="";const k=[],E=d??this._bufferService.buffer.lines.length,S=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const N=S.get(j);if(!N)continue;const T=(u=S.get(j+1))===null||u===void 0?void 0:u.isWrapped;if(y+=N.translateToString(!T),!T||j===S.length-1){const M=document.createElement("div");M.textContent=y,k.push(M),y.length>0&&(b=M),y=""}}return{bufferElements:k,cursorElement:b}}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 u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&d.altKey||u==="ctrl"&&d.ctrlKey||u==="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=c([f(2,v.IBufferService),f(3,v.IOptionsService),f(4,g.ICharSizeService),f(5,g.IRenderService),f(6,g.ICoreBrowserService),f(7,g.IThemeService)],a)},3107:function(x,n,i){var c=this&&this.__decorate||function(a,h,d,u){var b,y=arguments.length,k=y<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(y<3?b(k):y>3?b(h,d,k):b(h,d))||k);return y>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const l=i(3656),g=i(4725),_=i(844),w=i(2585);let v=n.BufferDecorationRenderer=class extends _.Disposable{constructor(a,h,d,u){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=u,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,l.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((b=>this._removeDecoration(b)))),this.register((0,_.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 u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),u.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",u.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const b=(d=a.options.x)!==null&&d!==void 0?d:0;return b&&b>this._bufferService.cols&&(u.style.display="none"),this._refreshXPosition(a,u),u}_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 u=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=u?u*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=v=c([f(1,w.IBufferService),f(2,w.IDecorationService),f(3,g.IRenderService)],v)},5871:(x,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 c of this._zones)if(c.color===i.options.overviewRulerOptions.color&&c.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,i.marker.line))return;if(this._lineAdjacentToZone(c,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(c,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,c){return c>=i.startBufferLine&&c<=i.endBufferLine}_lineAdjacentToZone(i,c,f){return c>=i.startBufferLine-this._linePadding[f||"full"]&&c<=i.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(i,c){i.startBufferLine=Math.min(i.startBufferLine,c),i.endBufferLine=Math.max(i.endBufferLine,c)}}},5744:function(x,n,i){var c=this&&this.__decorate||function(b,y,k,E){var S,j=arguments.length,N=j<3?y:E===null?E=Object.getOwnPropertyDescriptor(y,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,y,k,E);else for(var T=b.length-1;T>=0;T--)(S=b[T])&&(N=(j<3?S(N):j>3?S(y,k,N):S(y,k))||N);return j>3&&N&&Object.defineProperty(y,k,N),N},f=this&&this.__param||function(b,y){return function(k,E){y(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const l=i(5871),g=i(3656),_=i(4725),w=i(844),v=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 u=n.OverviewRulerRenderer=class extends w.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,y,k,E,S,j,N){var T;super(),this._viewportElement=b,this._screenElement=y,this._bufferService=k,this._decorationService=E,this._renderService=S,this._optionsService=j,this._coreBrowseService=N,this._colorZoneStore=new l.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(),(T=this._viewportElement.parentElement)===null||T===void 0||T.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,w.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 b=Math.floor(this._canvas.width/3),y=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=y,h.right=b,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 b=this._canvas.height/this._bufferService.buffer.lines.length,y=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);a.left=y,a.center=y,a.right=y}_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 y of this._decorationService.decorations)this._colorZoneStore.addDecoration(y);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const y of b)y.position!=="full"&&this._renderColorZone(y);for(const y of b)y.position==="full"&&this._renderColorZone(y);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(d[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-a[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[b.position||"full"]))}_queueRefresh(b,y){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=y||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=u=c([f(2,v.IBufferService),f(3,v.IDecorationService),f(4,_.IRenderService),f(5,v.IOptionsService),f(6,_.ICoreBrowserService)],u)},2950:function(x,n,i){var c=this&&this.__decorate||function(v,a,h,d){var u,b=arguments.length,y=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,a,h,d);else for(var k=v.length-1;k>=0;k--)(u=v[k])&&(y=(b<3?u(y):b>3?u(a,h,y):u(a,h))||y);return b>3&&y&&Object.defineProperty(a,h,y),y},f=this&&this.__param||function(v,a){return function(h,d){a(h,d,v)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const l=i(4725),g=i(2585),_=i(2584);let w=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(v,a,h,d,u,b){this._textarea=v,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=u,this._renderService=b,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(v){this._compositionView.textContent=v.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(v){if(this._isComposing||this._isSendingComposition){if(v.keyCode===229||v.keyCode===16||v.keyCode===17||v.keyCode===18)return!1;this._finalizeComposition(!1)}return v.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(v){if(this._compositionView.classList.remove("active"),this._isComposing=!1,v){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 v=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(v,"");this._dataAlreadySent=h,a.length>v.length?this._coreService.triggerDataEvent(h,!0):a.length<v.length?this._coreService.triggerDataEvent(`${_.C0.DEL}`,!0):a.length===v.length&&a!==v&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(v){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,u=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"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 b=this._compositionView.getBoundingClientRect();this._textarea.style.left=u+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}v||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=w=c([f(2,g.IBufferService),f(3,g.IOptionsService),f(4,g.ICoreService),f(5,l.IRenderService)],w)},9806:(x,n)=>{function i(c,f,l){const g=l.getBoundingClientRect(),_=c.getComputedStyle(l),w=parseInt(_.getPropertyValue("padding-left")),v=parseInt(_.getPropertyValue("padding-top"));return[f.clientX-g.left-w,f.clientY-g.top-v]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(c,f,l,g,_,w,v,a,h){if(!w)return;const d=i(c,f,l);return d?(d[0]=Math.ceil((d[0]+(h?v/2:0))/v),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),_),d):void 0}},9504:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const c=i(2584);function f(a,h,d,u){const b=a-l(a,d),y=h-l(h,d),k=Math.abs(b-y)-(function(E,S,j){let N=0;const T=E-l(E,j),M=S-l(S,j);for(let D=0;D<Math.abs(T-M);D++){const I=g(E,S)==="A"?-1:1,L=j.buffer.lines.get(T+I*D);L?.isWrapped&&N++}return N})(a,h,d);return v(k,w(g(a,h),u))}function l(a,h){let d=0,u=h.buffer.lines.get(a),b=u?.isWrapped;for(;b&&a>=0&&a<h.rows;)d++,u=h.buffer.lines.get(--a),b=u?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function _(a,h,d,u,b,y){let k=a,E=h,S="";for(;k!==d||E!==u;)k+=b?1:-1,b&&k>y.cols-1?(S+=y.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!b&&k<0&&(S+=y.buffer.translateBufferLineToString(E,!1,0,a+1),k=y.cols-1,a=k,E--);return S+y.buffer.translateBufferLineToString(E,!1,a,k)}function w(a,h){const d=h?"O":"[";return c.C0.ESC+d+a}function v(a,h){a=Math.floor(a);let d="";for(let u=0;u<a;u++)d+=h;return d}n.moveToCellSequence=function(a,h,d,u){const b=d.buffer.x,y=d.buffer.y;if(!d.buffer.hasScrollback)return(function(S,j,N,T,M,D){return f(j,T,M,D).length===0?"":v(_(S,j,S,j-l(j,M),!1,M).length,w("D",D))})(b,y,0,h,d,u)+f(y,h,d,u)+(function(S,j,N,T,M,D){let I;I=f(j,T,M,D).length>0?T-l(T,M):j;const L=T,F=(function(z,A,P,O,B,U){let X;return X=f(P,O,B,U).length>0?O-l(O,B):A,z<P&&X<=O||z>=P&&X<O?"C":"D"})(S,j,N,T,M,D);return v(_(S,I,N,L,F==="C",M).length,w(F,D))})(b,y,a,h,d,u);let k;if(y===h)return k=b>a?"D":"C",v(Math.abs(b-a),w(k,u));k=y>h?"D":"C";const E=Math.abs(y-h);return v((function(S,j){return j.cols-S})(y>h?a:b,d)+(E-1)*d.cols+1+((y>h?b:a)-1),w(k,u))}},1296:function(x,n,i){var c=this&&this.__decorate||function(M,D,I,L){var F,z=arguments.length,A=z<3?D:L===null?L=Object.getOwnPropertyDescriptor(D,I):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(M,D,I,L);else for(var P=M.length-1;P>=0;P--)(F=M[P])&&(A=(z<3?F(A):z>3?F(D,I,A):F(D,I))||A);return z>3&&A&&Object.defineProperty(D,I,A),A},f=this&&this.__param||function(M,D){return function(I,L){D(I,L,M)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const l=i(3787),g=i(2550),_=i(2223),w=i(6171),v=i(4725),a=i(8055),h=i(8460),d=i(844),u=i(2585),b="xterm-dom-renderer-owner-",y="xterm-rows",k="xterm-fg-",E="xterm-bg-",S="xterm-focus",j="xterm-selection";let N=1,T=n.DomRenderer=class extends d.Disposable{constructor(M,D,I,L,F,z,A,P,O,B){super(),this._element=M,this._screenElement=D,this._viewportElement=I,this._linkifier2=L,this._charSizeService=z,this._optionsService=A,this._bufferService=P,this._coreBrowserService=O,this._themeService=B,this._terminalClass=N++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(y),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,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((U=>this._injectCss(U)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(b+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(b+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 M=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*M,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*M),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/M),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/M),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 I of this._rowElements)I.style.width=`${this.dimensions.css.canvas.width}px`,I.style.height=`${this.dimensions.css.cell.height}px`,I.style.lineHeight=`${this.dimensions.css.cell.height}px`,I.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const D=`${this._terminalSelector} .${y} 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(M){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${y} { color: ${M.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${y} .xterm-dim { color: ${a.color.multiplyOpacity(M.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: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,D+=`${this._terminalSelector} .${y}.${S} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${y}.${S} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-block { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css};}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${M.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${M.cursor.css} inset;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${M.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: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[I,L]of M.ansi.entries())D+=`${this._terminalSelector} .${k}${I} { color: ${L.css}; }${this._terminalSelector} .${k}${I}.xterm-dim { color: ${a.color.multiplyOpacity(L,.5).css}; }${this._terminalSelector} .${E}${I} { background-color: ${L.css}; }`;D+=`${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(M.background).css}; }${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(M.background),.5).css}; }${this._terminalSelector} .${E}${_.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const M=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${M}px`,this._rowFactory.defaultSpacing=M}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(M,D){for(let I=this._rowElements.length;I<=D;I++){const L=document.createElement("div");this._rowContainer.appendChild(L),this._rowElements.push(L)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,D){this._refreshRowElements(M,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(S)}handleFocus(){this._rowContainer.classList.add(S),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(M,D,I){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,D,I),this.renderRows(0,this._bufferService.rows-1),!M||!D)return;const L=M[1]-this._bufferService.buffer.ydisp,F=D[1]-this._bufferService.buffer.ydisp,z=Math.max(L,0),A=Math.min(F,this._bufferService.rows-1);if(z>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(I){const O=M[0]>D[0];P.appendChild(this._createSelectionElement(z,O?D[0]:M[0],O?M[0]:D[0],A-z+1))}else{const O=L===z?M[0]:0,B=z===F?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(z,O,B));const U=A-z-1;if(P.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,U)),z!==A){const X=F===A?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,X))}}this._selectionContainer.appendChild(P)}_createSelectionElement(M,D,I,L=1){const F=document.createElement("div");return F.style.height=L*this.dimensions.css.cell.height+"px",F.style.top=M*this.dimensions.css.cell.height+"px",F.style.left=D*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(I-D)+"px",F}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 M of this._rowElements)M.replaceChildren()}renderRows(M,D){const I=this._bufferService.buffer,L=I.ybase+I.y,F=Math.min(I.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let O=M;O<=D;O++){const B=O+I.ydisp,U=this._rowElements[O],X=I.lines.get(B);if(!U||!X)break;U.replaceChildren(...this._rowFactory.createRow(X,B,B===L,A,P,F,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!0)}_handleLinkLeave(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!1)}_setCellUnderline(M,D,I,L,F,z){I<0&&(M=0),L<0&&(D=0);const A=this._bufferService.rows-1;I=Math.max(Math.min(I,A),0),L=Math.max(Math.min(L,A),0),F=Math.min(F,this._bufferService.cols);const P=this._bufferService.buffer,O=P.ybase+P.y,B=Math.min(P.x,F-1),U=this._optionsService.rawOptions.cursorBlink,X=this._optionsService.rawOptions.cursorStyle,V=this._optionsService.rawOptions.cursorInactiveStyle;for(let Z=I;Z<=L;++Z){const q=Z+P.ydisp,R=this._rowElements[Z],H=P.lines.get(q);if(!R||!H)break;R.replaceChildren(...this._rowFactory.createRow(H,q,q===O,X,V,B,U,this.dimensions.css.cell.width,this._widthCache,z?Z===I?M:0:-1,z?(Z===L?D:F)-1:-1))}}};n.DomRenderer=T=c([f(4,u.IInstantiationService),f(5,v.ICharSizeService),f(6,u.IOptionsService),f(7,u.IBufferService),f(8,v.ICoreBrowserService),f(9,v.IThemeService)],T)},3787:function(x,n,i){var c=this&&this.__decorate||function(k,E,S,j){var N,T=arguments.length,M=T<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,S):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(k,E,S,j);else for(var D=k.length-1;D>=0;D--)(N=k[D])&&(M=(T<3?N(M):T>3?N(E,S,M):N(E,S))||M);return T>3&&M&&Object.defineProperty(E,S,M),M},f=this&&this.__param||function(k,E){return function(S,j){E(S,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const l=i(2223),g=i(643),_=i(511),w=i(2585),v=i(8055),a=i(4725),h=i(4269),d=i(6171),u=i(3734);let b=n.DomRendererRowFactory=class{constructor(k,E,S,j,N,T,M){this._document=k,this._characterJoinerService=E,this._optionsService=S,this._coreBrowserService=j,this._coreService=N,this._decorationService=T,this._themeService=M,this._workCell=new _.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,S){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=S}createRow(k,E,S,j,N,T,M,D,I,L,F){const z=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let O,B=k.getNoBgTrimmedLength();S&&B<T+1&&(B=T+1);let U=0,X="",V=0,Z=0,q=0,R=!1,H=0,K=!1,W=0;const Y=[],G=L!==-1&&F!==-1;for(let ae=0;ae<B;ae++){k.loadCell(ae,this._workCell);let le=this._workCell.getWidth();if(le===0)continue;let Te=!1,De=ae,re=this._workCell;if(A.length>0&&ae===A[0][0]){Te=!0;const $=A.shift();re=new h.JoinedCellData(this._workCell,k.translateToString(!0,$[0],$[1]),$[1]-$[0]),De=$[1]-1,le=re.getWidth()}const We=this._isCellInSelection(ae,E),Be=S&&ae===T,Re=G&&ae>=L&&ae<=F;let ke=!1;this._decorationService.forEachDecorationAtCell(ae,E,void 0,($=>{ke=!0}));let Ee=re.getChars()||g.WHITESPACE_CELL_CHAR;if(Ee===" "&&(re.isUnderline()||re.isOverline())&&(Ee=" "),W=le*D-I.get(Ee,re.isBold(),re.isItalic()),O){if(U&&(We&&K||!We&&!K&&re.bg===V)&&(We&&K&&P.selectionForeground||re.fg===Z)&&re.extended.ext===q&&Re===R&&W===H&&!Be&&!Te&&!ke){X+=Ee,U++;continue}U&&(O.textContent=X),O=this._document.createElement("span"),U=0,X=""}else O=this._document.createElement("span");if(V=re.bg,Z=re.fg,q=re.extended.ext,R=Re,H=W,K=We,Te&&T>=ae&&T<=De&&(T=ae),!this._coreService.isCursorHidden&&Be){if(Y.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&Y.push("xterm-cursor-blink"),Y.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(N)switch(N){case"outline":Y.push("xterm-cursor-outline");break;case"block":Y.push("xterm-cursor-block");break;case"bar":Y.push("xterm-cursor-bar");break;case"underline":Y.push("xterm-cursor-underline")}}if(re.isBold()&&Y.push("xterm-bold"),re.isItalic()&&Y.push("xterm-italic"),re.isDim()&&Y.push("xterm-dim"),X=re.isInvisible()?g.WHITESPACE_CELL_CHAR:re.getChars()||g.WHITESPACE_CELL_CHAR,re.isUnderline()&&(Y.push(`xterm-underline-${re.extended.underlineStyle}`),X===" "&&(X=" "),!re.isUnderlineColorDefault()))if(re.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(re.getUnderlineColor()).join(",")})`;else{let $=re.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&re.isBold()&&$<8&&($+=8),O.style.textDecorationColor=P.ansi[$].css}re.isOverline()&&(Y.push("xterm-overline"),X===" "&&(X=" ")),re.isStrikethrough()&&Y.push("xterm-strikethrough"),Re&&(O.style.textDecoration="underline");let ve=re.getFgColor(),Q=re.getFgColorMode(),ye=re.getBgColor(),Ae=re.getBgColorMode();const te=!!re.isInverse();if(te){const $=ve;ve=ye,ye=$;const ne=Q;Q=Ae,Ae=ne}let ie,me,he,we=!1;switch(this._decorationService.forEachDecorationAtCell(ae,E,void 0,($=>{$.options.layer!=="top"&&we||($.backgroundColorRGB&&(Ae=50331648,ye=$.backgroundColorRGB.rgba>>8&16777215,ie=$.backgroundColorRGB),$.foregroundColorRGB&&(Q=50331648,ve=$.foregroundColorRGB.rgba>>8&16777215,me=$.foregroundColorRGB),we=$.options.layer==="top")})),!we&&We&&(ie=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,ye=ie.rgba>>8&16777215,Ae=50331648,we=!0,P.selectionForeground&&(Q=50331648,ve=P.selectionForeground.rgba>>8&16777215,me=P.selectionForeground)),we&&Y.push("xterm-decoration-top"),Ae){case 16777216:case 33554432:he=P.ansi[ye],Y.push(`xterm-bg-${ye}`);break;case 50331648:he=v.rgba.toColor(ye>>16,ye>>8&255,255&ye),this._addStyle(O,`background-color:#${y((ye>>>0).toString(16),"0",6)}`);break;default:te?(he=P.foreground,Y.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):he=P.background}switch(ie||re.isDim()&&(ie=v.color.multiplyOpacity(he,.5)),Q){case 16777216:case 33554432:re.isBold()&&ve<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ve+=8),this._applyMinimumContrast(O,he,P.ansi[ve],re,ie,void 0)||Y.push(`xterm-fg-${ve}`);break;case 50331648:const $=v.rgba.toColor(ve>>16&255,ve>>8&255,255&ve);this._applyMinimumContrast(O,he,$,re,ie,me)||this._addStyle(O,`color:#${y(ve.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,he,P.foreground,re,ie,void 0)||te&&Y.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}Y.length&&(O.className=Y.join(" "),Y.length=0),Be||Te||ke?O.textContent=X:U++,W!==this.defaultSpacing&&(O.style.letterSpacing=`${W}px`),z.push(O),ae=De}return O&&U&&(O.textContent=X),z}_applyMinimumContrast(k,E,S,j,N,T){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const M=this._getContrastCache(j);let D;if(N||T||(D=M.getColor(E.rgba,S.rgba)),D===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=v.color.ensureContrastRatio(N||E,T||S,I),M.setColor((N||E).rgba,(T||S).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 S=this._selectionStart,j=this._selectionEnd;return!(!S||!j)&&(this._columnSelectMode?S[0]<=j[0]?k>=S[0]&&E>=S[1]&&k<j[0]&&E<=j[1]:k<S[0]&&E>=S[1]&&k>=j[0]&&E<=j[1]:E>S[1]&&E<j[1]||S[1]===j[1]&&E===S[1]&&k>=S[0]&&k<j[0]||S[1]<j[1]&&E===j[1]&&k<j[0]||S[1]<j[1]&&E===S[1]&&k>=S[0])}};function y(k,E,S){for(;k.length<S;)k=E+k;return k}n.DomRendererRowFactory=b=c([f(1,a.ICharacterJoinerService),f(2,w.IOptionsService),f(3,a.ICoreBrowserService),f(4,w.ICoreService),f(5,w.IDecorationService),f(6,a.IThemeService)],b)},2550:(x,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 c=i.createElement("span"),f=i.createElement("span");f.style.fontWeight="bold";const l=i.createElement("span");l.style.fontStyle="italic";const g=i.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[c,f,l,g],this._container.appendChild(c),this._container.appendChild(f),this._container.appendChild(l),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,c,f,l){i===this._font&&c===this._fontSize&&f===this._weight&&l===this._weightBold||(this._font=i,this._fontSize=c,this._weight=f,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(i,c,f){let l=0;if(!c&&!f&&i.length===1&&(l=i.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(i,0);let g=i;c&&(g+="B"),f&&(g+="I");let _=this._holey.get(g);if(_===void 0){let w=0;c&&(w|=1),f&&(w|=2),_=this._measure(i,w),this._holey.set(g,_)}return _}_measure(i,c){const f=this._measureElements[c];return f.textContent=i.repeat(32),f.offsetWidth/32}}},2223:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const c=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(x,n)=>{function i(c){return 57508<=c&&c<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},n.excludeFromContrastRatioDemands=function(c){return i(c)||(function(f){return 9472<=f&&f<=9631})(c)},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:(x,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,c=this.selectionEnd;return!(!i||!c)&&(i[1]>c[1]||i[1]===c[1]&&i[0]>c[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(x,n,i){var c=this&&this.__decorate||function(a,h,d,u){var b,y=arguments.length,k=y<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(y<3?b(k):y>3?b(h,d,k):b(h,d))||k);return y>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const l=i(2585),g=i(8460),_=i(844);let w=n.CharSizeService=class extends _.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 v(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=w=c([f(2,l.IOptionsService)],w);class v{constructor(h,d,u){this._document=h,this._parentElement=d,this._optionsService=u,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(x,n,i){var c=this&&this.__decorate||function(h,d,u,b){var y,k=arguments.length,E=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,u):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,u,b);else for(var S=h.length-1;S>=0;S--)(y=h[S])&&(E=(k<3?y(E):k>3?y(d,u,E):y(d,u))||E);return k>3&&E&&Object.defineProperty(d,u,E),E},f=this&&this.__param||function(h,d){return function(u,b){d(u,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const l=i(3734),g=i(643),_=i(511),w=i(2585);class v extends l.AttributeData{constructor(d,u,b){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=u,this._width=b}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=v;let a=n.CharacterJoinerService=class Ka{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _.CellData}register(d){const u={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(u),u.id}deregister(d){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===d)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(d);if(!u||u.length===0)return[];const b=[],y=u.translateToString(!0);let k=0,E=0,S=0,j=u.getFg(0),N=u.getBg(0);for(let T=0;T<u.getTrimmedLength();T++)if(u.loadCell(T,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==N){if(T-k>1){const M=this._getJoinedRanges(y,S,E,u,k);for(let D=0;D<M.length;D++)b.push(M[D])}k=T,S=E,j=this._workCell.fg,N=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const T=this._getJoinedRanges(y,S,E,u,k);for(let M=0;M<T.length;M++)b.push(T[M])}return b}_getJoinedRanges(d,u,b,y,k){const E=d.substring(u,b);let S=[];try{S=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const N=this._characterJoiners[j].handler(E);for(let T=0;T<N.length;T++)Ka._mergeRanges(S,N[T])}catch(N){console.error(N)}return this._stringRangesToCellRanges(S,y,k),S}_stringRangesToCellRanges(d,u,b){let y=0,k=!1,E=0,S=d[y];if(S){for(let j=b;j<this._bufferService.cols;j++){const N=u.getWidth(j),T=u.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(N!==0){if(!k&&S[0]<=E&&(S[0]=j,k=!0),S[1]<=E){if(S[1]=j,S=d[++y],!S)break;S[0]<=E?(S[0]=j,k=!0):k=!1}E+=T}}S&&(S[1]=this._bufferService.cols)}}static _mergeRanges(d,u){let b=!1;for(let y=0;y<d.length;y++){const k=d[y];if(b){if(u[1]<=k[0])return d[y-1][1]=u[1],d;if(u[1]<=k[1])return d[y-1][1]=Math.max(u[1],k[1]),d.splice(y,1),d;d.splice(y,1),y--}else{if(u[1]<=k[0])return d.splice(y,0,u),d;if(u[1]<=k[1])return k[0]=Math.min(u[0],k[0]),d;u[0]<k[1]&&(k[0]=Math.min(u[0],k[0]),b=!0)}}return b?d[d.length-1][1]=u[1]:d.push(u),d}};n.CharacterJoinerService=a=c([f(0,w.IBufferService)],a)},5114:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,c){this._textarea=i,this.window=c,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(x,n,i){var c=this&&this.__decorate||function(w,v,a,h){var d,u=arguments.length,b=u<3?v:h===null?h=Object.getOwnPropertyDescriptor(v,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(w,v,a,h);else for(var y=w.length-1;y>=0;y--)(d=w[y])&&(b=(u<3?d(b):u>3?d(v,a,b):d(v,a))||b);return u>3&&b&&Object.defineProperty(v,a,b),b},f=this&&this.__param||function(w,v){return function(a,h){v(a,h,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const l=i(4725),g=i(9806);let _=n.MouseService=class{constructor(w,v){this._renderService=w,this._charSizeService=v}getCoords(w,v,a,h,d){return(0,g.getCoords)(window,w,v,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(w,v){const a=(0,g.getCoordsRelativeToElement)(window,w,v);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=_=c([f(0,l.IRenderService),f(1,l.ICharSizeService)],_)},3230:function(x,n,i){var c=this&&this.__decorate||function(b,y,k,E){var S,j=arguments.length,N=j<3?y:E===null?E=Object.getOwnPropertyDescriptor(y,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,y,k,E);else for(var T=b.length-1;T>=0;T--)(S=b[T])&&(N=(j<3?S(N):j>3?S(y,k,N):S(y,k))||N);return j>3&&N&&Object.defineProperty(y,k,N),N},f=this&&this.__param||function(b,y){return function(k,E){y(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const l=i(3656),g=i(6193),_=i(5596),w=i(4725),v=i(8460),a=i(844),h=i(7226),d=i(2585);let u=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,y,k,E,S,j,N,T){if(super(),this._rowCount=b,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 v.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new v.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new v.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new v.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(N.window,((M,D)=>this._renderRows(M,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new _.ScreenDprMonitor(N.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)===null||M===void 0?void 0:M.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(S.onDecorationRegistered((()=>this._fullRefresh()))),this.register(S.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,l.addDisposableDomListener)(N.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(T.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in N.window){const M=new N.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});M.observe(y),this.register({dispose:()=>M.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.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(b,y,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,y,this._rowCount))}_renderRows(b,y){this._renderer.value&&(b=Math.min(b,this._rowCount-1),y=Math.min(y,this._rowCount-1),this._renderer.value.renderRows(b,y),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:y}),this._onRender.fire({start:b,end:y}),this._isNextRenderRedrawOnly=!0)}resize(b,y){this._rowCount=y,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(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((y=>this.refreshRows(y.start,y.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,y;this._renderer.value&&((y=(b=this._renderer.value).clearTextureAtlas)===null||y===void 0||y.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,y){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,y))):this._renderer.value.handleResize(b,y),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,y,k){var E;this._selectionState.start=b,this._selectionState.end=y,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(b,y,k)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};n.RenderService=u=c([f(2,d.IOptionsService),f(3,w.ICharSizeService),f(4,d.IDecorationService),f(5,d.IBufferService),f(6,w.ICoreBrowserService),f(7,w.IThemeService)],u)},9312:function(x,n,i){var c=this&&this.__decorate||function(S,j,N,T){var M,D=arguments.length,I=D<3?j:T===null?T=Object.getOwnPropertyDescriptor(j,N):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(S,j,N,T);else for(var L=S.length-1;L>=0;L--)(M=S[L])&&(I=(D<3?M(I):D>3?M(j,N,I):M(j,N))||I);return D>3&&I&&Object.defineProperty(j,N,I),I},f=this&&this.__param||function(S,j){return function(N,T){j(N,T,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const l=i(9806),g=i(9504),_=i(456),w=i(4725),v=i(8460),a=i(844),h=i(6114),d=i(4841),u=i(511),b=i(2585),y=" ",k=new RegExp(y,"g");let E=n.SelectionService=class extends a.Disposable{constructor(S,j,N,T,M,D,I,L,F){super(),this._element=S,this._screenElement=j,this._linkifier=N,this._bufferService=T,this._coreService=M,this._mouseService=D,this._optionsService=I,this._renderService=L,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new u.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new v.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new v.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new v.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new v.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=z=>this._handleMouseMove(z),this._mouseUpListener=z=>this._handleMouseUp(z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((z=>this._handleTrim(z))),this.register(this._bufferService.buffers.onBufferActivate((z=>this._handleBufferActivate(z)))),this.enable(),this._model=new _.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 S=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!S||!j||S[0]===j[0]&&S[1]===j[1])}get selectionText(){const S=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!S||!j)return"";const N=this._bufferService.buffer,T=[];if(this._activeSelectionMode===3){if(S[0]===j[0])return"";const M=S[0]<j[0]?S[0]:j[0],D=S[0]<j[0]?j[0]:S[0];for(let I=S[1];I<=j[1];I++){const L=N.translateBufferLineToString(I,!0,M,D);T.push(L)}}else{const M=S[1]===j[1]?j[0]:void 0;T.push(N.translateBufferLineToString(S[1],!0,S[0],M));for(let D=S[1]+1;D<=j[1]-1;D++){const I=N.lines.get(D),L=N.translateBufferLineToString(D,!0);I?.isWrapped?T[T.length-1]+=L:T.push(L)}if(S[1]!==j[1]){const D=N.lines.get(j[1]),I=N.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?T[T.length-1]+=I:T.push(I)}}return T.map((M=>M.replace(k," "))).join(h.isWindows?`\r
22
- `:`
23
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(S){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&S&&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(S){const j=this._getMouseBufferCoords(S),N=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!!(N&&T&&j)&&this._areCoordsInSelection(j,N,T)}isCellInSelection(S,j){const N=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!(!N||!T)&&this._areCoordsInSelection([S,j],N,T)}_areCoordsInSelection(S,j,N){return S[1]>j[1]&&S[1]<N[1]||j[1]===N[1]&&S[1]===j[1]&&S[0]>=j[0]&&S[0]<N[0]||j[1]<N[1]&&S[1]===N[1]&&S[0]<N[0]||j[1]<N[1]&&S[1]===j[1]&&S[0]>=j[0]}_selectWordAtCursor(S,j){var N,T;const M=(T=(N=this._linkifier.currentLink)===null||N===void 0?void 0:N.link)===null||T===void 0?void 0:T.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(S);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(S,j){this._model.clearSelection(),S=Math.max(S,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,S],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(S){this._model.handleTrim(S)&&this.refresh()}_getMouseBufferCoords(S){const j=this._mouseService.getCoords(S,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(S){let j=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,S,this._screenElement)[1];const N=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=N?0:(j>N&&(j-=N),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(S){return h.isMac?S.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:S.shiftKey}handleMouseDown(S){if(this._mouseDownTimeStamp=S.timeStamp,(S.button!==2||!this.hasSelection)&&S.button===0){if(!this._enabled){if(!this.shouldForceSelection(S))return;S.stopPropagation()}S.preventDefault(),this._dragScrollAmount=0,this._enabled&&S.shiftKey?this._handleIncrementalClick(S):S.detail===1?this._handleSingleClick(S):S.detail===2?this._handleDoubleClick(S):S.detail===3&&this._handleTripleClick(S),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(S){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(S))}_handleSingleClick(S){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(S)?3:0,this._model.selectionStart=this._getMouseBufferCoords(S),!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(S){this._selectWordAtCursor(S,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(S){const j=this._getMouseBufferCoords(S);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(S){return S.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(S){if(S.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(S),!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(S),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const N=this._bufferService.buffer;if(this._model.selectionEnd[1]<N.lines.length){const T=N.lines.get(this._model.selectionEnd[1]);T&&T.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 S=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(S.ydisp+this._bufferService.rows,S.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=S.ydisp),this.refresh()}}_handleMouseUp(S){const j=S.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&S.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const N=this._mouseService.getCoords(S,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(N&&N[0]!==void 0&&N[1]!==void 0){const T=(0,g.moveToCellSequence)(N[0]-1,N[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(T,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const S=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,N=!(!S||!j||S[0]===j[0]&&S[1]===j[1]);N?S&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&S[0]===this._oldSelectionStart[0]&&S[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(S,j,N)):this._oldHasSelection&&this._fireOnSelectionChange(S,j,N)}_fireOnSelectionChange(S,j,N){this._oldSelectionStart=S,this._oldSelectionEnd=j,this._oldHasSelection=N,this._onSelectionChange.fire()}_handleBufferActivate(S){this.clearSelection(),this._trimListener.dispose(),this._trimListener=S.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(S,j){let N=j;for(let T=0;j>=T;T++){const M=S.loadCell(T,this._workCell).getChars().length;this._workCell.getWidth()===0?N--:M>1&&j!==T&&(N+=M-1)}return N}setSelection(S,j,N){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[S,j],this._model.selectionStartLength=N,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(S){this._isClickInSelection(S)||(this._selectWordAtCursor(S,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(S,j,N=!0,T=!0){if(S[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,D=M.lines.get(S[1]);if(!D)return;const I=M.translateBufferLineToString(S[1],!1);let L=this._convertViewportColToCharacterIndex(D,S[0]),F=L;const z=S[0]-L;let A=0,P=0,O=0,B=0;if(I.charAt(L)===" "){for(;L>0&&I.charAt(L-1)===" ";)L--;for(;F<I.length&&I.charAt(F+1)===" ";)F++}else{let V=S[0],Z=S[0];D.getWidth(V)===0&&(A++,V--),D.getWidth(Z)===2&&(P++,Z++);const q=D.getString(Z).length;for(q>1&&(B+=q-1,F+=q-1);V>0&&L>0&&!this._isCharWordSeparator(D.loadCell(V-1,this._workCell));){D.loadCell(V-1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,V--):R>1&&(O+=R-1,L-=R-1),L--,V--}for(;Z<D.length&&F+1<I.length&&!this._isCharWordSeparator(D.loadCell(Z+1,this._workCell));){D.loadCell(Z+1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,Z++):R>1&&(B+=R-1,F+=R-1),F++,Z++}}F++;let U=L+z-A+O,X=Math.min(this._bufferService.cols,F-L+A+P-O-B);if(j||I.slice(L,F).trim()!==""){if(N&&U===0&&D.getCodePoint(0)!==32){const V=M.lines.get(S[1]-1);if(V&&D.isWrapped&&V.getCodePoint(this._bufferService.cols-1)!==32){const Z=this._getWordAt([this._bufferService.cols-1,S[1]-1],!1,!0,!1);if(Z){const q=this._bufferService.cols-Z.start;U-=q,X+=q}}}if(T&&U+X===this._bufferService.cols&&D.getCodePoint(this._bufferService.cols-1)!==32){const V=M.lines.get(S[1]+1);if(V?.isWrapped&&V.getCodePoint(0)!==32){const Z=this._getWordAt([0,S[1]+1],!1,!1,!0);Z&&(X+=Z.length)}}return{start:U,length:X}}}_selectWordAt(S,j){const N=this._getWordAt(S,j);if(N){for(;N.start<0;)N.start+=this._bufferService.cols,S[1]--;this._model.selectionStart=[N.start,S[1]],this._model.selectionStartLength=N.length}}_selectToWordAt(S){const j=this._getWordAt(S,!0);if(j){let N=S[1];for(;j.start<0;)j.start+=this._bufferService.cols,N--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,N++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,N]}}_isCharWordSeparator(S){return S.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(S.getChars())>=0}_selectLineAt(S){const j=this._bufferService.buffer.getWrappedRangeForLine(S),N={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)(N,this._bufferService.cols)}};n.SelectionService=E=c([f(3,b.IBufferService),f(4,b.ICoreService),f(5,w.IMouseService),f(6,b.IOptionsService),f(7,w.IRenderService),f(8,w.ICoreBrowserService)],E)},4725:(x,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 c=i(8343);n.ICharSizeService=(0,c.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),n.IMouseService=(0,c.createDecorator)("MouseService"),n.IRenderService=(0,c.createDecorator)("RenderService"),n.ISelectionService=(0,c.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(x,n,i){var c=this&&this.__decorate||function(E,S,j,N){var T,M=arguments.length,D=M<3?S:N===null?N=Object.getOwnPropertyDescriptor(S,j):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,S,j,N);else for(var I=E.length-1;I>=0;I--)(T=E[I])&&(D=(M<3?T(D):M>3?T(S,j,D):T(S,j))||D);return M>3&&D&&Object.defineProperty(S,j,D),D},f=this&&this.__param||function(E,S){return function(j,N){S(j,N,E)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const l=i(7239),g=i(8055),_=i(8460),w=i(844),v=i(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),u=g.css.toColor("#000000"),b={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")],S=[0,95,135,175,215,255];for(let j=0;j<216;j++){const N=S[j/36%6|0],T=S[j/6%6|0],M=S[j%6];E.push({css:g.channels.toCss(N,T,M),rgba:g.channels.toRgba(N,T,M)})}for(let j=0;j<24;j++){const N=8+10*j;E.push({css:g.channels.toCss(N,N,N),rgba:g.channels.toRgba(N,N,N)})}return E})());let y=n.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:g.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:g.color.blend(h,b),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 S=this._colors;if(S.foreground=k(E.foreground,a),S.background=k(E.background,h),S.cursor=k(E.cursor,d),S.cursorAccent=k(E.cursorAccent,u),S.selectionBackgroundTransparent=k(E.selectionBackground,b),S.selectionBackgroundOpaque=g.color.blend(S.background,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundOpaque=g.color.blend(S.background,S.selectionInactiveBackgroundTransparent),S.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,S.selectionForeground===g.NULL_COLOR&&(S.selectionForeground=void 0),g.color.isOpaque(S.selectionBackgroundTransparent)&&(S.selectionBackgroundTransparent=g.color.opacity(S.selectionBackgroundTransparent,.3)),g.color.isOpaque(S.selectionInactiveBackgroundTransparent)&&(S.selectionInactiveBackgroundTransparent=g.color.opacity(S.selectionInactiveBackgroundTransparent,.3)),S.ansi=n.DEFAULT_ANSI_COLORS.slice(),S.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),S.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),S.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),S.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),S.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),S.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),S.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),S.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),S.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),S.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),S.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),S.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),S.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),S.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),S.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),S.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(S.ansi.length-16,E.extendedAnsi.length);for(let N=0;N<j;N++)S.ansi[N+16]=k(E.extendedAnsi[N],n.DEFAULT_ANSI_COLORS[N+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 S=0;S<this._restoreColors.ansi.length;++S)this._colors.ansi[S]=this._restoreColors.ansi[S]}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,S){if(E!==void 0)try{return g.css.toColor(E)}catch{}return S}n.ThemeService=y=c([f(0,v.IOptionsService)],y)},6349:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const c=i(8460),f=i(844);class l extends f.Disposable{constructor(_){super(),this._maxLength=_,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.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(_){if(this._maxLength===_)return;const w=new Array(_);for(let v=0;v<Math.min(_,this.length);v++)w[v]=this._array[this._getCyclicIndex(v)];this._array=w,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let w=this._length;w<_;w++)this._array[w]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,w){this._array[this._getCyclicIndex(_)]=w}push(_){this._array[this._getCyclicIndex(this._length)]=_,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(_,w,...v){if(w){for(let a=_;a<this._length-w;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+w)];this._length-=w,this.onDeleteEmitter.fire({index:_,amount:w})}for(let a=this._length-1;a>=_;a--)this._array[this._getCyclicIndex(a+v.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<v.length;a++)this._array[this._getCyclicIndex(_+a)]=v[a];if(v.length&&this.onInsertEmitter.fire({index:_,amount:v.length}),this._length+v.length>this._maxLength){const a=this._length+v.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=v.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,w,v){if(!(w<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+v<0)throw new Error("Cannot shift elements in list beyond index 0");if(v>0){for(let h=w-1;h>=0;h--)this.set(_+h+v,this.get(_+h));const a=_+w+v-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<w;a++)this.set(_+a+v,this.get(_+a))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}n.CircularList=l},1439:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(c,f=5){if(typeof c!="object")return c;const l=Array.isArray(c)?[]:{};for(const g in c)l[g]=f<=1?c[g]:c[g]&&i(c[g],f-1);return l}},8055:(x,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 c=i(6114);let f=0,l=0,g=0,_=0;var w,v,a,h,d;function u(y){const k=y.toString(16);return k.length<2?"0"+k:k}function b(y,k){return y<k?(k+.05)/(y+.05):(y+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(y){y.toCss=function(k,E,S,j){return j!==void 0?`#${u(k)}${u(E)}${u(S)}${u(j)}`:`#${u(k)}${u(E)}${u(S)}`},y.toRgba=function(k,E,S,j=255){return(k<<24|E<<16|S<<8|j)>>>0}})(w||(n.channels=w={})),(function(y){function k(E,S){return _=Math.round(255*S),[f,l,g]=d.toChannels(E.rgba),{css:w.toCss(f,l,g,_),rgba:w.toRgba(f,l,g,_)}}y.blend=function(E,S){if(_=(255&S.rgba)/255,_===1)return{css:S.css,rgba:S.rgba};const j=S.rgba>>24&255,N=S.rgba>>16&255,T=S.rgba>>8&255,M=E.rgba>>24&255,D=E.rgba>>16&255,I=E.rgba>>8&255;return f=M+Math.round((j-M)*_),l=D+Math.round((N-D)*_),g=I+Math.round((T-I)*_),{css:w.toCss(f,l,g),rgba:w.toRgba(f,l,g)}},y.isOpaque=function(E){return(255&E.rgba)==255},y.ensureContrastRatio=function(E,S,j){const N=d.ensureContrastRatio(E.rgba,S.rgba,j);if(N)return d.toColor(N>>24&255,N>>16&255,N>>8&255)},y.opaque=function(E){const S=(255|E.rgba)>>>0;return[f,l,g]=d.toChannels(S),{css:w.toCss(f,l,g),rgba:S}},y.opacity=k,y.multiplyOpacity=function(E,S){return _=255&E.rgba,k(E,_*S/255)},y.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(v||(n.color=v={})),(function(y){let k,E;if(!c.isNode){const S=document.createElement("canvas");S.width=1,S.height=1;const j=S.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}y.toColor=function(S){if(S.match(/#[\da-f]{3,8}/i))switch(S.length){case 4:return f=parseInt(S.slice(1,2).repeat(2),16),l=parseInt(S.slice(2,3).repeat(2),16),g=parseInt(S.slice(3,4).repeat(2),16),d.toColor(f,l,g);case 5:return f=parseInt(S.slice(1,2).repeat(2),16),l=parseInt(S.slice(2,3).repeat(2),16),g=parseInt(S.slice(3,4).repeat(2),16),_=parseInt(S.slice(4,5).repeat(2),16),d.toColor(f,l,g,_);case 7:return{css:S,rgba:(parseInt(S.slice(1),16)<<8|255)>>>0};case 9:return{css:S,rgba:parseInt(S.slice(1),16)>>>0}}const j=S.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 f=parseInt(j[1]),l=parseInt(j[2]),g=parseInt(j[3]),_=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(f,l,g,_);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=S,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[f,l,g,_]=k.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:w.toRgba(f,l,g,_),css:S}}})(a||(n.css=a={})),(function(y){function k(E,S,j){const N=E/255,T=S/255,M=j/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}y.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},y.relativeLuminance2=k})(h||(n.rgb=h={})),(function(y){function k(S,j,N){const T=S>>24&255,M=S>>16&255,D=S>>8&255;let I=j>>24&255,L=j>>16&255,F=j>>8&255,z=b(h.relativeLuminance2(I,L,F),h.relativeLuminance2(T,M,D));for(;z<N&&(I>0||L>0||F>0);)I-=Math.max(0,Math.ceil(.1*I)),L-=Math.max(0,Math.ceil(.1*L)),F-=Math.max(0,Math.ceil(.1*F)),z=b(h.relativeLuminance2(I,L,F),h.relativeLuminance2(T,M,D));return(I<<24|L<<16|F<<8|255)>>>0}function E(S,j,N){const T=S>>24&255,M=S>>16&255,D=S>>8&255;let I=j>>24&255,L=j>>16&255,F=j>>8&255,z=b(h.relativeLuminance2(I,L,F),h.relativeLuminance2(T,M,D));for(;z<N&&(I<255||L<255||F<255);)I=Math.min(255,I+Math.ceil(.1*(255-I))),L=Math.min(255,L+Math.ceil(.1*(255-L))),F=Math.min(255,F+Math.ceil(.1*(255-F))),z=b(h.relativeLuminance2(I,L,F),h.relativeLuminance2(T,M,D));return(I<<24|L<<16|F<<8|255)>>>0}y.ensureContrastRatio=function(S,j,N){const T=h.relativeLuminance(S>>8),M=h.relativeLuminance(j>>8);if(b(T,M)<N){if(M<T){const L=k(S,j,N),F=b(T,h.relativeLuminance(L>>8));if(F<N){const z=E(S,j,N);return F>b(T,h.relativeLuminance(z>>8))?L:z}return L}const D=E(S,j,N),I=b(T,h.relativeLuminance(D>>8));if(I<N){const L=k(S,j,N);return I>b(T,h.relativeLuminance(L>>8))?D:L}return D}},y.reduceLuminance=k,y.increaseLuminance=E,y.toChannels=function(S){return[S>>24&255,S>>16&255,S>>8&255,255&S]},y.toColor=function(S,j,N,T){return{css:w.toCss(S,j,N,T),rgba:w.toRgba(S,j,N,T)}}})(d||(n.rgba=d={})),n.toPaddedHex=u,n.contrastRatio=b},8969:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const c=i(844),f=i(2585),l=i(4348),g=i(7866),_=i(744),w=i(7302),v=i(6975),a=i(8460),h=i(1753),d=i(1480),u=i(7994),b=i(9282),y=i(5435),k=i(5981),E=i(2660);let S=!1;class j extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((T=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(T.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(T){for(const M in T)this.optionsService.options[M]=T[M]}constructor(T){super(),this._windowsWrappingHeuristics=this.register(new c.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 l.InstantiationService,this.optionsService=this.register(new w.OptionsService(T)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(v.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new y.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((M=>{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((M=>{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(((M,D)=>this._inputHandler.parse(M,D)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(T,M){this._writeBuffer.write(T,M)}writeSync(T,M){this._logService.logLevel<=f.LogLevelEnum.WARN&&!S&&(this._logService.warn("writeSync is unreliable and will be removed soon."),S=!0),this._writeBuffer.writeSync(T,M)}resize(T,M){isNaN(T)||isNaN(M)||(T=Math.max(T,_.MINIMUM_COLS),M=Math.max(M,_.MINIMUM_ROWS),this._bufferService.resize(T,M))}scroll(T,M=!1){this._bufferService.scroll(T,M)}scrollLines(T,M,D){this._bufferService.scrollLines(T,M,D)}scrollPages(T){this.scrollLines(T*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(T){const M=T-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(T,M){return this._inputHandler.registerEscHandler(T,M)}registerDcsHandler(T,M){return this._inputHandler.registerDcsHandler(T,M)}registerCsiHandler(T,M){return this._inputHandler.registerCsiHandler(T,M)}registerOscHandler(T,M){return this._inputHandler.registerOscHandler(T,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let T=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?T=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(T=!0),T?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const T=[];T.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),T.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const M of T)M.dispose()}))}}}n.CoreTerminal=j},8460:(x,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 c=0;c<this._listeners.length;c++)if(this._listeners[c]===i)return void this._listeners.splice(c,1)}}})),this._event}fire(i,c){const f=[];for(let l=0;l<this._listeners.length;l++)f.push(this._listeners[l]);for(let l=0;l<f.length;l++)f[l].call(void 0,i,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,c){return i((f=>c.fire(f)))}},5435:function(x,n,i){var c=this&&this.__decorate||function(z,A,P,O){var B,U=arguments.length,X=U<3?A:O===null?O=Object.getOwnPropertyDescriptor(A,P):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(z,A,P,O);else for(var V=z.length-1;V>=0;V--)(B=z[V])&&(X=(U<3?B(X):U>3?B(A,P,X):B(A,P))||X);return U>3&&X&&Object.defineProperty(A,P,X),X},f=this&&this.__param||function(z,A){return function(P,O){A(P,O,z)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const l=i(2584),g=i(7116),_=i(2015),w=i(844),v=i(482),a=i(8437),h=i(8460),d=i(643),u=i(511),b=i(3734),y=i(2585),k=i(6242),E=i(6351),S=i(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},N=131072;function T(z,A){if(z>24)return A.setWinLines||!1;switch(z){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 M;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(n.WindowsOptionsReportType=M={}));let D=0;class I extends w.Disposable{getAttrData(){return this._curAttrData}constructor(A,P,O,B,U,X,V,Z,q=new _.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=P,this._coreService=O,this._logService=B,this._optionsService=U,this._oscLinkService=X,this._coreMouseService=V,this._unicodeService=Z,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new v.StringToUtf32,this._utf8Decoder=new v.Utf8ToUtf32,this._workCell=new u.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 L(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._parser.setCsiHandlerFallback(((R,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(R),params:H.toArray()})})),this._parser.setEscHandlerFallback((R=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(R)})})),this._parser.setExecuteHandlerFallback((R=>{this._logService.debug("Unknown EXECUTE code: ",{code:R})})),this._parser.setOscHandlerFallback(((R,H,K)=>{this._logService.debug("Unknown OSC code: ",{identifier:R,action:H,data:K})})),this._parser.setDcsHandlerFallback(((R,H,K)=>{H==="HOOK"&&(K=K.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(R),action:H,payload:K})})),this._parser.setPrintHandler(((R,H,K)=>this.print(R,H,K))),this._parser.registerCsiHandler({final:"@"},(R=>this.insertChars(R))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(R=>this.scrollLeft(R))),this._parser.registerCsiHandler({final:"A"},(R=>this.cursorUp(R))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(R=>this.scrollRight(R))),this._parser.registerCsiHandler({final:"B"},(R=>this.cursorDown(R))),this._parser.registerCsiHandler({final:"C"},(R=>this.cursorForward(R))),this._parser.registerCsiHandler({final:"D"},(R=>this.cursorBackward(R))),this._parser.registerCsiHandler({final:"E"},(R=>this.cursorNextLine(R))),this._parser.registerCsiHandler({final:"F"},(R=>this.cursorPrecedingLine(R))),this._parser.registerCsiHandler({final:"G"},(R=>this.cursorCharAbsolute(R))),this._parser.registerCsiHandler({final:"H"},(R=>this.cursorPosition(R))),this._parser.registerCsiHandler({final:"I"},(R=>this.cursorForwardTab(R))),this._parser.registerCsiHandler({final:"J"},(R=>this.eraseInDisplay(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(R=>this.eraseInDisplay(R,!0))),this._parser.registerCsiHandler({final:"K"},(R=>this.eraseInLine(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(R=>this.eraseInLine(R,!0))),this._parser.registerCsiHandler({final:"L"},(R=>this.insertLines(R))),this._parser.registerCsiHandler({final:"M"},(R=>this.deleteLines(R))),this._parser.registerCsiHandler({final:"P"},(R=>this.deleteChars(R))),this._parser.registerCsiHandler({final:"S"},(R=>this.scrollUp(R))),this._parser.registerCsiHandler({final:"T"},(R=>this.scrollDown(R))),this._parser.registerCsiHandler({final:"X"},(R=>this.eraseChars(R))),this._parser.registerCsiHandler({final:"Z"},(R=>this.cursorBackwardTab(R))),this._parser.registerCsiHandler({final:"`"},(R=>this.charPosAbsolute(R))),this._parser.registerCsiHandler({final:"a"},(R=>this.hPositionRelative(R))),this._parser.registerCsiHandler({final:"b"},(R=>this.repeatPrecedingCharacter(R))),this._parser.registerCsiHandler({final:"c"},(R=>this.sendDeviceAttributesPrimary(R))),this._parser.registerCsiHandler({prefix:">",final:"c"},(R=>this.sendDeviceAttributesSecondary(R))),this._parser.registerCsiHandler({final:"d"},(R=>this.linePosAbsolute(R))),this._parser.registerCsiHandler({final:"e"},(R=>this.vPositionRelative(R))),this._parser.registerCsiHandler({final:"f"},(R=>this.hVPosition(R))),this._parser.registerCsiHandler({final:"g"},(R=>this.tabClear(R))),this._parser.registerCsiHandler({final:"h"},(R=>this.setMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(R=>this.setModePrivate(R))),this._parser.registerCsiHandler({final:"l"},(R=>this.resetMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(R=>this.resetModePrivate(R))),this._parser.registerCsiHandler({final:"m"},(R=>this.charAttributes(R))),this._parser.registerCsiHandler({final:"n"},(R=>this.deviceStatus(R))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(R=>this.deviceStatusPrivate(R))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(R=>this.softReset(R))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(R=>this.setCursorStyle(R))),this._parser.registerCsiHandler({final:"r"},(R=>this.setScrollRegion(R))),this._parser.registerCsiHandler({final:"s"},(R=>this.saveCursor(R))),this._parser.registerCsiHandler({final:"t"},(R=>this.windowOptions(R))),this._parser.registerCsiHandler({final:"u"},(R=>this.restoreCursor(R))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(R=>this.insertColumns(R))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(R=>this.deleteColumns(R))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(R=>this.selectProtected(R))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(R=>this.requestMode(R,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(R=>this.requestMode(R,!1))),this._parser.setExecuteHandler(l.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(l.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(l.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(l.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(l.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(l.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(l.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(l.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(l.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((R=>(this.setTitle(R),this.setIconName(R),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((R=>this.setIconName(R)))),this._parser.registerOscHandler(2,new k.OscHandler((R=>this.setTitle(R)))),this._parser.registerOscHandler(4,new k.OscHandler((R=>this.setOrReportIndexedColor(R)))),this._parser.registerOscHandler(8,new k.OscHandler((R=>this.setHyperlink(R)))),this._parser.registerOscHandler(10,new k.OscHandler((R=>this.setOrReportFgColor(R)))),this._parser.registerOscHandler(11,new k.OscHandler((R=>this.setOrReportBgColor(R)))),this._parser.registerOscHandler(12,new k.OscHandler((R=>this.setOrReportCursorColor(R)))),this._parser.registerOscHandler(104,new k.OscHandler((R=>this.restoreIndexedColor(R)))),this._parser.registerOscHandler(110,new k.OscHandler((R=>this.restoreFgColor(R)))),this._parser.registerOscHandler(111,new k.OscHandler((R=>this.restoreBgColor(R)))),this._parser.registerOscHandler(112,new k.OscHandler((R=>this.restoreCursorColor(R)))),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 R in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:R},(()=>this.selectCharset("("+R))),this._parser.registerEscHandler({intermediates:")",final:R},(()=>this.selectCharset(")"+R))),this._parser.registerEscHandler({intermediates:"*",final:R},(()=>this.selectCharset("*"+R))),this._parser.registerEscHandler({intermediates:"+",final:R},(()=>this.selectCharset("+"+R))),this._parser.registerEscHandler({intermediates:"-",final:R},(()=>this.selectCharset("-"+R))),this._parser.registerEscHandler({intermediates:".",final:R},(()=>this.selectCharset("."+R))),this._parser.registerEscHandler({intermediates:"/",final:R},(()=>this.selectCharset("/"+R)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((R=>(this._logService.error("Parsing error: ",R),R))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((R,H)=>this.requestStatusString(R,H))))}_preserveStack(A,P,O,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=O,this._parseStack.position=B}_logSlowResolvingAsync(A){this._logService.logLevel<=y.LogLevelEnum.WARN&&Promise.race([A,new Promise(((P,O)=>setTimeout((()=>O("#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 O,B=this._activeBuffer.x,U=this._activeBuffer.y,X=0;const V=this._parseStack.paused;if(V){if(O=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(O),O;B=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>N&&(X=this._parseStack.position+N)}if(this._logService.logLevel<=y.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<N&&(this._parseBuffer=new Uint32Array(Math.min(A.length,N))),V||this._dirtyRowTracker.clearRange(),A.length>N)for(let Z=X;Z<A.length;Z+=N){const q=Z+N<A.length?Z+N:A.length,R=typeof A=="string"?this._stringDecoder.decode(A.substring(Z,q),this._parseBuffer):this._utf8Decoder.decode(A.subarray(Z,q),this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,R))return this._preserveStack(B,U,R,Z),this._logSlowResolvingAsync(O),O}else if(!V){const Z=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,Z))return this._preserveStack(B,U,Z,0),this._logSlowResolvingAsync(O),O}this._activeBuffer.x===B&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,P,O){let B,U;const X=this._charsetService.charset,V=this._optionsService.rawOptions.screenReaderMode,Z=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,R=this._coreService.modes.insertMode,H=this._curAttrData;let K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&O-P>0&&K.getWidth(this._activeBuffer.x-1)===2&&K.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let W=P;W<O;++W){if(B=A[W],U=this._unicodeService.wcwidth(B),B<127&&X){const Y=X[String.fromCharCode(B)];Y&&(B=Y.charCodeAt(0))}if(V&&this._onA11yChar.fire((0,v.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=Z){if(q){for(;this._activeBuffer.x<Z;)K.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.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),K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=Z-1,U===2)continue}if(R&&(K.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(H),H),K.getWidth(Z-1)===2&&K.setCellFromCodePoint(Z-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),K.setCellFromCodePoint(this._activeBuffer.x++,B,U,H.fg,H.bg,H.extended),U>0)for(;--U;)K.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else K.getWidth(this._activeBuffer.x-1)?K.addCodepointToCell(this._activeBuffer.x-1,B):K.addCodepointToCell(this._activeBuffer.x-2,B)}O-P>0&&(K.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&&O-P>0&&K.getWidth(this._activeBuffer.x)===0&&!K.hasContent(this._activeBuffer.x)&&K.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.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,(O=>!T(O.params[0],this._optionsService.rawOptions.windowOptions)||P(O)))}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,O,B=!1,U=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);X.replaceCells(P,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),B&&(X.isWrapped=!1)}_resetBufferLine(A,P=!1){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);O&&(O.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),O.isWrapped=!1)}eraseInDisplay(A,P=!1){let O;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);O<this._bufferService.rows;O++)this._resetBufferLine(O,P);this._dirtyRowTracker.markDirty(O);break;case 1:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(O+1).isWrapped=!1);O--;)this._resetBufferLine(O,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(O=this._bufferService.rows,this._dirtyRowTracker.markDirty(O-1);O--;)this._resetBufferLine(O,P);this._dirtyRowTracker.markDirty(0);break;case 3:const B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,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 O=this._activeBuffer.ybase+this._activeBuffer.y,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;P--;)this._activeBuffer.lines.splice(U-1,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}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 O=this._activeBuffer.ybase+this._activeBuffer.y;let B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;P--;)this._activeBuffer.lines.splice(O,1),this._activeBuffer.lines.splice(B,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 O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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,O=new Uint32Array(P);for(let B=0;B<P;++B)O[B]=this._parser.precedingCodepoint;return this.print(O,0,O.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(l.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(l.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(l.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(l.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.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 O=this._coreService.decPrivateModes,{activeProtocol:B,activeEncoding:U}=this._coreMouseService,X=this._coreService,{buffers:V,cols:Z}=this._bufferService,{active:q,alt:R}=V,H=this._optionsService.rawOptions,K=ae=>ae?1:2,W=A.params[0];return Y=W,G=P?W===2?4:W===4?K(X.modes.insertMode):W===12?3:W===20?K(H.convertEol):0:W===1?K(O.applicationCursorKeys):W===3?H.windowOptions.setWinLines?Z===80?2:Z===132?1:0:0:W===6?K(O.origin):W===7?K(O.wraparound):W===8?3:W===9?K(B==="X10"):W===12?K(H.cursorBlink):W===25?K(!X.isCursorHidden):W===45?K(O.reverseWraparound):W===66?K(O.applicationKeypad):W===67?4:W===1e3?K(B==="VT200"):W===1002?K(B==="DRAG"):W===1003?K(B==="ANY"):W===1004?K(O.sendFocus):W===1005?4:W===1006?K(U==="SGR"):W===1015?4:W===1016?K(U==="SGR_PIXELS"):W===1048?1:W===47||W===1047||W===1049?K(q===R):W===2004?K(O.bracketedPasteMode):0,X.triggerDataEvent(`${l.C0.ESC}[${P?"":"?"}${Y};${G}$y`),!0;var Y,G}_updateAttrColor(A,P,O,B,U){return P===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([O,B,U])):P===5&&(A&=-50331904,A|=33554432|255&O),A}_extractColor(A,P,O){const B=[0,0,-1,0,0,0];let U=0,X=0;do{if(B[X+U]=A.params[P+X],A.hasSubParams(P+X)){const V=A.getSubParams(P+X);let Z=0;do B[1]===5&&(U=1),B[X+Z+1+U]=V[Z];while(++Z<V.length&&Z+X+1+U<B.length);break}if(B[1]===5&&X+U>=2||B[1]===2&&X+U>=5)break;B[1]&&(U=1)}while(++X+P<A.length&&X+U<B.length);for(let V=2;V<B.length;++V)B[V]===-1&&(B[V]=0);switch(B[0]){case 38:O.fg=this._updateAttrColor(O.fg,B[1],B[3],B[4],B[5]);break;case 48:O.bg=this._updateAttrColor(O.bg,B[1],B[3],B[4],B[5]);break;case 58:O.extended=O.extended.clone(),O.extended.underlineColor=this._updateAttrColor(O.extended.underlineColor,B[1],B[3],B[4],B[5])}return X}_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 O;const B=this._curAttrData;for(let U=0;U<P;U++)O=A.params[U],O>=30&&O<=37?(B.fg&=-50331904,B.fg|=16777216|O-30):O>=40&&O<=47?(B.bg&=-50331904,B.bg|=16777216|O-40):O>=90&&O<=97?(B.fg&=-50331904,B.fg|=16777224|O-90):O>=100&&O<=107?(B.bg&=-50331904,B.bg|=16777224|O-100):O===0?this._processSGR0(B):O===1?B.fg|=134217728:O===3?B.bg|=67108864:O===4?(B.fg|=268435456,this._processUnderline(A.hasSubParams(U)?A.getSubParams(U)[0]:1,B)):O===5?B.fg|=536870912:O===7?B.fg|=67108864:O===8?B.fg|=1073741824:O===9?B.fg|=2147483648:O===2?B.bg|=134217728:O===21?this._processUnderline(2,B):O===22?(B.fg&=-134217729,B.bg&=-134217729):O===23?B.bg&=-67108865:O===24?(B.fg&=-268435457,this._processUnderline(0,B)):O===25?B.fg&=-536870913:O===27?B.fg&=-67108865:O===28?B.fg&=-1073741825:O===29?B.fg&=2147483647:O===39?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):O===49?(B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):O===38||O===48||O===58?U+=this._extractColor(A,U,B):O===53?B.bg|=1073741824:O===55?B.bg&=-1073741825:O===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):O===100?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",O);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${P};${O}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const P=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${P};${O}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 O=P%2==1;return this._optionsService.options.cursorBlink=O,!0}setScrollRegion(A){const P=A.params[0]||1;let O;return(A.length<2||(O=A.params[1])>this._bufferService.rows||O===0)&&(O=this._bufferService.rows),O>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=O-1,this._setCursor(0,0)),!0}windowOptions(A){if(!T(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(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${l.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=[],O=A.split(";");for(;O.length>1;){const B=O.shift(),U=O.shift();if(/^\d+$/.exec(B)){const X=parseInt(B);if(F(X))if(U==="?")P.push({type:0,index:X});else{const V=(0,S.parseColor)(U);V&&P.push({type:1,index:X,color:V})}}}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 O=A.split(":");let B;const U=O.findIndex((X=>X.startsWith("id=")));return U!==-1&&(B=O[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,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 O=A.split(";");for(let B=0;B<O.length&&!(P>=this._specialColors.length);++B,++P)if(O[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const U=(0,S.parseColor)(O[B]);U&&this._onColor.fire([{type:1,index:this._specialColors[P],color:U}])}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=[],O=A.split(";");for(let B=0;B<O.length;++B)if(/^\d+$/.exec(O[B])){const U=parseInt(O[B]);F(U)&&P.push({type:2,index:U})}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 u.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 O=this._activeBuffer.ybase+this._activeBuffer.y+P,B=this._activeBuffer.lines.get(O);B&&(B.fill(A),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,P){const O=this._bufferService.buffer,B=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${U}${l.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${O.scrollTop+1};${O.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,P){this._dirtyRowTracker.markRangeDirty(A,P)}}n.InputHandler=I;let L=class{constructor(z){this._bufferService=z,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(z){z<this.start?this.start=z:z>this.end&&(this.end=z)}markRangeDirty(z,A){z>A&&(D=z,z=A,A=D),z<this.start&&(this.start=z),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(z){return 0<=z&&z<256}L=c([f(0,y.IBufferService)],L)},844:(x,n)=>{function i(c){for(const f of c)f.dispose();c.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 c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)===null||c===void 0||c.dispose(),this._value=void 0}},n.toDisposable=function(c){return{dispose:c}},n.disposeArray=i,n.getDisposeArrayDisposable=function(c){return{dispose:()=>i(c)}}},1505:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(f,l,g){this._data[f]||(this._data[f]={}),this._data[f][l]=g}get(f,l){return this._data[f]?this._data[f][l]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(c,f,l,g,_){this._data.get(c,f)||this._data.set(c,f,new i),this._data.get(c,f).set(l,g,_)}get(c,f,l,g){var _;return(_=this._data.get(c,f))===null||_===void 0?void 0:_.get(l,g)}clear(){this._data.clear()}}},6114:(x,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,c=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 f=i.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),n.isIpad=c==="iPad",n.isIphone=c==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),n.isLinux=c.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(i=this._search(this._getKey(c)),this._array.splice(i,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const f=this._getKey(c);if(f===void 0||(i=this._search(f),i===-1)||this._getKey(this._array[i])!==f)return!1;do if(this._array[i]===c)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===f);return!1}*getKeyIterator(c){if(this._array.length!==0&&(i=this._search(c),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===c))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===c)}forEachByKey(c,f){if(this._array.length!==0&&(i=this._search(c),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===c))do f(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===c)}values(){return[...this._array].values()}_search(c){let f=0,l=this._array.length-1;for(;l>=f;){let g=f+l>>1;const _=this._getKey(this._array[g]);if(_>c)l=g-1;else{if(!(_<c)){for(;g>0&&this._getKey(this._array[g-1])===c;)g--;return g}f=g+1}}return f}}},7226:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const c=i(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),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(_){this._idleCallback=void 0;let w=0,v=0,a=_.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),v=Math.max(w,v),h=_.timeRemaining(),1.5*v>h)return a-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-w))}ms`),void this._start();a=h}this.clear()}}class l extends f{_requestCallback(_){return setTimeout((()=>_(this._createDeadline(16))))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const w=Date.now()+_;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}n.PriorityTaskQueue=l,n.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:l,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const c=i(643);n.updateWindowsModeWrappedState=function(f){const l=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),g=l?.get(f.cols-1),_=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);_&&g&&(_.isWrapped=g[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&g[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(x,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 c}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){const l=new i;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}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 c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}constructor(l=0,g=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=g}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=c},9092:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const c=i(6349),f=i(7226),l=i(3734),g=i(8437),_=i(4634),w=i(511),v=i(643),a=i(4863),h=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(d,u,b){this._hasScrollback=d,this._optionsService=u,this._bufferService=b,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=w.CellData.fromCharData([0,v.NULL_CELL_CHAR,v.NULL_CELL_WIDTH,v.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,v.WHITESPACE_CELL_CHAR,v.WHITESPACE_CELL_WIDTH,v.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.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 l.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 l.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,u){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),u)}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 u=d+this._optionsService.rawOptions.scrollback;return u>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:u}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,u){const b=this.getNullCell(g.DEFAULT_ATTR_DATA);let y=0;const k=this._getCorrectBufferLength(u);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let S=0;S<this.lines.length;S++)y+=+this.lines.get(S).resize(d,b);let E=0;if(this._rows<u)for(let S=this._rows;S<u;S++)this.lines.length<u+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,b)):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,b)));else for(let S=this._rows;S>u;S--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const S=this.lines.length-k;S>0&&(this.lines.trimStart(S),this.ybase=Math.max(this.ybase-S,0),this.ydisp=Math.max(this.ydisp-S,0),this.savedY=Math.max(this.savedY-S,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,u-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(d,u),this._cols>d))for(let E=0;E<this.lines.length;E++)y+=+this.lines.get(E).resize(d,b);this._cols=d,this._rows=u,this._memoryCleanupQueue.clear(),y>.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 u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>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,u){this._cols!==d&&(d>this._cols?this._reflowLarger(d,u):this._reflowSmaller(d,u))}_reflowLarger(d,u){const b=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const y=(0,_.reflowLargerCreateNewLayout)(this.lines,b);(0,_.reflowLargerApplyNewLayout)(this.lines,y.layout),this._reflowLargerAdjustViewport(d,u,y.countRemoved)}}_reflowLargerAdjustViewport(d,u,b){const y=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=b;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new g.BufferLine(d,y))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(d,u){const b=this.getNullCell(g.DEFAULT_ATTR_DATA),y=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let S=this.lines.get(E);if(!S||!S.isWrapped&&S.getTrimmedLength()<=d)continue;const j=[S];for(;S.isWrapped&&E>0;)S=this.lines.get(--E),j.unshift(S);const N=this.ybase+this.y;if(N>=E&&N<E+j.length)continue;const T=j[j.length-1].getTrimmedLength(),M=(0,_.reflowSmallerGetNewLineLengths)(j,this._cols,d),D=M.length-j.length;let I;I=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 L=[];for(let B=0;B<D;B++){const U=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);L.push(U)}L.length>0&&(y.push({start:E+j.length+k,newLines:L}),k+=L.length),j.push(...L);let F=M.length-1,z=M[F];z===0&&(F--,z=M[F]);let A=j.length-D-1,P=T;for(;A>=0;){const B=Math.min(P,z);if(j[F]===void 0)break;if(j[F].copyCellsFrom(j[A],P-B,z-B,B,!0),z-=B,z===0&&(F--,z=M[F]),P-=B,P===0){A--;const U=Math.max(A,0);P=(0,_.getWrappedLineTrimmedLength)(j,U,this._cols)}}for(let B=0;B<j.length;B++)M[B]<d&&j[B].setCell(M[B],b);let O=D-I;for(;O-- >0;)this.ybase===0?this.y<u-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-u&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+D,this.ybase+u-1)}if(y.length>0){const E=[],S=[];for(let F=0;F<this.lines.length;F++)S.push(this.lines.get(F));const j=this.lines.length;let N=j-1,T=0,M=y[T];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let D=0;for(let F=Math.min(this.lines.maxLength-1,j+k-1);F>=0;F--)if(M&&M.start>N+D){for(let z=M.newLines.length-1;z>=0;z--)this.lines.set(F--,M.newLines[z]);F++,E.push({index:N+1,amount:M.newLines.length}),D+=M.newLines.length,M=y[++T]}else this.lines.set(F,S[N--]);let I=0;for(let F=E.length-1;F>=0;F--)E[F].index+=I,this.lines.onInsertEmitter.fire(E[F]),I+=E[F].amount;const L=Math.max(0,j+k-this.lines.maxLength);L>0&&this.lines.onTrimEmitter.fire(L)}}translateBufferLineToString(d,u,b=0,y){const k=this.lines.get(d);return k?k.translateToString(u,b,y):""}getWrappedRangeForLine(d){let u=d,b=d;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:u,last:b}}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 u=0;u<this.markers.length;u++)this.markers[u].line===d&&(this.markers[u].dispose(),this.markers.splice(u--,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 u=new a.Marker(d);return this.markers.push(u),u.register(this.lines.onTrim((b=>{u.line-=b,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((b=>{u.line>=b.index&&(u.line+=b.amount)}))),u.register(this.lines.onDelete((b=>{u.line>=b.index&&u.line<b.index+b.amount&&u.dispose(),u.line>b.index&&(u.line-=b.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const c=i(3734),f=i(511),l=i(643),g=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let _=0;class w{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const u=h||f.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let b=0;b<a;++b)this.setCell(b,u);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[l.CHAR_DATA_ATTR_INDEX],h[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[l.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 _=3*a,h.content=this._data[_+0],h.fg=this._data[_+1],h.bg=this._data[_+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,u,b,y){268435456&b&&(this._extendedAttrs[a]=y),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=u,this._data[3*a+2]=b}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,u){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length-a){const b=new f.CellData;for(let y=this.length-a-h-1;y>=0;--y)this.setCell(a+h+y,this.loadCell(a+y,b));for(let y=0;y<h;++y)this.setCell(a+y,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}deleteCells(a,h,d,u){if(a%=this.length,h<this.length-a){const b=new f.CellData;for(let y=0;y<this.length-a-h;++y)this.setCell(a+y,this.loadCell(a+h+y,b));for(let y=this.length-h;y<this.length;++y)this.setCell(y,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(a,h,d,u,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.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,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.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 u=new Uint32Array(d);u.set(this._data),this._data=u}for(let u=this.length;u<a;++u)this.setCell(u,h)}else{this._data=this._data.subarray(0,d);const u=Object.keys(this._combined);for(let y=0;y<u.length;y++){const k=parseInt(u[y],10);k>=a&&delete this._combined[k]}const b=Object.keys(this._extendedAttrs);for(let y=0;y<b.length;y++){const k=parseInt(b[y],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 w(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,u,b){const y=a._data;if(b)for(let E=u-1;E>=0;E--){for(let S=0;S<3;S++)this._data[3*(d+E)+S]=y[3*(h+E)+S];268435456&y[3*(h+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[h+E])}else for(let E=0;E<u;E++){for(let S=0;S<3;S++)this._data[3*(d+E)+S]=y[3*(h+E)+S];268435456&y[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 S=parseInt(k[E],10);S>=h&&(this._combined[S-h+d]=a._combined[S])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let u="";for(;h<d;){const b=this._data[3*h+0],y=2097151&b;u+=2097152&b?this._combined[h]:y?(0,g.stringFromCodePoint)(y):l.WHITESPACE_CELL_CHAR,h+=b>>22||1}return u}}n.BufferLine=w},4841:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,c){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 c*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(x,n)=>{function i(c,f,l){if(f===c.length-1)return c[f].getTrimmedLength();const g=!c[f].hasContent(l-1)&&c[f].getWidth(l-1)===1,_=c[f+1].getWidth(0)===2;return g&&_?l-1:l}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(c,f,l,g,_){const w=[];for(let v=0;v<c.length-1;v++){let a=v,h=c.get(++a);if(!h.isWrapped)continue;const d=[c.get(v)];for(;a<c.length&&h.isWrapped;)d.push(h),h=c.get(++a);if(g>=v&&g<a){v+=d.length-1;continue}let u=0,b=i(d,u,f),y=1,k=0;for(;y<d.length;){const S=i(d,y,f),j=S-k,N=l-b,T=Math.min(j,N);d[u].copyCellsFrom(d[y],k,b,T,!1),b+=T,b===l&&(u++,b=0),k+=T,k===S&&(y++,k=0),b===0&&u!==0&&d[u-1].getWidth(l-1)===2&&(d[u].copyCellsFrom(d[u-1],l-1,b++,1,!1),d[u-1].setCell(l-1,_))}d[u].replaceCells(b,l,_);let E=0;for(let S=d.length-1;S>0&&(S>u||d[S].getTrimmedLength()===0);S--)E++;E>0&&(w.push(v+d.length-E),w.push(E)),v+=d.length-1}return w},n.reflowLargerCreateNewLayout=function(c,f){const l=[];let g=0,_=f[g],w=0;for(let v=0;v<c.length;v++)if(_===v){const a=f[++g];c.onDeleteEmitter.fire({index:v-w,amount:a}),v+=a-1,w+=a,_=f[++g]}else l.push(v);return{layout:l,countRemoved:w}},n.reflowLargerApplyNewLayout=function(c,f){const l=[];for(let g=0;g<f.length;g++)l.push(c.get(f[g]));for(let g=0;g<l.length;g++)c.set(g,l[g]);c.length=f.length},n.reflowSmallerGetNewLineLengths=function(c,f,l){const g=[],_=c.map(((h,d)=>i(c,d,f))).reduce(((h,d)=>h+d));let w=0,v=0,a=0;for(;a<_;){if(_-a<l){g.push(_-a);break}w+=l;const h=i(c,v,f);w>h&&(w-=h,v++);const d=c[v].getWidth(w-1)===2;d&&w--;const u=d?l-1:l;g.push(u),a+=u}return g},n.getWrappedLineTrimmedLength=i},5295:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const c=i(8460),f=i(844),l=i(9092);class g extends f.Disposable{constructor(w,v){super(),this._optionsService=w,this._bufferService=v,this._onBufferActivate=this.register(new c.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 l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.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(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),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,v){this._normal.resize(w,v),this._alt.resize(w,v),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}n.BufferSet=g},511:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const c=i(482),f=i(643),l=i(3734);class g extends l.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new l.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const v=new g;return v.setFromCharData(w),v}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let v=!1;if(w[f.CHAR_DATA_CHAR_INDEX].length>2)v=!0;else if(w[f.CHAR_DATA_CHAR_INDEX].length===2){const a=w[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=w[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|w[f.CHAR_DATA_WIDTH_INDEX]<<22:v=!0}else v=!0}else this.content=w[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[f.CHAR_DATA_WIDTH_INDEX]<<22;v&&(this.combinedData=w[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=g},643:(x,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:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const c=i(8460),f=i(844);class l{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=l._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(_){return this._disposables.push(_),_}}n.Marker=l,l._nextId=1},7116:(x,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:(x,n)=>{var i,c,f;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(l){l.NUL="\0",l.SOH="",l.STX="",l.ETX="",l.EOT="",l.ENQ="",l.ACK="",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=`
24
- `,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="",l.SI="",l.DLE="",l.DC1="",l.DC2="",l.DC3="",l.DC4="",l.NAK="",l.SYN="",l.ETB="",l.CAN="",l.EM="",l.SUB="",l.ESC="\x1B",l.FS="",l.GS="",l.RS="",l.US="",l.SP=" ",l.DEL=""})(i||(n.C0=i={})),(function(l){l.PAD="€",l.HOP="",l.BPH="‚",l.NBH="ƒ",l.IND="„",l.NEL="…",l.SSA="†",l.ESA="‡",l.HTS="ˆ",l.HTJ="‰",l.VTS="Š",l.PLD="‹",l.PLU="Œ",l.RI="",l.SS2="Ž",l.SS3="",l.DCS="",l.PU1="‘",l.PU2="’",l.STS="“",l.CCH="”",l.MW="•",l.SPA="–",l.EPA="—",l.SOS="˜",l.SGCI="™",l.SCI="š",l.CSI="›",l.ST="œ",l.OSC="",l.PM="ž",l.APC="Ÿ"})(c||(n.C1=c={})),(function(l){l.ST=`${i.ESC}\\`})(f||(n.C1_ESCAPED=f={}))},7399:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const c=i(2584),f={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(l,g,_,w){const v={type:0,cancel:!1,key:void 0},a=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?v.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?v.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?v.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(v.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(l.altKey){v.key=c.C0.ESC+c.C0.DEL;break}v.key=c.C0.DEL;break;case 9:if(l.shiftKey){v.key=c.C0.ESC+"[Z";break}v.key=c.C0.HT,v.cancel=!0;break;case 13:v.key=l.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,v.cancel=!0;break;case 27:v.key=c.C0.ESC,l.altKey&&(v.key=c.C0.ESC+c.C0.ESC),v.cancel=!0;break;case 37:if(l.metaKey)break;a?(v.key=c.C0.ESC+"[1;"+(a+1)+"D",v.key===c.C0.ESC+"[1;3D"&&(v.key=c.C0.ESC+(_?"b":"[1;5D"))):v.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(l.metaKey)break;a?(v.key=c.C0.ESC+"[1;"+(a+1)+"C",v.key===c.C0.ESC+"[1;3C"&&(v.key=c.C0.ESC+(_?"f":"[1;5C"))):v.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(l.metaKey)break;a?(v.key=c.C0.ESC+"[1;"+(a+1)+"A",_||v.key!==c.C0.ESC+"[1;3A"||(v.key=c.C0.ESC+"[1;5A")):v.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(l.metaKey)break;a?(v.key=c.C0.ESC+"[1;"+(a+1)+"B",_||v.key!==c.C0.ESC+"[1;3B"||(v.key=c.C0.ESC+"[1;5B")):v.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(v.key=c.C0.ESC+"[2~");break;case 46:v.key=a?c.C0.ESC+"[3;"+(a+1)+"~":c.C0.ESC+"[3~";break;case 36:v.key=a?c.C0.ESC+"[1;"+(a+1)+"H":g?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:v.key=a?c.C0.ESC+"[1;"+(a+1)+"F":g?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:l.shiftKey?v.type=2:l.ctrlKey?v.key=c.C0.ESC+"[5;"+(a+1)+"~":v.key=c.C0.ESC+"[5~";break;case 34:l.shiftKey?v.type=3:l.ctrlKey?v.key=c.C0.ESC+"[6;"+(a+1)+"~":v.key=c.C0.ESC+"[6~";break;case 112:v.key=a?c.C0.ESC+"[1;"+(a+1)+"P":c.C0.ESC+"OP";break;case 113:v.key=a?c.C0.ESC+"[1;"+(a+1)+"Q":c.C0.ESC+"OQ";break;case 114:v.key=a?c.C0.ESC+"[1;"+(a+1)+"R":c.C0.ESC+"OR";break;case 115:v.key=a?c.C0.ESC+"[1;"+(a+1)+"S":c.C0.ESC+"OS";break;case 116:v.key=a?c.C0.ESC+"[15;"+(a+1)+"~":c.C0.ESC+"[15~";break;case 117:v.key=a?c.C0.ESC+"[17;"+(a+1)+"~":c.C0.ESC+"[17~";break;case 118:v.key=a?c.C0.ESC+"[18;"+(a+1)+"~":c.C0.ESC+"[18~";break;case 119:v.key=a?c.C0.ESC+"[19;"+(a+1)+"~":c.C0.ESC+"[19~";break;case 120:v.key=a?c.C0.ESC+"[20;"+(a+1)+"~":c.C0.ESC+"[20~";break;case 121:v.key=a?c.C0.ESC+"[21;"+(a+1)+"~":c.C0.ESC+"[21~";break;case 122:v.key=a?c.C0.ESC+"[23;"+(a+1)+"~":c.C0.ESC+"[23~";break;case 123:v.key=a?c.C0.ESC+"[24;"+(a+1)+"~":c.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(_&&!w||!l.altKey||l.metaKey)!_||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?v.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(v.key=c.C0.US),l.key==="@"&&(v.key=c.C0.NUL)):l.keyCode===65&&(v.type=1);else{const h=f[l.keyCode],d=h?.[l.shiftKey?1:0];if(d)v.key=c.C0.ESC+d;else if(l.keyCode>=65&&l.keyCode<=90){const u=l.ctrlKey?l.keyCode-64:l.keyCode+32;let b=String.fromCharCode(u);l.shiftKey&&(b=b.toUpperCase()),v.key=c.C0.ESC+b}else if(l.keyCode===32)v.key=c.C0.ESC+(l.ctrlKey?c.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let u=l.code.slice(3,4);l.shiftKey||(u=u.toLowerCase()),v.key=c.C0.ESC+u,v.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?v.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?v.key=c.C0.NUL:l.keyCode>=51&&l.keyCode<=55?v.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?v.key=c.C0.DEL:l.keyCode===219?v.key=c.C0.ESC:l.keyCode===220?v.key=c.C0.FS:l.keyCode===221&&(v.key=c.C0.GS)}return v}},482:(x,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,c=0,f=i.length){let l="";for(let g=c;g<f;++g){let _=i[g];_>65535?(_-=65536,l+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):l+=String.fromCharCode(_)}return l},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,c){const f=i.length;if(!f)return 0;let l=0,g=0;if(this._interim){const _=i.charCodeAt(g++);56320<=_&&_<=57343?c[l++]=1024*(this._interim-55296)+_-56320+65536:(c[l++]=this._interim,c[l++]=_),this._interim=0}for(let _=g;_<f;++_){const w=i.charCodeAt(_);if(55296<=w&&w<=56319){if(++_>=f)return this._interim=w,l;const v=i.charCodeAt(_);56320<=v&&v<=57343?c[l++]=1024*(w-55296)+v-56320+65536:(c[l++]=w,c[l++]=v)}else w!==65279&&(c[l++]=w)}return l}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,c){const f=i.length;if(!f)return 0;let l,g,_,w,v=0,a=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(224&y)==192?31:(240&y)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)y<<=6,y|=k;const S=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=S-E;for(;h<j;){if(h>=f)return 0;if(k=i[h++],(192&k)!=128){h--,b=!0;break}this.interim[E++]=k,y<<=6,y|=63&k}b||(S===2?y<128?h--:c[v++]=y:S===3?y<2048||y>=55296&&y<=57343||y===65279||(c[v++]=y):y<65536||y>1114111||(c[v++]=y)),this.interim.fill(0)}const d=f-4;let u=h;for(;u<f;){for(;!(!(u<d)||128&(l=i[u])||128&(g=i[u+1])||128&(_=i[u+2])||128&(w=i[u+3]));)c[v++]=l,c[v++]=g,c[v++]=_,c[v++]=w,u+=4;if(l=i[u++],l<128)c[v++]=l;else if((224&l)==192){if(u>=f)return this.interim[0]=l,v;if(g=i[u++],(192&g)!=128){u--;continue}if(a=(31&l)<<6|63&g,a<128){u--;continue}c[v++]=a}else if((240&l)==224){if(u>=f)return this.interim[0]=l,v;if(g=i[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,v;if(_=i[u++],(192&_)!=128){u--;continue}if(a=(15&l)<<12|(63&g)<<6|63&_,a<2048||a>=55296&&a<=57343||a===65279)continue;c[v++]=a}else if((248&l)==240){if(u>=f)return this.interim[0]=l,v;if(g=i[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,v;if(_=i[u++],(192&_)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,this.interim[2]=_,v;if(w=i[u++],(192&w)!=128){u--;continue}if(a=(7&l)<<18|(63&g)<<12|(63&_)<<6|63&w,a<65536||a>1114111)continue;c[v++]=a}}return v}}},225:(x,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]],c=[[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 f;n.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let l=0;l<i.length;++l)f.fill(0,i[l][0],i[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?f[l]:(function(g,_){let w,v=0,a=_.length-1;if(g<_[0][0]||g>_[a][1])return!1;for(;a>=v;)if(w=v+a>>1,g>_[w][1])v=w+1;else{if(!(g<_[w][0]))return!0;a=w-1}return!1})(l,c)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const c=i(8460),f=i(844);class l extends f.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(_,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let v;for(this._isSyncWriting=!0;v=this._writeBuffer.shift();){this._action(v);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,w){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+=_.length,this._writeBuffer.push(_),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(w)}_innerWrite(_=0,w=!0){const v=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,w);if(h){const u=b=>Date.now()-v>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(v,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(u)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-v>=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=l},5941:(x,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})$/,c=/^[\da-f]+$/;function f(l,g){const _=l.toString(16),w=_.length<2?"0"+_:_;switch(g){case 4:return _[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}n.parseColor=function(l){if(!l)return;let g=l.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const _=i.exec(g);if(_){const w=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/w*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/w*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/w*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),c.exec(g)&&[3,6,9,12].includes(g.length))){const _=g.length/3,w=[0,0,0];for(let v=0;v<3;++v){const a=parseInt(g.slice(_*v,_*v+_),16);w[v]=_===1?a<<4:_===2?a:_===3?a>>4:a>>8}return w}},n.toRgbString=function(l,g=16){const[_,w,v]=l;return`rgb:${f(_,g)}/${f(w,g)}/${f(v,g)}`}},5770:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const c=i(482),f=i(8742),l=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,v){this._handlers[w]===void 0&&(this._handlers[w]=[]);const a=this._handlers[w];return a.push(v),{dispose:()=>{const h=a.indexOf(v);h!==-1&&a.splice(h,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(w,v){if(this.reset(),this._ident=w,this._active=this._handlers[w]||g,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(v);else this._handlerFb(this._ident,"HOOK",v)}put(w,v,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(w,v,a);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(w,v,a))}unhook(w,v=!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=v,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;h>=0&&(a=this._active[h].unhook(w),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",w);this._active=g,this._ident=0}};const _=new f.Params;_.addParam(0),n.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=_,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():_,this._data="",this._hitLimit=!1}put(w,v,a){this._hitLimit||(this._data+=(0,c.utf32ToString)(w,v,a),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let v=!1;if(this._hitLimit)v=!1;else if(w&&(v=this._handler(this._data,this._params),v instanceof Promise))return v.then((a=>(this._params=_,this._data="",this._hitLimit=!1,a)));return this._params=_,this._data="",this._hitLimit=!1,v}}},2015:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const c=i(844),f=i(8742),l=i(6242),g=i(6351);class _{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,u,b){this.table[d<<8|h]=u<<4|b}addMany(h,d,u,b){for(let y=0;y<h.length;y++)this.table[d<<8|h[y]]=u<<4|b}}n.TransitionTable=_;const w=160;n.VT500_TRANSITION_TABLE=(function(){const a=new _(4095),h=Array.apply(null,Array(256)).map(((E,S)=>S)),d=(E,S)=>h.slice(E,S),u=d(32,127),b=d(0,24);b.push(25),b.push.apply(b,d(28,32));const y=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(u,0,2,0),y)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(b,0,3,0),a.addMany(b,1,3,1),a.add(127,1,0,1),a.addMany(b,8,0,8),a.addMany(b,3,3,3),a.add(127,3,0,3),a.addMany(b,4,3,4),a.add(127,4,0,4),a.addMany(b,6,3,6),a.addMany(b,5,3,5),a.add(127,5,0,5),a.addMany(b,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(u,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(u,7,0,7),a.addMany(b,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(b,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(b,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(b,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(b,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(b,13,13,13),a.addMany(u,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(w,0,2,0),a.add(w,8,5,8),a.add(w,6,0,6),a.add(w,11,0,11),a.add(w,13,13,13),a})();class v extends c.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 f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,u,b)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,u)=>{},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,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new l.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,d=[64,126]){let u=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=h.prefix.charCodeAt(0),u&&60>u||u>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 y=0;y<h.intermediates.length;++y){const k=h.intermediates.charCodeAt(y);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const b=h.final.charCodeAt(0);if(d[0]>b||b>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return u<<=8,u|=b,u}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 u=this._identifier(h,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const b=this._escHandlers[u];return b.push(d),{dispose:()=>{const y=b.indexOf(d);y!==-1&&b.splice(y,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 u=this._identifier(h);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const b=this._csiHandlers[u];return b.push(d),{dispose:()=>{const y=b.indexOf(d);y!==-1&&b.splice(y,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,u,b,y){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=u,this._parseStack.transition=b,this._parseStack.chunkPos=y}parse(h,d,u){let b,y=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(u===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const S=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&j>-1){for(;j>=0&&(b=S[j](this._params),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 4:if(u===!1&&j>-1){for(;j>=0&&(b=S[j](),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 6:if(y=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(y!==24&&y!==26,u),b)return b;y===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(y=h[this._parseStack.chunkPos],b=this._oscParser.end(y!==24&&y!==26,u),b)return b;y===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 S=E;S<d;++S){switch(y=h[S],k=this._transitions.table[this.currentState<<8|(y<160?y:w)],k>>4){case 2:for(let D=S+1;;++D){if(D>=d||(y=h[D])<32||y>126&&y<w){this._printHandler(h,S,D),S=D-1;break}if(++D>=d||(y=h[D])<32||y>126&&y<w){this._printHandler(h,S,D),S=D-1;break}if(++D>=d||(y=h[D])<32||y>126&&y<w){this._printHandler(h,S,D),S=D-1;break}if(++D>=d||(y=h[D])<32||y>126&&y<w){this._printHandler(h,S,D),S=D-1;break}}break;case 3:this._executeHandlers[y]?this._executeHandlers[y]():this._executeHandlerFb(y),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:S,code:y,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|y];let N=j?j.length-1:-1;for(;N>=0&&(b=j[N](this._params),b!==!0);N--)if(b instanceof Promise)return this._preserveStack(3,j,N,k,S),b;N<0&&this._csiHandlerFb(this._collect<<8|y,this._params),this.precedingCodepoint=0;break;case 8:do switch(y){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(y-48)}while(++S<d&&(y=h[S])>47&&y<60);S--;break;case 9:this._collect<<=8,this._collect|=y;break;case 10:const T=this._escHandlers[this._collect<<8|y];let M=T?T.length-1:-1;for(;M>=0&&(b=T[M](),b!==!0);M--)if(b instanceof Promise)return this._preserveStack(4,T,M,k,S),b;M<0&&this._escHandlerFb(this._collect<<8|y),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|y,this._params);break;case 13:for(let D=S+1;;++D)if(D>=d||(y=h[D])===24||y===26||y===27||y>127&&y<w){this._dcsParser.put(h,S,D),S=D-1;break}break;case 14:if(b=this._dcsParser.unhook(y!==24&&y!==26),b)return this._preserveStack(6,[],0,k,S),b;y===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=S+1;;D++)if(D>=d||(y=h[D])<32||y>127&&y<w){this._oscParser.put(h,S,D),S=D-1;break}break;case 6:if(b=this._oscParser.end(y!==24&&y!==26),b)return this._preserveStack(5,[],0,k,S),b;y===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=v},6242:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const c=i(5770),f=i(482),l=[];n.OscParser=class{constructor(){this._state=0,this._active=l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,_){this._handlers[g]===void 0&&(this._handlers[g]=[]);const w=this._handlers[g];return w.push(_),{dispose:()=>{const v=w.indexOf(_);v!==-1&&w.splice(v,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=l}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=l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||l,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,_,w){if(this._active.length)for(let v=this._active.length-1;v>=0;v--)this._active[v].put(g,_,w);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(g,_,w))}start(){this.reset(),this._state=1}put(g,_,w){if(this._state!==3){if(this._state===1)for(;_<w;){const v=g[_++];if(v===59){this._state=2,this._start();break}if(v<48||57<v)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+v-48}this._state===2&&w-_>0&&this._put(g,_,w)}}end(g,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,v=this._active.length-1,a=!1;if(this._stack.paused&&(v=this._stack.loopPosition-1,w=_,a=this._stack.fallThrough,this._stack.paused=!1),!a&&w===!1){for(;v>=0&&(w=this._active[v].end(g),w!==!0);v--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=v,this._stack.fallThrough=!1,w;v--}for(;v>=0;v--)if(w=this._active[v].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=v,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",g);this._active=l,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,_,w){this._hitLimit||(this._data+=(0,f.utf32ToString)(g,_,w),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let _=!1;if(this._hitLimit)_=!1;else if(g&&(_=this._handler(this._data),_ instanceof Promise))return _.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,_}}},8742:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class c{static fromArray(l){const g=new c;if(!l.length)return g;for(let _=Array.isArray(l[0])?1:0;_<l.length;++_){const w=l[_];if(Array.isArray(w))for(let v=0;v<w.length;++v)g.addSubParam(w[v]);else g.addParam(w)}return g}constructor(l=32,g=32){if(this.maxLength=l,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const l=new c(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){const l=[];for(let g=0;g<this.length;++g){l.push(this.params[g]);const _=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-_>0&&l.push(Array.prototype.slice.call(this._subParams,_,w))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>i?i:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>i?i:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const g=this._subParamsIdx[l]>>8,_=255&this._subParamsIdx[l];return _-g>0?this._subParams.subarray(g,_):null}getSubParamsAll(){const l={};for(let g=0;g<this.length;++g){const _=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-_>0&&(l[g]=this._subParams.slice(_,w))}return l}addDigit(l){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,w=_[g-1];_[g-1]=~w?Math.min(10*w+l,i):l}}n.Params=c},5741:(x,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,c){const f={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(f),c.dispose=()=>this._wrappedAddonDispose(f),c.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let c=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===i){c=f;break}if(c===-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(c,1)}}},8771:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const c=i(3785),f=i(511);n.BufferApiView=class{constructor(l,g){this._buffer=l,this.type=g}init(l){return this._buffer=l,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(l){const g=this._buffer.lines.get(l);if(g)return new c.BufferLineApiView(g)}getNullCell(){return new f.CellData}}},3785:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const c=i(511);n.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,l){if(!(f<0||f>=this._line.length))return l?(this._line.loadCell(f,l),l):this._line.loadCell(f,new c.CellData)}translateToString(f,l,g){return this._line.translateToString(f,l,g)}}},8285:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const c=i(8771),f=i(8460),l=i(844);class g extends l.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.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:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,c){return this._core.registerCsiHandler(i,(f=>c(f.toArray())))}addCsiHandler(i,c){return this.registerCsiHandler(i,c)}registerDcsHandler(i,c){return this._core.registerDcsHandler(i,((f,l)=>c(f,l.toArray())))}addDcsHandler(i,c){return this.registerDcsHandler(i,c)}registerEscHandler(i,c){return this._core.registerEscHandler(i,c)}addEscHandler(i,c){return this.registerEscHandler(i,c)}registerOscHandler(i,c){return this._core.registerOscHandler(i,c)}addOscHandler(i,c){return this.registerOscHandler(i,c)}}},7090:(x,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(x,n,i){var c=this&&this.__decorate||function(a,h,d,u){var b,y=arguments.length,k=y<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(y<3?b(k):y>3?b(h,d,k):b(h,d))||k);return y>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const l=i(8460),g=i(844),_=i(5295),w=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let v=n.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new l.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 _.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 u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===a.fg&&u.getBg(0)===a.bg||(u=d.getBlankLine(a,h),this._cachedBlankLine=u),u.isWrapped=h;const b=d.ybase+d.scrollTop,y=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;y===d.lines.length-1?k?d.lines.recycle().copyFrom(u):d.lines.push(u.clone()):d.lines.splice(y+1,0,u.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=y-b+1;d.lines.shiftElements(b+1,k-1,-1),d.lines.set(y,u.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const u=this.buffer;if(a<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else a+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const b=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+a,u.ybase),0),b!==u.ydisp&&(h||this._onScroll.fire(u.ydisp))}};n.BufferService=v=c([f(0,w.IOptionsService)],v)},7994:(x,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,c){this._charsets[i]=c,this.glevel===i&&(this.charset=c)}}},1753:function(x,n,i){var c=this&&this.__decorate||function(u,b,y,k){var E,S=arguments.length,j=S<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,b,y,k);else for(var N=u.length-1;N>=0;N--)(E=u[N])&&(j=(S<3?E(j):S>3?E(b,y,j):E(b,y))||j);return S>3&&j&&Object.defineProperty(b,y,j),j},f=this&&this.__param||function(u,b){return function(y,k){b(y,k,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const l=i(2585),g=i(8460),_=i(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:u=>u.button!==4&&u.action===1&&(u.ctrl=!1,u.alt=!1,u.shift=!1,!0)},VT200:{events:19,restrict:u=>u.action!==32},DRAG:{events:23,restrict:u=>u.action!==32||u.button!==3},ANY:{events:31,restrict:u=>!0}};function v(u,b){let y=(u.ctrl?16:0)|(u.shift?4:0)|(u.alt?8:0);return u.button===4?(y|=64,y|=u.action):(y|=3&u.button,4&u.button&&(y|=64),8&u.button&&(y|=128),u.action===32?y|=32:u.action!==0||b||(y|=3)),y}const a=String.fromCharCode,h={DEFAULT:u=>{const b=[v(u,!1)+32,u.col+32,u.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:u=>{const b=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${v(u,!0)};${u.col};${u.row}${b}`},SGR_PIXELS:u=>{const b=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${v(u,!0)};${u.x};${u.y}${b}`}};let d=n.CoreMouseService=class extends _.Disposable{constructor(u,b){super(),this._bufferService=u,this._coreService=b,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 y of Object.keys(w))this.addProtocol(y,w[y]);for(const y of Object.keys(h))this.addEncoding(y,h[y]);this.reset()}addProtocol(u,b){this._protocols[u]=b}addEncoding(u,b){this._encodings[u]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(u){if(!this._protocols[u])throw new Error(`unknown protocol "${u}"`);this._activeProtocol=u,this._onProtocolChange.fire(this._protocols[u].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(u){if(!this._encodings[u])throw new Error(`unknown encoding "${u}"`);this._activeEncoding=u}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(u){if(u.col<0||u.col>=this._bufferService.cols||u.row<0||u.row>=this._bufferService.rows||u.button===4&&u.action===32||u.button===3&&u.action!==32||u.button!==4&&(u.action===2||u.action===3)||(u.col++,u.row++,u.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,u,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(u))return!1;const b=this._encodings[this._activeEncoding](u);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=u,!0}explainEvents(u){return{down:!!(1&u),up:!!(2&u),drag:!!(4&u),move:!!(8&u),wheel:!!(16&u)}}_equalEvents(u,b,y){if(y){if(u.x!==b.x||u.y!==b.y)return!1}else if(u.col!==b.col||u.row!==b.row)return!1;return u.button===b.button&&u.action===b.action&&u.ctrl===b.ctrl&&u.alt===b.alt&&u.shift===b.shift}};n.CoreMouseService=d=c([f(0,l.IBufferService),f(1,l.ICoreService)],d)},6975:function(x,n,i){var c=this&&this.__decorate||function(d,u,b,y){var k,E=arguments.length,S=E<3?u:y===null?y=Object.getOwnPropertyDescriptor(u,b):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(d,u,b,y);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(S=(E<3?k(S):E>3?k(u,b,S):k(u,b))||S);return E>3&&S&&Object.defineProperty(u,b,S),S},f=this&&this.__param||function(d,u){return function(b,y){u(b,y,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const l=i(1439),g=i(8460),_=i(844),w=i(2585),v=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 _.Disposable{constructor(d,u,b){super(),this._bufferService=d,this._logService=u,this._optionsService=b,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,l.clone)(v),this.decPrivateModes=(0,l.clone)(a)}reset(){this.modes=(0,l.clone)(v),this.decPrivateModes=(0,l.clone)(a)}triggerDataEvent(d,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),u&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((y=>y.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((u=>u.charCodeAt(0))))),this._onBinary.fire(d))}};n.CoreService=h=c([f(0,w.IBufferService),f(1,w.ILogService),f(2,w.IOptionsService)],h)},9074:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const c=i(8055),f=i(8460),l=i(844),g=i(6106);let _=0,w=0;class v extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const u=new a(d);if(u){const b=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),b.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,u,b){var y,k,E;let S=0,j=0;for(const N of this._decorations.getKeyIterator(u))S=(y=N.options.x)!==null&&y!==void 0?y:0,j=S+((k=N.options.width)!==null&&k!==void 0?k:1),d>=S&&d<j&&(!b||((E=N.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&(yield N)}forEachDecorationAtCell(d,u,b,y){this._decorations.forEachByKey(u,(k=>{var E,S,j;_=(E=k.options.x)!==null&&E!==void 0?E:0,w=_+((S=k.options.width)!==null&&S!==void 0?S:1),d>=_&&d<w&&(!b||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&y(k)}))}}n.DecorationService=v;class a extends l.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.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:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const c=i(2585),f=i(8343);class l{constructor(..._){this._entries=new Map;for(const[w,v]of _)this.set(w,v)}set(_,w){const v=this._entries.get(_);return this._entries.set(_,w),v}forEach(_){for(const[w,v]of this._entries.entries())_(w,v)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}n.ServiceCollection=l,n.InstantiationService=class{constructor(){this._services=new l,this._services.set(c.IInstantiationService,this)}setService(g,_){this._services.set(g,_)}getService(g){return this._services.get(g)}createInstance(g,..._){const w=(0,f.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),v=[];for(const h of w){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);v.push(d)}const a=w.length>0?w[0].index:_.length;if(_.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${_.length} static arguments`);return new g(..._,...v)}}},7866:function(x,n,i){var c=this&&this.__decorate||function(a,h,d,u){var b,y=arguments.length,k=y<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(y<3?b(k):y>3?b(h,d,k):b(h,d))||k);return y>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const l=i(844),g=i(2585),_={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,v=n.LogService=class extends l.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()))),w=this}_updateLogLevel(){this._logLevel=_[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,u;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,a,h)}debug(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,a,h)}info(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.INFO&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,a,h)}warn(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.WARN&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,a,h)}error(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,a,h)}};n.LogService=v=c([f(0,g.IOptionsService)],v),n.setTraceLogger=function(a){w=a},n.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const u=d.value;d.value=function(...b){if(w.logLevel!==g.LogLevelEnum.TRACE)return u.apply(this,b);w.trace(`GlyphRenderer#${u.name}(${b.map((k=>JSON.stringify(k))).join(", ")})`);const y=u.apply(this,b);return w.trace(`GlyphRenderer#${u.name} return`,y),y}}},7302:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const c=i(8460),f=i(844),l=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:l.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 _ extends f.Disposable{constructor(v){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},n.DEFAULT_OPTIONS);for(const h in v)if(h in a)try{const d=v[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(v,a){return this.onOptionChange((h=>{h===v&&a(this.rawOptions[v])}))}onMultipleOptionChange(v,a){return this.onOptionChange((h=>{v.indexOf(h)!==-1&&a()}))}_setupOptions(){const v=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:v.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(v,a){switch(v){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[v]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${v}`);break;case"wordSeparator":a||(a=n.DEFAULT_OPTIONS[v]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:n.DEFAULT_OPTIONS[v];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${v} 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(`${v} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${v} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${v} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}n.OptionsService=_},2660:function(x,n,i){var c=this&&this.__decorate||function(_,w,v,a){var h,d=arguments.length,u=d<3?w:a===null?a=Object.getOwnPropertyDescriptor(w,v):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(_,w,v,a);else for(var b=_.length-1;b>=0;b--)(h=_[b])&&(u=(d<3?h(u):d>3?h(w,v,u):h(w,v))||u);return d>3&&u&&Object.defineProperty(w,v,u),u},f=this&&this.__param||function(_,w){return function(v,a){w(v,a,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const l=i(2585);let g=n.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const w=this._bufferService.buffer;if(_.id===void 0){const b=w.addMarker(w.ybase+w.y),y={data:_,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(y,b))),this._dataByLinkId.set(y.id,y),y.id}const v=_,a=this._getEntryIdKey(v),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,w.ybase+w.y),h.id;const d=w.addMarker(w.ybase+w.y),u={id:this._nextId++,key:this._getEntryIdKey(v),data:v,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(u,d))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(_,w){const v=this._dataByLinkId.get(_);if(v&&v.lines.every((a=>a.line!==w))){const a=this._bufferService.buffer.addMarker(w);v.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(v,a)))}}getLinkData(_){var w;return(w=this._dataByLinkId.get(_))===null||w===void 0?void 0:w.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,w){const v=_.lines.indexOf(w);v!==-1&&(_.lines.splice(v,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};n.OscLinkService=g=c([f(0,l.IBufferService)],g)},8343:(x,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",c="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(f){return f[c]||[]},n.createDecorator=function(f){if(n.serviceRegistry.has(f))return n.serviceRegistry.get(f);const l=function(g,_,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(v,a,h){a[i]===a?a[c].push({id:v,index:h}):(a[c]=[{id:v,index:h}],a[i]=a)})(l,g,w)};return l.toString=()=>f,n.serviceRegistry.set(f,l),l}},2585:(x,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 c=i(8343);var f;n.IBufferService=(0,c.createDecorator)("BufferService"),n.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),n.ICoreService=(0,c.createDecorator)("CoreService"),n.ICharsetService=(0,c.createDecorator)("CharsetService"),n.IInstantiationService=(0,c.createDecorator)("InstantiationService"),(function(l){l[l.TRACE=0]="TRACE",l[l.DEBUG=1]="DEBUG",l[l.INFO=2]="INFO",l[l.WARN=3]="WARN",l[l.ERROR=4]="ERROR",l[l.OFF=5]="OFF"})(f||(n.LogLevelEnum=f={})),n.ILogService=(0,c.createDecorator)("LogService"),n.IOptionsService=(0,c.createDecorator)("OptionsService"),n.IOscLinkService=(0,c.createDecorator)("OscLinkService"),n.IUnicodeService=(0,c.createDecorator)("UnicodeService"),n.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(x,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const c=i(8460),f=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const l=new f.UnicodeV6;this.register(l),this._active=l.version,this._activeProvider=l}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(l){if(!this._providers[l])throw new Error(`unknown Unicode version "${l}"`);this._active=l,this._activeProvider=this._providers[l],this._onChange.fire(l)}register(l){this._providers[l.version]=l}wcwidth(l){return this._activeProvider.wcwidth(l)}getStringCellWidth(l){let g=0;const _=l.length;for(let w=0;w<_;++w){let v=l.charCodeAt(w);if(55296<=v&&v<=56319){if(++w>=_)return g+this.wcwidth(v);const a=l.charCodeAt(w);56320<=a&&a<=57343?v=1024*(v-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(v)}return g}}}},o={};function m(x){var n=o[x];if(n!==void 0)return n.exports;var i=o[x]={exports:{}};return r[x].call(i.exports,i,i.exports,m),i.exports}var p={};return(()=>{var x=p;Object.defineProperty(x,"__esModule",{value:!0}),x.Terminal=void 0;const n=m(9042),i=m(3236),c=m(844),f=m(5741),l=m(8285),g=m(7975),_=m(7090),w=["cols","rows"];class v extends c.Disposable{constructor(h){super(),this._core=this.register(new i.Terminal(h)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=b=>this._core.options[b],u=(b,y)=>{this._checkReadonlyOptions(b),this._core.options[b]=y};for(const b in this._core.options){const y={get:d.bind(this,b),set:u.bind(this,b)};Object.defineProperty(this._publicOptions,b,y)}}_checkReadonlyOptions(h){if(w.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 _.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 l.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,u,b;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(u=h.width)!==null&&u!==void 0?u:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,u){this._verifyIntegers(h,d,u),this._core.select(h,d,u)}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
25
- `,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")}}x.Terminal=v})(),p})()))})(hi)),hi.exports}var sm=tm();var rm=2,im=1,nm=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")),m=Math.max(0,parseInt(r.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),x={top:parseInt(p.getPropertyValue("padding-top")),bottom:parseInt(p.getPropertyValue("padding-bottom")),right:parseInt(p.getPropertyValue("padding-right")),left:parseInt(p.getPropertyValue("padding-left"))},n=x.top+x.bottom,i=x.right+x.left,c=o-n,f=m-i-s;return{cols:Math.max(rm,Math.floor(f/e.css.cell.width)),rows:Math.max(im,Math.floor(c/e.css.cell.height))}}};function om(e={}){const{cwd:s,cols:r,rows:o,onOutput:m,onExit:p}=e,[x,n]=C.useState(null),[i,c]=C.useState(()=>Gt.isConnected()),[f,l]=C.useState(!1),[g,_]=C.useState(!1),[w,v]=C.useState(!1),a=C.useRef({onOutput:m,onExit:p});a.current={onOutput:m,onExit:p};const h=C.useRef(null);h.current=x,C.useEffect(()=>{if(!x)return;const k=Gt.getSocket(),E=()=>{c(!0),l(!1),n(null),v(!0)},S=()=>{c(!1),l(!1)},j=D=>{D.terminalId===x&&a.current.onOutput?.(D.data)},N=D=>{D.terminalId===x&&(l(!1),a.current.onExit?.(D.exitCode),n(null))},T=D=>{D.terminalId===x&&l(!0)},M=D=>{D.terminalId===x&&l(!1)};return k.on("connect",E),k.on("disconnect",S),k.on(nt.TERMINAL_STDOUT,j),k.on(nt.TERMINAL_EXIT,N),k.on(nt.TERMINAL_SUBSCRIBED,T),k.on(nt.TERMINAL_UNSUBSCRIBED,M),c(k.connected),k.connected&&k.emit(ps.SUBSCRIBE,{topic:"terminal",id:x},D=>{D.success&&l(!0)}),()=>{k.off("connect",E),k.off("disconnect",S),k.off(nt.TERMINAL_STDOUT,j),k.off(nt.TERMINAL_EXIT,N),k.off(nt.TERMINAL_SUBSCRIBED,T),k.off(nt.TERMINAL_UNSUBSCRIBED,M),k.emit(ps.UNSUBSCRIBE,{topic:"terminal",id:x})}},[x]);const d=C.useCallback(async()=>{const k=Gt.getSocket();if(!k.connected)return null;_(!0);try{const E=await Se.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(E.terminalId),v(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{_(!1)}},[s,r,o]),u=C.useCallback(async()=>{const k=h.current;if(k){try{await Se.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}n(null),l(!1)}},[]),b=C.useCallback(k=>{const E=h.current;if(!E)return;Gt.getSocket().emit(ps.TERMINAL_INPUT,{terminalId:E,data:k})},[]),y=C.useCallback((k,E)=>{const S=h.current;if(!S)return;Gt.getSocket().emit(ps.TERMINAL_RESIZE,{terminalId:S,cols:k,rows:E})},[]);return C.useEffect(()=>()=>{const k=h.current;k&&Se.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:x,isConnected:i,isAttached:f,isCreating:g,needsRecreate:w,create:d,destroy:u,sendInput:b,resize:y}}const am={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"},lm=oe.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:m}){const p=C.useRef(null),x=C.useRef(null),n=C.useRef(null),i=C.useRef(!1),{terminalId:c,isAttached:f,needsRecreate:l,create:g,sendInput:_,resize:w}=om({cwd:s,onOutput:C.useCallback(v=>{x.current?.write(v)},[]),onExit:C.useCallback(v=>{x.current?.writeln(`\r
26
- \x1B[90m[Process exited with code ${v}]\x1B[0m`),o?.(v)},[o])});return C.useEffect(()=>{if(!l)return;const v=x.current;v&&v.writeln(`\r
27
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[l,g]),C.useLayoutEffect(()=>{if(!p.current)return;const v=new sm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:am,scrollback:5e3,convertEol:!0}),a=new nm;v.loadAddon(a),v.open(p.current);const h=(d=0)=>{if(!(d>=5))try{const b=p.current;if(!b||b.clientWidth===0||b.clientHeight===0){setTimeout(()=>h(d+1),50);return}a.fit(),w(v.cols,v.rows)}catch{setTimeout(()=>h(d+1),50)}};return h(0),setTimeout(()=>h(1),100),x.current=v,n.current=a,()=>{v.dispose(),x.current=null,n.current=null}},[w]),C.useEffect(()=>{i.current||(i.current=!0,g())},[g]),C.useEffect(()=>{const v=x.current;if(!v||!f)return;const a=v.onData(h=>{_(h)});return()=>a.dispose()},[_,f]),C.useEffect(()=>{f&&m?.({sendInput:_})},[f,_,m]),C.useEffect(()=>{if(!r)return;const v=n.current,a=x.current,h=p.current;if(!v||!a||!h)return;let d=!1,u;const b=y=>{d||y>=5||(u=requestAnimationFrame(()=>{if(!d)if(h.clientWidth>0&&h.clientHeight>0)try{v.fit(),w(a.cols,a.rows)}catch{}else setTimeout(()=>b(y+1),30)}))};return b(0),()=>{d=!0,u!=null&&cancelAnimationFrame(u)}},[r,w]),C.useEffect(()=>{if(!p.current)return;const v=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const a=n.current,h=x.current,d=p.current;a&&h&&d&&d.clientWidth>0&&d.clientHeight>0&&(a.fit(),w(h.cols,h.rows))}catch{}})});return v.observe(p.current),()=>v.disconnect()},[w]),t.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!c&&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:p,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),cm=oe.memo(function({commands:s,onSelect:r}){const{t:o}=ce(),[m,p]=C.useState(!1),x=C.useRef(null),n=C.useRef(null);return C.useEffect(()=>{if(!m)return;const i=c=>{x.current&&!x.current.contains(c.target)&&n.current&&!n.current.contains(c.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[m]),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:()=>p(!m),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${m?"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(fa,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(dt,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&t.jsx("div",{ref:x,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,c)=>t.jsxs("button",{onClick:()=>{r(i.command),p(!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(as,{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})]})]},c))})})]})]})});let fi=0;function fo(){return fi+=1,{id:`shell-${fi}`,order:fi}}const dm=oe.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:m}=ce(),[p,x]=C.useState(()=>[fo()]),[n,i]=C.useState(()=>p[0].id),c=C.useRef(new Map),f=C.useCallback(()=>{const v=fo();x(a=>[...a,v]),i(v.id)},[]),l=C.useCallback((v,a)=>{a.stopPropagation(),c.current.delete(v),x(h=>{const d=h.filter(u=>u.id!==v);return v===n&&d.length>0&&i(d[d.length-1].id),d})},[n]),g=C.useCallback(v=>{c.current.delete(v),x(a=>{const h=a.filter(d=>d.id!==v);return v===n&&h.length>0&&i(h[h.length-1].id),h})},[n]),_=C.useCallback((v,a)=>{c.current.set(v,a.sendInput)},[]),w=C.useCallback(v=>{const a=c.current.get(n);a&&a(v+"\r")},[n]);return t.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",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 flex-1 min-w-0",children:p.map(v=>t.jsxs("button",{onClick:()=>i(v.id),className:J("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",v.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(mr,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:v.order})}),p.length>1&&t.jsx("span",{onClick:a=>l(v.id,a),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Ft,{size:10})})]},v.id))}),t.jsx("button",{onClick:f,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:m("New Terminal"),children:t.jsx(Bt,{size:14})}),o.length>0&&t.jsx(cm,{commands:o,onSelect:w})]}),t.jsx("div",{className:"flex-1 overflow-hidden relative",children:p.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(mr,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:f,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):p.map(v=>t.jsx("div",{className:"absolute inset-0",style:{display:v.id===n?"block":"none"},children:t.jsx(lm,{cwd:s,isVisible:r&&v.id===n,onExit:()=>g(v.id),onReady:a=>_(v.id,a)})},v.id))})]})});function mo(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 um(e){if(Array.isArray(e))return e}function hm(e,s,r){return(s=_m(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function fm(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,m,p,x,n=[],i=!0,c=!1;try{if(p=(r=r.call(e)).next,s!==0)for(;!(i=(o=p.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(f){c=!0,m=f}finally{try{if(!i&&r.return!=null&&(x=r.return(),Object(x)!==x))return}finally{if(c)throw m}}return n}}function mm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
28
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function po(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function go(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?po(Object(r),!0).forEach(function(o){hm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):po(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function pm(e,s){if(e==null)return{};var r,o,m=gm(e,s);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(o=0;o<p.length;o++)r=p[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(m[r]=e[r])}return m}function gm(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 vm(e,s){return um(e)||fm(e,s)||bm(e,s)||mm()}function xm(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 _m(e){var s=xm(e,"string");return typeof s=="symbol"?s:s+""}function bm(e,s){if(e){if(typeof e=="string")return mo(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)?mo(e,s):void 0}}function ym(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function vo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function xo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?vo(Object(r),!0).forEach(function(o){ym(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Sm(){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(m,p){return p(m)},o)}}function Ds(e){return function s(){for(var r=this,o=arguments.length,m=new Array(o),p=0;p<o;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var x=arguments.length,n=new Array(x),i=0;i<x;i++)n[i]=arguments[i];return s.apply(r,[].concat(m,n))}}}function Sr(e){return{}.toString.call(e).includes("Object")}function wm(e){return!Object.keys(e).length}function qs(e){return typeof e=="function"}function Cm(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function km(e,s){return Sr(s)||es("changeType"),Object.keys(s).some(function(r){return!Cm(e,r)})&&es("changeField"),s}function Em(e){qs(e)||es("selectorType")}function jm(e){qs(e)||Sr(e)||es("handlerType"),Sr(e)&&Object.values(e).some(function(s){return!qs(s)})&&es("handlersType")}function Nm(e){e||es("initialIsRequired"),Sr(e)||es("initialType"),wm(e)&&es("initialContent")}function Rm(e,s){throw new Error(e[s]||e.default)}var Am={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"},es=Ds(Rm)(Am),nr={changes:km,selector:Em,handler:jm,initial:Nm};function Mm(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};nr.initial(e),nr.handler(s);var r={current:e},o=Ds(Lm)(r,s),m=Ds(Dm)(r),p=Ds(nr.changes)(e),x=Ds(Tm)(r);function n(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return nr.selector(c),c(r.current)}function i(c){Sm(o,m,p,x)(c)}return[n,i]}function Tm(e,s){return qs(s)?s(e.current):s}function Dm(e,s){return e.current=xo(xo({},e.current),s),s}function Lm(e,s,r){return qs(s)?s(e.current):Object.keys(r).forEach(function(o){var m;return(m=s[o])===null||m===void 0?void 0:m.call(s,e.current[o])}),r}var Pm={create:Mm},Om={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Im(e){return function s(){for(var r=this,o=arguments.length,m=new Array(o),p=0;p<o;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var x=arguments.length,n=new Array(x),i=0;i<x;i++)n[i]=arguments[i];return s.apply(r,[].concat(m,n))}}}function Bm(e){return{}.toString.call(e).includes("Object")}function Fm(e){return e||_o("configIsRequired"),Bm(e)||_o("configType"),e.urls?(zm(),{paths:{vs:e.urls.monacoBase}}):e}function zm(){console.warn(Xa.deprecation)}function Hm(e,s){throw new Error(e[s]||e.default)}var Xa={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!
29
- You are using deprecated way of configuration.
30
-
31
- Instead of using
32
- monaco.config({ urls: { monacoBase: '...' } })
33
- use
34
- monaco.config({ paths: { vs: '...' } })
35
-
36
- For more please check the link https://github.com/suren-atoyan/monaco-loader#config
37
- `},_o=Im(Hm)(Xa),Wm={config:Fm},$m=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(m){return r.reduceRight(function(p,x){return x(p)},m)}};function Ya(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Ya(e[r],s[r]))}),go(go({},e),s)}var Um={type:"cancelation",msg:"operation is manually canceled"};function mi(e){var s=!1,r=new Promise(function(o,m){e.then(function(p){return s?m(Um):o(p)}),e.catch(m)});return r.cancel=function(){return s=!0},r}var qm=["monaco"],Km=Pm.create({config:Om,isInitialized:!1,resolve:null,reject:null,monaco:null}),Va=vm(Km,2),Qs=Va[0],Wr=Va[1];function Xm(e){var s=Wm.config(e),r=s.monaco,o=pm(s,qm);Wr(function(m){return{config:Ya(m.config,o),monaco:r}})}function Ym(){var e=Qs(function(s){var r=s.monaco,o=s.isInitialized,m=s.resolve;return{monaco:r,isInitialized:o,resolve:m}});if(!e.isInitialized){if(Wr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),mi(pi);if(window.monaco&&window.monaco.editor)return Ga(window.monaco),e.resolve(window.monaco),mi(pi);$m(Vm,Qm)(Zm)}return mi(pi)}function Vm(e){return document.body.appendChild(e)}function Gm(e){var s=document.createElement("script");return e&&(s.src=e),s}function Qm(e){var s=Qs(function(o){var m=o.config,p=o.reject;return{config:m,reject:p}}),r=Gm("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Zm(){var e=Qs(function(r){var o=r.config,m=r.resolve,p=r.reject;return{config:o,resolve:m,reject:p}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;Ga(o),e.resolve(o)},function(r){e.reject(r)})}function Ga(e){Qs().monaco||Wr({monaco:e})}function Jm(){return Qs(function(e){var s=e.monaco;return s})}var pi=new Promise(function(e,s){return Wr({resolve:e,reject:s})}),Qa={config:Xm,init:Ym,__getMonacoInstance:Jm},ep={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},gi=ep,tp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},sp=tp;function rp({children:e}){return oe.createElement("div",{style:sp.container},e)}var ip=rp,np=ip;function op({width:e,height:s,isEditorReady:r,loading:o,_ref:m,className:p,wrapperProps:x}){return oe.createElement("section",{style:{...gi.wrapper,width:e,height:s},...x},!r&&oe.createElement(np,null,o),oe.createElement("div",{ref:m,style:{...gi.fullWidth,...!r&&gi.hide},className:p}))}var ap=op,Za=C.memo(ap);function lp(e){C.useEffect(e,[])}var Ja=lp;function cp(e,s,r=!0){let o=C.useRef(!0);C.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var St=cp;function Is(){}function vs(e,s,r,o){return dp(e,o)||up(e,s,r,o)}function dp(e,s){return e.editor.getModel(el(e,s))}function up(e,s,r,o){return e.editor.createModel(s,r,o?el(e,o):void 0)}function el(e,s){return e.Uri.parse(s)}function hp({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:m,originalModelPath:p,modifiedModelPath:x,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:c="light",loading:f="Loading...",options:l={},height:g="100%",width:_="100%",className:w,wrapperProps:v={},beforeMount:a=Is,onMount:h=Is}){let[d,u]=C.useState(!1),[b,y]=C.useState(!0),k=C.useRef(null),E=C.useRef(null),S=C.useRef(null),j=C.useRef(h),N=C.useRef(a),T=C.useRef(!1);Ja(()=>{let L=Qa.init();return L.then(F=>(E.current=F)&&y(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?I():L.cancel()}),St(()=>{if(k.current&&E.current){let L=k.current.getOriginalEditor(),F=vs(E.current,e||"",o||r||"text",p||"");F!==L.getModel()&&L.setModel(F)}},[p],d),St(()=>{if(k.current&&E.current){let L=k.current.getModifiedEditor(),F=vs(E.current,s||"",m||r||"text",x||"");F!==L.getModel()&&L.setModel(F)}},[x],d),St(()=>{let L=k.current.getModifiedEditor();L.getOption(E.current.editor.EditorOption.readOnly)?L.setValue(s||""):s!==L.getValue()&&(L.executeEdits("",[{range:L.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),L.pushUndoStop())},[s],d),St(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),St(()=>{let{original:L,modified:F}=k.current.getModel();E.current.editor.setModelLanguage(L,o||r||"text"),E.current.editor.setModelLanguage(F,m||r||"text")},[r,o,m],d),St(()=>{E.current?.editor.setTheme(c)},[c],d),St(()=>{k.current?.updateOptions(l)},[l],d);let M=C.useCallback(()=>{if(!E.current)return;N.current(E.current);let L=vs(E.current,e||"",o||r||"text",p||""),F=vs(E.current,s||"",m||r||"text",x||"");k.current?.setModel({original:L,modified:F})},[r,s,m,e,o,p,x]),D=C.useCallback(()=>{!T.current&&S.current&&(k.current=E.current.editor.createDiffEditor(S.current,{automaticLayout:!0,...l}),M(),E.current?.editor.setTheme(c),u(!0),T.current=!0)},[l,c,M]);C.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),C.useEffect(()=>{!b&&!d&&D()},[b,d,D]);function I(){let L=k.current?.getModel();n||L?.original?.dispose(),i||L?.modified?.dispose(),k.current?.dispose()}return oe.createElement(Za,{width:_,height:g,isEditorReady:d,loading:f,_ref:S,className:w,wrapperProps:v})}var fp=hp;C.memo(fp);function mp(e){let s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}var pp=mp,or=new Map;function gp({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:m,path:p,theme:x="light",line:n,loading:i="Loading...",options:c={},overrideServices:f={},saveViewState:l=!0,keepCurrentModel:g=!1,width:_="100%",height:w="100%",className:v,wrapperProps:a={},beforeMount:h=Is,onMount:d=Is,onChange:u,onValidate:b=Is}){let[y,k]=C.useState(!1),[E,S]=C.useState(!0),j=C.useRef(null),N=C.useRef(null),T=C.useRef(null),M=C.useRef(d),D=C.useRef(h),I=C.useRef(),L=C.useRef(o),F=pp(p),z=C.useRef(!1),A=C.useRef(!1);Ja(()=>{let B=Qa.init();return B.then(U=>(j.current=U)&&S(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>N.current?O():B.cancel()}),St(()=>{let B=vs(j.current,e||o||"",s||m||"",p||r||"");B!==N.current?.getModel()&&(l&&or.set(F,N.current?.saveViewState()),N.current?.setModel(B),l&&N.current?.restoreViewState(or.get(p)))},[p],y),St(()=>{N.current?.updateOptions(c)},[c],y),St(()=>{!N.current||o===void 0||(N.current.getOption(j.current.editor.EditorOption.readOnly)?N.current.setValue(o):o!==N.current.getValue()&&(A.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),N.current.pushUndoStop(),A.current=!1))},[o],y),St(()=>{let B=N.current?.getModel();B&&m&&j.current?.editor.setModelLanguage(B,m)},[m],y),St(()=>{n!==void 0&&N.current?.revealLine(n)},[n],y),St(()=>{j.current?.editor.setTheme(x)},[x],y);let P=C.useCallback(()=>{if(!(!T.current||!j.current)&&!z.current){D.current(j.current);let B=p||r,U=vs(j.current,o||e||"",s||m||"",B||"");N.current=j.current?.editor.create(T.current,{model:U,automaticLayout:!0,...c},f),l&&N.current.restoreViewState(or.get(B)),j.current.editor.setTheme(x),n!==void 0&&N.current.revealLine(n),k(!0),z.current=!0}},[e,s,r,o,m,p,c,f,l,x,n]);C.useEffect(()=>{y&&M.current(N.current,j.current)},[y]),C.useEffect(()=>{!E&&!y&&P()},[E,y,P]),L.current=o,C.useEffect(()=>{y&&u&&(I.current?.dispose(),I.current=N.current?.onDidChangeModelContent(B=>{A.current||u(N.current.getValue(),B)}))},[y,u]),C.useEffect(()=>{if(y){let B=j.current.editor.onDidChangeMarkers(U=>{let X=N.current.getModel()?.uri;if(X&&U.find(V=>V.path===X.path)){let V=j.current.editor.getModelMarkers({resource:X});b?.(V)}});return()=>{B?.dispose()}}return()=>{}},[y,b]);function O(){I.current?.dispose(),g?l&&or.set(p,N.current.saveViewState()):N.current.getModel()?.dispose(),N.current.dispose()}return oe.createElement(Za,{width:_,height:w,isEditorReady:y,loading:i,_ref:T,className:v,wrapperProps:a})}var vp=gp,xp=C.memo(vp),_p=xp,Nt=function(e,s){return Number(e.toFixed(s))},bp=function(e,s){return typeof e=="number"?e:s},Ve=function(e,s,r){r&&typeof r=="function"&&r(e,s)},yp=function(e){return-Math.cos(e*Math.PI)/2+.5},Sp=function(e){return e},wp=function(e){return e*e},Cp=function(e){return e*(2-e)},kp=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Ep=function(e){return e*e*e},jp=function(e){return--e*e*e+1},Np=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Rp=function(e){return e*e*e*e},Ap=function(e){return 1- --e*e*e*e},Mp=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Tp=function(e){return e*e*e*e*e},Dp=function(e){return 1+--e*e*e*e*e},Lp=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},tl={easeOut:yp,linear:Sp,easeInQuad:wp,easeOutQuad:Cp,easeInOutQuad:kp,easeInCubic:Ep,easeOutCubic:jp,easeInOutCubic:Np,easeInQuart:Rp,easeOutQuart:Ap,easeInOutQuart:Mp,easeInQuint:Tp,easeOutQuint:Dp,easeInOutQuint:Lp},sl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Tt=function(e){e.mounted&&(sl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function rl(e,s,r,o){if(e.mounted){var m=new Date().getTime(),p=1;Tt(e),e.animation=function(){if(!e.mounted)return sl(e.animation);var x=new Date().getTime()-m,n=x/r,i=tl[s],c=i(n);x>=r?(o(p),e.animation=null):e.animation&&(o(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Pp(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function is(e,s,r,o){var m=Pp(s);if(!(!e.mounted||!m)){var p=e.setTransformState,x=e.transformState,n=x.scale,i=x.positionX,c=x.positionY,f=s.scale-n,l=s.positionX-i,g=s.positionY-c;r===0?p(s.scale,s.positionX,s.positionY):rl(e,o,r,function(_){var w=n+f*_,v=i+l*_,a=c+g*_;p(w,v,a)})}}function Op(e,s,r){var o=e.offsetWidth,m=e.offsetHeight,p=s.offsetWidth,x=s.offsetHeight,n=p*r,i=x*r,c=o-n,f=m-i;return{wrapperWidth:o,wrapperHeight:m,newContentWidth:n,newDiffWidth:c,newContentHeight:i,newDiffHeight:f}}var Ip=function(e,s,r,o,m,p,x){var n=e>s?r*(x?1:.5):0,i=o>m?p*(x?1:.5):0,c=e-s-n,f=n,l=o-m-i,g=i;return{minPositionX:c,maxPositionX:f,minPositionY:l,maxPositionY:g}},gn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,m=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=Op(r,o,s),x=p.wrapperWidth,n=p.wrapperHeight,i=p.newContentWidth,c=p.newDiffWidth,f=p.newContentHeight,l=p.newDiffHeight,g=Ip(x,i,c,n,f,l,!!m);return g},Mi=function(e,s,r,o){return o?e<s?Nt(s,2):e>r?Nt(r,2):Nt(e,2):Nt(e,2)},ls=function(e,s){var r=gn(e,s);return e.bounds=r,r};function Zs(e,s,r,o,m,p,x){var n=r.minPositionX,i=r.minPositionY,c=r.maxPositionX,f=r.maxPositionY,l=0,g=0;x&&(l=m,g=p);var _=Mi(e,n-l,c+l,o),w=Mi(s,i-g,f+g,o);return{x:_,y:w}}function $r(e,s,r,o,m,p){var x=e.transformState,n=x.scale,i=x.positionX,c=x.positionY,f=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:c};var l=i-s*f,g=c-r*f,_=Zs(l,g,m,p,0,0,null);return _}function Js(e,s,r,o,m){var p=m?o:0,x=s-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=x?x:e}var bo=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,m=e.wrapperComponent,p=s.target,x="shadowRoot"in p&&"composedPath"in s,n=x?s.composedPath().some(function(f){return f instanceof Element?m?.contains(f):!1}):m?.contains(p),i=o&&p&&n;if(!i)return!1;var c=Ur(p,r);return!c},yo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,m=o.panning.disabled,p=s&&r&&!m;return!!p},Bp=function(e,s){var r=e.transformState,o=r.positionX,m=r.positionY;e.isPanning=!0;var p=s.clientX,x=s.clientY;e.startCoords={x:p-o,y:x-m}},Fp=function(e,s){var r=s.touches,o=e.transformState,m=o.positionX,p=o.positionY;e.isPanning=!0;var x=r.length===1;if(x){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-m,y:i-p}}};function zp(e){var s=e.transformState,r=s.positionX,o=s.positionY,m=s.scale,p=e.setup,x=p.disabled,n=p.limitToBounds,i=p.centerZoomedOut,c=e.wrapperComponent;if(!(x||!c||!e.bounds)){var f=e.bounds,l=f.maxPositionX,g=f.minPositionX,_=f.maxPositionY,w=f.minPositionY,v=r>l||r<g,a=o>_||o<w,h=r>l?c.offsetWidth:e.setup.minPositionX||0,d=o>_?c.offsetHeight:e.setup.minPositionY||0,u=$r(e,h,d,m,e.bounds,n||i),b=u.x,y=u.y;return{scale:m,positionX:v?b:r,positionY:a?y:o}}}function il(e,s,r,o,m){var p=e.setup.limitToBounds,x=e.wrapperComponent,n=e.bounds,i=e.transformState,c=i.scale,f=i.positionX,l=i.positionY;if(!(x===null||n===null||s===f&&r===l)){var g=Zs(s,r,n,p,o,m,x),_=g.x,w=g.y;e.setTransformState(c,_,w)}}var Hp=function(e,s,r){var o=e.startCoords,m=e.transformState,p=e.setup.panning,x=p.lockAxisX,n=p.lockAxisY,i=m.positionX,c=m.positionY;if(!o)return{x:i,y:c};var f=s-o.x,l=r-o.y,g=x?i:f,_=n?c:l;return{x:g,y:_}},rs=function(e,s){var r=e.setup,o=e.transformState,m=o.scale,p=r.minScale,x=r.disablePadding;return s>0&&m>=p&&!x?s:0},Wp=function(e){var s=e.mounted,r=e.setup,o=r.disabled,m=r.velocityAnimation,p=e.transformState.scale,x=m.disabled,n=!x||p>1||!o||s;return!!n},$p=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,m=e.setup,p=m.disabled,x=m.velocityAnimation,n=e.transformState.scale,i=x.disabled,c=!i||n>1||!p||s;return!(!c||!r||!o)};function Up(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,m=r.animationTime,p=r.sensitivity;return o?m*s*p:m}function So(e,s,r,o,m,p,x,n,i,c){if(m){if(s>x&&r>x){var f=x+(e-x)*c;return f>i?i:f<x?x:f}if(s<p&&r<p){var f=p+(e-p)*c;return f<n?n:f>p?p:f}}return o?s:Mi(e,p,x,m)}function qp(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function Kp(e,s){var r=Wp(e);if(r){var o=e.lastMousePosition,m=e.velocityTime,p=e.setup,x=e.wrapperComponent,n=p.velocityAnimation.equalToMove,i=Date.now();if(o&&m&&x){var c=qp(x,n),f=s.x-o.x,l=s.y-o.y,g=f/c,_=l/c,w=i-m,v=f*f+l*l,a=Math.sqrt(v)/w;e.velocity={velocityX:g,velocityY:_,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function Xp(e){var s=e.velocity,r=e.bounds,o=e.setup,m=e.wrapperComponent,p=$p(e);if(!(!p||!s||!r||!m)){var x=s.velocityX,n=s.velocityY,i=s.total,c=r.maxPositionX,f=r.minPositionX,l=r.maxPositionY,g=r.minPositionY,_=o.limitToBounds,w=o.alignmentAnimation,v=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,u=v.animationType,b=w.sizeX,y=w.sizeY,k=w.velocityAlignmentTime,E=k,S=Up(e,i),j=Math.max(S,E),N=rs(e,b),T=rs(e,y),M=N*m.offsetWidth/100,D=T*m.offsetHeight/100,I=c+M,L=f-M,F=l+D,z=g-D,A=e.transformState,P=new Date().getTime();rl(e,u,j,function(O){var B=e.transformState,U=B.scale,X=B.positionX,V=B.positionY,Z=new Date().getTime()-P,q=Z/E,R=tl[w.animationType],H=1-R(Math.min(1,q)),K=1-O,W=X+x*K,Y=V+n*K,G=So(W,A.positionX,X,d,_,f,c,L,I,H),ae=So(Y,A.positionY,V,h,_,g,l,z,F,H);(X!==W||V!==Y)&&e.setTransformState(U,G,ae)})}}function wo(e,s){var r=e.transformState.scale;Tt(e),ls(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?Fp(e,s):Bp(e,s)}function vn(e,s){var r=e.transformState.scale,o=e.setup,m=o.minScale,p=o.alignmentAnimation,x=p.disabled,n=p.sizeX,i=p.sizeY,c=p.animationTime,f=p.animationType,l=x||r<m||!n&&!i;if(!l){var g=zp(e);g&&is(e,g,s??c,f)}}function Co(e,s,r){var o=e.startCoords,m=e.setup,p=m.alignmentAnimation,x=p.sizeX,n=p.sizeY;if(o){var i=Hp(e,s,r),c=i.x,f=i.y,l=rs(e,x),g=rs(e,n);Kp(e,{x:c,y:f}),il(e,c,f,l,g)}}function Yp(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var p=o?.getBoundingClientRect(),x=m?.getBoundingClientRect(),n=p?.width||0,i=p?.height||0,c=x?.width||0,f=x?.height||0,l=n<c||i<f,g=!s&&r&&r?.total>.1&&l;g?Xp(e):vn(e)}}function xn(e,s,r,o){var m=e.setup,p=m.minScale,x=m.maxScale,n=m.limitToBounds,i=Js(Nt(s,2),p,x,0,!1),c=ls(e,i),f=$r(e,r,o,i,c,n),l=f.x,g=f.y;return{scale:i,positionX:l,positionY:g}}function nl(e,s,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,x=p.minScale,n=p.limitToBounds,i=p.zoomAnimation,c=i.disabled,f=i.animationTime,l=i.animationType,g=c||o>=x;if((o>=1||n)&&vn(e),!(g||!m||!e.mounted)){var _=s||m.offsetWidth/2,w=r||m.offsetHeight/2,v=xn(e,x,_,w);v&&is(e,v,f,l)}}var ts=function(){return ts=Object.assign||function(s){for(var r,o=1,m=arguments.length;o<m;o++){r=arguments[o];for(var p in r)Object.prototype.hasOwnProperty.call(r,p)&&(s[p]=r[p])}return s},ts.apply(this,arguments)};function ko(e,s,r){for(var o=0,m=s.length,p;o<m;o++)(p||!(o in s))&&(p||(p=Array.prototype.slice.call(s,0,o)),p[o]=s[o]);return e.concat(p||Array.prototype.slice.call(s))}var ar={scale:1,positionX:0,positionY:0},Ms={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}},Ti={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},ol=function(e){var s,r,o,m;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:ar.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:ar.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:ar.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:ar.positionY}},Eo=function(e){var s=ts({},Ms);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",m=typeof Ms[r]<"u";if(m&&o){var p=Object.prototype.toString.call(Ms[r]),x=p==="[object Object]",n=p==="[object Array]";x?s[r]=ts(ts({},Ms[r]),e[r]):n?s[r]=ko(ko([],Ms[r],!0),e[r]):s[r]=e[r]}}),s},al=function(e,s,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,x=p.maxScale,n=p.minScale,i=p.zoomAnimation,c=p.smooth,f=i.size;if(!m)throw new Error("Wrapper is not mounted");var l=c?o*Math.exp(s*r):o+s*r,g=Js(Nt(l,3),n,x,f,!1);return g};function ll(e,s,r,o,m){var p=e.wrapperComponent,x=e.transformState,n=x.scale,i=x.positionX,c=x.positionY;if(!p)return console.error("No WrapperComponent found");var f=p.offsetWidth,l=p.offsetHeight,g=(f/2-i)/n,_=(l/2-c)/n,w=al(e,s,r),v=xn(e,w,g,_);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");is(e,v,o,m)}function cl(e,s,r,o){var m=e.setup,p=e.wrapperComponent,x=m.limitToBounds,n=ol(e.props),i=e.transformState,c=i.scale,f=i.positionX,l=i.positionY;if(p){var g=gn(e,n.scale),_=Zs(n.positionX,n.positionY,g,x,0,0,p),w={scale:n.scale,positionX:_.x,positionY:_.y};c===n.scale&&f===n.positionX&&l===n.positionY||(o?.(),is(e,w,s,r))}}function Vp(e,s,r,o){var m=e.getBoundingClientRect(),p=s.getBoundingClientRect(),x=r.getBoundingClientRect(),n=p.x*o.scale,i=p.y*o.scale;return{x:(m.x-x.x+n)/o.scale,y:(m.y-x.y+i)/o.scale}}function Gp(e,s,r){var o=e.wrapperComponent,m=e.contentComponent,p=e.transformState,x=e.setup,n=x.limitToBounds,i=x.minScale,c=x.maxScale;if(!o||!m)return p;var f=o.getBoundingClientRect(),l=s.getBoundingClientRect(),g=Vp(s,o,m,p),_=g.x,w=g.y,v=l.width/p.scale,a=l.height/p.scale,h=o.offsetWidth/v,d=o.offsetHeight/a,u=Js(r||Math.min(h,d),i,c,0,!1),b=(f.width-v*u)/2,y=(f.height-a*u)/2,k=(f.left-_)*u+b,E=(f.top-w)*u+y,S=gn(e,u),j=Zs(k,E,S,n,0,0,o),N=j.x,T=j.y;return{positionX:N,positionY:T,scale:u}}var Qp=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),ll(e,1,s,r,o)}},Zp=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),ll(e,-1,s,r,o)}},Jp=function(e){return function(s,r,o,m,p){m===void 0&&(m=300),p===void 0&&(p="easeOut");var x=e.transformState,n=x.positionX,i=x.positionY,c=x.scale,f=e.wrapperComponent,l=e.contentComponent,g=e.setup.disabled;if(!(g||!f||!l)){var _={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?c:o};is(e,_,m,p)}}},e0=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),cl(e,s,r)}},t0=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var m=e.transformState,p=e.wrapperComponent,x=e.contentComponent;if(p&&x){var n=dl(s||m.scale,p,x);is(e,n,r,o)}}},s0=function(e){return function(s,r,o,m){o===void 0&&(o=600),m===void 0&&(m="easeOut"),Tt(e);var p=e.wrapperComponent,x=typeof s=="string"?document.getElementById(s):s;if(p&&x&&p.contains(x)){var n=Gp(e,x,r);is(e,n,o,m)}}},wr=function(e){return{instance:e,zoomIn:Qp(e),zoomOut:Zp(e),setTransform:Jp(e),resetTransform:e0(e),centerView:t0(e),zoomToElement:s0(e)}},Di=function(e){return{instance:e,state:e.transformState}},qe=function(e){var s={};return Object.assign(s,Di(e)),Object.assign(s,wr(e)),s},vi=!1;function xi(){try{var e={get passive(){return vi=!0,!1}};return e}catch{return vi=!1,vi}}var lr=".".concat(Ti.wrapperClass),Ur=function(e,s){return s.some(function(r){return e.matches("".concat(lr," ").concat(r,", ").concat(lr," .").concat(r,", ").concat(lr," ").concat(r," *, ").concat(lr," .").concat(r," *"))})},Li=function(e){e&&clearTimeout(e)},r0=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},dl=function(e,s,r){var o=r.offsetWidth*e,m=r.offsetHeight*e,p=(s.offsetWidth-o)/2,x=(s.offsetHeight-m)/2;return{scale:e,positionX:p,positionY:x}};function i0(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var n0=function(e,s){var r=e.setup.wheel,o=r.disabled,m=r.wheelDisabled,p=r.touchPadDisabled,x=r.excluded,n=e.isInitialized,i=e.isPanning,c=s.target,f=n&&!i&&!o&&c;if(!f||m&&!s.ctrlKey||p&&s.ctrlKey)return!1;var l=Ur(c,x);return!l},o0=function(e){return e?e.deltaY<0?1:-1:0};function a0(e,s){var r=o0(e),o=bp(s,r);return o}function ul(e,s,r){var o=s.getBoundingClientRect(),m=0,p=0;if("clientX"in e)m=(e.clientX-o.left)/r,p=(e.clientY-o.top)/r;else{var x=e.touches[0];m=(x.clientX-o.left)/r,p=(x.clientY-o.top)/r}return(Number.isNaN(m)||Number.isNaN(p))&&console.error("No mouse or touch offset found"),{x:m,y:p}}var l0=function(e,s,r,o,m){var p=e.transformState.scale,x=e.wrapperComponent,n=e.setup,i=n.maxScale,c=n.minScale,f=n.zoomAnimation,l=n.disablePadding,g=f.size,_=f.disabled;if(!x)throw new Error("Wrapper is not mounted");var w=p+s*r,v=o?!1:!_,a=Js(Nt(w,3),c,i,g,v&&!l);return a},c0=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,m=e.setup,p=m.maxScale,x=m.minScale;return r?o<p||o>x||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},d0=function(e,s){var r=e.setup.pinch,o=r.disabled,m=r.excluded,p=e.isInitialized,x=s.target,n=p&&!o&&x;if(!n)return!1;var i=Ur(x,m);return!i},u0=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,m=r&&!s&&o;return!!m},h0=function(e,s,r){var o=r.getBoundingClientRect(),m=e.touches,p=Nt(m[0].clientX-o.left,5),x=Nt(m[0].clientY-o.top,5),n=Nt(m[1].clientX-o.left,5),i=Nt(m[1].clientY-o.top,5);return{x:(p+n)/2/s,y:(x+i)/2/s}},hl=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))},f0=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,m=e.setup,p=m.maxScale,x=m.minScale,n=m.zoomAnimation,i=m.disablePadding,c=n.size,f=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var l=s/o,g=l*r;return Js(Nt(g,2),x,p,c,!f&&!i)},m0=160,p0=100,g0=function(e,s){var r=e.props,o=r.onWheelStart,m=r.onZoomStart;e.wheelStopEventTimer||(Tt(e),Ve(qe(e),s,o),Ve(qe(e),s,m))},v0=function(e,s){var r=e.props,o=r.onWheel,m=r.onZoom,p=e.contentComponent,x=e.setup,n=e.transformState,i=n.scale,c=x.limitToBounds,f=x.centerZoomedOut,l=x.zoomAnimation,g=x.wheel,_=x.disablePadding,w=x.smooth,v=l.size,a=l.disabled,h=g.step,d=g.smoothStep;if(!p)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var u=a0(s,null),b=w?d*Math.abs(s.deltaY):h,y=l0(e,u,b,!s.ctrlKey);if(i!==y){var k=ls(e,y),E=ul(s,p,i),S=a||v===0||f||_,j=c&&S,N=$r(e,E.x,E.y,y,k,j),T=N.x,M=N.y;e.previousWheelEvent=s,e.setTransformState(y,T,M),Ve(qe(e),s,o),Ve(qe(e),s,m)}},x0=function(e,s){var r=e.props,o=r.onWheelStop,m=r.onZoomStop;Li(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(nl(e,s.x,s.y),e.wheelAnimationTimer=null)},p0);var p=c0(e,s);p&&(Li(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ve(qe(e),s,o),Ve(qe(e),s,m))},m0))},fl=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 m=s/2,p=r/2;return{x:m,y:p}},_0=function(e,s){var r=hl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=fl(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Tt(e)},b0=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,m=e.wrapperComponent,p=e.transformState.scale,x=e.setup,n=x.limitToBounds,i=x.centerZoomedOut,c=x.zoomAnimation,f=x.alignmentAnimation,l=c.disabled,g=c.size;if(!(o===null||!r)){var _=h0(s,p,r);if(!(!Number.isFinite(_.x)||!Number.isFinite(_.y))){var w=hl(s),v=f0(e,w),a=fl(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(v===p&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var u=ls(e,v),b=l||g===0||i,y=n&&b,k=$r(e,_.x,_.y,v,u,y),E=k.x,S=k.y;e.pinchMidpoint=_,e.lastDistance=w;var j=f.sizeX,N=f.sizeY,T=rs(e,j),M=rs(e,N),D=E+h,I=S+d,L=Zs(D,I,u,n,T,M,m),F=L.x,z=L.y;e.setTransformState(v,F,z)}}}},y0=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,nl(e,s?.x,s?.y)},ml=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;Li(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ve(qe(e),s,r)},o)},S0=function(e,s){var r=e.props,o=r.onZoomStart,m=r.onZoom,p=e.setup.doubleClick,x=p.animationTime,n=p.animationType;Ve(qe(e),s,o),cl(e,x,n,function(){return Ve(qe(e),s,m)}),ml(e,s)};function w0(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function C0(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,m=e.transformState,p=e.contentComponent,x=m.scale,n=e.props,i=n.onZoomStart,c=n.onZoom,f=r.doubleClick,l=f.disabled,g=f.mode,_=f.step,w=f.animationTime,v=f.animationType;if(!l&&!o){if(g==="reset")return S0(e,s);if(!p)return console.error("No ContentComponent found");var a=w0(g,e.transformState.scale),h=al(e,a,_);if(x!==h){Ve(qe(e),s,i);var d=ul(s,p,x),u=xn(e,h,d.x,d.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");Ve(qe(e),s,c),is(e,u,w,v),ml(e,s)}}}var k0=function(e,s){var r=e.isInitialized,o=e.setup,m=e.wrapperComponent,p=o.doubleClick,x=p.disabled,n=p.excluded,i=s.target,c=m?.contains(i),f=r&&i&&c&&!x;if(!f)return!1;var l=Ur(i,n);return!l},E0=(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,ls(r,r.transformState.scale),r.setup=Eo(o)},this.initializeWindowEvents=function(){var o,m,p=xi(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=x?.defaultView;(m=r.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",r.onWheelPanning,p),n?.addEventListener("mousedown",r.onPanningStart,p),n?.addEventListener("mousemove",r.onPanning,p),n?.addEventListener("mouseup",r.onPanningStop,p),x?.addEventListener("mouseleave",r.clearPanning,p),n?.addEventListener("keyup",r.setKeyUnPressed,p),n?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,m,p=xi(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=x?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,p),n?.removeEventListener("mousemove",r.onPanning,p),n?.removeEventListener("mouseup",r.onPanningStop,p),x?.removeEventListener("mouseleave",r.clearPanning,p),n?.removeEventListener("keyup",r.setKeyUnPressed,p),n?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),Tt(r),(m=r.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(o){var m=xi();o.addEventListener("wheel",r.onWheelZoom,m),o.addEventListener("dblclick",r.onDoubleClick,m),o.addEventListener("touchstart",r.onTouchPanningStart,m),o.addEventListener("touchmove",r.onTouchPanning,m),o.addEventListener("touchend",r.onTouchPanningStop,m)},this.handleInitialize=function(o,m){var p=!1,x=r.setup.centerOnInit,n=function(i,c){for(var f=0,l=i;f<l.length;f++){var g=l[f];if(g.target===c)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(qe(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,m))if(x&&!p){var c=m.offsetWidth,f=m.offsetHeight;(c>0||f>0)&&(p=!0,r.setCenter())}else Tt(r),ls(r,r.transformState.scale),vn(r,0)}),r.observer.observe(o),r.observer.observe(m)},this.onWheelZoom=function(o){var m=r.setup.disabled;if(!m){var p=n0(r,o);if(p){var x=r.isPressingKeys(r.setup.wheel.activationKeys);x&&(g0(r,o),v0(r,o),x0(r,o))}}},this.onWheelPanning=function(o){var m=r.setup,p=m.disabled,x=m.wheel,n=m.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!x.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,c=i.positionX,f=i.positionY,l=c-o.deltaX,g=f-o.deltaY,_=n.lockAxisX?c:l,w=n.lockAxisY?f:g,v=r.setup.alignmentAnimation,a=v.sizeX,h=v.sizeY,d=rs(r,a),u=rs(r,h);_===c&&w===f||il(r,_,w,d,u)}},this.onPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var x=bo(r,o);if(x){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(),Tt(r),wo(r,o),Ve(qe(r),o,p)))}}},this.onPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(!m){var x=yo(r);if(x){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),Co(r,o.clientX,o.clientY),Ve(qe(r),o,p))}}},this.onPanningStop=function(o){var m=r.props.onPanningStop;r.isPanning&&(Yp(r),Ve(qe(r),o,m))},this.onPinchStart=function(o){var m=r.setup.disabled,p=r.props,x=p.onPinchingStart,n=p.onZoomStart;if(!m){var i=d0(r,o);i&&(_0(r,o),Tt(r),Ve(qe(r),o,x),Ve(qe(r),o,n))}},this.onPinch=function(o){var m=r.setup.disabled,p=r.props,x=p.onPinching,n=p.onZoom;if(!m){var i=u0(r);i&&(o.preventDefault(),o.stopPropagation(),b0(r,o),Ve(qe(r),o,x),Ve(qe(r),o,n))}},this.onPinchStop=function(o){var m=r.props,p=m.onPinchingStop,x=m.onZoomStop;r.pinchStartScale&&(y0(r),Ve(qe(r),o,p),Ve(qe(r),o,x))},this.onTouchPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var x=bo(r,o);if(x){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,Tt(r);var i=o.touches,c=i.length===1,f=i.length===2;c&&(Tt(r),wo(r,o),Ve(qe(r),o,p)),f&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(m)return;var x=yo(r);if(!x)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];Co(r,n.clientX,n.clientY),Ve(qe(r),o,p)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var m=r.setup.disabled;if(!m){var p=k0(r,o);p&&C0(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(m){return r.pressedKeys[m]}):!0},this.setTransformState=function(o,m,p){var x=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(m)&&!Number.isNaN(p)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=m,r.transformState.positionY=p,r.applyTransformation();var n=qe(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Ve(n,{scale:o,positionX:m,positionY:p},x)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=dl(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,m,p){return r.props.customTransform?r.props.customTransform(o,m,p):r0(o,m,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,m=o.scale,p=o.positionX,x=o.positionY,n=r.handleTransformStyles(p,x,m);r.contentComponent.style.transform=n}},this.getContext=function(){return qe(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,m){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=m,ls(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,m),r.initializeWindowEvents(),r.isInitialized=!0;var p=qe(r);Ve(p,void 0,r.props.onInit)},this.props=s,this.setup=Eo(this.props),this.transformState=ol(this.props)}return e})(),qr=oe.createContext(null),j0=function(e,s){return typeof e=="function"?e(s):e},N0=oe.forwardRef(function(e,s){var r=C.useRef(new E0(e)).current,o=j0(e.children,wr(r));return C.useImperativeHandle(s,function(){return wr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),oe.createElement(qr.Provider,{value:r},o)});oe.forwardRef(function(e,s){var r=C.useRef(null),o=C.useContext(qr);return C.useEffect(function(){return o.onChange(function(m){if(r.current){var p=0,x=0;r.current.style.transform=o.handleTransformStyles(p,x,1/m.instance.transformState.scale)}})},[o]),oe.createElement("div",ts({},e,{ref:i0([r,s])}))});function R0(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",r==="top"&&o.firstChild?o.insertBefore(m,o.firstChild):o.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var A0=`.transform-component-module_wrapper__SPB86 {
38
- position: relative;
39
- width: -moz-fit-content;
40
- width: fit-content;
41
- height: -moz-fit-content;
42
- height: fit-content;
43
- overflow: hidden;
44
- -webkit-touch-callout: none; /* iOS Safari */
45
- -webkit-user-select: none; /* Safari */
46
- -khtml-user-select: none; /* Konqueror HTML */
47
- -moz-user-select: none; /* Firefox */
48
- -ms-user-select: none; /* Internet Explorer/Edge */
49
- user-select: none;
50
- margin: 0;
51
- padding: 0;
52
- transform: translate3d(0, 0, 0);
53
- }
54
- .transform-component-module_content__FBWxo {
55
- display: flex;
56
- flex-wrap: wrap;
57
- width: -moz-fit-content;
58
- width: fit-content;
59
- height: -moz-fit-content;
60
- height: fit-content;
61
- margin: 0;
62
- padding: 0;
63
- transform-origin: 0% 0%;
64
- }
65
- .transform-component-module_content__FBWxo img {
66
- pointer-events: none;
67
- }
68
- `,jo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};R0(A0);var M0=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,m=e.contentClass,p=m===void 0?"":m,x=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,c=i===void 0?{}:i,f=e.contentProps,l=f===void 0?{}:f,g=C.useContext(qr),_=g.init,w=g.cleanupWindowEvents,v=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=v.current,d=a.current;return h!==null&&d!==null&&_&&_?.(h,d),function(){w?.()}},[]),oe.createElement("div",ts({},c,{ref:v,className:"".concat(Ti.wrapperClass," ").concat(jo.wrapper," ").concat(o),style:x}),oe.createElement("div",ts({},l,{ref:a,className:"".concat(Ti.contentClass," ").concat(jo.content," ").concat(p),style:n}),s))},pl=function(){var e=C.useContext(qr);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},T0=function(){var e=pl();return wr(e)};function D0(e){var s=pl(),r=C.useState(e(Di(s))),o=r[0],m=r[1];return C.useEffect(function(){var p=!0,x=s.onChange(function(n){p&&m(e(Di(n.instance)))});return function(){x(),p=!1}},[e,s]),o}function L0(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 P0(e,s){return wt({queryKey:de.files.tree(e||"",s),queryFn:()=>Se.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function O0(e,s){return wt({queryKey:de.files.content(e||"",s||""),queryFn:()=>Se.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function I0(e){const s=tt();return C.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function B0(){const e=tt();return pt({mutationFn:s=>Se.post("/files/write",s),onSuccess:(s,r)=>{const o=de.files.content(r.workingDir,r.path),m=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:m?.language||L0(r.path)})}})}function F0(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function z0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const H0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function W0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&H0.has(s)?Qi:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?zs:s==="json"?ad:s==="md"||s==="mdx"||s==="txt"?Vi:Lc}const No=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:m,label:p})=>t.jsxs("button",{type:"button",onClick:r,className:J("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:m}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:p})]}),gl=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:x})=>{const{t:n}=ce(),{data:i,isLoading:c,isError:f}=P0(e,s),l=C.useMemo(()=>i?.items??[],[i?.items]);return c?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):f?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:l.map(g=>{if(g.type==="directory"){const h=F0(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(No,{depth:r,onClick:()=>m(h),rightIcon:d?t.jsx(dt,{size:14,className:"text-neutral-400"}):t.jsx(zt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(Mr,{size:14,className:"text-amber-500"}):t.jsx(Dc,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(gl,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:x})]},h)}const _=z0(s,g.name),w=W0(g),v=x===_,a=w===Qi;return t.jsx(No,{depth:r,active:v,onClick:()=>p(_),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:w?t.jsx(w,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},_)})})},$0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:m})=>{const{t:p}=ce(),[x,n]=C.useState(()=>new Set),i=I0(e),c=C.useCallback(f=>{n(l=>{const g=new Set(l);return g.has(f)?g.delete(f):g.add(f),g})},[]);return t.jsxs("div",{className:J("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:p("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("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:p("Refresh file tree"),children:t.jsx(Tr,{size:13})}),m&&t.jsx("button",{type:"button",onClick:m,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Collapse file tree"),children:t.jsx(jd,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(gl,{workingDir:e,path:"/",depth:0,expanded:x,toggleDir:c,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},U0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function q0(e){const s=e.split(".").pop()?.toLowerCase();return s?U0.has(s):!1}function K0(e,s){const r="/api",o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const X0=({filePath:e})=>{const{t:s}=ce(),{zoomIn:r,zoomOut:o,centerView:m}=T0(),p=D0(n=>n.state.scale),x=Math.round(p*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(Yd,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>m(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[x,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(Kd,{size:14})}),t.jsx("button",{type:"button",onClick:()=>m(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(kd,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Y0=({workingDir:e,filePath:s})=>{const{t:r}=ce(),[o,m]=C.useState(!1),p=K0(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(N0,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(X0,{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(M0,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:p,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function V0(e){const s=e.split("/");return s[s.length-1]||e}function G0(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 Q0=({active:e,name:s,isDirty:r,onClick:o,onClose:m})=>{const{t:p}=ce();return t.jsxs("button",{type:"button",onClick:o,className:J("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:J("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:m,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":p("Close tab"),title:p("Close"),children:t.jsx(Ft,{size:12})})]})},Z0=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:o}=ce(),[m,p]=C.useState([]),[x,n]=C.useState(null),i=B0(),[c,f]=C.useState(280),[l,g]=C.useState(!1),[_,w]=C.useState(!1),v=C.useRef(280),a=C.useCallback(()=>{g(D=>(D?f(v.current):v.current=c,!D))},[c]),h=C.useCallback(D=>{D.preventDefault(),w(!0);const I=D.clientX,L=c,F=A=>{const P=A.clientX-I,O=Math.min(480,Math.max(160,L+P));f(O)},z=()=>{w(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",z)},[c]);C.useEffect(()=>{p([]),n(null)},[e]);const d=C.useMemo(()=>m.find(D=>D.path===x)||null,[m,x]),{data:u,isFetching:b,isError:y,error:k}=O0(e,d?.isImage?null:x);C.useEffect(()=>{!x||!u||p(D=>D.map(I=>I.path!==x||I.isDirty||I.loaded?I:{...I,language:u.language||I.language,content:u.content,savedContent:u.content,isDirty:!1,loaded:!0}))},[x,u]);const E=C.useCallback(D=>{p(I=>{if(I.find(z=>z.path===D))return I;const F=q0(D);return[...I,{path:D,name:V0(D),language:G0(D),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),n(D)},[]),S=C.useCallback(D=>{p(I=>{const L=I.filter(F=>F.path!==D);return n(F=>F!==D?F:L.length?L[L.length-1].path:null),L})},[]),j=C.useCallback(D=>{p(I=>I.map(L=>{if(L.path!==x)return L;const F=D!==L.savedContent;return{...L,content:D,isDirty:F}}))},[x]),N=C.useCallback(async()=>{r||!e||!d||(await i.mutateAsync({workingDir:e,path:d.path,content:d.content}),p(D=>D.map(I=>I.path===d.path?{...I,savedContent:I.content,isDirty:!1,loaded:!0}:I)))},[d,r,i,e]),T=C.useRef(()=>{});C.useEffect(()=>{T.current=()=>{N().catch(()=>{})}},[N]),C.useEffect(()=>{const D=I=>{r||(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="s"&&(I.preventDefault(),T.current())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[r]);const M=C.useCallback((D,I)=>{D.addCommand(I.KeyMod.CtrlCmd|I.KeyCode.KeyS,()=>{T.current()})},[]);return t.jsxs("div",{className:J("flex h-full overflow-hidden bg-white",s),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:l?36:c,transition:_?"none":"width 0.15s ease"},children:l?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:a,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:o("Expand file tree"),children:t.jsx(Rd,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx($0,{workingDir:e,onFileSelect:E,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!l&&t.jsx("div",{onMouseDown:h,className:J("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:[m.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:o("No open files")}):m.map(D=>t.jsx(Q0,{active:D.path===x,name:D.name,isDirty:D.isDirty,onClick:()=>n(D.path),onClose:I=>{I.stopPropagation(),S(D.path)}},D.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:o("Read-only")}),i.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),o("Saving")]}),d?.isDirty&&!i.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:o("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?t.jsx(Y0,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(_p,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:D=>j(D??""),onMount:M,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),b&&!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(Ke,{size:14,className:"animate-spin"}),o("Loading file...")]})}),y&&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:[o("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("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:o("No workspace selected.")})})]})]})};function _n(e){return wt({queryKey:de.git.changes(e||""),queryFn:()=>Se.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function vl(e,s,r){return wt({queryKey:de.git.diff(e||"",s||"",r),queryFn:()=>Se.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function xl(e,s){return wt({queryKey:de.git.commitFiles(e||"",s||""),queryFn:()=>Se.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function _l(e,s,r){return wt({queryKey:de.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Se.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function ms(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function J0(e){if(!(e instanceof ea)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==Bs.REBASE&&s.conflictOp!==Bs.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:ms(s,"sourceBranch"),targetBranch:ms(s,"targetBranch"),sourceWorktreePath:ms(s,"sourceWorktreePath"),targetWorktreePath:ms(s,"targetWorktreePath"),sourceWorkspaceId:ms(s,"sourceWorkspaceId"),targetWorkspaceId:ms(s,"targetWorkspaceId")}}function Ro(e,s,r,o){const m=J0(e);if(m){r(m);return}o(e instanceof Error?e.message:s)}function bl({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:m,onRefreshCommitMessage:p,onConflict:x,onResolveConflicts:n}){const{t:i}=ce(),{data:c,isLoading:f}=cn(e),l=Th(),g=Ah(),_=Oa(),[w,v]=C.useState(!1),[a,h]=C.useState(null),[d,u]=C.useState(""),[b,y]=C.useState(!1);if(C.useEffect(()=>{b||u(o??"")},[o,b]),C.useEffect(()=>{w&&p?.()},[w,p]),f||!c)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-neutral-400 border-b border-neutral-100",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const k=c.conflictedFiles.length>0,E=c.operation!=="idle",S=c.hasUncommittedChanges||c.untrackedCount>0,j=c.uncommittedCount+c.untrackedCount,N=!k&&!E&&!S,T=c.operation==="idle"&&c.ahead===0&&c.behind===0&&!S&&!k,M=()=>{h(null),l.mutate(e,{onError:F=>{Ro(F,i("更新失败,请稍后重试"),z=>x(z),h)}})},D=()=>{h(null),y(!1),u(o??""),v(!0)},I=()=>{h(null);const F=d.trim()||void 0;g.mutate({id:e,commitMessage:F},{onSuccess:()=>v(!1),onError:z=>{Ro(z,i("提交失败,请稍后重试"),A=>{v(!1),x(A)},h)}})},L=()=>{g.isPending||(v(!1),h(null))};return T?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-neutral-400 border-b border-neutral-100",children:[t.jsx(bd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-neutral-200 bg-white",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}),S&&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(dd,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:j})})]}),k&&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(Rr,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:c.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:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-neutral-600 hover:bg-neutral-100 border border-neutral-200 transition-colors disabled:opacity-50",children:_.isPending?i("正在撤销..."):i("撤销操作")})]})]}),E&&!k&&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-blue-700",children:[t.jsx(Ke,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:c.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-neutral-600 hover:bg-neutral-100 border border-neutral-200 transition-colors disabled:opacity-50",children:[t.jsx(Fc,{size:12}),_.isPending?i("正在撤销..."):i("撤销操作")]})]}),!k&&!E&&(c.behind>0||c.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-neutral-600",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:c.behind})}),t.jsxs("button",{onClick:M,disabled:!N||l.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-white bg-blue-600 hover:bg-blue-700 transition-colors disabled:opacity-50",children:[t.jsx(Tr,{size:12}),l.isPending?i("正在同步..."):i("同步更新")]})]}),c.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-neutral-600",children:i("{count} 个文件变更,可以安全提交",{count:m??c.ahead})}),c.behind===0&&!S?t.jsxs("button",{onClick:D,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-white bg-emerald-600 hover:bg-emerald-700 transition-colors disabled:opacity-50",children:[t.jsx(ri,{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-neutral-400 bg-neutral-50 border border-neutral-200 cursor-not-allowed",title:i(S?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(ri,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(ws,{isOpen:w,onClose:L,title:i("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:L,disabled:g.isPending,className:"px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:i("取消")}),t.jsx("button",{onClick:I,disabled:g.isPending,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 rounded-lg transition-colors disabled:opacity-50",children:g.isPending?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:14,className:"animate-spin"}),i("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(ri,{size:14}),i("确认提交")]})})]}),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 bg-neutral-100 font-mono text-xs text-neutral-700",children:s}),t.jsx(Xc,{size:14,className:"text-neutral-400 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded bg-neutral-100 font-mono text-xs text-neutral-700",children:r})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1.5",children:i("提交消息")}),t.jsx("textarea",{value:d,onChange:F=>{y(!0),u(F.target.value)},placeholder:i("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-lg border border-neutral-200 text-sm font-mono text-neutral-800 placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-300 resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-neutral-400 leading-relaxed",children:i("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!d.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-neutral-400",children:i("留空将使用默认消息")})]}),a&&t.jsx("div",{className:"px-3 py-2 rounded-lg bg-red-50 border border-red-200 text-sm text-red-700",children:a})]})})]})}const Ao={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"},eg={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function tg(e){const s=e.split("/");return s[s.length-1]||e}function sg(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const rg=({entry:e,selected:s,onClick:r})=>{const{t:o}=ce(),m=Ao[e.status]||Ao.M,p=eg[e.status]||e.status,x=sg(e.path);return t.jsxs("button",{type:"button",onClick:r,className:J("flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer group w-full text-left",s?"bg-blue-50":"hover:bg-neutral-50"),children:[t.jsx("span",{className:J("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",m),title:o(p),children:e.status}),t.jsx("span",{className:"text-xs text-neutral-900 truncate",children:tg(e.path)}),x&&t.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:x})]})},Mo=({title:e,entries:s,type:r,selectedKey:o,onSelect:m})=>{const{t:p}=ce();return s.length===0?null:t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:s.length})]}),t.jsx("div",{className:"space-y-0.5",children:s.map(x=>{const n=`${r}:${x.path}`;return t.jsx(rg,{entry:x,selected:o===n,onClick:()=>m(x.path,r)},n)})})]})},ig=({line:e,lineNum:s})=>{let r="",o="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",o="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",o="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",o="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-neutral-400"),t.jsxs("div",{className:J("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:s}),t.jsx("span",{className:J("pl-2 whitespace-pre",o),children:e})]})},ng=({workingDir:e,filePath:s,type:r})=>{const{t:o}=ce(),{data:m,isLoading:p,isError:x}=vl(e,s,r);if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:o("No diff content available.")});const i=n.split(`
69
- `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((c,f)=>t.jsx(ig,{line:c,lineNum:f+1},f))})},og=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:m,canRunGitOperations:p,onRefreshCommitMessage:x,onConflict:n,onResolveConflicts:i})=>{const{t:c}=ce(),{data:f,isLoading:l,isError:g}=_n(e),[_,w]=C.useState(null),[v,a]=C.useState(260),[h,d]=C.useState(!1),u=C.useCallback(N=>{N.preventDefault(),d(!0);const T=N.clientX,M=v,D=L=>{const F=L.clientX-T,z=Math.min(480,Math.max(160,M+F));a(z)},I=()=>{d(!1),document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",D),document.addEventListener("mouseup",I)},[v]),b=_?`${_.type}:${_.path}`:null,y=(N,T)=>{w({path:N,type:T})};if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:c("No workspace selected.")});if(l)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:c("Loading changes...")})]});if(g)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:c("Failed to load changes.")});const k=f?.uncommitted||[],E=f?.committed||[],S=k.length+E.length,j=p&&s&&r&&o;return t.jsxs("div",{className:"flex flex-col h-full bg-white",children:[j&&n&&i&&t.jsx(bl,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:m,committedFileCount:E.length,onRefreshCommitMessage:x,onConflict:n,onResolveConflicts:i}),t.jsxs("div",{className:"flex flex-1 min-h-0",style:h?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:v},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{size:14,className:"text-neutral-500"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:c("Changes")}),S>0&&t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:S})]})}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:S===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[t.jsx(ys,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:c("No pending changes")})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(Mo,{title:"Uncommitted",entries:k,type:"uncommitted",selectedKey:b,onSelect:y}),t.jsx(Mo,{title:"Committed",entries:E,type:"committed",selectedKey:b,onSelect:y})]})})]}),t.jsx("div",{onMouseDown:u,className:J("w-1 shrink-0 cursor-col-resize transition-colors",h?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:_?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[t.jsx(zs,{size:14,className:"text-neutral-500"}),t.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:_.path}),t.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",c(_.type==="uncommitted"?"Uncommitted":"Committed"),")"]})]}),t.jsx(ng,{workingDir:e,filePath:_.path,type:_.type})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(zs,{size:28}),t.jsx("span",{className:"text-xs",children:c("Select a file to view diff")})]})})})]})]})},_i=50,To={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 ag(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Zt("{count}s ago",{count:r}):r<3600?Zt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Zt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Zt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function lg(e){const s=e.split("/");return s[s.length-1]||e}function cg(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const dg=({line:e,lineNum:s})=>{let r="",o="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",o="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",o="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",o="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-neutral-400"),t.jsxs("div",{className:J("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:s}),t.jsx("span",{className:J("pl-2 whitespace-pre",o),children:e})]})},ug=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ce(),{data:m,isLoading:p,isError:x}=_l(e,s,r);if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:o("No diff content available.")});const i=n.split(`
70
- `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((c,f)=>t.jsx(dg,{line:c,lineNum:f+1},f))})},hg=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:m}=ce(),{data:p,isLoading:x}=xl(e,s);if(x)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[t.jsx(Ke,{size:12,className:"animate-spin"}),t.jsx("span",{children:m("Loading...")})]});const n=p?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const c=To[i.status]||To.M,f=cg(i.path);return t.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),o(i.path)},className:J("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",r===i.path?"bg-blue-50":"hover:bg-neutral-50"),children:[t.jsx("span",{className:J("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",c),children:i.status}),t.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:lg(i.path)}),f&&t.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},i.path)})})},fg=({workingDir:e})=>{const{t:s}=ce(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:x,isFetchingNextPage:n}=la({queryKey:de.git.log(e||""),queryFn:({pageParam:y=0})=>Se.get("/git/log",{params:{workingDir:e||"",limit:String(_i),skip:String(y)}}),initialPageParam:0,getNextPageParam:(y,k)=>y.commits.length<_i?void 0:k.length*_i,enabled:!!e}),i=r?.pages.flatMap(y=>y.commits)||[],[c,f]=C.useState(null),[l,g]=C.useState(null),[_,w]=C.useState(280),[v,a]=C.useState(!1),h=C.useCallback(y=>{y.preventDefault(),a(!0);const k=y.clientX,E=_,S=N=>{const T=Math.min(480,Math.max(180,E+(N.clientX-k)));w(T)},j=()=>{a(!1),document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",j)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",j)},[_]),d=y=>{c===y?(f(null),g(null)):(f(y),g(null))},u=C.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(m)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:s("Failed to load history.")});if(i.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[t.jsx(Ss,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const b=i.find(y=>y.hash===c);return t.jsxs("div",{className:"flex h-full bg-white",style:v?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:_},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ss,{size:14,className:"text-neutral-500"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:s("History")}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:i.length})]})}),t.jsxs("div",{ref:u,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[i.map(y=>{const k=c===y.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>d(y.hash),className:J("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",k?"bg-blue-50":"hover:bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:J("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),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-blue-600 shrink-0",children:y.shortHash}),t.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:y.message}),t.jsx(zt,{size:12,className:J("shrink-0 text-neutral-400 transition-transform",k&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:y.author}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:ag(y.timestamp)})]})]})]}),k&&t.jsxs(t.Fragment,{children:[y.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-neutral-600 whitespace-pre-wrap leading-4 border-l-2 border-blue-100 ml-3",children:y.body}),t.jsx(hg,{workingDir:e,hash:y.hash,selectedPath:l,onSelectFile:g})]})]},y.hash)}),x&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,className:"w-full py-2 text-xs text-neutral-500 hover:text-neutral-700 hover:bg-neutral-50 rounded transition-colors flex items-center justify-center gap-1.5",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:J("w-1 shrink-0 cursor-col-resize transition-colors",v?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:l&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[t.jsx(zs,{size:14,className:"text-neutral-500"}),t.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:l}),t.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",b?.shortHash,")"]})]}),t.jsx(ug,{workingDir:e,hash:c,filePath:l})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(zs,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function mg(e){return wt({queryKey:de.previews.status(e??""),queryFn:async()=>{const s=await Se.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function pg(e){const s=tt();return pt({mutationFn:r=>Se.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:de.previews.status(e)}),s.invalidateQueries({queryKey:de.workspaces.all}))}})}function gg(){return"3000, localhost:3000, http://127.0.0.1:5173"}function vg({workspaceId:e,readOnly:s}){const{t:r}=ce(),{data:o,isLoading:m,refetch:p,isFetching:x}=mg(e),n=pg(e),[i,c]=C.useState(""),[f,l]=C.useState(0);C.useEffect(()=>{c(o?.target??"")},[o?.target]);const g=C.useMemo(()=>!o?.ready||!o.viewUrl?null:`${o.viewUrl}?_=${f}`,[f,o?.ready,o?.viewUrl]),_=async()=>{if(e)try{await n.mutateAsync(i.trim()||null),l(v=>v+1),at.success(r("Preview target saved"))}catch(v){const a=v instanceof Error?v.message:r("Failed to save preview target");at.error(a)}},w=async()=>{await p(),l(v=>v+1)};return e?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-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:i,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&!v.nativeEvent.isComposing&&(v.preventDefault(),_())},disabled:s||n.isPending,placeholder:gg(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-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.jsxs(Pe,{type:"button",size:"sm",variant:"outline",onClick:_,disabled:s||n.isPending,title:r("Save preview target"),children:[n.isPending?t.jsx(Ke,{className:"animate-spin"}):t.jsx(Bd,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Pe,{type:"button",size:"sm",variant:"outline",onClick:w,disabled:x,title:r("Refresh preview"),children:[x?t.jsx(Ke,{className:"animate-spin"}):t.jsx(Tr,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&t.jsx(Pe,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:t.jsx("a",{href:o.viewUrl,target:"_blank",rel:"noopener noreferrer",children:t.jsx(Yi,{})})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:m?r("Checking preview target..."):o?.ready?`${r("Proxying")} ${o.target}`:o?.configured?`${r("Preview target is not reachable")}${o.error?`: ${o.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?t.jsx("iframe",{src:g,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},g):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:o?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function xg(e){switch(e){case jt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case jt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case jt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case jt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Do(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 _g(e){return e.length<=34?e:`...${e.slice(-31)}`}function yl({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:m,className:p,buttonClassName:x}){const{t:n}=ce(),[i,c]=C.useState(!1),f=C.useRef(null),l=C.useMemo(()=>mn(e,s),[e,s]),g=l.find(_=>_.workspace.id===r)??l[0];return C.useEffect(()=>{if(!i)return;const _=w=>{f.current&&!f.current.contains(w.target)&&c(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[i]),l.length<=1?null:t.jsxs("div",{ref:f,className:J("relative",p),children:[t.jsxs("button",{type:"button",onClick:()=>c(_=>!_),disabled:m,className:J("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",x),title:n("Workspace"),children:[t.jsx(Hs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Do(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:_g(cs(g.workspace))}),t.jsx(dt,{size:13,className:J("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:l.map(_=>{const w=_.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(_.workspace.id),c(!1)},className:J("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",w&&"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:w?t.jsx(ft,{size:13}):t.jsx(Gi,{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(_.displayName)}),t.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Do(_.roleLabel)),children:n(_.roleLabel)}),t.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",xg(_.workspace.status)),children:_.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:cs(_.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:[_.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",_.ownerName]}),_.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",_.parentBranchName]}),t.jsx("span",{children:_.workspace.id.slice(0,8)})]})]})]},_.workspace.id)})})]})}const bg=[{key:"changes",label:"Changes",icon:t.jsx(ys,{size:14})},{key:"history",label:"History",icon:t.jsx(Ss,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Ks,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(mr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ia,{size:14})}],yg=[{key:"history",label:"History",icon:t.jsx(Ss,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Ks,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(mr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ia,{size:14})}],Sg=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{onClick:s,className:J("flex items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px",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})]}),Sl=oe.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:m,projectId:p,hideChanges:x,readOnly:n,repoDeleted:i,teamRun:c,teamStatus:f,gitProps:l,workspaces:g,selectedWorkspaceId:_,onSelectWorkspace:w,tabRef:v}){const{t:a}=ce(),h=C.useMemo(()=>{const N=x?yg:bg,T=n?N.filter(M=>M.key!=="terminal"):N;return c?[{key:"team-status",label:"Team Status",icon:t.jsx(ss,{size:14})},...T]:T},[x,n,c]),[d,u]=C.useState(x?"history":"changes");C.useImperativeHandle(v,()=>({setTab:N=>u(N)}),[]);const{data:b}=Pc(p??""),y=C.useMemo(()=>{if(!b?.quickCommands)return[];try{return JSON.parse(b.quickCommands)}catch{return[]}},[b?.quickCommands]),[k,E]=C.useState([]),S=C.useRef(void 0);C.useEffect(()=>{m&&m!==S.current&&(S.current=m,E(N=>N.includes(m)?N:[...N,m]))},[m]),C.useEffect(()=>{n&&d==="terminal"&&u(x?"history":"changes")},[d,x,n]),C.useEffect(()=>{c||d!=="team-status"||u(x?"history":"changes")},[d,x,c]);const j=!!w&&mn(g,c).length>1;return t.jsxs("div",{className:J("flex flex-col h-full bg-white",s),children:[n&&t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:a(i?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),t.jsx("div",{className:"flex items-center px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:h.map(N=>t.jsx(Sg,{active:d===N.key,onClick:()=>u(N.key),icon:N.icon,label:a(N.label)},N.key))}),t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[j&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(yl,{workspaces:g,teamRun:c,selectedWorkspaceId:_,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[d==="team-status"&&c&&f,d==="editor"&&t.jsx(Z0,{workingDir:m,readOnly:n}),k.map(N=>{const T=d==="terminal"&&m===N;return t.jsx("div",{className:"h-full absolute inset-0",style:{display:T?"block":"none"},children:t.jsx(dm,{cwd:N,isVisible:T,quickCommands:y})},N)}),d==="preview"&&t.jsx(vg,{workspaceId:o,readOnly:n}),d==="changes"&&t.jsx(og,{workingDir:m,workspaceId:o,branchName:l?.branchName,targetBranch:l?.targetBranch,commitMessage:l?.commitMessage,canRunGitOperations:l?.canRunGitOperations,onRefreshCommitMessage:l?.onRefreshCommitMessage,onConflict:l?.onConflict,onResolveConflicts:l?.onResolveConflicts}),d==="history"&&t.jsx(fg,{workingDir:m})]})]})]})}),Lo=1500,wg=3e3;function Cg(e){const[s,r]=C.useState(null),o=C.useRef(0),m=C.useRef(null),p=C.useRef(null);return C.useEffect(()=>{if(!e)return;const x=()=>{p.current&&(clearTimeout(p.current),p.current=null)},n=Gt.connect(),i=f=>{r(f),p.current=setTimeout(()=>r(null),wg)},c=f=>{if(f.taskId!==e)return;const l={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.status==="running"){x(),m.current=null,o.current===0&&(o.current=Date.now()),r(l);return}const g=o.current>0?Date.now()-o.current:0,_=Lo-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),m.current=l,p.current=setTimeout(()=>i(l),Lo)):_>0?(m.current=l,x(),p.current=setTimeout(()=>i(l),_)):i(l)};return n.on(nt.WORKSPACE_SETUP_PROGRESS,c),()=>{n.off(nt.WORKSPACE_SETUP_PROGRESS,c),x(),o.current=0,m.current=null}},[e]),s}function bn(){const e=tt();return pt({mutationFn:s=>Se.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.sessions.detail(r)}),e.invalidateQueries({queryKey:de.tasks.all})}})}function wl(){const e=tt();return pt({mutationFn:s=>Se.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.sessions.detail(r)})}})}function yn(){const e=tt();return pt({mutationFn:({id:s,message:r,providerId:o})=>Se.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function Cl(e,s){return C.useMemo(()=>{for(let r=e.length-1;r>=0;r--){const o=e[r];if(o.tokenUsage&&typeof o.tokenUsage.totalTokens=="number"&&o.tokenUsage.totalTokens>0)return{totalTokens:o.tokenUsage.totalTokens,modelContextWindow:o.tokenUsage.modelContextWindow}}return s??null},[e,s])}function kl({isOpen:e,onClose:s,taskId:r,taskTitle:o,taskDescription:m}){const{t:p}=ce(),[x,n]=C.useState(""),[i,c]=C.useState(""),[f,l]=C.useState(it.WORKTREE),[g,_]=C.useState("idle"),[w,v]=C.useState(null),a=tt(),h=Pa(r),d=bn(),{data:u,isLoading:b}=Cs();C.useEffect(()=>{if(!e||!u)return;const N=u.find(T=>T.availability.type!=="NOT_FOUND");N&&n(N.provider.id)},[e,u]),C.useEffect(()=>{if(e){const N=[o];m&&N.push(m),c(N.join(`
71
-
72
- `)),l(it.WORKTREE),_("idle"),v(null)}},[e,o,m]);const y=g!=="idle",k=async()=>{if(!(!x||!i.trim())){v(null);try{_("creating-workspace");const N=await h.mutateAsync({workspaceKind:f});_("creating-session");const T=await Se.post(`/workspaces/${N.id}/sessions`,{providerId:x,prompt:i.trim()});_("starting-session"),await d.mutateAsync(T.id),await a.invalidateQueries({queryKey:de.workspaces.list(r)}),_("idle"),s()}catch(N){_("idle"),v(N instanceof Error?N.message:p("启动失败,请重试"))}}},E={idle:p("启动"),"creating-workspace":p("创建工作空间..."),"creating-session":p("创建会话..."),"starting-session":p("启动 Agent...")},S=(u??[]).map(({provider:N,availability:T})=>{const M=T.type!=="NOT_FOUND";return{value:N.id,label:M?N.name:`${N.name}${p(" (不可用)")}`,disabled:!M}}),j=[{value:it.WORKTREE,label:p("工作树模式")},{value:it.MAIN_DIRECTORY,label:p("本地模式")}];return t.jsx(ws,{isOpen:e,onClose:y?()=>{}:s,title:p("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Pe,{variant:"outline",onClick:s,disabled:y,children:p("取消")}),t.jsx(Pe,{onClick:k,disabled:y||!x||!i.trim(),children:E[g]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("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:p("Agent")}),t.jsx(os,{value:x,onChange:n,options:S,placeholder:p(b?"加载中...":"选择 Agent"),disabled:y||b})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("模式")}),t.jsx(os,{value:f,onChange:N=>l(N),options:j,disabled:y})]})]}),f===it.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-800",children:p("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("任务描述")}),t.jsx("textarea",{value:i,onChange:N=>c(N.target.value),rows:5,disabled:y,placeholder:p("描述你想让 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"})]}),w&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:w})]})})}function El(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function kg(e,s,r){const o=e?.providerId??r?.providerId??null,m=o?s?.find(n=>n.provider.id===o)?.provider:null,p=m?.name??o??e?.agentType??r?.agentType??null;if(!p)return null;const x=o&&m?.name&&o!==m.name?`${m.name} (${o})`:p;return{label:p,title:x}}function jl({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:m,agentTypeFallback:p,tokenTooltipSide:x="top"}){const{t:n}=ce(),i=kg(e,s,{providerId:m,agentType:p});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(Ks,{size:o?12:14,className:"shrink-0 text-neutral-400"}),t.jsx("span",{className:"min-w-0 truncate",children:ki(i.label,o?12:18)})]}),t.jsx(hn,{usage:r,tooltipSide:x})]})}function Po(e,s,r,o){if(r.filter(x=>x===o).length<=1)return e;const p=r.slice(0,s+1).filter(x=>x===o).length;return`${e} #${p}`}function Eg(e){return Object.values(e).filter(Boolean).length}function Nl({mode:e,setMode:s,selectedTemplateId:r,setSelectedTemplateId:o,selectedMemberPresetIds:m,setSelectedMemberPresetIds:p,disabled:x=!1}){const{t:n}=ce(),{data:i}=Cs(),{data:c,isError:f,isFetching:l,isLoading:g,refetch:_}=Jo(),{data:w,isError:v,isFetching:a,isLoading:h,refetch:d}=jc(),u=C.useMemo(()=>new Map((i??[]).map(({provider:N,availability:T})=>[N.id,N.name+(T.type==="NOT_FOUND"?n(" (不可用)"):"")])),[i,n]),b=C.useMemo(()=>new Map((c??[]).map(N=>[N.id,N])),[c]),y=C.useMemo(()=>new Map((w??[]).map(N=>[N.id,N])),[w]),k=C.useMemo(()=>m.map(N=>b.get(N)).filter(N=>!!N),[b,m]);C.useEffect(()=>{c!==void 0&&p(N=>{const T=N.filter(M=>b.has(M));return T.length===N.length&&T.every((M,D)=>M===N[D])?N:T})},[c,b,p]),C.useEffect(()=>{w!==void 0&&o(N=>!N||y.has(N)?N:null)},[o,y,w]);const E=N=>{x||o(T=>T===N?null:N)},S=N=>{x||p(T=>[...T,N])},j=N=>{x||p(T=>T.filter((M,D)=>D!==N))};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 shrink-0",children:n("执行模式")}),t.jsxs("div",{className:"inline-flex rounded-md bg-white p-0.5 shadow-sm",children:[t.jsxs("button",{type:"button",onClick:()=>!x&&s("AUTO"),disabled:x,className:J("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(fa,{size:11}),n("自动模式")]}),t.jsxs("button",{type:"button",onClick:()=>!x&&s("CONFIRM"),disabled:x,className:J("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(ha,{size:11}),n("确认模式")]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("section",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium text-neutral-500 mb-1.5",children:n("团队模板")}),v?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:n("团队模板加载失败")}),t.jsx("button",{type:"button",onClick:()=>{d()},disabled:x||a,className:"ml-2 underline hover:no-underline",children:n("重试")})]}):h?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(Ke,{size:12,className:"animate-spin"}),n("加载中...")]}):(w??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[n("当前没有团队模板"),t.jsx(An,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:n("去创建")})]}):t.jsx("div",{className:"space-y-1.5",children:(w??[]).map(N=>{const T=N.id===r,M=N.members?.length??0,D=N.members?.map(L=>L.memberPresetId)??[],I=N.members?.slice(0,3).map((L,F)=>Po(L.memberPreset?.name??L.memberPresetId,F,D,L.memberPresetId)).join(", ");return t.jsx("button",{type:"button",onClick:()=>E(N.id),disabled:x,className:J("w-full rounded-lg px-3 py-2 text-left transition-all disabled:cursor-not-allowed disabled:opacity-60",T?"bg-blue-50 ring-1 ring-blue-200":"bg-white hover:bg-white/80"),children:t.jsxs("div",{className:"flex items-center 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("span",{className:J("text-xs truncate",T?"font-medium text-blue-800":"text-neutral-800"),children:N.name}),t.jsxs("span",{className:"text-[10px] text-neutral-400 shrink-0",children:[M,n("人")]})]}),I&&t.jsx("div",{className:"mt-0.5 text-[10px] text-neutral-400 truncate",children:I})]}),T&&t.jsx(ft,{size:13,className:"shrink-0 text-blue-600"})]})},N.id)})})]}),t.jsxs("section",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:n("追加成员")}),k.length>0&&t.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-blue-600 text-[9px] font-medium text-white px-1",children:k.length})]}),k.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:k.map((N,T)=>{const M=Po(N.name,T,m,N.id);return t.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded bg-blue-50 text-[10px] text-neutral-700",children:[t.jsx(Rt,{name:N.name,avatar:N.avatar,className:"h-3.5 w-3.5 text-[7px]"}),t.jsx("span",{className:"max-w-[80px] truncate",children:M}),t.jsx("button",{type:"button",onClick:()=>j(T),disabled:x,className:"p-0.5 text-neutral-400 hover:text-red-500 disabled:opacity-30 rounded",children:t.jsx(Ft,{size:9})})]},`${N.id}-${T}`)})}),f?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:n("成员预设加载失败")}),t.jsx("button",{type:"button",onClick:()=>{_()},disabled:x||l,className:"ml-2 underline hover:no-underline",children:n("重试")})]}):g?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(Ke,{size:12,className:"animate-spin"}),n("加载中...")]}):(c??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[n("当前没有成员预设"),t.jsx(An,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:n("去创建")})]}):t.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:(c??[]).map(N=>{const T=m.filter(I=>I===N.id).length,M=u.get(N.providerId)??N.providerId,D=Eg(N.capabilities);return t.jsxs("button",{type:"button",onClick:()=>S(N.id),disabled:x,className:J("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left transition-all",x&&"cursor-not-allowed opacity-60","bg-white hover:bg-white/80"),children:[t.jsx(Rt,{name:N.name,avatar:N.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs text-neutral-800 truncate",children:N.name}),t.jsxs("div",{className:"text-[10px] text-neutral-400 truncate",children:[M," · ",D,"/10"]})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[T>0&&t.jsxs("span",{className:"text-[9px] text-blue-600 font-medium",children:["×",T]}),t.jsx(Bt,{size:12,className:"text-neutral-300"})]})]},N.id)})})]})]})]})}function jg({isOpen:e,onClose:s,taskId:r}){const{t:o}=ce(),[m,p]=C.useState("AUTO"),[x,n]=C.useState(null),[i,c]=C.useState([]),[f,l]=C.useState(null),g=ta();C.useEffect(()=>{e&&(p("AUTO"),n(null),c([]),l(null))},[e]);const _=g.isPending,w=!!x||i.length>0,v=async()=>{if(!_){if(!x&&i.length===0){l(o("请选择至少一个团队模板或成员预设。"));return}l(null);try{await g.mutateAsync({taskId:r,mode:m,...x?{teamTemplateId:x}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(h){if(h instanceof ea&&h.status===409){l(o("该任务已经存在 TeamRun。请刷新后再试。"));return}l(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=_||!w;return t.jsxs(ws,{isOpen:e,onClose:_?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Pe,{type:"button",variant:"outline",onClick:s,disabled:_,children:o("取消")}),t.jsx(Pe,{type:"button",onClick:v,disabled:a,children:o(_?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(Nl,{mode:m,setMode:p,selectedTemplateId:x,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:c,disabled:_}),f&&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:f})]})}function Rl({providers:e,currentProviderId:s,agentType:r,onSelect:o}){const{t:m}=ce(),[p,x]=C.useState(!1),n=C.useRef(null),i=e.filter(f=>String(f.provider.agentType)===r),c=e.find(f=>f.provider.id===s);return C.useEffect(()=>{function f(l){n.current&&!n.current.contains(l.target)&&x(!1)}if(p)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[p]),i.length<=1?t.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[t.jsx(Mn,{size:14,className:"shrink-0"}),t.jsx("span",{children:c?.provider.name?ki(c.provider.name,12):r})]}):t.jsxs("div",{className:"relative",ref:n,children:[t.jsxs("button",{onClick:()=>x(!p),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${c?.provider.name??r} (click to change)`,children:[t.jsx(Mn,{size:14,className:"shrink-0"}),t.jsx("span",{children:c?.provider.name?ki(c.provider.name,12):r}),t.jsx(dt,{size:12,className:`shrink-0 transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[t.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),i.map(f=>t.jsxs("button",{onClick:()=>{o(f.provider.id),x(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${f.provider.id===s?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate max-w-[120px]",children:f.provider.name}),f.provider.isDefault&&t.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),f.provider.id===s&&t.jsx(ft,{size:14,className:"shrink-0"})]},f.provider.id))]})]})}function Ng({commands:e,selectedIndex:s,query:r,hasCatalog:o,title:m="Slash Commands",queryPrefix:p="/",emptyCatalogMessage:x="No slash commands catalog for this agent yet.",emptyQueryMessage:n,insertionHint:i="Enter / Tab to insert",compact:c=!1,onSelect:f}){const l=c?"px-1.5 pb-1.5":"px-2 pb-2",g=c?"px-2 py-1.5":"px-2.5 py-2",_=c?"max-h-36":"max-h-48";return t.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[t.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:i})]}),e.length===0?t.jsx("div",{className:`${c?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?n??`No matches for ${p}${r}`:x}):t.jsx("div",{className:`${l} ${_} overflow-y-auto`,children:e.map((w,v)=>t.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>f(w),className:`w-full rounded-lg border text-left transition-colors ${v===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:w.command}),w.kind&&w.kind!=="builtin"?t.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:w.scope?`${w.scope} ${w.kind}`:w.kind}):null]}),t.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:w.description})]},w.command))})]})}const Yt=12,cr=8;function Cr({open:e,anchorRef:s,commands:r,selectedIndex:o,query:m,hasCatalog:p,title:x,queryPrefix:n,emptyCatalogMessage:i,emptyQueryMessage:c,insertionHint:f,compact:l=!1,onSelect:g}){const _=C.useRef(null),[w,v]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){v(null);return}const a=s.current;if(!a)return;let h=0;const d=()=>{const y=s.current;if(!y)return;const k=y.getBoundingClientRect(),E=window.innerWidth,S=window.innerHeight,j=l?260:320,N=l?E-Yt*2:560,T=Math.min(Math.max(k.width,j),Math.max(j,N)),M=Math.min(Math.max(Yt,k.left),Math.max(Yt,E-Yt-T)),D=S-k.bottom-cr-Yt,I=k.top-cr-Yt,L=_.current?.offsetHeight??(l?220:280),F=l?240:320,z=D<180&&I>D,P=Math.max(120,Math.min(F,z?I:D)),O=z?Math.max(Yt,k.top-cr-Math.min(L,P)):Math.min(S-Yt-Math.min(L,P),k.bottom+cr);v({top:O,left:M,width:T,maxHeight:P})},u=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};u();const b=new ResizeObserver(u);return b.observe(a),_.current&&b.observe(_.current),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),window.visualViewport?.addEventListener("resize",u),window.visualViewport?.addEventListener("scroll",u),()=>{cancelAnimationFrame(h),b.disconnect(),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),window.visualViewport?.removeEventListener("resize",u),window.visualViewport?.removeEventListener("scroll",u)}},[s,r.length,l,e,m,o]),!e||!w||typeof document>"u"?null:Qt.createPortal(t.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:t.jsx("div",{ref:_,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:w.top,left:w.left,width:w.width,maxHeight:w.maxHeight},children:t.jsx(Ng,{commands:r,selectedIndex:o,query:m,hasCatalog:p,title:x,queryPrefix:n,emptyCatalogMessage:i,emptyQueryMessage:c,insertionHint:f,compact:l,onSelect:g})})}),document.body)}function Rg({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ce(),m=Oa();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const p=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 px-4 py-3 rounded-lg border border-amber-200 bg-amber-50 flex items-center gap-3",children:[t.jsx(Rr,{size:18,className:"text-amber-600 shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium text-amber-900",children:o("{opLabel} 冲突 — {count} 个文件",{opLabel:p,count:s.conflictedFiles.length})})}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(Pe,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:o("中止操作")}),t.jsx(Pe,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Al(e){return e.length>0?e.map(s=>`- ${s}`).join(`
73
- `):"- 未获取到冲突文件列表"}function Ml(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 Ag(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 Mg(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 Tg(e,s,r,o,m){const p=Al(r),x=Ml(m);return o===Bs.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",p,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
74
- `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",p,"","### 解决步骤",...Ag(e,m)].join(`
75
- `)}function Dg(e){const s=e.conflictOp===Bs.REBASE?"Rebase":"Merge",r=Al(e.conflictedFiles),o=[...Ml(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===Bs.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":Mg(e)].join(`
76
- `)}function Lg(e){if(e.teamRunId)return{type:"team_room",message:Dg(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:Tg(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Tl({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:m,sourceBranch:p,targetBranch:x,operation:n,worktreePath:i,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:w,sessions:v,currentSessionId:a,teamRunId:h}){const{t:d}=ce(),[u,b]=C.useState(""),y=yn(),k=Bi(h??""),E=ln(),S=!!h,j=a||u,N=S?k.isPending:y.isPending,T=()=>{const F=Lg({workspaceId:r,worktreePath:i,operation:n,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:w,sourceBranch:p,targetBranch:x,conflictedFiles:m,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:u});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{at.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&y.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},M=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",I=!S&&!a&&v.length>0,L=S||!!j;return t.jsx(ws,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Pe,{variant:"outline",onClick:M,children:d("在 IDE 中打开")}),t.jsx(Pe,{onClick:T,disabled:!L||N,children:d(N?"发送中...":"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:m.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(F=>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:F},F))})]}),S&&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,由团队调度处理。")}),I&&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:u,onChange:F=>b(F.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...")}),v.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!S&&!j&&v.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Pg({agentType:e,workingDir:s}){return wt({queryKey:de.system.slashCommandCatalog(e,s),queryFn:async()=>(await Se.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function Og(e,s){const r=new Set,o=[];for(const m of[...e,...s]){const p=m.command.trim().toLowerCase();!p||r.has(p)||(r.add(p),o.push(m.kind?m:{...m,kind:"builtin"}))}return o}function Kr(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function Ig(e){return Kr(e.command)}function Bg(e,s){if(!s)return 1e3;const r=Ig(e),o=e.aliases?.map(Kr)??[],m=[r,...o];let p=0;for(const n of m)n===s?p=Math.max(p,500):n.startsWith(s)?p=Math.max(p,400-(n.length-s.length)):n.includes(s)&&(p=Math.max(p,250-n.indexOf(s)));return p>0?p:`${r} ${o.join(" ")} ${e.description}`.toLowerCase().includes(s)?100:0}function Oo(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:Kr(s[2]),replaceStart:r}}function Dl(e,s){const r=Kr(s);return r?e.map((o,m)=>({command:o,index:m,score:Bg(o,r)})).filter(o=>o.score>0).sort((o,m)=>m.score-o.score||o.index-m.index||o.command.command.localeCompare(m.command.command)).map(o=>o.command):e.slice()}const Fg=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],zg=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],Hg=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],Wg=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],$g={[It.CODEX]:Fg,[It.CLAUDE_CODE]:zg,[It.GEMINI_CLI]:Hg,[It.CURSOR_AGENT]:Wg};function Ll(e){return e.trim().toLowerCase().replace(/^\//,"")}function Ug(e){return e?($g[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function qg(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?Ll(s[1]):null}function Kg(e,s){return Dl(e,Ll(s))}function Xg(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 Pl({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:x}){const[n,i]=C.useState(0),{data:c=[]}=Pg({agentType:e,workingDir:s}),f=C.useMemo(()=>Og(Ug(e),c),[e,c]),l=C.useMemo(()=>qg(r),[r]),g=C.useMemo(()=>l===null?[]:Kg(f,l),[f,l]),_=C.useCallback(()=>{const a=m.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,x))}px`)},[x,p,m]);C.useEffect(()=>{i(0)},[e,l]),C.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const w=C.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;o(d),requestAnimationFrame(()=>{const u=m.current;u&&(_(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,_,o,m]),v=C.useCallback(a=>l===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):Xg(a)?(a.preventDefault(),w(g[n]??g[0]),!0):!1,[w,g,l,n]);return{allCommands:f,query:l,filteredCommands:g,selectedIndex:n,setSelectedIndex:i,applyCommand:w,handleKeyDown:v}}function Yg({agentType:e,workingDir:s}){return wt({queryKey:de.system.skillCatalog(e,s),queryFn:async()=>(await Se.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===It.CODEX,staleTime:3e4})}function Vg(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 Ol({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:x}){const[n,i]=C.useState(0),{data:c=[]}=Yg({agentType:e,workingDir:s}),l=C.useMemo(()=>e===It.CODEX?Oo(r):null,[e,r])?.query??null,g=C.useMemo(()=>l===null?[]:Dl(c,l),[l,c]),_=C.useCallback(()=>{const a=m.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,x))}px`)},[x,p,m]);C.useEffect(()=>{i(0)},[e,l]),C.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const w=C.useCallback(a=>{const h=Oo(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const u=m.current;u&&(_(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,_,o,m]),v=C.useCallback(a=>l===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):Vg(a)?(a.preventDefault(),w(g[n]??g[0]),!0):!1,[w,g,l,n]);return{allSkills:c,query:l,filteredSkills:g,selectedIndex:n,setSelectedIndex:i,applySkill:w,handleKeyDown:v}}const Gg="/api",Qg=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Gg}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Zg=675,Io=320,Bo=1200;function Jg(){const{t:e}=ce();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 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-neutral-300",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-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-neutral-500 leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const Fo=[{status:pe.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:t.jsx(Fi,{className:"w-3 h-3"})},{status:pe.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:t.jsx(zi,{className:"w-3 h-3"})},{status:pe.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:t.jsx(Hi,{className:"w-3 h-3"})},{status:pe.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:t.jsx(Wi,{className:"w-3 h-3"})},{status:pe.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:t.jsx($i,{className:"w-3 h-3"})}];function ev({status:e,onChangeStatus:s}){const{t:r}=ce(),[o,m]=C.useState(!1),p=C.useRef(null);C.useEffect(()=>{if(!o)return;const n=i=>{p.current&&!p.current.contains(i.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const x=Fo.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:p,children:[t.jsxs("button",{onClick:()=>s&&m(n=>!n),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${x.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[x.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-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:Fo.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),m(!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-neutral-700",children:r(n.status)})]},n.status))})]})}function tv({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o}){const{t:m}=ce(),[p,x]=C.useState(""),[n,i]=C.useState(!1),[c,f]=C.useState(!1),[l,g]=C.useState(!1),[_,w]=C.useState(!1),[v,a]=C.useState(!1),[h,d]=C.useState(!1),[u,b]=C.useState(null),y=C.useRef(null),[k,E]=C.useState(!1),[S,j]=C.useState(null),[N,T]=C.useState(void 0),[M,D]=C.useState(!1),I=C.useRef(null),L=C.useRef(null),F=C.useRef(null),z=C.useRef(null),{scrollRef:A,contentRef:P,isAtBottom:O,scrollToBottom:B}=un({resize:"smooth",initial:"instant"}),[U,X]=C.useState(Zg),[V,Z]=C.useState(!0),[q,R]=C.useState(!1),H=C.useRef(0),K=C.useRef(0),W=C.useRef(null),{data:Y,isLoading:G}=an(e?.id??""),ae=Cg(e?.id),{data:le}=sa(e?.id??""),{data:Te}=ra(le?.id??""),De=Bi(le?.id??""),re=le??null,We=!!re,Be=le===null;C.useEffect(()=>{D(!1),j(null),T(void 0)},[e?.id]);const Re=C.useMemo(()=>za(Y,re,N),[N,re,Y]);C.useEffect(()=>{N&&!Y?.some(ee=>ee.id===N)&&T(void 0)},[N,Y]);const ke=C.useMemo(()=>Y?.find(ee=>ee.id===Re),[Re,Y]),Ee=ke?.status===jt.ACTIVE?ke.id:void 0,ve=Ha(ke,re);C.useEffect(()=>{if(!M||!Y)return;Y.some(ue=>ue.status==="ACTIVE"&&ue.sessions&&ue.sessions.length>0)&&D(!1)},[Y,M]);const Q=C.useMemo(()=>{if(M||!Y)return null;const ee=ct=>{const si=ct.createdAt,Rs=ct.endedAt??ct.startedAt??si;if(!Rs)return 0;const hs=Date.parse(Rs);return Number.isNaN(hs)?0:hs},ue=(ct,si)=>{const Rs=ct.filter(hs=>si.includes(hs.status));return Rs.length===0?null:Rs.sort((hs,cc)=>ee(cc)-ee(hs))[0]??null},Ie=Y.filter(ct=>ct.status==="ACTIVE"&&Array.isArray(ct.sessions)).flatMap(ct=>ct.sessions??[]),bt=ue(Ie,[Ze.RUNNING])??ue(Ie,[Ze.PENDING])??ue(Ie,[Ze.COMPLETED,Ze.FAILED,Ze.CANCELLED]);if(bt)return bt;const yt=Y.filter(ct=>(ct.status==="MERGED"||ct.status==="ABANDONED"||ct.status==="HIBERNATED")&&Array.isArray(ct.sessions)).flatMap(ct=>ct.sessions??[]);return ue(yt,[Ze.COMPLETED,Ze.FAILED,Ze.CANCELLED])},[Y,M]),ye=Q?.id??"",Ae=We?S??"":ye,te=C.useMemo(()=>{if(!S||!Y)return null;for(const ee of Y){const ue=ee.sessions?.find(Ie=>Ie.id===S);if(ue)return ue}return null},[S,Y]),ie=C.useMemo(()=>{if(!S||!re?.invocations)return null;const ee=re.invocations.filter(ue=>ue.sessionId===S);return ee.length===0?null:ee.sort((ue,Ie)=>{const bt=Date.parse(ue.updatedAt??ue.createdAt??""),yt=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(yt)?0:yt)-(Number.isNaN(bt)?0:bt)})[0]??null},[S,re?.invocations]),me=C.useMemo(()=>!ie?.memberId||!re?.members?null:re.members.find(ee=>ee.id===ie.memberId)??null,[ie?.memberId,re?.members]),he=S?te:Q??null,we=he?.status===Ze.RUNNING||he?.status===Ze.PENDING,$=!!e?.projectArchivedAt,ne=!!e?.projectRepoDeletedAt,fe=m(ne?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:je}=Cs(),[$e,Fe]=C.useState(null);C.useEffect(()=>{Fe(Q?.providerId??null)},[Q?.providerId]);const st=C.useMemo(()=>!Q||!Y?!1:!Y.some(ue=>ue.status==="ACTIVE"&&ue.sessions?.some(Ie=>Ie.id===Q.id)),[Q,Y]),Le=C.useMemo(()=>{if(!(!Y||M)){if(ke)return Jt(ke);for(const ee of Y)if(ee.status==="ACTIVE"&&Jt(ee))return Jt(ee);return Jt(Y[0])}},[M,ke,Y]),_e=Pl({agentType:Q?.agentType,workingDir:Le,input:p,setInput:x,textareaRef:F,minHeight:60,maxHeight:300}),Xe=Ol({agentType:Q?.agentType,workingDir:Le,input:p,setInput:x,textareaRef:F,minHeight:60,maxHeight:300}),{data:xe}=cn(ve?Ee??"":""),Ge=ke?.sessions??[],Je=cs(ke),gt=ke?.commitMessage,rt=C.useMemo(()=>Wa(ke,Y,e?.mainBranch??""),[ke,e?.mainBranch,Y]),Ne=C.useMemo(()=>xe?.conflictOp&&xe.conflictedFiles.length>0?{conflictOp:xe.conflictOp,conflictedFiles:xe.conflictedFiles}:u,[xe?.conflictOp,xe?.conflictedFiles,u]),ut=Ne?.targetWorkspaceId??Ee,vt=Ne?.targetWorktreePath??ke?.worktreePath,Ye=Ne?.sourceBranch??Je,Ct=Ne?.targetBranch??rt,Me=tt(),xt=C.useCallback(()=>e?.id?Me.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Me]);C.useEffect(()=>{if(!k)return;const ee=ue=>{L.current&&!L.current.contains(ue.target)&&E(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[k]);const At=yn(),Mt=ln(),lt=Nc(),_t=Pa(e?.id??""),Ut=bn(),us=Mh(),qt=C.useMemo(()=>!Y||Y.some(ue=>ue.status==="ACTIVE")?null:Y.find(ue=>ue.status==="HIBERNATED")??null,[Y]),ns=C.useRef(null);C.useEffect(()=>{qt&&ns.current!==qt.id&&(us.isPending||(ns.current=qt.id,us.mutate(qt.id,{onSettled:()=>{ns.current=null}})))},[qt,us]);const er=C.useCallback(async()=>{if(!e?.id)return;const ee=Q?.providerId??je?.find(Ie=>Ie.availability.type!=="NOT_FOUND")?.provider.id;if(!ee)return;const ue=[e.title,e.description].filter(Boolean).join(`
77
-
78
- `);w(!1),a(!0);try{await lt.mutateAsync(e.id),D(!0);const Ie=await _t.mutateAsync({}),bt=await Se.post(`/workspaces/${Ie.id}/sessions`,{providerId:ee,prompt:ue});await Ut.mutateAsync(bt.id),await Me.invalidateQueries({queryKey:de.workspaces.list(e.id)})}catch(Ie){console.error("[retry] failed:",Ie),D(!1)}finally{a(!1)}},[e?.id,e?.title,e?.description,Q?.providerId,je,lt,_t,Ut,Me]),Xr=C.useCallback(()=>{ke?.id&&Mt.mutate({workspaceId:ke.id})},[Mt,ke?.id]),Yr=C.useCallback(()=>{!e?.id||!s||(s(e.id),g(!1))},[e?.id,s]),js=C.useCallback(ee=>{j(ee),requestAnimationFrame(()=>{B()})},[B]),Vr=C.useCallback(()=>{j(null)},[]),Ns=C.useCallback(ee=>{b(ee??null),d(!0)},[]),Gr=C.useCallback(ee=>De.mutateAsync(ee),[De]),Kt=C.useCallback(()=>{Me.invalidateQueries({queryKey:Rc.all})},[Me]),{isConnected:tr,isLoadingSnapshot:Xt,logs:se,entries:be,attach:ze}=na({sessionId:Ae,sessionStatus:he?.status,onExit:C.useCallback(()=>{Me.invalidateQueries({queryKey:["workspaces"]})},[Me])});C.useEffect(()=>{if(!e?.id)return;const ee=Gt.connect();ee.emit(ps.SUBSCRIBE,{topic:"task",id:e.id});const ue=yt=>{yt.taskId===e.id&&(Me.invalidateQueries({queryKey:["tasks"]}),Kt())},Ie=yt=>{yt.taskId===e.id&&(Me.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Kt())},bt=yt=>{yt.taskId===e.id&&(Me.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Kt())};return ee.on(nt.TASK_UPDATED,ue),ee.on(nt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),ee.on(nt.WORKSPACE_HIBERNATED,bt),()=>{ee.off(nt.TASK_UPDATED,ue),ee.off(nt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),ee.off(nt.WORKSPACE_HIBERNATED,bt),ee.emit(ps.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Me,Kt]),C.useEffect(()=>{if(!Ae)return;const ee=Gt.connect(),ue=Ie=>{Ie.sessionId===Ae&&(Me.invalidateQueries({queryKey:["workspaces"]}),Kt())};return ee.on(nt.SESSION_COMPLETED,ue),()=>{ee.off(nt.SESSION_COMPLETED,ue)}},[Ae,Me,Kt]);const{todos:Oe}=oa(be),{files:kt,addFiles:ht,removeFile:He,clear:Ht,buildMarkdownLinks:Wt,hasFiles:Lt,isUploading:sr}=Fr(),Jl=C.useMemo(()=>El(he),[he?.tokenUsage]),wn=Cl(se,Jl);C.useEffect(()=>{Ae&&tr&&ze()},[Ae,tr,ze]);const Cn=C.useRef(e?.id);C.useEffect(()=>{if(Cn.current!==e?.id&&A.current){const ee=A.current;requestAnimationFrame(()=>{ee.scrollTop=ee.scrollHeight})}Cn.current=e?.id},[e?.id,A]);const Qr=wl(),Zr=C.useRef(!1),kn=C.useCallback(async()=>{if(!p.trim()&&!Lt||!Ae||Zr.current||sr)return;Zr.current=!0;const ee=Wt(),ue=[p.trim(),ee].filter(Boolean).join(`
79
-
80
- `);x(""),Ht(),F.current&&(F.current.style.height="60px"),At.mutate({id:Ae,message:ue,providerId:$e??void 0},{onSuccess:()=>{ze()},onSettled:()=>{Zr.current=!1}})},[p,Ae,At,ze,Lt,sr,Wt,Ht,$e]),ec=C.useCallback(async()=>{Ae&&(await Qr.mutateAsync(Ae),Me.invalidateQueries({queryKey:["workspaces"]}))},[Ae,Qr,Me]),tc=C.useCallback(ee=>{const ue=ee.target.files;ue&&ue.length>0&&ht(Array.from(ue)),ee.target.value=""},[ht]),sc=C.useCallback(ee=>{const ue=ee.clipboardData.items,Ie=[];for(const bt of ue)if(bt.kind==="file"){const yt=bt.getAsFile();yt&&Ie.push(yt)}Ie.length>0&&(ee.preventDefault(),ht(Ie))},[ht]),[En,Jr]=C.useState(!1),rc=C.useCallback(ee=>{ee.preventDefault(),Jr(!0)},[]),ic=C.useCallback(ee=>{ee.preventDefault(),Jr(!1)},[]),nc=C.useCallback(ee=>{ee.preventDefault(),Jr(!1);const ue=ee.dataTransfer.files;ue.length>0&&ht(Array.from(ue))},[ht]),ei=C.useCallback(ee=>{const ue=ee.clientX-H.current,Ie=Math.max(Io,Math.min(K.current+ue,Bo));W.current&&(W.current.style.width=`${Ie}px`)},[]),ti=C.useCallback(()=>{if(R(!1),W.current){const ee=W.current.getBoundingClientRect().width;X(Math.max(Io,Math.min(Math.round(ee),Bo)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(q)return document.addEventListener("mousemove",ei),document.addEventListener("mouseup",ti),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ei),document.removeEventListener("mouseup",ti),document.body.style.cursor="",document.body.style.userSelect=""}},[q,ei,ti]);const oc=C.useCallback(ee=>{ee.preventDefault(),H.current=ee.clientX,K.current=U,R(!0)},[U]),ac=C.useCallback(()=>{Z(ee=>!ee)},[]),lc=C.useCallback(ee=>{x(ee.target.value);const ue=ee.target;ue.style.height="auto";const Ie=ue.scrollHeight;ue.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]);return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 flex items-center justify-between border-b border-neutral-100 bg-white/80 backdrop-blur-sm 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-2 mb-0.5",children:[t.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),t.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-neutral-500 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-bold text-neutral-900 break-words line-clamp-2",title:e.title,children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-4 flex-shrink-0",children:[t.jsx(ev,{status:e.status,onChangeStatus:!$&&o?ee=>o(e.id,ee):void 0}),t.jsx("button",{onClick:Xr,disabled:!Le||$,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:t.jsx(Ks,{size:18})}),t.jsx("button",{onClick:ac,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Toggle Workspace"),children:V?t.jsx(Md,{size:18}):t.jsx(fr,{size:18})}),Be&&!$&&t.jsxs("button",{onClick:()=>f(!0),className:"flex h-8 items-center justify-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50",title:m("创建 TeamRun"),children:[t.jsx(Bt,{size:14}),t.jsx("span",{children:m("创建 TeamRun")})]}),s&&!$&&t.jsxs("div",{className:"relative",ref:L,children:[t.jsx("button",{onClick:()=>E(ee=>!ee),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("More actions"),children:t.jsx(da,{size:18})}),k&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[t.jsxs("button",{onClick:()=>{w(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[t.jsx(zc,{size:15}),t.jsx("span",{children:m("重新开始")})]}),t.jsxs("button",{onClick:()=>{g(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[t.jsx(Ki,{size:15}),t.jsx("span",{children:m("删除任务")})]})]})]})]})]}),ve&&Ee&&xe&&t.jsx(Rg,{workspaceId:Ee,gitStatus:xe,onResolve:()=>Ns()}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{ref:W,className:`flex flex-col bg-white relative ${V?"flex-shrink-0":"flex-1"}`,style:{width:V?U:"100%"},children:We&&re?S?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-neutral-200 px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:S})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(jl,{session:he,providers:je,usage:wn,providerIdFallback:me?.providerId,agentTypeFallback:he?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Pe,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-2 text-xs font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900",onClick:Vr,children:[t.jsx(Ei,{size:13}),t.jsx("span",{children:m("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:A,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:P,className:`w-full ${V?"":"max-w-5xl mx-auto"}`,children:Xt?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:m("Loading logs...")})]}):se.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(we?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(ur,{logs:se})})}),!O&&t.jsxs("button",{onClick:()=>B(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[t.jsx(Fs,{size:14}),t.jsx("span",{children:m("回到底部")})]})]}),Oe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:t.jsx(hr,{todos:Oe})})})]}):t.jsx(Fa,{teamRun:re,messages:Te??re.messages??[],readOnly:$,readOnlyMessage:fe,onSendMessage:Gr,onViewInvocationSession:js,centered:!V}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:A,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:P,className:`w-full min-w-0 ${V?"":"max-w-5xl mx-auto"}`,children:[t.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100 min-w-0",children:e.description?t.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(Ui,{urlTransform:Qg,components:qi,children:e.description})}):t.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),ae&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[ae.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:m("Setup ({current}/{total}): {command}",{current:ae.currentIndex,total:ae.totalCommands,command:ae.currentCommand})})]}),ae.status==="completed"&&t.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),ae.status==="failed"&&t.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:ae.error})})]}),G?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:m("Loading...")})]}):ye?Xt?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:m("Loading logs...")})]}):se.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(we?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(ur,{logs:se}):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-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:t.jsx(as,{size:24,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m($?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:$?fe:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!$&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Pe,{onClick:()=>i(!0),children:[t.jsx(as,{size:16,className:"mr-1.5"}),m("启动 Agent")]}),Be&&t.jsxs(Pe,{variant:"outline",onClick:()=>f(!0),children:[t.jsx(Bt,{size:16,className:"mr-1.5"}),m("创建 TeamRun")]})]})]})]})}),!O&&t.jsxs("button",{onClick:()=>B(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[t.jsx(Fs,{size:14}),t.jsx("span",{children:m("回到底部")})]})]}),Oe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:t.jsx(hr,{todos:Oe})})}),$?t.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:t.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:t.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:fe})})}):st?t.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:t.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:t.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[t.jsx("span",{className:"text-sm text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),t.jsxs(Pe,{size:"sm",onClick:()=>i(!0),children:[t.jsx(as,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:rc,onDragLeave:ic,onDrop:nc,children:[t.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:t.jsxs("div",{ref:I,className:`relative bg-white rounded-xl border shadow-sm hover:shadow-md focus-within:shadow-md focus-within:border-neutral-300 transition-all duration-200 ${En?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[t.jsx(zr,{files:kt,onRemove:He}),t.jsx("textarea",{ref:F,value:p,onChange:lc,onPaste:sc,onKeyDown:ee=>{Xe.handleKeyDown(ee)||_e.handleKeyDown(ee)||ee.key==="Enter"&&!ee.shiftKey&&!ee.repeat&&!ee.nativeEvent.isComposing&&ee.nativeEvent.keyCode!==229&&(ee.preventDefault(),kn())},rows:1,placeholder:m(En?"Drop files here...":ye&&!we?"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-neutral-900 placeholder-neutral-400 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:z,type:"file",multiple:!0,className:"hidden",onChange:tc}),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:()=>z.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:m("Upload file"),children:t.jsx(jr,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Q&&je&&t.jsx(Rl,{providers:je,currentProviderId:$e,agentType:Q.agentType,onSelect:Fe}),t.jsx(hn,{usage:wn}),we&&!p.trim()&&!Lt?t.jsx("button",{onClick:ec,disabled:Qr.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-red-500 text-white hover:bg-red-600 shadow-md disabled:opacity-50",children:t.jsx(bs,{size:14})}):t.jsx("button",{onClick:kn,disabled:!p.trim()&&!Lt||sr,className:`p-2 rounded-lg transition-all duration-200 ${(p.trim()||Lt)&&!sr?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:t.jsx(Ar,{size:18})})]})]})]})}),t.jsx(Cr,{open:_e.query!==null,anchorRef:I,commands:_e.filteredCommands,selectedIndex:_e.selectedIndex,query:_e.query??"",hasCatalog:_e.allCommands.length>0,onSelect:_e.applyCommand}),t.jsx(Cr,{open:Xe.query!==null,anchorRef:I,commands:Xe.filteredSkills,selectedIndex:Xe.selectedIndex,query:Xe.query??"",hasCatalog:Xe.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Xe.applySkill})]})]})}),V&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-neutral-200 active:bg-blue-400 transition-colors z-30 flex-shrink-0 border-l border-neutral-200",onMouseDown:oc}),V&&t.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:t.jsx(Sl,{sessionId:ye||void 0,workspaceId:Re,workingDir:Le,projectId:e.projectId,readOnly:$,repoDeleted:ne,teamRun:re,teamStatus:re?t.jsx(qa,{teamRun:re,workspaces:Y,selectedWorkspaceId:Re,onSelectWorkspace:T,onViewInvocationSession:js}):void 0,workspaces:Y,selectedWorkspaceId:Re,onSelectWorkspace:T,tabRef:y,gitProps:ve&&Ee?{branchName:Je,targetBranch:rt,commitMessage:gt,canRunGitOperations:!0,onRefreshCommitMessage:xt,onConflict:Ns,onResolveConflicts:()=>Ns()}:void 0})})]}),!$&&t.jsx(kl,{isOpen:n,onClose:()=>i(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),Be&&!$&&t.jsx(jg,{isOpen:c,onClose:()=>f(!1),taskId:e.id}),ve&&ut&&Ne&&t.jsx(Tl,{open:h,onOpenChange:ee=>{d(ee),ee||b(null)},workspaceId:ut,conflictOp:Ne.conflictOp,conflictedFiles:Ne.conflictedFiles,sourceBranch:Ye,targetBranch:Ct,operation:xe?.operation,worktreePath:vt,mergeAborted:Ne.mergeAborted,mergeStrategy:Ne.mergeStrategy,sourceWorkspaceId:Ne.sourceWorkspaceId,targetWorkspaceId:Ne.targetWorkspaceId,sourceWorktreePath:Ne.sourceWorktreePath,targetWorktreePath:Ne.targetWorktreePath,sessions:Ge,currentSessionId:We?void 0:ye,teamRunId:re?.id}),t.jsx(Nr,{isOpen:_,onClose:()=>w(!1),onConfirm:er,title:m("重新开始任务"),description:t.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:v}),t.jsx(dn,{isOpen:l,onClose:()=>g(!1),onConfirm:Yr,taskId:e.id,taskTitle:e.title,workspaces:Y,isLoading:r})]}):t.jsx(Jg,{})}function Sn(e){switch(e){case Ot.TODO:return pe.Pending;case Ot.IN_PROGRESS:return pe.Running;case Ot.IN_REVIEW:return pe.Review;case Ot.DONE:return pe.Done;case Ot.CANCELLED:return pe.Cancelled}}function sv(e){switch(e){case pe.Pending:return Ot.TODO;case pe.Running:return Ot.IN_PROGRESS;case pe.Review:return Ot.IN_REVIEW;case pe.Done:return Ot.DONE;case pe.Cancelled:return Ot.CANCELLED}}function rv(e){switch(e){case It.CLAUDE_CODE:return"Claude Code";case It.GEMINI_CLI:return"Gemini CLI";case It.CURSOR_AGENT:return"Cursor Agent";case It.CODEX:return"Codex"}}const kr=["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 Il(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 Bl(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function Fl(e){return e?e.workspaceKind===it.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function iv(e){return{id:e.id,name:e.name,color:e.color||kr[Il(e.name,kr.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function nv(e){const s=Bl(e);if(!s)return{agent:"—",branch:"—"};const r=Fl(s),o=s.sessions;if(o&&o.length>0){const m=o[o.length-1];return{agent:rv(m.agentType),branch:r}}return{agent:"—",branch:r}}function ov(e){const{agent:s,branch:r}=nv(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:Sn(e.status),agent:s,branch:r,description:e.description??"",projectArchivedAt:o?.archivedAt??null,projectRepoDeletedAt:o?.repoDeletedAt??null}}function av(e,s,r){const o=Bl(e.workspaces,r),m=Fl(o);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||kr[Il(s.name,kr.length)],title:e.title,status:Sn(e.status),branch:m,mainBranch:o?.baseBranch??s.mainBranch??"main",description:e.description??"",projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const zo={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 lv(e){const s=e.split("/");return s[s.length-1]||e}function cv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function dv({workingDir:e,filePath:s,type:r}){const{t:o}=ce(),{data:m,isLoading:p,isError:x}=vl(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=m?.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(`
81
- `);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((c,f)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:J("px-3 whitespace-pre",l,g),children:c},f)})})}function uv({entry:e,type:s,workingDir:r}){const[o,m]=C.useState(!1),p=zo[e.status]||zo.M,x=cv(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(n=>!n),className:J("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:J("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),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:lv(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(dt,{size:14}):t.jsx(zt,{size:14})})]}),o&&t.jsx(dv,{workingDir:r,filePath:e.path,type:s})]})}function Ho({title:e,entries:s,type:r,workingDir:o,defaultOpen:m}){const{t:p}=ce(),[x,n]=C.useState(m);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:x?t.jsx(dt,{size:14}):t.jsx(zt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),x&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(uv,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function hv({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:m}=_n(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(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(m)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const p=r?.uncommitted||[],x=r?.committed||[];return p.length+x.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(ys,{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(Ho,{title:"Uncommitted",entries:p,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(Ho,{title:"Committed",entries:x,type:"committed",workingDir:e,defaultOpen:!1})]})}const bi=50,Wo={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 fv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Zt("{count}s ago",{count:r}):r<3600?Zt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Zt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Zt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function mv(e){const s=e.split("/");return s[s.length-1]||e}function pv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function gv({workingDir:e,hash:s,filePath:r}){const{t:o}=ce(),{data:m,isLoading:p,isError:x}=_l(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=m?.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((c,f)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:J("px-3 whitespace-pre",l,g),children:c},f)})})}function vv({entry:e,workingDir:s,hash:r}){const[o,m]=C.useState(!1),p=Wo[e.status]||Wo.M,x=pv(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(n=>!n),className:J("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:J("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),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:mv(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(dt,{size:14}):t.jsx(zt,{size:14})})]}),o&&t.jsx(gv,{workingDir:s,hash:r,filePath:e.path})]})}function xv({commit:e,workingDir:s}){const{t:r}=ce(),[o,m]=C.useState(!1),{data:p,isLoading:x}=xl(s,o?e.hash:null),n=p?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(i=>!i),className:J("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:J("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:fv(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(dt,{size:14}):t.jsx(zt,{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}),x?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Ke,{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(vv,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function _v({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:x,isFetchingNextPage:n}=la({queryKey:de.git.log(e||""),queryFn:({pageParam:c=0})=>Se.get("/git/log",{params:{workingDir:e||"",limit:String(bi),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<bi?void 0:f.length*bi,enabled:!!e}),i=r?.pages.flatMap(c=>c.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):m?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(Ss,{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(c=>t.jsx(xv,{commit:c,workingDir:e},c.hash))}),x&&t.jsx("button",{type:"button",onClick:()=>p(),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(Ke,{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 bv="/api",yv=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${bv}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Sv({status:e}){const s={[pe.Running]:"bg-blue-500",[pe.Review]:"bg-amber-500",[pe.Pending]:"bg-neutral-400",[pe.Done]:"bg-emerald-500",[pe.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const wv=[{key:"chat",label:"Chat",icon:Xi},{key:"changes",label:"Changes",icon:ys},{key:"history",label:"History",icon:Ss},{key:"workspace",label:"Workspace",icon:Mr}],Cv=[{key:"chat",label:"Team room",icon:Xi},{key:"team-status",label:"Team Status",icon:ss},{key:"changes",label:"Changes",icon:ys},{key:"workspace",label:"Workspace",icon:Mr}];function kv({task:e,onBack:s,onDeleteTask:r,isDeleting:o}){const{t:m}=ce(),[p,x]=C.useState("chat"),[n,i]=C.useState(""),[c,f]=C.useState(!1),[l,g]=C.useState(!1),[_,w]=C.useState(!1),[v,a]=C.useState(null),[h,d]=C.useState(void 0),u=C.useRef(null),b=C.useRef(null),y=C.useRef(null),k=C.useRef(null),{scrollRef:E,contentRef:S,isAtBottom:j,scrollToBottom:N}=un({resize:"smooth",initial:"instant"}),T=tt();C.useEffect(()=>{if(!_)return;const se=be=>{b.current&&!b.current.contains(be.target)&&w(!1)};return document.addEventListener("mousedown",se),()=>document.removeEventListener("mousedown",se)},[_]);const{data:M,isLoading:D}=an(e.id),{data:I}=sa(e.id),{data:L}=ra(I?.id??""),F=Bi(I?.id??""),z=I??null,A=z?Cv:wv;C.useEffect(()=>{d(void 0),a(null)},[e.id]),C.useEffect(()=>{z&&p==="history"&&x("chat"),!z&&p==="team-status"&&x("chat")},[p,z]);const P=C.useMemo(()=>za(M,z,h),[h,z,M]);C.useEffect(()=>{h&&!M?.some(se=>se.id===h)&&d(void 0)},[h,M]);const O=C.useMemo(()=>M?.find(se=>se.id===P),[P,M]),B=C.useMemo(()=>{if(M){if(O)return Jt(O);for(const se of M)if(se.status==="ACTIVE"&&Jt(se))return Jt(se);return Jt(M[0])}},[O,M]),U=O?.status===jt.ACTIVE?O.id:void 0,X=Ha(O,z),V=O?.branchName??"",Z=O?.commitMessage,q=C.useMemo(()=>Wa(O,M,e?.mainBranch??""),[O,e?.mainBranch,M]),{data:R}=cn(U??""),{data:H}=_n(B),K=H?.committed?.length,[W,Y]=C.useState(!1),[G,ae]=C.useState(null),le=C.useMemo(()=>R?.conflictOp&&R.conflictedFiles.length>0?{conflictOp:R.conflictOp,conflictedFiles:R.conflictedFiles}:G,[R?.conflictOp,R?.conflictedFiles,G]),Te=le?.targetWorkspaceId??U,De=le?.targetWorktreePath??O?.worktreePath,re=le?.sourceBranch??V,We=le?.targetBranch??q,Be=O?.sessions??[],Re=C.useCallback(se=>{ae(se??null),Y(!0)},[]),ke=C.useCallback(()=>e?.id?T.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,T]),Ee=C.useMemo(()=>{if(!M)return null;const se=M.filter(He=>He.status==="ACTIVE"&&Array.isArray(He.sessions)).flatMap(He=>He.sessions??[]),be=He=>{const Ht=He.createdAt,Wt=He.endedAt??He.startedAt??Ht;if(!Wt)return 0;const Lt=Date.parse(Wt);return Number.isNaN(Lt)?0:Lt},ze=He=>{const Ht=se.filter(Wt=>He.includes(Wt.status));return Ht.length===0?null:Ht.sort((Wt,Lt)=>be(Lt)-be(Wt))[0]??null},Oe=ze([Ze.RUNNING])??ze([Ze.PENDING])??ze([Ze.COMPLETED,Ze.FAILED,Ze.CANCELLED]);if(Oe)return Oe;const ht=M.filter(He=>(He.status==="ABANDONED"||He.status==="MERGED"||He.status==="HIBERNATED")&&Array.isArray(He.sessions)).flatMap(He=>He.sessions??[]).filter(He=>[Ze.COMPLETED,Ze.FAILED,Ze.CANCELLED].includes(He.status));return ht.length===0?null:ht.sort((He,Ht)=>be(Ht)-be(He))[0]??null},[M]),ve=Ee?.id??"",Q=z?v??"":ve,ye=C.useMemo(()=>{if(!v||!M)return null;for(const se of M){const be=se.sessions?.find(ze=>ze.id===v);if(be)return be}return null},[v,M]),Ae=C.useMemo(()=>{if(!v||!z?.invocations)return null;const se=z.invocations.filter(be=>be.sessionId===v);return se.length===0?null:se.sort((be,ze)=>{const Oe=Date.parse(be.updatedAt??be.createdAt??""),kt=Date.parse(ze.updatedAt??ze.createdAt??"");return(Number.isNaN(kt)?0:kt)-(Number.isNaN(Oe)?0:Oe)})[0]??null},[v,z?.invocations]),te=C.useMemo(()=>!Ae?.memberId||!z?.members?null:z.members.find(se=>se.id===Ae.memberId)??null,[Ae?.memberId,z?.members]),ie=v?ye:Ee??null,me=ie?.status===Ze.RUNNING||ie?.status===Ze.PENDING,he=!!e.projectArchivedAt,we=!!e.projectRepoDeletedAt,$=m(we?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),ne=C.useMemo(()=>!Ee||!M?!1:!M.some(be=>be.status==="ACTIVE"&&be.sessions?.some(ze=>ze.id===Ee.id)),[Ee,M]),{data:fe}=Cs(),[je,$e]=C.useState(null),Fe=je?.sessionId===ve?je.providerId:Ee?.providerId??null,st=C.useCallback(se=>{$e({sessionId:ve,providerId:se})},[ve]),Le=Pl({agentType:Ee?.agentType,workingDir:B,input:n,setInput:i,textareaRef:y,minHeight:40,maxHeight:140}),_e=Ol({agentType:Ee?.agentType,workingDir:B,input:n,setInput:i,textareaRef:y,minHeight:40,maxHeight:140}),Xe=B&&O?O.id:void 0,xe=yn(),Ge=ln(),Je=wl(),{isConnected:gt,isLoadingSnapshot:rt,logs:Ne,entries:ut,attach:vt}=na({sessionId:Q,sessionStatus:ie?.status,onExit:C.useCallback(()=>{T.invalidateQueries({queryKey:["workspaces"]})},[T])}),{todos:Ye}=oa(ut),{files:Ct,addFiles:Me,removeFile:xt,clear:At,buildMarkdownLinks:Mt,hasFiles:lt,isUploading:_t}=Fr(),Ut=C.useMemo(()=>El(ie),[ie?.tokenUsage]),us=Cl(Ne,Ut);C.useEffect(()=>{Q&&gt&&vt()},[Q,gt,vt]);const qt=C.useRef(null);C.useEffect(()=>{if(qt.current!==e.id&&E.current){const se=E.current;requestAnimationFrame(()=>{se.scrollTop=se.scrollHeight})}qt.current=e.id},[e.id,E]);const ns=C.useRef(!1),er=C.useCallback(async()=>{if(!n.trim()&&!lt||!ve||ns.current||_t)return;ns.current=!0;const se=Mt(),be=[n.trim(),se].filter(Boolean).join(`
83
-
84
- `);i(""),At(),y.current&&(y.current.style.height="40px"),xe.mutate({id:ve,message:be,providerId:Fe??void 0},{onSuccess:()=>vt(),onSettled:()=>{ns.current=!1}})},[n,ve,xe,vt,lt,_t,Mt,At,Fe]),Xr=C.useCallback(async()=>{ve&&(await Je.mutateAsync(ve),T.invalidateQueries({queryKey:["workspaces"]}))},[ve,Je,T]),Yr=C.useCallback(se=>F.mutateAsync(se),[F]),js=C.useCallback(se=>{a(se),x("chat"),requestAnimationFrame(()=>{N()})},[N]),Vr=C.useCallback(()=>{a(null)},[]),Ns=C.useCallback(se=>{const be=se.target.files;be&&be.length>0&&Me(Array.from(be)),se.target.value=""},[Me]),Gr=C.useCallback(se=>{const be=se.clipboardData.items,ze=[];for(const Oe of be)if(Oe.kind==="file"){const kt=Oe.getAsFile();kt&&ze.push(kt)}ze.length>0&&(se.preventDefault(),Me(ze))},[Me]),Kt=C.useCallback(se=>{i(se.target.value);const be=se.target;be.style.height="auto",be.style.height=`${Math.max(40,Math.min(be.scrollHeight,140))}px`},[]),tr=C.useCallback(()=>{Xe&&Ge.mutate({workspaceId:Xe})},[Ge,Xe]),Xt=C.useRef(null);return C.useEffect(()=>{const se=window.visualViewport;if(!se)return;let be=!1;const ze=()=>{Xt.current&&(Xt.current.style.height=`${se.height}px`,Xt.current.style.top=`${se.offsetTop}px`)},Oe=()=>ze(),kt=()=>{be||ze()},ht=()=>{be=!0},He=()=>{be=!1,requestAnimationFrame(ze)};return se.addEventListener("resize",Oe),se.addEventListener("scroll",kt),document.addEventListener("touchstart",ht,{passive:!0}),document.addEventListener("touchend",He,{passive:!0}),document.addEventListener("touchcancel",He,{passive:!0}),()=>{se.removeEventListener("resize",Oe),se.removeEventListener("scroll",kt),document.removeEventListener("touchstart",ht),document.removeEventListener("touchend",He),document.removeEventListener("touchcancel",He)}},[]),C.useEffect(()=>{const se=Xt.current;if(!se)return;const be=ze=>{let Oe=ze.target;for(;Oe&&Oe!==se;){if(Oe.tagName==="TEXTAREA"){if(Oe.scrollHeight>Oe.clientHeight)return;Oe=Oe.parentElement;continue}const ht=window.getComputedStyle(Oe).overflowY;if((ht==="auto"||ht==="scroll")&&Oe.scrollHeight>Oe.clientHeight)return;Oe=Oe.parentElement}ze.preventDefault()};return se.addEventListener("touchmove",be,{passive:!1}),()=>se.removeEventListener("touchmove",be)},[]),t.jsxs("div",{ref:Xt,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(Ei,{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?m("源码已删除"):m("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(Sv,{status:e.status}),t.jsx("button",{onClick:tr,disabled:!Xe||he,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(Ks,{size:16})}),r&&!he&&t.jsxs("div",{className:"relative",ref:b,children:[t.jsx("button",{onClick:()=>w(se=>!se),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(da,{size:16})}),_&&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:()=>{g(!0),w(!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(Ki,{size:15}),t.jsx("span",{children:m("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:A.map(({key:se,label:be,icon:ze})=>t.jsxs("button",{onClick:()=>x(se),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${p===se?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(ze,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:m(be)})]},se))})]}),p==="chat"&&(z?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:v?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:m("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:v})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(jl,{session:ie,providers:fe,usage:us,compact:!0,providerIdFallback:te?.providerId,agentTypeFallback:ie?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Pe,{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:Vr,children:[t.jsx(Ei,{size:12}),t.jsx("span",{children:m("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:E,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:S,children:rt?t.jsx(yi,{label:m("Loading logs...")}):Ne.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:m(me?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(ur,{logs:Ne})})}),!j&&t.jsxs("button",{onClick:()=>N(),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":m("Scroll to bottom"),children:[t.jsx(Fs,{size:12}),t.jsx("span",{children:m("回到底部")})]})]}),Ye.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(hr,{todos:Ye,compact:!0})})]}):t.jsx(Fa,{teamRun:z,messages:L??z.messages??[],readOnly:he,readOnlyMessage:$,onSendMessage:Yr,onViewInvocationSession:js,compactComposer:!0})}):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:E,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:S,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(Ui,{urlTransform:yv,components:qi,children:e.description})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),D?t.jsx(yi,{label:"Loading..."}):ve?rt?t.jsx(yi,{label:"Loading logs..."}):Ne.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:me?"Waiting for agent output...":"No logs recorded."}):t.jsx(ur,{logs:Ne}):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(as,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:he?$:m("选择一个 Agent 来执行此任务")}),!he&&t.jsxs(Pe,{onClick:()=>f(!0),children:[t.jsx(as,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!j&&t.jsxs("button",{onClick:()=>N(),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(Fs,{size:12}),t.jsx("span",{children:m("回到底部")})]})]}),Ye.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(hr,{todos:Ye,compact:!0})}),he?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:$})}):ne?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:m("代码已合并,以上为历史沟通记录")}),t.jsxs(Pe,{size:"sm",onClick:()=>f(!0),children:[t.jsx(as,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):ve&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[t.jsxs("div",{ref:u,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(zr,{files:Ct,onRemove:xt}),t.jsx("textarea",{ref:y,value:n,onChange:Kt,onPaste:Gr,onKeyDown:se=>{_e.handleKeyDown(se)||Le.handleKeyDown(se)||se.key==="Enter"&&!se.shiftKey&&!se.repeat&&!se.nativeEvent.isComposing&&se.nativeEvent.keyCode!==229&&(se.preventDefault(),er())},rows:1,placeholder:me?"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:k,type:"file",multiple:!0,className:"hidden",onChange:Ns}),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:()=>k.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(jr,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[Ee&&fe&&t.jsx(Rl,{providers:fe,currentProviderId:Fe,agentType:Ee.agentType,onSelect:st}),t.jsx(hn,{usage:us}),me&&!n.trim()&&!lt?t.jsx("button",{onClick:Xr,disabled:Je.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(bs,{size:12})}):t.jsx("button",{onClick:er,disabled:!n.trim()&&!lt||_t,className:`p-1.5 rounded-lg transition-colors ${(n.trim()||lt)&&!_t?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Ar,{size:15})})]})]})]}),t.jsx(Cr,{open:Le.query!==null,anchorRef:u,commands:Le.filteredCommands,selectedIndex:Le.selectedIndex,query:Le.query??"",hasCatalog:Le.allCommands.length>0,compact:!0,onSelect:Le.applyCommand}),t.jsx(Cr,{open:_e.query!==null,anchorRef:u,commands:_e.filteredSkills,selectedIndex:_e.selectedIndex,query:_e.query??"",hasCatalog:_e.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:_e.applySkill})]})]})),p==="team-status"&&z&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(qa,{teamRun:z,workspaces:M,selectedWorkspaceId:P,onSelectWorkspace:d,onViewInvocationSession:js})}),p==="changes"&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[M&&M.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(yl,{workspaces:M,teamRun:z,selectedWorkspaceId:P,onSelectWorkspace:d,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),X&&U&&t.jsx("div",{className:"shrink-0",children:t.jsx(bl,{workspaceId:U,branchName:V,targetBranch:q,commitMessage:Z,committedFileCount:K,onRefreshCommitMessage:ke,onConflict:Re,onResolveConflicts:()=>Re()})}),t.jsx(hv,{workingDir:B})]}),p==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(_v,{workingDir:B})}),p==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Sl,{sessionId:ve||void 0,workspaceId:P,workingDir:B,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:he,repoDeleted:we})}),!he&&t.jsx(kl,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),t.jsx(dn,{isOpen:l,onClose:()=>g(!1),onConfirm:()=>{r?.(e.id),g(!1)},taskId:e.id,taskTitle:e.title,workspaces:M,isLoading:o}),W&&le&&Te&&t.jsx(Tl,{open:W,onOpenChange:se=>{Y(se),se||ae(null)},workspaceId:Te,conflictOp:le.conflictOp,conflictedFiles:le.conflictedFiles,sourceBranch:re,targetBranch:We,operation:R?.operation,worktreePath:De,mergeAborted:le.mergeAborted,mergeStrategy:le.mergeStrategy,sourceWorkspaceId:le.sourceWorkspaceId,targetWorkspaceId:le.targetWorkspaceId,sourceWorktreePath:le.sourceWorktreePath,targetWorktreePath:le.targetWorktreePath,sessions:Be,currentSessionId:z?void 0:ve,teamRunId:z?.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 Ev=Object.defineProperty,Er=Object.getOwnPropertySymbols,zl=Object.prototype.hasOwnProperty,Hl=Object.prototype.propertyIsEnumerable,$o=(e,s,r)=>s in e?Ev(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Pi=(e,s)=>{for(var r in s||(s={}))zl.call(s,r)&&$o(e,r,s[r]);if(Er)for(var r of Er(s))Hl.call(s,r)&&$o(e,r,s[r]);return e},Oi=(e,s)=>{var r={};for(var o in e)zl.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Er)for(var o of Er(e))s.indexOf(o)<0&&Hl.call(e,o)&&(r[o]=e[o]);return r};var ds;(e=>{const s=class Ce{constructor(i,c,f,l){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<Ce.MIN_VERSION||i>Ce.MAX_VERSION)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let g=[];for(let w=0;w<this.size;w++)g.push(!1);for(let w=0;w<this.size;w++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(f);if(this.drawCodewords(_),l==-1){let w=1e9;for(let v=0;v<8;v++){this.applyMask(v),this.drawFormatBits(v);const a=this.getPenaltyScore();a<w&&(l=v,w=a),this.applyMask(v)}}m(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(i,c){const f=e.QrSegment.makeSegments(i);return Ce.encodeSegments(f,c)}static encodeBinary(i,c){const f=e.QrSegment.makeBytes(i);return Ce.encodeSegments([f],c)}static encodeSegments(i,c,f=1,l=40,g=-1,_=!0){if(!(Ce.MIN_VERSION<=f&&f<=l&&l<=Ce.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let w,v;for(w=f;;w++){const u=Ce.getNumDataCodewords(w,c)*8,b=x.getTotalBits(i,w);if(b<=u){v=b;break}if(w>=l)throw new RangeError("Data too long")}for(const u of[Ce.Ecc.MEDIUM,Ce.Ecc.QUARTILE,Ce.Ecc.HIGH])_&&v<=Ce.getNumDataCodewords(w,u)*8&&(c=u);let a=[];for(const u of i){r(u.mode.modeBits,4,a),r(u.numChars,u.mode.numCharCountBits(w),a);for(const b of u.getData())a.push(b)}m(a.length==v);const h=Ce.getNumDataCodewords(w,c)*8;m(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),m(a.length%8==0);for(let u=236;a.length<h;u^=253)r(u,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((u,b)=>d[b>>>3]|=u<<7-(b&7)),new Ce(w,c,d,g)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let f=0;f<c;f++)for(let l=0;l<c;l++)f==0&&l==0||f==0&&l==c-1||f==c-1&&l==0||this.drawAlignmentPattern(i[f],i[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let f=c;for(let g=0;g<10;g++)f=f<<1^(f>>>9)*1335;const l=(c<<10|f)^21522;m(l>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(l,g));this.setFunctionModule(8,7,o(l,6)),this.setFunctionModule(8,8,o(l,7)),this.setFunctionModule(7,8,o(l,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(l,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(l,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(l,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let f=0;f<12;f++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let f=0;f<18;f++){const l=o(c,f),g=this.size-11+f%3,_=Math.floor(f/3);this.setFunctionModule(g,_,l),this.setFunctionModule(_,g,l)}}drawFinderPattern(i,c){for(let f=-4;f<=4;f++)for(let l=-4;l<=4;l++){const g=Math.max(Math.abs(l),Math.abs(f)),_=i+l,w=c+f;0<=_&&_<this.size&&0<=w&&w<this.size&&this.setFunctionModule(_,w,g!=2&&g!=4)}}drawAlignmentPattern(i,c){for(let f=-2;f<=2;f++)for(let l=-2;l<=2;l++)this.setFunctionModule(i+l,c+f,Math.max(Math.abs(l),Math.abs(f))!=1)}setFunctionModule(i,c,f){this.modules[c][i]=f,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,f=this.errorCorrectionLevel;if(i.length!=Ce.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const l=Ce.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],g=Ce.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],_=Math.floor(Ce.getNumRawDataModules(c)/8),w=l-_%l,v=Math.floor(_/l);let a=[];const h=Ce.reedSolomonComputeDivisor(g);for(let u=0,b=0;u<l;u++){let y=i.slice(b,b+v-g+(u<w?0:1));b+=y.length;const k=Ce.reedSolomonComputeRemainder(y,h);u<w&&y.push(0),a.push(y.concat(k))}let d=[];for(let u=0;u<a[0].length;u++)a.forEach((b,y)=>{(u!=v-g||y>=w)&&d.push(b[u])});return m(d.length==_),d}drawCodewords(i){if(i.length!=Math.floor(Ce.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let l=0;l<this.size;l++)for(let g=0;g<2;g++){const _=f-g,v=(f+1&2)==0?this.size-1-l:l;!this.isFunction[v][_]&&c<i.length*8&&(this.modules[v][_]=o(i[c>>>3],7-(c&7)),c++)}}m(c==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let l;switch(i){case 0:l=(f+c)%2==0;break;case 1:l=c%2==0;break;case 2:l=f%3==0;break;case 3:l=(f+c)%3==0;break;case 4:l=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:l=f*c%2+f*c%3==0;break;case 6:l=(f*c%2+f*c%3)%2==0;break;case 7:l=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&l&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let _=!1,w=0,v=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==_?(w++,w==5?i+=Ce.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,v),_||(i+=this.finderPenaltyCountPatterns(v)*Ce.PENALTY_N3),_=this.modules[g][a],w=1);i+=this.finderPenaltyTerminateAndCount(_,w,v)*Ce.PENALTY_N3}for(let g=0;g<this.size;g++){let _=!1,w=0,v=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==_?(w++,w==5?i+=Ce.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,v),_||(i+=this.finderPenaltyCountPatterns(v)*Ce.PENALTY_N3),_=this.modules[a][g],w=1);i+=this.finderPenaltyTerminateAndCount(_,w,v)*Ce.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let _=0;_<this.size-1;_++){const w=this.modules[g][_];w==this.modules[g][_+1]&&w==this.modules[g+1][_]&&w==this.modules[g+1][_+1]&&(i+=Ce.PENALTY_N2)}let c=0;for(const g of this.modules)c=g.reduce((_,w)=>_+(w?1:0),c);const f=this.size*this.size,l=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=l&&l<=9),i+=l*Ce.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let f=[6];for(let l=this.size-7;f.length<i;l-=c)f.splice(1,0,l);return f}}static getNumRawDataModules(i){if(i<Ce.MIN_VERSION||i>Ce.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const f=Math.floor(i/7)+2;c-=(25*f-10)*f-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(Ce.getNumRawDataModules(i)/8)-Ce.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*Ce.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let c=[];for(let l=0;l<i-1;l++)c.push(0);c.push(1);let f=1;for(let l=0;l<i;l++){for(let g=0;g<c.length;g++)c[g]=Ce.reedSolomonMultiply(c[g],f),g+1<c.length&&(c[g]^=c[g+1]);f=Ce.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(i,c){let f=c.map(l=>0);for(const l of i){const g=l^f.shift();f.push(0),c.forEach((_,w)=>f[w]^=Ce.reedSolomonMultiply(_,g))}return f}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let l=7;l>=0;l--)f=f<<1^(f>>>7)*285,f^=(c>>>l&1)*i;return m(f>>>8==0),f}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const f=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(f&&i[0]>=c*4&&i[6]>=c?1:0)+(f&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,f){return i&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(i,c){c[0]==0&&(i+=this.size),c.pop(),c.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,c){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let f=i-1;f>=0;f--)c.push(n>>>f&1)}function o(n,i){return(n>>>i&1)!=0}function m(n){if(!n)throw new Error("Assertion error")}const p=class Qe{constructor(i,c,f){if(this.mode=i,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(i){let c=[];for(const f of i)r(f,8,c);return new Qe(Qe.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Qe.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<i.length;){const l=Math.min(i.length-f,3);r(parseInt(i.substring(f,f+l),10),l*3+1,c),f+=l}return new Qe(Qe.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Qe.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=i.length;f+=2){let l=Qe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;l+=Qe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),r(l,11,c)}return f<i.length&&r(Qe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Qe(Qe.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Qe.isNumeric(i)?[Qe.makeNumeric(i)]:Qe.isAlphanumeric(i)?[Qe.makeAlphanumeric(i)]:[Qe.makeBytes(Qe.toUtf8ByteArray(i))]}static makeEci(i){let c=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,c);else if(i<16384)r(2,2,c),r(i,14,c);else if(i<1e6)r(6,3,c),r(i,21,c);else throw new RangeError("ECI assignment value out of range");return new Qe(Qe.Mode.ECI,0,c)}static isNumeric(i){return Qe.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Qe.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let f=0;for(const l of i){const g=l.mode.numCharCountBits(c);if(l.numChars>=1<<g)return 1/0;f+=4+g+l.bitData.length}return f}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let f=0;f<i.length;f++)i.charAt(f)!="%"?c.push(i.charCodeAt(f)):(c.push(parseInt(i.substring(f+1,f+3),16)),f+=2);return c}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let x=p;e.QrSegment=p})(ds||(ds={}));(e=>{(s=>{const r=class{constructor(m,p){this.ordinal=m,this.formatBits=p}};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={}))})(ds||(ds={}));(e=>{(s=>{const r=class{constructor(m,p){this.modeBits=m,this.numBitsCharCount=p}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+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={}))})(ds||(ds={}));var xs=ds;var jv={L:xs.QrCode.Ecc.LOW,M:xs.QrCode.Ecc.MEDIUM,Q:xs.QrCode.Ecc.QUARTILE,H:xs.QrCode.Ecc.HIGH},Wl=128,$l="L",Ul="#FFFFFF",ql="#000000",Kl=!1,Xl=1,Nv=4,Rv=0,Av=.1;function Yl(e,s=0){const r=[];return e.forEach(function(o,m){let p=null;o.forEach(function(x,n){if(!x&&p!==null){r.push(`M${p+s} ${m+s}h${n-p}v1H${p+s}z`),p=null;return}if(n===o.length-1){if(!x)return;p===null?r.push(`M${n+s},${m+s} h1v1H${n+s}z`):r.push(`M${p+s},${m+s} h${n+1-p}v1H${p+s}z`);return}x&&p===null&&(p=n)})}),r.join("")}function Vl(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((m,p)=>p<s.x||p>=s.x+s.w?m:!1))}function Mv(e,s,r,o){if(o==null)return null;const m=e.length+r*2,p=Math.floor(s*Av),x=m/s,n=(o.width||p)*x,i=(o.height||p)*x,c=o.x==null?e.length/2-n/2:o.x*x,f=o.y==null?e.length/2-i/2:o.y*x,l=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let w=Math.floor(c),v=Math.floor(f),a=Math.ceil(n+c-w),h=Math.ceil(i+f-v);g={x:w,y:v,w:a,h}}const _=o.crossOrigin;return{x:c,y:f,h:i,w:n,excavation:g,opacity:l,crossOrigin:_}}function Tv(e,s){return s!=null?Math.max(Math.floor(s),0):e?Nv:Rv}function Gl({value:e,level:s,minVersion:r,includeMargin:o,marginSize:m,imageSettings:p,size:x,boostLevel:n}){let i=oe.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((v,a)=>(v.push(...xs.QrSegment.makeSegments(a)),v),[]);return xs.QrCode.encodeSegments(w,jv[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:c,margin:f,numCells:l,calculatedImageSettings:g}=oe.useMemo(()=>{let _=i.getModules();const w=Tv(o,m),v=_.length+w*2,a=Mv(_,x,w,p);return{cells:_,margin:w,numCells:v,calculatedImageSettings:a}},[i,x,p,o,m]);return{qrcode:i,margin:f,cells:c,numCells:l,calculatedImageSettings:g}}var Dv=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Lv=oe.forwardRef(function(s,r){const o=s,{value:m,size:p=Wl,level:x=$l,bgColor:n=Ul,fgColor:i=ql,includeMargin:c=Kl,minVersion:f=Xl,boostLevel:l,marginSize:g,imageSettings:_}=o,v=Oi(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=v,h=Oi(v,["style"]),d=_?.src,u=oe.useRef(null),b=oe.useRef(null),y=oe.useCallback(I=>{u.current=I,typeof r=="function"?r(I):r&&(r.current=I)},[r]),[k,E]=oe.useState(!1),{margin:S,cells:j,numCells:N,calculatedImageSettings:T}=Gl({value:m,level:x,minVersion:f,boostLevel:l,includeMargin:c,marginSize:g,imageSettings:_,size:p});oe.useEffect(()=>{if(u.current!=null){const I=u.current,L=I.getContext("2d");if(!L)return;let F=j;const z=b.current,A=T!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;A&&T.excavation!=null&&(F=Vl(j,T.excavation));const P=window.devicePixelRatio||1;I.height=I.width=p*P;const O=p/N*P;L.scale(O,O),L.fillStyle=n,L.fillRect(0,0,N,N),L.fillStyle=i,Dv?L.fill(new Path2D(Yl(F,S))):j.forEach(function(B,U){B.forEach(function(X,V){X&&L.fillRect(V+S,U+S,1,1)})}),T&&(L.globalAlpha=T.opacity),A&&L.drawImage(z,T.x+S,T.y+S,T.w,T.h)}}),oe.useEffect(()=>{E(!1)},[d]);const M=Pi({height:p,width:p},a);let D=null;return d!=null&&(D=oe.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:b,crossOrigin:T?.crossOrigin})),oe.createElement(oe.Fragment,null,oe.createElement("canvas",Pi({style:M,height:p,width:p,ref:y,role:"img"},h)),D)});Lv.displayName="QRCodeCanvas";var Ql=oe.forwardRef(function(s,r){const o=s,{value:m,size:p=Wl,level:x=$l,bgColor:n=Ul,fgColor:i=ql,includeMargin:c=Kl,minVersion:f=Xl,boostLevel:l,title:g,marginSize:_,imageSettings:w}=o,v=Oi(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:u}=Gl({value:m,level:x,minVersion:f,boostLevel:l,includeMargin:c,marginSize:_,imageSettings:w,size:p});let b=h,y=null;w!=null&&u!=null&&(u.excavation!=null&&(b=Vl(h,u.excavation)),y=oe.createElement("image",{href:w.src,height:u.h,width:u.w,x:u.x+a,y:u.y+a,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const k=Yl(b,a);return oe.createElement("svg",Pi({height:p,width:p,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},v),!!g&&oe.createElement("title",null,g),oe.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),oe.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),y)});Ql.displayName="QRCodeSVG";function Zl(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Pv(){return wt({queryKey:de.tunnel.status,queryFn:()=>Se.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Ov(){const e=tt();return pt({mutationFn:()=>Se.post("/tunnel/start",{port:Zl()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function Iv(){const e=tt();return pt({mutationFn:()=>Se.post("/tunnel/regenerate",{port:Zl()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function Bv(){const e=tt();return pt({mutationFn:()=>Se.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function Fv(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 zv(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 Hv(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 Uo(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 m=Math.round(o/60);return m<24?`${m}h ago`:`${Math.round(m/24)}d ago`}function Ts(e){const s=e?.trim();return s||null}function Wv(e){if(!e)return"";const s=[Ts(e.lastLocalError),Ts(e.lastRemoteError),Ts(e.lastError)].filter(m=>m!==null),r=Ts(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Ts(e.lastError));return r&&o&&s.push(r),s.join(`
85
- `)}function qo(){const{t:e}=ce(),{data:s}=Pv(),r=Ov(),o=Bv(),m=Iv(),[p,x]=C.useState(!1),[n,i]=C.useState(null),c=C.useRef(null),[f,l]=C.useState({top:0,right:0}),[g,_]=C.useState(!1),[w,v]=C.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=m.isPending,u=s?.shareableUrl,b=s?.token,y=Fv(s),k=zv(s),E=Wv(s);C.useEffect(()=>{if(p&&c.current){const I=c.current.getBoundingClientRect();l({top:I.bottom+8,right:window.innerWidth-I.right})}},[p]);const S=C.useCallback(()=>{x(!0)},[a]),j=C.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>x(!0)})},[r]),N=C.useCallback(()=>{u&&(navigator.clipboard.writeText(u),i("url"),setTimeout(()=>i(null),2e3))},[u]),T=C.useCallback(()=>{b&&(navigator.clipboard.writeText(b),i("token"),setTimeout(()=>i(null),2e3))},[b]),M=C.useCallback(()=>{o.mutate(),x(!1),_(!1),v(!1)},[o]),D=C.useCallback(()=>{m.mutate(void 0,{onSuccess:()=>{v(!1),x(!0)}})},[m]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:c,onClick:S,disabled:h,className:`p-1.5 rounded-md transition-colors ${y.button}`,title:e(y.label),children:h?t.jsx(Ke,{size:16,className:"animate-spin"}):y.icon==="warn"?t.jsx(Rr,{size:16}):t.jsx(Bn,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${y.dot} rounded-full`}),p&&!a&&Qt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!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:f.top,right:f.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(Bn,{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:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Ft,{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(Ke,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),p&&a&&Qt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!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:f.top,right:f.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 ${y.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(Hv(s))})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Ft,{size:14})})]}),b&&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(ha,{size:12}),t.jsx("span",{children:e("Token protected")})]}),u&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Ql,{value:u,size:160})}),u||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:u??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:I=>I.target.select()}),t.jsx("button",{onClick:N,disabled:!u,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(ft,{size:14,className:"text-emerald-500"}):t.jsx(In,{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:Uo(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:Uo(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.")}),b&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>_(!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:b}),t.jsx("button",{onClick:T,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(ft,{size:14,className:"text-emerald-500"}):t.jsx(In,{size:14})})]})]}),w&&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:()=>v(!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")})]})]}),!w&&t.jsxs("button",{onClick:()=>v(!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(Tr,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:M,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 Si({isOpen:e,onClose:s}){const{t:r}=ce(),o=Oc(),[m,p]=C.useState(""),[x,n]=C.useState(""),[i,c]=C.useState(null),[f,l]=C.useState(!1),[g,_]=C.useState(!1),w=m.trim(),v=x.trim(),a=f||o.isPending,h=C.useMemo(()=>!!(w&&v&&!a),[w,v,a]),d=C.useCallback(()=>{p(""),n(""),c(null),_(!1)},[]),u=C.useCallback(()=>{a||(d(),s())},[a,s,d]);C.useEffect(()=>{e||d()},[e,d]);const b=C.useCallback(async E=>{try{await o.mutateAsync({name:w,repoPath:v,initEmptyRepo:E}),d(),s()}catch(S){const j=S instanceof Error?S.message:r("Failed to create project");c(j),at.error(j)}},[o,s,d,r,w,v]),y=C.useCallback(async()=>{if(!(!w||!v||a)){c(null),l(!0);try{const E=await Se.get("/filesystem/validate",{params:{path:v}});if(E.valid){await b(!1);return}if(E.reason==="no_git"&&E.isEmpty){_(!0);return}if(E.reason==="no_git"){c(r("The selected directory is not a Git repository and is not empty. Initialize Git manually and make an initial commit, then create the project."));return}c(E.error??r("Selected path is not a valid directory"))}catch(E){c(E instanceof Error?E.message:r("Could not check repository path"))}finally{l(!1)}}},[b,a,r,w,v]),k=C.useCallback(()=>{_(!1),b(!0)},[b]);return t.jsxs(t.Fragment,{children:[t.jsx(ws,{isOpen:e,onClose:u,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:u,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:y,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:f?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:m,onChange:E=>p(E.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("Repository Path")}),t.jsx(Ic,{value:x,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(Nr,{isOpen:g,onClose:()=>{o.isPending||_(!1)},onConfirm:k,title:r("Initialize Git repository?"),description: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."),confirmText:"Initialize and Create",cancelText:"Cancel",isLoading:o.isPending})]})}const $v="/assets/agent-tower-logo-COx9gy77.png";function Ko({className:e="h-7 w-7"}){return t.jsx("img",{src:$v,alt:"Agent Tower",className:`block shrink-0 object-contain ${e}`})}const Uv={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Xo({projects:e,providers:s,isProvidersLoading:r,onSubmit:o,defaultProjectId:m="",defaultProviderId:p="",onProjectChange:x,createStep:n}){const{t:i}=ce(),[c,f]=C.useState(""),[l,g]=C.useState(m),[_,w]=C.useState(p),[v,a]=C.useState("SOLO"),[h,d]=C.useState(it.WORKTREE),[u,b]=C.useState("AUTO"),[y,k]=C.useState(null),[E,S]=C.useState([]),[j,N]=C.useState(!1),[T,M]=C.useState(!1),[D,I]=C.useState(!1),[L,F]=C.useState(!1),z=C.useRef(null),A=C.useRef(null),P=C.useRef(null),O=C.useRef(null),B=C.useRef(null),{files:U,addFiles:X,removeFile:V,clear:Z,buildMarkdownLinks:q,isUploading:R}=Fr();C.useEffect(()=>{g(m),x?.(m)},[m,x]),C.useEffect(()=>{w(p)},[p]),C.useEffect(()=>{if(!T)return;const Q=ye=>{z.current&&!z.current.contains(ye.target)&&M(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[T]),C.useEffect(()=>{if(!D)return;const Q=ye=>{A.current&&!A.current.contains(ye.target)&&I(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[D]),C.useEffect(()=>{if(!L)return;const Q=ye=>{P.current&&!P.current.contains(ye.target)&&F(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[L]);const H=C.useMemo(()=>e.find(Q=>Q.id===l),[e,l]),K=C.useMemo(()=>s.find(Q=>Q.id===_),[s,_]),W=h===it.MAIN_DIRECTORY?i("本地模式"):i("工作树模式"),Y=n!=="idle",G=!!y||E.length>0,ae=!Y&&!R&&c.trim().length>0&&!!l&&(v==="TEAM"?G:!!_),le=C.useCallback(async()=>{if(!ae)return;const Q=q();try{await o({title:c.trim(),description:"",projectId:l,providerId:_,mode:v,workspaceMode:v==="SOLO"?h:it.WORKTREE,teamRunMode:u,teamTemplateId:y,memberPresetIds:E,attachmentLinks:Q}),f(""),Z()}catch{}},[ae,c,l,_,v,h,u,y,E,o,q,Z]),Te=C.useCallback(Q=>{Q.key==="Enter"&&!Q.shiftKey&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),le())},[le]),De=C.useCallback(Q=>{const ye=Q.target.files;ye&&ye.length>0&&X(Array.from(ye)),Q.target.value=""},[X]),re=C.useCallback(Q=>{g(Q),x?.(Q),M(!1)},[x]),We=C.useCallback(Q=>{const ye=Q.clipboardData.items,Ae=[];for(const te of ye)if(te.kind==="file"){const ie=te.getAsFile();ie&&Ae.push(ie)}Ae.length>0&&(Q.preventDefault(),X(Ae))},[X]),[Be,Re]=C.useState(!1),ke=C.useCallback(Q=>{Q.preventDefault(),Re(!0)},[]),Ee=C.useCallback(Q=>{Q.preventDefault(),Re(!1)},[]),ve=C.useCallback(Q=>{Q.preventDefault(),Re(!1);const ye=Q.dataTransfer.files;ye.length>0&&X(Array.from(ye))},[X]);return t.jsxs("div",{className:"w-full",children:[t.jsxs("div",{className:J("relative bg-white rounded-xl border shadow-sm transition-all duration-200","hover:shadow-md focus-within:shadow-md focus-within:border-neutral-300",Be?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200",Y&&"opacity-80"),onDragOver:ke,onDragLeave:Ee,onDrop:ve,children:[U.length>0&&t.jsx("div",{className:"px-4 pt-3",children:t.jsx(zr,{files:U,onRemove:V})}),t.jsx("textarea",{ref:O,value:c,onChange:Q=>f(Q.target.value),onKeyDown:Te,onPaste:We,placeholder:i("Describe your task..."),disabled:Y,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-neutral-900 placeholder-neutral-400 leading-relaxed",style:{minHeight:"72px",maxHeight:"200px",fieldSizing:"content"}}),Be&&t.jsx("div",{className:"px-4 pb-2",children:t.jsx("div",{className:"flex items-center justify-center py-3 border-2 border-dashed border-neutral-300 rounded-lg text-sm text-neutral-500",children:i("Drop files here")})}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>B.current?.click(),disabled:Y||R,className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("Attach files"),children:t.jsx(jr,{size:18})}),t.jsx("input",{ref:B,type:"file",multiple:!0,onChange:De,className:"hidden"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[R&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-neutral-500",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),i("Uploading...")]}),Y&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-neutral-500",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),i(Uv[n])]}),!Y&&!R&&v==="TEAM"&&!G&&c.trim().length>0&&t.jsx("span",{className:"text-[11px] text-amber-600",children:i("请选择团队模板或追加成员")}),t.jsx("button",{type:"button",onClick:le,disabled:!ae,className:J("p-2 rounded-lg transition-all duration-200",ae?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"),title:i("Create & Start"),children:t.jsx(Ar,{size:16})})]})]})]}),t.jsxs("div",{className:"flex items-center flex-wrap gap-1 mt-3 px-1",children:[t.jsxs("div",{className:"relative",ref:z,children:[t.jsxs("button",{type:"button",onClick:()=>{Y||M(Q=>!Q)},disabled:Y,className:J("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-neutral-100 disabled:opacity-40 disabled:cursor-not-allowed",H?"text-neutral-700":"text-neutral-400"),children:[t.jsx(Mr,{size:14}),t.jsx("span",{className:"max-w-[120px] truncate",children:H?.name??i("Project")}),t.jsx(dt,{size:12,className:J("transition-transform",T&&"rotate-180")})]}),T&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 max-h-[240px] overflow-y-auto z-50",children:e.map(Q=>t.jsxs("button",{type:"button",onClick:()=>re(Q.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",children:[t.jsx(ft,{size:14,className:J("mr-2 shrink-0",Q.id===l?"opacity-100":"opacity-0")}),t.jsx("span",{className:J("truncate",Q.id===l?"text-neutral-900 font-medium":"text-neutral-600"),children:Q.name})]},Q.id))})]}),v==="SOLO"&&t.jsxs("div",{className:"relative",ref:A,children:[t.jsxs("button",{type:"button",onClick:()=>{Y||I(Q=>!Q)},disabled:Y,className:J("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-neutral-100 disabled:opacity-40 disabled:cursor-not-allowed",K?"text-neutral-700":"text-neutral-400"),children:[t.jsx(Qc,{size:14}),t.jsx("span",{className:"max-w-[120px] truncate",children:K?.name??i(r?"Loading...":"Agent")}),t.jsx(dt,{size:12,className:J("transition-transform",D&&"rotate-180")})]}),D&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 max-h-[240px] overflow-y-auto z-50",children:s.map(Q=>t.jsxs("button",{type:"button",disabled:!Q.available,onClick:()=>{w(Q.id),I(!1)},className:J("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",!Q.available&&"opacity-40 cursor-not-allowed"),children:[t.jsx(ft,{size:14,className:J("mr-2 shrink-0",Q.id===_?"opacity-100":"opacity-0")}),t.jsxs("span",{className:J("truncate",Q.id===_?"text-neutral-900 font-medium":"text-neutral-600"),children:[Q.name,Q.available?"":i(" (unavailable)")]})]},Q.id))})]}),v==="SOLO"&&t.jsxs("div",{className:"relative",ref:P,children:[t.jsxs("button",{type:"button",onClick:()=>{Y||F(Q=>!Q)},disabled:Y,className:J("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-neutral-100 disabled:opacity-40 disabled:cursor-not-allowed","text-neutral-700"),children:[t.jsx(Gi,{size:14}),t.jsx("span",{className:"max-w-[96px] truncate",children:W}),t.jsx(dt,{size:12,className:J("transition-transform",L&&"rotate-180")})]}),L&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-40 bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 z-50",children:[t.jsxs("button",{type:"button",onClick:()=>{d(it.WORKTREE),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",children:[t.jsx(ft,{size:14,className:J("mr-2 shrink-0",h===it.WORKTREE?"opacity-100":"opacity-0")}),t.jsx("span",{className:J("truncate",h===it.WORKTREE?"text-neutral-900 font-medium":"text-neutral-600"),children:i("工作树模式")})]}),t.jsxs("button",{type:"button",onClick:()=>{d(it.MAIN_DIRECTORY),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",children:[t.jsx(ft,{size:14,className:J("mr-2 shrink-0",h===it.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),t.jsx("span",{className:J("truncate",h===it.MAIN_DIRECTORY?"text-neutral-900 font-medium":"text-neutral-600"),children:i("本地模式")})]})]})]}),t.jsxs("button",{type:"button",onClick:()=>{if(Y)return;const Q=v==="SOLO"?"TEAM":"SOLO";a(Q),F(!1),Q==="TEAM"?(d(it.WORKTREE),N(!0)):N(!1)},disabled:Y,className:J("flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium transition-colors","disabled:opacity-40 disabled:cursor-not-allowed",v==="TEAM"?"text-blue-600 bg-neutral-50 rounded-t-lg rounded-b-none":"text-neutral-500 hover:text-neutral-700 hover:bg-neutral-50 rounded-lg"),title:i(v==="SOLO"?"Switch to TeamRun":"Switch to Solo Agent"),children:[t.jsx(ss,{size:14}),t.jsx("span",{children:i("团队协作")})]})]}),v==="SOLO"&&h===it.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2 px-1",children:t.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11px] leading-relaxed text-amber-800",children:i("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})}),v==="TEAM"&&j&&t.jsxs("div",{className:"rounded-b-xl rounded-tr-xl bg-neutral-50 px-4 pt-3 pb-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:i("团队协作配置")}),t.jsx("button",{type:"button",onClick:()=>{a("SOLO"),N(!1)},className:"text-[11px] text-neutral-400 hover:text-neutral-600 transition-colors",children:i("切换回单 Agent")})]}),t.jsx(Nl,{mode:u,setMode:b,selectedTemplateId:y,setSelectedTemplateId:k,selectedMemberPresetIds:E,setSelectedMemberPresetIds:S,disabled:Y})]})]})}const Yo=t.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),qv=260,Kv=600,Vo=400,Xv=100,wi=1e3;function px(){const{t:e,locale:s}=ce(),[r,o]=C.useState(null),[m,p]=C.useState(null),[x,n]=C.useState(Vo),[i,c]=C.useState(!1),[f,l]=C.useState("idle"),g=C.useRef(!1),_=C.useRef(0),w=C.useRef(Vo),v=C.useRef(null),a=tt(),{data:h,isLoading:d}=Cs(),{data:u,isLoading:b}=Bc({limit:Xv}),y=C.useMemo(()=>u?.data??[],[u?.data]),k=C.useMemo(()=>y.map(iv),[y]),E=m&&y.some(te=>te.id===m)?m:null,{data:S,isLoading:j}=Ac(E??"",{limit:wi}),N=Uc({queries:E?[]:y.map(te=>({queryKey:de.tasks.list(te.id,{limit:wi}),queryFn:()=>Se.get(`/projects/${te.id}/tasks`,{params:{limit:String(wi)}})}))}),T=!E&&N.some(te=>te.isLoading),M=C.useMemo(()=>{if(E)return S?.data??[];const te=[];for(const ie of N)ie.data?.data&&te.push(...ie.data.data);return te},[E,S,N]),[D,I]=C.useState(null),L=C.useMemo(()=>r&&M.some(te=>te.id===r)?r:D&&r===D?D:null,[r,M,D]);C.useEffect(()=>{D&&M.some(te=>te.id===D)&&I(null)},[D,M]);const F=C.useMemo(()=>{const te=new Map;for(const ie of M){const me=ie.createdAt?new Date(ie.createdAt).getTime():0,he=te.get(ie.projectId)??0;me>he&&te.set(ie.projectId,me)}return[...y].sort((ie,me)=>{const he=te.get(ie.id)??(ie.createdAt?new Date(ie.createdAt).getTime():0);return(te.get(me.id)??(me.createdAt?new Date(me.createdAt).getTime():0))-he})},[y,M]),z=C.useMemo(()=>F.filter(te=>!te.archivedAt),[F]),A=C.useMemo(()=>{if(!h)return[];const te=localStorage.getItem("providerUsageCount"),ie=te?JSON.parse(te):{};return[...h].sort((me,he)=>{const we=me.availability.type!=="NOT_FOUND",$=he.availability.type!=="NOT_FOUND";if(we!==$)return we?-1:1;const ne=ie[me.provider.id]??0;return(ie[he.provider.id]??0)-ne})},[h]),P=C.useMemo(()=>M.map(ov),[M]),O=C.useMemo(()=>new Set,[]),B=C.useMemo(()=>{if(!L)return null;const te=M.find(me=>me.id===L);if(!te)return null;const ie=y.find(me=>me.id===te.projectId);if(!ie){const me=cs(te.workspaces?.find(he=>he.status==="ACTIVE")??te.workspaces?.[0]);return{id:te.id,projectId:te.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:te.title,status:Sn(te.status),branch:me,mainBranch:"main",description:te.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return av(te,ie)},[L,M,y]),U=ta(),X=Mc(),V=Tc(),Z=C.useCallback(te=>{X.mutate(te,{onSuccess:()=>{L===te&&o(null),a.invalidateQueries({queryKey:de.tasks.all})},onError:()=>{at.error(e("删除任务失败"))}})},[X,L,a,e]),q=C.useCallback((te,ie)=>{V.mutate({id:te,status:sv(ie)},{onError:()=>{at.error(e("状态变更失败,该操作不被允许"))}})},[V,e]),R=C.useCallback(te=>{te.preventDefault(),g.current=!0,_.current=te.clientX,w.current=x,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[x]);C.useEffect(()=>{const te=me=>{if(!g.current)return;const he=me.clientX-_.current,we=Math.max(qv,Math.min(Kv,w.current+he));n(we)},ie=()=>{g.current&&(g.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",te),document.addEventListener("mouseup",ie),()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",ie)}},[]);const H=C.useCallback(()=>{c(!0)},[]),K=C.useCallback(()=>{if(z.length===0){at.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[z,e]),W=C.useCallback(()=>{c(!1)},[]),Y=bn(),G=C.useCallback(async te=>{const{title:ie,description:me,projectId:he,providerId:we,mode:$,workspaceMode:ne,teamRunMode:fe,teamTemplateId:je,memberPresetIds:$e,attachmentLinks:Fe}=te,st=[me,Fe].filter(Boolean).join(`
86
-
87
- `);let Le=null;try{if(l("creating-task"),Le=await Se.post(`/projects/${he}/tasks`,{title:ie,description:st||void 0}),localStorage.setItem("lastSelectedProjectId",he),$==="SOLO"&&we){localStorage.setItem("lastSelectedProviderId",we);const _e=localStorage.getItem("providerUsageCount"),Xe=_e?JSON.parse(_e):{};Xe[we]=(Xe[we]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Xe))}if($==="TEAM")l("creating-teamrun"),await U.mutateAsync({taskId:Le.id,mode:fe,...je?{teamTemplateId:je}:{},...$e.length>0?{memberPresetIds:$e}:{}});else if(we){const _e=[ie,st].filter(Boolean).join(`
88
-
89
- `);l("creating-workspace");const Xe=await Se.post(`/tasks/${Le.id}/workspaces`,{workspaceKind:ne});l("creating-session");const xe=await Se.post(`/workspaces/${Xe.id}/sessions`,{providerId:we,prompt:_e});l("starting-session"),await Y.mutateAsync(xe.id),await a.invalidateQueries({queryKey:de.workspaces.list(Le.id)})}E&&he!==E&&p(null),I(Le.id),o(Le.id),l("idle"),a.invalidateQueries({queryKey:de.tasks.all}),a.invalidateQueries({queryKey:de.projects.all})}catch(_e){if(l("idle"),Le&&$==="TEAM"){try{await X.mutateAsync(Le.id)}catch{}throw at.error(e("TeamRun 创建失败,请检查团队配置后重试")),_e}else if(Le)E&&he!==E&&p(null),I(Le.id),o(Le.id),a.invalidateQueries({queryKey:de.tasks.all}),a.invalidateQueries({queryKey:de.projects.all}),at.error(e("任务已创建,但启动 Agent 失败,可在详情中重试"));else throw at.error(_e instanceof Error?_e.message:e("Failed to create task")),_e}},[U,Y,X,a,e,E]),ae=b||j||T,le=C.useMemo(()=>z.map(te=>({id:te.id,name:te.name})),[z]),Te=C.useMemo(()=>A.map(({provider:te,availability:ie})=>({id:te.id,name:te.name,available:ie.type!=="NOT_FOUND"})),[A]),De=C.useMemo(()=>{if(E&&z.find(ie=>ie.id===E))return E;const te=localStorage.getItem("lastSelectedProjectId");return te&&z.find(ie=>ie.id===te)?te:z[0]?.id??""},[z,E]),[re,We]=C.useState(De);C.useEffect(()=>{We(De)},[De]);const Be=C.useMemo(()=>z.find(te=>te.id===re)?.name??z.find(te=>te.id===De)?.name??e("Project"),[z,re,De,e]),Re=s==="zh-CN"?`你需要在 ${Be} 中做点什么?`:`What do you need to do in ${Be}?`,ke=C.useMemo(()=>{const te=localStorage.getItem("lastSelectedProviderId");return te&&A.find(me=>me.provider.id===te&&me.availability.type!=="NOT_FOUND")?te:A.find(me=>me.availability.type!=="NOT_FOUND")?.provider.id??""},[A]),Ee=La(),[ve,Q]=C.useState(!1),ye=C.useCallback(()=>{if(z.length===0){at.error(e("没有可用项目,请先创建或恢复项目"));return}Q(!0)},[z,e]),Ae=C.useCallback(async te=>{await G(te),Q(!1)},[G]);return Ee?ve?t.jsxs("div",{className:"flex flex-col h-dvh bg-white overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-neutral-200 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Q(!1),className:"text-sm text-neutral-600 active:text-neutral-900",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4",children:[t.jsx("h1",{className:"max-w-full text-center text-xl leading-tight text-neutral-900 mb-6 break-words",children:Re}),t.jsx(Xo,{projects:le,providers:Te,isProvidersLoading:d,onSubmit:Ae,defaultProjectId:De,defaultProviderId:ke,onProjectChange:We,createStep:f})]})]}):L&&B?t.jsxs(t.Fragment,{children:[t.jsx(kv,{task:B,onBack:()=>o(null),onDeleteTask:B.projectArchivedAt?void 0:Z,isDeleting:X.isPending}),t.jsx(Si,{isOpen:i,onClose:W})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ko,{}),Yo]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(qo,{}),t.jsx("button",{onClick:()=>Dn.getState().openSettings(),className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:t.jsx(Tn,{size:16})})]})]}),ae&&P.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):t.jsx(Qn,{tasks:P,projects:k,selectedTaskId:null,onSelectTask:o,filterProjectId:E,setFilterProjectId:p,width:"100%",onCreateProject:H,onCreateTask:ye,activeTaskIds:O,onTaskStatusChange:q})]}),t.jsx(Si,{isOpen:i,onClose:W})]}):t.jsxs("div",{ref:v,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between flex-shrink-0 z-10 relative",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ko,{}),Yo]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(qo,{}),t.jsx("button",{onClick:()=>Dn.getState().openSettings(),className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:t.jsx(Tn,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[ae&&P.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-sm text-neutral-400 border-r border-neutral-200 flex-shrink-0",style:{width:x},children:e("Loading...")}):t.jsx(Qn,{tasks:P,projects:k,selectedTaskId:L,onSelectTask:o,filterProjectId:E,setFilterProjectId:p,width:x,onCreateProject:H,onCreateTask:K,activeTaskIds:O,onTaskStatusChange:q,onDeleteTask:Z}),t.jsx("div",{onMouseDown:R,className:"w-1 cursor-col-resize hover:bg-neutral-300 active:bg-neutral-400 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),L&&B?t.jsx(tv,{task:B,onDeleteTask:B.projectArchivedAt?void 0:Z,isDeleting:X.isPending,onTaskStatusChange:B.projectArchivedAt?void 0:q}):L&&!B?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-white min-w-0",children:t.jsx("span",{className:"text-sm text-neutral-400",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-white min-w-0 px-8",children:t.jsxs("div",{className:"w-full max-w-3xl 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-2xl leading-tight text-neutral-900 mb-8 break-words",children:Re}),t.jsx(Xo,{projects:le,providers:Te,isProvidersLoading:d,onSubmit:G,defaultProjectId:De,defaultProviderId:ke,onProjectChange:We,createStep:f})]})})]}),t.jsx(Si,{isOpen:i,onClose:W})]})}export{px as ProjectKanbanPage};