loki-mode 9.48.2 → 9.49.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.github/workflows/loki-issue-to-pr.yml +1 -1
  2. package/SKILL.md +2 -2
  3. package/VERSION +1 -1
  4. package/autonomy/lib/claude-flags.sh +18 -2
  5. package/autonomy/loki +137 -12
  6. package/autonomy/notification-checker.py +45 -17
  7. package/autonomy/provider-offer.sh +47 -0
  8. package/autonomy/quickstart.sh +306 -9
  9. package/autonomy/run.sh +43 -4
  10. package/dashboard/__init__.py +1 -1
  11. package/dashboard/static/index.html +7 -1
  12. package/docs/INSTALLATION.md +1 -1
  13. package/docs/KNOWN-ISSUES.md +42 -0
  14. package/docs/cost-controls.md +1 -1
  15. package/docs/environment-variables.md +1 -1
  16. package/loki-ts/dist/loki.js +317 -317
  17. package/mcp/__init__.py +1 -1
  18. package/package.json +1 -1
  19. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  20. package/web-app/dist/assets/{AdminPage-PyyVXg4b.js → AdminPage-BA6etdwL.js} +1 -1
  21. package/web-app/dist/assets/{Avatar-CTUlr_Xf.js → Avatar-CAtbcD23.js} +1 -1
  22. package/web-app/dist/assets/{Badge-BQeXvmg8.js → Badge-sb_JbKl0.js} +1 -1
  23. package/web-app/dist/assets/{Button-Dc6-P6pz.js → Button-BamXbIWa.js} +1 -1
  24. package/web-app/dist/assets/{CockpitPage-BspOJ3Fv.js → CockpitPage-CUYizBtG.js} +4 -4
  25. package/web-app/dist/assets/{ComparePage-CFXIM--Z.js → ComparePage-BnmNTggM.js} +1 -1
  26. package/web-app/dist/assets/{ErrorBoundary-C7vQYDW9.js → ErrorBoundary-BjX4_KOW.js} +1 -1
  27. package/web-app/dist/assets/{EvidenceReceiptPanel-CqjsjTOs.js → EvidenceReceiptPanel-Bq6pmNUw.js} +1 -1
  28. package/web-app/dist/assets/{GitHubIssuesPanel-DyuNDMgD.js → GitHubIssuesPanel-DD8c6RVj.js} +1 -1
  29. package/web-app/dist/assets/{GitHubPRsPanel-BtAq20xF.js → GitHubPRsPanel-4NawTXRl.js} +2 -2
  30. package/web-app/dist/assets/{HomePage-BuVFOrO8.js → HomePage-DTREi8OE.js} +1 -1
  31. package/web-app/dist/assets/{LoginPage-CuhhrxGb.js → LoginPage-DavfeQxC.js} +1 -1
  32. package/web-app/dist/assets/{MagicPage-D2KZPX3F.js → MagicPage-BIbTFlwh.js} +1 -1
  33. package/web-app/dist/assets/MetricsPage-Cn3UPKpU.js +6 -0
  34. package/web-app/dist/assets/{NotFoundPage-CTnnaWlL.js → NotFoundPage-BVs_nuBv.js} +1 -1
  35. package/web-app/dist/assets/{ProjectPage-uJFaoM8-.js → ProjectPage-CLplvOHe.js} +25 -25
  36. package/web-app/dist/assets/{ProjectsPage-8lKAOBIW.js → ProjectsPage-BBFzBBG_.js} +2 -2
  37. package/web-app/dist/assets/{SettingsPage-D1BBd5qy.js → SettingsPage-WPsJ_K9r.js} +1 -1
  38. package/web-app/dist/assets/{ShowcasePage-CmQ0n8iO.js → ShowcasePage-ZaLaJl5J.js} +1 -1
  39. package/web-app/dist/assets/SystemSettingsPage-CCORP-uG.js +1 -0
  40. package/web-app/dist/assets/{TeamsPage-BS0TtVUa.js → TeamsPage-B6IGT_K2.js} +1 -1
  41. package/web-app/dist/assets/{TemplatesPage-C2zPnnf2.js → TemplatesPage-RrYYC3CM.js} +1 -1
  42. package/web-app/dist/assets/{TerminalOutput-Dle1klqq.js → TerminalOutput-CeTvKnkl.js} +1 -1
  43. package/web-app/dist/assets/{activity-DQp5U9f9.js → activity-CySdOdDP.js} +1 -1
  44. package/web-app/dist/assets/{bell-BqkTmgL7.js → bell-BHdr5yat.js} +1 -1
  45. package/web-app/dist/assets/{bot-DILhaIGH.js → bot-BaB4q_4m.js} +1 -1
  46. package/web-app/dist/assets/{check-BC9x7oPm.js → check-BAgbzVrK.js} +1 -1
  47. package/web-app/dist/assets/{chevron-left--yqvAfjx.js → chevron-left-CrVUY29C.js} +1 -1
  48. package/web-app/dist/assets/{circle-alert-DOH6PcgZ.js → circle-alert-YrWgH49w.js} +1 -1
  49. package/web-app/dist/assets/{clock-DKSDFsE6.js → clock-DN8LAN-0.js} +1 -1
  50. package/web-app/dist/assets/{cloud-DRBU3JYs.js → cloud-D6C4b1KY.js} +1 -1
  51. package/web-app/dist/assets/{code-xml-D2LqszR9.js → code-xml-xBWyKfux.js} +1 -1
  52. package/web-app/dist/assets/{database-D7ceedlh.js → database-BYqcS6kn.js} +1 -1
  53. package/web-app/dist/assets/{dollar-sign-D0A47egY.js → dollar-sign--WOh4k_m.js} +1 -1
  54. package/web-app/dist/assets/{file-code-corner-CH_Qbtjo.js → file-code-corner-B0rLPjW1.js} +1 -1
  55. package/web-app/dist/assets/{file-plus-CUNMjHk9.js → file-plus-BNhUQ1TQ.js} +1 -1
  56. package/web-app/dist/assets/folder-open-DliiOgFl.js +11 -0
  57. package/web-app/dist/assets/{globe-gZnaGg8N.js → globe-BV-hx0u_.js} +1 -1
  58. package/web-app/dist/assets/{hammer-BhJC5DMK.js → hammer-DhmP4GLw.js} +1 -1
  59. package/web-app/dist/assets/index-D98GzaW8.css +1 -0
  60. package/web-app/dist/assets/{index-BMmYYws0.js → index-x0TESFYr.js} +3 -3
  61. package/web-app/dist/assets/{layers-glXeoUbJ.js → layers-DXWDMSYj.js} +1 -1
  62. package/web-app/dist/assets/{lightbulb-gXn8H0Lf.js → lightbulb-PBw6hhLS.js} +1 -1
  63. package/web-app/dist/assets/{loader-circle-Do2ke8xm.js → loader-circle-B7KiGAVU.js} +1 -1
  64. package/web-app/dist/assets/{lock-Bgplb1_n.js → lock-BUTRYdDQ.js} +1 -1
  65. package/web-app/dist/assets/{mail-j4Lo8hfB.js → mail-DaLiNrPb.js} +1 -1
  66. package/web-app/dist/assets/{minus-dhrzKSK5.js → minus-DB_hlGEk.js} +1 -1
  67. package/web-app/dist/assets/{package-CInWQQ97.js → package-CymmXoiQ.js} +1 -1
  68. package/web-app/dist/assets/{plus-BpYvoLlZ.js → plus-Cp4AO4I2.js} +1 -1
  69. package/web-app/dist/assets/{refresh-cw-F6koqEgF.js → refresh-cw-ygYTmZTE.js} +1 -1
  70. package/web-app/dist/assets/{rotate-ccw-CQ2W5S8f.js → rotate-ccw-Ba3QxM9K.js} +1 -1
  71. package/web-app/dist/assets/{save-DMCYGm06.js → save-DPm96BnR.js} +1 -1
  72. package/web-app/dist/assets/{server-Bj8EX4Z1.js → server-BapOz_vf.js} +1 -1
  73. package/web-app/dist/assets/{shield-alert-CiYuulCU.js → shield-alert-DYzfVqWS.js} +1 -1
  74. package/web-app/dist/assets/{thumbs-up-BqEh1puP.js → thumbs-up-DxOTplej.js} +11 -6
  75. package/web-app/dist/assets/{trash-2-CCwouZJJ.js → trash-2-Br8dh_6B.js} +1 -1
  76. package/web-app/dist/assets/{trending-down-Cx1vhE4o.js → trending-down-CxSP6MU3.js} +1 -1
  77. package/web-app/dist/assets/{trending-up-BUhVYJ2T.js → trending-up-CXx0ywZb.js} +1 -1
  78. package/web-app/dist/assets/{upload-D5IsZeFM.js → upload-CpEO3qNc.js} +1 -1
  79. package/web-app/dist/assets/{usePolling-CJbfhFcH.js → usePolling-BuzXwjmC.js} +1 -1
  80. package/web-app/dist/assets/{user-BRLhezsD.js → user-DUUYT47B.js} +1 -1
  81. package/web-app/dist/index.html +2 -2
  82. package/web-app/server.py +121 -1
  83. package/web-app/dist/assets/MetricsPage-DFEYJl9z.js +0 -6
  84. package/web-app/dist/assets/SystemSettingsPage-CSHaVyuD.js +0 -6
  85. package/web-app/dist/assets/copy-BKW4U4Qr.js +0 -6
  86. package/web-app/dist/assets/folder-open-CQ_SVq94.js +0 -6
  87. package/web-app/dist/assets/git-commit-horizontal-DQUBe0oD.js +0 -6
  88. package/web-app/dist/assets/index-84JUN_aA.css +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-DyuNDMgD.js","assets/index-BMmYYws0.js","assets/index-84JUN_aA.css","assets/Button-Dc6-P6pz.js","assets/thumbs-up-BqEh1puP.js","assets/refresh-cw-F6koqEgF.js","assets/circle-alert-DOH6PcgZ.js","assets/user-BRLhezsD.js","assets/rotate-ccw-CQ2W5S8f.js","assets/loader-circle-Do2ke8xm.js","assets/GitHubPRsPanel-BtAq20xF.js","assets/chevron-left--yqvAfjx.js","assets/shield-alert-CiYuulCU.js","assets/file-code-corner-CH_Qbtjo.js","assets/clock-DKSDFsE6.js","assets/check-BC9x7oPm.js","assets/ErrorBoundary-C7vQYDW9.js","assets/TerminalOutput-Dle1klqq.js","assets/lock-Bgplb1_n.js","assets/package-CInWQQ97.js","assets/file-plus-CUNMjHk9.js","assets/activity-DQp5U9f9.js","assets/bot-DILhaIGH.js","assets/hammer-BhJC5DMK.js","assets/dollar-sign-D0A47egY.js","assets/globe-gZnaGg8N.js","assets/copy-BKW4U4Qr.js","assets/git-commit-horizontal-DQUBe0oD.js","assets/upload-D5IsZeFM.js","assets/plus-BpYvoLlZ.js","assets/trash-2-CCwouZJJ.js","assets/minus-dhrzKSK5.js","assets/save-DMCYGm06.js","assets/code-xml-D2LqszR9.js","assets/trending-up-BUhVYJ2T.js","assets/layers-glXeoUbJ.js","assets/trending-down-Cx1vhE4o.js","assets/folder-open-CQ_SVq94.js","assets/server-Bj8EX4Z1.js"])))=>i.map(i=>d[i]);
2
- var sa=e=>{throw TypeError(e)};var ia=(e,t,s)=>t.has(e)||sa("Cannot "+s);var Hs=(e,t,s)=>(ia(e,t,"read from private field"),s?s.call(e):t.get(e)),ra=(e,t,s)=>t.has(e)?sa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),na=(e,t,s,i)=>(ia(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as ce,r as d,W as Ds,j as r,f as en,g as Kl,h as ur,i as fs,I as ql,T as Ht,R as Wt,k as ns,M as Vl,l as tr,m as Dt,S as Gl,U as _d,X as _t,n as os,Z as is,a as W,E as as,G as ze,K as xd,o as vd,p as bd,F as mi,P as Ut,_ as Qn,b as fr,q as Yl,s as Xl,t as yd,v as Sd,A as eo,L as wd,B as Ys,w as tn,x as Cd,e as kd,y as ks,z as oa,D as aa,H as jd,J as Jl,N as ri,O as Nd,u as Ed}from"./index-BMmYYws0.js";import{R as Dd,S as sr,P as Zl,E as Wi}from"./ErrorBoundary-C7vQYDW9.js";import{B as he}from"./Button-Dc6-P6pz.js";import{T as Rd,F as Pd}from"./TerminalOutput-Dle1klqq.js";import{P as Ql}from"./package-CInWQQ97.js";import{F as ee}from"./file-code-corner-CH_Qbtjo.js";import{F as mr}from"./file-plus-CUNMjHk9.js";import{C as ct}from"./clock-DKSDFsE6.js";import{A as Md}from"./activity-DQp5U9f9.js";import{B as Ld}from"./bot-DILhaIGH.js";import{C as Gt}from"./check-BC9x7oPm.js";import{L as pi}from"./loader-circle-Do2ke8xm.js";import{H as Bd}from"./hammer-BhJC5DMK.js";import{D as ec}from"./dollar-sign-D0A47egY.js";import{R as bt}from"./refresh-cw-F6koqEgF.js";import{C as Bs}from"./circle-alert-DOH6PcgZ.js";import{G as sn}from"./globe-gZnaGg8N.js";import{C as to}from"./copy-BKW4U4Qr.js";import{C as Td,G as rn,F as tc,H as nn,T as zd}from"./thumbs-up-BqEh1puP.js";import{G as sc}from"./git-commit-horizontal-DQUBe0oD.js";import{U as ic}from"./upload-D5IsZeFM.js";import{P as pr}from"./plus-BpYvoLlZ.js";import{T as so}from"./trash-2-CCwouZJJ.js";import{R as rc,E as Ad}from"./rotate-ccw-CQ2W5S8f.js";import{M as nc}from"./minus-dhrzKSK5.js";import{S as Od}from"./save-DMCYGm06.js";import{C as on}from"./code-xml-D2LqszR9.js";import{T as $d}from"./trending-up-BUhVYJ2T.js";import{L as Id}from"./layers-glXeoUbJ.js";import{T as Fd}from"./trending-down-Cx1vhE4o.js";import{F as an}from"./folder-open-CQ_SVq94.js";import{S as Hd}from"./server-Bj8EX4Z1.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-DD8c6RVj.js","assets/index-x0TESFYr.js","assets/index-D98GzaW8.css","assets/Button-BamXbIWa.js","assets/thumbs-up-DxOTplej.js","assets/refresh-cw-ygYTmZTE.js","assets/circle-alert-YrWgH49w.js","assets/user-DUUYT47B.js","assets/rotate-ccw-Ba3QxM9K.js","assets/loader-circle-B7KiGAVU.js","assets/GitHubPRsPanel-4NawTXRl.js","assets/chevron-left-CrVUY29C.js","assets/shield-alert-DYzfVqWS.js","assets/file-code-corner-B0rLPjW1.js","assets/clock-DN8LAN-0.js","assets/check-BAgbzVrK.js","assets/ErrorBoundary-BjX4_KOW.js","assets/TerminalOutput-CeTvKnkl.js","assets/lock-BUTRYdDQ.js","assets/package-CymmXoiQ.js","assets/file-plus-BNhUQ1TQ.js","assets/activity-CySdOdDP.js","assets/bot-BaB4q_4m.js","assets/hammer-DhmP4GLw.js","assets/dollar-sign--WOh4k_m.js","assets/globe-BV-hx0u_.js","assets/folder-open-DliiOgFl.js","assets/upload-CpEO3qNc.js","assets/plus-Cp4AO4I2.js","assets/trash-2-Br8dh_6B.js","assets/minus-DB_hlGEk.js","assets/save-DPm96BnR.js","assets/code-xml-xBWyKfux.js","assets/trending-up-CXx0ywZb.js","assets/layers-DXWDMSYj.js","assets/trending-down-CxSP6MU3.js","assets/server-BapOz_vf.js"])))=>i.map(i=>d[i]);
2
+ var sa=e=>{throw TypeError(e)};var ia=(e,t,s)=>t.has(e)||sa("Cannot "+s);var Hs=(e,t,s)=>(ia(e,t,"read from private field"),s?s.call(e):t.get(e)),ra=(e,t,s)=>t.has(e)?sa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),na=(e,t,s,i)=>(ia(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as ce,r as d,W as Ds,j as r,f as en,g as Kl,h as ur,i as fs,I as ql,T as Ht,R as Wt,k as ns,M as Vl,l as tr,m as Rt,S as Gl,U as _d,X as _t,n as os,Z as is,a as W,E as as,G as ze,K as xd,o as vd,p as bd,F as mi,P as Ut,_ as Qn,b as fr,q as Yl,s as Xl,t as yd,v as Sd,A as eo,L as wd,B as Ys,w as tn,x as Cd,e as kd,y as js,z as oa,D as aa,H as jd,J as Jl,N as ri,O as Nd,u as Ed}from"./index-x0TESFYr.js";import{R as Rd,S as sr,P as Zl,E as Wi}from"./ErrorBoundary-BjX4_KOW.js";import{B as he}from"./Button-BamXbIWa.js";import{T as Dd,F as Pd}from"./TerminalOutput-CeTvKnkl.js";import{P as Ql}from"./package-CymmXoiQ.js";import{F as ee}from"./file-code-corner-B0rLPjW1.js";import{F as mr}from"./file-plus-BNhUQ1TQ.js";import{C as ct}from"./clock-DN8LAN-0.js";import{A as Md}from"./activity-CySdOdDP.js";import{B as Ld}from"./bot-BaB4q_4m.js";import{C as Gt}from"./check-BAgbzVrK.js";import{L as pi}from"./loader-circle-B7KiGAVU.js";import{H as Bd}from"./hammer-DhmP4GLw.js";import{D as ec}from"./dollar-sign--WOh4k_m.js";import{R as bt}from"./refresh-cw-ygYTmZTE.js";import{C as ms}from"./circle-alert-YrWgH49w.js";import{G as sn}from"./globe-BV-hx0u_.js";import{C as to,F as rn}from"./folder-open-DliiOgFl.js";import{C as Td,G as nn,a as tc,F as sc,H as on,T as zd}from"./thumbs-up-DxOTplej.js";import{U as ic}from"./upload-CpEO3qNc.js";import{P as pr}from"./plus-Cp4AO4I2.js";import{T as so}from"./trash-2-Br8dh_6B.js";import{R as rc,E as Ad}from"./rotate-ccw-Ba3QxM9K.js";import{M as nc}from"./minus-DB_hlGEk.js";import{S as Od}from"./save-DPm96BnR.js";import{C as an}from"./code-xml-xBWyKfux.js";import{T as $d}from"./trending-up-CXx0ywZb.js";import{L as Id}from"./layers-DXWDMSYj.js";import{T as Fd}from"./trending-down-CxSP6MU3.js";import{S as Hd}from"./server-BapOz_vf.js";/**
3
3
  * @license lucide-react v0.577.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -79,7 +79,7 @@ var sa=e=>{throw TypeError(e)};var ia=(e,t,s)=>t.has(e)||sa("Cannot "+s);var Hs=
79
79
  *
80
80
  * This source code is licensed under the ISC license.
81
81
  * See the LICENSE file in the root directory of this source tree.
82
- */const uu=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Rr=ce("layout-dashboard",uu);/**
82
+ */const uu=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Dr=ce("layout-dashboard",uu);/**
83
83
  * @license lucide-react v0.577.0 - ISC
84
84
  *
85
85
  * This source code is licensed under the ISC license.
@@ -134,12 +134,12 @@ var sa=e=>{throw TypeError(e)};var ia=(e,t,s)=>t.has(e)||sa("Cannot "+s);var Hs=
134
134
  *
135
135
  * This source code is licensed under the ISC license.
136
136
  * See the LICENSE file in the root directory of this source tree.
137
- */const Eu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Du=ce("smartphone",Eu);/**
137
+ */const Eu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ru=ce("smartphone",Eu);/**
138
138
  * @license lucide-react v0.577.0 - ISC
139
139
  *
140
140
  * This source code is licensed under the ISC license.
141
141
  * See the LICENSE file in the root directory of this source tree.
142
- */const Ru=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],Pu=ce("tablet",Ru);/**
142
+ */const Du=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],Pu=ce("tablet",Du);/**
143
143
  * @license lucide-react v0.577.0 - ISC
144
144
  *
145
145
  * This source code is licensed under the ISC license.
@@ -169,7 +169,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
169
169
  monaco.config({ paths: { vs: '...' } })
170
170
 
171
171
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
172
- `},ma=df(pf)(dc),gf={config:ff},_f=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(n){return s.reduceRight(function(o,a){return a(o)},n)}};function uc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],uc(e[s],t[s]))}),da(da({},e),t)}var xf={type:"cancelation",msg:"operation is manually canceled"};function Pr(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(xf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var vf=["monaco"],bf=cf.create({config:hf,isInitialized:!1,resolve:null,reject:null,monaco:null}),fc=Uu(bf,2),gi=fc[0],_r=fc[1];function yf(e){var t=gf.config(e),s=t.monaco,i=Hu(t,vf);_r(function(n){return{config:uc(n.config,i),monaco:s}})}function Sf(){var e=gi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(_r({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Pr(Mr);if(window.monaco&&window.monaco.editor)return mc(window.monaco),e.resolve(window.monaco),Pr(Mr);_f(wf,kf)(jf)}return Pr(Mr)}function wf(e){return document.body.appendChild(e)}function Cf(e){var t=document.createElement("script");return e&&(t.src=e),t}function kf(e){var t=gi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Cf("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function jf(){var e=gi(function(s){var i=s.config,n=s.resolve,o=s.reject;return{config:i,resolve:n,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;mc(i),e.resolve(i)},function(s){e.reject(s)})}function mc(e){gi().monaco||_r({monaco:e})}function Nf(){return gi(function(e){var t=e.monaco;return t})}var Mr=new Promise(function(e,t){return _r({resolve:e,reject:t})}),pc={config:yf,init:Sf,__getMonacoInstance:Nf},Ef={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Lr=Ef,Df={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Rf=Df;function Pf({children:e}){return Ds.createElement("div",{style:Rf.container},e)}var Mf=Pf,Lf=Mf;function Bf({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return Ds.createElement("section",{style:{...Lr.wrapper,width:e,height:t},...a},!s&&Ds.createElement(Lf,null,i),Ds.createElement("div",{ref:n,style:{...Lr.fullWidth,...!s&&Lr.hide},className:o}))}var Tf=Bf,gc=d.memo(Tf);function zf(e){d.useEffect(e,[])}var _c=zf;function Af(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var rt=Af;function oi(){}function js(e,t,s,i){return Of(e,i)||$f(e,t,s,i)}function Of(e,t){return e.editor.getModel(xc(e,t))}function $f(e,t,s,i){return e.editor.createModel(t,s,i?xc(e,i):void 0)}function xc(e,t){return e.Uri.parse(t)}function If({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:u="Loading...",options:m={},height:f="100%",width:_="100%",className:p,wrapperProps:g={},beforeMount:v=oi,onMount:y=oi}){let[x,C]=d.useState(!1),[j,w]=d.useState(!0),D=d.useRef(null),B=d.useRef(null),U=d.useRef(null),G=d.useRef(y),K=d.useRef(v),A=d.useRef(!1);_c(()=>{let S=pc.init();return S.then(N=>(B.current=N)&&w(!1)).catch(N=>(N==null?void 0:N.type)!=="cancelation"&&console.error("Monaco initialization: error:",N)),()=>D.current?L():S.cancel()}),rt(()=>{if(D.current&&B.current){let S=D.current.getOriginalEditor(),N=js(B.current,e||"",i||s||"text",o||"");N!==S.getModel()&&S.setModel(N)}},[o],x),rt(()=>{if(D.current&&B.current){let S=D.current.getModifiedEditor(),N=js(B.current,t||"",n||s||"text",a||"");N!==S.getModel()&&S.setModel(N)}},[a],x),rt(()=>{let S=D.current.getModifiedEditor();S.getOption(B.current.editor.EditorOption.readOnly)?S.setValue(t||""):t!==S.getValue()&&(S.executeEdits("",[{range:S.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),S.pushUndoStop())},[t],x),rt(()=>{var S,N;(N=(S=D.current)==null?void 0:S.getModel())==null||N.original.setValue(e||"")},[e],x),rt(()=>{let{original:S,modified:N}=D.current.getModel();B.current.editor.setModelLanguage(S,i||s||"text"),B.current.editor.setModelLanguage(N,n||s||"text")},[s,i,n],x),rt(()=>{var S;(S=B.current)==null||S.editor.setTheme(c)},[c],x),rt(()=>{var S;(S=D.current)==null||S.updateOptions(m)},[m],x);let R=d.useCallback(()=>{var k;if(!B.current)return;K.current(B.current);let S=js(B.current,e||"",i||s||"text",o||""),N=js(B.current,t||"",n||s||"text",a||"");(k=D.current)==null||k.setModel({original:S,modified:N})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!A.current&&U.current&&(D.current=B.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...m}),R(),(S=B.current)==null||S.editor.setTheme(c),C(!0),A.current=!0)},[m,c,R]);d.useEffect(()=>{x&&G.current(D.current,B.current)},[x]),d.useEffect(()=>{!j&&!x&&E()},[j,x,E]);function L(){var N,k,P,J;let S=(N=D.current)==null?void 0:N.getModel();l||((k=S==null?void 0:S.original)==null||k.dispose()),h||((P=S==null?void 0:S.modified)==null||P.dispose()),(J=D.current)==null||J.dispose()}return Ds.createElement(gc,{width:_,height:f,isEditorReady:x,loading:u,_ref:U,className:p,wrapperProps:g})}var Ff=If;d.memo(Ff);function Hf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var Wf=Hf,Bi=new Map;function Uf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:u={},saveViewState:m=!0,keepCurrentModel:f=!1,width:_="100%",height:p="100%",className:g,wrapperProps:v={},beforeMount:y=oi,onMount:x=oi,onChange:C,onValidate:j=oi}){let[w,D]=d.useState(!1),[B,U]=d.useState(!0),G=d.useRef(null),K=d.useRef(null),A=d.useRef(null),R=d.useRef(x),E=d.useRef(y),L=d.useRef(),S=d.useRef(i),N=Wf(o),k=d.useRef(!1),P=d.useRef(!1);_c(()=>{let V=pc.init();return V.then(Z=>(G.current=Z)&&U(!1)).catch(Z=>(Z==null?void 0:Z.type)!=="cancelation"&&console.error("Monaco initialization: error:",Z)),()=>K.current?oe():V.cancel()}),rt(()=>{var Z,ie,ue,fe;let V=js(G.current,e||i||"",t||n||"",o||s||"");V!==((Z=K.current)==null?void 0:Z.getModel())&&(m&&Bi.set(N,(ie=K.current)==null?void 0:ie.saveViewState()),(ue=K.current)==null||ue.setModel(V),m&&((fe=K.current)==null||fe.restoreViewState(Bi.get(o))))},[o],w),rt(()=>{var V;(V=K.current)==null||V.updateOptions(c)},[c],w),rt(()=>{!K.current||i===void 0||(K.current.getOption(G.current.editor.EditorOption.readOnly)?K.current.setValue(i):i!==K.current.getValue()&&(P.current=!0,K.current.executeEdits("",[{range:K.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),K.current.pushUndoStop(),P.current=!1))},[i],w),rt(()=>{var Z,ie;let V=(Z=K.current)==null?void 0:Z.getModel();V&&n&&((ie=G.current)==null||ie.editor.setModelLanguage(V,n))},[n],w),rt(()=>{var V;l!==void 0&&((V=K.current)==null||V.revealLine(l))},[l],w),rt(()=>{var V;(V=G.current)==null||V.editor.setTheme(a)},[a],w);let J=d.useCallback(()=>{var V;if(!(!A.current||!G.current)&&!k.current){E.current(G.current);let Z=o||s,ie=js(G.current,i||e||"",t||n||"",Z||"");K.current=(V=G.current)==null?void 0:V.editor.create(A.current,{model:ie,automaticLayout:!0,...c},u),m&&K.current.restoreViewState(Bi.get(Z)),G.current.editor.setTheme(a),l!==void 0&&K.current.revealLine(l),D(!0),k.current=!0}},[e,t,s,i,n,o,c,u,m,a,l]);d.useEffect(()=>{w&&R.current(K.current,G.current)},[w]),d.useEffect(()=>{!B&&!w&&J()},[B,w,J]),S.current=i,d.useEffect(()=>{var V,Z;w&&C&&((V=L.current)==null||V.dispose(),L.current=(Z=K.current)==null?void 0:Z.onDidChangeModelContent(ie=>{P.current||C(K.current.getValue(),ie)}))},[w,C]),d.useEffect(()=>{if(w){let V=G.current.editor.onDidChangeMarkers(Z=>{var ue;let ie=(ue=K.current.getModel())==null?void 0:ue.uri;if(ie&&Z.find(fe=>fe.path===ie.path)){let fe=G.current.editor.getModelMarkers({resource:ie});j==null||j(fe)}});return()=>{V==null||V.dispose()}}return()=>{}},[w,j]);function oe(){var V,Z;(V=L.current)==null||V.dispose(),f?m&&Bi.set(o,K.current.saveViewState()):(Z=K.current.getModel())==null||Z.dispose(),K.current.dispose()}return Ds.createElement(gc,{width:_,height:p,isEditorReady:w,loading:h,_ref:A,className:g,wrapperProps:v})}var Kf=Uf,qf=d.memo(Kf),Vf=qf;function Gf(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function Yf(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function Xf(e){return e/100*window.innerHeight}function Jf(e){return e/100*window.innerWidth}function Zf(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Js({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=Zf(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=Yf(t,n);break}case"em":{i=Gf(t,n);break}case"vh":{i=Xf(n);break}case"vw":{i=Jf(n);break}}return i}function Je(e){return parseFloat(e.toFixed(3))}function Ms({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,n)=>(i+=t==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,i),0)}function cn(e){const{panels:t}=e,s=Ms({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:n,panelConstraints:o}=i;let a=0;if(o.collapsedSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=Je(u/s*100)}let l;if(o.defaultSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=Je(u/s*100)}let h=0;if(o.minSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.minSize});h=Je(u/s*100)}let c=100;if(o.maxSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.maxSize});c=Je(u/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsible:o.collapsible===!0,defaultSize:l,disabled:o.disabled,minSize:h,maxSize:c,panelId:i.id}})}function pe(e,t="Assertion error"){if(!e)throw Error(t)}function hn(e,t){return Array.from(t).sort(e==="horizontal"?Qf:em)}function Qf(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function em(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function vc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function bc(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function tm({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let n,o=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=bc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return pe(n,"No rect found"),n}let Ti;function sm(){return Ti===void 0&&(typeof matchMedia=="function"?Ti=!!matchMedia("(pointer:coarse)").matches:Ti=!1),Ti}function yc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=hn(s,Array.from(t.children).filter(vc).map(p=>({element:p}))).map(({element:p})=>p),a=[];let l=!1,h=!1,c=-1,u=-1,m=0,f,_=[];{let p=-1;for(const g of o)g.hasAttribute("data-panel")&&(p++,g.ariaDisabled===null&&(m++,c===-1&&(c=p),u=p))}if(m>1){let p=-1;for(const g of o)if(g.hasAttribute("data-panel")){p++;const v=i.find(y=>y.element===g);if(v){if(f){const y=f.element.getBoundingClientRect(),x=g.getBoundingClientRect();let C;if(h){const j=s==="horizontal"?new DOMRect(y.right,y.top,0,y.height):new DOMRect(y.left,y.bottom,y.width,0),w=s==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(_.length){case 0:{C=[j,w];break}case 1:{const D=_[0],B=tm({orientation:s,rects:[y,x],targetRect:D.element.getBoundingClientRect()});C=[D,B===y?w:j];break}default:{C=_;break}}}else _.length?C=_:C=[s==="horizontal"?new DOMRect(y.right,x.top,x.left-y.right,x.height):new DOMRect(x.left,y.bottom,x.width,x.top-y.bottom)];for(const j of C){let w="width"in j?j:j.element.getBoundingClientRect();const D=sm()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<D){const U=D-w.width;w=new DOMRect(w.x-U/2,w.y,w.width+U,w.height)}if(w.height<D){const U=D-w.height;w=new DOMRect(w.x,w.y-U/2,w.width,w.height+U)}const B=p<=c||p>u;!l&&!B&&a.push({group:e,groupSize:Ms({group:e}),panels:[f,v],separator:"width"in j?void 0:j,rect:w}),l=!1}}h=!1,f=v,_=[]}}else if(g.hasAttribute("data-separator")){g.ariaDisabled!==null&&(l=!0);const v=n.find(y=>y.element===g);v?_.push(v):(f=void 0,_=[])}else h=!0}return a}var It,Fl;let Sc=(Fl=class{constructor(){ra(this,It,{})}addListener(t,s){const i=Hs(this,It)[t];return i===void 0?Hs(this,It)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Hs(this,It)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let n=!1,o=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){o===null&&(n=!0,o=c)}}if(n)throw o}}removeAllListeners(){na(this,It,{})}removeListener(t,s){const i=Hs(this,It)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},It=new WeakMap,Fl),xt=new Map;const wc=new Sc;function im(e){xt=new Map(xt),xt.delete(e)}function pa(e,t){for(const[s]of xt)if(s.id===e)return s}function qt(e,t){for(const[s,i]of xt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ms(){return xt}function lo(e,t){return wc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function Rt(e,t){const s=xt.get(e);xt=new Map(xt),xt.set(e,t),wc.emit("groupChange",{group:e,prev:s,next:t})}function rm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=bc(s,o.rect);switch(e){case"horizontal":{a.x<=n.x&&(i=o,n=a);break}case"vertical":{a.y<=n.y&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function nm(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function om(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:xa(e),b:xa(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();pe(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:_a(ga(s.a)),b:_a(ga(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=o.length;for(;l--;){const h=o[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const am=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function lm(e){const t=getComputedStyle(Cc(e)??e).display;return t==="flex"||t==="inline-flex"}function cm(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||lm(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||am.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function ga(e){let t=e.length;for(;t--;){const s=e[t];if(pe(s,"Missing node"),cm(s))return s}return null}function _a(e){return e&&Number(getComputedStyle(e).zIndex)||0}function xa(e){const t=[];for(;e;)t.push(e),e=Cc(e);return t}function Cc(e){const{parentNode:t}=e;return nm(t)?t.host:t}function hm(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function dm({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!vc(s)||s.contains(e)||e.contains(s))return!0;if(om(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(hm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function co(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=yc(n),a=rm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&dm({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function um(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function qe(e,t,s=0){return Math.abs(Je(e)-Je(t))<=s}function gt(e,t){return qe(e,t)?0:e>t?1:-1}function Ns({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsible:o,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(gt(i,h)<0)if(o){const c=(n+h)/2;gt(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=Je(i),i}function hi({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(qe(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[u,m]=i;pe(u!=null,"Invalid first pivot index"),pe(m!=null,"Invalid second pivot index");let f=0;switch(o){case"keyboard":{{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:C=0}=v;if(x){const j=l[g];if(pe(j!=null,`Previous layout not found for panel index ${g}`),qe(j,y)){const w=C-j;gt(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const g=e<0?u:m,v=s[g];pe(v,`No panel constraints found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:C=0}=v;if(x){const j=l[g];if(pe(j!=null,`Previous layout not found for panel index ${g}`),qe(j,C)){const w=j-y;gt(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const y=l[g],{collapsible:x,collapsedSize:C,minSize:j}=v;if(x&&gt(y,j)<0)if(e>0){const w=j-C,D=w/2,B=y+e;gt(B,j)<0&&(e=gt(e,D)<=0?0:w)}else{const w=j-C,D=100-w/2,B=y-e;gt(B,j)<0&&(e=gt(100+e,D)>0?0:-w)}break}}{const g=e<0?1:-1;let v=e<0?m:u,y=0;for(;;){const C=l[v];pe(C!=null,`Previous layout not found for panel index ${v}`);const j=Ns({overrideDisabledPanels:a,panelConstraints:s[v],prevSize:C,size:100})-C;if(y+=j,v+=g,v<0||v>=s.length)break}const x=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-x:x}{let g=e<0?u:m;for(;g>=0&&g<s.length;){const v=Math.abs(e)-Math.abs(f),y=l[g];pe(y!=null,`Previous layout not found for panel index ${g}`);const x=y-v,C=Ns({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:y,size:x});if(!qe(y,C)&&(f+=y-C,c[g]=C,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(um(h,c))return n;{const g=e<0?m:u,v=l[g];pe(v!=null,`Previous layout not found for panel index ${g}`);const y=v+f,x=Ns({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:v,size:y});if(c[g]=x,!qe(x,y)){let C=y-x,j=e<0?m:u;for(;j>=0&&j<s.length;){const w=c[j];pe(w!=null,`Previous layout not found for panel index ${j}`);const D=w+C,B=Ns({overrideDisabledPanels:a,panelConstraints:s[j],prevSize:w,size:D});if(qe(w,B)||(C-=B-w,c[j]=B),qe(C,0))break;e>0?j--:j++}}}const _=Object.values(c).reduce((g,v)=>v+g,0);if(!qe(_,100,.1))return n;const p=Object.keys(n);return c.reduce((g,v,y)=>(g[p[y]]=v,g),{})}function ls(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||gt(e[s],t[s])!==0)return!1;return!0}function cs({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],n=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!qe(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=100/n*h;i[l]=c}let o=0;for(let l=0;l<t.length;l++){const h=s[l];pe(h!=null,`No layout data found for index ${l}`);const c=i[l];pe(c!=null,`No layout data found for index ${l}`);const u=Ns({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=u&&(o+=c-u,i[l]=u)}if(!qe(o,0))for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=h+o,u=Ns({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==u&&(o-=u-h,i[l]=u,qe(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function kc({groupId:e,panelId:t}){const s=()=>{const l=ms();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:u,layout:m,groupSize:f,separatorToPanels:_}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:h,groupSize:f,layout:m,separatorToPanels:_};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=o();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:m,groupSize:f,layout:_,separatorToPanels:p}=s(),g=m.panels.findIndex(C=>C.id===t),v=g===m.panels.length-1,y=hi({delta:v?h-l:l-h,initialLayout:_,panelConstraints:u,pivotIndices:v?[g-1,g]:[g,g+1],prevLayout:_,trigger:"imperative-api"}),x=cs({layout:y,panelConstraints:u});ls(_,x)||Rt(m,{defaultLayoutDeferred:c,derivedPanelConstraints:u,groupSize:f,layout:x,separatorToPanels:p})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),u=o();l&&u!==h&&(c.expandToSize=u,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:u}=n(),m=o();if(l&&m===h){let f=u.expandToSize??c;f===0&&(f=1),a(f)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),u=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:u}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&qe(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),u=Ms({group:h}),m=Js({groupSize:u,panelElement:c,styleProp:l}),f=Je(m/u*100);a(f)}}}function va(e){if(e.defaultPrevented)return;const t=ms();co(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(n=>n.panelConstraints.defaultSize!==void 0);if(i){const n=i.panelConstraints.defaultSize,o=kc({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Ui(e){const t=ms();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function jc({groupId:e}){const t=()=>{const s=ms();for(const[i,n]of s)if(i.id===e)return{group:i,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:n,group:o,groupSize:a,layout:l,separatorToPanels:h}=t(),c=cs({layout:s,panelConstraints:n});return i?l:(ls(l,c)||Rt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function Jt(e,t){const s=Ui(e),i=qt(s.id,!0),n=s.separators.find(u=>u.element===e);pe(n,"Matching separator not found");const o=i.separatorToPanels.get(n);pe(o,"Matching panels not found");const a=o.map(u=>s.panels.indexOf(u)),l=jc({groupId:s.id}).getLayout(),h=hi({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=cs({layout:h,panelConstraints:i.derivedPanelConstraints});ls(l,c)||Rt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function ba(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Ui(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&Jt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&Jt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&Jt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&Jt(t,-5);break}case"End":{e.preventDefault(),Jt(t,100);break}case"Enter":{e.preventDefault();const i=Ui(t),n=qt(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(f=>f.element===t);pe(h,"Matching separator not found");const c=l.get(h);pe(c,"Matching panels not found");const u=c[0],m=o.find(f=>f.panelId===u.id);if(pe(m,"Panel metadata not found"),m.collapsible){const f=a[u.id],_=m.collapsedSize===f?i.mutableState.expandedPanelSizes[u.id]??m.minSize:m.collapsedSize;Jt(t,_-f)}break}case"F6":{e.preventDefault();const i=Ui(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);pe(n!==null,"Index not found");const o=e.shiftKey?n>0?n-1:i.length-1:n+1<i.length?n+1:0;i[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Jt(t,-100);break}}}let Rs={cursorFlags:0,state:"inactive"};const ho=new Sc;function hs(){return Rs}function fm(e){return ho.addListener("change",e)}function mm(e){const t=Rs,s={...Rs};s.cursorFlags=e,Rs=s,ho.emit("change",{prev:t,next:s})}function Ps(e){const t=Rs;Rs=e,ho.emit("change",{prev:t,next:e})}function ya(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ms(),s=co(e,t),i=new Map;let n=!1;s.forEach(o=>{o.separator&&(n||(n=!0,o.separator.element.focus({preventScroll:!0})));const a=t.get(o.group);a&&i.set(o.group,a.layout)}),Ps({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const pm=e=>e,Br=()=>{},Nc=1,Ec=2,Dc=4,Rc=8,Sa=3,wa=12;let zi;function Ca(){return zi===void 0&&(zi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(zi=!0)),zi}function gm({cursorFlags:e,groups:t,state:s}){let i=0,n=0;switch(s){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{i++;break}case"vertical":{n++;break}}})}if(!(i===0&&n===0)){switch(s){case"active":{if(e&&Ca()){const o=(e&Nc)!==0,a=(e&Ec)!==0,l=(e&Dc)!==0,h=(e&Rc)!==0;if(o)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return Ca()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const ka=new WeakMap;function uo(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=ka.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=hs();switch(i.state){case"active":case"hover":{const n=gm({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),o=`*, *:hover {cursor: ${n} !important; }`;if(t===o)return;t=o,n?s.cssRules.length===0?s.insertRule(o):s.replaceSync(o):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}ka.set(e,{prevStyle:t,styleSheet:s})}function Pc({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:u,groupSize:m}=c,{orientation:f,panels:_}=u,{disableCursor:p}=u.mutableState;let g=0;o?f==="horizontal"?g=(t.clientX-o.x)/m*100:g=(t.clientY-o.y)/m*100:f==="horizontal"?g=t.clientX<0?-100:100:g=t.clientY<0?-100:100;const v=i.get(u),y=n.get(u);if(!v||!y)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:C,groupSize:j,layout:w,separatorToPanels:D}=y;if(C&&w&&D){const B=hi({delta:g,initialLayout:v,panelConstraints:C,pivotIndices:c.panels.map(U=>_.indexOf(U)),prevLayout:w,trigger:"mouse-or-touch"});if(ls(B,w)){if(g!==0&&!p)switch(f){case"horizontal":{l|=g<0?Nc:Ec;break}case"vertical":{l|=g<0?Dc:Rc;break}}}else Rt(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:C,groupSize:j,layout:B,separatorToPanels:D})}});let h=0;t.movementX===0?h|=a&Sa:h|=l&Sa,t.movementY===0?h|=a&wa:h|=l&wa,mm(h),uo(e)}function ja(e){const t=ms(),s=hs();switch(s.state){case"active":Pc({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function Na(e){if(e.defaultPrevented)return;const t=hs(),s=ms();switch(t.state){case"active":{if(e.buttons===0){Ps({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=qt(i.group.id,!0);Rt(i.group,n)});return}Pc({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=co(e,s);i.length===0?t.state!=="inactive"&&Ps({cursorFlags:0,state:"inactive"}):Ps({cursorFlags:0,hitRegions:i,state:"hover"}),uo(e.currentTarget);break}}}function Ea(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(hs().state){case"hover":Ps({cursorFlags:0,state:"inactive"})}}function Da(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=hs();switch(t.state){case"active":Ps({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(uo(e.currentTarget),t.hitRegions.forEach(s=>{const i=qt(s.group.id,!0);Rt(s.group,i)}),e.preventDefault())}}function Ra(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=Je(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=Je((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function _m(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=Ms({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:Je(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function xm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function vm({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const l=new Map,h=[];for(const m of e.panels){const f=i[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const _=f/100*s,p=Je(_/t*100);l.set(m.id,p),n+=p;break}case"preserve-relative-size":default:{h.push(m.id),o+=f;break}}}if(!a||h.length===0)return i;const c=100-n,u={...i};if(l.forEach((m,f)=>{u[f]=m}),o>0)for(const m of h){const f=i[m]??0;u[m]=Je(f/o*c)}else{const m=Je(c/h.length);for(const f of h)u[f]=m}return u}function bm(e,t){const s=e.map(n=>n.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const n of s)if(!i.includes(n))return!1;return!0}const ys=new Map;function ym(e){let t=!0;pe(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,n=new Set,o=new s(p=>{for(const g of p){const{borderBoxSize:v,target:y}=g;if(y===e.element){if(t){const x=Ms({group:e});if(x===0)return;const C=qt(e.id);if(!C)return;const j=cn(e),w=C.defaultLayoutDeferred?Ra(j):C.layout,D=vm({group:e,nextGroupSize:x,prevGroupSize:C.groupSize,prevLayout:w}),B=cs({layout:D,panelConstraints:j});if(!C.defaultLayoutDeferred&&ls(C.layout,B)&&xm(C.derivedPanelConstraints,j)&&C.groupSize===x)return;Rt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:j,groupSize:x,layout:B,separatorToPanels:C.separatorToPanels})}}else _m(e,y,v)}});o.observe(e.element),e.panels.forEach(p=>{pe(!i.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),i.add(p.id),p.onResize&&o.observe(p.element)});const a=Ms({group:e}),l=cn(e),h=e.panels.map(({id:p})=>p).join(",");let c=e.mutableState.defaultLayout;c&&(bm(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[h]??c??Ra(l),m=cs({layout:u,panelConstraints:l}),f=e.element.ownerDocument;ys.set(f,(ys.get(f)??0)+1);const _=new Map;return yc(e).forEach(p=>{p.separator&&_.set(p.separator,p.panels)}),Rt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:m,separatorToPanels:_}),e.separators.forEach(p=>{pe(!n.has(p.id),`Separator ids must be unique; id "${p.id}" was used more than once`),n.add(p.id),p.element.addEventListener("keydown",ba)}),ys.get(f)===1&&(f.addEventListener("dblclick",va,!0),f.addEventListener("pointerdown",ya,!0),f.addEventListener("pointerleave",ja),f.addEventListener("pointermove",Na),f.addEventListener("pointerout",Ea),f.addEventListener("pointerup",Da,!0)),function(){t=!1,ys.set(f,Math.max(0,(ys.get(f)??0)-1)),im(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",ba)}),ys.get(f)||(f.removeEventListener("dblclick",va,!0),f.removeEventListener("pointerdown",ya,!0),f.removeEventListener("pointerleave",ja),f.removeEventListener("pointermove",Na),f.removeEventListener("pointerout",Ea),f.removeEventListener("pointerup",Da,!0)),o.disconnect()}}function Sm(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function fo(e){const t=d.useId();return`${e??t}`}const ps=typeof window<"u"?d.useLayoutEffect:d.useEffect;function ai(e){const t=d.useRef(e);return ps(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function mo(...e){return ai(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function po(e){const t=d.useRef({...e});return ps(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Mc=d.createContext(null);function wm(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:pm});d.useImperativeHandle(t,()=>s.current,[]),ps(()=>{Object.assign(s.current,jc({groupId:e}))})}function dn({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:f,..._}){const p=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),g=ai(A=>{ls(p.current.onLayoutChange,A)||(p.current.onLayoutChange=A,h==null||h(A))}),v=ai(A=>{ls(p.current.onLayoutChanged,A)||(p.current.onLayoutChanged=A,c==null||c(A))}),y=fo(l),x=d.useRef(null),[C,j]=Sm(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),D=mo(x,o);wm(y,a);const B=ai((A,R)=>{const E=hs(),L=pa(A),S=qt(A);if(S){let N=!1;switch(E.state){case"active":{N=E.hitRegions.some(k=>k.group===L);break}}return{flexGrow:S.layout[R]??1,pointerEvents:N?"none":void 0}}return{flexGrow:(s==null?void 0:s[R])??1}}),U=po({defaultLayout:s,disableCursor:i}),G=d.useMemo(()=>({get disableCursor(){return!!U.disableCursor},getPanelStyles:B,id:y,orientation:u,registerPanel:A=>{const R=w.current;return R.panels=hn(u,[...R.panels,A]),j(),()=>{R.panels=R.panels.filter(E=>E!==A),j()}},registerSeparator:A=>{const R=w.current;return R.separators=hn(u,[...R.separators,A]),j(),()=>{R.separators=R.separators.filter(E=>E!==A),j()}},togglePanelDisabled:(A,R)=>{const E=w.current.panels.find(N=>N.id===A);E&&(E.panelConstraints.disabled=R);const L=pa(y),S=qt(y);L&&S&&Rt(L,{...S,derivedPanelConstraints:cn(L)})},toggleSeparatorDisabled:(A,R)=>{const E=w.current.separators.find(L=>L.id===A);E&&(E.disabled=R)}}),[B,y,j,u,U]),K=d.useRef(null);return ps(()=>{const A=x.current;if(A===null)return;const R=w.current;let E;if(U.defaultLayout!==void 0&&Object.keys(U.defaultLayout).length===R.panels.length){E={};for(const oe of R.panels){const V=U.defaultLayout[oe.id];V!==void 0&&(E[oe.id]=V)}}const L={disabled:!!n,element:A,id:y,mutableState:{defaultLayout:E,disableCursor:!!U.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};K.current=L;const S=ym(L),{defaultLayoutDeferred:N,derivedPanelConstraints:k,layout:P}=qt(L.id,!0);!N&&k.length>0&&(g(P),v(P));const J=lo(y,oe=>{const{defaultLayoutDeferred:V,derivedPanelConstraints:Z,layout:ie}=oe.next;if(V||Z.length===0)return;const ue=L.panels.map(({id:de})=>de).join(",");L.mutableState.layouts[ue]=ie,Z.forEach(de=>{if(de.collapsible){const{layout:_e}=oe.prev??{};if(_e){const He=qe(de.collapsedSize,ie[de.panelId]),z=qe(de.collapsedSize,_e[de.panelId]);He&&!z&&(L.mutableState.expandedPanelSizes[de.panelId]=_e[de.panelId])}}});const fe=hs().state!=="active";g(ie),fe&&v(ie)});return()=>{K.current=null,S(),J()}},[n,y,v,g,u,C,U]),d.useEffect(()=>{const A=K.current;A&&(A.mutableState.defaultLayout=s,A.mutableState.disableCursor=!!i)}),r.jsx(Mc.Provider,{value:G,children:r.jsx("div",{..._,className:t,"data-group":!0,"data-testid":y,id:y,ref:D,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}dn.displayName="Group";function go(){const e=d.useContext(Mc);return pe(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Cm(e,t){const{id:s}=go(),i=d.useRef({collapse:Br,expand:Br,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Br});d.useImperativeHandle(t,()=>i.current,[]),ps(()=>{Object.assign(i.current,kc({groupId:s,panelId:e}))})}function Zs({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:n,disabled:o,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:u="0%",onResize:m,panelRef:f,style:_,...p}){const g=!!h,v=fo(h),y=po({disabled:o}),x=d.useRef(null),C=mo(x,a),{getPanelStyles:j,id:w,orientation:D,registerPanel:B,togglePanelDisabled:U}=go(),G=m!==null,K=ai((R,E,L)=>{m==null||m(R,h,L)});ps(()=>{const R=x.current;if(R!==null){const E={element:R,id:v,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?K:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:u}};return B(E)}},[l,s,i,n,G,v,g,c,u,K,B,y]),d.useEffect(()=>{U(v,!!o)},[o,v,U]),Cm(v,f);const A=d.useSyncExternalStore(R=>lo(w,R),()=>JSON.stringify(j(w,v)),()=>JSON.stringify(j(w,v)));return r.jsx("div",{...p,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":v,id:v,ref:C,style:{...km,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(A)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",..._,touchAction:D==="horizontal"?"pan-y":"pan-x"},children:e})})}Zs.displayName="Panel";const km={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function jm({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let n,o;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,u=[i,i+1];o=cs({layout:hi({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s],n=cs({layout:hi({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function un({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=fo(n),h=po({disabled:s}),[c,u]=d.useState({}),[m,f]=d.useState("inactive"),_=d.useRef(null),p=mo(_,i),{disableCursor:g,id:v,orientation:y,registerSeparator:x,toggleSeparatorDisabled:C}=go(),j=y==="horizontal"?"vertical":"horizontal";ps(()=>{const D=_.current;if(D!==null){const B={disabled:h.disabled,element:D,id:l},U=x(B),G=fm(A=>{f(A.next.state!=="inactive"&&A.next.hitRegions.some(R=>R.separator===B)?A.next.state:"inactive")}),K=lo(v,A=>{const{derivedPanelConstraints:R,layout:E,separatorToPanels:L}=A.next,S=L.get(B);if(S){const N=S[0],k=S.indexOf(N);u(jm({layout:E,panelConstraints:R,panelId:N.id,panelIndex:k}))}});return()=>{G(),K(),U()}}},[v,l,x,h]),d.useEffect(()=>{C(l,!!s)},[s,l,C]);let w;return s&&!g&&(w="not-allowed"),r.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":j,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":m,"data-testid":l,id:l,ref:p,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}un.displayName="Separator";const Nm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Em={sm:"w-7 h-7",md:"w-8 h-8"},Dm={sm:14,md:16};function Tt({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:l}){return r.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Nm[i],Em[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:Dm[s]})})}function Rm({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),l=d.useRef([]);d.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var u,m;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(f=>{var p;const _=(f+1)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"ArrowUp":c.preventDefault(),o(f=>{var p;const _=(f-1+s.length)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"Home":c.preventDefault(),o(0),(u=l.current[0])==null||u.focus();break;case"End":c.preventDefault(),o(s.length-1),(m=l.current[s.length-1])==null||m.focus();break}},[s.length,i]);return r.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,u)=>{const m=c.icon,f=c.variant==="danger";return r.jsxs("button",{ref:_=>{l.current[u]=_},role:"menuitem",tabIndex:n===u?0:-1,onClick:()=>{c.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",f?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[r.jsx(m,{size:14}),c.label]},c.label)})})}/**
172
+ `},ma=df(pf)(dc),gf={config:ff},_f=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(n){return s.reduceRight(function(o,a){return a(o)},n)}};function uc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],uc(e[s],t[s]))}),da(da({},e),t)}var xf={type:"cancelation",msg:"operation is manually canceled"};function Pr(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(xf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var vf=["monaco"],bf=cf.create({config:hf,isInitialized:!1,resolve:null,reject:null,monaco:null}),fc=Uu(bf,2),gi=fc[0],_r=fc[1];function yf(e){var t=gf.config(e),s=t.monaco,i=Hu(t,vf);_r(function(n){return{config:uc(n.config,i),monaco:s}})}function Sf(){var e=gi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(_r({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Pr(Mr);if(window.monaco&&window.monaco.editor)return mc(window.monaco),e.resolve(window.monaco),Pr(Mr);_f(wf,kf)(jf)}return Pr(Mr)}function wf(e){return document.body.appendChild(e)}function Cf(e){var t=document.createElement("script");return e&&(t.src=e),t}function kf(e){var t=gi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Cf("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function jf(){var e=gi(function(s){var i=s.config,n=s.resolve,o=s.reject;return{config:i,resolve:n,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;mc(i),e.resolve(i)},function(s){e.reject(s)})}function mc(e){gi().monaco||_r({monaco:e})}function Nf(){return gi(function(e){var t=e.monaco;return t})}var Mr=new Promise(function(e,t){return _r({resolve:e,reject:t})}),pc={config:yf,init:Sf,__getMonacoInstance:Nf},Ef={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Lr=Ef,Rf={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Df=Rf;function Pf({children:e}){return Ds.createElement("div",{style:Df.container},e)}var Mf=Pf,Lf=Mf;function Bf({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return Ds.createElement("section",{style:{...Lr.wrapper,width:e,height:t},...a},!s&&Ds.createElement(Lf,null,i),Ds.createElement("div",{ref:n,style:{...Lr.fullWidth,...!s&&Lr.hide},className:o}))}var Tf=Bf,gc=d.memo(Tf);function zf(e){d.useEffect(e,[])}var _c=zf;function Af(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var rt=Af;function oi(){}function Ns(e,t,s,i){return Of(e,i)||$f(e,t,s,i)}function Of(e,t){return e.editor.getModel(xc(e,t))}function $f(e,t,s,i){return e.editor.createModel(t,s,i?xc(e,i):void 0)}function xc(e,t){return e.Uri.parse(t)}function If({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:u="Loading...",options:m={},height:f="100%",width:_="100%",className:p,wrapperProps:g={},beforeMount:v=oi,onMount:y=oi}){let[x,C]=d.useState(!1),[j,w]=d.useState(!0),R=d.useRef(null),B=d.useRef(null),U=d.useRef(null),G=d.useRef(y),K=d.useRef(v),A=d.useRef(!1);_c(()=>{let S=pc.init();return S.then(N=>(B.current=N)&&w(!1)).catch(N=>(N==null?void 0:N.type)!=="cancelation"&&console.error("Monaco initialization: error:",N)),()=>R.current?L():S.cancel()}),rt(()=>{if(R.current&&B.current){let S=R.current.getOriginalEditor(),N=Ns(B.current,e||"",i||s||"text",o||"");N!==S.getModel()&&S.setModel(N)}},[o],x),rt(()=>{if(R.current&&B.current){let S=R.current.getModifiedEditor(),N=Ns(B.current,t||"",n||s||"text",a||"");N!==S.getModel()&&S.setModel(N)}},[a],x),rt(()=>{let S=R.current.getModifiedEditor();S.getOption(B.current.editor.EditorOption.readOnly)?S.setValue(t||""):t!==S.getValue()&&(S.executeEdits("",[{range:S.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),S.pushUndoStop())},[t],x),rt(()=>{var S,N;(N=(S=R.current)==null?void 0:S.getModel())==null||N.original.setValue(e||"")},[e],x),rt(()=>{let{original:S,modified:N}=R.current.getModel();B.current.editor.setModelLanguage(S,i||s||"text"),B.current.editor.setModelLanguage(N,n||s||"text")},[s,i,n],x),rt(()=>{var S;(S=B.current)==null||S.editor.setTheme(c)},[c],x),rt(()=>{var S;(S=R.current)==null||S.updateOptions(m)},[m],x);let D=d.useCallback(()=>{var k;if(!B.current)return;K.current(B.current);let S=Ns(B.current,e||"",i||s||"text",o||""),N=Ns(B.current,t||"",n||s||"text",a||"");(k=R.current)==null||k.setModel({original:S,modified:N})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!A.current&&U.current&&(R.current=B.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...m}),D(),(S=B.current)==null||S.editor.setTheme(c),C(!0),A.current=!0)},[m,c,D]);d.useEffect(()=>{x&&G.current(R.current,B.current)},[x]),d.useEffect(()=>{!j&&!x&&E()},[j,x,E]);function L(){var N,k,P,J;let S=(N=R.current)==null?void 0:N.getModel();l||((k=S==null?void 0:S.original)==null||k.dispose()),h||((P=S==null?void 0:S.modified)==null||P.dispose()),(J=R.current)==null||J.dispose()}return Ds.createElement(gc,{width:_,height:f,isEditorReady:x,loading:u,_ref:U,className:p,wrapperProps:g})}var Ff=If;d.memo(Ff);function Hf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var Wf=Hf,Bi=new Map;function Uf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:u={},saveViewState:m=!0,keepCurrentModel:f=!1,width:_="100%",height:p="100%",className:g,wrapperProps:v={},beforeMount:y=oi,onMount:x=oi,onChange:C,onValidate:j=oi}){let[w,R]=d.useState(!1),[B,U]=d.useState(!0),G=d.useRef(null),K=d.useRef(null),A=d.useRef(null),D=d.useRef(x),E=d.useRef(y),L=d.useRef(),S=d.useRef(i),N=Wf(o),k=d.useRef(!1),P=d.useRef(!1);_c(()=>{let V=pc.init();return V.then(Z=>(G.current=Z)&&U(!1)).catch(Z=>(Z==null?void 0:Z.type)!=="cancelation"&&console.error("Monaco initialization: error:",Z)),()=>K.current?oe():V.cancel()}),rt(()=>{var Z,ie,ue,fe;let V=Ns(G.current,e||i||"",t||n||"",o||s||"");V!==((Z=K.current)==null?void 0:Z.getModel())&&(m&&Bi.set(N,(ie=K.current)==null?void 0:ie.saveViewState()),(ue=K.current)==null||ue.setModel(V),m&&((fe=K.current)==null||fe.restoreViewState(Bi.get(o))))},[o],w),rt(()=>{var V;(V=K.current)==null||V.updateOptions(c)},[c],w),rt(()=>{!K.current||i===void 0||(K.current.getOption(G.current.editor.EditorOption.readOnly)?K.current.setValue(i):i!==K.current.getValue()&&(P.current=!0,K.current.executeEdits("",[{range:K.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),K.current.pushUndoStop(),P.current=!1))},[i],w),rt(()=>{var Z,ie;let V=(Z=K.current)==null?void 0:Z.getModel();V&&n&&((ie=G.current)==null||ie.editor.setModelLanguage(V,n))},[n],w),rt(()=>{var V;l!==void 0&&((V=K.current)==null||V.revealLine(l))},[l],w),rt(()=>{var V;(V=G.current)==null||V.editor.setTheme(a)},[a],w);let J=d.useCallback(()=>{var V;if(!(!A.current||!G.current)&&!k.current){E.current(G.current);let Z=o||s,ie=Ns(G.current,i||e||"",t||n||"",Z||"");K.current=(V=G.current)==null?void 0:V.editor.create(A.current,{model:ie,automaticLayout:!0,...c},u),m&&K.current.restoreViewState(Bi.get(Z)),G.current.editor.setTheme(a),l!==void 0&&K.current.revealLine(l),R(!0),k.current=!0}},[e,t,s,i,n,o,c,u,m,a,l]);d.useEffect(()=>{w&&D.current(K.current,G.current)},[w]),d.useEffect(()=>{!B&&!w&&J()},[B,w,J]),S.current=i,d.useEffect(()=>{var V,Z;w&&C&&((V=L.current)==null||V.dispose(),L.current=(Z=K.current)==null?void 0:Z.onDidChangeModelContent(ie=>{P.current||C(K.current.getValue(),ie)}))},[w,C]),d.useEffect(()=>{if(w){let V=G.current.editor.onDidChangeMarkers(Z=>{var ue;let ie=(ue=K.current.getModel())==null?void 0:ue.uri;if(ie&&Z.find(fe=>fe.path===ie.path)){let fe=G.current.editor.getModelMarkers({resource:ie});j==null||j(fe)}});return()=>{V==null||V.dispose()}}return()=>{}},[w,j]);function oe(){var V,Z;(V=L.current)==null||V.dispose(),f?m&&Bi.set(o,K.current.saveViewState()):(Z=K.current.getModel())==null||Z.dispose(),K.current.dispose()}return Ds.createElement(gc,{width:_,height:p,isEditorReady:w,loading:h,_ref:A,className:g,wrapperProps:v})}var Kf=Uf,qf=d.memo(Kf),Vf=qf;function Gf(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function Yf(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function Xf(e){return e/100*window.innerHeight}function Jf(e){return e/100*window.innerWidth}function Zf(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Js({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=Zf(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=Yf(t,n);break}case"em":{i=Gf(t,n);break}case"vh":{i=Xf(n);break}case"vw":{i=Jf(n);break}}return i}function Je(e){return parseFloat(e.toFixed(3))}function Ls({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,n)=>(i+=t==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,i),0)}function cn(e){const{panels:t}=e,s=Ls({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:n,panelConstraints:o}=i;let a=0;if(o.collapsedSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=Je(u/s*100)}let l;if(o.defaultSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=Je(u/s*100)}let h=0;if(o.minSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.minSize});h=Je(u/s*100)}let c=100;if(o.maxSize!==void 0){const u=Js({groupSize:s,panelElement:n,styleProp:o.maxSize});c=Je(u/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsible:o.collapsible===!0,defaultSize:l,disabled:o.disabled,minSize:h,maxSize:c,panelId:i.id}})}function pe(e,t="Assertion error"){if(!e)throw Error(t)}function hn(e,t){return Array.from(t).sort(e==="horizontal"?Qf:em)}function Qf(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function em(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function vc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function bc(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function tm({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let n,o=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=bc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return pe(n,"No rect found"),n}let Ti;function sm(){return Ti===void 0&&(typeof matchMedia=="function"?Ti=!!matchMedia("(pointer:coarse)").matches:Ti=!1),Ti}function yc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=hn(s,Array.from(t.children).filter(vc).map(p=>({element:p}))).map(({element:p})=>p),a=[];let l=!1,h=!1,c=-1,u=-1,m=0,f,_=[];{let p=-1;for(const g of o)g.hasAttribute("data-panel")&&(p++,g.ariaDisabled===null&&(m++,c===-1&&(c=p),u=p))}if(m>1){let p=-1;for(const g of o)if(g.hasAttribute("data-panel")){p++;const v=i.find(y=>y.element===g);if(v){if(f){const y=f.element.getBoundingClientRect(),x=g.getBoundingClientRect();let C;if(h){const j=s==="horizontal"?new DOMRect(y.right,y.top,0,y.height):new DOMRect(y.left,y.bottom,y.width,0),w=s==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(_.length){case 0:{C=[j,w];break}case 1:{const R=_[0],B=tm({orientation:s,rects:[y,x],targetRect:R.element.getBoundingClientRect()});C=[R,B===y?w:j];break}default:{C=_;break}}}else _.length?C=_:C=[s==="horizontal"?new DOMRect(y.right,x.top,x.left-y.right,x.height):new DOMRect(x.left,y.bottom,x.width,x.top-y.bottom)];for(const j of C){let w="width"in j?j:j.element.getBoundingClientRect();const R=sm()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<R){const U=R-w.width;w=new DOMRect(w.x-U/2,w.y,w.width+U,w.height)}if(w.height<R){const U=R-w.height;w=new DOMRect(w.x,w.y-U/2,w.width,w.height+U)}const B=p<=c||p>u;!l&&!B&&a.push({group:e,groupSize:Ls({group:e}),panels:[f,v],separator:"width"in j?void 0:j,rect:w}),l=!1}}h=!1,f=v,_=[]}}else if(g.hasAttribute("data-separator")){g.ariaDisabled!==null&&(l=!0);const v=n.find(y=>y.element===g);v?_.push(v):(f=void 0,_=[])}else h=!0}return a}var It,Fl;let Sc=(Fl=class{constructor(){ra(this,It,{})}addListener(t,s){const i=Hs(this,It)[t];return i===void 0?Hs(this,It)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Hs(this,It)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let n=!1,o=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){o===null&&(n=!0,o=c)}}if(n)throw o}}removeAllListeners(){na(this,It,{})}removeListener(t,s){const i=Hs(this,It)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},It=new WeakMap,Fl),xt=new Map;const wc=new Sc;function im(e){xt=new Map(xt),xt.delete(e)}function pa(e,t){for(const[s]of xt)if(s.id===e)return s}function qt(e,t){for(const[s,i]of xt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ps(){return xt}function lo(e,t){return wc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function Dt(e,t){const s=xt.get(e);xt=new Map(xt),xt.set(e,t),wc.emit("groupChange",{group:e,prev:s,next:t})}function rm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=bc(s,o.rect);switch(e){case"horizontal":{a.x<=n.x&&(i=o,n=a);break}case"vertical":{a.y<=n.y&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function nm(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function om(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:xa(e),b:xa(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();pe(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:_a(ga(s.a)),b:_a(ga(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=o.length;for(;l--;){const h=o[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const am=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function lm(e){const t=getComputedStyle(Cc(e)??e).display;return t==="flex"||t==="inline-flex"}function cm(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||lm(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||am.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function ga(e){let t=e.length;for(;t--;){const s=e[t];if(pe(s,"Missing node"),cm(s))return s}return null}function _a(e){return e&&Number(getComputedStyle(e).zIndex)||0}function xa(e){const t=[];for(;e;)t.push(e),e=Cc(e);return t}function Cc(e){const{parentNode:t}=e;return nm(t)?t.host:t}function hm(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function dm({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!vc(s)||s.contains(e)||e.contains(s))return!0;if(om(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(hm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function co(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=yc(n),a=rm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&dm({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function um(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function qe(e,t,s=0){return Math.abs(Je(e)-Je(t))<=s}function gt(e,t){return qe(e,t)?0:e>t?1:-1}function Es({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsible:o,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(gt(i,h)<0)if(o){const c=(n+h)/2;gt(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=Je(i),i}function hi({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(qe(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[u,m]=i;pe(u!=null,"Invalid first pivot index"),pe(m!=null,"Invalid second pivot index");let f=0;switch(o){case"keyboard":{{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:C=0}=v;if(x){const j=l[g];if(pe(j!=null,`Previous layout not found for panel index ${g}`),qe(j,y)){const w=C-j;gt(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const g=e<0?u:m,v=s[g];pe(v,`No panel constraints found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:C=0}=v;if(x){const j=l[g];if(pe(j!=null,`Previous layout not found for panel index ${g}`),qe(j,C)){const w=j-y;gt(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const y=l[g],{collapsible:x,collapsedSize:C,minSize:j}=v;if(x&&gt(y,j)<0)if(e>0){const w=j-C,R=w/2,B=y+e;gt(B,j)<0&&(e=gt(e,R)<=0?0:w)}else{const w=j-C,R=100-w/2,B=y-e;gt(B,j)<0&&(e=gt(100+e,R)>0?0:-w)}break}}{const g=e<0?1:-1;let v=e<0?m:u,y=0;for(;;){const C=l[v];pe(C!=null,`Previous layout not found for panel index ${v}`);const j=Es({overrideDisabledPanels:a,panelConstraints:s[v],prevSize:C,size:100})-C;if(y+=j,v+=g,v<0||v>=s.length)break}const x=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-x:x}{let g=e<0?u:m;for(;g>=0&&g<s.length;){const v=Math.abs(e)-Math.abs(f),y=l[g];pe(y!=null,`Previous layout not found for panel index ${g}`);const x=y-v,C=Es({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:y,size:x});if(!qe(y,C)&&(f+=y-C,c[g]=C,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(um(h,c))return n;{const g=e<0?m:u,v=l[g];pe(v!=null,`Previous layout not found for panel index ${g}`);const y=v+f,x=Es({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:v,size:y});if(c[g]=x,!qe(x,y)){let C=y-x,j=e<0?m:u;for(;j>=0&&j<s.length;){const w=c[j];pe(w!=null,`Previous layout not found for panel index ${j}`);const R=w+C,B=Es({overrideDisabledPanels:a,panelConstraints:s[j],prevSize:w,size:R});if(qe(w,B)||(C-=B-w,c[j]=B),qe(C,0))break;e>0?j--:j++}}}const _=Object.values(c).reduce((g,v)=>v+g,0);if(!qe(_,100,.1))return n;const p=Object.keys(n);return c.reduce((g,v,y)=>(g[p[y]]=v,g),{})}function ls(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||gt(e[s],t[s])!==0)return!1;return!0}function cs({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],n=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!qe(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=100/n*h;i[l]=c}let o=0;for(let l=0;l<t.length;l++){const h=s[l];pe(h!=null,`No layout data found for index ${l}`);const c=i[l];pe(c!=null,`No layout data found for index ${l}`);const u=Es({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=u&&(o+=c-u,i[l]=u)}if(!qe(o,0))for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=h+o,u=Es({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==u&&(o-=u-h,i[l]=u,qe(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function kc({groupId:e,panelId:t}){const s=()=>{const l=ps();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:u,layout:m,groupSize:f,separatorToPanels:_}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:h,groupSize:f,layout:m,separatorToPanels:_};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=o();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:m,groupSize:f,layout:_,separatorToPanels:p}=s(),g=m.panels.findIndex(C=>C.id===t),v=g===m.panels.length-1,y=hi({delta:v?h-l:l-h,initialLayout:_,panelConstraints:u,pivotIndices:v?[g-1,g]:[g,g+1],prevLayout:_,trigger:"imperative-api"}),x=cs({layout:y,panelConstraints:u});ls(_,x)||Dt(m,{defaultLayoutDeferred:c,derivedPanelConstraints:u,groupSize:f,layout:x,separatorToPanels:p})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),u=o();l&&u!==h&&(c.expandToSize=u,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:u}=n(),m=o();if(l&&m===h){let f=u.expandToSize??c;f===0&&(f=1),a(f)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),u=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:u}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&qe(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),u=Ls({group:h}),m=Js({groupSize:u,panelElement:c,styleProp:l}),f=Je(m/u*100);a(f)}}}function va(e){if(e.defaultPrevented)return;const t=ps();co(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(n=>n.panelConstraints.defaultSize!==void 0);if(i){const n=i.panelConstraints.defaultSize,o=kc({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Ui(e){const t=ps();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function jc({groupId:e}){const t=()=>{const s=ps();for(const[i,n]of s)if(i.id===e)return{group:i,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:n,group:o,groupSize:a,layout:l,separatorToPanels:h}=t(),c=cs({layout:s,panelConstraints:n});return i?l:(ls(l,c)||Dt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function Jt(e,t){const s=Ui(e),i=qt(s.id,!0),n=s.separators.find(u=>u.element===e);pe(n,"Matching separator not found");const o=i.separatorToPanels.get(n);pe(o,"Matching panels not found");const a=o.map(u=>s.panels.indexOf(u)),l=jc({groupId:s.id}).getLayout(),h=hi({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=cs({layout:h,panelConstraints:i.derivedPanelConstraints});ls(l,c)||Dt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function ba(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Ui(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&Jt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&Jt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&Jt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&Jt(t,-5);break}case"End":{e.preventDefault(),Jt(t,100);break}case"Enter":{e.preventDefault();const i=Ui(t),n=qt(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(f=>f.element===t);pe(h,"Matching separator not found");const c=l.get(h);pe(c,"Matching panels not found");const u=c[0],m=o.find(f=>f.panelId===u.id);if(pe(m,"Panel metadata not found"),m.collapsible){const f=a[u.id],_=m.collapsedSize===f?i.mutableState.expandedPanelSizes[u.id]??m.minSize:m.collapsedSize;Jt(t,_-f)}break}case"F6":{e.preventDefault();const i=Ui(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);pe(n!==null,"Index not found");const o=e.shiftKey?n>0?n-1:i.length-1:n+1<i.length?n+1:0;i[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Jt(t,-100);break}}}let Ps={cursorFlags:0,state:"inactive"};const ho=new Sc;function hs(){return Ps}function fm(e){return ho.addListener("change",e)}function mm(e){const t=Ps,s={...Ps};s.cursorFlags=e,Ps=s,ho.emit("change",{prev:t,next:s})}function Ms(e){const t=Ps;Ps=e,ho.emit("change",{prev:t,next:e})}function ya(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ps(),s=co(e,t),i=new Map;let n=!1;s.forEach(o=>{o.separator&&(n||(n=!0,o.separator.element.focus({preventScroll:!0})));const a=t.get(o.group);a&&i.set(o.group,a.layout)}),Ms({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const pm=e=>e,Br=()=>{},Nc=1,Ec=2,Rc=4,Dc=8,Sa=3,wa=12;let zi;function Ca(){return zi===void 0&&(zi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(zi=!0)),zi}function gm({cursorFlags:e,groups:t,state:s}){let i=0,n=0;switch(s){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{i++;break}case"vertical":{n++;break}}})}if(!(i===0&&n===0)){switch(s){case"active":{if(e&&Ca()){const o=(e&Nc)!==0,a=(e&Ec)!==0,l=(e&Rc)!==0,h=(e&Dc)!==0;if(o)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return Ca()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const ka=new WeakMap;function uo(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=ka.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=hs();switch(i.state){case"active":case"hover":{const n=gm({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),o=`*, *:hover {cursor: ${n} !important; }`;if(t===o)return;t=o,n?s.cssRules.length===0?s.insertRule(o):s.replaceSync(o):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}ka.set(e,{prevStyle:t,styleSheet:s})}function Pc({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:u,groupSize:m}=c,{orientation:f,panels:_}=u,{disableCursor:p}=u.mutableState;let g=0;o?f==="horizontal"?g=(t.clientX-o.x)/m*100:g=(t.clientY-o.y)/m*100:f==="horizontal"?g=t.clientX<0?-100:100:g=t.clientY<0?-100:100;const v=i.get(u),y=n.get(u);if(!v||!y)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:C,groupSize:j,layout:w,separatorToPanels:R}=y;if(C&&w&&R){const B=hi({delta:g,initialLayout:v,panelConstraints:C,pivotIndices:c.panels.map(U=>_.indexOf(U)),prevLayout:w,trigger:"mouse-or-touch"});if(ls(B,w)){if(g!==0&&!p)switch(f){case"horizontal":{l|=g<0?Nc:Ec;break}case"vertical":{l|=g<0?Rc:Dc;break}}}else Dt(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:C,groupSize:j,layout:B,separatorToPanels:R})}});let h=0;t.movementX===0?h|=a&Sa:h|=l&Sa,t.movementY===0?h|=a&wa:h|=l&wa,mm(h),uo(e)}function ja(e){const t=ps(),s=hs();switch(s.state){case"active":Pc({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function Na(e){if(e.defaultPrevented)return;const t=hs(),s=ps();switch(t.state){case"active":{if(e.buttons===0){Ms({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=qt(i.group.id,!0);Dt(i.group,n)});return}Pc({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=co(e,s);i.length===0?t.state!=="inactive"&&Ms({cursorFlags:0,state:"inactive"}):Ms({cursorFlags:0,hitRegions:i,state:"hover"}),uo(e.currentTarget);break}}}function Ea(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(hs().state){case"hover":Ms({cursorFlags:0,state:"inactive"})}}function Ra(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=hs();switch(t.state){case"active":Ms({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(uo(e.currentTarget),t.hitRegions.forEach(s=>{const i=qt(s.group.id,!0);Dt(s.group,i)}),e.preventDefault())}}function Da(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=Je(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=Je((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function _m(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=Ls({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:Je(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function xm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function vm({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const l=new Map,h=[];for(const m of e.panels){const f=i[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const _=f/100*s,p=Je(_/t*100);l.set(m.id,p),n+=p;break}case"preserve-relative-size":default:{h.push(m.id),o+=f;break}}}if(!a||h.length===0)return i;const c=100-n,u={...i};if(l.forEach((m,f)=>{u[f]=m}),o>0)for(const m of h){const f=i[m]??0;u[m]=Je(f/o*c)}else{const m=Je(c/h.length);for(const f of h)u[f]=m}return u}function bm(e,t){const s=e.map(n=>n.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const n of s)if(!i.includes(n))return!1;return!0}const Ss=new Map;function ym(e){let t=!0;pe(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,n=new Set,o=new s(p=>{for(const g of p){const{borderBoxSize:v,target:y}=g;if(y===e.element){if(t){const x=Ls({group:e});if(x===0)return;const C=qt(e.id);if(!C)return;const j=cn(e),w=C.defaultLayoutDeferred?Da(j):C.layout,R=vm({group:e,nextGroupSize:x,prevGroupSize:C.groupSize,prevLayout:w}),B=cs({layout:R,panelConstraints:j});if(!C.defaultLayoutDeferred&&ls(C.layout,B)&&xm(C.derivedPanelConstraints,j)&&C.groupSize===x)return;Dt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:j,groupSize:x,layout:B,separatorToPanels:C.separatorToPanels})}}else _m(e,y,v)}});o.observe(e.element),e.panels.forEach(p=>{pe(!i.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),i.add(p.id),p.onResize&&o.observe(p.element)});const a=Ls({group:e}),l=cn(e),h=e.panels.map(({id:p})=>p).join(",");let c=e.mutableState.defaultLayout;c&&(bm(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[h]??c??Da(l),m=cs({layout:u,panelConstraints:l}),f=e.element.ownerDocument;Ss.set(f,(Ss.get(f)??0)+1);const _=new Map;return yc(e).forEach(p=>{p.separator&&_.set(p.separator,p.panels)}),Dt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:m,separatorToPanels:_}),e.separators.forEach(p=>{pe(!n.has(p.id),`Separator ids must be unique; id "${p.id}" was used more than once`),n.add(p.id),p.element.addEventListener("keydown",ba)}),Ss.get(f)===1&&(f.addEventListener("dblclick",va,!0),f.addEventListener("pointerdown",ya,!0),f.addEventListener("pointerleave",ja),f.addEventListener("pointermove",Na),f.addEventListener("pointerout",Ea),f.addEventListener("pointerup",Ra,!0)),function(){t=!1,Ss.set(f,Math.max(0,(Ss.get(f)??0)-1)),im(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",ba)}),Ss.get(f)||(f.removeEventListener("dblclick",va,!0),f.removeEventListener("pointerdown",ya,!0),f.removeEventListener("pointerleave",ja),f.removeEventListener("pointermove",Na),f.removeEventListener("pointerout",Ea),f.removeEventListener("pointerup",Ra,!0)),o.disconnect()}}function Sm(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function fo(e){const t=d.useId();return`${e??t}`}const gs=typeof window<"u"?d.useLayoutEffect:d.useEffect;function ai(e){const t=d.useRef(e);return gs(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function mo(...e){return ai(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function po(e){const t=d.useRef({...e});return gs(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Mc=d.createContext(null);function wm(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:pm});d.useImperativeHandle(t,()=>s.current,[]),gs(()=>{Object.assign(s.current,jc({groupId:e}))})}function dn({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:f,..._}){const p=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),g=ai(A=>{ls(p.current.onLayoutChange,A)||(p.current.onLayoutChange=A,h==null||h(A))}),v=ai(A=>{ls(p.current.onLayoutChanged,A)||(p.current.onLayoutChanged=A,c==null||c(A))}),y=fo(l),x=d.useRef(null),[C,j]=Sm(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),R=mo(x,o);wm(y,a);const B=ai((A,D)=>{const E=hs(),L=pa(A),S=qt(A);if(S){let N=!1;switch(E.state){case"active":{N=E.hitRegions.some(k=>k.group===L);break}}return{flexGrow:S.layout[D]??1,pointerEvents:N?"none":void 0}}return{flexGrow:(s==null?void 0:s[D])??1}}),U=po({defaultLayout:s,disableCursor:i}),G=d.useMemo(()=>({get disableCursor(){return!!U.disableCursor},getPanelStyles:B,id:y,orientation:u,registerPanel:A=>{const D=w.current;return D.panels=hn(u,[...D.panels,A]),j(),()=>{D.panels=D.panels.filter(E=>E!==A),j()}},registerSeparator:A=>{const D=w.current;return D.separators=hn(u,[...D.separators,A]),j(),()=>{D.separators=D.separators.filter(E=>E!==A),j()}},togglePanelDisabled:(A,D)=>{const E=w.current.panels.find(N=>N.id===A);E&&(E.panelConstraints.disabled=D);const L=pa(y),S=qt(y);L&&S&&Dt(L,{...S,derivedPanelConstraints:cn(L)})},toggleSeparatorDisabled:(A,D)=>{const E=w.current.separators.find(L=>L.id===A);E&&(E.disabled=D)}}),[B,y,j,u,U]),K=d.useRef(null);return gs(()=>{const A=x.current;if(A===null)return;const D=w.current;let E;if(U.defaultLayout!==void 0&&Object.keys(U.defaultLayout).length===D.panels.length){E={};for(const oe of D.panels){const V=U.defaultLayout[oe.id];V!==void 0&&(E[oe.id]=V)}}const L={disabled:!!n,element:A,id:y,mutableState:{defaultLayout:E,disableCursor:!!U.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:u,panels:D.panels,resizeTargetMinimumSize:D.resizeTargetMinimumSize,separators:D.separators};K.current=L;const S=ym(L),{defaultLayoutDeferred:N,derivedPanelConstraints:k,layout:P}=qt(L.id,!0);!N&&k.length>0&&(g(P),v(P));const J=lo(y,oe=>{const{defaultLayoutDeferred:V,derivedPanelConstraints:Z,layout:ie}=oe.next;if(V||Z.length===0)return;const ue=L.panels.map(({id:de})=>de).join(",");L.mutableState.layouts[ue]=ie,Z.forEach(de=>{if(de.collapsible){const{layout:_e}=oe.prev??{};if(_e){const He=qe(de.collapsedSize,ie[de.panelId]),z=qe(de.collapsedSize,_e[de.panelId]);He&&!z&&(L.mutableState.expandedPanelSizes[de.panelId]=_e[de.panelId])}}});const fe=hs().state!=="active";g(ie),fe&&v(ie)});return()=>{K.current=null,S(),J()}},[n,y,v,g,u,C,U]),d.useEffect(()=>{const A=K.current;A&&(A.mutableState.defaultLayout=s,A.mutableState.disableCursor=!!i)}),r.jsx(Mc.Provider,{value:G,children:r.jsx("div",{..._,className:t,"data-group":!0,"data-testid":y,id:y,ref:R,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}dn.displayName="Group";function go(){const e=d.useContext(Mc);return pe(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Cm(e,t){const{id:s}=go(),i=d.useRef({collapse:Br,expand:Br,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Br});d.useImperativeHandle(t,()=>i.current,[]),gs(()=>{Object.assign(i.current,kc({groupId:s,panelId:e}))})}function Zs({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:n,disabled:o,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:u="0%",onResize:m,panelRef:f,style:_,...p}){const g=!!h,v=fo(h),y=po({disabled:o}),x=d.useRef(null),C=mo(x,a),{getPanelStyles:j,id:w,orientation:R,registerPanel:B,togglePanelDisabled:U}=go(),G=m!==null,K=ai((D,E,L)=>{m==null||m(D,h,L)});gs(()=>{const D=x.current;if(D!==null){const E={element:D,id:v,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?K:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:u}};return B(E)}},[l,s,i,n,G,v,g,c,u,K,B,y]),d.useEffect(()=>{U(v,!!o)},[o,v,U]),Cm(v,f);const A=d.useSyncExternalStore(D=>lo(w,D),()=>JSON.stringify(j(w,v)),()=>JSON.stringify(j(w,v)));return r.jsx("div",{...p,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":v,id:v,ref:C,style:{...km,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(A)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",..._,touchAction:R==="horizontal"?"pan-y":"pan-x"},children:e})})}Zs.displayName="Panel";const km={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function jm({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let n,o;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,u=[i,i+1];o=cs({layout:hi({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s],n=cs({layout:hi({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function un({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=fo(n),h=po({disabled:s}),[c,u]=d.useState({}),[m,f]=d.useState("inactive"),_=d.useRef(null),p=mo(_,i),{disableCursor:g,id:v,orientation:y,registerSeparator:x,toggleSeparatorDisabled:C}=go(),j=y==="horizontal"?"vertical":"horizontal";gs(()=>{const R=_.current;if(R!==null){const B={disabled:h.disabled,element:R,id:l},U=x(B),G=fm(A=>{f(A.next.state!=="inactive"&&A.next.hitRegions.some(D=>D.separator===B)?A.next.state:"inactive")}),K=lo(v,A=>{const{derivedPanelConstraints:D,layout:E,separatorToPanels:L}=A.next,S=L.get(B);if(S){const N=S[0],k=S.indexOf(N);u(jm({layout:E,panelConstraints:D,panelId:N.id,panelIndex:k}))}});return()=>{G(),K(),U()}}},[v,l,x,h]),d.useEffect(()=>{C(l,!!s)},[s,l,C]);let w;return s&&!g&&(w="not-allowed"),r.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":j,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":m,"data-testid":l,id:l,ref:p,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}un.displayName="Separator";const Nm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Em={sm:"w-7 h-7",md:"w-8 h-8"},Rm={sm:14,md:16};function Tt({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:l}){return r.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Nm[i],Em[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:Rm[s]})})}function Dm({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),l=d.useRef([]);d.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var u,m;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(f=>{var p;const _=(f+1)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"ArrowUp":c.preventDefault(),o(f=>{var p;const _=(f-1+s.length)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"Home":c.preventDefault(),o(0),(u=l.current[0])==null||u.focus();break;case"End":c.preventDefault(),o(s.length-1),(m=l.current[s.length-1])==null||m.focus();break}},[s.length,i]);return r.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,u)=>{const m=c.icon,f=c.variant==="danger";return r.jsxs("button",{ref:_=>{l.current[u]=_},role:"menuitem",tabIndex:n===u?0:-1,onClick:()=>{c.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",f?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[r.jsx(m,{size:14}),c.label]},c.label)})})}/**
173
173
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
174
174
  * @license MIT
175
175
  *
@@ -180,21 +180,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
180
180
  * Fabrice Bellard's javascript vt100 for jslinux:
181
181
  * http://bellard.org/jslinux/
182
182
  * Copyright (c) 2011 Fabrice Bellard
183
- */var Lc=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Mm=(e,t)=>{for(var s in t)Lc(e,s,{get:t[s],enumerable:!0})},we=(e,t,s,i)=>{for(var n=i>1?void 0:i?Pm(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(i?a(t,s,n):a(n))||n);return i&&n&&Lc(t,s,n),n},H=(e,t)=>(s,i)=>t(s,i,e),Pa="Terminal input",fn={get:()=>Pa,set:e=>Pa=e},Ma="Too much output to announce, navigate to rows manually to read",mn={get:()=>Ma,set:e=>Ma=e};function Lm(e){return e.replace(/\r?\n/g,"\r")}function Bm(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Tm(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function zm(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let n=e.clipboardData.getData("text/plain");Bc(n,t,s,i)}}function Bc(e,t,s,i){e=Lm(e),e=Bm(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Tc(e,t,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${n}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function La(e,t,s,i,n){Tc(e,t,s),n&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function $t(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function xr(e,t=0,s=e.length){let i="";for(let n=t;n<s;++n){let o=e[n];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var Am=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=n;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[i++]=(a-55296)*1024+l-56320+65536:(t[i++]=a,t[i++]=l);continue}a!==65279&&(t[i++]=a)}return i}},Om=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)_<<=6,_|=g;let v=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=v-p;for(;c<y;){if(c>=s)return 0;if(g=e[c++],(g&192)!==128){c--,f=!0;break}else this.interim[p++]=g,_<<=6,_|=g&63}f||(v===2?_<128?c--:t[i++]=_:v===3?_<2048||_>=55296&&_<=57343||_===65279||(t[i++]=_):_<65536||_>1114111||(t[i++]=_)),this.interim.fill(0)}let u=s-4,m=c;for(;m<s;){for(;m<u&&!((n=e[m])&128)&&!((o=e[m+1])&128)&&!((a=e[m+2])&128)&&!((l=e[m+3])&128);)t[i++]=n,t[i++]=o,t[i++]=a,t[i++]=l,m+=4;if(n=e[m++],n<128)t[i++]=n;else if((n&224)===192){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(h=(n&31)<<6|o&63,h<128){m--;continue}t[i++]=h}else if((n&240)===224){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(h=(n&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((n&248)===240){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,i;if(l=e[m++],(l&192)!==128){m--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},zc="",Ft=" ",_i=class Ac{constructor(){this.fg=0,this.bg=0,this.extended=new rr}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Ac;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rr=class Oc{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Oc(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},lt=class $c extends _i{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rr,this.combinedData=""}static fromCharData(t){let s=new $c;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?$t(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let n=t[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(i-55296)*1024+n-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ba="di$target",pn="di$dependencies",Tr=new Map;function $m(e){return e[pn]||[]}function Ae(e){if(Tr.has(e))return Tr.get(e);let t=function(s,i,n){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Im(t,s,n)};return t._id=e,Tr.set(e,t),t}function Im(e,t,s){t[Ba]===t?t[pn].push({id:e,index:s}):(t[pn]=[{id:e,index:s}],t[Ba]=t)}var Ve=Ae("BufferService"),Ic=Ae("CoreMouseService"),gs=Ae("CoreService"),Fm=Ae("CharsetService"),_o=Ae("InstantiationService"),Fc=Ae("LogService"),Ge=Ae("OptionsService"),Hc=Ae("OscLinkService"),Hm=Ae("UnicodeService"),xi=Ae("DecorationService"),gn=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],n=this._optionsService.rawOptions.linkHandler,o=new lt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let m=0;m<a;m++)if(!(h===-1&&!s.hasContent(m))){if(s.loadCell(m,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=m,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&m===a-1){let f=(u=this._oscLinkService.getLinkData(l))==null?void 0:u.uri;if(f){let _={start:{x:h+1,y:e},end:{x:m+(!c&&m===a-1?1:0),y:e}},p=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let g=new URL(f);["http:","https:"].includes(g.protocol)||(p=!0)}catch{p=!0}p||i.push({text:f,range:_,activate:(g,v)=>n?n.activate(g,v,_):Wm(g,v),hover:(g,v)=>{var y;return(y=n==null?void 0:n.hover)==null?void 0:y.call(n,g,v,_)},leave:(g,v)=>{var y;return(y=n==null?void 0:n.leave)==null?void 0:y.call(n,g,v,_)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=m,l=o.extended.urlId):(h=-1,l=-1)}}t(i)}};gn=we([H(0,Ve),H(1,Ge),H(2,Hc)],gn);function Wm(e,t){if(confirm(`Do you want to navigate to ${t}?
183
+ */var Lc=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Mm=(e,t)=>{for(var s in t)Lc(e,s,{get:t[s],enumerable:!0})},we=(e,t,s,i)=>{for(var n=i>1?void 0:i?Pm(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(i?a(t,s,n):a(n))||n);return i&&n&&Lc(t,s,n),n},H=(e,t)=>(s,i)=>t(s,i,e),Pa="Terminal input",fn={get:()=>Pa,set:e=>Pa=e},Ma="Too much output to announce, navigate to rows manually to read",mn={get:()=>Ma,set:e=>Ma=e};function Lm(e){return e.replace(/\r?\n/g,"\r")}function Bm(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Tm(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function zm(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let n=e.clipboardData.getData("text/plain");Bc(n,t,s,i)}}function Bc(e,t,s,i){e=Lm(e),e=Bm(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Tc(e,t,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${n}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function La(e,t,s,i,n){Tc(e,t,s),n&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function $t(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function xr(e,t=0,s=e.length){let i="";for(let n=t;n<s;++n){let o=e[n];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var Am=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=n;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[i++]=(a-55296)*1024+l-56320+65536:(t[i++]=a,t[i++]=l);continue}a!==65279&&(t[i++]=a)}return i}},Om=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)_<<=6,_|=g;let v=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=v-p;for(;c<y;){if(c>=s)return 0;if(g=e[c++],(g&192)!==128){c--,f=!0;break}else this.interim[p++]=g,_<<=6,_|=g&63}f||(v===2?_<128?c--:t[i++]=_:v===3?_<2048||_>=55296&&_<=57343||_===65279||(t[i++]=_):_<65536||_>1114111||(t[i++]=_)),this.interim.fill(0)}let u=s-4,m=c;for(;m<s;){for(;m<u&&!((n=e[m])&128)&&!((o=e[m+1])&128)&&!((a=e[m+2])&128)&&!((l=e[m+3])&128);)t[i++]=n,t[i++]=o,t[i++]=a,t[i++]=l,m+=4;if(n=e[m++],n<128)t[i++]=n;else if((n&224)===192){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(h=(n&31)<<6|o&63,h<128){m--;continue}t[i++]=h}else if((n&240)===224){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(h=(n&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((n&248)===240){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,i;if(l=e[m++],(l&192)!==128){m--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},zc="",Ft=" ",_i=class Ac{constructor(){this.fg=0,this.bg=0,this.extended=new rr}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Ac;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rr=class Oc{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Oc(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},lt=class $c extends _i{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rr,this.combinedData=""}static fromCharData(t){let s=new $c;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?$t(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let n=t[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(i-55296)*1024+n-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ba="di$target",pn="di$dependencies",Tr=new Map;function $m(e){return e[pn]||[]}function Ae(e){if(Tr.has(e))return Tr.get(e);let t=function(s,i,n){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Im(t,s,n)};return t._id=e,Tr.set(e,t),t}function Im(e,t,s){t[Ba]===t?t[pn].push({id:e,index:s}):(t[pn]=[{id:e,index:s}],t[Ba]=t)}var Ve=Ae("BufferService"),Ic=Ae("CoreMouseService"),_s=Ae("CoreService"),Fm=Ae("CharsetService"),_o=Ae("InstantiationService"),Fc=Ae("LogService"),Ge=Ae("OptionsService"),Hc=Ae("OscLinkService"),Hm=Ae("UnicodeService"),xi=Ae("DecorationService"),gn=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],n=this._optionsService.rawOptions.linkHandler,o=new lt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let m=0;m<a;m++)if(!(h===-1&&!s.hasContent(m))){if(s.loadCell(m,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=m,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&m===a-1){let f=(u=this._oscLinkService.getLinkData(l))==null?void 0:u.uri;if(f){let _={start:{x:h+1,y:e},end:{x:m+(!c&&m===a-1?1:0),y:e}},p=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let g=new URL(f);["http:","https:"].includes(g.protocol)||(p=!0)}catch{p=!0}p||i.push({text:f,range:_,activate:(g,v)=>n?n.activate(g,v,_):Wm(g,v),hover:(g,v)=>{var y;return(y=n==null?void 0:n.hover)==null?void 0:y.call(n,g,v,_)},leave:(g,v)=>{var y;return(y=n==null?void 0:n.leave)==null?void 0:y.call(n,g,v,_)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=m,l=o.extended.urlId):(h=-1,l=-1)}}t(i)}};gn=we([H(0,Ve),H(1,Ge),H(2,Hc)],gn);function Wm(e,t){if(confirm(`Do you want to navigate to ${t}?
184
184
 
185
185
  WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var vr=Ae("CharSizeService"),Pt=Ae("CoreBrowserService"),xo=Ae("MouseService"),Mt=Ae("RenderService"),Um=Ae("SelectionService"),Wc=Ae("CharacterJoinerService"),Ts=Ae("ThemeService"),Uc=Ae("LinkProviderService"),Km=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ta.isErrorNoTelemetry(e)?new Ta(e.message+`
186
186
 
187
187
  `+e.stack):new Error(e.message+`
188
188
 
189
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},qm=new Km;function Ki(e){Vm(e)||qm.onUnexpectedError(e)}var _n="Canceled";function Vm(e){return e instanceof Gm?!0:e instanceof Error&&e.name===_n&&e.message===_n}var Gm=class extends Error{constructor(){super(_n),this.name=this.message}};function Ym(e){return new Error(`Illegal argument: ${e}`)}var Ta=class xn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof xn)return t;let s=new xn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},vn=class Kc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Kc.prototype)}};function st(e,t=0){return e[e.length-(1+t)]}var Xm;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function n(o){return o===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Xm||(Xm={}));function Jm(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var qc;(e=>{function t(j){return j&&typeof j=="object"&&typeof j[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(j){yield j}e.single=n;function o(j){return t(j)?j:n(j)}e.wrap=o;function a(j){return j||s}e.from=a;function*l(j){for(let w=j.length-1;w>=0;w--)yield j[w]}e.reverse=l;function h(j){return!j||j[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(j){return j[Symbol.iterator]().next().value}e.first=c;function u(j,w){let D=0;for(let B of j)if(w(B,D++))return!0;return!1}e.some=u;function m(j,w){for(let D of j)if(w(D))return D}e.find=m;function*f(j,w){for(let D of j)w(D)&&(yield D)}e.filter=f;function*_(j,w){let D=0;for(let B of j)yield w(B,D++)}e.map=_;function*p(j,w){let D=0;for(let B of j)yield*w(B,D++)}e.flatMap=p;function*g(...j){for(let w of j)yield*w}e.concat=g;function v(j,w,D){let B=D;for(let U of j)B=w(B,U);return B}e.reduce=v;function*y(j,w,D=j.length){for(w<0&&(w+=j.length),D<0?D+=j.length:D>j.length&&(D=j.length);w<D;w++)yield j[w]}e.slice=y;function x(j,w=Number.POSITIVE_INFINITY){let D=[];if(w===0)return[D,j];let B=j[Symbol.iterator]();for(let U=0;U<w;U++){let G=B.next();if(G.done)return[D,e.empty()];D.push(G.value)}return[D,{[Symbol.iterator](){return B}}]}e.consume=x;async function C(j){let w=[];for await(let D of j)w.push(D);return Promise.resolve(w)}e.asyncToArray=C})(qc||(qc={}));function ds(e){if(qc.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Zm(...e){return ve(()=>ds(e))}function ve(e){return{dispose:Jm(()=>{e()})}}var Vc=class Gc{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ds(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Gc.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Vc.DISABLE_DISPOSED_WARNING=!1;var Vt=Vc,ne=class{constructor(){this._store=new Vt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ne.None=Object.freeze({dispose(){}});var Ls=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Et=typeof window=="object"?window:globalThis,bn=class yn{constructor(t){this.element=t,this.next=yn.Undefined,this.prev=yn.Undefined}};bn.Undefined=new bn(void 0);var be=bn,za=class{constructor(){this._first=be.Undefined,this._last=be.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===be.Undefined}clear(){let e=this._first;for(;e!==be.Undefined;){let t=e.next;e.prev=be.Undefined,e.next=be.Undefined,e=t}this._first=be.Undefined,this._last=be.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new be(e);if(this._first===be.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==be.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==be.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==be.Undefined&&e.next!==be.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===be.Undefined&&e.next===be.Undefined?(this._first=be.Undefined,this._last=be.Undefined):e.next===be.Undefined?(this._last=this._last.prev,this._last.next=be.Undefined):e.prev===be.Undefined&&(this._first=this._first.next,this._first.prev=be.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==be.Undefined;)yield e.element,e=e.next}},Qm=globalThis.performance&&typeof globalThis.performance.now=="function",ep=class Yc{static create(t){return new Yc(t)}constructor(t){this._now=Qm&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},$e;(e=>{e.None=()=>ne.None;function t(R,E){return m(R,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(R){return(E,L=null,S)=>{let N=!1,k;return k=R(P=>{if(!N)return k?k.dispose():N=!0,E.call(L,P)},null,S),N&&k.dispose(),k}}e.once=s;function i(R,E,L){return c((S,N=null,k)=>R(P=>S.call(N,E(P)),null,k),L)}e.map=i;function n(R,E,L){return c((S,N=null,k)=>R(P=>{E(P),S.call(N,P)},null,k),L)}e.forEach=n;function o(R,E,L){return c((S,N=null,k)=>R(P=>E(P)&&S.call(N,P),null,k),L)}e.filter=o;function a(R){return R}e.signal=a;function l(...R){return(E,L=null,S)=>{let N=Zm(...R.map(k=>k(P=>E.call(L,P))));return u(N,S)}}e.any=l;function h(R,E,L,S){let N=L;return i(R,k=>(N=E(N,k),N),S)}e.reduce=h;function c(R,E){let L,S={onWillAddFirstListener(){L=R(N.fire,N)},onDidRemoveLastListener(){L==null||L.dispose()}},N=new O(S);return E==null||E.add(N),N.event}function u(R,E){return E instanceof Array?E.push(R):E&&E.add(R),R}function m(R,E,L=100,S=!1,N=!1,k,P){let J,oe,V,Z=0,ie,ue={leakWarningThreshold:k,onWillAddFirstListener(){J=R(de=>{Z++,oe=E(oe,de),S&&!V&&(fe.fire(oe),oe=void 0),ie=()=>{let _e=oe;oe=void 0,V=void 0,(!S||Z>1)&&fe.fire(_e),Z=0},typeof L=="number"?(clearTimeout(V),V=setTimeout(ie,L)):V===void 0&&(V=0,queueMicrotask(ie))})},onWillRemoveListener(){N&&Z>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,J.dispose()}},fe=new O(ue);return P==null||P.add(fe),fe.event}e.debounce=m;function f(R,E=0,L){return e.debounce(R,(S,N)=>S?(S.push(N),S):[N],E,void 0,!0,void 0,L)}e.accumulate=f;function _(R,E=(S,N)=>S===N,L){let S=!0,N;return o(R,k=>{let P=S||!E(k,N);return S=!1,N=k,P},L)}e.latch=_;function p(R,E,L){return[e.filter(R,E,L),e.filter(R,S=>!E(S),L)]}e.split=p;function g(R,E=!1,L=[],S){let N=L.slice(),k=R(oe=>{N?N.push(oe):J.fire(oe)});S&&S.add(k);let P=()=>{N==null||N.forEach(oe=>J.fire(oe)),N=null},J=new O({onWillAddFirstListener(){k||(k=R(oe=>J.fire(oe)),S&&S.add(k))},onDidAddFirstListener(){N&&(E?setTimeout(P):P())},onDidRemoveLastListener(){k&&k.dispose(),k=null}});return S&&S.add(J),J.event}e.buffer=g;function v(R,E){return(L,S,N)=>{let k=E(new x);return R(function(P){let J=k.evaluate(P);J!==y&&L.call(S,J)},void 0,N)}}e.chain=v;let y=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(L=>(E(L),L)),this}filter(E){return this.steps.push(L=>E(L)?L:y),this}reduce(E,L){let S=L;return this.steps.push(N=>(S=E(S,N),S)),this}latch(E=(L,S)=>L===S){let L=!0,S;return this.steps.push(N=>{let k=L||!E(N,S);return L=!1,S=N,k?N:y}),this}evaluate(E){for(let L of this.steps)if(E=L(E),E===y)break;return E}}function C(R,E,L=S=>S){let S=(...J)=>P.fire(L(...J)),N=()=>R.on(E,S),k=()=>R.removeListener(E,S),P=new O({onWillAddFirstListener:N,onDidRemoveLastListener:k});return P.event}e.fromNodeEventEmitter=C;function j(R,E,L=S=>S){let S=(...J)=>P.fire(L(...J)),N=()=>R.addEventListener(E,S),k=()=>R.removeEventListener(E,S),P=new O({onWillAddFirstListener:N,onDidRemoveLastListener:k});return P.event}e.fromDOMEventEmitter=j;function w(R){return new Promise(E=>s(R)(E))}e.toPromise=w;function D(R){let E=new O;return R.then(L=>{E.fire(L)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=D;function B(R,E){return R(L=>E.fire(L))}e.forward=B;function U(R,E,L){return E(L),R(S=>E(S))}e.runAndSubscribe=U;class G{constructor(E,L){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new O(S),L&&L.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,L){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function K(R,E){return new G(R,E).emitter.event}e.fromObservable=K;function A(R){return(E,L,S)=>{let N=0,k=!1,P={beginUpdate(){N++},endUpdate(){N--,N===0&&(R.reportChanges(),k&&(k=!1,E.call(L)))},handlePossibleChange(){},handleChange(){k=!0}};R.addObserver(P),R.reportChanges();let J={dispose(){R.removeObserver(P)}};return S instanceof Vt?S.add(J):Array.isArray(S)&&S.push(J),J}}e.fromObservableLight=A})($e||($e={}));var Sn=class wn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${wn._idPool++}`,wn.all.add(this)}start(t){this._stopWatch=new ep,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Sn.all=new Set,Sn._idPool=0;var tp=Sn,sp=-1,Xc=class Jc{constructor(t,s,i=(Jc._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new np(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,n]of this._stacks)(!t||s<n)&&(t=[i,n],s=n);return t}};Xc._idPool=1;var ip=Xc,rp=class Zc{constructor(t){this.value=t}static create(){let t=new Error;return new Zc(t.stack??"")}print(){console.warn(this.value.split(`
189
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},qm=new Km;function Ki(e){Vm(e)||qm.onUnexpectedError(e)}var _n="Canceled";function Vm(e){return e instanceof Gm?!0:e instanceof Error&&e.name===_n&&e.message===_n}var Gm=class extends Error{constructor(){super(_n),this.name=this.message}};function Ym(e){return new Error(`Illegal argument: ${e}`)}var Ta=class xn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof xn)return t;let s=new xn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},vn=class Kc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Kc.prototype)}};function st(e,t=0){return e[e.length-(1+t)]}var Xm;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function n(o){return o===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Xm||(Xm={}));function Jm(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var qc;(e=>{function t(j){return j&&typeof j=="object"&&typeof j[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(j){yield j}e.single=n;function o(j){return t(j)?j:n(j)}e.wrap=o;function a(j){return j||s}e.from=a;function*l(j){for(let w=j.length-1;w>=0;w--)yield j[w]}e.reverse=l;function h(j){return!j||j[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(j){return j[Symbol.iterator]().next().value}e.first=c;function u(j,w){let R=0;for(let B of j)if(w(B,R++))return!0;return!1}e.some=u;function m(j,w){for(let R of j)if(w(R))return R}e.find=m;function*f(j,w){for(let R of j)w(R)&&(yield R)}e.filter=f;function*_(j,w){let R=0;for(let B of j)yield w(B,R++)}e.map=_;function*p(j,w){let R=0;for(let B of j)yield*w(B,R++)}e.flatMap=p;function*g(...j){for(let w of j)yield*w}e.concat=g;function v(j,w,R){let B=R;for(let U of j)B=w(B,U);return B}e.reduce=v;function*y(j,w,R=j.length){for(w<0&&(w+=j.length),R<0?R+=j.length:R>j.length&&(R=j.length);w<R;w++)yield j[w]}e.slice=y;function x(j,w=Number.POSITIVE_INFINITY){let R=[];if(w===0)return[R,j];let B=j[Symbol.iterator]();for(let U=0;U<w;U++){let G=B.next();if(G.done)return[R,e.empty()];R.push(G.value)}return[R,{[Symbol.iterator](){return B}}]}e.consume=x;async function C(j){let w=[];for await(let R of j)w.push(R);return Promise.resolve(w)}e.asyncToArray=C})(qc||(qc={}));function ds(e){if(qc.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Zm(...e){return ve(()=>ds(e))}function ve(e){return{dispose:Jm(()=>{e()})}}var Vc=class Gc{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ds(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Gc.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Vc.DISABLE_DISPOSED_WARNING=!1;var Vt=Vc,ne=class{constructor(){this._store=new Vt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ne.None=Object.freeze({dispose(){}});var Bs=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Et=typeof window=="object"?window:globalThis,bn=class yn{constructor(t){this.element=t,this.next=yn.Undefined,this.prev=yn.Undefined}};bn.Undefined=new bn(void 0);var be=bn,za=class{constructor(){this._first=be.Undefined,this._last=be.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===be.Undefined}clear(){let e=this._first;for(;e!==be.Undefined;){let t=e.next;e.prev=be.Undefined,e.next=be.Undefined,e=t}this._first=be.Undefined,this._last=be.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new be(e);if(this._first===be.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==be.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==be.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==be.Undefined&&e.next!==be.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===be.Undefined&&e.next===be.Undefined?(this._first=be.Undefined,this._last=be.Undefined):e.next===be.Undefined?(this._last=this._last.prev,this._last.next=be.Undefined):e.prev===be.Undefined&&(this._first=this._first.next,this._first.prev=be.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==be.Undefined;)yield e.element,e=e.next}},Qm=globalThis.performance&&typeof globalThis.performance.now=="function",ep=class Yc{static create(t){return new Yc(t)}constructor(t){this._now=Qm&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},$e;(e=>{e.None=()=>ne.None;function t(D,E){return m(D,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(D){return(E,L=null,S)=>{let N=!1,k;return k=D(P=>{if(!N)return k?k.dispose():N=!0,E.call(L,P)},null,S),N&&k.dispose(),k}}e.once=s;function i(D,E,L){return c((S,N=null,k)=>D(P=>S.call(N,E(P)),null,k),L)}e.map=i;function n(D,E,L){return c((S,N=null,k)=>D(P=>{E(P),S.call(N,P)},null,k),L)}e.forEach=n;function o(D,E,L){return c((S,N=null,k)=>D(P=>E(P)&&S.call(N,P),null,k),L)}e.filter=o;function a(D){return D}e.signal=a;function l(...D){return(E,L=null,S)=>{let N=Zm(...D.map(k=>k(P=>E.call(L,P))));return u(N,S)}}e.any=l;function h(D,E,L,S){let N=L;return i(D,k=>(N=E(N,k),N),S)}e.reduce=h;function c(D,E){let L,S={onWillAddFirstListener(){L=D(N.fire,N)},onDidRemoveLastListener(){L==null||L.dispose()}},N=new O(S);return E==null||E.add(N),N.event}function u(D,E){return E instanceof Array?E.push(D):E&&E.add(D),D}function m(D,E,L=100,S=!1,N=!1,k,P){let J,oe,V,Z=0,ie,ue={leakWarningThreshold:k,onWillAddFirstListener(){J=D(de=>{Z++,oe=E(oe,de),S&&!V&&(fe.fire(oe),oe=void 0),ie=()=>{let _e=oe;oe=void 0,V=void 0,(!S||Z>1)&&fe.fire(_e),Z=0},typeof L=="number"?(clearTimeout(V),V=setTimeout(ie,L)):V===void 0&&(V=0,queueMicrotask(ie))})},onWillRemoveListener(){N&&Z>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,J.dispose()}},fe=new O(ue);return P==null||P.add(fe),fe.event}e.debounce=m;function f(D,E=0,L){return e.debounce(D,(S,N)=>S?(S.push(N),S):[N],E,void 0,!0,void 0,L)}e.accumulate=f;function _(D,E=(S,N)=>S===N,L){let S=!0,N;return o(D,k=>{let P=S||!E(k,N);return S=!1,N=k,P},L)}e.latch=_;function p(D,E,L){return[e.filter(D,E,L),e.filter(D,S=>!E(S),L)]}e.split=p;function g(D,E=!1,L=[],S){let N=L.slice(),k=D(oe=>{N?N.push(oe):J.fire(oe)});S&&S.add(k);let P=()=>{N==null||N.forEach(oe=>J.fire(oe)),N=null},J=new O({onWillAddFirstListener(){k||(k=D(oe=>J.fire(oe)),S&&S.add(k))},onDidAddFirstListener(){N&&(E?setTimeout(P):P())},onDidRemoveLastListener(){k&&k.dispose(),k=null}});return S&&S.add(J),J.event}e.buffer=g;function v(D,E){return(L,S,N)=>{let k=E(new x);return D(function(P){let J=k.evaluate(P);J!==y&&L.call(S,J)},void 0,N)}}e.chain=v;let y=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(L=>(E(L),L)),this}filter(E){return this.steps.push(L=>E(L)?L:y),this}reduce(E,L){let S=L;return this.steps.push(N=>(S=E(S,N),S)),this}latch(E=(L,S)=>L===S){let L=!0,S;return this.steps.push(N=>{let k=L||!E(N,S);return L=!1,S=N,k?N:y}),this}evaluate(E){for(let L of this.steps)if(E=L(E),E===y)break;return E}}function C(D,E,L=S=>S){let S=(...J)=>P.fire(L(...J)),N=()=>D.on(E,S),k=()=>D.removeListener(E,S),P=new O({onWillAddFirstListener:N,onDidRemoveLastListener:k});return P.event}e.fromNodeEventEmitter=C;function j(D,E,L=S=>S){let S=(...J)=>P.fire(L(...J)),N=()=>D.addEventListener(E,S),k=()=>D.removeEventListener(E,S),P=new O({onWillAddFirstListener:N,onDidRemoveLastListener:k});return P.event}e.fromDOMEventEmitter=j;function w(D){return new Promise(E=>s(D)(E))}e.toPromise=w;function R(D){let E=new O;return D.then(L=>{E.fire(L)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=R;function B(D,E){return D(L=>E.fire(L))}e.forward=B;function U(D,E,L){return E(L),D(S=>E(S))}e.runAndSubscribe=U;class G{constructor(E,L){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new O(S),L&&L.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,L){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function K(D,E){return new G(D,E).emitter.event}e.fromObservable=K;function A(D){return(E,L,S)=>{let N=0,k=!1,P={beginUpdate(){N++},endUpdate(){N--,N===0&&(D.reportChanges(),k&&(k=!1,E.call(L)))},handlePossibleChange(){},handleChange(){k=!0}};D.addObserver(P),D.reportChanges();let J={dispose(){D.removeObserver(P)}};return S instanceof Vt?S.add(J):Array.isArray(S)&&S.push(J),J}}e.fromObservableLight=A})($e||($e={}));var Sn=class wn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${wn._idPool++}`,wn.all.add(this)}start(t){this._stopWatch=new ep,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Sn.all=new Set,Sn._idPool=0;var tp=Sn,sp=-1,Xc=class Jc{constructor(t,s,i=(Jc._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new np(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,n]of this._stacks)(!t||s<n)&&(t=[i,n],s=n);return t}};Xc._idPool=1;var ip=Xc,rp=class Zc{constructor(t){this.value=t}static create(){let t=new Error;return new Zc(t.stack??"")}print(){console.warn(this.value.split(`
190
190
  `).slice(2).join(`
191
- `))}},np=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},op=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},ap=0,zr=class{constructor(e){this.value=e,this.id=ap++}},lp=2,cp,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new ip((t==null?void 0:t.onListenerError)??Ki,((i=this._options)==null?void 0:i.leakWarningThreshold)??sp):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new tp(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,n;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,u,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new op(`${f}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Ki)(p),ne.None}if(this._disposed)return ne.None;s&&(t=t.bind(s));let n=new zr(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=rp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof zr?(this._deliveryQueue??(this._deliveryQueue=new hp),this._listeners=[this._listeners,n]):this._listeners.push(n):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=n,(m=(u=this._options)==null?void 0:u.onDidAddFirstListener)==null||m.call(u,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Vt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*lp<=s.length){let c=0;for(let u=0;u<s.length;u++)s[u]?s[c++]=s[u]:n&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Ki;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,n,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof zr)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},hp=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Cn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Cn.INSTANCE=new Cn;var vo=Cn;function dp(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}vo.INSTANCE.onDidChangeZoomLevel;function up(e){return vo.INSTANCE.getZoomFactor(e)}vo.INSTANCE.onDidChangeFullscreen;var zs=typeof navigator=="object"?navigator.userAgent:"",kn=zs.indexOf("Firefox")>=0,fp=zs.indexOf("AppleWebKit")>=0,bo=zs.indexOf("Chrome")>=0,mp=!bo&&zs.indexOf("Safari")>=0;zs.indexOf("Electron/")>=0;zs.indexOf("Android")>=0;var Ar=!1;if(typeof Et.matchMedia=="function"){let e=Et.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Et.matchMedia("(display-mode: fullscreen)");Ar=e.matches,dp(Et,e,({matches:s})=>{Ar&&t.matches||(Ar=s)})}var Es="en",jn=!1,Nn=!1,qi=!1,Qc=!1,Ai,Vi=Es,Aa=Es,pp,dt,rs=globalThis,Oe,Hl;typeof rs.vscode<"u"&&typeof rs.vscode.process<"u"?Oe=rs.vscode.process:typeof process<"u"&&typeof((Hl=process==null?void 0:process.versions)==null?void 0:Hl.node)=="string"&&(Oe=process);var Wl,gp=typeof((Wl=Oe==null?void 0:Oe.versions)==null?void 0:Wl.electron)=="string",_p=gp&&(Oe==null?void 0:Oe.type)==="renderer",Ul;if(typeof Oe=="object"){jn=Oe.platform==="win32",Nn=Oe.platform==="darwin",qi=Oe.platform==="linux",qi&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ai=Es,Vi=Es;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ai=t.userLocale,Aa=t.osLocale,Vi=t.resolvedLanguage||Es,pp=(Ul=t.languagePack)==null?void 0:Ul.translationsConfigFile}catch{}Qc=!0}else typeof navigator=="object"&&!_p?(dt=navigator.userAgent,jn=dt.indexOf("Windows")>=0,Nn=dt.indexOf("Macintosh")>=0,(dt.indexOf("Macintosh")>=0||dt.indexOf("iPad")>=0||dt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qi=dt.indexOf("Linux")>=0,(dt==null?void 0:dt.indexOf("Mobi"))>=0,Vi=globalThis._VSCODE_NLS_LANGUAGE||Es,Ai=navigator.language.toLowerCase(),Aa=Ai):console.error("Unable to resolve platform.");var eh=jn,yt=Nn,xp=qi,Oa=Qc,St=dt,zt=Vi,vp;(e=>{function t(){return zt}e.value=t;function s(){return zt.length===2?zt==="en":zt.length>=3?zt[0]==="e"&&zt[1]==="n"&&zt[2]==="-":!1}e.isDefaultVariant=s;function i(){return zt==="en"}e.isDefault=i})(vp||(vp={}));var bp=typeof rs.postMessage=="function"&&!rs.importScripts;(()=>{if(bp){let e=[];rs.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,n=e.length;i<n;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),rs.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var yp=!!(St&&St.indexOf("Chrome")>=0);St&&St.indexOf("Firefox")>=0;!yp&&St&&St.indexOf("Safari")>=0;St&&St.indexOf("Edg/")>=0;St&&St.indexOf("Android")>=0;var Ss=typeof navigator=="object"?navigator:{};Oa||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ss&&Ss.clipboard&&Ss.clipboard.writeText,Oa||Ss&&Ss.clipboard&&Ss.clipboard.readText;var yo=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Or=new yo,$a=new yo,Ia=new yo,Sp=new Array(230),th;(e=>{function t(l){return Or.keyCodeToStr(l)}e.toString=t;function s(l){return Or.strToKeyCode(l)}e.fromString=s;function i(l){return $a.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return Ia.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return $a.strToKeyCode(l)||Ia.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Or.keyCodeToStr(l)}e.toElectronAccelerator=a})(th||(th={}));var wp=class sh{constructor(t,s,i,n,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=n,this.keyCode=o}equals(t){return t instanceof sh&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${s}${i}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Cp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Cp=class{constructor(e){if(e.length===0)throw Ym("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function kp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return th.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(kn)switch(t){case 59:return 85;case 60:if(xp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(yt)return 57;break}else if(fp&&(yt&&t===93||!yt&&t===92))return 57;return Sp[t]||0}var jp=yt?256:2048,Np=512,Ep=1024,Dp=yt?2048:256,Fa=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=kp(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=jp),this.altKey&&(t|=Np),this.shiftKey&&(t|=Ep),this.metaKey&&(t|=Dp),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new wp(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ha=new WeakMap;function Rp(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var Pp=class{static getSameOriginWindowChain(e){let t=Ha.get(e);if(!t){t=[],Ha.set(e,t);let s=e,i;do i=Rp(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,n=this.getSameOriginWindowChain(e);for(let o of n){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Oi=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Pp.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Wa=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(bo){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?kn&&!yt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")mp&&eh?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?kn&&!yt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},ih=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Mp;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Lp?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ih})})(Mp||(Mp={}));var Lp=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?ih:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},So=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new vn("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new vn("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Bp=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new vn("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ve(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Tp;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{n||(n=l)})));if(typeof n<"u")throw n;return o}e.settled=t;function s(i){return new Promise(async(n,o)=>{try{await i(n,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Tp||(Tp={}));var Ua=class ot{static fromArray(t){return new ot(s=>{s.emitMany(t)})}static fromPromise(t){return new ot(async s=>{s.emitMany(await t)})}static fromPromises(t){return new ot(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new ot(async s=>{await Promise.all(t.map(async i=>{for await(let n of i)s.emitOne(n)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(i)),this.resolve()}catch(n){this.reject(n)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new ot(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return ot.map(this,t)}static filter(t,s){return new ot(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return ot.filter(this,t)}static coalesce(t){return ot.filter(t,s=>!!s)}coalesce(){return ot.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return ot.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Ua.EMPTY=Ua.fromArray([]);var{getWindow:vt,getWindowId:zp,onDidRegisterWindow:Ap}=(function(){let e=new Map,t={window:Et,disposables:new Vt};e.set(Et.vscodeWindowId,t);let s=new O,i=new O,n=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ne.None;let l=new Vt,h={window:a,disposables:l.add(new Vt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(X(a,Me.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:Et},getDocument(a){return vt(a).document}}})(),Op=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function X(e,t,s,i){return new Op(e,t,s,i)}var Ka=function(e,t,s,i){return X(e,t,s,i)},wo,$p=class extends Bp{constructor(e){super(),this.defaultTarget=e&&vt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},qa=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ki(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,n=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(qa.sort),a.shift().execute();i.set(o,!1)};wo=(o,a,l=0)=>{let h=zp(o),c=new qa(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function Ip(e){let t=e.getBoundingClientRect(),s=vt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Me={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Fp=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Xe(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Xe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Xe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Xe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Xe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Xe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Xe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Xe(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Xe(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Xe(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Xe(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Xe(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Xe(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Xe(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Xe(e){return typeof e=="number"?`${e}px`:e}function li(e){return new Fp(e)}var rh=class{constructor(){this._hooks=new Vt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=vt(e)}this._hooks.add(X(o,Me.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(X(o,Me.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Hp(e,t,s){let i=null,n=null;if(typeof s.value=="function"?(i="value",n=s.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",n=s.get),!n)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,a)}),this[o]}}var pt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(pt||(pt={}));var Qs=class Fe extends ne{constructor(){super(),this.dispatched=!1,this.targets=new za,this.ignoreTargets=new za,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Ap,({window:t,disposables:s})=>{s.add(X(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(X(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(X(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Et,disposables:this._store}))}static addTarget(t){if(!Fe.isTouchDevice())return ne.None;Fe.INSTANCE||(Fe.INSTANCE=new Fe);let s=Fe.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!Fe.isTouchDevice())return ne.None;Fe.INSTANCE||(Fe.INSTANCE=new Fe);let s=Fe.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in Et||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,n=t.targetTouches.length;i<n;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(pt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Fe.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let u=this.newGestureEvent(pt.Tap,h.initialTarget);u.pageX=st(h.rollingPageX),u.pageY=st(h.rollingPageY),this.dispatchEvent(u)}else if(c>=Fe.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let u=this.newGestureEvent(pt.Contextmenu,h.initialTarget);u.pageX=st(h.rollingPageX),u.pageY=st(h.rollingPageY),this.dispatchEvent(u)}else if(n===1){let u=st(h.rollingPageX),m=st(h.rollingPageY),f=st(h.rollingTimestamps)-h.rollingTimestamps[0],_=u-h.rollingPageX[0],p=m-h.rollingPageY[0],g=[...this.targets].filter(v=>h.initialTarget instanceof Node&&v.contains(h.initialTarget));this.inertia(t,g,i,Math.abs(_)/f,_>0?1:-1,u,Math.abs(p)/f,p>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(pt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===pt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Fe.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===pt.Change||t.type===pt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let n=0,o=t.initialTarget;for(;o&&o!==i;)n++,o=o.parentElement;s.push([n,i])}s.sort((i,n)=>i[0]-n[0]);for(let[i,n]of s)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,n,o,a,l,h,c){this.handle=wo(t,()=>{let u=Date.now(),m=u-i,f=0,_=0,p=!0;n+=Fe.SCROLL_FRICTION*m,l+=Fe.SCROLL_FRICTION*m,n>0&&(p=!1,f=o*n*m),l>0&&(p=!1,_=h*l*m);let g=this.newGestureEvent(pt.Change);g.translationX=f,g.translationY=_,s.forEach(v=>v.dispatchEvent(g)),p||this.inertia(t,s,u,n,o,a+f,l,h,c+_)})}onTouchMove(t){let s=Date.now();for(let i=0,n=t.changedTouches.length;i<n;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(pt.Change,a.initialTarget);l.translationX=o.pageX-st(a.rollingPageX),l.translationY=o.pageY-st(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Qs.SCROLL_FRICTION=-.005,Qs.HOLD_DELAY=700,Qs.CLEAR_TAP_COUNT_TIME=400,we([Hp],Qs,"isTouchDevice",1);var Wp=Qs,Co=class extends ne{onclick(e,t){this._register(X(e,Me.CLICK,s=>t(new Oi(vt(e),s))))}onmousedown(e,t){this._register(X(e,Me.MOUSE_DOWN,s=>t(new Oi(vt(e),s))))}onmouseover(e,t){this._register(X(e,Me.MOUSE_OVER,s=>t(new Oi(vt(e),s))))}onmouseleave(e,t){this._register(X(e,Me.MOUSE_LEAVE,s=>t(new Oi(vt(e),s))))}onkeydown(e,t){this._register(X(e,Me.KEY_DOWN,s=>t(new Fa(s))))}onkeyup(e,t){this._register(X(e,Me.KEY_UP,s=>t(new Fa(s))))}oninput(e,t){this._register(X(e,Me.INPUT,t))}onblur(e,t){this._register(X(e,Me.BLUR,t))}onfocus(e,t){this._register(X(e,Me.FOCUS,t))}onchange(e,t){this._register(X(e,Me.CHANGE,t))}ignoreGesture(e){return Wp.ignoreTarget(e)}},Va=11,Up=class extends Co{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Va+"px",this.domNode.style.height=Va+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new rh),this._register(Ka(this.bgDomNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Ka(this.domNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new $p),this._pointerdownScheduleRepeatTimer=this._register(new So)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,vt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Kp=class En{constructor(t,s,i,n,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=n,this.rawScrollTop=l,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new En(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new En(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:n,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},qp=class extends ne{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Kp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Ya(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Ya.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Ga=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function $r(e,t){let s=t-e;return function(i){return e+s*Yp(i)}}function Vp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Ya=class Dn{constructor(t,s,i,n){this.from=t,this.to=s,this.duration=n,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let n,o;return t<s?(n=t+.75*i,o=s-.75*i):(n=t-.75*i,o=s+.75*i),Vp($r(t,n),$r(o,s),.33)}return $r(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),n=this.scrollTop(s);return new Ga(i,n,!1)}return new Ga(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Dn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Dn(t,s,n,i)}};function Gp(e){return Math.pow(e,3)}function Yp(e){return 1-Gp(1-e)}var Xp=class extends ne{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new So)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Jp=140,nh=class extends Co{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Xp(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new rh),this._shouldRender=!0,this.domNode=li(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(X(this.domNode.domNode,Me.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Up(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=li(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(X(this.slider.domNode,Me.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let n=Ip(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(eh&&a>Jp){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},oh=class Rn{constructor(t,s,i,n,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Rn(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,n,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/n))),u=(l-c)/(n-i),m=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let t=Rn._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},Zp=class extends nh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new oh(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,n.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Qp=class extends nh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new oh(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,n.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},eg=500,Xa=50,tg=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Pn=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,n=this._rear;do{let o=n===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[n].score*o,n===this._front)break;n=(this._capacity+n-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(bo){let s=vt(t.browserEvent),i=up(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let n=null,o=new tg(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(n=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,n)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(n,a),m=Math.max(o,l);u%h===0&&m%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Pn.INSTANCE=new Pn;var sg=Pn,ig=class extends Co{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=ng(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let i={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Qp(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Zp(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=li(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=li(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=li(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new So),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ds(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,yt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Wa(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ds(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Wa(s))};this._mouseWheelToDispose.push(X(this._listenOnDomNode,Me.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=sg.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!yt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Xa*o,m=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,m)}if(a){let u=Xa*a,m=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,m)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),eg)}},rg=class extends ig{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ng(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,yt&&(t.className+=" mac"),t}var Mn=class extends ne{constructor(e,t,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new qp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>wo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new rg(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ve(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
191
+ `))}},np=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},op=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},ap=0,zr=class{constructor(e){this.value=e,this.id=ap++}},lp=2,cp,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new ip((t==null?void 0:t.onListenerError)??Ki,((i=this._options)==null?void 0:i.leakWarningThreshold)??sp):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new tp(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,n;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,u,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new op(`${f}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Ki)(p),ne.None}if(this._disposed)return ne.None;s&&(t=t.bind(s));let n=new zr(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=rp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof zr?(this._deliveryQueue??(this._deliveryQueue=new hp),this._listeners=[this._listeners,n]):this._listeners.push(n):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=n,(m=(u=this._options)==null?void 0:u.onDidAddFirstListener)==null||m.call(u,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Vt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*lp<=s.length){let c=0;for(let u=0;u<s.length;u++)s[u]?s[c++]=s[u]:n&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Ki;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,n,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof zr)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},hp=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Cn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Cn.INSTANCE=new Cn;var vo=Cn;function dp(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}vo.INSTANCE.onDidChangeZoomLevel;function up(e){return vo.INSTANCE.getZoomFactor(e)}vo.INSTANCE.onDidChangeFullscreen;var zs=typeof navigator=="object"?navigator.userAgent:"",kn=zs.indexOf("Firefox")>=0,fp=zs.indexOf("AppleWebKit")>=0,bo=zs.indexOf("Chrome")>=0,mp=!bo&&zs.indexOf("Safari")>=0;zs.indexOf("Electron/")>=0;zs.indexOf("Android")>=0;var Ar=!1;if(typeof Et.matchMedia=="function"){let e=Et.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Et.matchMedia("(display-mode: fullscreen)");Ar=e.matches,dp(Et,e,({matches:s})=>{Ar&&t.matches||(Ar=s)})}var Rs="en",jn=!1,Nn=!1,qi=!1,Qc=!1,Ai,Vi=Rs,Aa=Rs,pp,dt,rs=globalThis,Oe,Hl;typeof rs.vscode<"u"&&typeof rs.vscode.process<"u"?Oe=rs.vscode.process:typeof process<"u"&&typeof((Hl=process==null?void 0:process.versions)==null?void 0:Hl.node)=="string"&&(Oe=process);var Wl,gp=typeof((Wl=Oe==null?void 0:Oe.versions)==null?void 0:Wl.electron)=="string",_p=gp&&(Oe==null?void 0:Oe.type)==="renderer",Ul;if(typeof Oe=="object"){jn=Oe.platform==="win32",Nn=Oe.platform==="darwin",qi=Oe.platform==="linux",qi&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ai=Rs,Vi=Rs;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ai=t.userLocale,Aa=t.osLocale,Vi=t.resolvedLanguage||Rs,pp=(Ul=t.languagePack)==null?void 0:Ul.translationsConfigFile}catch{}Qc=!0}else typeof navigator=="object"&&!_p?(dt=navigator.userAgent,jn=dt.indexOf("Windows")>=0,Nn=dt.indexOf("Macintosh")>=0,(dt.indexOf("Macintosh")>=0||dt.indexOf("iPad")>=0||dt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qi=dt.indexOf("Linux")>=0,(dt==null?void 0:dt.indexOf("Mobi"))>=0,Vi=globalThis._VSCODE_NLS_LANGUAGE||Rs,Ai=navigator.language.toLowerCase(),Aa=Ai):console.error("Unable to resolve platform.");var eh=jn,yt=Nn,xp=qi,Oa=Qc,St=dt,zt=Vi,vp;(e=>{function t(){return zt}e.value=t;function s(){return zt.length===2?zt==="en":zt.length>=3?zt[0]==="e"&&zt[1]==="n"&&zt[2]==="-":!1}e.isDefaultVariant=s;function i(){return zt==="en"}e.isDefault=i})(vp||(vp={}));var bp=typeof rs.postMessage=="function"&&!rs.importScripts;(()=>{if(bp){let e=[];rs.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,n=e.length;i<n;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),rs.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var yp=!!(St&&St.indexOf("Chrome")>=0);St&&St.indexOf("Firefox")>=0;!yp&&St&&St.indexOf("Safari")>=0;St&&St.indexOf("Edg/")>=0;St&&St.indexOf("Android")>=0;var ws=typeof navigator=="object"?navigator:{};Oa||document.queryCommandSupported&&document.queryCommandSupported("copy")||ws&&ws.clipboard&&ws.clipboard.writeText,Oa||ws&&ws.clipboard&&ws.clipboard.readText;var yo=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Or=new yo,$a=new yo,Ia=new yo,Sp=new Array(230),th;(e=>{function t(l){return Or.keyCodeToStr(l)}e.toString=t;function s(l){return Or.strToKeyCode(l)}e.fromString=s;function i(l){return $a.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return Ia.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return $a.strToKeyCode(l)||Ia.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Or.keyCodeToStr(l)}e.toElectronAccelerator=a})(th||(th={}));var wp=class sh{constructor(t,s,i,n,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=n,this.keyCode=o}equals(t){return t instanceof sh&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${s}${i}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Cp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Cp=class{constructor(e){if(e.length===0)throw Ym("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function kp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return th.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(kn)switch(t){case 59:return 85;case 60:if(xp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(yt)return 57;break}else if(fp&&(yt&&t===93||!yt&&t===92))return 57;return Sp[t]||0}var jp=yt?256:2048,Np=512,Ep=1024,Rp=yt?2048:256,Fa=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=kp(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=jp),this.altKey&&(t|=Np),this.shiftKey&&(t|=Ep),this.metaKey&&(t|=Rp),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new wp(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ha=new WeakMap;function Dp(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var Pp=class{static getSameOriginWindowChain(e){let t=Ha.get(e);if(!t){t=[],Ha.set(e,t);let s=e,i;do i=Dp(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,n=this.getSameOriginWindowChain(e);for(let o of n){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Oi=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Pp.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Wa=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(bo){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?kn&&!yt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")mp&&eh?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?kn&&!yt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},ih=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Mp;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Lp?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ih})})(Mp||(Mp={}));var Lp=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?ih:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},So=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new vn("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new vn("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Bp=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new vn("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ve(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Tp;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{n||(n=l)})));if(typeof n<"u")throw n;return o}e.settled=t;function s(i){return new Promise(async(n,o)=>{try{await i(n,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Tp||(Tp={}));var Ua=class ot{static fromArray(t){return new ot(s=>{s.emitMany(t)})}static fromPromise(t){return new ot(async s=>{s.emitMany(await t)})}static fromPromises(t){return new ot(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new ot(async s=>{await Promise.all(t.map(async i=>{for await(let n of i)s.emitOne(n)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(i)),this.resolve()}catch(n){this.reject(n)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new ot(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return ot.map(this,t)}static filter(t,s){return new ot(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return ot.filter(this,t)}static coalesce(t){return ot.filter(t,s=>!!s)}coalesce(){return ot.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return ot.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Ua.EMPTY=Ua.fromArray([]);var{getWindow:vt,getWindowId:zp,onDidRegisterWindow:Ap}=(function(){let e=new Map,t={window:Et,disposables:new Vt};e.set(Et.vscodeWindowId,t);let s=new O,i=new O,n=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ne.None;let l=new Vt,h={window:a,disposables:l.add(new Vt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(X(a,Me.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:Et},getDocument(a){return vt(a).document}}})(),Op=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function X(e,t,s,i){return new Op(e,t,s,i)}var Ka=function(e,t,s,i){return X(e,t,s,i)},wo,$p=class extends Bp{constructor(e){super(),this.defaultTarget=e&&vt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},qa=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ki(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,n=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(qa.sort),a.shift().execute();i.set(o,!1)};wo=(o,a,l=0)=>{let h=zp(o),c=new qa(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function Ip(e){let t=e.getBoundingClientRect(),s=vt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Me={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Fp=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Xe(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Xe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Xe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Xe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Xe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Xe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Xe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Xe(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Xe(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Xe(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Xe(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Xe(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Xe(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Xe(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Xe(e){return typeof e=="number"?`${e}px`:e}function li(e){return new Fp(e)}var rh=class{constructor(){this._hooks=new Vt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=vt(e)}this._hooks.add(X(o,Me.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(X(o,Me.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Hp(e,t,s){let i=null,n=null;if(typeof s.value=="function"?(i="value",n=s.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",n=s.get),!n)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,a)}),this[o]}}var pt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(pt||(pt={}));var Qs=class Fe extends ne{constructor(){super(),this.dispatched=!1,this.targets=new za,this.ignoreTargets=new za,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Ap,({window:t,disposables:s})=>{s.add(X(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(X(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(X(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Et,disposables:this._store}))}static addTarget(t){if(!Fe.isTouchDevice())return ne.None;Fe.INSTANCE||(Fe.INSTANCE=new Fe);let s=Fe.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!Fe.isTouchDevice())return ne.None;Fe.INSTANCE||(Fe.INSTANCE=new Fe);let s=Fe.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in Et||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,n=t.targetTouches.length;i<n;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(pt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Fe.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let u=this.newGestureEvent(pt.Tap,h.initialTarget);u.pageX=st(h.rollingPageX),u.pageY=st(h.rollingPageY),this.dispatchEvent(u)}else if(c>=Fe.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let u=this.newGestureEvent(pt.Contextmenu,h.initialTarget);u.pageX=st(h.rollingPageX),u.pageY=st(h.rollingPageY),this.dispatchEvent(u)}else if(n===1){let u=st(h.rollingPageX),m=st(h.rollingPageY),f=st(h.rollingTimestamps)-h.rollingTimestamps[0],_=u-h.rollingPageX[0],p=m-h.rollingPageY[0],g=[...this.targets].filter(v=>h.initialTarget instanceof Node&&v.contains(h.initialTarget));this.inertia(t,g,i,Math.abs(_)/f,_>0?1:-1,u,Math.abs(p)/f,p>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(pt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===pt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Fe.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===pt.Change||t.type===pt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let n=0,o=t.initialTarget;for(;o&&o!==i;)n++,o=o.parentElement;s.push([n,i])}s.sort((i,n)=>i[0]-n[0]);for(let[i,n]of s)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,n,o,a,l,h,c){this.handle=wo(t,()=>{let u=Date.now(),m=u-i,f=0,_=0,p=!0;n+=Fe.SCROLL_FRICTION*m,l+=Fe.SCROLL_FRICTION*m,n>0&&(p=!1,f=o*n*m),l>0&&(p=!1,_=h*l*m);let g=this.newGestureEvent(pt.Change);g.translationX=f,g.translationY=_,s.forEach(v=>v.dispatchEvent(g)),p||this.inertia(t,s,u,n,o,a+f,l,h,c+_)})}onTouchMove(t){let s=Date.now();for(let i=0,n=t.changedTouches.length;i<n;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(pt.Change,a.initialTarget);l.translationX=o.pageX-st(a.rollingPageX),l.translationY=o.pageY-st(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Qs.SCROLL_FRICTION=-.005,Qs.HOLD_DELAY=700,Qs.CLEAR_TAP_COUNT_TIME=400,we([Hp],Qs,"isTouchDevice",1);var Wp=Qs,Co=class extends ne{onclick(e,t){this._register(X(e,Me.CLICK,s=>t(new Oi(vt(e),s))))}onmousedown(e,t){this._register(X(e,Me.MOUSE_DOWN,s=>t(new Oi(vt(e),s))))}onmouseover(e,t){this._register(X(e,Me.MOUSE_OVER,s=>t(new Oi(vt(e),s))))}onmouseleave(e,t){this._register(X(e,Me.MOUSE_LEAVE,s=>t(new Oi(vt(e),s))))}onkeydown(e,t){this._register(X(e,Me.KEY_DOWN,s=>t(new Fa(s))))}onkeyup(e,t){this._register(X(e,Me.KEY_UP,s=>t(new Fa(s))))}oninput(e,t){this._register(X(e,Me.INPUT,t))}onblur(e,t){this._register(X(e,Me.BLUR,t))}onfocus(e,t){this._register(X(e,Me.FOCUS,t))}onchange(e,t){this._register(X(e,Me.CHANGE,t))}ignoreGesture(e){return Wp.ignoreTarget(e)}},Va=11,Up=class extends Co{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Va+"px",this.domNode.style.height=Va+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new rh),this._register(Ka(this.bgDomNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Ka(this.domNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new $p),this._pointerdownScheduleRepeatTimer=this._register(new So)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,vt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Kp=class En{constructor(t,s,i,n,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=n,this.rawScrollTop=l,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new En(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new En(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:n,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},qp=class extends ne{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Kp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Ya(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Ya.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Ga=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function $r(e,t){let s=t-e;return function(i){return e+s*Yp(i)}}function Vp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Ya=class Rn{constructor(t,s,i,n){this.from=t,this.to=s,this.duration=n,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let n,o;return t<s?(n=t+.75*i,o=s-.75*i):(n=t-.75*i,o=s+.75*i),Vp($r(t,n),$r(o,s),.33)}return $r(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),n=this.scrollTop(s);return new Ga(i,n,!1)}return new Ga(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Rn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Rn(t,s,n,i)}};function Gp(e){return Math.pow(e,3)}function Yp(e){return 1-Gp(1-e)}var Xp=class extends ne{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new So)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Jp=140,nh=class extends Co{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Xp(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new rh),this._shouldRender=!0,this.domNode=li(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(X(this.domNode.domNode,Me.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Up(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=li(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(X(this.slider.domNode,Me.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let n=Ip(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(eh&&a>Jp){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},oh=class Dn{constructor(t,s,i,n,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Dn(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,n,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/n))),u=(l-c)/(n-i),m=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let t=Dn._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},Zp=class extends nh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new oh(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,n.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Qp=class extends nh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new oh(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,n.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},eg=500,Xa=50,tg=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Pn=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,n=this._rear;do{let o=n===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[n].score*o,n===this._front)break;n=(this._capacity+n-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(bo){let s=vt(t.browserEvent),i=up(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let n=null,o=new tg(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(n=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,n)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(n,a),m=Math.max(o,l);u%h===0&&m%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Pn.INSTANCE=new Pn;var sg=Pn,ig=class extends Co{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=ng(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let i={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Qp(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Zp(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=li(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=li(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=li(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new So),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ds(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,yt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Wa(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ds(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Wa(s))};this._mouseWheelToDispose.push(X(this._listenOnDomNode,Me.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=sg.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!yt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Xa*o,m=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,m)}if(a){let u=Xa*a,m=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,m)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),eg)}},rg=class extends ig{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ng(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,yt&&(t.className+=" mac"),t}var Mn=class extends ne{constructor(e,t,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new qp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>wo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new rg(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ve(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
192
192
  `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Mn=we([H(2,Ve),H(3,Pt),H(4,Ic),H(5,Ts),H(6,Ge),H(7,Mt)],Mn);var Ln=class extends ne{constructor(e,t,s,i,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,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(this._coreBrowserService.onDprChange(()=>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(o=>this._removeDecoration(o))),this._register(ve(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Ln=we([H(1,Ve),H(2,Pt),H(3,xi),H(4,Mt)],Ln);var og=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(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ft={full:0,left:0,center:0,right:0},At={full:0,left:0,center:0,right:0},Ws={full:0,left:0,center:0,right:0},nr=class extends ne{constructor(e,t,s,i,n,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new og,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(ve(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),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())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);At.full=this._canvas.width,At.left=e,At.center=t,At.right=e,this._refreshDrawHeightConstants(),Ws.full=1,Ws.left=1,Ws.center=1+At.left,Ws.right=1+At.left+At.center}_refreshDrawHeightConstants(){ft.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ft.left=t,ft.center=t,ft.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.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._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.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(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ft[e.position||"full"]/2),At[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ft[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};nr=we([H(2,Ve),H(3,xi),H(4,Mt),H(5,Ge),H(6,Ts),H(7,Pt)],nr);var M;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
193
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(M||(M={}));var Gi;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Gi||(Gi={}));var ah;(e=>e.ST=`${M.ESC}\\`)(ah||(ah={}));var Bn=class{constructor(e,t,s,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${M.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Bn=we([H(2,Ve),H(3,Ge),H(4,gs),H(5,Mt)],Bn);var Le=0,Be=0,Te=0,Se=0,Ja={css:"#00000000",rgba:0},Ne;(e=>{function t(n,o,a,l){return l!==void 0?`#${Zt(n)}${Zt(o)}${Zt(a)}${Zt(l)}`:`#${Zt(n)}${Zt(o)}${Zt(a)}`}e.toCss=t;function s(n,o,a,l=255){return(n<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(n,o,a,l){return{css:e.toCss(n,o,a,l),rgba:e.toRgba(n,o,a,l)}}e.toColor=i})(Ne||(Ne={}));var ge;(e=>{function t(h,c){if(Se=(c.rgba&255)/255,Se===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,m=c.rgba>>16&255,f=c.rgba>>8&255,_=h.rgba>>24&255,p=h.rgba>>16&255,g=h.rgba>>8&255;Le=_+Math.round((u-_)*Se),Be=p+Math.round((m-p)*Se),Te=g+Math.round((f-g)*Se);let v=Ne.toCss(Le,Be,Te),y=Ne.toRgba(Le,Be,Te);return{css:v,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,u){let m=Yi.ensureContrastRatio(h.rgba,c.rgba,u);if(m)return Ne.toColor(m>>24&255,m>>16&255,m>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Le,Be,Te]=Yi.toChannels(c),{css:Ne.toCss(Le,Be,Te),rgba:c}}e.opaque=n;function o(h,c){return Se=Math.round(c*255),[Le,Be,Te]=Yi.toChannels(h.rgba),{css:Ne.toCss(Le,Be,Te,Se),rgba:Ne.toRgba(Le,Be,Te,Se)}}e.opacity=o;function a(h,c){return Se=h.rgba&255,o(h,Se*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(ge||(ge={}));var ye;(e=>{let t,s;try{let n=document.createElement("canvas");n.width=1,n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Ne.toColor(Le,Be,Te);case 5:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Se=parseInt(n.slice(4,5).repeat(2),16),Ne.toColor(Le,Be,Te,Se);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let o=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Le=parseInt(o[1]),Be=parseInt(o[2]),Te=parseInt(o[3]),Se=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ne.toColor(Le,Be,Te,Se);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Le,Be,Te,Se]=t.getImageData(0,0,1,1).data,Se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ne.toRgba(Le,Be,Te,Se),css:n}}e.toColor=i})(ye||(ye={}));var Ke;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,n,o){let a=i/255,l=n/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+m*.0722}e.relativeLuminance2=s})(Ke||(Ke={}));var Yi;(e=>{function t(a,l){if(Se=(l&255)/255,Se===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,m=a>>24&255,f=a>>16&255,_=a>>8&255;return Le=m+Math.round((h-m)*Se),Be=f+Math.round((c-f)*Se),Te=_+Math.round((u-_)*Se),Ne.toRgba(Le,Be,Te)}e.blend=t;function s(a,l,h){let c=Ke.relativeLuminance(a>>8),u=Ke.relativeLuminance(l>>8);if(jt(c,u)<h){if(u<c){let _=i(a,l,h),p=jt(c,Ke.relativeLuminance(_>>8));if(p<h){let g=n(a,l,h),v=jt(c,Ke.relativeLuminance(g>>8));return p>v?_:g}return _}let m=n(a,l,h),f=jt(c,Ke.relativeLuminance(m>>8));if(f<h){let _=i(a,l,h),p=jt(c,Ke.relativeLuminance(_>>8));return f>p?m:_}return m}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));for(;g<h&&(f>0||_>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));for(;g<h&&(f<255||_<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Yi||(Yi={}));function Zt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ag=class extends _i{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},or=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new lt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),n=0,o=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-n>1){let u=this._getJoinedRanges(i,a,o,t,n);for(let m=0;m<u.length;m++)s.push(u[m])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||Ft.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let u=0;u<c.length;u++)s.push(c[u])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)or._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,t,s){let i=0,n=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||Ft.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};or=we([H(0,Ve)],or);function lg(e){return 57508<=e&&e<=57558}function cg(e){return 9472<=e&&e<=9631}function hg(e){return lg(e)||cg(e)}function dg(){return{css:{canvas:$i(),cell:$i()},device:{canvas:$i(),cell:$i(),char:{width:0,height:0,left:0,top:0}}}}function $i(){return{width:0,height:0}}var Tn=class{constructor(e,t,s,i,n,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new lt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,n,o,a,l,h,c,u){let m=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,v=0,y="",x=0,C=0,j=0,w=0,D=!1,B=0,U=!1,G=0,K=0,A=[],R=c!==-1&&u!==-1;for(let E=0;E<p;E++){e.loadCell(E,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let S=!1,N=E>=K,k=E,P=this._workCell;if(f.length>0&&E===f[0][0]&&N){let q=f.shift(),Q=this._isCellInSelection(q[0],t);for(x=q[0]+1;x<q[1];x++)N&&(N=Q===this._isCellInSelection(x,t));N&&(N=!s||o<q[0]||o>=q[1]),N?(S=!0,P=new ag(this._workCell,e.translateToString(!0,q[0],q[1]),q[1]-q[0]),k=q[1]-1,L=P.getWidth()):K=q[1]}let J=this._isCellInSelection(E,t),oe=s&&E===o,V=R&&E>=c&&E<=u,Z=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,q=>{Z=!0});let ie=P.getChars()||Ft;if(ie===" "&&(P.isUnderline()||P.isOverline())&&(ie=" "),G=L*l-h.get(ie,P.isBold(),P.isItalic()),!g)g=this._document.createElement("span");else if(v&&(J&&U||!J&&!U&&P.bg===C)&&(J&&U&&_.selectionForeground||P.fg===j)&&P.extended.ext===w&&V===D&&G===B&&!oe&&!S&&!Z&&N){P.isInvisible()?y+=Ft:y+=ie,v++;continue}else v&&(g.textContent=y),g=this._document.createElement("span"),v=0,y="";if(C=P.bg,j=P.fg,w=P.extended.ext,D=V,B=G,U=J,S&&o>=E&&o<=k&&(o=E),!this._coreService.isCursorHidden&&oe&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(P.isBold()&&A.push("xterm-bold"),P.isItalic()&&A.push("xterm-italic"),P.isDim()&&A.push("xterm-dim"),P.isInvisible()?y=Ft:y=P.getChars()||Ft,P.isUnderline()&&(A.push(`xterm-underline-${P.extended.underlineStyle}`),y===" "&&(y=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${_i.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let q=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&q<8&&(q+=8),g.style.textDecorationColor=_.ansi[q].css}P.isOverline()&&(A.push("xterm-overline"),y===" "&&(y=" ")),P.isStrikethrough()&&A.push("xterm-strikethrough"),V&&(g.style.textDecoration="underline");let ue=P.getFgColor(),fe=P.getFgColorMode(),de=P.getBgColor(),_e=P.getBgColorMode(),He=!!P.isInverse();if(He){let q=ue;ue=de,de=q;let Q=fe;fe=_e,_e=Q}let z,xe,T=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,q=>{q.options.layer!=="top"&&T||(q.backgroundColorRGB&&(_e=50331648,de=q.backgroundColorRGB.rgba>>8&16777215,z=q.backgroundColorRGB),q.foregroundColorRGB&&(fe=50331648,ue=q.foregroundColorRGB.rgba>>8&16777215,xe=q.foregroundColorRGB),T=q.options.layer==="top")}),!T&&J&&(z=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,de=z.rgba>>8&16777215,_e=50331648,T=!0,_.selectionForeground&&(fe=50331648,ue=_.selectionForeground.rgba>>8&16777215,xe=_.selectionForeground)),T&&A.push("xterm-decoration-top");let Y;switch(_e){case 16777216:case 33554432:Y=_.ansi[de],A.push(`xterm-bg-${de}`);break;case 50331648:Y=Ne.toColor(de>>16,de>>8&255,de&255),this._addStyle(g,`background-color:#${Za((de>>>0).toString(16),"0",6)}`);break;case 0:default:He?(Y=_.foreground,A.push("xterm-bg-257")):Y=_.background}switch(z||P.isDim()&&(z=ge.multiplyOpacity(Y,.5)),fe){case 16777216:case 33554432:P.isBold()&&ue<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ue+=8),this._applyMinimumContrast(g,Y,_.ansi[ue],P,z,void 0)||A.push(`xterm-fg-${ue}`);break;case 50331648:let q=Ne.toColor(ue>>16&255,ue>>8&255,ue&255);this._applyMinimumContrast(g,Y,q,P,z,xe)||this._addStyle(g,`color:#${Za(ue.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,Y,_.foreground,P,z,xe)||He&&A.push("xterm-fg-257")}A.length&&(g.className=A.join(" "),A.length=0),!oe&&!S&&!Z&&N?v++:g.textContent=y,G!==this.defaultSpacing&&(g.style.letterSpacing=`${G}px`),m.push(g),E=k}return g&&v&&(g.textContent=y),m}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||hg(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!n&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=ge.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Tn=we([H(1,Wc),H(2,Ge),H(3,Pt),H(4,gs),H(5,xi),H(6,Ts)],Tn);function Za(e,t,s){for(;e.length<s;)e=t+e;return e}var ug=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),t.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(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},fg=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function mg(){return new fg}var Ir="xterm-dom-renderer-owner-",nt="xterm-rows",Ii="xterm-fg-",Qa="xterm-bg-",Us="xterm-focus",Fi="xterm-selection",pg=1,zn=class extends ne{constructor(e,t,s,i,n,o,a,l,h,c,u,m,f,_){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=m,this._coreBrowserService=f,this._themeService=_,this._terminalClass=pg++,this._rowElements=[],this._selectionRenderModel=mg(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(nt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Fi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=dg(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Tn,document),this._element.classList.add(Ir+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(ve(()=>{this._element.classList.remove(Ir+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ug(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),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/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),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(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${nt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,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(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${nt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${nt} .xterm-dim { color: ${ge.multiplyOpacity(e.foreground,.5).css};}`,t+=`${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;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${nt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${nt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${nt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Fi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Fi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Fi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${Ii}${o} { color: ${a.css}; }${this._terminalSelector} .${Ii}${o}.xterm-dim { color: ${ge.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Qa}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${Ii}257 { color: ${ge.opaque(e.background).css}; }${this._terminalSelector} .${Ii}257.xterm-dim { color: ${ge.multiplyOpacity(ge.opaque(e.background),.5).css}; }${this._terminalSelector} .${Qa}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Us),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Us),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=i===o?e[0]:0,c=o===n?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let m=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,m))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}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(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],m=s.lines.get(c);if(!u||!m)break;u.replaceChildren(...this._rowFactory.createRow(m,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ir}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,n,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),u=this._optionsService.rawOptions.cursorBlink,m=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=s;_<=i;++_){let p=_+l.ydisp,g=this._rowElements[_],v=l.lines.get(p);if(!g||!v)break;g.replaceChildren(...this._rowFactory.createRow(v,p,p===h,m,f,c,u,this.dimensions.css.cell.width,this._widthCache,o?_===s?e:0:-1,o?(_===i?t:n)-1:-1))}}};zn=we([H(7,_o),H(8,vr),H(9,Ge),H(10,Ve),H(11,gs),H(12,Pt),H(13,Ts)],zn);var An=class extends ne{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new _g(this._optionsService))}catch{this._measureStrategy=this._register(new gg(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};An=we([H(2,Ge)],An);var lh=class extends ne{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},gg=class extends lh{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},_g=class extends lh{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},xg=class extends ne{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new vg(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(X(this._textarea,"focus",()=>this._isFocused=!0)),this._register(X(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}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}},vg=class extends ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ls),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=X(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},bg=class extends ne{constructor(){super(),this.linkProviders=[],this._register(ve(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ko(e,t,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function yg(e,t,s,i,n,o,a,l,h){if(!o)return;let c=ko(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c}var On=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return yg(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=ko(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};On=we([H(0,Mt),H(1,vr)],On);var Sg=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ch={};Mm(ch,{getSafariVersion:()=>Cg,isChromeOS:()=>fh,isFirefox:()=>hh,isIpad:()=>kg,isIphone:()=>jg,isLegacyEdge:()=>wg,isLinux:()=>jo,isMac:()=>ar,isNode:()=>br,isSafari:()=>dh,isWindows:()=>uh});var br=typeof process<"u"&&"title"in process,vi=br?"node":navigator.userAgent,bi=br?"node":navigator.platform,hh=vi.includes("Firefox"),wg=vi.includes("Edge"),dh=/^((?!chrome|android).)*safari/i.test(vi);function Cg(){if(!dh)return 0;let e=vi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ar=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(bi),kg=bi==="iPad",jg=bi==="iPhone",uh=["Windows","Win16","Win32","WinCE"].includes(bi),jo=bi.indexOf("Linux")>=0,fh=/\bCrOS\b/.test(vi),mh=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),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(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),n=e.timeRemaining(),s*1.5>n){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=n}this.clear()}},Ng=class extends mh{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Eg=class extends mh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},lr=!br&&"requestIdleCallback"in window?Eg:Ng,Dg=class{constructor(){this._queue=new lr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},$n=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new Ls),this._pausedResizeTask=new Dg,this._observerDisposable=this._register(new Ls),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 O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Sg((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Rg(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ve(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.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(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,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(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};$n=we([H(2,Ge),H(3,vr),H(4,gs),H(5,xi),H(6,Ve),H(7,Pt),H(8,Ts)],$n);var Rg=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Pg(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Bg(n,o,e,t,s,i)+yr(o,t,s,i)+Tg(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",ui(Math.abs(n-e),di(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=Lg(o>t?e:n,s)+(l-1)*s.cols+1+Mg(o>t?n:e);return ui(h,di(a,i))}function Mg(e,t){return e-1}function Lg(e,t){return t.cols-e}function Bg(e,t,s,i,n,o){return yr(t,i,n,o).length===0?"":ui(gh(e,t,e,t-us(t,n),!1,n).length,di("D",o))}function yr(e,t,s,i){let n=e-us(e,s),o=t-us(t,s),a=Math.abs(n-o)-zg(e,t,s);return ui(a,di(ph(e,t),i))}function Tg(e,t,s,i,n,o){let a;yr(t,i,n,o).length>0?a=i-us(i,n):a=t;let l=i,h=Ag(e,t,s,i,n,o);return ui(gh(e,a,s,l,h==="C",n).length,di(h,o))}function zg(e,t,s){var a;let i=0,n=e-us(e,s),o=t-us(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=ph(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function us(e,t){let s=0,i=t.buffer.lines.get(e),n=i==null?void 0:i.isWrapped;for(;n&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),n=i==null?void 0:i.isWrapped;return s}function Ag(e,t,s,i,n,o){let a;return yr(s,i,n,o).length>0?a=i-us(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function ph(e,t){return e>t?"A":"B"}function gh(e,t,s,i,n,o){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function di(e,t){let s=t?"O":"[";return M.ESC+s+e}function ui(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var Og=class{constructor(e){this._bufferService=e,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.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()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function el(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Fr=50,$g=15,Ig=50,Fg=500,Hg=" ",Wg=new RegExp(Hg,"g"),In=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new lt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Og(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}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(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);i.push(l)}}else{let n=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(n=>n.replace(Wg," ")).join(uh?`\r
193
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(M||(M={}));var Gi;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Gi||(Gi={}));var ah;(e=>e.ST=`${M.ESC}\\`)(ah||(ah={}));var Bn=class{constructor(e,t,s,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${M.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Bn=we([H(2,Ve),H(3,Ge),H(4,_s),H(5,Mt)],Bn);var Le=0,Be=0,Te=0,Se=0,Ja={css:"#00000000",rgba:0},Ne;(e=>{function t(n,o,a,l){return l!==void 0?`#${Zt(n)}${Zt(o)}${Zt(a)}${Zt(l)}`:`#${Zt(n)}${Zt(o)}${Zt(a)}`}e.toCss=t;function s(n,o,a,l=255){return(n<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(n,o,a,l){return{css:e.toCss(n,o,a,l),rgba:e.toRgba(n,o,a,l)}}e.toColor=i})(Ne||(Ne={}));var ge;(e=>{function t(h,c){if(Se=(c.rgba&255)/255,Se===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,m=c.rgba>>16&255,f=c.rgba>>8&255,_=h.rgba>>24&255,p=h.rgba>>16&255,g=h.rgba>>8&255;Le=_+Math.round((u-_)*Se),Be=p+Math.round((m-p)*Se),Te=g+Math.round((f-g)*Se);let v=Ne.toCss(Le,Be,Te),y=Ne.toRgba(Le,Be,Te);return{css:v,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,u){let m=Yi.ensureContrastRatio(h.rgba,c.rgba,u);if(m)return Ne.toColor(m>>24&255,m>>16&255,m>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Le,Be,Te]=Yi.toChannels(c),{css:Ne.toCss(Le,Be,Te),rgba:c}}e.opaque=n;function o(h,c){return Se=Math.round(c*255),[Le,Be,Te]=Yi.toChannels(h.rgba),{css:Ne.toCss(Le,Be,Te,Se),rgba:Ne.toRgba(Le,Be,Te,Se)}}e.opacity=o;function a(h,c){return Se=h.rgba&255,o(h,Se*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(ge||(ge={}));var ye;(e=>{let t,s;try{let n=document.createElement("canvas");n.width=1,n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Ne.toColor(Le,Be,Te);case 5:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Se=parseInt(n.slice(4,5).repeat(2),16),Ne.toColor(Le,Be,Te,Se);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let o=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Le=parseInt(o[1]),Be=parseInt(o[2]),Te=parseInt(o[3]),Se=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ne.toColor(Le,Be,Te,Se);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Le,Be,Te,Se]=t.getImageData(0,0,1,1).data,Se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ne.toRgba(Le,Be,Te,Se),css:n}}e.toColor=i})(ye||(ye={}));var Ke;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,n,o){let a=i/255,l=n/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+m*.0722}e.relativeLuminance2=s})(Ke||(Ke={}));var Yi;(e=>{function t(a,l){if(Se=(l&255)/255,Se===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,m=a>>24&255,f=a>>16&255,_=a>>8&255;return Le=m+Math.round((h-m)*Se),Be=f+Math.round((c-f)*Se),Te=_+Math.round((u-_)*Se),Ne.toRgba(Le,Be,Te)}e.blend=t;function s(a,l,h){let c=Ke.relativeLuminance(a>>8),u=Ke.relativeLuminance(l>>8);if(jt(c,u)<h){if(u<c){let _=i(a,l,h),p=jt(c,Ke.relativeLuminance(_>>8));if(p<h){let g=n(a,l,h),v=jt(c,Ke.relativeLuminance(g>>8));return p>v?_:g}return _}let m=n(a,l,h),f=jt(c,Ke.relativeLuminance(m>>8));if(f<h){let _=i(a,l,h),p=jt(c,Ke.relativeLuminance(_>>8));return f>p?m:_}return m}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));for(;g<h&&(f>0||_>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));for(;g<h&&(f<255||_<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=jt(Ke.relativeLuminance2(f,_,p),Ke.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Yi||(Yi={}));function Zt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ag=class extends _i{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},or=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new lt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),n=0,o=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-n>1){let u=this._getJoinedRanges(i,a,o,t,n);for(let m=0;m<u.length;m++)s.push(u[m])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||Ft.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let u=0;u<c.length;u++)s.push(c[u])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)or._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,t,s){let i=0,n=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||Ft.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};or=we([H(0,Ve)],or);function lg(e){return 57508<=e&&e<=57558}function cg(e){return 9472<=e&&e<=9631}function hg(e){return lg(e)||cg(e)}function dg(){return{css:{canvas:$i(),cell:$i()},device:{canvas:$i(),cell:$i(),char:{width:0,height:0,left:0,top:0}}}}function $i(){return{width:0,height:0}}var Tn=class{constructor(e,t,s,i,n,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new lt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,n,o,a,l,h,c,u){let m=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,v=0,y="",x=0,C=0,j=0,w=0,R=!1,B=0,U=!1,G=0,K=0,A=[],D=c!==-1&&u!==-1;for(let E=0;E<p;E++){e.loadCell(E,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let S=!1,N=E>=K,k=E,P=this._workCell;if(f.length>0&&E===f[0][0]&&N){let q=f.shift(),Q=this._isCellInSelection(q[0],t);for(x=q[0]+1;x<q[1];x++)N&&(N=Q===this._isCellInSelection(x,t));N&&(N=!s||o<q[0]||o>=q[1]),N?(S=!0,P=new ag(this._workCell,e.translateToString(!0,q[0],q[1]),q[1]-q[0]),k=q[1]-1,L=P.getWidth()):K=q[1]}let J=this._isCellInSelection(E,t),oe=s&&E===o,V=D&&E>=c&&E<=u,Z=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,q=>{Z=!0});let ie=P.getChars()||Ft;if(ie===" "&&(P.isUnderline()||P.isOverline())&&(ie=" "),G=L*l-h.get(ie,P.isBold(),P.isItalic()),!g)g=this._document.createElement("span");else if(v&&(J&&U||!J&&!U&&P.bg===C)&&(J&&U&&_.selectionForeground||P.fg===j)&&P.extended.ext===w&&V===R&&G===B&&!oe&&!S&&!Z&&N){P.isInvisible()?y+=Ft:y+=ie,v++;continue}else v&&(g.textContent=y),g=this._document.createElement("span"),v=0,y="";if(C=P.bg,j=P.fg,w=P.extended.ext,R=V,B=G,U=J,S&&o>=E&&o<=k&&(o=E),!this._coreService.isCursorHidden&&oe&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(P.isBold()&&A.push("xterm-bold"),P.isItalic()&&A.push("xterm-italic"),P.isDim()&&A.push("xterm-dim"),P.isInvisible()?y=Ft:y=P.getChars()||Ft,P.isUnderline()&&(A.push(`xterm-underline-${P.extended.underlineStyle}`),y===" "&&(y=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${_i.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let q=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&q<8&&(q+=8),g.style.textDecorationColor=_.ansi[q].css}P.isOverline()&&(A.push("xterm-overline"),y===" "&&(y=" ")),P.isStrikethrough()&&A.push("xterm-strikethrough"),V&&(g.style.textDecoration="underline");let ue=P.getFgColor(),fe=P.getFgColorMode(),de=P.getBgColor(),_e=P.getBgColorMode(),He=!!P.isInverse();if(He){let q=ue;ue=de,de=q;let Q=fe;fe=_e,_e=Q}let z,xe,T=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,q=>{q.options.layer!=="top"&&T||(q.backgroundColorRGB&&(_e=50331648,de=q.backgroundColorRGB.rgba>>8&16777215,z=q.backgroundColorRGB),q.foregroundColorRGB&&(fe=50331648,ue=q.foregroundColorRGB.rgba>>8&16777215,xe=q.foregroundColorRGB),T=q.options.layer==="top")}),!T&&J&&(z=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,de=z.rgba>>8&16777215,_e=50331648,T=!0,_.selectionForeground&&(fe=50331648,ue=_.selectionForeground.rgba>>8&16777215,xe=_.selectionForeground)),T&&A.push("xterm-decoration-top");let Y;switch(_e){case 16777216:case 33554432:Y=_.ansi[de],A.push(`xterm-bg-${de}`);break;case 50331648:Y=Ne.toColor(de>>16,de>>8&255,de&255),this._addStyle(g,`background-color:#${Za((de>>>0).toString(16),"0",6)}`);break;case 0:default:He?(Y=_.foreground,A.push("xterm-bg-257")):Y=_.background}switch(z||P.isDim()&&(z=ge.multiplyOpacity(Y,.5)),fe){case 16777216:case 33554432:P.isBold()&&ue<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ue+=8),this._applyMinimumContrast(g,Y,_.ansi[ue],P,z,void 0)||A.push(`xterm-fg-${ue}`);break;case 50331648:let q=Ne.toColor(ue>>16&255,ue>>8&255,ue&255);this._applyMinimumContrast(g,Y,q,P,z,xe)||this._addStyle(g,`color:#${Za(ue.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,Y,_.foreground,P,z,xe)||He&&A.push("xterm-fg-257")}A.length&&(g.className=A.join(" "),A.length=0),!oe&&!S&&!Z&&N?v++:g.textContent=y,G!==this.defaultSpacing&&(g.style.letterSpacing=`${G}px`),m.push(g),E=k}return g&&v&&(g.textContent=y),m}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||hg(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!n&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=ge.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Tn=we([H(1,Wc),H(2,Ge),H(3,Pt),H(4,_s),H(5,xi),H(6,Ts)],Tn);function Za(e,t,s){for(;e.length<s;)e=t+e;return e}var ug=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),t.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(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},fg=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function mg(){return new fg}var Ir="xterm-dom-renderer-owner-",nt="xterm-rows",Ii="xterm-fg-",Qa="xterm-bg-",Us="xterm-focus",Fi="xterm-selection",pg=1,zn=class extends ne{constructor(e,t,s,i,n,o,a,l,h,c,u,m,f,_){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=m,this._coreBrowserService=f,this._themeService=_,this._terminalClass=pg++,this._rowElements=[],this._selectionRenderModel=mg(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(nt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Fi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=dg(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Tn,document),this._element.classList.add(Ir+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(ve(()=>{this._element.classList.remove(Ir+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ug(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),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/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),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(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${nt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,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(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${nt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${nt} .xterm-dim { color: ${ge.multiplyOpacity(e.foreground,.5).css};}`,t+=`${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;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${nt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${nt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${nt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${nt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Fi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Fi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Fi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${Ii}${o} { color: ${a.css}; }${this._terminalSelector} .${Ii}${o}.xterm-dim { color: ${ge.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Qa}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${Ii}257 { color: ${ge.opaque(e.background).css}; }${this._terminalSelector} .${Ii}257.xterm-dim { color: ${ge.multiplyOpacity(ge.opaque(e.background),.5).css}; }${this._terminalSelector} .${Qa}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Us),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Us),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=i===o?e[0]:0,c=o===n?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let m=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,m))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}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(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],m=s.lines.get(c);if(!u||!m)break;u.replaceChildren(...this._rowFactory.createRow(m,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ir}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,n,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),u=this._optionsService.rawOptions.cursorBlink,m=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=s;_<=i;++_){let p=_+l.ydisp,g=this._rowElements[_],v=l.lines.get(p);if(!g||!v)break;g.replaceChildren(...this._rowFactory.createRow(v,p,p===h,m,f,c,u,this.dimensions.css.cell.width,this._widthCache,o?_===s?e:0:-1,o?(_===i?t:n)-1:-1))}}};zn=we([H(7,_o),H(8,vr),H(9,Ge),H(10,Ve),H(11,_s),H(12,Pt),H(13,Ts)],zn);var An=class extends ne{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new _g(this._optionsService))}catch{this._measureStrategy=this._register(new gg(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};An=we([H(2,Ge)],An);var lh=class extends ne{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},gg=class extends lh{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},_g=class extends lh{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},xg=class extends ne{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new vg(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(X(this._textarea,"focus",()=>this._isFocused=!0)),this._register(X(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}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}},vg=class extends ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Bs),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=X(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},bg=class extends ne{constructor(){super(),this.linkProviders=[],this._register(ve(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ko(e,t,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function yg(e,t,s,i,n,o,a,l,h){if(!o)return;let c=ko(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c}var On=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return yg(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=ko(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};On=we([H(0,Mt),H(1,vr)],On);var Sg=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ch={};Mm(ch,{getSafariVersion:()=>Cg,isChromeOS:()=>fh,isFirefox:()=>hh,isIpad:()=>kg,isIphone:()=>jg,isLegacyEdge:()=>wg,isLinux:()=>jo,isMac:()=>ar,isNode:()=>br,isSafari:()=>dh,isWindows:()=>uh});var br=typeof process<"u"&&"title"in process,vi=br?"node":navigator.userAgent,bi=br?"node":navigator.platform,hh=vi.includes("Firefox"),wg=vi.includes("Edge"),dh=/^((?!chrome|android).)*safari/i.test(vi);function Cg(){if(!dh)return 0;let e=vi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ar=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(bi),kg=bi==="iPad",jg=bi==="iPhone",uh=["Windows","Win16","Win32","WinCE"].includes(bi),jo=bi.indexOf("Linux")>=0,fh=/\bCrOS\b/.test(vi),mh=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),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(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),n=e.timeRemaining(),s*1.5>n){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=n}this.clear()}},Ng=class extends mh{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Eg=class extends mh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},lr=!br&&"requestIdleCallback"in window?Eg:Ng,Rg=class{constructor(){this._queue=new lr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},$n=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new Bs),this._pausedResizeTask=new Rg,this._observerDisposable=this._register(new Bs),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 O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Sg((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Dg(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ve(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.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(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,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(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};$n=we([H(2,Ge),H(3,vr),H(4,_s),H(5,xi),H(6,Ve),H(7,Pt),H(8,Ts)],$n);var Dg=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Pg(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Bg(n,o,e,t,s,i)+yr(o,t,s,i)+Tg(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",ui(Math.abs(n-e),di(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=Lg(o>t?e:n,s)+(l-1)*s.cols+1+Mg(o>t?n:e);return ui(h,di(a,i))}function Mg(e,t){return e-1}function Lg(e,t){return t.cols-e}function Bg(e,t,s,i,n,o){return yr(t,i,n,o).length===0?"":ui(gh(e,t,e,t-us(t,n),!1,n).length,di("D",o))}function yr(e,t,s,i){let n=e-us(e,s),o=t-us(t,s),a=Math.abs(n-o)-zg(e,t,s);return ui(a,di(ph(e,t),i))}function Tg(e,t,s,i,n,o){let a;yr(t,i,n,o).length>0?a=i-us(i,n):a=t;let l=i,h=Ag(e,t,s,i,n,o);return ui(gh(e,a,s,l,h==="C",n).length,di(h,o))}function zg(e,t,s){var a;let i=0,n=e-us(e,s),o=t-us(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=ph(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function us(e,t){let s=0,i=t.buffer.lines.get(e),n=i==null?void 0:i.isWrapped;for(;n&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),n=i==null?void 0:i.isWrapped;return s}function Ag(e,t,s,i,n,o){let a;return yr(s,i,n,o).length>0?a=i-us(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function ph(e,t){return e>t?"A":"B"}function gh(e,t,s,i,n,o){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function di(e,t){let s=t?"O":"[";return M.ESC+s+e}function ui(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var Og=class{constructor(e){this._bufferService=e,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.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()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function el(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Fr=50,$g=15,Ig=50,Fg=500,Hg=" ",Wg=new RegExp(Hg,"g"),In=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new lt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Og(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}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(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);i.push(l)}}else{let n=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(n=>n.replace(Wg," ")).join(uh?`\r
194
194
  `:`
195
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),jo&&e&&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(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=el(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ko(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Fr),Fr),t/=Fr,t/Math.abs(t)+Math.round(t*($g-1)))}shouldForceSelection(e){return ar?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),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(),Ig)}_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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(ar&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}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(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[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});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Fg&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Pg(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==i&&(s+=n-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,m=0,f=0,_=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let v=e[0],y=e[0];o.getWidth(v)===0&&(u++,v--),o.getWidth(y)===2&&(m++,y++);let x=o.getString(y).length;for(x>1&&(_+=x-1,h+=x-1);v>0&&l>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,v--):C>1&&(f+=C-1,l-=C-1),l--,v--}for(;y<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(y+1,this._workCell));){o.loadCell(y+1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===2?(m++,y++):C>1&&(_+=C-1,h+=C-1),h++,y++}}h++;let p=l+c-u+f,g=Math.min(this._bufferService.cols,h-l+u+m-f-_);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let v=n.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let x=this._bufferService.cols-y.start;p-=x,g+=x}}}if(i&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=n.lines.get(e[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(g+=y.length)}}return{start:p,length:g}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=el(s,this._bufferService.cols)}};In=we([H(3,Ve),H(4,gs),H(5,xo),H(6,Ge),H(7,Mt),H(8,Pt)],In);var tl=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},sl=class{constructor(){this._color=new tl,this._css=new tl}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ee=Object.freeze((()=>{let e=[ye.toColor("#2e3436"),ye.toColor("#cc0000"),ye.toColor("#4e9a06"),ye.toColor("#c4a000"),ye.toColor("#3465a4"),ye.toColor("#75507b"),ye.toColor("#06989a"),ye.toColor("#d3d7cf"),ye.toColor("#555753"),ye.toColor("#ef2929"),ye.toColor("#8ae234"),ye.toColor("#fce94f"),ye.toColor("#729fcf"),ye.toColor("#ad7fa8"),ye.toColor("#34e2e2"),ye.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],n=t[s/6%6|0],o=t[s%6];e.push({css:Ne.toCss(i,n,o),rgba:Ne.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Ne.toCss(i,i,i),rgba:Ne.toRgba(i,i,i)})}return e})()),es=ye.toColor("#ffffff"),ei=ye.toColor("#000000"),il=ye.toColor("#ffffff"),rl=ei,Ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ug=es,Fn=class extends ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new sl,this._halfContrastCache=new sl,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:es,background:ei,cursor:il,cursorAccent:rl,selectionForeground:void 0,selectionBackgroundTransparent:Ks,selectionBackgroundOpaque:ge.blend(ei,Ks),selectionInactiveBackgroundTransparent:Ks,selectionInactiveBackgroundOpaque:ge.blend(ei,Ks),scrollbarSliderBackground:ge.opacity(es,.2),scrollbarSliderHoverBackground:ge.opacity(es,.4),scrollbarSliderActiveBackground:ge.opacity(es,.5),overviewRulerBorder:es,ansi:Ee.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)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=me(e.foreground,es),t.background=me(e.background,ei),t.cursor=ge.blend(t.background,me(e.cursor,il)),t.cursorAccent=ge.blend(t.background,me(e.cursorAccent,rl)),t.selectionBackgroundTransparent=me(e.selectionBackground,Ks),t.selectionBackgroundOpaque=ge.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=me(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ge.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?me(e.selectionForeground,Ja):void 0,t.selectionForeground===Ja&&(t.selectionForeground=void 0),ge.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ge.opacity(t.selectionBackgroundTransparent,.3)),ge.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ge.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=me(e.scrollbarSliderBackground,ge.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=me(e.scrollbarSliderHoverBackground,ge.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=me(e.scrollbarSliderActiveBackground,ge.opacity(t.foreground,.5)),t.overviewRulerBorder=me(e.overviewRulerBorder,Ug),t.ansi=Ee.slice(),t.ansi[0]=me(e.black,Ee[0]),t.ansi[1]=me(e.red,Ee[1]),t.ansi[2]=me(e.green,Ee[2]),t.ansi[3]=me(e.yellow,Ee[3]),t.ansi[4]=me(e.blue,Ee[4]),t.ansi[5]=me(e.magenta,Ee[5]),t.ansi[6]=me(e.cyan,Ee[6]),t.ansi[7]=me(e.white,Ee[7]),t.ansi[8]=me(e.brightBlack,Ee[8]),t.ansi[9]=me(e.brightRed,Ee[9]),t.ansi[10]=me(e.brightGreen,Ee[10]),t.ansi[11]=me(e.brightYellow,Ee[11]),t.ansi[12]=me(e.brightBlue,Ee[12]),t.ansi[13]=me(e.brightMagenta,Ee[13]),t.ansi[14]=me(e.brightCyan,Ee[14]),t.ansi[15]=me(e.brightWhite,Ee[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=me(e.extendedAnsi[i],Ee[i+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){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}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]}}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()}}};Fn=we([H(0,Ge)],Fn);function me(e,t){if(e!==void 0)try{return ye.toColor(e)}catch{}return t}var Kg=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},qg=class{constructor(){this._services=new Kg,this._services.set(_o,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=$m(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let n=s.length>0?s[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Vg={trace:0,debug:1,info:2,warn:3,error:4,off:5},Gg="xterm.js: ",Hn=class extends ne{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Vg[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Gg)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Hn=we([H(0,Ge)],Hn);var nl=class extends ne{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,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(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},re=3,je=Object.freeze(new _i),Hi=0,Hr=2,ti=class _h{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*re);let n=s||lt.fromCharData([0,zc,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*re+0],i=s&2097151;return[this._data[t*re+1],s&2097152?this._combined[t]:i?$t(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*re+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*re+0]=t|2097152|s[2]<<22):this._data[t*re+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*re+0]>>22}hasWidth(t){return this._data[t*re+0]&12582912}getFg(t){return this._data[t*re+1]}getBg(t){return this._data[t*re+2]}hasContent(t){return this._data[t*re+0]&4194303}getCodePoint(t){let s=this._data[t*re+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*re+0]&2097152}getString(t){let s=this._data[t*re+0];return s&2097152?this._combined[t]:s&2097151?$t(s&2097151):""}isProtected(t){return this._data[t*re+2]&536870912}loadCell(t,s){return Hi=t*re,s.content=this._data[Hi+0],s.fg=this._data[Hi+1],s.bg=this._data[Hi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*re+0]=s.content,this._data[t*re+1]=s.fg,this._data[t*re+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*re+0]=s|i<<22,this._data[t*re+1]=n.fg,this._data[t*re+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*re+0];n&2097152?this._combined[t]+=$t(s):n&2097151?(this._combined[t]=$t(n&2097151)+$t(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*re+0]=n}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let n=new lt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,n));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let n=new lt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,n));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*Hr<this._data.buffer.byteLength;let i=t*re;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let n=new Uint32Array(i);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,s)}else{this._data=this._data.subarray(0,i);let n=Object.keys(this._combined);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*Hr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Hr<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new _h(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303)return t+(this._data[t*re+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303||this._data[t*re+2]&50331648)return t+(this._data[t*re+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,n){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),n&&(n.length=0);let o="";for(;s<i;){let a=this._data[s*re+0],l=a&2097151,h=a&2097152?this._combined[s]:l?$t(l):Ft;if(o+=h,n)for(let c=0;c<h.length;++c)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function Yg(e,t,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let u=[e.get(l)];for(;h<e.length&&c.isWrapped;)u.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=u.length-1;continue}let m=0,f=fi(u,m,t),_=1,p=0;for(;_<u.length;){let v=fi(u,_,t),y=v-p,x=s-f,C=Math.min(y,x);u[m].copyCellsFrom(u[_],p,f,C,!1),f+=C,f===s&&(m++,f=0),p+=C,p===v&&(_++,p=0),f===0&&m!==0&&u[m-1].getWidth(s-1)===2&&(u[m].copyCellsFrom(u[m-1],s-1,f++,1,!1),u[m-1].setCell(s-1,n))}u[m].replaceCells(f,s,n);let g=0;for(let v=u.length-1;v>0&&(v>m||u[v].getTrimmedLength()===0);v--)g++;g>0&&(a.push(l+u.length-g),a.push(g)),l+=u.length-1}return a}function Xg(e,t){let s=[],i=0,n=t[i],o=0;for(let a=0;a<e.length;a++)if(n===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function Jg(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function Zg(e,t,s){let i=[],n=e.map((h,c)=>fi(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let h=fi(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;i.push(u),l+=u}return i}function fi(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,n=e[t+1].getWidth(0)===2;return i&&n?s-1:s}var xh=class vh{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=vh._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ds(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};xh._nextId=1;var Qg=xh,Re={},ts=Re.B;Re[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Re.A={"#":"£"};Re.B=void 0;Re[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Re.C=Re[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Re.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Re.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Re.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Re.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Re.E=Re[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Re.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Re.H=Re[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Re["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ol=4294967295,al=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=je.clone(),this.savedCharset=ts,this.markers=[],this._nullCell=lt.fromCharData([0,zc,1,0]),this._whitespaceCell=lt.fromCharData([0,Ft,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new lr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new nl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rr),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rr),this._whitespaceCell}getBlankLine(e,t){return new ti(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>ol?ol:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=je);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new nl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(je),i=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ti(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ti(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let a=this.lines.length-n;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=Yg(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(je),s);if(i.length>0){let n=Xg(this.lines,i);Jg(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(je),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ti(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(je),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let C=this.ybase+this.y;if(C>=a&&C<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),u=Zg(h,this._cols,e),m=u.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+m):f=Math.max(0,this.lines.length-this.lines.maxLength+m);let _=[];for(let C=0;C<m;C++){let j=this.getBlankLine(je,!0);_.push(j)}_.length>0&&(n.push({start:a+h.length+o,newLines:_}),o+=_.length),h.push(..._);let p=u.length-1,g=u[p];g===0&&(p--,g=u[p]);let v=h.length-m-1,y=c;for(;v>=0;){let C=Math.min(y,g);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[v],y-C,g-C,C,!0),g-=C,g===0&&(p--,g=u[p]),y-=C,y===0){v--;let j=Math.max(v,0);y=fi(h,j,this._cols)}}for(let C=0;C<h.length;C++)u[C]<e&&h[C].setCell(u[C],i);let x=m-f;for(;x-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+t-1)}if(n.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let h=this.lines.length,c=h-1,u=0,m=n[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,h+o-1);g>=0;g--)if(m&&m.start>c+f){for(let v=m.newLines.length-1;v>=0;v--)this.lines.set(g--,m.newLines[v]);g++,a.push({index:c+1,amount:m.newLines.length}),f+=m.newLines.length,m=n[++u]}else this.lines.set(g,l[c--]);let _=0;for(let g=a.length-1;g>=0;g--)a[g].index+=_,this.lines.onInsertEmitter.fire(a[g]),_+=a[g].amount;let p=Math.max(0,h+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,s=0,i){let n=this.lines.get(e);return n?n.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Qg(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},e_=class extends ne{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),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 al(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new al(!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(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),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(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},bh=2,yh=1,Wn=class extends ne{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,bh),this.rows=Math.max(e.rawOptions.rows||0,yh),this.buffers=this._register(new e_(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-n+1;s.lines.shiftElements(n+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Wn=we([H(0,Ge)],Wn);var ws={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:ar,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},t_=["normal","bold","100","200","300","400","500","600","700","800","900"],s_=class extends ne{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...ws};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in ws))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in ws))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=ws[e]),!i_(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ws[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=t_.includes(t)?t:ws[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function i_(e){return e==="block"||e==="underline"||e==="bar"}function si(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&si(e[i],t-1);return s}var ll=Object.freeze({insertMode:!1}),cl=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Un=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=si(ll),this.decPrivateModes=si(cl)}reset(){this.modes=si(ll),this.decPrivateModes=si(cl)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Un=we([H(0,Ve),H(1,Fc),H(2,Ge)],Un);var hl={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Wr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Ur=String.fromCharCode,dl={DEFAULT:e=>{let t=[Wr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ur(t[0])}${Ur(t[1])}${Ur(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Wr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Wr(e,!0)};${e.x};${e.y}${t}`}},Kn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(hl))this.addProtocol(i,hl[i]);for(let i of Object.keys(dl))this.addEncoding(i,dl[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=i+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Kn=we([H(0,Ve),H(1,gs),H(2,Ge)],Kn);var Kr=[[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]],r_=[[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]],De;function n_(e,t){let s=0,i=t.length-1,n;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(n=s+i>>1,e>t[n][1])s=n+1;else if(e<t[n][0])i=n-1;else return!0;return!1}var o_=class{constructor(){if(this.version="6",!De){De=new Uint8Array(65536),De.fill(1),De[0]=0,De.fill(0,1,32),De.fill(0,127,160),De.fill(2,4352,4448),De[9001]=2,De[9002]=2,De.fill(2,11904,42192),De[12351]=1,De.fill(2,44032,55204),De.fill(2,63744,64256),De.fill(2,65040,65050),De.fill(2,65072,65136),De.fill(2,65280,65377),De.fill(2,65504,65511);for(let e=0;e<Kr.length;++e)De.fill(0,Kr[e][0],Kr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?De[e]:n_(e,r_)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let n=ss.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return ss.createPropertyValue(0,s,i)}},ss=class Xi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new o_;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,n=t.length;for(let o=0;o<n;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Xi.extractWidth(l);Xi.extractShouldJoin(l)&&(h-=Xi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},a_=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function ul(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var qs=2147483647,l_=256,Sh=class qn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>l_)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new qn;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let n=t[i];if(Array.isArray(n))for(let o=0;o<n.length;++o)s.addSubParam(n[o]);else s.addParam(n)}return s}clone(){let t=new qn(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,n))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>qs?qs:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>qs?qs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&(t[s]=this._subParams.slice(i,n))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,n=i[s-1];i[s-1]=~n?Math.min(n*10+t,qs):t}},Vs=[],c_=class{constructor(){this._state=0,this._active=Vs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Vs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Vs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",xr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Vs,this._id=-1,this._state=0}}},it=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=xr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Gs=[],h_=class{constructor(){this._handlers=Object.create(null),this._active=Gs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Gs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",xr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Gs,this._ident=0}},ii=new Sh;ii.addParam(0);var fl=class{constructor(e){this._handler=e,this._data="",this._params=ii,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ii,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=xr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=ii,this._data="",this._hitLimit=!1,s));return this._params=ii,this._data="",this._hitLimit=!1,t}},d_=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|i}},at=160,u_=(function(){let e=new d_(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(at,0,2,0),e.add(at,8,5,8),e.add(at,6,0,6),e.add(at,11,0,11),e.add(at,13,13,13),e})(),f_=class extends ne{constructor(e=u_){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Sh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new c_),this._dcsParser=this._register(new h_),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}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.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,t,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],n=this._transitions.table[this.currentState<<8|(i<160?i:at)],n>>4){case 2:for(let f=l+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let u=this._escHandlers[this._collect<<8|i],m=u?u.length-1:-1;for(;m>=0&&(a=u[m](),a!==!0);m--)if(a instanceof Promise)return this._preserveStack(4,u,m,n,l),a;m<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<at){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<at){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},m_=/^([\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})$/,p_=/^[\da-f]+$/;function ml(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=m_.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),p_.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let n=0;n<3;++n){let o=parseInt(t.slice(s*n,s*n+s),16);i[n]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function qr(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function g_(e,t=16){let[s,i,n]=e;return`rgb:${qr(s,t)}/${qr(i,t)}/${qr(n,t)}`}var __={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ot=131072,pl=10;function gl(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var _l=5e3,xl=0,x_=class extends ne{constructor(e,t,s,i,n,o,a,l,h=new f_){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Am,this._utf8Decoder=new Om,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=je.clone(),this._eraseAttrDataInternal=je.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),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 Vn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:m})}),this._parser.setDcsHandlerFallback((c,u,m)=>{u==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:m})}),this._parser.setPrintHandler((c,u,m)=>this.print(c,u,m)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(M.BEL,()=>this.bell()),this._parser.setExecuteHandler(M.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(M.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(M.BS,()=>this.backspace()),this._parser.setExecuteHandler(M.HT,()=>this.tab()),this._parser.setExecuteHandler(M.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(M.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Gi.IND,()=>this.index()),this._parser.setExecuteHandler(Gi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Gi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new it(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new it(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new it(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new it(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new it(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new it(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new it(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new it(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new it(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new it(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new it(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new it(c=>this.restoreCursorColor(c))),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(let c in Re)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new fl((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),_l))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${_l} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ot&&(o=this._parseStack.position+Ot)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ot&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ot))),a||this._dirtyRowTracker.clearRange(),e.length>Ot)for(let c=o;c<e.length;c+=Ot){let u=c+Ot<e.length?c+Ot:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(i,n,m,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,n,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,u=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let _=t;_<s;++_){if(i=e[_],i<127&&o){let y=o[String.fromCharCode(i)];y&&(i=y.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);n=ss.extractWidth(p);let g=ss.extractShouldJoin(p),v=g?ss.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire($t(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-v>l){if(h){let y=m,x=this._activeBuffer.x-v;for(this._activeBuffer.x=v,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof ti&&m.copyCellsFrom(y,x,0,v,!1);x<l;)y.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=l-1,n===2)continue}if(g&&this._activeBuffer.x){let y=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let x=n-v;--x>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(m.insertCells(this._activeBuffer.x,n-v,this._activeBuffer.getNullCell(u)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,u)),m.setCellFromCodepoint(this._activeBuffer.x++,i,n,u),n>0)for(;--n;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>gl(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new fl(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new it(t))}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 e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,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(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)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(e){let t=e.params[0]||1;for(;t--;)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(je));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=ss.extractWidth(t),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let u=o.codePointAt(c)||0;a[l++]=u,c+=u>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(M.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(M.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(M.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(M.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(M.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ts),this._charsetService.setgCharset(1,ts),this._charsetService.setgCharset(2,ts),this._charsetService.setgCharset(3,ts);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(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){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:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,m=this._optionsService.rawOptions,f=(g,v)=>(a.triggerDataEvent(`${M.ESC}[${t?"":"?"}${g};${v}$y`),!0),_=g=>g?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,_(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,_(m.convertEol)):f(p,0):p===1?f(p,_(i.applicationCursorKeys)):p===3?f(p,m.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,_(i.origin)):p===7?f(p,_(i.wraparound)):p===8?f(p,3):p===9?f(p,_(n==="X10")):p===12?f(p,_(m.cursorBlink)):p===25?f(p,_(!a.isCursorHidden)):p===45?f(p,_(i.reverseWraparound)):p===66?f(p,_(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,_(n==="VT200")):p===1002?f(p,_(n==="DRAG")):p===1003?f(p,_(n==="ANY")):p===1004?f(p,_(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,_(o==="SGR")):p===1015?f(p,4):p===1016?f(p,_(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,_(c===u)):p===2004?f(p,_(i.bracketedPasteMode)):p===2026?f(p,_(i.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=_i.fromColorRGB([s,i,n])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(n=1),i[o+l+1+n]=a[l];while(++l<a.length&&l+o+1+n<i.length);break}if(i[1]===5&&o+n>=2||i[1]===2&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=je.fg,e.bg=je.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let n=0;n<t;n++)s=e.params[n],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=je.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=je.bg&16777215):s===38||s===48||s===58?n+=this._extractColor(e,n,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=je.fg&16777215,i.bg&=-67108864,i.bg|=je.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${M.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=je.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(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!gl(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${M.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>pl&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>pl&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){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(e){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(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),n=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(vl(o))if(n==="?")t.push({type:0,index:o});else{let a=ml(n);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(o=>o.startsWith("id="));return n!==-1&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=ml(s[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let n=parseInt(s[i]);vl(n)&&t.push({type:2,index:n})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){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,ts),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(__[e[0]],Re[e[1]]||ts),!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){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,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=je.clone(),this._eraseAttrDataInternal=je.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new lt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${M.ESC}${a}${M.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Vn=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(xl=e,e=t,t=xl),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Vn=we([H(0,Ve)],Vn);function vl(e){return 0<=e&&e<256}var v_=5e7,bl=12,b_=50,y_=class extends ne{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>v_)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],n=this._action(i,t);if(n){let a=l=>performance.now()-s>=bl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=bl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>b_&&(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()}},Gn=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),n=this._entriesWithId.get(i);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Gn=we([H(0,Ve)],Gn);var yl=!1,S_=class extends ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ls),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new qg,this.optionsService=this._register(new s_(e)),this._instantiationService.setService(Ge,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Wn)),this._instantiationService.setService(Ve,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Hn)),this._instantiationService.setService(Fc,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Un)),this._instantiationService.setService(gs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Kn)),this._instantiationService.setService(Ic,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ss)),this._instantiationService.setService(Hm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(a_),this._instantiationService.setService(Fm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Gn),this._instantiationService.setService(Hc,this._oscLinkService),this._inputHandler=this._register(new x_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new y_((t,s)=>this._inputHandler.parse(t,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.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(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!yl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),yl=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,bh),t=Math.max(t,yh),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(ul.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ul(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},w_={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:["'",'"']};function C_(e,t,s,i){var a;let n={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?n.key=M.ESC+"OA":n.key=M.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=M.ESC+"OD":n.key=M.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=M.ESC+"OC":n.key=M.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=M.ESC+"OB":n.key=M.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":M.DEL,e.altKey&&(n.key=M.ESC+n.key);break;case 9:if(e.shiftKey){n.key=M.ESC+"[Z";break}n.key=M.HT,n.cancel=!0;break;case 13:n.key=e.altKey?M.ESC+M.CR:M.CR,n.cancel=!0;break;case 27:n.key=M.ESC,e.altKey&&(n.key=M.ESC+M.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"D":t?n.key=M.ESC+"OD":n.key=M.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"C":t?n.key=M.ESC+"OC":n.key=M.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"A":t?n.key=M.ESC+"OA":n.key=M.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"B":t?n.key=M.ESC+"OB":n.key=M.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=M.ESC+"[2~");break;case 46:o?n.key=M.ESC+"[3;"+(o+1)+"~":n.key=M.ESC+"[3~";break;case 36:o?n.key=M.ESC+"[1;"+(o+1)+"H":t?n.key=M.ESC+"OH":n.key=M.ESC+"[H";break;case 35:o?n.key=M.ESC+"[1;"+(o+1)+"F":t?n.key=M.ESC+"OF":n.key=M.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=M.ESC+"[5;"+(o+1)+"~":n.key=M.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=M.ESC+"[6;"+(o+1)+"~":n.key=M.ESC+"[6~";break;case 112:o?n.key=M.ESC+"[1;"+(o+1)+"P":n.key=M.ESC+"OP";break;case 113:o?n.key=M.ESC+"[1;"+(o+1)+"Q":n.key=M.ESC+"OQ";break;case 114:o?n.key=M.ESC+"[1;"+(o+1)+"R":n.key=M.ESC+"OR";break;case 115:o?n.key=M.ESC+"[1;"+(o+1)+"S":n.key=M.ESC+"OS";break;case 116:o?n.key=M.ESC+"[15;"+(o+1)+"~":n.key=M.ESC+"[15~";break;case 117:o?n.key=M.ESC+"[17;"+(o+1)+"~":n.key=M.ESC+"[17~";break;case 118:o?n.key=M.ESC+"[18;"+(o+1)+"~":n.key=M.ESC+"[18~";break;case 119:o?n.key=M.ESC+"[19;"+(o+1)+"~":n.key=M.ESC+"[19~";break;case 120:o?n.key=M.ESC+"[20;"+(o+1)+"~":n.key=M.ESC+"[20~";break;case 121:o?n.key=M.ESC+"[21;"+(o+1)+"~":n.key=M.ESC+"[21~";break;case 122:o?n.key=M.ESC+"[23;"+(o+1)+"~":n.key=M.ESC+"[23~";break;case 123:o?n.key=M.ESC+"[24;"+(o+1)+"~":n.key=M.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=M.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=M.DEL:e.keyCode===219?n.key=M.ESC:e.keyCode===220?n.key=M.FS:e.keyCode===221&&(n.key=M.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=w_[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)n.key=M.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),n.key=M.ESC+c}else if(e.keyCode===32)n.key=M.ESC+(e.ctrlKey?M.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=M.ESC+h,n.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=M.US),e.key==="@"&&(n.key=M.NUL));break}return n}var Ce=0,k_=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new lr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new lr,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[n]=e[t],t++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Ce=this._search(t),Ce===-1)||this._getKey(this._array[Ce])!==t)return!1;do if(this._array[Ce]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ce),!0;while(++Ce<this._array.length&&this._getKey(this._array[Ce])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ce=this._search(e),!(Ce<0||Ce>=this._array.length)&&this._getKey(this._array[Ce])===e))do yield this._array[Ce];while(++Ce<this._array.length&&this._getKey(this._array[Ce])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ce=this._search(e),!(Ce<0||Ce>=this._array.length)&&this._getKey(this._array[Ce])===e))do t(this._array[Ce]);while(++Ce<this._array.length&&this._getKey(this._array[Ce])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Vr=0,Sl=0,j_=class extends ne{constructor(){super(),this._decorations=new k_(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new N_(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,n=i+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,n=>{Vr=n.options.x??0,Sl=Vr+(n.options.width??1),e>=Vr&&e<Sl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},N_=class extends Vt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ye.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ye.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},E_=1e3,D_=class{constructor(e,t=E_){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=i-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},wl=20,cr=class extends ne{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new D_(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(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
195
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),jo&&e&&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(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=el(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ko(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Fr),Fr),t/=Fr,t/Math.abs(t)+Math.round(t*($g-1)))}shouldForceSelection(e){return ar?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),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(),Ig)}_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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(ar&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}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(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[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});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Fg&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Pg(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==i&&(s+=n-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,m=0,f=0,_=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let v=e[0],y=e[0];o.getWidth(v)===0&&(u++,v--),o.getWidth(y)===2&&(m++,y++);let x=o.getString(y).length;for(x>1&&(_+=x-1,h+=x-1);v>0&&l>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,v--):C>1&&(f+=C-1,l-=C-1),l--,v--}for(;y<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(y+1,this._workCell));){o.loadCell(y+1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===2?(m++,y++):C>1&&(_+=C-1,h+=C-1),h++,y++}}h++;let p=l+c-u+f,g=Math.min(this._bufferService.cols,h-l+u+m-f-_);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let v=n.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let x=this._bufferService.cols-y.start;p-=x,g+=x}}}if(i&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=n.lines.get(e[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(g+=y.length)}}return{start:p,length:g}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=el(s,this._bufferService.cols)}};In=we([H(3,Ve),H(4,_s),H(5,xo),H(6,Ge),H(7,Mt),H(8,Pt)],In);var tl=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},sl=class{constructor(){this._color=new tl,this._css=new tl}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ee=Object.freeze((()=>{let e=[ye.toColor("#2e3436"),ye.toColor("#cc0000"),ye.toColor("#4e9a06"),ye.toColor("#c4a000"),ye.toColor("#3465a4"),ye.toColor("#75507b"),ye.toColor("#06989a"),ye.toColor("#d3d7cf"),ye.toColor("#555753"),ye.toColor("#ef2929"),ye.toColor("#8ae234"),ye.toColor("#fce94f"),ye.toColor("#729fcf"),ye.toColor("#ad7fa8"),ye.toColor("#34e2e2"),ye.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],n=t[s/6%6|0],o=t[s%6];e.push({css:Ne.toCss(i,n,o),rgba:Ne.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Ne.toCss(i,i,i),rgba:Ne.toRgba(i,i,i)})}return e})()),es=ye.toColor("#ffffff"),ei=ye.toColor("#000000"),il=ye.toColor("#ffffff"),rl=ei,Ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ug=es,Fn=class extends ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new sl,this._halfContrastCache=new sl,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:es,background:ei,cursor:il,cursorAccent:rl,selectionForeground:void 0,selectionBackgroundTransparent:Ks,selectionBackgroundOpaque:ge.blend(ei,Ks),selectionInactiveBackgroundTransparent:Ks,selectionInactiveBackgroundOpaque:ge.blend(ei,Ks),scrollbarSliderBackground:ge.opacity(es,.2),scrollbarSliderHoverBackground:ge.opacity(es,.4),scrollbarSliderActiveBackground:ge.opacity(es,.5),overviewRulerBorder:es,ansi:Ee.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)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=me(e.foreground,es),t.background=me(e.background,ei),t.cursor=ge.blend(t.background,me(e.cursor,il)),t.cursorAccent=ge.blend(t.background,me(e.cursorAccent,rl)),t.selectionBackgroundTransparent=me(e.selectionBackground,Ks),t.selectionBackgroundOpaque=ge.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=me(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ge.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?me(e.selectionForeground,Ja):void 0,t.selectionForeground===Ja&&(t.selectionForeground=void 0),ge.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ge.opacity(t.selectionBackgroundTransparent,.3)),ge.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ge.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=me(e.scrollbarSliderBackground,ge.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=me(e.scrollbarSliderHoverBackground,ge.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=me(e.scrollbarSliderActiveBackground,ge.opacity(t.foreground,.5)),t.overviewRulerBorder=me(e.overviewRulerBorder,Ug),t.ansi=Ee.slice(),t.ansi[0]=me(e.black,Ee[0]),t.ansi[1]=me(e.red,Ee[1]),t.ansi[2]=me(e.green,Ee[2]),t.ansi[3]=me(e.yellow,Ee[3]),t.ansi[4]=me(e.blue,Ee[4]),t.ansi[5]=me(e.magenta,Ee[5]),t.ansi[6]=me(e.cyan,Ee[6]),t.ansi[7]=me(e.white,Ee[7]),t.ansi[8]=me(e.brightBlack,Ee[8]),t.ansi[9]=me(e.brightRed,Ee[9]),t.ansi[10]=me(e.brightGreen,Ee[10]),t.ansi[11]=me(e.brightYellow,Ee[11]),t.ansi[12]=me(e.brightBlue,Ee[12]),t.ansi[13]=me(e.brightMagenta,Ee[13]),t.ansi[14]=me(e.brightCyan,Ee[14]),t.ansi[15]=me(e.brightWhite,Ee[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=me(e.extendedAnsi[i],Ee[i+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){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}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]}}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()}}};Fn=we([H(0,Ge)],Fn);function me(e,t){if(e!==void 0)try{return ye.toColor(e)}catch{}return t}var Kg=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},qg=class{constructor(){this._services=new Kg,this._services.set(_o,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=$m(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let n=s.length>0?s[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Vg={trace:0,debug:1,info:2,warn:3,error:4,off:5},Gg="xterm.js: ",Hn=class extends ne{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Vg[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Gg)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Hn=we([H(0,Ge)],Hn);var nl=class extends ne{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,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(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},re=3,je=Object.freeze(new _i),Hi=0,Hr=2,ti=class _h{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*re);let n=s||lt.fromCharData([0,zc,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*re+0],i=s&2097151;return[this._data[t*re+1],s&2097152?this._combined[t]:i?$t(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*re+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*re+0]=t|2097152|s[2]<<22):this._data[t*re+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*re+0]>>22}hasWidth(t){return this._data[t*re+0]&12582912}getFg(t){return this._data[t*re+1]}getBg(t){return this._data[t*re+2]}hasContent(t){return this._data[t*re+0]&4194303}getCodePoint(t){let s=this._data[t*re+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*re+0]&2097152}getString(t){let s=this._data[t*re+0];return s&2097152?this._combined[t]:s&2097151?$t(s&2097151):""}isProtected(t){return this._data[t*re+2]&536870912}loadCell(t,s){return Hi=t*re,s.content=this._data[Hi+0],s.fg=this._data[Hi+1],s.bg=this._data[Hi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*re+0]=s.content,this._data[t*re+1]=s.fg,this._data[t*re+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*re+0]=s|i<<22,this._data[t*re+1]=n.fg,this._data[t*re+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*re+0];n&2097152?this._combined[t]+=$t(s):n&2097151?(this._combined[t]=$t(n&2097151)+$t(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*re+0]=n}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let n=new lt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,n));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let n=new lt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,n));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*Hr<this._data.buffer.byteLength;let i=t*re;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let n=new Uint32Array(i);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,s)}else{this._data=this._data.subarray(0,i);let n=Object.keys(this._combined);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*Hr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Hr<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new _h(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303)return t+(this._data[t*re+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303||this._data[t*re+2]&50331648)return t+(this._data[t*re+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,n){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),n&&(n.length=0);let o="";for(;s<i;){let a=this._data[s*re+0],l=a&2097151,h=a&2097152?this._combined[s]:l?$t(l):Ft;if(o+=h,n)for(let c=0;c<h.length;++c)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function Yg(e,t,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let u=[e.get(l)];for(;h<e.length&&c.isWrapped;)u.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=u.length-1;continue}let m=0,f=fi(u,m,t),_=1,p=0;for(;_<u.length;){let v=fi(u,_,t),y=v-p,x=s-f,C=Math.min(y,x);u[m].copyCellsFrom(u[_],p,f,C,!1),f+=C,f===s&&(m++,f=0),p+=C,p===v&&(_++,p=0),f===0&&m!==0&&u[m-1].getWidth(s-1)===2&&(u[m].copyCellsFrom(u[m-1],s-1,f++,1,!1),u[m-1].setCell(s-1,n))}u[m].replaceCells(f,s,n);let g=0;for(let v=u.length-1;v>0&&(v>m||u[v].getTrimmedLength()===0);v--)g++;g>0&&(a.push(l+u.length-g),a.push(g)),l+=u.length-1}return a}function Xg(e,t){let s=[],i=0,n=t[i],o=0;for(let a=0;a<e.length;a++)if(n===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function Jg(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function Zg(e,t,s){let i=[],n=e.map((h,c)=>fi(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let h=fi(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;i.push(u),l+=u}return i}function fi(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,n=e[t+1].getWidth(0)===2;return i&&n?s-1:s}var xh=class vh{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=vh._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ds(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};xh._nextId=1;var Qg=xh,De={},ts=De.B;De[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:"≥","{":"π","|":"≠","}":"£","~":"·"};De.A={"#":"£"};De.B=void 0;De[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};De.C=De[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};De.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};De.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};De.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};De.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};De.E=De[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};De.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};De.H=De[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};De["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ol=4294967295,al=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=je.clone(),this.savedCharset=ts,this.markers=[],this._nullCell=lt.fromCharData([0,zc,1,0]),this._whitespaceCell=lt.fromCharData([0,Ft,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new lr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new nl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rr),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rr),this._whitespaceCell}getBlankLine(e,t){return new ti(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>ol?ol:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=je);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new nl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(je),i=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ti(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ti(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let a=this.lines.length-n;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=Yg(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(je),s);if(i.length>0){let n=Xg(this.lines,i);Jg(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(je),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ti(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(je),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let C=this.ybase+this.y;if(C>=a&&C<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),u=Zg(h,this._cols,e),m=u.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+m):f=Math.max(0,this.lines.length-this.lines.maxLength+m);let _=[];for(let C=0;C<m;C++){let j=this.getBlankLine(je,!0);_.push(j)}_.length>0&&(n.push({start:a+h.length+o,newLines:_}),o+=_.length),h.push(..._);let p=u.length-1,g=u[p];g===0&&(p--,g=u[p]);let v=h.length-m-1,y=c;for(;v>=0;){let C=Math.min(y,g);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[v],y-C,g-C,C,!0),g-=C,g===0&&(p--,g=u[p]),y-=C,y===0){v--;let j=Math.max(v,0);y=fi(h,j,this._cols)}}for(let C=0;C<h.length;C++)u[C]<e&&h[C].setCell(u[C],i);let x=m-f;for(;x-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+t-1)}if(n.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let h=this.lines.length,c=h-1,u=0,m=n[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,h+o-1);g>=0;g--)if(m&&m.start>c+f){for(let v=m.newLines.length-1;v>=0;v--)this.lines.set(g--,m.newLines[v]);g++,a.push({index:c+1,amount:m.newLines.length}),f+=m.newLines.length,m=n[++u]}else this.lines.set(g,l[c--]);let _=0;for(let g=a.length-1;g>=0;g--)a[g].index+=_,this.lines.onInsertEmitter.fire(a[g]),_+=a[g].amount;let p=Math.max(0,h+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,s=0,i){let n=this.lines.get(e);return n?n.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Qg(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},e_=class extends ne{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),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 al(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new al(!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(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),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(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},bh=2,yh=1,Wn=class extends ne{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,bh),this.rows=Math.max(e.rawOptions.rows||0,yh),this.buffers=this._register(new e_(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-n+1;s.lines.shiftElements(n+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Wn=we([H(0,Ge)],Wn);var Cs={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:ar,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},t_=["normal","bold","100","200","300","400","500","600","700","800","900"],s_=class extends ne{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...Cs};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in Cs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in Cs))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Cs[e]),!i_(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Cs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=t_.includes(t)?t:Cs[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function i_(e){return e==="block"||e==="underline"||e==="bar"}function si(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&si(e[i],t-1);return s}var ll=Object.freeze({insertMode:!1}),cl=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Un=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=si(ll),this.decPrivateModes=si(cl)}reset(){this.modes=si(ll),this.decPrivateModes=si(cl)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Un=we([H(0,Ve),H(1,Fc),H(2,Ge)],Un);var hl={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Wr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Ur=String.fromCharCode,dl={DEFAULT:e=>{let t=[Wr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ur(t[0])}${Ur(t[1])}${Ur(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Wr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Wr(e,!0)};${e.x};${e.y}${t}`}},Kn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(hl))this.addProtocol(i,hl[i]);for(let i of Object.keys(dl))this.addEncoding(i,dl[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=i+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Kn=we([H(0,Ve),H(1,_s),H(2,Ge)],Kn);var Kr=[[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]],r_=[[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]],Re;function n_(e,t){let s=0,i=t.length-1,n;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(n=s+i>>1,e>t[n][1])s=n+1;else if(e<t[n][0])i=n-1;else return!0;return!1}var o_=class{constructor(){if(this.version="6",!Re){Re=new Uint8Array(65536),Re.fill(1),Re[0]=0,Re.fill(0,1,32),Re.fill(0,127,160),Re.fill(2,4352,4448),Re[9001]=2,Re[9002]=2,Re.fill(2,11904,42192),Re[12351]=1,Re.fill(2,44032,55204),Re.fill(2,63744,64256),Re.fill(2,65040,65050),Re.fill(2,65072,65136),Re.fill(2,65280,65377),Re.fill(2,65504,65511);for(let e=0;e<Kr.length;++e)Re.fill(0,Kr[e][0],Kr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Re[e]:n_(e,r_)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let n=ss.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return ss.createPropertyValue(0,s,i)}},ss=class Xi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new o_;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,n=t.length;for(let o=0;o<n;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Xi.extractWidth(l);Xi.extractShouldJoin(l)&&(h-=Xi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},a_=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function ul(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var qs=2147483647,l_=256,Sh=class qn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>l_)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new qn;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let n=t[i];if(Array.isArray(n))for(let o=0;o<n.length;++o)s.addSubParam(n[o]);else s.addParam(n)}return s}clone(){let t=new qn(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,n))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>qs?qs:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>qs?qs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&(t[s]=this._subParams.slice(i,n))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,n=i[s-1];i[s-1]=~n?Math.min(n*10+t,qs):t}},Vs=[],c_=class{constructor(){this._state=0,this._active=Vs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Vs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Vs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",xr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Vs,this._id=-1,this._state=0}}},it=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=xr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Gs=[],h_=class{constructor(){this._handlers=Object.create(null),this._active=Gs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Gs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",xr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Gs,this._ident=0}},ii=new Sh;ii.addParam(0);var fl=class{constructor(e){this._handler=e,this._data="",this._params=ii,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ii,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=xr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=ii,this._data="",this._hitLimit=!1,s));return this._params=ii,this._data="",this._hitLimit=!1,t}},d_=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|i}},at=160,u_=(function(){let e=new d_(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(at,0,2,0),e.add(at,8,5,8),e.add(at,6,0,6),e.add(at,11,0,11),e.add(at,13,13,13),e})(),f_=class extends ne{constructor(e=u_){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Sh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new c_),this._dcsParser=this._register(new h_),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}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.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,t,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],n=this._transitions.table[this.currentState<<8|(i<160?i:at)],n>>4){case 2:for(let f=l+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<at){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let u=this._escHandlers[this._collect<<8|i],m=u?u.length-1:-1;for(;m>=0&&(a=u[m](),a!==!0);m--)if(a instanceof Promise)return this._preserveStack(4,u,m,n,l),a;m<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<at){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<at){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},m_=/^([\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})$/,p_=/^[\da-f]+$/;function ml(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=m_.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),p_.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let n=0;n<3;++n){let o=parseInt(t.slice(s*n,s*n+s),16);i[n]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function qr(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function g_(e,t=16){let[s,i,n]=e;return`rgb:${qr(s,t)}/${qr(i,t)}/${qr(n,t)}`}var __={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ot=131072,pl=10;function gl(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var _l=5e3,xl=0,x_=class extends ne{constructor(e,t,s,i,n,o,a,l,h=new f_){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Am,this._utf8Decoder=new Om,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=je.clone(),this._eraseAttrDataInternal=je.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),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 Vn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:m})}),this._parser.setDcsHandlerFallback((c,u,m)=>{u==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:m})}),this._parser.setPrintHandler((c,u,m)=>this.print(c,u,m)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(M.BEL,()=>this.bell()),this._parser.setExecuteHandler(M.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(M.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(M.BS,()=>this.backspace()),this._parser.setExecuteHandler(M.HT,()=>this.tab()),this._parser.setExecuteHandler(M.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(M.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Gi.IND,()=>this.index()),this._parser.setExecuteHandler(Gi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Gi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new it(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new it(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new it(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new it(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new it(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new it(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new it(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new it(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new it(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new it(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new it(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new it(c=>this.restoreCursorColor(c))),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(let c in De)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new fl((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),_l))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${_l} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ot&&(o=this._parseStack.position+Ot)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ot&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ot))),a||this._dirtyRowTracker.clearRange(),e.length>Ot)for(let c=o;c<e.length;c+=Ot){let u=c+Ot<e.length?c+Ot:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(i,n,m,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,n,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,u=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let _=t;_<s;++_){if(i=e[_],i<127&&o){let y=o[String.fromCharCode(i)];y&&(i=y.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);n=ss.extractWidth(p);let g=ss.extractShouldJoin(p),v=g?ss.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire($t(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-v>l){if(h){let y=m,x=this._activeBuffer.x-v;for(this._activeBuffer.x=v,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof ti&&m.copyCellsFrom(y,x,0,v,!1);x<l;)y.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=l-1,n===2)continue}if(g&&this._activeBuffer.x){let y=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let x=n-v;--x>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(m.insertCells(this._activeBuffer.x,n-v,this._activeBuffer.getNullCell(u)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,u)),m.setCellFromCodepoint(this._activeBuffer.x++,i,n,u),n>0)for(;--n;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>gl(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new fl(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new it(t))}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 e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,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(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)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(e){let t=e.params[0]||1;for(;t--;)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(je));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=ss.extractWidth(t),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let u=o.codePointAt(c)||0;a[l++]=u,c+=u>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(M.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(M.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(M.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(M.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(M.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ts),this._charsetService.setgCharset(1,ts),this._charsetService.setgCharset(2,ts),this._charsetService.setgCharset(3,ts);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(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){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:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,m=this._optionsService.rawOptions,f=(g,v)=>(a.triggerDataEvent(`${M.ESC}[${t?"":"?"}${g};${v}$y`),!0),_=g=>g?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,_(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,_(m.convertEol)):f(p,0):p===1?f(p,_(i.applicationCursorKeys)):p===3?f(p,m.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,_(i.origin)):p===7?f(p,_(i.wraparound)):p===8?f(p,3):p===9?f(p,_(n==="X10")):p===12?f(p,_(m.cursorBlink)):p===25?f(p,_(!a.isCursorHidden)):p===45?f(p,_(i.reverseWraparound)):p===66?f(p,_(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,_(n==="VT200")):p===1002?f(p,_(n==="DRAG")):p===1003?f(p,_(n==="ANY")):p===1004?f(p,_(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,_(o==="SGR")):p===1015?f(p,4):p===1016?f(p,_(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,_(c===u)):p===2004?f(p,_(i.bracketedPasteMode)):p===2026?f(p,_(i.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=_i.fromColorRGB([s,i,n])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(n=1),i[o+l+1+n]=a[l];while(++l<a.length&&l+o+1+n<i.length);break}if(i[1]===5&&o+n>=2||i[1]===2&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=je.fg,e.bg=je.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let n=0;n<t;n++)s=e.params[n],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=je.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=je.bg&16777215):s===38||s===48||s===58?n+=this._extractColor(e,n,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=je.fg&16777215,i.bg&=-67108864,i.bg|=je.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${M.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=je.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(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!gl(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${M.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>pl&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>pl&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){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(e){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(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),n=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(vl(o))if(n==="?")t.push({type:0,index:o});else{let a=ml(n);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(o=>o.startsWith("id="));return n!==-1&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=ml(s[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let n=parseInt(s[i]);vl(n)&&t.push({type:2,index:n})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){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,ts),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(__[e[0]],De[e[1]]||ts),!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){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,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=je.clone(),this._eraseAttrDataInternal=je.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new lt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${M.ESC}${a}${M.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Vn=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(xl=e,e=t,t=xl),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Vn=we([H(0,Ve)],Vn);function vl(e){return 0<=e&&e<256}var v_=5e7,bl=12,b_=50,y_=class extends ne{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>v_)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],n=this._action(i,t);if(n){let a=l=>performance.now()-s>=bl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=bl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>b_&&(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()}},Gn=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),n=this._entriesWithId.get(i);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Gn=we([H(0,Ve)],Gn);var yl=!1,S_=class extends ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Bs),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new qg,this.optionsService=this._register(new s_(e)),this._instantiationService.setService(Ge,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Wn)),this._instantiationService.setService(Ve,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Hn)),this._instantiationService.setService(Fc,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Un)),this._instantiationService.setService(_s,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Kn)),this._instantiationService.setService(Ic,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ss)),this._instantiationService.setService(Hm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(a_),this._instantiationService.setService(Fm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Gn),this._instantiationService.setService(Hc,this._oscLinkService),this._inputHandler=this._register(new x_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new y_((t,s)=>this._inputHandler.parse(t,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.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(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!yl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),yl=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,bh),t=Math.max(t,yh),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(ul.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ul(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},w_={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:["'",'"']};function C_(e,t,s,i){var a;let n={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?n.key=M.ESC+"OA":n.key=M.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=M.ESC+"OD":n.key=M.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=M.ESC+"OC":n.key=M.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=M.ESC+"OB":n.key=M.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":M.DEL,e.altKey&&(n.key=M.ESC+n.key);break;case 9:if(e.shiftKey){n.key=M.ESC+"[Z";break}n.key=M.HT,n.cancel=!0;break;case 13:n.key=e.altKey?M.ESC+M.CR:M.CR,n.cancel=!0;break;case 27:n.key=M.ESC,e.altKey&&(n.key=M.ESC+M.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"D":t?n.key=M.ESC+"OD":n.key=M.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"C":t?n.key=M.ESC+"OC":n.key=M.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"A":t?n.key=M.ESC+"OA":n.key=M.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=M.ESC+"[1;"+(o+1)+"B":t?n.key=M.ESC+"OB":n.key=M.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=M.ESC+"[2~");break;case 46:o?n.key=M.ESC+"[3;"+(o+1)+"~":n.key=M.ESC+"[3~";break;case 36:o?n.key=M.ESC+"[1;"+(o+1)+"H":t?n.key=M.ESC+"OH":n.key=M.ESC+"[H";break;case 35:o?n.key=M.ESC+"[1;"+(o+1)+"F":t?n.key=M.ESC+"OF":n.key=M.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=M.ESC+"[5;"+(o+1)+"~":n.key=M.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=M.ESC+"[6;"+(o+1)+"~":n.key=M.ESC+"[6~";break;case 112:o?n.key=M.ESC+"[1;"+(o+1)+"P":n.key=M.ESC+"OP";break;case 113:o?n.key=M.ESC+"[1;"+(o+1)+"Q":n.key=M.ESC+"OQ";break;case 114:o?n.key=M.ESC+"[1;"+(o+1)+"R":n.key=M.ESC+"OR";break;case 115:o?n.key=M.ESC+"[1;"+(o+1)+"S":n.key=M.ESC+"OS";break;case 116:o?n.key=M.ESC+"[15;"+(o+1)+"~":n.key=M.ESC+"[15~";break;case 117:o?n.key=M.ESC+"[17;"+(o+1)+"~":n.key=M.ESC+"[17~";break;case 118:o?n.key=M.ESC+"[18;"+(o+1)+"~":n.key=M.ESC+"[18~";break;case 119:o?n.key=M.ESC+"[19;"+(o+1)+"~":n.key=M.ESC+"[19~";break;case 120:o?n.key=M.ESC+"[20;"+(o+1)+"~":n.key=M.ESC+"[20~";break;case 121:o?n.key=M.ESC+"[21;"+(o+1)+"~":n.key=M.ESC+"[21~";break;case 122:o?n.key=M.ESC+"[23;"+(o+1)+"~":n.key=M.ESC+"[23~";break;case 123:o?n.key=M.ESC+"[24;"+(o+1)+"~":n.key=M.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=M.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=M.DEL:e.keyCode===219?n.key=M.ESC:e.keyCode===220?n.key=M.FS:e.keyCode===221&&(n.key=M.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=w_[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)n.key=M.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),n.key=M.ESC+c}else if(e.keyCode===32)n.key=M.ESC+(e.ctrlKey?M.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=M.ESC+h,n.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=M.US),e.key==="@"&&(n.key=M.NUL));break}return n}var Ce=0,k_=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new lr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new lr,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[n]=e[t],t++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Ce=this._search(t),Ce===-1)||this._getKey(this._array[Ce])!==t)return!1;do if(this._array[Ce]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ce),!0;while(++Ce<this._array.length&&this._getKey(this._array[Ce])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ce=this._search(e),!(Ce<0||Ce>=this._array.length)&&this._getKey(this._array[Ce])===e))do yield this._array[Ce];while(++Ce<this._array.length&&this._getKey(this._array[Ce])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ce=this._search(e),!(Ce<0||Ce>=this._array.length)&&this._getKey(this._array[Ce])===e))do t(this._array[Ce]);while(++Ce<this._array.length&&this._getKey(this._array[Ce])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Vr=0,Sl=0,j_=class extends ne{constructor(){super(),this._decorations=new k_(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new N_(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,n=i+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,n=>{Vr=n.options.x??0,Sl=Vr+(n.options.width??1),e>=Vr&&e<Sl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},N_=class extends Vt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ye.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ye.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},E_=1e3,R_=class{constructor(e,t=E_){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=i-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},wl=20,cr=class extends ne{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new R_(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(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
196
196
  `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(X(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ve(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<wl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
197
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===wl+1&&(this._liveRegion.textContent+=mn.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=t;n++){let o=s.lines.get(s.ydisp+n),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),c=this._rowElements[n];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],n=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,m=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let _=c<f.length?f[c]:f.slice(-1)[0]+1;return _>=this._terminal.cols&&(++m,_=0),{row:m,column:_}},o=n(t),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var n,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(n=this._rowColumns.get(e))==null?void 0:n.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};cr=we([H(1,_o),H(2,Pt),H(3,Mt)],cr);var Yn=class extends ne{constructor(e,t,s,i,n){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;ds(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(X(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(X(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(X(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(X(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let n=s[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,n;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(n=this._activeProviderReplies)!=null&&n.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(m=>({link:m}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let n=t.get(i);if(n)for(let o=0;o<n.length;o++){let a=n[o],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){n.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(n=!0);if(!n&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&R_(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ds(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,n,o;(i=this._currentLink)!=null&&i.state&&((o=(n=this._currentLink)==null?void 0:n.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return s<=n&&n<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,n){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};Yn=we([H(1,xo),H(2,Mt),H(3,Ve),H(4,Uc)],Yn);function R_(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var P_=class extends S_{constructor(e={}){super(e),this._linkifier=this._register(new Ls),this.browser=ch,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ls),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(j_),this._instantiationService.setService(xi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(bg),this._instantiationService.setService(Uc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(gn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ve(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}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}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let n=ge.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${M.ESC}]${i};${g_(n)}${ah.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ne.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ne.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(cr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(X(this.element,"copy",t=>{this.hasSelection()&&Tm(t,this._selectionService)}));let e=t=>zm(t,this.textarea,this.coreService,this.optionsService);this._register(X(this.textarea,"paste",e)),this._register(X(this.element,"paste",e)),hh?this._register(X(this.element,"mousedown",t=>{t.button===2&&La(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(X(this.element,"contextmenu",t=>{La(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),jo&&this._register(X(this.element,"auxclick",t=>{t.button===1&&Tc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(X(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(X(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(X(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(X(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(X(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(X(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(X(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((n=this.element)==null?void 0:n.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(X(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",fn.get()),fh||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._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(xg,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Pt,this._coreBrowserService),this._register(X(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(X(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(An,this._document,this._helperContainer),this._instantiationService.setService(vr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Fn),this._instantiationService.setService(Ts,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(or),this._instantiationService.setService(Wc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance($n,this.rows,this.screenElement)),this._instantiationService.setService(Mt,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Bn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(On),this._instantiationService.setService(xo,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Yn,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),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._viewport=this._register(this._instantiationService.createInstance(Mn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(In,this.element,this.screenElement,i)),this._instantiationService.setService(Um,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Ln,this.screenElement)),this._register(X(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(cr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,m,f,_;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let p=o.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(o,(f=(m=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:m.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;h=p<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",n.mousemove),i.mousemove=n.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),i.wheel=n.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(X(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(X(t,"wheel",o=>{var a,l,h,c,u;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let m=M.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(m,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?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(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Bc(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}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 e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=C_(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===M.ETX||s.key===M.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(M_(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(je));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(M.ESC+"[I"):this.coreService.triggerDataEvent(M.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function M_(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var L_=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},B_=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new lt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Cl=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,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(e){let t=this._buffer.lines.get(e);if(t)return new B_(t)}getNullCell(){return new lt}},T_=class extends ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new Cl(this._core.buffers.normal,"normal"),this._alternate=new Cl(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)}},z_=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},A_=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},O_=["cols","rows"],mt=0,$_=class extends ne{constructor(e){super(),this._core=this._register(new P_(e)),this._addonManager=this._register(new L_),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,n)=>{this._checkReadonlyOptions(i),this._core.options[i]=n};for(let i in this._core.options){let n={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,n)}}_checkReadonlyOptions(e){if(O_.includes(e))throw new Error(`Option "${e}" 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 z_(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new A_(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 T_(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
197
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===wl+1&&(this._liveRegion.textContent+=mn.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=t;n++){let o=s.lines.get(s.ydisp+n),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),c=this._rowElements[n];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],n=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,m=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let _=c<f.length?f[c]:f.slice(-1)[0]+1;return _>=this._terminal.cols&&(++m,_=0),{row:m,column:_}},o=n(t),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var n,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(n=this._rowColumns.get(e))==null?void 0:n.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};cr=we([H(1,_o),H(2,Pt),H(3,Mt)],cr);var Yn=class extends ne{constructor(e,t,s,i,n){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;ds(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(X(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(X(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(X(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(X(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let n=s[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,n;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(n=this._activeProviderReplies)!=null&&n.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(m=>({link:m}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let n=t.get(i);if(n)for(let o=0;o<n.length;o++){let a=n[o],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){n.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(n=!0);if(!n&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&D_(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ds(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,n,o;(i=this._currentLink)!=null&&i.state&&((o=(n=this._currentLink)==null?void 0:n.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return s<=n&&n<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,n){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};Yn=we([H(1,xo),H(2,Mt),H(3,Ve),H(4,Uc)],Yn);function D_(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var P_=class extends S_{constructor(e={}){super(e),this._linkifier=this._register(new Bs),this.browser=ch,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Bs),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(j_),this._instantiationService.setService(xi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(bg),this._instantiationService.setService(Uc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(gn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ve(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}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}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let n=ge.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${M.ESC}]${i};${g_(n)}${ah.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ne.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ne.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(cr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(X(this.element,"copy",t=>{this.hasSelection()&&Tm(t,this._selectionService)}));let e=t=>zm(t,this.textarea,this.coreService,this.optionsService);this._register(X(this.textarea,"paste",e)),this._register(X(this.element,"paste",e)),hh?this._register(X(this.element,"mousedown",t=>{t.button===2&&La(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(X(this.element,"contextmenu",t=>{La(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),jo&&this._register(X(this.element,"auxclick",t=>{t.button===1&&Tc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(X(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(X(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(X(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(X(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(X(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(X(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(X(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((n=this.element)==null?void 0:n.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(X(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",fn.get()),fh||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._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(xg,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Pt,this._coreBrowserService),this._register(X(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(X(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(An,this._document,this._helperContainer),this._instantiationService.setService(vr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Fn),this._instantiationService.setService(Ts,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(or),this._instantiationService.setService(Wc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance($n,this.rows,this.screenElement)),this._instantiationService.setService(Mt,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Bn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(On),this._instantiationService.setService(xo,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Yn,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),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._viewport=this._register(this._instantiationService.createInstance(Mn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(In,this.element,this.screenElement,i)),this._instantiationService.setService(Um,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Ln,this.screenElement)),this._register(X(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(cr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,m,f,_;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let p=o.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(o,(f=(m=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:m.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;h=p<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",n.mousemove),i.mousemove=n.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),i.wheel=n.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(X(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(X(t,"wheel",o=>{var a,l,h,c,u;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let m=M.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(m,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?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(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Bc(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}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 e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=C_(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===M.ETX||s.key===M.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(M_(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(je));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(M.ESC+"[I"):this.coreService.triggerDataEvent(M.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function M_(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var L_=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},B_=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new lt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Cl=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,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(e){let t=this._buffer.lines.get(e);if(t)return new B_(t)}getNullCell(){return new lt}},T_=class extends ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new Cl(this._core.buffers.normal,"normal"),this._alternate=new Cl(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)}},z_=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},A_=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},O_=["cols","rows"],mt=0,$_=class extends ne{constructor(e){super(),this._core=this._register(new P_(e)),this._addonManager=this._register(new L_),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,n)=>{this._checkReadonlyOptions(i),this._core.options[i]=n};for(let i in this._core.options){let n={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,n)}}_checkReadonlyOptions(e){if(O_.includes(e))throw new Error(`Option "${e}" 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 z_(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new A_(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 T_(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
198
198
  `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return fn.get()},set promptLabel(e){fn.set(e)},get tooMuchOutput(){return mn.get()},set tooMuchOutput(e){mn.set(e)}}}_verifyIntegers(...e){for(mt of e)if(mt===1/0||isNaN(mt)||mt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(mt of e)if(mt&&(mt===1/0||isNaN(mt)||mt%1!==0||mt<0))throw new Error("This API only accepts positive integers")}};/**
199
199
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
200
200
  * @license MIT
@@ -220,14 +220,14 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
220
220
  */var W_=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=K_.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:n}=t;this._options.hover(s,i,n)}},t))}};function U_(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var K_=class Ji{static computeLink(t,s,i,n){let o=new RegExp(s.source,(s.flags||"")+"g"),[a,l]=Ji._getWindowedLineStrings(t-1,i),h=a.join(""),c,u=[];for(;c=o.exec(h);){let m=c[0];if(!U_(m))continue;let[f,_]=Ji._mapStrIdx(i,l,0,c.index),[p,g]=Ji._mapStrIdx(i,f,_,m.length);if(f===-1||_===-1||p===-1||g===-1)continue;let v={start:{x:_+1,y:f+1},end:{x:g,y:p+1}};u.push({range:v,text:m,activate:n})}return u}static _getWindowedLineStrings(t,s){let i,n=t,o=t,a=0,l="",h=[];if(i=s.buffer.active.getLine(t)){let c=i.translateToString(!0);if(i.isWrapped&&c[0]!==" "){for(a=0;(i=s.buffer.active.getLine(--n))&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););h.reverse()}for(h.push(c),a=0;(i=s.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),l.indexOf(" ")===-1););}return[h,n]}static _mapStrIdx(t,s,i,n){let o=t.buffer.active,a=o.getNullCell(),l=i;for(;n;){let h=o.getLine(s);if(!h)return[-1,-1];for(let c=l;c<h.length;++c){h.getCell(c,a);let u=a.getChars();if(a.getWidth()&&(n-=u.length||1,c===h.length-1&&u==="")){let m=o.getLine(s+1);m&&m.isWrapped&&(m.getCell(0,a),a.getWidth()===2&&(n+=1))}if(n<0)return[s,c]}s++,l=0}return[s,l]}},q_=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function V_(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var G_=class{constructor(e=V_,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,s=t.urlRegex||q_;this._linkProvider=this._terminal.registerLinkProvider(new W_(this._terminal,s,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const kl=10,Y_=1e3,X_=3e4;function J_({sessionId:e,isActive:t}){const s=d.useRef(null),i=d.useRef(null),n=d.useRef(null),o=d.useRef(null),a=d.useRef(null),l=d.useRef(!0),h=d.useRef(0),c=d.useCallback(()=>{const m=o.current,f=i.current;m&&m.readyState===WebSocket.OPEN&&f&&m.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))},[]),u=d.useCallback(()=>{if(!l.current)return;o.current&&(o.current.onclose=null,o.current.onerror=null,o.current.close(),o.current=null);const f=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${en}/ws/terminal/${e}`,_=new WebSocket(f);o.current=_,_.onopen=()=>{h.current=0;const p=i.current;p&&p.writeln("\x1B[32m-- Terminal connected --\x1B[0m");const g=n.current;if(g&&p){try{g.fit()}catch{}c()}},_.onmessage=p=>{try{const g=JSON.parse(p.data);g.type==="output"&&i.current?i.current.write(g.data):g.type==="error"&&i.current&&i.current.writeln(`\x1B[31m${g.data}\x1B[0m`)}catch{i.current&&i.current.write(p.data)}},_.onclose=p=>{if(!l.current)return;const g=i.current;if(p.code===4e3){g&&g.writeln(`\r
221
221
  \x1B[31m-- Terminal unavailable: `+(p.reason||"server rejected connection")+". --\x1B[0m");return}const v=h.current;if(v>=kl){g&&g.writeln(`\r
222
222
  \x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(Y_*Math.pow(2,v),X_);h.current=v+1,g&&g.writeln(`\r
223
- \x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${v+1}/${kl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&u()},y)},_.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const m=s.current;if(!m)return;const f=new $_({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),_=new H_,p=new G_;f.loadAddon(_),f.loadAddon(p),f.open(m),i.current=f,n.current=_;try{_.fit()}catch{}f.onData(y=>{const x=o.current;x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:y}))}),u();let g=null;const v=new ResizeObserver(()=>{g&&clearTimeout(g),g=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return v.observe(m),()=>{l.current=!1,v.disconnect(),g&&clearTimeout(g),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),f.dispose(),i.current=null,n.current=null}},[u,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const m=setTimeout(()=>{var f;try{(f=n.current)==null||f.fit(),c()}catch{}},50);return()=>clearTimeout(m)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const jl={file_created:{icon:mr,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:ee,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Ql,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:Dt,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:tr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:tr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Vl,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:ns,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:Wt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:Wt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ht,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:ql,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Nl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function Z_({event:e,isLast:t,onFileClick:s}){const i=jl[e.type]||jl.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(ct,{size:10}),Nl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(ct,{size:10}),Nl(e.timestamp)]})]})})]})}const Gr=20,El=10;function Q_({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>Gr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Kl,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>Gr&&n,l=a?e.slice(-El):e,h=a?e.length-El:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ur,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Gr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(fs,{size:12}),"Collapse older events"]}),l.map((c,u)=>r.jsx(Z_,{event:c,isLast:u===l.length-1,onFileClick:t},c.id))]})}const Dl=[{id:"terminal",label:"Terminal",icon:ns,alwaysShow:!0},{id:"activity",label:"Activity",icon:Md,alwaysShow:!0},{id:"build",label:"Build Log",icon:Cu},{id:"agents",label:"Agents",icon:Ld},{id:"quality",label:"Quality",icon:Gl}];function ex({status:e}){switch(e){case"pass":return r.jsx(Gt,{size:14,className:"text-success"});case"fail":return r.jsx(_t,{size:14,className:"text-danger"});default:return r.jsx(ct,{size:14,className:"text-muted"})}}function tx({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(_d,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function sx({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(Gl,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(ex,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function ix({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var g;const[c,u]=d.useState("terminal"),m=s&&s.length>0,f=i&&i.items&&i.items.length>0,_=e&&e.length>0,p=Dl.filter(v=>!!(v.alwaysShow||v.id==="build"&&(_||o)||v.id==="agents"&&(m||o)||v.id==="quality"&&(f||o)));return p.find(v=>v.id===c)||u("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:p.map(v=>{const y=v.icon,x=c===v.id;return r.jsxs("button",{role:"tab","aria-selected":x,onClick:()=>u(v.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${x?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),v.label,v.id==="agents"&&m&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),v.id==="quality"&&f&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},v.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(g=Dl.find(v=>v.id===c))==null?void 0:g.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(J_,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Rd,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(tx,{agents:s}),c==="activity"&&r.jsx(Q_,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(sx,{checklist:i})]})]})}const Rl={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Setting things up...","Installing dependencies...","Compiling your project...","Running the build pipeline...","Finishing touches..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function rx({context:e="general",className:t=""}){const s=Rl[e]||Rl.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(pi,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const Yr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:Jd},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Bd},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ni},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:os},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:Dt}];function nx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(0),[h,c]=d.useState(e),[u,m]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){m(!0);const x=setTimeout(()=>{c(e),m(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const f=Yr.findIndex(x=>x.id===e),_=s>0?Math.min(t/s*100,100):0,p=t>0?a/t:60,g=Math.max(0,s-t),v=Math.ceil(p*g),y=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${_}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${u?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Yr.map((x,C)=>{const j=C<f,w=C===f,D=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${w?"phase-indicator-active":""} ${j?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${w?"phase-icon-active":""} ${j?"phase-icon-complete":""}`,children:j?r.jsx(Dt,{size:14,className:"text-success phase-check-enter"}):w?r.jsx(D,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(D,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${w?"text-ink":j?"text-success":"text-muted/50"}`,children:x.label}),C<Yr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${j?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(rx,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(is,{size:12}),"Iter ",t,"/",s]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ct,{size:12}),y(a),o&&v>0&&r.jsxs("span",{className:"text-muted/60",children:["(",y(v)," left)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ec,{size:12}),"$",i.toFixed(2)]})]})]})]})}const Xr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function ox({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(u){l(u instanceof Error?u.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
223
+ \x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${v+1}/${kl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&u()},y)},_.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const m=s.current;if(!m)return;const f=new $_({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),_=new H_,p=new G_;f.loadAddon(_),f.loadAddon(p),f.open(m),i.current=f,n.current=_;try{_.fit()}catch{}f.onData(y=>{const x=o.current;x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:y}))}),u();let g=null;const v=new ResizeObserver(()=>{g&&clearTimeout(g),g=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return v.observe(m),()=>{l.current=!1,v.disconnect(),g&&clearTimeout(g),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),f.dispose(),i.current=null,n.current=null}},[u,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const m=setTimeout(()=>{var f;try{(f=n.current)==null||f.fit(),c()}catch{}},50);return()=>clearTimeout(m)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const jl={file_created:{icon:mr,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:ee,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Ql,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:Rt,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:tr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:tr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Vl,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:ns,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:Wt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:Wt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ht,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:ql,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Nl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function Z_({event:e,isLast:t,onFileClick:s}){const i=jl[e.type]||jl.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(ct,{size:10}),Nl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(ct,{size:10}),Nl(e.timestamp)]})]})})]})}const Gr=20,El=10;function Q_({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>Gr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Kl,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>Gr&&n,l=a?e.slice(-El):e,h=a?e.length-El:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ur,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Gr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(fs,{size:12}),"Collapse older events"]}),l.map((c,u)=>r.jsx(Z_,{event:c,isLast:u===l.length-1,onFileClick:t},c.id))]})}const Rl=[{id:"terminal",label:"Terminal",icon:ns,alwaysShow:!0},{id:"activity",label:"Activity",icon:Md,alwaysShow:!0},{id:"build",label:"Build Log",icon:Cu},{id:"agents",label:"Agents",icon:Ld},{id:"quality",label:"Quality",icon:Gl}];function ex({status:e}){switch(e){case"pass":return r.jsx(Gt,{size:14,className:"text-success"});case"fail":return r.jsx(_t,{size:14,className:"text-danger"});default:return r.jsx(ct,{size:14,className:"text-muted"})}}function tx({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(_d,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function sx({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(Gl,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(ex,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function ix({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var g;const[c,u]=d.useState("terminal"),m=s&&s.length>0,f=i&&i.items&&i.items.length>0,_=e&&e.length>0,p=Rl.filter(v=>!!(v.alwaysShow||v.id==="build"&&(_||o)||v.id==="agents"&&(m||o)||v.id==="quality"&&(f||o)));return p.find(v=>v.id===c)||u("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:p.map(v=>{const y=v.icon,x=c===v.id;return r.jsxs("button",{role:"tab","aria-selected":x,onClick:()=>u(v.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${x?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),v.label,v.id==="agents"&&m&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),v.id==="quality"&&f&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},v.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(g=Rl.find(v=>v.id===c))==null?void 0:g.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(J_,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Dd,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(tx,{agents:s}),c==="activity"&&r.jsx(Q_,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(sx,{checklist:i})]})]})}const Dl={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Setting things up...","Installing dependencies...","Compiling your project...","Running the build pipeline...","Finishing touches..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function rx({context:e="general",className:t=""}){const s=Dl[e]||Dl.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(pi,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const Yr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:Jd},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Bd},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ni},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:os},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:Rt}];function nx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(0),[h,c]=d.useState(e),[u,m]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){m(!0);const x=setTimeout(()=>{c(e),m(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const f=Yr.findIndex(x=>x.id===e),_=s>0?Math.min(t/s*100,100):0,p=t>0?a/t:60,g=Math.max(0,s-t),v=Math.ceil(p*g),y=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${_}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${u?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Yr.map((x,C)=>{const j=C<f,w=C===f,R=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${w?"phase-indicator-active":""} ${j?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${w?"phase-icon-active":""} ${j?"phase-icon-complete":""}`,children:j?r.jsx(Rt,{size:14,className:"text-success phase-check-enter"}):w?r.jsx(R,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(R,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${w?"text-ink":j?"text-success":"text-muted/50"}`,children:x.label}),C<Yr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${j?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(rx,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(is,{size:12}),"Iter ",t,"/",s]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ct,{size:12}),y(a),o&&v>0&&r.jsxs("span",{className:"text-muted/60",children:["(",y(v)," left)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ec,{size:12}),"$",i.toFixed(2)]})]})]})]})}const Xr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function ox({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(u){l(u instanceof Error?u.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
224
224
  focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary
225
- placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(as,{size:10})]}),r.jsx(he,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(Bs,{size:12}),a]})]})}function ax(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(ns,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(as,{size:10})]})]})}function lx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async u=>{await s(u),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(Dt,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(he,{variant:"danger",size:"sm",icon:Au,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsx(r.Fragment,{children:e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsxs(he,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:["Connect ",e.name]})}),n&&r.jsx(ox,{platform:e,onConnect:c})]}):r.jsx(ax,{})})]})}function cx({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const p=await W.getDeployStatus();i(p),t==null||t(p),l(null)}catch(p){l(p instanceof Error?p.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const p=setInterval(h,3e4);return()=>clearInterval(p)},[h]);const c=d.useCallback(async p=>{const g=await W.connectVercel(p);g.success&&(i(v=>({...v,vercel:{connected:!0,user:g.user}})),t==null||t({...s,vercel:{connected:!0,user:g.user}}))},[s,t]),u=d.useCallback(async p=>{const g=await W.connectNetlify(p);g.success&&(i(v=>({...v,netlify:{connected:!0,user:g.user}})),t==null||t({...s,netlify:{connected:!0,user:g.user}}))},[s,t]),m=d.useCallback(async p=>{await W.disconnectPlatform(p),i(v=>({...v,[p]:{connected:!1}}));const g={...s,[p]:{connected:!1}};t==null||t(g)},[s,t]),f={vercel:c,netlify:u,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(pi,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const _=[s.vercel,s.netlify,s.github].filter(p=>p.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[_," of ",Xr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(bt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Xr.map(p=>{const g=s[p.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${p.name}: ${g.connected?`Connected as ${g.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${g.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:p.name})]},p.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(Bs,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Xr.map(p=>r.jsx(lx,{platform:p,status:s[p.id],onConnect:f[p.id],onDisconnect:()=>m(p.id)},p.id))})]})}const hx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:sn,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:sn,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:ze,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function dx({platform:e,deployState:t,onDeploy:s,disabled:i,connected:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=i||!n;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n?"hover:border-primary/30 hover:bg-hover":"opacity-60"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${n?"bg-green-500":"bg-gray-300"}`,title:n?"Connected":"Not connected"})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(he,{variant:"secondary",size:"sm",icon:Wt,onClick:s,disabled:c,className:"w-full",children:["Deploy to ",e.name]}),!n&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(pi,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(Dt,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(sn,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Gt,{size:12,className:"text-green-500"}):r.jsx(to,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(as,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Bs,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(he,{variant:"secondary",size:"sm",icon:Wt,onClick:s,disabled:c,className:"w-full",children:"Retry"})]})]})}function ux({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await W.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(ze,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(pi,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(Dt,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(ze,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Gt,{size:12,className:"text-green-500"}):r.jsx(to,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Bs,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function fx({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[o,a]=d.useState(!1),l=Object.values(t).some(u=>u.status==="deploying"),h=d.useCallback(async u=>{s(m=>({...m,[u]:{status:"deploying"}}));try{const m=await W.deployProject(e,u);m.url?s(f=>({...f,[u]:{status:"success",url:m.url}})):s(f=>({...f,[u]:{status:"error",error:m.error||"Deploy failed"}}))}catch(m){s(f=>({...f,[u]:{status:"error",error:m instanceof Error?m.message:"Deploy failed"}}))}},[e]),c=u=>{var m;return((m=i[u.connectionKey])==null?void 0:m.connected)??!1};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx(Wt,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(!o),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lc,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:["vercel","netlify","github"].map(u=>{var m,f;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(m=i[u])!=null&&m.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(f=i[u])!=null&&f.connected?"Connected":"Not connected"}`},u)})})]}),r.jsx("span",{className:"text-xs text-muted",children:o?"Hide":"Manage"})]}),o&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(cx,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:hx.map(u=>r.jsx(dx,{platform:u,deployState:t[u.id],onDeploy:()=>h(u.id),disabled:l,connected:c(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(ux,{sessionId:e,disabled:l})]})})}const wh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Nt=wh?"Cmd":"Ctrl",Pl=[{keys:[`${Nt}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${Nt}+P`],label:"Quick open file",category:"navigation"},{keys:[`${Nt}+,`],label:"Open settings",category:"navigation"},{keys:[`${Nt}+S`],label:"Save file",category:"editor"},{keys:[`${Nt}+Z`],label:"Undo",category:"editor"},{keys:[`${Nt}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${Nt}+B`],label:"Start / stop build",category:"build"},{keys:[`${Nt}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${Nt}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],mx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},px=["navigation","editor","build","general"];function gx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,u;const a=wh?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((u=o.target)==null?void 0:u.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(m=>!m);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(m=>!m);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function _x({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Pl;const a=s.toLowerCase();return Pl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(xd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(_t,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(os,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[px.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:mx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function xx({onClick:e}){return r.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}const Ch="pl_recent_commands",vx=5;function kh(){try{const e=localStorage.getItem(Ch);return e?JSON.parse(e):[]}catch{return[]}}function Jr(e){try{const t=kh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(Ch,JSON.stringify(t.slice(0,vx)))}catch{}}function bx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:ee,ts:ee,tsx:ee,jsx:ee,py:ee,go:ee,rs:ee,rb:ee,sh:ee,html:ac,css:ro,json:io,md:mi}[t]||no}function yx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Ml({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function Sx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,u]=d.useState([]),[m,f]=d.useState(!1),_=d.useRef(null),p=d.useRef(null),g=vd(e);bd(e,t),d.useEffect(()=>{e&&(a(""),h(0),u([]),f(!1),setTimeout(()=>{var S;return(S=_.current)==null?void 0:S.focus()},50))},[e]);const v=d.useMemo(()=>kh().map(N=>s.find(k=>k.id===N)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(N=>({cmd:N,indices:[]}));const S=[];for(const N of s){const k=yx(o,N.label);if(k){const P=k[0]*10+(k[k.length-1]-k[0]);S.push({cmd:N,indices:k,score:P})}}return S.sort((N,k)=>N.score-k.score),S.map(N=>({cmd:N.cmd,indices:N.indices}))},[s,o]),x=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),C=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){u([]),f(!1);return}return f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{const S=await W.searchFiles(i,o);u(S.filter(N=>N.type==="file"))}catch{u([])}f(!1)},200),()=>{p.current&&clearTimeout(p.current)}},[o,i]);const j=!o.trim()&&v.length>0,w=d.useMemo(()=>{const S=[];return j&&v.forEach((N,k)=>S.push({type:"recent",index:k})),C.forEach((N,k)=>S.push({type:"command",index:k})),x.length>0&&x.forEach((N,k)=>S.push({type:"setting",index:k})),c.forEach((N,k)=>S.push({type:"file",index:k})),S},[j,v,C,x,c]),D=w.length;d.useEffect(()=>{h(0)},[o]);const B=d.useCallback(S=>{const N=w[S];if(N){if(N.type==="recent"){const k=v[N.index];k&&(Jr(k.id),k.action(),t())}else if(N.type==="command"){const k=C[N.index];k&&(Jr(k.cmd.id),k.cmd.action(),t())}else if(N.type==="setting"){const k=x[N.index];k&&(Jr(k.cmd.id),k.cmd.action(),t())}else if(N.type==="file"){const k=c[N.index];k&&n&&(n(k.path,k.name),t())}}},[w,v,C,x,c,n,t]),U=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(N=>Math.min(N+1,D-1))):S.key==="ArrowUp"?(S.preventDefault(),h(N=>Math.max(N-1,0))):S.key==="Enter"&&D>0?B(l):S.key==="Escape"&&t()},[D,l,B,t]);if(!e)return null;let G=0;const K=()=>G++,A=C.length>0,R=x.length>0,E=c.length>0,L=m&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:g,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(os,{size:18,className:"text-muted"}),r.jsx("input",{ref:_,value:o,onChange:S=>a(S.target.value),onKeyDown:U,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[j&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(ct,{size:10})," Recent"]}),v.map((S,N)=>{const k=K(),P=S.icon;return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),A&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),C.map((S,N)=>{const k=K(),P=S.cmd.icon;return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Ml,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),R&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),x.map((S,N)=>{const k=K(),P=S.cmd.icon;return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Ml,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,N)=>{const k=K(),P=S.type==="directory"?oo:bx(S.name);return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),L&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),D===0&&!L&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const wx=d.lazy(()=>Qn(()=>import("./GitHubIssuesPanel-DyuNDMgD.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),Cx=d.lazy(()=>Qn(()=>import("./GitHubPRsPanel-BtAq20xF.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,9,23,24,25,26,27,28,29,30,8,31,32,33,34,35,36,37,38])).then(e=>({default:e.GitHubPRsPanel}))),kx=d.lazy(()=>Qn(()=>Promise.resolve().then(()=>Wx),void 0).then(e=>({default:e.CICDPanel}))),jx=3e4,Nx={modified:r.jsx(ee,{size:13,className:"text-yellow-500"}),added:r.jsx(mr,{size:13,className:"text-green-500"}),deleted:r.jsx(so,{size:13,className:"text-red-400"}),renamed:r.jsx(ee,{size:13,className:"text-blue-400"}),untracked:r.jsx(tc,{size:13,className:"text-muted"})},Ex={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Dx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(sc,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(ze,{size:9}),t]},s))})]})]})})}function Ll({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Nx[e.status]||r.jsx(tc,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Ex[e.status]||"?"})]})}function Rx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,u]=d.useState(!0),[m,f]=d.useState(null),[_,p]=d.useState(""),[g,v]=d.useState(!1),[y,x]=d.useState(null),[C,j]=d.useState(!1),[w,D]=d.useState(""),[B,U]=d.useState(!1),[G,K]=d.useState(!1),[A,R]=d.useState(""),[E,L]=d.useState(""),[S,N]=d.useState(!1),[k,P]=d.useState(null),[J,oe]=d.useState(!1),V=d.useCallback(async()=>{u(!0),f(null);try{const[z,xe,T]=await Promise.all([W.git.status(e),W.git.log(e),W.git.branches(e)]);n(z),a(xe),h(T)}catch(z){f(z instanceof Error?z.message:"Failed to load git data")}u(!1)},[e]);d.useEffect(()=>{V()},[V]);const Z=async()=>{if(!(!_.trim()||g)){v(!0),x(null);try{const z=await W.git.commit(e,_.trim());x(`Committed: ${z.hash}`),p(""),await V()}catch(z){x(`Error: ${z instanceof Error?z.message:"Commit failed"}`)}v(!1)}},ie=async()=>{if(!(!w.trim()||B)){U(!0);try{await W.git.createBranch(e,w.trim()),D(""),j(!1),await V()}catch(z){f(z instanceof Error?z.message:"Branch creation failed")}U(!1)}},ue=async z=>{try{await W.git.checkoutBranch(e,z),await V()}catch(xe){f(xe instanceof Error?xe.message:"Checkout failed")}},fe=async()=>{oe(!0);try{await W.git.push(e),await V()}catch(z){f(z instanceof Error?z.message:"Push failed")}oe(!1)},de=async()=>{if(!(!A.trim()||S)){N(!0),P(null);try{const z=await W.git.pr(e,A.trim(),E.trim());P(z.url),R(""),L(""),K(!1)}catch(z){P(`Error: ${z instanceof Error?z.message:"PR creation failed"}`)}N(!1)}},_e=(i==null?void 0:i.files.filter(z=>z.staged))||[],He=(i==null?void 0:i.files.filter(z=>!z.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):m&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(Bs,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:m}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(he,{size:"sm",variant:"secondary",icon:bt,onClick:V,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(ze,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Gt,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:V,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:ee,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:ct},{id:"branches",label:"Branches",icon:ze,count:l.length}].map(z=>r.jsxs("button",{onClick:()=>s(z.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===z.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(z.icon,{size:12}),z.label,z.count!==void 0&&z.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:z.count})]},z.id))}),m&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:m}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Gt,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[_e.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",_e.length,")"]}),_e.map((z,xe)=>r.jsx(Ll,{file:z},`s-${xe}`))]}),He.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",He.length,")"]}),He.map((z,xe)=>r.jsx(Ll,{file:z},`u-${xe}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:_,onChange:z=>p(z.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(he,{size:"sm",icon:sc,onClick:Z,disabled:!_.trim()||g,loading:g,children:"Commit"}),r.jsx(he,{size:"sm",variant:"secondary",icon:ic,onClick:fe,loading:J,disabled:J,children:"Push"}),r.jsx(he,{size:"sm",variant:"ghost",icon:rn,onClick:()=>K(!G),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),k&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:k.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:k}):r.jsx("a",{href:k,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:k})})]}),G&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:A,onChange:z=>R(z.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:z=>L(z.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(he,{size:"sm",icon:rn,onClick:de,disabled:!A.trim()||S,loading:S,children:"Create PR"}),r.jsx(he,{size:"sm",variant:"ghost",onClick:()=>K(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ct,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((z,xe)=>r.jsx(Dx,{commit:z},xe))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>j(!C),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(pr,{size:12}),"New Branch"]})}),C&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:z=>D(z.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:z=>{z.key==="Enter"&&ie()}}),r.jsx(he,{size:"sm",onClick:ie,disabled:!w.trim()||B,loading:B,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ze,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(z=>!z.remote).map((z,xe)=>r.jsxs("button",{onClick:()=>!z.current&&ue(z.name),disabled:z.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${z.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(ze,{size:13,className:z.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${z.current?"text-primary font-semibold":"text-ink"}`,children:z.name}),z.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${xe}`)),l.filter(z=>z.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(z=>z.remote).map((z,xe)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(ze,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:z.name})]},`r-${xe}`))]})]})]})]})]})}function Zr(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function Qr({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await W.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(ou,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(he,{size:"sm",icon:ic,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function Px({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({issues:0,prs:0,actions:0,fetchedAt:0}),c=d.useRef(!1),u=d.useCallback(async()=>{n(!0);try{const g=await W.getStatus();a({has_remote:!0,repo:"",owner:""})}catch{a({has_remote:!1})}n(!1)},[e]);d.useEffect(()=>{u()},[u]);const m=d.useCallback(async()=>{if(!(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<jx)&&!c.current){c.current=!0;try{const[v,y,x]=await Promise.allSettled([W.getGitHubIssues(e,"open",1),W.getGitHubPRs(e,"open",1),W.getWorkflowRuns(e,5)]);h({issues:v.status==="fulfilled"?v.value.length:0,prs:y.status==="fulfilled"?y.value.length:0,actions:x.status==="fulfilled"?x.value.filter(C=>C.status==="in_progress").length:0,fetchedAt:Date.now()})}catch{}c.current=!1}},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&m()},[o==null?void 0:o.has_remote,m]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&m()},[t,o==null?void 0:o.has_remote,m]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const f=(o==null?void 0:o.has_remote)??!1,_=[{id:"changes",label:"Changes",icon:ee,requiresRemote:!1},{id:"issues",label:"Issues",icon:Td,count:l.issues,requiresRemote:!0},{id:"prs",label:"PRs",icon:rn,count:l.prs,requiresRemote:!0},{id:"actions",label:"Actions",icon:Ut,count:l.actions,requiresRemote:!0}],p=_;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[p.map(g=>{const v=g.requiresRemote&&!f;return r.jsxs("button",{onClick:()=>s(g.id),disabled:v,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===g.id?"bg-primary/10 text-primary":v?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:v?"Connect to GitHub to access this tab":void 0,children:[r.jsx(g.icon,{size:12}),g.label,g.count!==void 0&&g.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:g.count})]},g.id)}),f&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(lc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Rx,{sessionId:e}),t==="issues"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Zr,{}),children:r.jsx(wx,{sessionId:e})}):r.jsx(Qr,{sessionId:e,onPushed:u})),t==="prs"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Zr,{}),children:r.jsx(Cx,{sessionId:e})}):r.jsx(Qr,{sessionId:e,onPushed:u})),t==="actions"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Zr,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kx,{sessionId:e})})}):r.jsx(Qr,{sessionId:e,onPushed:u}))]})]})}function Mx({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(null),f=d.useCallback(async()=>{try{const g=await W.getCheckpoints(e);i(g),m(null)}catch{m("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{f();const g=setInterval(f,15e3);return()=>clearInterval(g)},[f]);const _=d.useCallback(async g=>{if(a)return;const v=s.find(x=>x.id===g);if(!(!v||!window.confirm(`Restore to checkpoint "${v.description}"?
225
+ placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(as,{size:10})]}),r.jsx(he,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(ms,{size:12}),a]})]})}function ax(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(ns,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(as,{size:10})]})]})}function lx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async u=>{await s(u),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(Rt,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(he,{variant:"danger",size:"sm",icon:Au,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsxs(r.Fragment,{children:[t.error&&r.jsxs("div",{className:"mt-3 flex items-start gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(ms,{size:14,className:"text-red-500 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"text-xs text-red-600",children:t.error})]}),e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsx(he,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:t.error?`Reconnect ${e.name}`:`Connect ${e.name}`})}),n&&r.jsx(ox,{platform:e,onConnect:c})]}):r.jsx(ax,{})]})]})}function cx({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const p=await W.getDeployStatus();i(p),t==null||t(p),l(null)}catch(p){l(p instanceof Error?p.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const p=setInterval(h,3e4);return()=>clearInterval(p)},[h]);const c=d.useCallback(async p=>{const g=await W.connectVercel(p);g.success&&(i(v=>({...v,vercel:{connected:!0,user:g.user}})),t==null||t({...s,vercel:{connected:!0,user:g.user}}))},[s,t]),u=d.useCallback(async p=>{const g=await W.connectNetlify(p);g.success&&(i(v=>({...v,netlify:{connected:!0,user:g.user}})),t==null||t({...s,netlify:{connected:!0,user:g.user}}))},[s,t]),m=d.useCallback(async p=>{await W.disconnectPlatform(p),i(v=>({...v,[p]:{connected:!1}}));const g={...s,[p]:{connected:!1}};t==null||t(g)},[s,t]),f={vercel:c,netlify:u,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(pi,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const _=[s.vercel,s.netlify,s.github].filter(p=>p.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[_," of ",Xr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(bt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Xr.map(p=>{const g=s[p.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${p.name}: ${g.connected?`Connected as ${g.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${g.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:p.name})]},p.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(ms,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Xr.map(p=>r.jsx(lx,{platform:p,status:s[p.id],onConnect:f[p.id],onDisconnect:()=>m(p.id)},p.id))})]})}const hx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:sn,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:sn,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:ze,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function dx({platform:e,deployState:t,onDeploy:s,disabled:i,connected:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=i||!n;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n?"hover:border-primary/30 hover:bg-hover":"opacity-60"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${n?"bg-green-500":"bg-gray-300"}`,title:n?"Connected":"Not connected"})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(he,{variant:"secondary",size:"sm",icon:Wt,onClick:s,disabled:c,className:"w-full",children:["Deploy to ",e.name]}),!n&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(pi,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(Rt,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(sn,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Gt,{size:12,className:"text-green-500"}):r.jsx(to,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(as,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(ms,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(he,{variant:"secondary",size:"sm",icon:Wt,onClick:s,disabled:c,className:"w-full",children:"Retry"})]})]})}function ux({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await W.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(ze,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(pi,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(Rt,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(ze,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Gt,{size:12,className:"text-green-500"}):r.jsx(to,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(ms,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function fx({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[o,a]=d.useState(!1),l=Object.values(t).some(u=>u.status==="deploying"),h=d.useCallback(async u=>{s(m=>({...m,[u]:{status:"deploying"}}));try{const m=await W.deployProject(e,u);m.url?s(f=>({...f,[u]:{status:"success",url:m.url}})):s(f=>({...f,[u]:{status:"error",error:m.error||"Deploy failed"}}))}catch(m){s(f=>({...f,[u]:{status:"error",error:m instanceof Error?m.message:"Deploy failed"}}))}},[e]),c=u=>{var m;return((m=i[u.connectionKey])==null?void 0:m.connected)??!1};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx(Wt,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(!o),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lc,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:["vercel","netlify","github"].map(u=>{var m,f;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(m=i[u])!=null&&m.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(f=i[u])!=null&&f.connected?"Connected":"Not connected"}`},u)})})]}),r.jsx("span",{className:"text-xs text-muted",children:o?"Hide":"Manage"})]}),o&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(cx,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:hx.map(u=>r.jsx(dx,{platform:u,deployState:t[u.id],onDeploy:()=>h(u.id),disabled:l,connected:c(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(ux,{sessionId:e,disabled:l})]})})}const wh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Nt=wh?"Cmd":"Ctrl",Pl=[{keys:[`${Nt}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${Nt}+P`],label:"Quick open file",category:"navigation"},{keys:[`${Nt}+,`],label:"Open settings",category:"navigation"},{keys:[`${Nt}+S`],label:"Save file",category:"editor"},{keys:[`${Nt}+Z`],label:"Undo",category:"editor"},{keys:[`${Nt}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${Nt}+B`],label:"Start / stop build",category:"build"},{keys:[`${Nt}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${Nt}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],mx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},px=["navigation","editor","build","general"];function gx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,u;const a=wh?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((u=o.target)==null?void 0:u.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(m=>!m);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(m=>!m);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function _x({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Pl;const a=s.toLowerCase();return Pl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(xd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(_t,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(os,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[px.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:mx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function xx({onClick:e}){return r.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}const Ch="pl_recent_commands",vx=5;function kh(){try{const e=localStorage.getItem(Ch);return e?JSON.parse(e):[]}catch{return[]}}function Jr(e){try{const t=kh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(Ch,JSON.stringify(t.slice(0,vx)))}catch{}}function bx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:ee,ts:ee,tsx:ee,jsx:ee,py:ee,go:ee,rs:ee,rb:ee,sh:ee,html:ac,css:ro,json:io,md:mi}[t]||no}function yx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Ml({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function Sx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,u]=d.useState([]),[m,f]=d.useState(!1),_=d.useRef(null),p=d.useRef(null),g=vd(e);bd(e,t),d.useEffect(()=>{e&&(a(""),h(0),u([]),f(!1),setTimeout(()=>{var S;return(S=_.current)==null?void 0:S.focus()},50))},[e]);const v=d.useMemo(()=>kh().map(N=>s.find(k=>k.id===N)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(N=>({cmd:N,indices:[]}));const S=[];for(const N of s){const k=yx(o,N.label);if(k){const P=k[0]*10+(k[k.length-1]-k[0]);S.push({cmd:N,indices:k,score:P})}}return S.sort((N,k)=>N.score-k.score),S.map(N=>({cmd:N.cmd,indices:N.indices}))},[s,o]),x=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),C=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){u([]),f(!1);return}return f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{const S=await W.searchFiles(i,o);u(S.filter(N=>N.type==="file"))}catch{u([])}f(!1)},200),()=>{p.current&&clearTimeout(p.current)}},[o,i]);const j=!o.trim()&&v.length>0,w=d.useMemo(()=>{const S=[];return j&&v.forEach((N,k)=>S.push({type:"recent",index:k})),C.forEach((N,k)=>S.push({type:"command",index:k})),x.length>0&&x.forEach((N,k)=>S.push({type:"setting",index:k})),c.forEach((N,k)=>S.push({type:"file",index:k})),S},[j,v,C,x,c]),R=w.length;d.useEffect(()=>{h(0)},[o]);const B=d.useCallback(S=>{const N=w[S];if(N){if(N.type==="recent"){const k=v[N.index];k&&(Jr(k.id),k.action(),t())}else if(N.type==="command"){const k=C[N.index];k&&(Jr(k.cmd.id),k.cmd.action(),t())}else if(N.type==="setting"){const k=x[N.index];k&&(Jr(k.cmd.id),k.cmd.action(),t())}else if(N.type==="file"){const k=c[N.index];k&&n&&(n(k.path,k.name),t())}}},[w,v,C,x,c,n,t]),U=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(N=>Math.min(N+1,R-1))):S.key==="ArrowUp"?(S.preventDefault(),h(N=>Math.max(N-1,0))):S.key==="Enter"&&R>0?B(l):S.key==="Escape"&&t()},[R,l,B,t]);if(!e)return null;let G=0;const K=()=>G++,A=C.length>0,D=x.length>0,E=c.length>0,L=m&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:g,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(os,{size:18,className:"text-muted"}),r.jsx("input",{ref:_,value:o,onChange:S=>a(S.target.value),onKeyDown:U,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[j&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(ct,{size:10})," Recent"]}),v.map((S,N)=>{const k=K(),P=S.icon;return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),A&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),C.map((S,N)=>{const k=K(),P=S.cmd.icon;return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Ml,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),D&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),x.map((S,N)=>{const k=K(),P=S.cmd.icon;return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Ml,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,N)=>{const k=K(),P=S.type==="directory"?oo:bx(S.name);return r.jsxs("button",{onClick:()=>B(k),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${k===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(P,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),L&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),R===0&&!L&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const wx=d.lazy(()=>Qn(()=>import("./GitHubIssuesPanel-DD8c6RVj.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),Cx=d.lazy(()=>Qn(()=>import("./GitHubPRsPanel-4NawTXRl.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,9,23,24,25,26,27,28,29,8,30,31,32,33,34,35,36])).then(e=>({default:e.GitHubPRsPanel}))),kx=d.lazy(()=>Qn(()=>Promise.resolve().then(()=>Wx),void 0).then(e=>({default:e.CICDPanel}))),jx=3e4,Nx={modified:r.jsx(ee,{size:13,className:"text-yellow-500"}),added:r.jsx(mr,{size:13,className:"text-green-500"}),deleted:r.jsx(so,{size:13,className:"text-red-400"}),renamed:r.jsx(ee,{size:13,className:"text-blue-400"}),untracked:r.jsx(sc,{size:13,className:"text-muted"})},Ex={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Rx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(tc,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(ze,{size:9}),t]},s))})]})]})})}function Ll({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Nx[e.status]||r.jsx(sc,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Ex[e.status]||"?"})]})}function Dx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,u]=d.useState(!0),[m,f]=d.useState(null),[_,p]=d.useState(""),[g,v]=d.useState(!1),[y,x]=d.useState(null),[C,j]=d.useState(!1),[w,R]=d.useState(""),[B,U]=d.useState(!1),[G,K]=d.useState(!1),[A,D]=d.useState(""),[E,L]=d.useState(""),[S,N]=d.useState(!1),[k,P]=d.useState(null),[J,oe]=d.useState(!1),V=d.useCallback(async()=>{u(!0),f(null);try{const[z,xe,T]=await Promise.all([W.git.status(e),W.git.log(e),W.git.branches(e)]);n(z),a(xe),h(T)}catch(z){f(z instanceof Error?z.message:"Failed to load git data")}u(!1)},[e]);d.useEffect(()=>{V()},[V]);const Z=async()=>{if(!(!_.trim()||g)){v(!0),x(null);try{const z=await W.git.commit(e,_.trim());x(`Committed: ${z.hash}`),p(""),await V()}catch(z){x(`Error: ${z instanceof Error?z.message:"Commit failed"}`)}v(!1)}},ie=async()=>{if(!(!w.trim()||B)){U(!0);try{await W.git.createBranch(e,w.trim()),R(""),j(!1),await V()}catch(z){f(z instanceof Error?z.message:"Branch creation failed")}U(!1)}},ue=async z=>{try{await W.git.checkoutBranch(e,z),await V()}catch(xe){f(xe instanceof Error?xe.message:"Checkout failed")}},fe=async()=>{oe(!0);try{await W.git.push(e),await V()}catch(z){f(z instanceof Error?z.message:"Push failed")}oe(!1)},de=async()=>{if(!(!A.trim()||S)){N(!0),P(null);try{const z=await W.git.pr(e,A.trim(),E.trim());P(z.url),D(""),L(""),K(!1)}catch(z){P(`Error: ${z instanceof Error?z.message:"PR creation failed"}`)}N(!1)}},_e=(i==null?void 0:i.files.filter(z=>z.staged))||[],He=(i==null?void 0:i.files.filter(z=>!z.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):m&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(ms,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:m}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(he,{size:"sm",variant:"secondary",icon:bt,onClick:V,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(ze,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Gt,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:V,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:ee,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:ct},{id:"branches",label:"Branches",icon:ze,count:l.length}].map(z=>r.jsxs("button",{onClick:()=>s(z.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===z.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(z.icon,{size:12}),z.label,z.count!==void 0&&z.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:z.count})]},z.id))}),m&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:m}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Gt,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[_e.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",_e.length,")"]}),_e.map((z,xe)=>r.jsx(Ll,{file:z},`s-${xe}`))]}),He.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",He.length,")"]}),He.map((z,xe)=>r.jsx(Ll,{file:z},`u-${xe}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:_,onChange:z=>p(z.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(he,{size:"sm",icon:tc,onClick:Z,disabled:!_.trim()||g,loading:g,children:"Commit"}),r.jsx(he,{size:"sm",variant:"secondary",icon:ic,onClick:fe,loading:J,disabled:J,children:"Push"}),r.jsx(he,{size:"sm",variant:"ghost",icon:nn,onClick:()=>K(!G),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),k&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:k.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:k}):r.jsx("a",{href:k,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:k})})]}),G&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:A,onChange:z=>D(z.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:z=>L(z.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(he,{size:"sm",icon:nn,onClick:de,disabled:!A.trim()||S,loading:S,children:"Create PR"}),r.jsx(he,{size:"sm",variant:"ghost",onClick:()=>K(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ct,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((z,xe)=>r.jsx(Rx,{commit:z},xe))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>j(!C),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(pr,{size:12}),"New Branch"]})}),C&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:z=>R(z.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:z=>{z.key==="Enter"&&ie()}}),r.jsx(he,{size:"sm",onClick:ie,disabled:!w.trim()||B,loading:B,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ze,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(z=>!z.remote).map((z,xe)=>r.jsxs("button",{onClick:()=>!z.current&&ue(z.name),disabled:z.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${z.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(ze,{size:13,className:z.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${z.current?"text-primary font-semibold":"text-ink"}`,children:z.name}),z.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${xe}`)),l.filter(z=>z.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(z=>z.remote).map((z,xe)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(ze,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:z.name})]},`r-${xe}`))]})]})]})]})]})}function Zr(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function Qr({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await W.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(ou,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(he,{size:"sm",icon:ic,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function Px({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({issues:0,prs:0,actions:0,fetchedAt:0}),c=d.useRef(!1),u=d.useCallback(async()=>{n(!0);try{const g=await W.getStatus();a({has_remote:!0,repo:"",owner:""})}catch{a({has_remote:!1})}n(!1)},[e]);d.useEffect(()=>{u()},[u]);const m=d.useCallback(async()=>{if(!(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<jx)&&!c.current){c.current=!0;try{const[v,y,x]=await Promise.allSettled([W.getGitHubIssues(e,"open",1),W.getGitHubPRs(e,"open",1),W.getWorkflowRuns(e,5)]);h({issues:v.status==="fulfilled"?v.value.length:0,prs:y.status==="fulfilled"?y.value.length:0,actions:x.status==="fulfilled"?x.value.filter(C=>C.status==="in_progress").length:0,fetchedAt:Date.now()})}catch{}c.current=!1}},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&m()},[o==null?void 0:o.has_remote,m]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&m()},[t,o==null?void 0:o.has_remote,m]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const f=(o==null?void 0:o.has_remote)??!1,_=[{id:"changes",label:"Changes",icon:ee,requiresRemote:!1},{id:"issues",label:"Issues",icon:Td,count:l.issues,requiresRemote:!0},{id:"prs",label:"PRs",icon:nn,count:l.prs,requiresRemote:!0},{id:"actions",label:"Actions",icon:Ut,count:l.actions,requiresRemote:!0}],p=_;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[p.map(g=>{const v=g.requiresRemote&&!f;return r.jsxs("button",{onClick:()=>s(g.id),disabled:v,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===g.id?"bg-primary/10 text-primary":v?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:v?"Connect to GitHub to access this tab":void 0,children:[r.jsx(g.icon,{size:12}),g.label,g.count!==void 0&&g.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:g.count})]},g.id)}),f&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(lc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Dx,{sessionId:e}),t==="issues"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Zr,{}),children:r.jsx(wx,{sessionId:e})}):r.jsx(Qr,{sessionId:e,onPushed:u})),t==="prs"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Zr,{}),children:r.jsx(Cx,{sessionId:e})}):r.jsx(Qr,{sessionId:e,onPushed:u})),t==="actions"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Zr,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kx,{sessionId:e})})}):r.jsx(Qr,{sessionId:e,onPushed:u}))]})]})}function Mx({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(null),f=d.useCallback(async()=>{try{const g=await W.getCheckpoints(e);i(g),m(null)}catch{m("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{f();const g=setInterval(f,15e3);return()=>clearInterval(g)},[f]);const _=d.useCallback(async g=>{if(a)return;const v=s.find(x=>x.id===g);if(!(!v||!window.confirm(`Restore to checkpoint "${v.description}"?
226
226
 
227
- This will revert files to this checkpoint state.`))){l(g);try{await W.restoreCheckpoint(e,g),await f(),t==null||t()}catch{m("Failed to restore checkpoint")}l(null)}},[e,s,a,f,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(nn,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(u&&s.length===0||s.length===0)return null;const p=g=>{if(!g)return"";try{return new Date(g).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(nn,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((g,v)=>r.jsxs("div",{className:"flex items-center gap-1",children:[v>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>_(g.id),onMouseEnter:()=>c(g.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${g.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===g.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==g.id?"opacity-50":""}`,title:`${g.description} -- Click to restore`}),h===g.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:g.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[g.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ct,{size:10}),p(g.timestamp)]}),g.files_changed>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ee,{size:10}),g.files_changed," file",g.files_changed!==1?"s":""]}),g.iteration>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",g.iteration]})]}),!g.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(rc,{size:10}),"Click to restore"]}),g.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},g.id))}),u&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:u})]})}function Lx({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function Bx({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(mr,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(su,{size:14,className:"text-danger"}):r.jsx(ee,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(fr,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(pr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(nc,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,u)=>r.jsx(Lx,{line:c},`${h}-${u}`))]},h))})]})}function Tx({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(f=>f.path))),[l,h]=d.useState(0),c=d.useCallback(f=>{a(_=>{const p=new Set(_);return p.has(f)?p.delete(f):p.add(f),p})},[]),u=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(f=>f.path)))},[o.size,e.files]),m=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:f=>f.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(ee,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(pr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(nc,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(_t,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:u,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((f,_)=>{const p=f.action==="add"?"text-success":f.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(_),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${_===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(f.path),onChange:()=>c(f.path),onClick:g=>g.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:f.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:f.action==="add"?"+":f.action==="delete"?"-":"M"})]},f.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx(Bx,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(oc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:m,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Gt,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(Yd,{size:14}),"Accept All"]})]})]})]})}function Zi(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function zx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Ax(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const No={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:ct,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:gr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Yl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:tr,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:oc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Xl,label:"Skipped"}};function jh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Nh(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function Eo({status:e}){const t=No[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Ox({step:e}){const t=Ax(e),s=No[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:Nh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:t})]})}function $x({job:e}){const[t,s]=d.useState(!1),i=zx(e),n=No[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(fs,{size:14,className:"text-[#939084]"}):r.jsx(fr,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:Nh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Ox,{step:o},o.number))})]})}function Ix({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await W.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(gr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function Fx({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[u,m]=d.useState(!1),f=Zi(e),_=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const g=await W.getWorkflowRunDetail(t,e.databaseId);o(g)}catch(g){c(g instanceof Error?g.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),p=()=>{const g=!s;i(g),g&&_()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:p,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(fs,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(fr,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(Eo,{status:f})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(ze,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:jh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(as,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(gr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ht,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(g=>r.jsx($x,{job:g},g.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>m(!u),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(ns,{size:12}),u?"Hide full logs":"View full logs"]}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Ix,{sessionId:t,runId:e.databaseId})})]})]})]})}function Hx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var _;const[n,o]=d.useState(((_=t[0])==null?void 0:_.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[u,m]=d.useState(null),f=async()=>{if(n){c(!0),m(null);try{await W.dispatchWorkflow(e,n,a),i(),s()}catch(p){m(p instanceof Error?p.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:p=>o(p.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(p=>r.jsxs("option",{value:p.name,children:[p.name," (",p.name,")"]},p.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),u&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ht,{size:12}),r.jsx("span",{className:"text-xs",children:u})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(he,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(he,{size:"sm",icon:Ut,onClick:f,loading:h,children:"Dispatch"})]})]})}function Eh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,u]=d.useState(null),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useRef(null),v=t.some(D=>D.status==="in_progress"||D.status==="queued"||D.status==="waiting"||D.status==="requested"||D.status==="pending"),y=d.useCallback(async(D=!1)=>{if(e){D&&h(!0),u(null);try{const B=await W.getWorkflowRuns(e);s(B),a(""),p(new Date)}catch(B){const U=B instanceof Error?B.message:String(B);U.includes("gh CLI not found")?u({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):U.includes("not authenticated")||U.includes("401")?u({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):U.includes("Could not detect")?u({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):u({type:"generic",message:U})}finally{h(!1)}}},[e]),x=d.useCallback(async()=>{if(e)try{const D=await W.getWorkflows(e);n(D.filter(B=>B.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),x()},[y,x]),d.useEffect(()=>(v&&e?g.current=setInterval(()=>y(!1),1e4):g.current&&(clearInterval(g.current),g.current=null),()=>{g.current&&clearInterval(g.current)}),[v,e,y]);const C=t.filter(D=>Zi(D)==="success").length,j=t.filter(D=>Zi(D)==="failed").length,w=t.filter(D=>{const B=Zi(D);return B==="running"||B==="pending"}).length;return r.jsxs("div",{className:"card p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ze,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[_&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(hc,{size:10}),jh(_.toISOString())]}),r.jsx(he,{size:"sm",variant:"ghost",icon:bt,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(he,{size:"sm",icon:Ut,onClick:()=>f(!m),children:"Run Workflow"})]})]}),m&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Hx,{sessionId:e,workflows:i,onClose:()=>f(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ht,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(as,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ht,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(ze,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ht,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Yl,{size:12}),C," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(tr,{size:12}),j," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(gr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),v&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(D=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},D))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(D=>r.jsx(Fx,{run:D,sessionId:e},D.databaseId))})]})}const Wx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:Eh},Symbol.toStringTag,{value:"Module"}));function Ux({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const u=Math.floor(c/60),m=c%60;return`${u}m ${m}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(Dt,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Kx({tokenHistory:e,budget:t=1e5,className:s=""}){const i=e.slice(-10);if(i.length<2)return null;const n=64,o=20,a=2,l=Math.max(...i,1),h=Math.min(...i,0),c=l-h||1,u=i.map((y,x)=>({x:a+x/(i.length-1)*(n-a*2),y:a+(1-(y-h)/c)*(o-a*2)})),m=u.map((y,x)=>`${x===0?"M":"L"} ${y.x.toFixed(1)} ${y.y.toFixed(1)}`).join(" "),f=`${m} L ${u[u.length-1].x.toFixed(1)} ${o-a} L ${u[0].x.toFixed(1)} ${o-a} Z`,p=i[i.length-1]/t;let g="#1FC5A8",v="rgba(31, 197, 168, 0.15)";return p>1?(g="#C45B5B",v="rgba(196, 91, 91, 0.15)"):p>.75&&(g="#D4A03C",v="rgba(212, 160, 60, 0.15)"),r.jsxs("svg",{width:n,height:o,viewBox:`0 0 ${n} ${o}`,className:`inline-block align-middle ${s}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:f,fill:v}),r.jsx("path",{d:m,fill:"none",stroke:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:"2",fill:g})]})}function qx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Vx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:ee,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:ee,color:"text-yellow-500",label:"JSX"},ts:{icon:ee,color:"text-blue-500",label:"TypeScript"},tsx:{icon:ee,color:"text-blue-400",label:"TSX"},py:{icon:ee,color:"text-green-600",label:"Python"},html:{icon:ee,color:"text-orange-500",label:"HTML"},css:{icon:ro,color:"text-purple-500",label:"CSS"},json:{icon:io,color:"text-green-500",label:"JSON"},md:{icon:mi,color:"text-muted",label:"Markdown"},go:{icon:ee,color:"text-cyan-600",label:"Go"},rs:{icon:ee,color:"text-orange-600",label:"Rust"}}[t]||{icon:no,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function Gx(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Bl(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function Yx({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:u}){const[m,f]=d.useState(""),[_,p]=d.useState(!1);d.useEffect(()=>{if(!n)return;const j=()=>f(Gx(n));j();const w=setInterval(j,5e3);return()=>clearInterval(w)},[n]);const g=d.useCallback(async()=>{const j=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Bl(h)}`:"",u?`
227
+ This will revert files to this checkpoint state.`))){l(g);try{await W.restoreCheckpoint(e,g),await f(),t==null||t()}catch{m("Failed to restore checkpoint")}l(null)}},[e,s,a,f,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(on,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(u&&s.length===0||s.length===0)return null;const p=g=>{if(!g)return"";try{return new Date(g).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(on,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((g,v)=>r.jsxs("div",{className:"flex items-center gap-1",children:[v>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>_(g.id),onMouseEnter:()=>c(g.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${g.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===g.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==g.id?"opacity-50":""}`,title:`${g.description} -- Click to restore`}),h===g.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:g.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[g.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ct,{size:10}),p(g.timestamp)]}),g.files_changed>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ee,{size:10}),g.files_changed," file",g.files_changed!==1?"s":""]}),g.iteration>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",g.iteration]})]}),!g.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(rc,{size:10}),"Click to restore"]}),g.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},g.id))}),u&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:u})]})}function Lx({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function Bx({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(mr,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(su,{size:14,className:"text-danger"}):r.jsx(ee,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(fr,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(pr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(nc,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,u)=>r.jsx(Lx,{line:c},`${h}-${u}`))]},h))})]})}function Tx({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(f=>f.path))),[l,h]=d.useState(0),c=d.useCallback(f=>{a(_=>{const p=new Set(_);return p.has(f)?p.delete(f):p.add(f),p})},[]),u=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(f=>f.path)))},[o.size,e.files]),m=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:f=>f.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(ee,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(pr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(nc,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(_t,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:u,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((f,_)=>{const p=f.action==="add"?"text-success":f.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(_),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${_===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(f.path),onChange:()=>c(f.path),onClick:g=>g.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:f.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:f.action==="add"?"+":f.action==="delete"?"-":"M"})]},f.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx(Bx,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(oc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:m,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Gt,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(Yd,{size:14}),"Accept All"]})]})]})]})}function Zi(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function zx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Ax(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const No={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:ct,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:gr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Yl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:tr,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:oc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Xl,label:"Skipped"}};function jh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Nh(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function Eo({status:e}){const t=No[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Ox({step:e}){const t=Ax(e),s=No[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:Nh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:t})]})}function $x({job:e}){const[t,s]=d.useState(!1),i=zx(e),n=No[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(fs,{size:14,className:"text-[#939084]"}):r.jsx(fr,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:Nh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Ox,{step:o},o.number))})]})}function Ix({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await W.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(gr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function Fx({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[u,m]=d.useState(!1),f=Zi(e),_=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const g=await W.getWorkflowRunDetail(t,e.databaseId);o(g)}catch(g){c(g instanceof Error?g.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),p=()=>{const g=!s;i(g),g&&_()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:p,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(fs,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(fr,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(Eo,{status:f})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(ze,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:jh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(as,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(gr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ht,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(g=>r.jsx($x,{job:g},g.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>m(!u),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(ns,{size:12}),u?"Hide full logs":"View full logs"]}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Ix,{sessionId:t,runId:e.databaseId})})]})]})]})}function Hx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var _;const[n,o]=d.useState(((_=t[0])==null?void 0:_.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[u,m]=d.useState(null),f=async()=>{if(n){c(!0),m(null);try{await W.dispatchWorkflow(e,n,a),i(),s()}catch(p){m(p instanceof Error?p.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:p=>o(p.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(p=>r.jsxs("option",{value:p.name,children:[p.name," (",p.name,")"]},p.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),u&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ht,{size:12}),r.jsx("span",{className:"text-xs",children:u})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(he,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(he,{size:"sm",icon:Ut,onClick:f,loading:h,children:"Dispatch"})]})]})}function Eh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,u]=d.useState(null),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useRef(null),v=t.some(R=>R.status==="in_progress"||R.status==="queued"||R.status==="waiting"||R.status==="requested"||R.status==="pending"),y=d.useCallback(async(R=!1)=>{if(e){R&&h(!0),u(null);try{const B=await W.getWorkflowRuns(e);s(B),a(""),p(new Date)}catch(B){const U=B instanceof Error?B.message:String(B);U.includes("gh CLI not found")?u({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):U.includes("not authenticated")||U.includes("401")?u({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):U.includes("Could not detect")?u({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):u({type:"generic",message:U})}finally{h(!1)}}},[e]),x=d.useCallback(async()=>{if(e)try{const R=await W.getWorkflows(e);n(R.filter(B=>B.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),x()},[y,x]),d.useEffect(()=>(v&&e?g.current=setInterval(()=>y(!1),1e4):g.current&&(clearInterval(g.current),g.current=null),()=>{g.current&&clearInterval(g.current)}),[v,e,y]);const C=t.filter(R=>Zi(R)==="success").length,j=t.filter(R=>Zi(R)==="failed").length,w=t.filter(R=>{const B=Zi(R);return B==="running"||B==="pending"}).length;return r.jsxs("div",{className:"card p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ze,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[_&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(hc,{size:10}),jh(_.toISOString())]}),r.jsx(he,{size:"sm",variant:"ghost",icon:bt,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(he,{size:"sm",icon:Ut,onClick:()=>f(!m),children:"Run Workflow"})]})]}),m&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Hx,{sessionId:e,workflows:i,onClose:()=>f(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ht,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(as,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ht,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(ze,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ht,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Yl,{size:12}),C," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(tr,{size:12}),j," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(gr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),v&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(R=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},R))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(R=>r.jsx(Fx,{run:R,sessionId:e},R.databaseId))})]})}const Wx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:Eh},Symbol.toStringTag,{value:"Module"}));function Ux({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const u=Math.floor(c/60),m=c%60;return`${u}m ${m}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(Rt,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Kx({tokenHistory:e,budget:t=1e5,className:s=""}){const i=e.slice(-10);if(i.length<2)return null;const n=64,o=20,a=2,l=Math.max(...i,1),h=Math.min(...i,0),c=l-h||1,u=i.map((y,x)=>({x:a+x/(i.length-1)*(n-a*2),y:a+(1-(y-h)/c)*(o-a*2)})),m=u.map((y,x)=>`${x===0?"M":"L"} ${y.x.toFixed(1)} ${y.y.toFixed(1)}`).join(" "),f=`${m} L ${u[u.length-1].x.toFixed(1)} ${o-a} L ${u[0].x.toFixed(1)} ${o-a} Z`,p=i[i.length-1]/t;let g="#1FC5A8",v="rgba(31, 197, 168, 0.15)";return p>1?(g="#C45B5B",v="rgba(196, 91, 91, 0.15)"):p>.75&&(g="#D4A03C",v="rgba(212, 160, 60, 0.15)"),r.jsxs("svg",{width:n,height:o,viewBox:`0 0 ${n} ${o}`,className:`inline-block align-middle ${s}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:f,fill:v}),r.jsx("path",{d:m,fill:"none",stroke:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:"2",fill:g})]})}function qx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Vx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:ee,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:ee,color:"text-yellow-500",label:"JSX"},ts:{icon:ee,color:"text-blue-500",label:"TypeScript"},tsx:{icon:ee,color:"text-blue-400",label:"TSX"},py:{icon:ee,color:"text-green-600",label:"Python"},html:{icon:ee,color:"text-orange-500",label:"HTML"},css:{icon:ro,color:"text-purple-500",label:"CSS"},json:{icon:io,color:"text-green-500",label:"JSON"},md:{icon:mi,color:"text-muted",label:"Markdown"},go:{icon:ee,color:"text-cyan-600",label:"Go"},rs:{icon:ee,color:"text-orange-600",label:"Rust"}}[t]||{icon:no,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function Gx(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Bl(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function Yx({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:u}){const[m,f]=d.useState(""),[_,p]=d.useState(!1);d.useEffect(()=>{if(!n)return;const j=()=>f(Gx(n));j();const w=setInterval(j,5e3);return()=>clearInterval(w)},[n]);const g=d.useCallback(async()=>{const j=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Bl(h)}`:"",u?`
228
228
  Project: ${u.substring(0,100)}${u.length>100?"...":""}`:"",`
229
229
  https://autonomi.dev`].filter(Boolean).join(`
230
- `);try{await navigator.clipboard.writeText(j),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[c,h,u]);if(!e)return null;const v=Vx(t),y=v.icon,x=h?h*5:0,C=h&&x>0?(x/h).toFixed(1):null;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 bg-card border-t border-border text-[11px] font-mono text-muted select-none flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(y,{size:12,className:v.color}),r.jsx("span",{children:v.label})]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:[o," lines"]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:["Ln ",a,", Col ",l]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Od,{size:11}),i?r.jsx("span",{className:"text-primary animate-pulse",children:"Saving..."}):s?r.jsx("span",{className:"text-warning",children:"Unsaved"}):n?r.jsxs("span",{className:"text-success",children:["Saved ",m]}):r.jsx("span",{children:"Saved"})]}),r.jsx("div",{className:"flex-1"}),h!=null&&h>0&&r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(hc,{size:11}),r.jsxs("span",{children:["Built in ",Bl(h)]}),C&&r.jsxs("span",{className:"text-muted ml-1",children:[r.jsx(is,{size:10,className:"inline"})," ",C,"x faster"]})]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-border",children:"|"}),r.jsx("button",{onClick:g,className:"flex items-center gap-1 hover:text-primary transition-colors",title:"Copy build summary to clipboard",children:_?r.jsxs(r.Fragment,{children:[r.jsx(Gt,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(ao,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Xn=[{id:"desktop",label:"Desktop",icon:yd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Pu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Du,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function Xx({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Xn.map(i=>{const n=i.icon,o=e===i.id;return r.jsx("button",{onClick:()=>t(i.id),title:`${i.label} (${i.frameWidth}px)`,className:`p-1.5 rounded transition-colors ${o?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:r.jsx(n,{size:14})},i.id)}),s!=null&&s>0&&r.jsxs("span",{className:"text-[10px] font-mono text-muted ml-1 tabular-nums",children:[s,"px"]})]})}function Jx(){const[e,t]=d.useState("desktop"),s=Xn.find(i=>i.id===e)||Xn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const Zx=[75,100,125];function Qx({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:Zx.map(s=>r.jsxs("button",{onClick:()=>t(s),className:`px-2 py-1 text-[10px] font-medium transition-colors ${e===s?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,title:`Zoom ${s}%`,children:[s,"%"]},s))})}function ev({data:e,size:t=80}){const i=t/11,n=[];let o=0;for(let a=0;a<e.length;a++)o=(o<<5)-o+e.charCodeAt(a)|0;for(let a=0;a<11;a++){n[a]=[];for(let l=0;l<11;l++){const h=l<3&&a<3,c=l>=8&&a<3,u=l<3&&a>=8;if((h||c||u)&&(l===0||a===0||l===2||a===2||l===10||a===10||l===8||a===8)||(l===1&&a===1||l===9&&a===1||l===1&&a===9))n[a][l]=!0;else if(h||c||u)n[a][l]=!1;else{const _=o+l*17+a*31&65535;n[a][l]=_%3!==0}}}return r.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"bg-white rounded p-1",children:n.map((a,l)=>a.map((h,c)=>h?r.jsx("rect",{x:c*i,y:l*i,width:i,height:i,fill:"#201515"},`${c}-${l}`):null))})}function tv(){const[e,t]=d.useState(!1);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:()=>t(s=>!s),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Screenshot",children:r.jsx(Vd,{size:14})}),e&&r.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-card border border-border rounded-btn shadow-lg p-2 text-xs text-muted whitespace-nowrap",children:"Right-click the preview to save as image"})]})}function sv({url:e}){const[t,s]=d.useState(!1),i=d.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}},[e]);return r.jsxs("button",{onClick:i,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors relative",title:"Copy preview URL",children:[t?r.jsx(Gt,{size:14,className:"text-success"}):r.jsx(to,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function iv({isFullscreen:e,onToggle:t}){return r.jsx("button",{onClick:t,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:e?"Exit fullscreen":"Fullscreen preview",children:e?r.jsx(cc,{size:14}):r.jsx(ln,{size:14})})}function Tl({messages:e}){const[t,s]=d.useState(!1),i=e.slice(-5),n=i.some(o=>o.level==="error");return i.length===0?null:r.jsxs("div",{className:`border-t border-border bg-card ${t?"":"cursor-pointer"}`,children:[r.jsxs("button",{onClick:()=>s(o=>!o),className:"w-full flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono hover:bg-hover transition-colors",children:[n?r.jsx(Bs,{size:12,className:"text-danger"}):r.jsx("span",{className:"w-3 h-3 rounded-full border border-muted/40 flex items-center justify-center text-[8px] text-muted",children:"i"}),r.jsxs("span",{className:`font-medium ${n?"text-danger":"text-muted"}`,children:["Console (",i.length,")"]}),r.jsx("div",{className:"flex-1"}),t?r.jsx(fs,{size:12}):r.jsx(ur,{size:12})]}),t&&r.jsx("div",{className:"max-h-32 overflow-y-auto terminal-scroll border-t border-border",children:i.map((o,a)=>r.jsxs("div",{className:`px-3 py-1 text-[11px] font-mono border-b border-border/50 last:border-b-0 ${o.level==="error"?"bg-danger/5 text-danger":o.level==="warn"?"bg-warning/5 text-warning":"text-muted"}`,children:[r.jsx("span",{className:"uppercase text-[9px] font-semibold mr-2 opacity-60",children:o.level}),o.message]},a))})]})}function rv({onClick:e,isRefreshing:t}){const[s,i]=d.useState(!1),n=d.useCallback(()=>{i(!0),e(),setTimeout(()=>i(!1),600)},[e]);return r.jsx("button",{onClick:n,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Refresh preview",children:r.jsx(Dd,{size:14,className:s||t?"animate-spin-once":""})})}function zl(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-card p-8",children:[r.jsxs("div",{className:"w-full max-w-md space-y-4",children:[r.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded"}),r.jsx("div",{className:"skeleton-shimmer h-32 w-full rounded"}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"})]}),r.jsx("div",{className:"skeleton-shimmer h-8 w-48 rounded mx-auto"})]}),r.jsx("p",{className:"text-xs text-muted mt-6 animate-pulse",children:"Loading preview..."})]})}function nv({url:e}){const[t,s]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!t)return;const n=o=>{i.current&&!i.current.contains(o.target)&&s(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[t]),r.jsxs("div",{className:"relative",ref:i,children:[r.jsx("button",{onClick:()=>s(n=>!n),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors text-[10px] font-semibold",title:"Show QR code",children:"QR"}),t&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 z-30 bg-card border border-border rounded-btn shadow-lg p-3",children:[r.jsx(ev,{data:e,size:100}),r.jsx("p",{className:"text-[10px] text-muted text-center mt-2 max-w-[100px] truncate",children:e})]})]})}const Al={create:"bg-primary/8 text-primary border-primary/15 hover:bg-primary/15",improve:"bg-info/8 text-info border-info/15 hover:bg-info/15",fix:"bg-danger/8 text-danger border-danger/15 hover:bg-danger/15",test:"bg-teal/8 text-teal border-teal/15 hover:bg-teal/15",deploy:"bg-warning/8 text-warning border-warning/15 hover:bg-warning/15"};function ov(e){const{projectState:t,hasSession:s,files:i,lastError:n,phase:o}=e;if(!s||t==="empty")return[{label:"Build a SaaS dashboard",prompt:"Build a modern SaaS analytics dashboard with charts and dark mode",category:"create"},{label:"Create a CLI tool",prompt:"Create a CLI tool with commands, flags, and help text",category:"create"},{label:"Build a REST API",prompt:"Build a REST API with CRUD endpoints, authentication, and database",category:"create"},{label:"Make a landing page",prompt:"Create a beautiful landing page with hero, features, pricing, and CTA sections",category:"create"}];if(t==="failed"){const a=[{label:"Fix the build errors",prompt:"Fix all build errors and get the project to compile successfully",category:"fix"},{label:"Try a different approach",prompt:"The current approach has issues. Try an alternative implementation strategy",category:"fix"}];if(n){const l=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${l}`,prompt:`Fix this error: ${n}`,category:"fix"})}return a.push({label:"Add error handling",prompt:"Add comprehensive error handling and fallbacks throughout the codebase",category:"improve"}),a.slice(0,4)}if(t==="building")return[];if(t==="completed"||t==="idle"){const a=[],l=i==null?void 0:i.some(m=>m.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(m=>m.path.includes(".test.")||m.path.includes(".spec.")||m.path.includes("__tests__")),c=i==null?void 0:i.some(m=>m.path.endsWith(".css")||m.path.endsWith(".scss")),u=i==null?void 0:i.some(m=>m.path.includes("Dockerfile")||m.path.includes("docker-compose"));return l||a.push({label:"Add authentication",prompt:"Add user authentication with login, signup, and session management",category:"improve"}),h||a.push({label:"Add test suite",prompt:"Add comprehensive unit tests and integration tests for all major features",category:"test"}),a.push({label:"Improve the UI",prompt:"Improve the UI with better styling, animations, and responsive design",category:"improve"}),u||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),l&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),c||a.push({label:"Add dark mode",prompt:"Add a dark mode toggle with proper theme support across all components",category:"improve"}),a.push({label:"Add API docs",prompt:"Add OpenAPI/Swagger documentation for all API endpoints",category:"improve"}),a.push({label:"Performance optimization",prompt:"Optimize performance: add lazy loading, caching, code splitting, and minimize bundle size",category:"improve"}),a.slice(0,4)}return[]}function av(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),l=d.useMemo(()=>ov(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,c]=d.useState(0);if(d.useEffect(()=>{if(l.length<=4)return;const m=setInterval(()=>{a(!0),setTimeout(()=>{c(f=>(f+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(m)},[l.length]),l.length===0||!i)return null;const u=l.slice(h,h+4).concat(h+4>l.length?l.slice(0,h+4-l.length):[]).slice(0,4);return r.jsxs("div",{className:`${s}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Sd,{size:12,className:"text-primary"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Suggestions"})]}),r.jsx("div",{className:`flex flex-wrap gap-1.5 transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:u.map((m,f)=>r.jsxs("button",{onClick:()=>t(m.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
230
+ `);try{await navigator.clipboard.writeText(j),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[c,h,u]);if(!e)return null;const v=Vx(t),y=v.icon,x=h?h*5:0,C=h&&x>0?(x/h).toFixed(1):null;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 bg-card border-t border-border text-[11px] font-mono text-muted select-none flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(y,{size:12,className:v.color}),r.jsx("span",{children:v.label})]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:[o," lines"]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:["Ln ",a,", Col ",l]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Od,{size:11}),i?r.jsx("span",{className:"text-primary animate-pulse",children:"Saving..."}):s?r.jsx("span",{className:"text-warning",children:"Unsaved"}):n?r.jsxs("span",{className:"text-success",children:["Saved ",m]}):r.jsx("span",{children:"Saved"})]}),r.jsx("div",{className:"flex-1"}),h!=null&&h>0&&r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(hc,{size:11}),r.jsxs("span",{children:["Built in ",Bl(h)]}),C&&r.jsxs("span",{className:"text-muted ml-1",children:[r.jsx(is,{size:10,className:"inline"})," ",C,"x faster"]})]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-border",children:"|"}),r.jsx("button",{onClick:g,className:"flex items-center gap-1 hover:text-primary transition-colors",title:"Copy build summary to clipboard",children:_?r.jsxs(r.Fragment,{children:[r.jsx(Gt,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(ao,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Xn=[{id:"desktop",label:"Desktop",icon:yd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Pu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Ru,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function Xx({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Xn.map(i=>{const n=i.icon,o=e===i.id;return r.jsx("button",{onClick:()=>t(i.id),title:`${i.label} (${i.frameWidth}px)`,className:`p-1.5 rounded transition-colors ${o?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:r.jsx(n,{size:14})},i.id)}),s!=null&&s>0&&r.jsxs("span",{className:"text-[10px] font-mono text-muted ml-1 tabular-nums",children:[s,"px"]})]})}function Jx(){const[e,t]=d.useState("desktop"),s=Xn.find(i=>i.id===e)||Xn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const Zx=[75,100,125];function Qx({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:Zx.map(s=>r.jsxs("button",{onClick:()=>t(s),className:`px-2 py-1 text-[10px] font-medium transition-colors ${e===s?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,title:`Zoom ${s}%`,children:[s,"%"]},s))})}function ev({data:e,size:t=80}){const i=t/11,n=[];let o=0;for(let a=0;a<e.length;a++)o=(o<<5)-o+e.charCodeAt(a)|0;for(let a=0;a<11;a++){n[a]=[];for(let l=0;l<11;l++){const h=l<3&&a<3,c=l>=8&&a<3,u=l<3&&a>=8;if((h||c||u)&&(l===0||a===0||l===2||a===2||l===10||a===10||l===8||a===8)||(l===1&&a===1||l===9&&a===1||l===1&&a===9))n[a][l]=!0;else if(h||c||u)n[a][l]=!1;else{const _=o+l*17+a*31&65535;n[a][l]=_%3!==0}}}return r.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"bg-white rounded p-1",children:n.map((a,l)=>a.map((h,c)=>h?r.jsx("rect",{x:c*i,y:l*i,width:i,height:i,fill:"#201515"},`${c}-${l}`):null))})}function tv(){const[e,t]=d.useState(!1);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:()=>t(s=>!s),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Screenshot",children:r.jsx(Vd,{size:14})}),e&&r.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-card border border-border rounded-btn shadow-lg p-2 text-xs text-muted whitespace-nowrap",children:"Right-click the preview to save as image"})]})}function sv({url:e}){const[t,s]=d.useState(!1),i=d.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}},[e]);return r.jsxs("button",{onClick:i,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors relative",title:"Copy preview URL",children:[t?r.jsx(Gt,{size:14,className:"text-success"}):r.jsx(to,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function iv({isFullscreen:e,onToggle:t}){return r.jsx("button",{onClick:t,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:e?"Exit fullscreen":"Fullscreen preview",children:e?r.jsx(cc,{size:14}):r.jsx(ln,{size:14})})}function Tl({messages:e}){const[t,s]=d.useState(!1),i=e.slice(-5),n=i.some(o=>o.level==="error");return i.length===0?null:r.jsxs("div",{className:`border-t border-border bg-card ${t?"":"cursor-pointer"}`,children:[r.jsxs("button",{onClick:()=>s(o=>!o),className:"w-full flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono hover:bg-hover transition-colors",children:[n?r.jsx(ms,{size:12,className:"text-danger"}):r.jsx("span",{className:"w-3 h-3 rounded-full border border-muted/40 flex items-center justify-center text-[8px] text-muted",children:"i"}),r.jsxs("span",{className:`font-medium ${n?"text-danger":"text-muted"}`,children:["Console (",i.length,")"]}),r.jsx("div",{className:"flex-1"}),t?r.jsx(fs,{size:12}):r.jsx(ur,{size:12})]}),t&&r.jsx("div",{className:"max-h-32 overflow-y-auto terminal-scroll border-t border-border",children:i.map((o,a)=>r.jsxs("div",{className:`px-3 py-1 text-[11px] font-mono border-b border-border/50 last:border-b-0 ${o.level==="error"?"bg-danger/5 text-danger":o.level==="warn"?"bg-warning/5 text-warning":"text-muted"}`,children:[r.jsx("span",{className:"uppercase text-[9px] font-semibold mr-2 opacity-60",children:o.level}),o.message]},a))})]})}function rv({onClick:e,isRefreshing:t}){const[s,i]=d.useState(!1),n=d.useCallback(()=>{i(!0),e(),setTimeout(()=>i(!1),600)},[e]);return r.jsx("button",{onClick:n,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Refresh preview",children:r.jsx(Rd,{size:14,className:s||t?"animate-spin-once":""})})}function zl(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-card p-8",children:[r.jsxs("div",{className:"w-full max-w-md space-y-4",children:[r.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded"}),r.jsx("div",{className:"skeleton-shimmer h-32 w-full rounded"}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"})]}),r.jsx("div",{className:"skeleton-shimmer h-8 w-48 rounded mx-auto"})]}),r.jsx("p",{className:"text-xs text-muted mt-6 animate-pulse",children:"Loading preview..."})]})}function nv({url:e}){const[t,s]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!t)return;const n=o=>{i.current&&!i.current.contains(o.target)&&s(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[t]),r.jsxs("div",{className:"relative",ref:i,children:[r.jsx("button",{onClick:()=>s(n=>!n),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors text-[10px] font-semibold",title:"Show QR code",children:"QR"}),t&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 z-30 bg-card border border-border rounded-btn shadow-lg p-3",children:[r.jsx(ev,{data:e,size:100}),r.jsx("p",{className:"text-[10px] text-muted text-center mt-2 max-w-[100px] truncate",children:e})]})]})}const Al={create:"bg-primary/8 text-primary border-primary/15 hover:bg-primary/15",improve:"bg-info/8 text-info border-info/15 hover:bg-info/15",fix:"bg-danger/8 text-danger border-danger/15 hover:bg-danger/15",test:"bg-teal/8 text-teal border-teal/15 hover:bg-teal/15",deploy:"bg-warning/8 text-warning border-warning/15 hover:bg-warning/15"};function ov(e){const{projectState:t,hasSession:s,files:i,lastError:n,phase:o}=e;if(!s||t==="empty")return[{label:"Build a SaaS dashboard",prompt:"Build a modern SaaS analytics dashboard with charts and dark mode",category:"create"},{label:"Create a CLI tool",prompt:"Create a CLI tool with commands, flags, and help text",category:"create"},{label:"Build a REST API",prompt:"Build a REST API with CRUD endpoints, authentication, and database",category:"create"},{label:"Make a landing page",prompt:"Create a beautiful landing page with hero, features, pricing, and CTA sections",category:"create"}];if(t==="failed"){const a=[{label:"Fix the build errors",prompt:"Fix all build errors and get the project to compile successfully",category:"fix"},{label:"Try a different approach",prompt:"The current approach has issues. Try an alternative implementation strategy",category:"fix"}];if(n){const l=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${l}`,prompt:`Fix this error: ${n}`,category:"fix"})}return a.push({label:"Add error handling",prompt:"Add comprehensive error handling and fallbacks throughout the codebase",category:"improve"}),a.slice(0,4)}if(t==="building")return[];if(t==="completed"||t==="idle"){const a=[],l=i==null?void 0:i.some(m=>m.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(m=>m.path.includes(".test.")||m.path.includes(".spec.")||m.path.includes("__tests__")),c=i==null?void 0:i.some(m=>m.path.endsWith(".css")||m.path.endsWith(".scss")),u=i==null?void 0:i.some(m=>m.path.includes("Dockerfile")||m.path.includes("docker-compose"));return l||a.push({label:"Add authentication",prompt:"Add user authentication with login, signup, and session management",category:"improve"}),h||a.push({label:"Add test suite",prompt:"Add comprehensive unit tests and integration tests for all major features",category:"test"}),a.push({label:"Improve the UI",prompt:"Improve the UI with better styling, animations, and responsive design",category:"improve"}),u||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),l&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),c||a.push({label:"Add dark mode",prompt:"Add a dark mode toggle with proper theme support across all components",category:"improve"}),a.push({label:"Add API docs",prompt:"Add OpenAPI/Swagger documentation for all API endpoints",category:"improve"}),a.push({label:"Performance optimization",prompt:"Optimize performance: add lazy loading, caching, code splitting, and minimize bundle size",category:"improve"}),a.slice(0,4)}return[]}function av(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),l=d.useMemo(()=>ov(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,c]=d.useState(0);if(d.useEffect(()=>{if(l.length<=4)return;const m=setInterval(()=>{a(!0),setTimeout(()=>{c(f=>(f+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(m)},[l.length]),l.length===0||!i)return null;const u=l.slice(h,h+4).concat(h+4>l.length?l.slice(0,h+4-l.length):[]).slice(0,4);return r.jsxs("div",{className:`${s}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Sd,{size:12,className:"text-primary"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Suggestions"})]}),r.jsx("div",{className:`flex flex-wrap gap-1.5 transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:u.map((m,f)=>r.jsxs("button",{onClick:()=>t(m.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
231
231
  border rounded-pill transition-all duration-200 cursor-pointer
232
232
  ${Al[m.category]||Al.create}
233
233
  `,children:[m.label,r.jsx(eo,{size:10,className:"opacity-50"})]},`${m.label}-${f}`))})]})}function Qt(e,t){if(e.length===0)return e;const s=[...e],i=s[s.length-1];return s[s.length-1]={...i,...t(i)},s}function lv(e){const t=[],s=[],i=[];for(const n of e.split(`
@@ -237,21 +237,21 @@ https://autonomi.dev`].filter(Boolean).join(`
237
237
  `).slice(0,30).join(`
238
238
  `)+`
239
239
  ...`:o,e.isStreaming&&r.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-primary/60 animate-pulse ml-0.5 align-text-bottom"})]}),a&&!e.isStreaming&&r.jsx("button",{onClick:()=>i(h=>!h),className:"text-[10px] text-primary hover:text-primary/80 mt-1 font-medium",children:s?"Show less":`Show all (${o.split(`
240
- `).length} lines)`}),n&&n.fileChanges.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(ee,{size:11}),"Files modified (",n.fileChanges.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:n.fileChanges.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:h},c))})]}),e.filesChanged&&e.filesChanged.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(ee,{size:11}),"Changed files (",e.filesChanged.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-muted",children:h},c))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&r.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?r.jsxs("span",{children:["Done",n&&(n.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${n.fileChanges.length+(((l=e.filesChanged)==null?void 0:l.length)||0)} files changed`:"",n&&n.commands.length>0?`, ${n.commands.length} commands run`:""]}):r.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})}),e.role==="system"&&!e.isStreaming&&e.content&&r.jsx(cv,{msgIndex:t})]})]})}const fv={quick:"Quick: Fast single-task fix (3 iterations max)",standard:"Standard: Thorough implementation with testing",max:"Max: Full autonomous build from your description"},mv=10*1024*1024,pv=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function gv(e){return pv.has(e.type.toLowerCase())?e.size>mv?"This attachment was not added because it exceeds the 10 MiB limit.":null:"This attachment was not added. Use a PNG, JPEG, GIF, or WebP image."}function _v(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function xv(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>t(String(i.result)),i.onerror=()=>s(i.error),i.readAsDataURL(e)})}function vv({sessionId:e,defaultMode:t,onFilesChanged:s,services:i}){var xe;const[n,o]=d.useState([]),[a,l]=d.useState(""),[h,c]=d.useState(t||"quick"),[u,m]=d.useState(!1),[f,_]=d.useState(!1),[p,g]=d.useState(null),[v,y]=d.useState(!1),[x,C]=d.useState(null),j=d.useRef(null),w=d.useRef(null),D=d.useRef(null),B=d.useRef(null),U=d.useRef(null),G=d.useRef(null),K=d.useRef(null),A=d.useRef(new Set);d.useEffect(()=>{const T=sessionStorage.getItem(`chat_${e}`);if(T)try{o(JSON.parse(T))}catch{}},[e]),d.useEffect(()=>{if(n.length>0){const T=n.slice(-50).map(Y=>({...Y,imageUrl:void 0}));sessionStorage.setItem(`chat_${e}`,JSON.stringify(T))}},[n,e]),d.useEffect(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[n]),d.useEffect(()=>{const T=A.current;return()=>{U.current&&U.current.abort();for(const Y of T)URL.revokeObjectURL(Y);T.clear()}},[]);const R=d.useCallback(T=>{A.current.delete(T)&&URL.revokeObjectURL(T)},[]),E=d.useCallback(T=>{if(u)return;const Y=gv(T);if(Y){C(Y);return}C(null),p!=null&&p.previewUrl&&R(p.previewUrl);const q=URL.createObjectURL(T);A.current.add(q),g({file:T,previewUrl:q})},[p==null?void 0:p.previewUrl,R,u]),L=d.useCallback(()=>{var T;p!=null&&p.previewUrl&&R(p.previewUrl),g(null),C(null),D.current&&(D.current.value=""),(T=B.current)==null||T.focus()},[p==null?void 0:p.previewUrl,R]);d.useEffect(()=>{const T=Y=>{var Q;const q=(Q=Y.clipboardData)==null?void 0:Q.items;if(q){for(const le of q)if(le.type.startsWith("image/")){Y.preventDefault();const ke=le.getAsFile();ke&&E(ke);return}}};return document.addEventListener("paste",T),()=>document.removeEventListener("paste",T)},[E]);const[S,N]=d.useState(!1),[k,P]=d.useState(!1),[J,oe]=d.useState(""),[V,Z]=d.useState(0),ie=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&N(!0)},[]),ue=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),N(!1)},[]),fe=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),N(!1);const Y=T.dataTransfer.files;if(Y.length>0){const q=Y[0];q.type.startsWith("image/")&&E(q)}},[E]),de=d.useCallback(async()=>{var T;if(U.current&&(U.current.abort(),U.current=null),G.current){try{await W.chatCancel(e,G.current)}catch{}G.current=null}_(!1),m(!1),o(Y=>Qt(Y,q=>q.isStreaming?{isStreaming:!1,content:q.content+`
240
+ `).length} lines)`}),n&&n.fileChanges.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(ee,{size:11}),"Files modified (",n.fileChanges.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:n.fileChanges.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:h},c))})]}),e.filesChanged&&e.filesChanged.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(ee,{size:11}),"Changed files (",e.filesChanged.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-muted",children:h},c))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&r.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?r.jsxs("span",{children:["Done",n&&(n.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${n.fileChanges.length+(((l=e.filesChanged)==null?void 0:l.length)||0)} files changed`:"",n&&n.commands.length>0?`, ${n.commands.length} commands run`:""]}):r.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})}),e.role==="system"&&!e.isStreaming&&e.content&&r.jsx(cv,{msgIndex:t})]})]})}const fv={quick:"Quick: Fast single-task fix (3 iterations max)",standard:"Standard: Thorough implementation with testing",max:"Max: Full autonomous build from your description"},mv=10*1024*1024,pv=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function gv(e){return pv.has(e.type.toLowerCase())?e.size>mv?"This attachment was not added because it exceeds the 10 MiB limit.":null:"This attachment was not added. Use a PNG, JPEG, GIF, or WebP image."}function _v(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function xv(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>t(String(i.result)),i.onerror=()=>s(i.error),i.readAsDataURL(e)})}function vv({sessionId:e,defaultMode:t,onFilesChanged:s,services:i}){var xe;const[n,o]=d.useState([]),[a,l]=d.useState(""),[h,c]=d.useState(t||"quick"),[u,m]=d.useState(!1),[f,_]=d.useState(!1),[p,g]=d.useState(null),[v,y]=d.useState(!1),[x,C]=d.useState(null),j=d.useRef(null),w=d.useRef(null),R=d.useRef(null),B=d.useRef(null),U=d.useRef(null),G=d.useRef(null),K=d.useRef(null),A=d.useRef(new Set);d.useEffect(()=>{const T=sessionStorage.getItem(`chat_${e}`);if(T)try{o(JSON.parse(T))}catch{}},[e]),d.useEffect(()=>{if(n.length>0){const T=n.slice(-50).map(Y=>({...Y,imageUrl:void 0}));sessionStorage.setItem(`chat_${e}`,JSON.stringify(T))}},[n,e]),d.useEffect(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[n]),d.useEffect(()=>{const T=A.current;return()=>{U.current&&U.current.abort();for(const Y of T)URL.revokeObjectURL(Y);T.clear()}},[]);const D=d.useCallback(T=>{A.current.delete(T)&&URL.revokeObjectURL(T)},[]),E=d.useCallback(T=>{if(u)return;const Y=gv(T);if(Y){C(Y);return}C(null),p!=null&&p.previewUrl&&D(p.previewUrl);const q=URL.createObjectURL(T);A.current.add(q),g({file:T,previewUrl:q})},[p==null?void 0:p.previewUrl,D,u]),L=d.useCallback(()=>{var T;p!=null&&p.previewUrl&&D(p.previewUrl),g(null),C(null),R.current&&(R.current.value=""),(T=B.current)==null||T.focus()},[p==null?void 0:p.previewUrl,D]);d.useEffect(()=>{const T=Y=>{var Q;const q=(Q=Y.clipboardData)==null?void 0:Q.items;if(q){for(const le of q)if(le.type.startsWith("image/")){Y.preventDefault();const ke=le.getAsFile();ke&&E(ke);return}}};return document.addEventListener("paste",T),()=>document.removeEventListener("paste",T)},[E]);const[S,N]=d.useState(!1),[k,P]=d.useState(!1),[J,oe]=d.useState(""),[V,Z]=d.useState(0),ie=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&N(!0)},[]),ue=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),N(!1)},[]),fe=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),N(!1);const Y=T.dataTransfer.files;if(Y.length>0){const q=Y[0];q.type.startsWith("image/")&&E(q)}},[E]),de=d.useCallback(async()=>{var T;if(U.current&&(U.current.abort(),U.current=null),G.current){try{await W.chatCancel(e,G.current)}catch{}G.current=null}_(!1),m(!1),o(Y=>Qt(Y,q=>q.isStreaming?{isStreaming:!1,content:q.content+`
241
241
  [cancelled]`}:{})),(T=w.current)==null||T.focus()},[e]),_e=d.useCallback(async T=>{var le;let q=0,Q;do{if(await new Promise(ke=>setTimeout(ke,2e3)),Q=await W.chatPoll(e,T),q++,Q.output_lines.length>0){const ke=Q.output_lines.join(`
242
242
  `);o(Pe=>Qt(Pe,Ze=>Ze.role==="system"&&Ze.isStreaming?{content:ke}:{}))}q>=150&&(Q={complete:!0,output_lines:["Task timed out after 5 minutes. The AI may still be working in the background. Try checking the terminal or refreshing."],files_changed:[],returncode:1})}while(!Q.complete);o(ke=>Qt(ke,Pe=>Pe.role==="system"?{isStreaming:!1,content:Q.output_lines.join(`
243
243
  `)||"Done.",filesChanged:Q.files_changed,returncode:Q.returncode}:{})),((le=Q.files_changed)==null?void 0:le.length)>0&&s&&s(Q.files_changed)},[e,s]),He=d.useCallback(async T=>{var q;const Y=new AbortController;U.current=Y,G.current=T,_(!0);try{const Q=W.chatStreamUrl(e,T),le=await fetch(Q,{signal:Y.signal});if(!le.ok||!le.body)throw new Error(`Stream failed: ${le.status}`);const ke=le.body.getReader(),Pe=new TextDecoder;let Ze="";for(;;){const{done:We,value:ut}=await ke.read();if(We)break;Ze+=Pe.decode(ut,{stream:!0});const ae=Ze.split(`
244
244
 
245
245
  `);Ze=ae.pop()||"";for(const yi of ae){if(!yi.trim())continue;const Sr=yi.split(`
246
246
  `);let Yt="",Qe="";for(const Ie of Sr)Ie.startsWith("event:")?Yt=Ie.slice(6).trim():Ie.startsWith("data:")&&(Qe=Ie.slice(5).trim());if(Yt==="output"&&Qe)try{const{line:Ie}=JSON.parse(Qe);o(Ue=>Qt(Ue,ht=>ht.role==="system"&&ht.isStreaming?{content:ht.content?ht.content+`
247
- `+Ie:Ie}:{}))}catch{}else if(Yt==="complete"&&Qe)try{const{returncode:Ie,files_changed:Ue}=JSON.parse(Qe);o(ht=>Qt(ht,_s=>_s.role==="system"&&_s.isStreaming?{isStreaming:!1,filesChanged:Ue,returncode:Ie,content:_s.content||"Done."}:{})),(Ue==null?void 0:Ue.length)>0&&s&&s(Ue)}catch{}else if(Yt==="error"&&Qe)try{const{error:Ie}=JSON.parse(Qe);o(Ue=>Qt(Ue,ht=>ht.role==="system"&&ht.isStreaming?{isStreaming:!1,content:`Error: ${Ie}`}:{}))}catch{}}}}catch(Q){if(Q instanceof DOMException&&Q.name==="AbortError")return;await _e(T)}finally{_(!1),m(!1),U.current=null,G.current=null,(q=w.current)==null||q.focus()}},[e,s,_e]),z=async()=>{var Ze;const T=a.trim();if(!T&&!p||u)return;m(!0),C(null);let Y,q,Q="";if(p){y(!0);try{Y=await xv(p.file);const We=await W.chatImageUpload(e,p.file);q=We.filename,Q=`[Attached image: ${We.filename} (id: ${We.image_id})] Make it look like this. `}catch{C("The attachment was refused and no message was sent. Use a valid PNG, JPEG, GIF, or WebP image up to 10 MiB."),y(!1),m(!1);return}y(!1)}const le=Q+(T||"Make changes based on this screenshot."),ke={role:"user",content:T||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:Y,imageName:q},Pe={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(We=>[...We,ke,Pe]),l(""),p&&R(p.previewUrl),g(null);try{const We=n.filter(ae=>ae.role==="user"||ae.role==="system"&&!ae.isStreaming&&ae.content).slice(-10).map(ae=>({role:ae.role==="user"?"user":"assistant",content:ae.content})),{task_id:ut}=await W.chatStart(e,le,h,We.length>0?We:void 0);await He(ut)}catch(We){o(ut=>Qt(ut,ae=>ae.role==="system"&&ae.isStreaming?{isStreaming:!1,content:`Error: ${We instanceof Error?We.message:"Request failed"}`}:{})),m(!1),(Ze=w.current)==null||Ze.focus()}};return r.jsxs("div",{ref:K,className:`flex flex-col h-full relative ${S?"ring-2 ring-primary ring-inset":""}`,onDragOver:ie,onDragLeave:ue,onDrop:fe,children:[S&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[r.jsx(la,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&r.jsxs("div",{className:"flex items-start gap-2 py-6 px-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:r.jsx("p",{className:"leading-relaxed",children:"Hey! I'm Loki, your AI coding companion. Tell me what you want to build and I'll make it happen."})})]}),n.map((T,Y)=>r.jsx(uv,{msg:T,msgIndex:Y},Y)),f&&r.jsx(dv,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&r.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[r.jsxs("span",{className:"text-[10px] text-muted font-mono flex items-center gap-1.5",children:["Loki is thinking",r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]})]}),r.jsxs("button",{onClick:de,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(sr,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(i==null?void 0:i.some(T=>T.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Kl,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(xe=i.find(T=>T.fix_status==="fixing"))==null?void 0:xe.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(T=>r.jsx("button",{onClick:()=>c(T),title:fv[T],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===T?"bg-primary text-white":"text-muted hover:text-ink"}`,children:T},T))}),p&&r.jsxs("div",{role:"group","aria-label":"Selected attachment","aria-live":"polite",className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p.previewUrl,alt:`Preview of ${p.file.name}`,className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:L,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image","aria-label":`Remove ${p.file.name}`,children:r.jsx(_t,{size:10})})]}),r.jsxs("div",{className:"min-w-0 text-[10px] text-muted",children:[r.jsx("p",{className:"truncate max-w-[180px] text-ink",title:p.file.name,children:p.file.name}),r.jsxs("p",{children:[p.file.type," · ",_v(p.file.size)]})]}),v&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),x&&r.jsx("p",{role:"alert",className:"mb-2 px-1 text-[11px] text-red-400",children:x}),!f&&r.jsx(av,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:T=>l(T),className:"mb-2"}),r.jsx("p",{id:"chat-attachment-guidance",className:"mb-1 px-1 text-[10px] text-muted",children:"Attach one PNG, JPEG, GIF, or WebP image up to 10 MiB."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:D,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:T=>{var q;const Y=(q=T.target.files)==null?void 0:q[0];Y&&E(Y),T.target.value=""}}),r.jsx("button",{ref:B,onClick:()=>{var T;return(T=D.current)==null?void 0:T.click()},disabled:u,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)","aria-label":"Attach image","aria-describedby":"chat-attachment-guidance",children:r.jsx(la,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(hv,{visible:k,filter:J,selectedIndex:V,onSelect:T=>{var Q;const Y=a.lastIndexOf("@"),q=Y>=0?a.slice(0,Y):a;l(q+T+" "),P(!1),Z(0),(Q=w.current)==null||Q.focus()},onClose:()=>P(!1)}),r.jsx("textarea",{ref:w,value:a,onChange:T=>{const Y=T.target.value;l(Y);const q=Y.lastIndexOf("@");if(q>=0){const Q=Y.slice(q);/^@\w*$/.test(Q)?(P(!0),oe(Q),Z(0)):P(!1)}else P(!1)},onKeyDown:T=>{if(k){if(T.key==="ArrowDown"){T.preventDefault(),Z(Y=>Math.min(Y+1,Jn.length-1));return}if(T.key==="ArrowUp"){T.preventDefault(),Z(Y=>Math.max(Y-1,0));return}if(T.key==="Tab"||T.key==="Enter"&&!T.shiftKey){T.preventDefault();const Y=Jn.filter(q=>q.label.toLowerCase().includes(J.toLowerCase()));if(Y[V]){const q=a.lastIndexOf("@"),Q=q>=0?a.slice(0,q):a;l(Q+Y[V].label+" "),P(!1),Z(0)}return}if(T.key==="Escape"){P(!1);return}}T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),z())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:u})]}),f?r.jsx(he,{size:"sm",icon:sr,onClick:de,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(he,{size:"sm",icon:ju,onClick:z,disabled:u||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}function bv(e){const t=[],s=e.gatePassRate*100;t.push({label:"Quality Gates",value:s,weight:.4,description:`${Math.round(s)}% of quality gates passing`});const i=Math.min(e.testCoverage,100);t.push({label:"Test Coverage",value:i,weight:.3,description:`${Math.round(i)}% code covered by tests`});const n=e.maxIterations>0?Math.min(e.iteration/e.maxIterations*100,100):50;t.push({label:"Iteration Progress",value:n,weight:.2,description:`${e.iteration}/${e.maxIterations} iterations completed`});const a={planning:30,building:50,testing:75,reviewing:90,complete:100,idle:0}[e.phase]??40;t.push({label:"Build Phase",value:a,weight:.1,description:`Currently in ${e.phase} phase`});const l=t.reduce((h,c)=>h+c.value*c.weight,0);return{score:Math.round(Math.min(l,100)),factors:t}}function Dh(e){return e>=80?{ring:"#1FC5A8",text:"text-success",bg:"bg-success/10",label:"High"}:e>=60?{ring:"#D4A03C",text:"text-warning",bg:"bg-warning/10",label:"Medium"}:{ring:"#C45B5B",text:"text-danger",bg:"bg-danger/10",label:"Low"}}function Ol({score:e,size:t=48}){const s=t<40?3:4,i=(t-s*2)/2,n=2*Math.PI*i,o=e/100*n,a=Dh(e);return r.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:t,height:t},children:[r.jsxs("svg",{width:t,height:t,className:"-rotate-90",children:[r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",className:"text-border",strokeWidth:s}),r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:a.ring,strokeWidth:s,strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:n-o,className:"transition-all duration-1000 ease-out"})]}),r.jsx("span",{className:`absolute text-center font-mono font-bold ${a.text}`,style:{fontSize:t<40?"10px":"12px"},children:e})]})}function yv(e){const[t,s]=d.useState(!1),{score:i,factors:n}=bv(e),o=Dh(i);return e.compact?r.jsxs("div",{className:"relative inline-flex items-center gap-1.5",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx(Ol,{score:i,size:28}),r.jsx("span",{className:`text-xs font-medium ${o.text}`,children:o.label}),t&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 w-56",children:[r.jsxs("div",{className:"text-xs font-semibold text-ink mb-2",children:["AI Confidence: ",i,"%"]}),n.map(a=>r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted mb-1",children:[r.jsx("span",{children:a.label}),r.jsxs("span",{className:"font-mono",children:[Math.round(a.value),"%"]})]},a.label))]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]}):r.jsxs("div",{className:"card p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx(Ol,{score:i,size:56}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"AI Confidence"}),r.jsxs("div",{className:`text-xs font-medium ${o.text} flex items-center gap-1`,children:[o.label," Confidence",r.jsxs("div",{className:"relative",children:[r.jsx(ql,{size:12,className:"text-muted cursor-help",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)}),t&&r.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 w-64 pointer-events-none",children:r.jsx("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2",children:r.jsx("p",{className:"text-[11px] text-muted leading-relaxed",children:"Confidence is computed from quality gate pass rate (40%), test coverage (30%), iteration progress (20%), and build phase maturity (10%)."})})})]})]})]})]}),r.jsx("div",{className:"space-y-2.5",children:n.map(a=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-xs text-secondary",children:a.label}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[Math.round(a.value),"%"]})]}),r.jsx("div",{className:"w-full h-1.5 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${a.value>=80?"bg-success":a.value>=60?"bg-warning":"bg-danger"}`,style:{width:`${Math.min(a.value,100)}%`}})}),r.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:a.description})]},a.label))})]})}function Qi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function er(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function Sv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function wv(e){return e>=90?{label:"Excellent",color:"text-success"}:e>=75?{label:"Good",color:"text-teal"}:e>=60?{label:"Fair",color:"text-warning"}:{label:"Needs Work",color:"text-danger"}}function Cs({icon:e,label:t,value:s,subtext:i,iconColor:n="text-primary"}){return r.jsxs("div",{className:"bg-hover/40 rounded-card p-3 flex flex-col items-center text-center",children:[r.jsx(e,{size:18,className:`${n} mb-1.5`}),r.jsx("div",{className:"text-lg font-bold font-mono text-ink leading-tight",children:s}),r.jsx("div",{className:"text-[11px] text-muted font-medium mt-0.5",children:t}),i&&r.jsx("div",{className:"text-[11px] text-muted/60 mt-0.5",children:i})]})}function Cv({phase:e,maxDuration:t}){const s=t>0?e.durationSecs/t*100:0,i={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-secondary w-16 text-right flex-shrink-0",children:e.label}),r.jsxs("div",{className:"flex-1 h-4 bg-border rounded-sm overflow-hidden relative",children:[r.jsx("div",{className:`h-full rounded-sm transition-all duration-700 ease-out ${i[e.phase]||"bg-primary"}`,style:{width:`${s}%`}}),r.jsxs("span",{className:"absolute inset-0 flex items-center px-2 text-[10px] font-mono text-white mix-blend-difference",children:[er(e.durationSecs)," | ",Qi(e.tokenCount)," tokens"]})]}),r.jsxs("span",{className:"text-[11px] font-mono text-muted w-10 text-right flex-shrink-0",children:[Math.round(e.percentage),"%"]})]})}function kv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:u,provider:m,onShare:f,className:_=""}){const[p,g]=d.useState(!0),v=wv(h),y=Math.max(...a.map(C=>C.durationSecs),1),x=()=>{const C=["Build Insights Summary","=====================",`Provider: ${m}`,`Total Time: ${er(l)}`,`Iterations: ${u}`,`Cost: $${c.toFixed(2)}`,"","Output:",` Files Created: ${e}`,` Files Modified: ${t}`,` Lines Generated: ${s}`,` Tests Generated: ${i}`,` Test Pass Rate: ${Math.round(n*100)}%`,"","Resources:",` Total Tokens: ${Qi(o)}`,` Quality Score: ${h}/100 (${v.label})`,"","Time Breakdown:",...a.map(j=>` ${j.label}: ${er(j.durationSecs)} (${Math.round(j.percentage)}%)`)].join(`
248
- `);f==null||f(C)};return r.jsxs("div",{className:`card overflow-hidden ${_}`,children:[r.jsxs("button",{onClick:()=>g(!p),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(tn,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),r.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-pill ${h>=80?"bg-success/10 text-success":h>=60?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:v.label})]}),r.jsx("span",{className:"text-muted",children:p?r.jsx(ur,{size:16}):r.jsx(fs,{size:16})})]}),p&&r.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(Cs,{icon:ee,label:"Files",value:String(e+t),subtext:`${e} new, ${t} modified`,iconColor:"text-primary"}),r.jsx(Cs,{icon:on,label:"Lines of Code",value:Sv(s),iconColor:"text-info"}),r.jsx(Cs,{icon:ni,label:"Tests",value:String(i),subtext:`${Math.round(n*100)}% passing`,iconColor:"text-teal"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(Cs,{icon:is,label:"Tokens Used",value:Qi(o),iconColor:"text-warning"}),r.jsx(Cs,{icon:ct,label:"Build Time",value:er(l),subtext:`${u} iterations`,iconColor:"text-muted"}),r.jsx(Cs,{icon:Cd,label:"Quality",value:`${h}`,subtext:v.label,iconColor:v.color})]}),r.jsxs("div",{className:"flex items-center justify-between bg-hover/40 rounded-card px-3 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx($d,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-medium text-ink",children:"Total Cost"})]}),r.jsxs("span",{className:"text-sm font-bold font-mono text-ink",children:["$",c.toFixed(2)]})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Id,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Time Breakdown"})]}),r.jsx("div",{className:"space-y-1.5",children:a.map(C=>r.jsx(Cv,{phase:C,maxDuration:y},C.phase))})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(is,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Token Distribution"})]}),r.jsx("div",{className:"flex h-3 rounded-full overflow-hidden bg-border",children:a.map(C=>{const j={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsx("div",{className:`h-full transition-all duration-700 ${j[C.phase]||"bg-primary"}`,style:{width:`${C.percentage}%`},title:`${C.label}: ${Qi(C.tokenCount)} tokens (${Math.round(C.percentage)}%)`},C.phase)})}),r.jsx("div",{className:"flex items-center justify-between mt-1",children:a.map(C=>{const j={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${j[C.phase]||"bg-primary"}`}),C.label]},C.phase)})})]}),f&&r.jsx("div",{className:"flex justify-end pt-1",children:r.jsxs("button",{onClick:x,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
249
- text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(ao,{size:12}),"Share Insights"]})})]})]})}const $l=[1,2,5];function jv(e){const t=[];let s=0;const i=600,n=["planning","building","testing","reviewing","complete"],o=e.phases.length>0?e.phases:n;for(const a of o){if(t.push({timestamp:s,type:"phase_change",label:`Phase: ${a}`,phase:a}),s+=i,a==="building")for(const l of e.files.filter(h=>h.type==="file"))t.push({timestamp:s,type:"file_created",label:l.path,detail:l.path}),s+=i*.4;if(a==="testing"||a==="reviewing")for(const l of e.qualityGates){const h=l.status==="pass"?"gate_pass":"gate_fail";t.push({timestamp:s,type:h,label:l.label,phase:a}),s+=i*.3}}for(let a=1;a<=e.totalIterations;a++){const l=a/e.totalIterations*s;t.push({timestamp:l,type:"iteration",label:`Iteration ${a}/${e.totalIterations}`})}return t.sort((a,l)=>a.timestamp-l.timestamp),t}function Nv({path:e,visible:t,delay:s}){const i=e.split("/"),n=i[i.length-1],o=i.length-1;return r.jsxs("div",{className:`flex items-center gap-1.5 py-0.5 transition-all duration-500 ${t?"opacity-100 translate-x-0":"opacity-0 -translate-x-4"}`,style:{paddingLeft:`${o*16+8}px`,transitionDelay:`${s}ms`},children:[r.jsx(ee,{size:12,className:"text-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:n})]})}function Ev({sessionId:e,files:t,phases:s,checkpoints:i,qualityGates:n,totalIterations:o,onShare:a}){var S,N;const[l,h]=d.useState(!1),[c,u]=d.useState(0),[m,f]=d.useState(0),[_,p]=d.useState(!1),g=d.useRef(null),v=d.useRef(0),y=d.useRef([]);y.current.length===0&&(y.current=jv({files:t,phases:s,qualityGates:n,totalIterations:o}));const x=y.current.length>0?y.current[y.current.length-1].timestamp+600:1,C=y.current.filter(k=>k.timestamp<=m),j=new Set(C.filter(k=>k.type==="file_created").map(k=>k.detail)),w=((S=[...C].reverse().find(k=>k.type==="phase_change"))==null?void 0:S.phase)||"idle",D=C.filter(k=>k.type==="gate_pass").length,B=C.filter(k=>k.type==="gate_fail").length,U=((N=[...C].reverse().find(k=>k.type==="iteration"))==null?void 0:N.label)||"",G=$l[c],K=d.useCallback(k=>{v.current===0&&(v.current=k);const P=(k-v.current)*G;v.current=k,f(J=>{const oe=J+P;return oe>=x?(h(!1),x):oe}),g.current=requestAnimationFrame(K)},[G,x]);d.useEffect(()=>(l?(v.current=0,g.current=requestAnimationFrame(K)):g.current&&cancelAnimationFrame(g.current),()=>{g.current&&cancelAnimationFrame(g.current)}),[l,K]);const A=()=>{h(!1),f(0)},R=k=>{f(Number(k.target.value))},E=()=>{const k=[`Build Replay: Session ${e}`,`Total iterations: ${o}`,`Files created: ${t.filter(P=>P.type==="file").length}`,`Quality gates: ${D} passed, ${B} failed`,`Phases: ${s.join(" > ")}`].join(`
250
- `);a==null||a(k)},L=x>0?m/x*100:0;return _?r.jsxs("div",{className:"card overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Replay"}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("button",{onClick:()=>p(!1),className:"text-xs text-muted hover:text-ink transition-colors",children:"Collapse"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0 min-h-[240px]",children:[r.jsxs("div",{className:"border-r border-border p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"File Tree"}),t.filter(k=>k.type==="file").length===0?r.jsx("div",{className:"text-xs text-muted py-4 text-center",children:"No files to display"}):t.filter(k=>k.type==="file").map((k,P)=>r.jsx(Nv,{path:k.path,visible:j.has(k.path),delay:P*30},k.path))]}),r.jsxs("div",{className:"p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"Activity"}),r.jsx("div",{className:"space-y-1",children:C.slice(-20).map((k,P)=>r.jsxs("div",{className:"flex items-center gap-2 text-xs animate-fade-in",children:[k.type==="file_created"&&r.jsx(ee,{size:11,className:"text-primary flex-shrink-0"}),k.type==="phase_change"&&r.jsx(ct,{size:11,className:"text-info flex-shrink-0"}),k.type==="gate_pass"&&r.jsx(Dt,{size:11,className:"text-success flex-shrink-0"}),k.type==="gate_fail"&&r.jsx(Dt,{size:11,className:"text-danger flex-shrink-0"}),k.type==="iteration"&&r.jsx(Xl,{size:11,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:`truncate ${k.type==="phase_change"?"font-semibold text-ink":k.type==="gate_fail"?"text-danger":"text-secondary"}`,children:k.label})]},`${k.timestamp}-${P}`))})]})]}),r.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 bg-hover/50 border-t border-border text-xs text-muted",children:[r.jsx("span",{className:"font-medium text-ink capitalize",children:w}),r.jsxs("span",{children:[j.size," files"]}),r.jsxs("span",{className:"text-success",children:[D," passed"]}),B>0&&r.jsxs("span",{className:"text-danger",children:[B," failed"]}),U&&r.jsx("span",{className:"font-mono",children:U})]}),r.jsxs("div",{className:"px-4 py-2 border-t border-border",children:[r.jsx("div",{className:"relative w-full h-1.5 bg-border rounded-full overflow-hidden mb-2",children:r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal rounded-full transition-all duration-100",style:{width:`${L}%`}})}),r.jsx("input",{type:"range",min:0,max:x,value:m,onChange:R,className:"w-full h-1 opacity-0 absolute cursor-pointer",style:{marginTop:"-14px"}})]}),r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-border",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>h(!l),className:"p-1.5 rounded-card hover:bg-hover transition-colors text-ink",title:l?"Pause":"Play",children:l?r.jsx(Zl,{size:16}):r.jsx(Ut,{size:16})}),r.jsx("button",{onClick:A,className:"p-1.5 rounded-card hover:bg-hover transition-colors text-muted",title:"Reset",children:r.jsx(rc,{size:14})}),r.jsxs("button",{onClick:()=>u((c+1)%$l.length),className:"px-2 py-1 rounded-card hover:bg-hover transition-colors text-xs font-mono text-muted",title:"Playback speed",children:[G,"x"]})]}),r.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(ao,{size:12}),"Share Replay"]})]})]}):r.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(Ut,{size:14}),"Replay Build"]})}function Dv(e){const t=e.toLowerCase().trim(),s=[];let i;const n=t.match(/where (?:is|are) (?:the )?(.+?)(?:\?|$)/);n&&s.push(...n[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l)));const o=t.match(/show (?:me )?(?:all )?(.+?)(?:\?|$)/);o&&s.length===0&&s.push(...o[1].split(/\s+/).filter(l=>!["the","a","an","my","all"].includes(l)));const a=t.match(/find (?:the )?(.+?)(?:\?|$)/);return a&&s.length===0&&s.push(...a[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l))),(t.includes("api endpoint")||t.includes("route")||t.includes("handler"))&&(i="api",s.length===0&&s.push("app.get","app.post","router","@app.route","endpoint")),(t.includes("database")||t.includes("db connection")||t.includes("schema"))&&s.length===0&&s.push("database","connection","schema","model","migration"),(t.includes("login")||t.includes("auth")||t.includes("authentication"))&&s.length===0&&s.push("auth","login","session","token","password"),(t.includes("test")||t.includes("spec"))&&(i="test",s.length===0&&s.push("describe","it(","test(","expect")),(t.includes("style")||t.includes("css")||t.includes("theme"))&&(i="css",s.length===0&&s.push("style","theme","color","font")),(t.includes("config")||t.includes("configuration")||t.includes("settings"))&&s.length===0&&s.push("config","settings","env","options"),s.length===0&&s.push(...t.split(/\s+/).filter(l=>l.length>2&&!["the","a","an","my","all","show","me","find","where","is","are","how"].includes(l))),{terms:s,filePattern:i}}function Rv(e,t){let s=0;const i=e.path.toLowerCase(),n=e.name.toLowerCase();for(const o of t){const a=o.toLowerCase();n===a?s+=100:n.includes(a)?s+=60:i.includes(a)&&(s+=30)}return s+=Math.max(0,20-e.path.split("/").length*2),s}const Pv=["Where is the login function?","Show me all API endpoints","Find the database connection","Where are the tests?","Show me the configuration files"];function Mv({sessionId:e,onOpenFile:t,className:s=""}){const[i,n]=d.useState(""),[o,a]=d.useState([]),[l,h]=d.useState(!1),[c,u]=d.useState(!1),[m,f]=d.useState(!1),_=d.useRef(null),p=d.useRef(null),g=d.useCallback(async w=>{if(!w.trim()||!e){a([]),f(!1);return}h(!0),f(!0);try{const{terms:D}=Dv(w),B=D.join(" "),G=(await W.searchFiles(e,B)).map(K=>({path:K.path,name:K.name,relevanceScore:Rv(K,D)}));G.sort((K,A)=>A.relevanceScore-K.relevanceScore),a(G.slice(0,15))}catch{a([])}finally{h(!1)}},[e]),v=w=>{n(w),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>g(w),400)},y=w=>{w.preventDefault(),p.current&&clearTimeout(p.current),g(i)},x=()=>{var w;n(""),a([]),f(!1),(w=_.current)==null||w.focus()},C=w=>{n(w),g(w)};d.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const j=w=>w.includes(".test.")||w.includes(".spec.")?"text-teal":w.endsWith(".css")||w.endsWith(".scss")?"text-pink":w.endsWith(".json")||w.endsWith(".yaml")?"text-warning":w.endsWith(".md")?"text-muted":"text-primary";return r.jsxs("div",{className:`card overflow-hidden ${s}`,children:[r.jsxs("div",{className:"px-4 pt-4 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(os,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Code Search"})]}),r.jsx("p",{className:"text-[11px] text-muted mb-3",children:'Search in natural language -- "Where is the login function?"'}),r.jsxs("form",{onSubmit:y,className:"relative",children:[r.jsx(os,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{ref:_,type:"text",value:i,onChange:w=>v(w.target.value),onFocus:()=>u(!0),onBlur:()=>setTimeout(()=>u(!1),200),placeholder:"Ask about your code...",className:`w-full pl-9 pr-8 py-2 text-sm bg-hover/50 border border-border rounded-card
247
+ `+Ie:Ie}:{}))}catch{}else if(Yt==="complete"&&Qe)try{const{returncode:Ie,files_changed:Ue}=JSON.parse(Qe);o(ht=>Qt(ht,xs=>xs.role==="system"&&xs.isStreaming?{isStreaming:!1,filesChanged:Ue,returncode:Ie,content:xs.content||"Done."}:{})),(Ue==null?void 0:Ue.length)>0&&s&&s(Ue)}catch{}else if(Yt==="error"&&Qe)try{const{error:Ie}=JSON.parse(Qe);o(Ue=>Qt(Ue,ht=>ht.role==="system"&&ht.isStreaming?{isStreaming:!1,content:`Error: ${Ie}`}:{}))}catch{}}}}catch(Q){if(Q instanceof DOMException&&Q.name==="AbortError")return;await _e(T)}finally{_(!1),m(!1),U.current=null,G.current=null,(q=w.current)==null||q.focus()}},[e,s,_e]),z=async()=>{var Ze;const T=a.trim();if(!T&&!p||u)return;m(!0),C(null);let Y,q,Q="";if(p){y(!0);try{Y=await xv(p.file);const We=await W.chatImageUpload(e,p.file);q=We.filename,Q=`[Attached image: ${We.filename} (id: ${We.image_id})] Make it look like this. `}catch{C("The attachment was refused and no message was sent. Use a valid PNG, JPEG, GIF, or WebP image up to 10 MiB."),y(!1),m(!1);return}y(!1)}const le=Q+(T||"Make changes based on this screenshot."),ke={role:"user",content:T||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:Y,imageName:q},Pe={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(We=>[...We,ke,Pe]),l(""),p&&D(p.previewUrl),g(null);try{const We=n.filter(ae=>ae.role==="user"||ae.role==="system"&&!ae.isStreaming&&ae.content).slice(-10).map(ae=>({role:ae.role==="user"?"user":"assistant",content:ae.content})),{task_id:ut}=await W.chatStart(e,le,h,We.length>0?We:void 0);await He(ut)}catch(We){o(ut=>Qt(ut,ae=>ae.role==="system"&&ae.isStreaming?{isStreaming:!1,content:`Error: ${We instanceof Error?We.message:"Request failed"}`}:{})),m(!1),(Ze=w.current)==null||Ze.focus()}};return r.jsxs("div",{ref:K,className:`flex flex-col h-full relative ${S?"ring-2 ring-primary ring-inset":""}`,onDragOver:ie,onDragLeave:ue,onDrop:fe,children:[S&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[r.jsx(la,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&r.jsxs("div",{className:"flex items-start gap-2 py-6 px-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:r.jsx("p",{className:"leading-relaxed",children:"Hey! I'm Loki, your AI coding companion. Tell me what you want to build and I'll make it happen."})})]}),n.map((T,Y)=>r.jsx(uv,{msg:T,msgIndex:Y},Y)),f&&r.jsx(dv,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&r.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[r.jsxs("span",{className:"text-[10px] text-muted font-mono flex items-center gap-1.5",children:["Loki is thinking",r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]})]}),r.jsxs("button",{onClick:de,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(sr,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(i==null?void 0:i.some(T=>T.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Kl,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(xe=i.find(T=>T.fix_status==="fixing"))==null?void 0:xe.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(T=>r.jsx("button",{onClick:()=>c(T),title:fv[T],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===T?"bg-primary text-white":"text-muted hover:text-ink"}`,children:T},T))}),p&&r.jsxs("div",{role:"group","aria-label":"Selected attachment","aria-live":"polite",className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p.previewUrl,alt:`Preview of ${p.file.name}`,className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:L,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image","aria-label":`Remove ${p.file.name}`,children:r.jsx(_t,{size:10})})]}),r.jsxs("div",{className:"min-w-0 text-[10px] text-muted",children:[r.jsx("p",{className:"truncate max-w-[180px] text-ink",title:p.file.name,children:p.file.name}),r.jsxs("p",{children:[p.file.type," · ",_v(p.file.size)]})]}),v&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),x&&r.jsx("p",{role:"alert",className:"mb-2 px-1 text-[11px] text-red-400",children:x}),!f&&r.jsx(av,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:T=>l(T),className:"mb-2"}),r.jsx("p",{id:"chat-attachment-guidance",className:"mb-1 px-1 text-[10px] text-muted",children:"Attach one PNG, JPEG, GIF, or WebP image up to 10 MiB."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:R,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:T=>{var q;const Y=(q=T.target.files)==null?void 0:q[0];Y&&E(Y),T.target.value=""}}),r.jsx("button",{ref:B,onClick:()=>{var T;return(T=R.current)==null?void 0:T.click()},disabled:u,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)","aria-label":"Attach image","aria-describedby":"chat-attachment-guidance",children:r.jsx(la,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(hv,{visible:k,filter:J,selectedIndex:V,onSelect:T=>{var Q;const Y=a.lastIndexOf("@"),q=Y>=0?a.slice(0,Y):a;l(q+T+" "),P(!1),Z(0),(Q=w.current)==null||Q.focus()},onClose:()=>P(!1)}),r.jsx("textarea",{ref:w,value:a,onChange:T=>{const Y=T.target.value;l(Y);const q=Y.lastIndexOf("@");if(q>=0){const Q=Y.slice(q);/^@\w*$/.test(Q)?(P(!0),oe(Q),Z(0)):P(!1)}else P(!1)},onKeyDown:T=>{if(k){if(T.key==="ArrowDown"){T.preventDefault(),Z(Y=>Math.min(Y+1,Jn.length-1));return}if(T.key==="ArrowUp"){T.preventDefault(),Z(Y=>Math.max(Y-1,0));return}if(T.key==="Tab"||T.key==="Enter"&&!T.shiftKey){T.preventDefault();const Y=Jn.filter(q=>q.label.toLowerCase().includes(J.toLowerCase()));if(Y[V]){const q=a.lastIndexOf("@"),Q=q>=0?a.slice(0,q):a;l(Q+Y[V].label+" "),P(!1),Z(0)}return}if(T.key==="Escape"){P(!1);return}}T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),z())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:u})]}),f?r.jsx(he,{size:"sm",icon:sr,onClick:de,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(he,{size:"sm",icon:ju,onClick:z,disabled:u||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}function bv(e){const t=[],s=e.gatePassRate*100;t.push({label:"Quality Gates",value:s,weight:.4,description:`${Math.round(s)}% of quality gates passing`});const i=Math.min(e.testCoverage,100);t.push({label:"Test Coverage",value:i,weight:.3,description:`${Math.round(i)}% code covered by tests`});const n=e.maxIterations>0?Math.min(e.iteration/e.maxIterations*100,100):50;t.push({label:"Iteration Progress",value:n,weight:.2,description:`${e.iteration}/${e.maxIterations} iterations completed`});const a={planning:30,building:50,testing:75,reviewing:90,complete:100,idle:0}[e.phase]??40;t.push({label:"Build Phase",value:a,weight:.1,description:`Currently in ${e.phase} phase`});const l=t.reduce((h,c)=>h+c.value*c.weight,0);return{score:Math.round(Math.min(l,100)),factors:t}}function Rh(e){return e>=80?{ring:"#1FC5A8",text:"text-success",bg:"bg-success/10",label:"High"}:e>=60?{ring:"#D4A03C",text:"text-warning",bg:"bg-warning/10",label:"Medium"}:{ring:"#C45B5B",text:"text-danger",bg:"bg-danger/10",label:"Low"}}function Ol({score:e,size:t=48}){const s=t<40?3:4,i=(t-s*2)/2,n=2*Math.PI*i,o=e/100*n,a=Rh(e);return r.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:t,height:t},children:[r.jsxs("svg",{width:t,height:t,className:"-rotate-90",children:[r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",className:"text-border",strokeWidth:s}),r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:a.ring,strokeWidth:s,strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:n-o,className:"transition-all duration-1000 ease-out"})]}),r.jsx("span",{className:`absolute text-center font-mono font-bold ${a.text}`,style:{fontSize:t<40?"10px":"12px"},children:e})]})}function yv(e){const[t,s]=d.useState(!1),{score:i,factors:n}=bv(e),o=Rh(i);return e.compact?r.jsxs("div",{className:"relative inline-flex items-center gap-1.5",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx(Ol,{score:i,size:28}),r.jsx("span",{className:`text-xs font-medium ${o.text}`,children:o.label}),t&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 w-56",children:[r.jsxs("div",{className:"text-xs font-semibold text-ink mb-2",children:["AI Confidence: ",i,"%"]}),n.map(a=>r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted mb-1",children:[r.jsx("span",{children:a.label}),r.jsxs("span",{className:"font-mono",children:[Math.round(a.value),"%"]})]},a.label))]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]}):r.jsxs("div",{className:"card p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx(Ol,{score:i,size:56}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"AI Confidence"}),r.jsxs("div",{className:`text-xs font-medium ${o.text} flex items-center gap-1`,children:[o.label," Confidence",r.jsxs("div",{className:"relative",children:[r.jsx(ql,{size:12,className:"text-muted cursor-help",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)}),t&&r.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 w-64 pointer-events-none",children:r.jsx("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2",children:r.jsx("p",{className:"text-[11px] text-muted leading-relaxed",children:"Confidence is computed from quality gate pass rate (40%), test coverage (30%), iteration progress (20%), and build phase maturity (10%)."})})})]})]})]})]}),r.jsx("div",{className:"space-y-2.5",children:n.map(a=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-xs text-secondary",children:a.label}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[Math.round(a.value),"%"]})]}),r.jsx("div",{className:"w-full h-1.5 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${a.value>=80?"bg-success":a.value>=60?"bg-warning":"bg-danger"}`,style:{width:`${Math.min(a.value,100)}%`}})}),r.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:a.description})]},a.label))})]})}function Qi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function er(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function Sv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function wv(e){return e>=90?{label:"Excellent",color:"text-success"}:e>=75?{label:"Good",color:"text-teal"}:e>=60?{label:"Fair",color:"text-warning"}:{label:"Needs Work",color:"text-danger"}}function ks({icon:e,label:t,value:s,subtext:i,iconColor:n="text-primary"}){return r.jsxs("div",{className:"bg-hover/40 rounded-card p-3 flex flex-col items-center text-center",children:[r.jsx(e,{size:18,className:`${n} mb-1.5`}),r.jsx("div",{className:"text-lg font-bold font-mono text-ink leading-tight",children:s}),r.jsx("div",{className:"text-[11px] text-muted font-medium mt-0.5",children:t}),i&&r.jsx("div",{className:"text-[11px] text-muted/60 mt-0.5",children:i})]})}function Cv({phase:e,maxDuration:t}){const s=t>0?e.durationSecs/t*100:0,i={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-secondary w-16 text-right flex-shrink-0",children:e.label}),r.jsxs("div",{className:"flex-1 h-4 bg-border rounded-sm overflow-hidden relative",children:[r.jsx("div",{className:`h-full rounded-sm transition-all duration-700 ease-out ${i[e.phase]||"bg-primary"}`,style:{width:`${s}%`}}),r.jsxs("span",{className:"absolute inset-0 flex items-center px-2 text-[10px] font-mono text-white mix-blend-difference",children:[er(e.durationSecs)," | ",Qi(e.tokenCount)," tokens"]})]}),r.jsxs("span",{className:"text-[11px] font-mono text-muted w-10 text-right flex-shrink-0",children:[Math.round(e.percentage),"%"]})]})}function kv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:u,provider:m,onShare:f,className:_=""}){const[p,g]=d.useState(!0),v=wv(h),y=Math.max(...a.map(C=>C.durationSecs),1),x=()=>{const C=["Build Insights Summary","=====================",`Provider: ${m}`,`Total Time: ${er(l)}`,`Iterations: ${u}`,`Cost: $${c.toFixed(2)}`,"","Output:",` Files Created: ${e}`,` Files Modified: ${t}`,` Lines Generated: ${s}`,` Tests Generated: ${i}`,` Test Pass Rate: ${Math.round(n*100)}%`,"","Resources:",` Total Tokens: ${Qi(o)}`,` Quality Score: ${h}/100 (${v.label})`,"","Time Breakdown:",...a.map(j=>` ${j.label}: ${er(j.durationSecs)} (${Math.round(j.percentage)}%)`)].join(`
248
+ `);f==null||f(C)};return r.jsxs("div",{className:`card overflow-hidden ${_}`,children:[r.jsxs("button",{onClick:()=>g(!p),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(tn,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),r.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-pill ${h>=80?"bg-success/10 text-success":h>=60?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:v.label})]}),r.jsx("span",{className:"text-muted",children:p?r.jsx(ur,{size:16}):r.jsx(fs,{size:16})})]}),p&&r.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(ks,{icon:ee,label:"Files",value:String(e+t),subtext:`${e} new, ${t} modified`,iconColor:"text-primary"}),r.jsx(ks,{icon:an,label:"Lines of Code",value:Sv(s),iconColor:"text-info"}),r.jsx(ks,{icon:ni,label:"Tests",value:String(i),subtext:`${Math.round(n*100)}% passing`,iconColor:"text-teal"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(ks,{icon:is,label:"Tokens Used",value:Qi(o),iconColor:"text-warning"}),r.jsx(ks,{icon:ct,label:"Build Time",value:er(l),subtext:`${u} iterations`,iconColor:"text-muted"}),r.jsx(ks,{icon:Cd,label:"Quality",value:`${h}`,subtext:v.label,iconColor:v.color})]}),r.jsxs("div",{className:"flex items-center justify-between bg-hover/40 rounded-card px-3 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx($d,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-medium text-ink",children:"Total Cost"})]}),r.jsxs("span",{className:"text-sm font-bold font-mono text-ink",children:["$",c.toFixed(2)]})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Id,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Time Breakdown"})]}),r.jsx("div",{className:"space-y-1.5",children:a.map(C=>r.jsx(Cv,{phase:C,maxDuration:y},C.phase))})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(is,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Token Distribution"})]}),r.jsx("div",{className:"flex h-3 rounded-full overflow-hidden bg-border",children:a.map(C=>{const j={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsx("div",{className:`h-full transition-all duration-700 ${j[C.phase]||"bg-primary"}`,style:{width:`${C.percentage}%`},title:`${C.label}: ${Qi(C.tokenCount)} tokens (${Math.round(C.percentage)}%)`},C.phase)})}),r.jsx("div",{className:"flex items-center justify-between mt-1",children:a.map(C=>{const j={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${j[C.phase]||"bg-primary"}`}),C.label]},C.phase)})})]}),f&&r.jsx("div",{className:"flex justify-end pt-1",children:r.jsxs("button",{onClick:x,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
249
+ text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(ao,{size:12}),"Share Insights"]})})]})]})}const $l=[1,2,5];function jv(e){const t=[];let s=0;const i=600,n=["planning","building","testing","reviewing","complete"],o=e.phases.length>0?e.phases:n;for(const a of o){if(t.push({timestamp:s,type:"phase_change",label:`Phase: ${a}`,phase:a}),s+=i,a==="building")for(const l of e.files.filter(h=>h.type==="file"))t.push({timestamp:s,type:"file_created",label:l.path,detail:l.path}),s+=i*.4;if(a==="testing"||a==="reviewing")for(const l of e.qualityGates){const h=l.status==="pass"?"gate_pass":"gate_fail";t.push({timestamp:s,type:h,label:l.label,phase:a}),s+=i*.3}}for(let a=1;a<=e.totalIterations;a++){const l=a/e.totalIterations*s;t.push({timestamp:l,type:"iteration",label:`Iteration ${a}/${e.totalIterations}`})}return t.sort((a,l)=>a.timestamp-l.timestamp),t}function Nv({path:e,visible:t,delay:s}){const i=e.split("/"),n=i[i.length-1],o=i.length-1;return r.jsxs("div",{className:`flex items-center gap-1.5 py-0.5 transition-all duration-500 ${t?"opacity-100 translate-x-0":"opacity-0 -translate-x-4"}`,style:{paddingLeft:`${o*16+8}px`,transitionDelay:`${s}ms`},children:[r.jsx(ee,{size:12,className:"text-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:n})]})}function Ev({sessionId:e,files:t,phases:s,checkpoints:i,qualityGates:n,totalIterations:o,onShare:a}){var S,N;const[l,h]=d.useState(!1),[c,u]=d.useState(0),[m,f]=d.useState(0),[_,p]=d.useState(!1),g=d.useRef(null),v=d.useRef(0),y=d.useRef([]);y.current.length===0&&(y.current=jv({files:t,phases:s,qualityGates:n,totalIterations:o}));const x=y.current.length>0?y.current[y.current.length-1].timestamp+600:1,C=y.current.filter(k=>k.timestamp<=m),j=new Set(C.filter(k=>k.type==="file_created").map(k=>k.detail)),w=((S=[...C].reverse().find(k=>k.type==="phase_change"))==null?void 0:S.phase)||"idle",R=C.filter(k=>k.type==="gate_pass").length,B=C.filter(k=>k.type==="gate_fail").length,U=((N=[...C].reverse().find(k=>k.type==="iteration"))==null?void 0:N.label)||"",G=$l[c],K=d.useCallback(k=>{v.current===0&&(v.current=k);const P=(k-v.current)*G;v.current=k,f(J=>{const oe=J+P;return oe>=x?(h(!1),x):oe}),g.current=requestAnimationFrame(K)},[G,x]);d.useEffect(()=>(l?(v.current=0,g.current=requestAnimationFrame(K)):g.current&&cancelAnimationFrame(g.current),()=>{g.current&&cancelAnimationFrame(g.current)}),[l,K]);const A=()=>{h(!1),f(0)},D=k=>{f(Number(k.target.value))},E=()=>{const k=[`Build Replay: Session ${e}`,`Total iterations: ${o}`,`Files created: ${t.filter(P=>P.type==="file").length}`,`Quality gates: ${R} passed, ${B} failed`,`Phases: ${s.join(" > ")}`].join(`
250
+ `);a==null||a(k)},L=x>0?m/x*100:0;return _?r.jsxs("div",{className:"card overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Replay"}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("button",{onClick:()=>p(!1),className:"text-xs text-muted hover:text-ink transition-colors",children:"Collapse"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0 min-h-[240px]",children:[r.jsxs("div",{className:"border-r border-border p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"File Tree"}),t.filter(k=>k.type==="file").length===0?r.jsx("div",{className:"text-xs text-muted py-4 text-center",children:"No files to display"}):t.filter(k=>k.type==="file").map((k,P)=>r.jsx(Nv,{path:k.path,visible:j.has(k.path),delay:P*30},k.path))]}),r.jsxs("div",{className:"p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"Activity"}),r.jsx("div",{className:"space-y-1",children:C.slice(-20).map((k,P)=>r.jsxs("div",{className:"flex items-center gap-2 text-xs animate-fade-in",children:[k.type==="file_created"&&r.jsx(ee,{size:11,className:"text-primary flex-shrink-0"}),k.type==="phase_change"&&r.jsx(ct,{size:11,className:"text-info flex-shrink-0"}),k.type==="gate_pass"&&r.jsx(Rt,{size:11,className:"text-success flex-shrink-0"}),k.type==="gate_fail"&&r.jsx(Rt,{size:11,className:"text-danger flex-shrink-0"}),k.type==="iteration"&&r.jsx(Xl,{size:11,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:`truncate ${k.type==="phase_change"?"font-semibold text-ink":k.type==="gate_fail"?"text-danger":"text-secondary"}`,children:k.label})]},`${k.timestamp}-${P}`))})]})]}),r.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 bg-hover/50 border-t border-border text-xs text-muted",children:[r.jsx("span",{className:"font-medium text-ink capitalize",children:w}),r.jsxs("span",{children:[j.size," files"]}),r.jsxs("span",{className:"text-success",children:[R," passed"]}),B>0&&r.jsxs("span",{className:"text-danger",children:[B," failed"]}),U&&r.jsx("span",{className:"font-mono",children:U})]}),r.jsxs("div",{className:"px-4 py-2 border-t border-border",children:[r.jsx("div",{className:"relative w-full h-1.5 bg-border rounded-full overflow-hidden mb-2",children:r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal rounded-full transition-all duration-100",style:{width:`${L}%`}})}),r.jsx("input",{type:"range",min:0,max:x,value:m,onChange:D,className:"w-full h-1 opacity-0 absolute cursor-pointer",style:{marginTop:"-14px"}})]}),r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-border",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>h(!l),className:"p-1.5 rounded-card hover:bg-hover transition-colors text-ink",title:l?"Pause":"Play",children:l?r.jsx(Zl,{size:16}):r.jsx(Ut,{size:16})}),r.jsx("button",{onClick:A,className:"p-1.5 rounded-card hover:bg-hover transition-colors text-muted",title:"Reset",children:r.jsx(rc,{size:14})}),r.jsxs("button",{onClick:()=>u((c+1)%$l.length),className:"px-2 py-1 rounded-card hover:bg-hover transition-colors text-xs font-mono text-muted",title:"Playback speed",children:[G,"x"]})]}),r.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(ao,{size:12}),"Share Replay"]})]})]}):r.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(Ut,{size:14}),"Replay Build"]})}function Rv(e){const t=e.toLowerCase().trim(),s=[];let i;const n=t.match(/where (?:is|are) (?:the )?(.+?)(?:\?|$)/);n&&s.push(...n[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l)));const o=t.match(/show (?:me )?(?:all )?(.+?)(?:\?|$)/);o&&s.length===0&&s.push(...o[1].split(/\s+/).filter(l=>!["the","a","an","my","all"].includes(l)));const a=t.match(/find (?:the )?(.+?)(?:\?|$)/);return a&&s.length===0&&s.push(...a[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l))),(t.includes("api endpoint")||t.includes("route")||t.includes("handler"))&&(i="api",s.length===0&&s.push("app.get","app.post","router","@app.route","endpoint")),(t.includes("database")||t.includes("db connection")||t.includes("schema"))&&s.length===0&&s.push("database","connection","schema","model","migration"),(t.includes("login")||t.includes("auth")||t.includes("authentication"))&&s.length===0&&s.push("auth","login","session","token","password"),(t.includes("test")||t.includes("spec"))&&(i="test",s.length===0&&s.push("describe","it(","test(","expect")),(t.includes("style")||t.includes("css")||t.includes("theme"))&&(i="css",s.length===0&&s.push("style","theme","color","font")),(t.includes("config")||t.includes("configuration")||t.includes("settings"))&&s.length===0&&s.push("config","settings","env","options"),s.length===0&&s.push(...t.split(/\s+/).filter(l=>l.length>2&&!["the","a","an","my","all","show","me","find","where","is","are","how"].includes(l))),{terms:s,filePattern:i}}function Dv(e,t){let s=0;const i=e.path.toLowerCase(),n=e.name.toLowerCase();for(const o of t){const a=o.toLowerCase();n===a?s+=100:n.includes(a)?s+=60:i.includes(a)&&(s+=30)}return s+=Math.max(0,20-e.path.split("/").length*2),s}const Pv=["Where is the login function?","Show me all API endpoints","Find the database connection","Where are the tests?","Show me the configuration files"];function Mv({sessionId:e,onOpenFile:t,className:s=""}){const[i,n]=d.useState(""),[o,a]=d.useState([]),[l,h]=d.useState(!1),[c,u]=d.useState(!1),[m,f]=d.useState(!1),_=d.useRef(null),p=d.useRef(null),g=d.useCallback(async w=>{if(!w.trim()||!e){a([]),f(!1);return}h(!0),f(!0);try{const{terms:R}=Rv(w),B=R.join(" "),G=(await W.searchFiles(e,B)).map(K=>({path:K.path,name:K.name,relevanceScore:Dv(K,R)}));G.sort((K,A)=>A.relevanceScore-K.relevanceScore),a(G.slice(0,15))}catch{a([])}finally{h(!1)}},[e]),v=w=>{n(w),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>g(w),400)},y=w=>{w.preventDefault(),p.current&&clearTimeout(p.current),g(i)},x=()=>{var w;n(""),a([]),f(!1),(w=_.current)==null||w.focus()},C=w=>{n(w),g(w)};d.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const j=w=>w.includes(".test.")||w.includes(".spec.")?"text-teal":w.endsWith(".css")||w.endsWith(".scss")?"text-pink":w.endsWith(".json")||w.endsWith(".yaml")?"text-warning":w.endsWith(".md")?"text-muted":"text-primary";return r.jsxs("div",{className:`card overflow-hidden ${s}`,children:[r.jsxs("div",{className:"px-4 pt-4 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(os,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Code Search"})]}),r.jsx("p",{className:"text-[11px] text-muted mb-3",children:'Search in natural language -- "Where is the login function?"'}),r.jsxs("form",{onSubmit:y,className:"relative",children:[r.jsx(os,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{ref:_,type:"text",value:i,onChange:w=>v(w.target.value),onFocus:()=>u(!0),onBlur:()=>setTimeout(()=>u(!1),200),placeholder:"Ask about your code...",className:`w-full pl-9 pr-8 py-2 text-sm bg-hover/50 border border-border rounded-card
251
251
  focus:border-primary focus:ring-1 focus:ring-primary/20 outline-none
252
252
  text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:x,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-ink transition-colors",children:r.jsx(_t,{size:14})})]})]}),!m&&c&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"text-[11px] text-muted mb-1.5",children:"Try searching for:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:Pv.map(w=>r.jsx("button",{onClick:()=>C(w),className:`text-[11px] text-primary bg-primary/5 hover:bg-primary/10
253
- px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:w},w))})]}),l&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(pi,{size:14,className:"animate-spin"}),"Searching..."]}),m&&!l&&r.jsx("div",{className:"border-t border-border",children:o.length===0?r.jsx("div",{className:"text-center py-6 text-xs text-muted",children:"No results found. Try a different query."}):r.jsxs("div",{className:"max-h-[320px] overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"text-[11px] text-muted px-4 py-1.5 bg-hover/30 border-b border-border",children:[o.length," result",o.length!==1?"s":""," found"]}),o.map((w,D)=>r.jsxs("button",{onClick:()=>t(w.path,w.lineNumber),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left
253
+ px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:w},w))})]}),l&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(pi,{size:14,className:"animate-spin"}),"Searching..."]}),m&&!l&&r.jsx("div",{className:"border-t border-border",children:o.length===0?r.jsx("div",{className:"text-center py-6 text-xs text-muted",children:"No results found. Try a different query."}):r.jsxs("div",{className:"max-h-[320px] overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"text-[11px] text-muted px-4 py-1.5 bg-hover/30 border-b border-border",children:[o.length," result",o.length!==1?"s":""," found"]}),o.map((w,R)=>r.jsxs("button",{onClick:()=>t(w.path,w.lineNumber),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left
254
254
  hover:bg-hover/50 transition-colors border-b border-border last:border-b-0
255
- group cursor-pointer`,children:[r.jsx(ee,{size:14,className:j(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(lu,{size:10}),w.lineNumber]}),r.jsx(eo,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${D}`))]})})]})}const hr={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},dr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Lv(e,t,s){const i=hr[t]||hr.claude,n=dr[e]||dr.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(p=>{const g=Math.round(h*p.pct),v=g*.4,y=g*.6,x=(v*i.input+y*i.output)/1e3;return{phase:p.phase,label:p.label,estimatedCost:x,estimatedTokens:g}}),u=c.reduce((p,g)=>p+g.estimatedCost,0),f=o*(e==="complex"?40:e==="simple"?15:25),_=f<60?`${f}s`:f<3600?`${Math.round(f/60)}min`:`${(f/3600).toFixed(1)}hr`;return{total:{low:u*.7,high:u*1.4},breakdown:c,totalTokens:h,estimatedTime:_}}function Il(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Bv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Lv(e,t,i),u=hr[t]||hr.claude,m=dr[e]||dr.standard,f=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ec,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(is,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Il(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(ct,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(is,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||m.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:u.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:m.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Fd,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(ur,{size:12}):r.jsx(fs,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(_=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:_.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[Il(_.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",_.estimatedCost.toFixed(2)]})]},_.phase))})]}),f&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ht,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(he,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(he,{variant:"primary",size:"sm",onClick:n,icon:is,children:"Start Build"})]})]})}function Tv({sessionId:e}){return r.jsx(Eh,{sessionId:e})}function Zn(e,t,s){var o;if(t==="directory")return s?r.jsx(an,{size:14}):r.jsx(oo,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(ee,{size:14,className:"text-yellow-600"}),ts:r.jsx(ee,{size:14,className:"text-blue-500"}),tsx:r.jsx(ee,{size:14,className:"text-blue-400"}),jsx:r.jsx(ee,{size:14,className:"text-yellow-500"}),py:r.jsx(ee,{size:14,className:"text-green-600"}),html:r.jsx(ac,{size:14,className:"text-orange-500"}),css:r.jsx(ro,{size:14,className:"text-purple-500"}),json:r.jsx(io,{size:14,className:"text-green-500"}),md:r.jsx(mi,{size:14,className:"text-muted"}),go:r.jsx(ee,{size:14,className:"text-cyan-600"}),rs:r.jsx(ee,{size:14,className:"text-orange-600"}),rb:r.jsx(ee,{size:14,className:"text-red-500"}),sh:r.jsx(ee,{size:14,className:"text-green-600"})}[i]||r.jsx(no,{size:14})}function zv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Rh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Rh(s.children,t);if(i!==void 0)return i}}}function Ph(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",u=a.has(h.path),m=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":m,...c?{"aria-expanded":u}:{},onContextMenu:f=>{f.preventDefault(),n==null||n(f,h.path,h.name,h.type)},onClick:()=>{c?l(f=>{const _=new Set(f);return _.has(h.path)?_.delete(h.path):_.add(h.path),_}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${m?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:u?r.jsx(fs,{size:14}):r.jsx(fr,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Zn(h.name,h.type,u)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Ph(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),i(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(_t,{size:12})})]}),c&&u&&h.children&&r.jsx(Mh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Lh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Lh(i.children,i.path+"/"));return s}function Av(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[u,m]=d.useState(new Set),f=d.useCallback(async()=>{try{const y=await W.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{f()},[f]);const _=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await W.setSecret(y,n),i(""),o(""),await f()}catch(x){c(x instanceof Error?x.message:"Failed to set secret")}}},p=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await W.deleteSecret(y),await f()}catch(x){c(x instanceof Error?x.message:"Failed to delete secret")}},g=y=>{m(x=>{const C=new Set(x);return C.has(y)?C.delete(y):C.add(y),C})},v=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ri,{variant:"text",width:"180px",height:"16px"}),r.jsx(ri,{variant:"block",width:"100%",height:"60px"}),r.jsx(ri,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ht,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),v.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:v.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:u.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>g(y),className:"text-muted hover:text-ink transition-colors",title:u.has(y)?"Hide value":"Show value",children:u.has(y)?r.jsx(Ad,{size:14}):r.jsx(ks,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>p(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(so,{size:14})})})]},y))})]})}),v.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("button",{onClick:_,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(pr,{size:14}),"Add"]})]})]})]})})}function Ov({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,u]=d.useState(!0),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useCallback(async()=>{try{const x=await W.getDocsStatus(e);if(s(x),x.has_docs){const C=await W.getDocFiles(e);n(C.files)}}catch{}u(!1)},[e]);d.useEffect(()=>{g()},[g]);const v=async()=>{f(!0),p(null);try{await W.generateDocs(e);const x=setInterval(async()=>{try{const C=await W.getDocsStatus(e);if(C.has_docs){s(C);const j=await W.getDocFiles(e);n(j.files),f(!1),clearInterval(x)}}catch{}},3e3);setTimeout(()=>{clearInterval(x),f(!1)},3e5)}catch(x){p(x instanceof Error?x.message:"Failed to start doc generation"),f(!1)}},y=async x=>{try{const C=await W.getDocFileContent(e,x);a(x),h(C)}catch(C){p(C instanceof Error?C.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ri,{variant:"text",width:"180px",height:"16px"}),r.jsx(ri,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Jl,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Documentation"}),_&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:_})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(he,{onClick:v,disabled:m,size:"sm",variant:"secondary",children:[r.jsx(bt,{size:14,className:m?"animate-spin":""}),m?"Updating...":"Update Docs"]}):r.jsx(he,{onClick:v,disabled:m,size:"sm",children:m?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(x=>r.jsxs("button",{onClick:()=>y(x.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(mi,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:x.name}),r.jsx("span",{className:"text-xs text-muted",children:x.size<1024?`${x.size} B`:`${(x.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},x.name))}):t!=null&&t.has_docs?null:r.jsx("p",{className:"text-sm text-muted",children:'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}),(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function $v({session:e,onClose:t}){var ta;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(!1),[f,_]=d.useState("code"),[p,g]=d.useState(!1),[v,y]=d.useState(!1),[x,C]=d.useState(e),j=d.useRef(null),[w,D]=d.useState([]),[B,U]=d.useState(!1),[G,K]=d.useState(""),A=d.useRef(null),R=d.useRef(null),[E,L]=d.useState(0),[S,N]=d.useState(null),[k,P]=d.useState(!0),[J,oe]=d.useState(!0),[V,Z]=d.useState(!1),[ie,ue]=d.useState("overview"),fe=57374,[de,_e]=d.useState(null),He=d.useCallback(()=>{Z(b=>{const I=!b;return P(!I),oe(!I),I})},[]),[z,xe]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${x.id}`)||"standard"),[T,Y]=d.useState(()=>sessionStorage.getItem(`pl_provider_${x.id}`)||"claude"),[q,Q]=d.useState(null),[le,ke]=d.useState(null),[Pe,Ze]=d.useState(!1),[We,ut]=d.useState(!1),[ae,yi]=d.useState({phase:"idle",iteration:0,maxIterations:10,cost:0,startTime:0}),[Sr,Yt]=d.useState(!1),[Qe,Ie]=d.useState(null),Ue=d.useRef(null),[ht,_s]=d.useState(!1),[Bh,Do]=d.useState([]),[Ro,As]=d.useState(null),[Th,wr]=d.useState(!1),[zh,Si]=d.useState(!1),[Ah,Os]=d.useState(!1),[wi,Po]=d.useState("files"),{history:Mo,recordTokens:Lo}=qx(),[Oh,$h]=d.useState(null),[Bo,Ih]=d.useState({line:1,column:1}),[Fh,To]=d.useState(0),{device:Hh,setDevice:Wh,frameClass:zo}=Jx(),[Cr,Uh]=d.useState(100),[Ao,Kh]=d.useState(!1),[Ci,kr]=d.useState(!1),[Oo,Fv]=d.useState([]),xs=d.useRef(null),[qh,$o]=d.useState(0),{subscribe:Io}=kd(),et=d.useCallback(async()=>{try{const b=await W.getSessionDetail(x.id);C(b)}catch{}},[x.id]),Fo=d.useCallback(async()=>{try{await W.stopSession(),Ze(!1),ut(!1)}catch{}},[]),Vh=d.useCallback(async()=>{try{await W.pauseSession(),ut(!0)}catch{}},[]),Gh=d.useCallback(async()=>{try{await W.resumeSession(),ut(!1)}catch{}},[]),Ho=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await W.getStatus();Ze(F.running),ut(F.paused),F.provider&&Y(F.provider);const te=F.phase||"idle";if(te!==Ho.current&&te!=="idle"){const tt=new Date().toISOString(),Bt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},kt={starting:"Setting up the build environment and checking prerequisites...",planning:"Analyzing requirements and designing the architecture...",building:"Writing code and creating project files...",testing:"Running test suite to verify everything works...",reviewing:"Checking code quality and best practices...",complete:"All done. Your project is ready."},Fs=[{id:`phase-${Date.now()}`,type:"phase_change",message:Bt[te]||`Phase: ${te}`,timestamp:tt}];kt[te]&&Fs.push({id:`narration-${Date.now()}`,type:"narration",message:kt[te],timestamp:tt}),Do(Mi=>[...Mi,...Fs]),Ho.current=te}yi({phase:te,iteration:F.iteration||0,maxIterations:F.max_iterations||10,cost:F.cost||0,startTime:F.start_time?F.start_time*1e3:0});const Ye=F.tokens_used;Ye!=null&&Lo(Ye)}catch{}};b();const I=setInterval(b,Pe?3e3:1e4);return()=>clearInterval(I)},[Pe,Lo]),d.useEffect(()=>{if(!(le!=null&&le.loading))return;const b=setInterval(()=>{ke(I=>I?{...I,elapsed:Math.floor((Date.now()-I.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[le==null?void 0:le.loading]);const[se,Yh]=d.useState(null);d.useEffect(()=>{W.getPreviewInfo(x.id).then(Yh).catch(()=>{})},[x.id]);const[$,ki]=d.useState(null),[$s,Wo]=d.useState(!1),[Uo,Ko]=d.useState(!1),[qo,ji]=d.useState(null),[Xt,Xh]=d.useState("");d.useEffect(()=>{const b=Io("file_changed",I=>{const F=I;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ye=F.paths.map((tt,Bt)=>{var Mi;const kt=(Mi=F.event_types)==null?void 0:Mi[Bt],Fs=kt==="created"||kt==="IN_CREATE";return{id:`file-${Date.now()}-${Bt}`,type:Fs?"file_created":"file_modified",message:Fs?`Created ${tt.split("/").pop()}`:`Modified ${tt.split("/").pop()}`,timestamp:te,filePath:tt}});if(Do(tt=>[...tt,...Ye]),Yt(!0),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>Yt(!1),2e3),et(),s&&F.paths.some(Bt=>Bt===s||s.endsWith(Bt))&&Ie(s),f==="preview"){const tt=["react","vite","next","nuxt","svelte","remix"];($==null?void 0:$.running)&&($==null?void 0:$.framework)&&tt.some(kt=>$.framework.toLowerCase().includes(kt))||L(kt=>kt+1)}});return()=>{b(),Ue.current&&clearTimeout(Ue.current)}},[Io,s,f,$==null?void 0:$.running,et]);const Jh=d.useCallback(async()=>{if(!(!Qe||!x.id)){try{const b=await W.getSessionFileContent(x.id,Qe);l(b.content),c(b.content),g(!1),D(I=>I.map(F=>F.path===Qe?{...F,content:b.content,modified:!1}:F))}catch{}Ie(null)}},[Qe,x.id]);d.useEffect(()=>{if(f!=="preview")return;let b=!1;const I=async()=>{try{const te=await W.devserver.status(x.id);b||ki(te)}catch{}};I();const F=setInterval(I,3e3);return()=>{b=!0,clearInterval(F)}},[f,x.id]),d.useEffect(()=>{f==="dashboard"&&fetch(`http://127.0.0.1:${fe}/health`).then(b=>_e(b.ok)).catch(()=>_e(!1))},[f]);const vs=d.useCallback(async b=>{Wo(!0),ji(null);try{const I=await W.devserver.start(x.id,b);if(I.status==="error")ji(I.message||"Failed to start dev server");else{const F=await W.devserver.status(x.id);ki(F)}}catch(I){ji(I instanceof Error?I.message:"Failed to start dev server")}Wo(!1)},[x.id]),Vo=d.useRef(!1);d.useEffect(()=>{Vo.current||se!=null&&se.dev_command&&($!=null&&$.running||($==null?void 0:$.status)==="starting"||$s||(Vo.current=!0,vs(se.dev_command)))},[se==null?void 0:se.dev_command,$==null?void 0:$.running,$==null?void 0:$.status,$s,vs]);const Zh=d.useCallback(async()=>{try{await W.devserver.stop(x.id);const b=await W.devserver.status(x.id);ki(b)}catch{}},[x.id]),Qh=d.useCallback(async()=>{Ko(!0);try{const b=await W.fixProject(x.id);if(b.task_id){let F=0,te;do await new Promise(tt=>setTimeout(tt,2e3)),te=await W.chatPoll(x.id,b.task_id),F++;while(!te.complete&&F<150);const Ye=await W.devserver.status(x.id);ki(Ye)}}catch(b){ji(b instanceof Error?b.message:"Fix failed")}Ko(!1)},[x.id]),bs=$!=null&&$.running&&($!=null&&$.port)?$.framework==="expo"?`${en}/api/sessions/${encodeURIComponent(x.id)}/expo-qr`:$.portless_url||`http://localhost:${$.port}/`:null,ed=(se==null?void 0:se.preview_url)||`${en}/api/sessions/${encodeURIComponent(x.id)}/preview/index.html`,td=bs||ed,[Ni,Go]=d.useState([]),[wt,Ei]=d.useState(0);d.useEffect(()=>{const b=bs||(se==null?void 0:se.preview_url);b&&(Go([b]),Ei(0))},[bs,se==null?void 0:se.preview_url]);const Ct=Ni[wt]||td,[Yo,jr]=d.useState(Ct),sd=d.useCallback((b,I,F,te)=>{b.preventDefault(),N({x:b.clientX,y:b.clientY,path:I,name:F,type:te})},[]),id=d.useCallback(()=>{wt>0&&(Ei(b=>b-1),L(b=>b+1))},[wt]),rd=d.useCallback(()=>{wt<Ni.length-1&&(Ei(b=>b+1),L(b=>b+1))},[wt,Ni.length]),nd=d.useCallback(b=>{let I=b;if(b.startsWith("/")&&bs)try{I=`${new URL(bs).origin}${b}`}catch{const F=$==null?void 0:$.port;F&&(I=`http://localhost:${F}${b}`)}Go(F=>[...F.slice(0,wt+1),I]),Ei(F=>F+1),L(F=>F+1)},[wt,bs,$==null?void 0:$.port]);d.useEffect(()=>{try{const b=new URL(Ct,window.location.origin);jr(b.pathname+b.search+b.hash||"/")}catch{jr(Ct)}},[Ct]);const Di=d.useCallback(async()=>{ke({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),Q(null);try{const b=await W.reviewProject(x.id);Q(b.output)}catch(b){Q(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{ke(null)}},[x.id]),Ri=d.useCallback(async()=>{ke({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),Q(null);try{const b=await W.testProject(x.id);Q(b.output)}catch(b){Q(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{ke(null)}},[x.id]),Nr=d.useCallback(async()=>{ke({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),Q(null);try{const b=await W.explainProject(x.id);Q(b.output)}catch(b){Q(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{ke(null)}},[x.id]),Er=d.useCallback(async(b,I)=>{if(window.confirm(`Delete "${I}"?`))try{await W.deleteSessionFile(x.id,b),s===b&&(i(null),o(""),l(null),c(null),g(!1)),await et()}catch(te){const Ye=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ye}`)}},[x.id,s,et]),od=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:ks,onClick:()=>{Di()}},{label:"Generate Tests",icon:ni,onClick:()=>{Ri()}},{label:"Explain",icon:Ys,onClick:()=>{Nr()}},{label:"Delete",icon:so,onClick:()=>{Er(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:ks,onClick:()=>{Di()}},{label:"Run Tests",icon:ni,onClick:()=>{Ri()}}],[Di,Ri,Nr,Er]),Lt=d.useCallback(async(b,I)=>{Ie(null),p&&s&&h!==null&&D(te=>te.map(Ye=>Ye.path===s?{...Ye,content:h,modified:!0}:Ye));const F=w.find(te=>te.path===b);if(F){i(b),o(I),l(F.content),c(F.content),g(F.modified);return}i(b),o(I),m(!0),g(!1);try{const te=x.id?await W.getSessionFileContent(x.id,b):await W.getFileContent(b);l(te.content),c(te.content),D(Ye=>[...Ye,{path:b,name:I,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{m(!1)}},[x.id,p,s,h,w]),Dr=d.useCallback(async()=>{var b;if(!(!s||h===null||!x.id)){y(!0);try{await W.saveSessionFile(x.id,s,h),l(h),g(!1),$h(Date.now()),D(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const I=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(I)&&L(F=>F+1)}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,x.id]),Xo=d.useCallback(b=>{const I=w.find(F=>F.path===b);if(!(I!=null&&I.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(D(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),g(te.modified)}else i(null),o(""),l(null),c(null),g(!1)}},[w,s]);d.useEffect(()=>{const b=I=>{(I.metaKey||I.ctrlKey)&&I.key==="s"&&(I.preventDefault(),p&&s&&Dr()),(I.metaKey||I.ctrlKey)&&I.key==="p"&&(I.preventDefault(),U(F=>!F),K("")),(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),_s(F=>!F)),I.key==="Escape"&&B&&U(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[p,s,Dr,B]),d.useEffect(()=>{B&&A.current&&A.current.focus()},[B]);const Jo=Lh(x.files),Is=G?Jo.filter(b=>b.path.toLowerCase().includes(G.toLowerCase())):Jo;d.useEffect(()=>{const b=x.files.find(I=>I.name==="index.html"&&I.type==="file");b&&Lt(b.path,b.name)},[]);const ad=d.useCallback(b=>{b!==void 0&&(c(b),g(b!==a),To(b.split(`
256
- `).length))},[a]),ld=d.useCallback(b=>{j.current=b;const I=b;if(I!=null&&I.onDidChangeCursorPosition&&I.onDidChangeCursorPosition(F=>{Ih({line:F.position.lineNumber,column:F.position.column})}),I!=null&&I.getModel){const F=I.getModel();F!=null&&F.getLineCount&&To(F.getLineCount())}},[]),cd=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await W.createSessionFile(x.id,b.trim()),await et()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[x.id,et]),hd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await W.createSessionDirectory(x.id,b.trim()),await et()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[x.id,et]),Zo=d.useCallback(async()=>{try{const b=await W.previewChanges(x.id,"preview current changes");As(b)}catch{}},[x.id]),dd=d.useCallback(()=>{As(null),et()},[et]),ud=d.useCallback(b=>{As(null),et()},[et]),fd=d.useCallback(()=>{As(null)},[]),Qo=s?Rh(x.files,s):void 0,md=((ta=n.split(".").pop())==null?void 0:ta.toUpperCase())||"",{showHelp:pd,setShowHelp:ea}=gx({onToggleBuild:()=>{Pe&&Fo()}}),gd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:ks,action:()=>_("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:on,action:()=>_("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:ns,action:()=>oe(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Rr,action:()=>_("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:Wt,action:()=>_("deploy")},{id:"git",label:"Git Status",category:"command",icon:ze,action:()=>_("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:oa,action:()=>_("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:ee,action:()=>{U(!0),K("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:ln,action:()=>He()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:aa,action:()=>P(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:ze,action:()=>Zo()},{id:"insights",label:"Build Insights",category:"command",icon:tn,action:()=>_("insights")},{id:"docs",label:"Documentation",category:"command",icon:Ys,action:()=>_("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:os,action:()=>Os(!0)}],[_,He,Zo]),Pi=d.useMemo(()=>{if(!Pe)return"idle";const b=(ae.phase||x.status||"").toLowerCase();return b.includes("starting")||b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[Pe,ae.phase,x.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.jsx("button",{onClick:()=>{p&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:x.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:x.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${x.status==="completed"||x.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:x.status}),Mo.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Kx,{tokenHistory:Mo})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>P(b=>!b),title:k?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:k?r.jsx(aa,{size:16}):r.jsx(Su,{size:16})}),r.jsx("button",{onClick:()=>oe(b=>!b),title:J?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:J?r.jsx(xu,{size:16}):r.jsx(bu,{size:16})}),r.jsx("button",{onClick:He,title:V?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${V?"text-primary":"text-muted hover:text-ink"}`,children:V?r.jsx(cc,{size:16}):r.jsx(ln,{size:16})})]}),!Pe&&r.jsx(he,{variant:"primary",size:"sm",icon:Ut,onClick:()=>{if(!(x.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}Si(!0)},title:"Start build for this project",children:"Build"}),!Pe&&Pi==="complete"&&r.jsx(he,{variant:"ghost",size:"sm",icon:nn,onClick:()=>wr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Tt,{icon:os,label:"Natural language search",size:"sm",onClick:()=>Os(!0)}),Pe&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[We?r.jsx(he,{variant:"ghost",size:"sm",icon:Ut,onClick:Gh,title:"Resume build",children:"Resume"}):r.jsx(he,{variant:"ghost",size:"sm",icon:Zl,onClick:Vh,title:"Pause build",children:"Pause"}),r.jsx(he,{variant:"danger",size:"sm",icon:sr,onClick:Fo,title:"Stop build",children:"Stop"})]}),r.jsx(Tt,{icon:ks,label:"Review project",size:"sm",onClick:Di,disabled:!!(le!=null&&le.loading)}),r.jsx(Tt,{icon:ni,label:"Run tests",size:"sm",onClick:Ri,disabled:!!(le!=null&&le.loading)}),r.jsx(Tt,{icon:Ys,label:"Explain project",size:"sm",onClick:Nr,disabled:!!(le!=null&&le.loading)}),r.jsx(he,{variant:"secondary",size:"sm",icon:Wt,onClick:()=>_("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(xx,{onClick:()=>ea(!0)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex-1",children:r.jsx(nx,{phase:Pi,iteration:ae.iteration,maxIterations:ae.maxIterations,cost:ae.cost,startTime:ae.startTime,isRunning:Pe})}),Pe&&r.jsx("div",{className:"flex-shrink-0 pr-2",children:r.jsx(yv,{gatePassRate:.8,testCoverage:ae.iteration>2?60:20,iteration:ae.iteration,maxIterations:ae.maxIterations,phase:Pi,compact:!0})})]}),r.jsx(Mx,{sessionId:x.id,onRestore:et}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(dn,{orientation:"vertical",children:[r.jsx(Zs,{defaultSize:70,minSize:40,children:r.jsxs(dn,{orientation:"horizontal",className:"h-full",children:[k&&r.jsx(Zs,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Po("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${wi==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(oo,{size:14}),"Files",Sr&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Po("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${wi==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Vl,{size:14}),"Chat"]}),wi==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:cd,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(mr,{size:12})," New"]}),r.jsxs("button",{onClick:hd,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(Pd,{size:12})," New"]})]})]}),wi==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:x.files.length>0?r.jsx(Mh,{nodes:x.files,selectedPath:s,onSelect:Lt,onDelete:Er,onContextMenu:sd}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(an,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(vv,{sessionId:x.id,defaultMode:z})})})]})}),k&&r.jsx(un,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(Zs,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:on},{id:"preview",label:"Preview",icon:ks},{id:"deploy",label:"Deploy",icon:Wt},{id:"config",label:"Config",icon:oa},{id:"secrets",label:"Secrets",icon:du},{id:"prd",label:"Spec",icon:mi},{id:"dashboard",label:"Dashboard",icon:Rr},{id:"git",label:"Git",icon:ze},{id:"cicd",label:"CI/CD",icon:ze},{id:"insights",label:"Insights",icon:tn},{id:"docs",label:"Docs",icon:Ys}].map(b=>r.jsxs("button",{role:"tab","aria-selected":f===b.id,onClick:()=>_(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Lt(b.path,b.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Zn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:I=>{I.stopPropagation(),Xo(b.path)},onKeyDown:I=>{I.key==="Enter"&&(I.stopPropagation(),Xo(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(_t,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),v&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Qo!=null?Ph(Qo):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:md}),p&&r.jsx("button",{onClick:Dr,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),Qe===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(bt,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Jh,className:"text-xs font-medium px-2 py-0.5 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors",children:"Reload"}),r.jsx("button",{onClick:()=>Ie(null),className:"text-xs font-medium px-2 py-0.5 rounded border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Dismiss"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:u?r.jsx(jd,{}):r.jsx(Wi,{name:"Editor",children:r.jsx(Vf,{value:h??"",language:zv(n),theme:"vs",onChange:ad,onMount:ld,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})}),r.jsx(Yx,{selectedFile:s,fileName:n,isModified:p,isSaving:v,lastSavedAt:Oh,lineCount:Fh,cursorLine:Bo.line,cursorColumn:Bo.column,buildTime:ae.phase==="complete"&&ae.startTime?Math.floor((Date.now()-ae.startTime)/1e3):void 0,sessionId:x.id,prd:x.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(ee,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Cmd+P"})," to quick open"]})]})]}),f==="preview"&&r.jsx(Wi,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${Ao?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:$!=null&&$.running||se!=null&&se.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Tt,{icon:Jl,label:"Back",size:"sm",onClick:id,disabled:wt<=0}),r.jsx(Tt,{icon:eo,label:"Forward",size:"sm",onClick:rd,disabled:wt>=Ni.length-1}),r.jsx(rv,{onClick:()=>{kr(!0),L(b=>b+1)}}),r.jsx("input",{value:Yo,onChange:b=>jr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&nd(Yo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(Xx,{selectedDevice:Hh,onDeviceChange:Wh,containerWidth:qh}),r.jsx(Qx,{zoom:Cr,onZoomChange:Uh}),r.jsx(sv,{url:Ct}),r.jsx(tv,{}),r.jsx(nv,{url:Ct}),r.jsx(Tt,{icon:as,label:"Open in new tab",size:"sm",onClick:()=>window.open(Ct,"_blank")}),r.jsx(iv,{isFullscreen:Ao,onToggle:()=>Kh(b=>!b)}),($==null?void 0:$.running)&&r.jsxs("button",{onClick:Zh,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded border border-danger/40 bg-danger/10 text-danger hover:bg-danger/20 transition-colors",children:[r.jsx(sr,{size:12}),"Stop"]})]}):se?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:se.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),$&&$.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${$.running?"bg-green-50 border-green-200 text-green-700":$.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":$.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${$.running?"bg-green-500":$.status==="starting"?"bg-yellow-500 animate-pulse":$.status==="error"?"bg-red-500":"bg-gray-400"}`}),$.running&&$.portless_url&&r.jsxs("span",{children:["Running at ",$.portless_url]}),$.running&&$.port&&!$.portless_url&&r.jsxs("span",{children:["Running on port ",$.port]}),$.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),$.status==="error"&&!$.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),$.status==="error"&&$.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",$.auto_fix_status]}),$.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:$.command})]}),$!=null&&$.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[Ci&&r.jsx(zl,{}),r.jsx("div",{ref:xs,className:`flex-1 bg-white overflow-auto flex justify-center ${Ci?"hidden":""}`,children:r.jsx("div",{className:`${zo} h-full preview-zoom-${Cr}`,children:r.jsx("iframe",{ref:R,src:Ct,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{kr(!1),xs.current&&$o(xs.current.clientWidth)}},E)})}),r.jsx(Tl,{messages:Oo})]}):se!=null&&se.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[Ci&&r.jsx(zl,{}),r.jsx("div",{ref:xs,className:`flex-1 bg-white overflow-auto flex justify-center ${Ci?"hidden":""}`,children:r.jsx("div",{className:`${zo} h-full preview-zoom-${Cr}`,children:r.jsx("iframe",{ref:R,src:Ct,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{kr(!1),xs.current&&$o(xs.current.clientWidth)}},E)})}),r.jsx(Tl,{messages:Oo})]}):se?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:se.type==="api"||se.type==="python-api"?r.jsx(Hd,{size:28,className:"text-primary"}):se.type==="library"?r.jsx(Ql,{size:28,className:"text-primary"}):se.type==="go-app"||se.type==="rust-app"?r.jsx(ns,{size:28,className:"text-primary"}):r.jsx(an,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:se.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:se.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[se.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:se.dev_command}),r.jsxs("button",{onClick:()=>vs(se.dev_command||void 0),disabled:$s,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary/90 transition-colors disabled:opacity-50",children:[r.jsx(Ut,{size:12}),$s?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:se.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:se.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Xt,onChange:b=>Xh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Xt.trim()&&vs(Xt.trim())},placeholder:"e.g. npm run dev",className:"flex-1 px-3 py-1.5 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx("button",{onClick:()=>Xt.trim()&&vs(Xt.trim()),disabled:$s||!Xt.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-btn border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:"Run"})]})]})]}),qo&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:qo})]}),($==null?void 0:$.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:Qh,disabled:Uo,className:"text-xs px-2 py-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:Uo?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>vs(se.dev_command||Xt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),$.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",$.auto_fix_status]}),$.auto_fix_attempts!==void 0&&$.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",$.auto_fix_attempts,"/3"]})]}),$.output.length>0&&r.jsx("pre",{className:"text-[11px] font-mono text-danger/70 bg-danger/5 p-2 rounded max-h-32 overflow-y-auto whitespace-pre-wrap",children:$.output.slice(-10).join(`
257
- `)})]}),se.port&&!($!=null&&$.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",se.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:T})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{onClick:()=>{Y(b),sessionStorage.setItem(`pl_provider_${x.id}`,b),W.setProvider(b).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${T===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{xe(b),sessionStorage.setItem(`pl_buildmode_${x.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${z===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:x.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:x.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),f==="secrets"&&r.jsx(Av,{}),f==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),x.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:x.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),f==="deploy"&&r.jsx(fx,{sessionId:x.id}),f==="dashboard"&&(de===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Rr,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.jsx("p",{className:"text-sm text-muted max-w-md",children:"The Loki Dashboard provides task boards, RARV timeline, quality gates, and cost tracking. Start it to see project analytics."}),r.jsx("button",{onClick:async()=>{_e(null);try{const b=await fetch(`http://127.0.0.1:${fe}/health`);_e(b.ok)}catch{_e(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[[{id:"overview",label:"Overview"},{id:"tasks",label:"Tasks"},{id:"timeline",label:"RARV Timeline"},{id:"quality",label:"Quality"},{id:"cost",label:"Cost"}].map(b=>r.jsx("button",{onClick:()=>ue(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ie===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${fe}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(as,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${fe}/#${ie}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),f==="git"&&r.jsx(Px,{sessionId:x.id}),f==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Tv,{sessionId:e.id})}),f==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Ov,{sessionId:x.id})}),f==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kv,{filesCreated:x.files.filter(b=>b.type==="file").length,filesModified:0,linesGenerated:0,testsGenerated:0,testPassRate:0,totalTokens:0,phaseBreakdown:[],totalTimeSecs:ae.startTime?Math.floor((Date.now()-ae.startTime)/1e3):0,qualityScore:0,totalCost:ae.cost,iterations:ae.iteration,provider:T})})]})]})})]})}),J&&r.jsx(un,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),J&&r.jsx(Zs,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Wi,{name:"ActivityPanel",children:r.jsx(ix,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:x.status==="running"||x.status==="in_progress",buildMode:z,buildEvents:Bh,onFileClick:b=>Lt(b,b.split("/").pop()||b)})})})]})}),(le==null?void 0:le.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[le.type==="review"?"Reviewing project":le.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[le.elapsed,"s"]})]})}),q&&r.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(Tt,{icon:_t,label:"Close",size:"sm",onClick:()=>Q(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:q})]}),S&&r.jsx(Rm,{x:S.x,y:S.y,items:od(S),onClose:()=>N(null)}),B&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>U(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:A,type:"text",value:G,onChange:b=>K(b.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:b=>{b.key==="Enter"&&Is.length>0&&(Lt(Is[0].path,Is[0].name),U(!1)),b.key==="Escape"&&U(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Is.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Lt(b.path,b.name),U(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Zn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),Is.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(_x,{open:pd,onClose:()=>ea(!1)}),r.jsx(Sx,{isOpen:ht,onClose:()=>_s(!1),commands:gd,sessionId:x.id,onFileSelect:Lt}),Ro&&r.jsx(Tx,{data:Ro,onAcceptAll:dd,onAcceptSelected:ud,onReject:fd,onClose:()=>As(null)}),r.jsx(Ux,{phase:Pi,buildTime:ae.startTime?Math.floor((Date.now()-ae.startTime)/1e3):void 0}),Th&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>wr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>wr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(_t,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(Ev,{sessionId:x.id,files:x.files.map(b=>({path:b.path,type:b.type})),phases:["planning","building","testing","reviewing","complete"],checkpoints:[],qualityGates:[],totalIterations:ae.iteration||ae.maxIterations})})]})}),Ah&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>Os(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>Os(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(_t,{size:16})})]}),r.jsx(Mv,{sessionId:x.id,onOpenFile:(b,I)=>{Lt(b,b.split("/").pop()||b),Os(!1)},className:"p-4"})]})}),zh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>Si(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Bv,{complexity:z==="quick"?"simple":z==="max"?"complex":"standard",provider:T,estimatedIterations:ae.maxIterations,onConfirm:async()=>{Si(!1);try{const b=x.prd||"";await W.startSession({prd:b,provider:T,projectDir:x.path}),Ze(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>Si(!1)})})})]})}function Iv(){const{sessionId:e}=Nd(),t=Ed(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),W.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Wi,{name:"ProjectWorkspace",children:r.jsx($v,{session:s,onClose:()=>t("/")})})})})}const kb=Object.freeze(Object.defineProperty({__proto__:null,default:Iv},Symbol.toStringTag,{value:"Module"}));export{gr as L,kb as P,ju as S};
255
+ group cursor-pointer`,children:[r.jsx(ee,{size:14,className:j(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(lu,{size:10}),w.lineNumber]}),r.jsx(eo,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${R}`))]})})]})}const hr={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},dr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Lv(e,t,s){const i=hr[t]||hr.claude,n=dr[e]||dr.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(p=>{const g=Math.round(h*p.pct),v=g*.4,y=g*.6,x=(v*i.input+y*i.output)/1e3;return{phase:p.phase,label:p.label,estimatedCost:x,estimatedTokens:g}}),u=c.reduce((p,g)=>p+g.estimatedCost,0),f=o*(e==="complex"?40:e==="simple"?15:25),_=f<60?`${f}s`:f<3600?`${Math.round(f/60)}min`:`${(f/3600).toFixed(1)}hr`;return{total:{low:u*.7,high:u*1.4},breakdown:c,totalTokens:h,estimatedTime:_}}function Il(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Bv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Lv(e,t,i),u=hr[t]||hr.claude,m=dr[e]||dr.standard,f=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ec,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(is,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Il(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(ct,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(is,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||m.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:u.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:m.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Fd,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(ur,{size:12}):r.jsx(fs,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(_=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:_.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[Il(_.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",_.estimatedCost.toFixed(2)]})]},_.phase))})]}),f&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ht,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(he,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(he,{variant:"primary",size:"sm",onClick:n,icon:is,children:"Start Build"})]})]})}function Tv({sessionId:e}){return r.jsx(Eh,{sessionId:e})}function Zn(e,t,s){var o;if(t==="directory")return s?r.jsx(rn,{size:14}):r.jsx(oo,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(ee,{size:14,className:"text-yellow-600"}),ts:r.jsx(ee,{size:14,className:"text-blue-500"}),tsx:r.jsx(ee,{size:14,className:"text-blue-400"}),jsx:r.jsx(ee,{size:14,className:"text-yellow-500"}),py:r.jsx(ee,{size:14,className:"text-green-600"}),html:r.jsx(ac,{size:14,className:"text-orange-500"}),css:r.jsx(ro,{size:14,className:"text-purple-500"}),json:r.jsx(io,{size:14,className:"text-green-500"}),md:r.jsx(mi,{size:14,className:"text-muted"}),go:r.jsx(ee,{size:14,className:"text-cyan-600"}),rs:r.jsx(ee,{size:14,className:"text-orange-600"}),rb:r.jsx(ee,{size:14,className:"text-red-500"}),sh:r.jsx(ee,{size:14,className:"text-green-600"})}[i]||r.jsx(no,{size:14})}function zv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Dh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Dh(s.children,t);if(i!==void 0)return i}}}function Ph(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",u=a.has(h.path),m=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":m,...c?{"aria-expanded":u}:{},onContextMenu:f=>{f.preventDefault(),n==null||n(f,h.path,h.name,h.type)},onClick:()=>{c?l(f=>{const _=new Set(f);return _.has(h.path)?_.delete(h.path):_.add(h.path),_}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${m?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:u?r.jsx(fs,{size:14}):r.jsx(fr,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Zn(h.name,h.type,u)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Ph(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),i(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(_t,{size:12})})]}),c&&u&&h.children&&r.jsx(Mh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Lh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Lh(i.children,i.path+"/"));return s}function Av(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[u,m]=d.useState(new Set),f=d.useCallback(async()=>{try{const y=await W.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{f()},[f]);const _=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await W.setSecret(y,n),i(""),o(""),await f()}catch(x){c(x instanceof Error?x.message:"Failed to set secret")}}},p=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await W.deleteSecret(y),await f()}catch(x){c(x instanceof Error?x.message:"Failed to delete secret")}},g=y=>{m(x=>{const C=new Set(x);return C.has(y)?C.delete(y):C.add(y),C})},v=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ri,{variant:"text",width:"180px",height:"16px"}),r.jsx(ri,{variant:"block",width:"100%",height:"60px"}),r.jsx(ri,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ht,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),v.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:v.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:u.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>g(y),className:"text-muted hover:text-ink transition-colors",title:u.has(y)?"Hide value":"Show value",children:u.has(y)?r.jsx(Ad,{size:14}):r.jsx(js,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>p(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(so,{size:14})})})]},y))})]})}),v.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("button",{onClick:_,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(pr,{size:14}),"Add"]})]})]})]})})}function Ov({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,u]=d.useState(!0),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useCallback(async()=>{try{const x=await W.getDocsStatus(e);if(s(x),x.has_docs){const C=await W.getDocFiles(e);n(C.files)}}catch{}u(!1)},[e]);d.useEffect(()=>{g()},[g]);const v=async()=>{f(!0),p(null);try{await W.generateDocs(e);const x=setInterval(async()=>{try{const C=await W.getDocsStatus(e);if(C.has_docs){s(C);const j=await W.getDocFiles(e);n(j.files),f(!1),clearInterval(x)}}catch{}},3e3);setTimeout(()=>{clearInterval(x),f(!1)},3e5)}catch(x){p(x instanceof Error?x.message:"Failed to start doc generation"),f(!1)}},y=async x=>{try{const C=await W.getDocFileContent(e,x);a(x),h(C)}catch(C){p(C instanceof Error?C.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ri,{variant:"text",width:"180px",height:"16px"}),r.jsx(ri,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Jl,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Documentation"}),_&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:_})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(he,{onClick:v,disabled:m,size:"sm",variant:"secondary",children:[r.jsx(bt,{size:14,className:m?"animate-spin":""}),m?"Updating...":"Update Docs"]}):r.jsx(he,{onClick:v,disabled:m,size:"sm",children:m?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(x=>r.jsxs("button",{onClick:()=>y(x.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(mi,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:x.name}),r.jsx("span",{className:"text-xs text-muted",children:x.size<1024?`${x.size} B`:`${(x.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},x.name))}):t!=null&&t.has_docs?null:r.jsx("p",{className:"text-sm text-muted",children:'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}),(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function $v({session:e,onClose:t}){var ta;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(!1),[f,_]=d.useState("code"),[p,g]=d.useState(!1),[v,y]=d.useState(!1),[x,C]=d.useState(e),j=d.useRef(null),[w,R]=d.useState([]),[B,U]=d.useState(!1),[G,K]=d.useState(""),A=d.useRef(null),D=d.useRef(null),[E,L]=d.useState(0),[S,N]=d.useState(null),[k,P]=d.useState(!0),[J,oe]=d.useState(!0),[V,Z]=d.useState(!1),[ie,ue]=d.useState("overview"),fe=57374,[de,_e]=d.useState(null),He=d.useCallback(()=>{Z(b=>{const I=!b;return P(!I),oe(!I),I})},[]),[z,xe]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${x.id}`)||"standard"),[T,Y]=d.useState(()=>sessionStorage.getItem(`pl_provider_${x.id}`)||"claude"),[q,Q]=d.useState(null),[le,ke]=d.useState(null),[Pe,Ze]=d.useState(!1),[We,ut]=d.useState(!1),[ae,yi]=d.useState({phase:"idle",iteration:0,maxIterations:10,cost:0,startTime:0}),[Sr,Yt]=d.useState(!1),[Qe,Ie]=d.useState(null),Ue=d.useRef(null),[ht,xs]=d.useState(!1),[Bh,Ro]=d.useState([]),[Do,As]=d.useState(null),[Th,wr]=d.useState(!1),[zh,Si]=d.useState(!1),[Ah,Os]=d.useState(!1),[wi,Po]=d.useState("files"),{history:Mo,recordTokens:Lo}=qx(),[Oh,$h]=d.useState(null),[Bo,Ih]=d.useState({line:1,column:1}),[Fh,To]=d.useState(0),{device:Hh,setDevice:Wh,frameClass:zo}=Jx(),[Cr,Uh]=d.useState(100),[Ao,Kh]=d.useState(!1),[Ci,kr]=d.useState(!1),[Oo,Fv]=d.useState([]),vs=d.useRef(null),[qh,$o]=d.useState(0),{subscribe:Io}=kd(),et=d.useCallback(async()=>{try{const b=await W.getSessionDetail(x.id);C(b)}catch{}},[x.id]),Fo=d.useCallback(async()=>{try{await W.stopSession(),Ze(!1),ut(!1)}catch{}},[]),Vh=d.useCallback(async()=>{try{await W.pauseSession(),ut(!0)}catch{}},[]),Gh=d.useCallback(async()=>{try{await W.resumeSession(),ut(!1)}catch{}},[]),Ho=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await W.getStatus();Ze(F.running),ut(F.paused),F.provider&&Y(F.provider);const te=F.phase||"idle";if(te!==Ho.current&&te!=="idle"){const tt=new Date().toISOString(),Bt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},kt={starting:"Setting up the build environment and checking prerequisites...",planning:"Analyzing requirements and designing the architecture...",building:"Writing code and creating project files...",testing:"Running test suite to verify everything works...",reviewing:"Checking code quality and best practices...",complete:"All done. Your project is ready."},Fs=[{id:`phase-${Date.now()}`,type:"phase_change",message:Bt[te]||`Phase: ${te}`,timestamp:tt}];kt[te]&&Fs.push({id:`narration-${Date.now()}`,type:"narration",message:kt[te],timestamp:tt}),Ro(Mi=>[...Mi,...Fs]),Ho.current=te}yi({phase:te,iteration:F.iteration||0,maxIterations:F.max_iterations||10,cost:F.cost||0,startTime:F.start_time?F.start_time*1e3:0});const Ye=F.tokens_used;Ye!=null&&Lo(Ye)}catch{}};b();const I=setInterval(b,Pe?3e3:1e4);return()=>clearInterval(I)},[Pe,Lo]),d.useEffect(()=>{if(!(le!=null&&le.loading))return;const b=setInterval(()=>{ke(I=>I?{...I,elapsed:Math.floor((Date.now()-I.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[le==null?void 0:le.loading]);const[se,Yh]=d.useState(null);d.useEffect(()=>{W.getPreviewInfo(x.id).then(Yh).catch(()=>{})},[x.id]);const[$,ki]=d.useState(null),[$s,Wo]=d.useState(!1),[Uo,Ko]=d.useState(!1),[qo,ji]=d.useState(null),[Xt,Xh]=d.useState("");d.useEffect(()=>{const b=Io("file_changed",I=>{const F=I;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ye=F.paths.map((tt,Bt)=>{var Mi;const kt=(Mi=F.event_types)==null?void 0:Mi[Bt],Fs=kt==="created"||kt==="IN_CREATE";return{id:`file-${Date.now()}-${Bt}`,type:Fs?"file_created":"file_modified",message:Fs?`Created ${tt.split("/").pop()}`:`Modified ${tt.split("/").pop()}`,timestamp:te,filePath:tt}});if(Ro(tt=>[...tt,...Ye]),Yt(!0),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>Yt(!1),2e3),et(),s&&F.paths.some(Bt=>Bt===s||s.endsWith(Bt))&&Ie(s),f==="preview"){const tt=["react","vite","next","nuxt","svelte","remix"];($==null?void 0:$.running)&&($==null?void 0:$.framework)&&tt.some(kt=>$.framework.toLowerCase().includes(kt))||L(kt=>kt+1)}});return()=>{b(),Ue.current&&clearTimeout(Ue.current)}},[Io,s,f,$==null?void 0:$.running,et]);const Jh=d.useCallback(async()=>{if(!(!Qe||!x.id)){try{const b=await W.getSessionFileContent(x.id,Qe);l(b.content),c(b.content),g(!1),R(I=>I.map(F=>F.path===Qe?{...F,content:b.content,modified:!1}:F))}catch{}Ie(null)}},[Qe,x.id]);d.useEffect(()=>{if(f!=="preview")return;let b=!1;const I=async()=>{try{const te=await W.devserver.status(x.id);b||ki(te)}catch{}};I();const F=setInterval(I,3e3);return()=>{b=!0,clearInterval(F)}},[f,x.id]),d.useEffect(()=>{f==="dashboard"&&fetch(`http://127.0.0.1:${fe}/health`).then(b=>_e(b.ok)).catch(()=>_e(!1))},[f]);const bs=d.useCallback(async b=>{Wo(!0),ji(null);try{const I=await W.devserver.start(x.id,b);if(I.status==="error")ji(I.message||"Failed to start dev server");else{const F=await W.devserver.status(x.id);ki(F)}}catch(I){ji(I instanceof Error?I.message:"Failed to start dev server")}Wo(!1)},[x.id]),Vo=d.useRef(!1);d.useEffect(()=>{Vo.current||se!=null&&se.dev_command&&($!=null&&$.running||($==null?void 0:$.status)==="starting"||$s||(Vo.current=!0,bs(se.dev_command)))},[se==null?void 0:se.dev_command,$==null?void 0:$.running,$==null?void 0:$.status,$s,bs]);const Zh=d.useCallback(async()=>{try{await W.devserver.stop(x.id);const b=await W.devserver.status(x.id);ki(b)}catch{}},[x.id]),Qh=d.useCallback(async()=>{Ko(!0);try{const b=await W.fixProject(x.id);if(b.task_id){let F=0,te;do await new Promise(tt=>setTimeout(tt,2e3)),te=await W.chatPoll(x.id,b.task_id),F++;while(!te.complete&&F<150);const Ye=await W.devserver.status(x.id);ki(Ye)}}catch(b){ji(b instanceof Error?b.message:"Fix failed")}Ko(!1)},[x.id]),ys=$!=null&&$.running&&($!=null&&$.port)?$.framework==="expo"?`${en}/api/sessions/${encodeURIComponent(x.id)}/expo-qr`:$.portless_url||`http://localhost:${$.port}/`:null,ed=(se==null?void 0:se.preview_url)||`${en}/api/sessions/${encodeURIComponent(x.id)}/preview/index.html`,td=ys||ed,[Ni,Go]=d.useState([]),[wt,Ei]=d.useState(0);d.useEffect(()=>{const b=ys||(se==null?void 0:se.preview_url);b&&(Go([b]),Ei(0))},[ys,se==null?void 0:se.preview_url]);const Ct=Ni[wt]||td,[Yo,jr]=d.useState(Ct),sd=d.useCallback((b,I,F,te)=>{b.preventDefault(),N({x:b.clientX,y:b.clientY,path:I,name:F,type:te})},[]),id=d.useCallback(()=>{wt>0&&(Ei(b=>b-1),L(b=>b+1))},[wt]),rd=d.useCallback(()=>{wt<Ni.length-1&&(Ei(b=>b+1),L(b=>b+1))},[wt,Ni.length]),nd=d.useCallback(b=>{let I=b;if(b.startsWith("/")&&ys)try{I=`${new URL(ys).origin}${b}`}catch{const F=$==null?void 0:$.port;F&&(I=`http://localhost:${F}${b}`)}Go(F=>[...F.slice(0,wt+1),I]),Ei(F=>F+1),L(F=>F+1)},[wt,ys,$==null?void 0:$.port]);d.useEffect(()=>{try{const b=new URL(Ct,window.location.origin);jr(b.pathname+b.search+b.hash||"/")}catch{jr(Ct)}},[Ct]);const Ri=d.useCallback(async()=>{ke({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),Q(null);try{const b=await W.reviewProject(x.id);Q(b.output)}catch(b){Q(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{ke(null)}},[x.id]),Di=d.useCallback(async()=>{ke({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),Q(null);try{const b=await W.testProject(x.id);Q(b.output)}catch(b){Q(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{ke(null)}},[x.id]),Nr=d.useCallback(async()=>{ke({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),Q(null);try{const b=await W.explainProject(x.id);Q(b.output)}catch(b){Q(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{ke(null)}},[x.id]),Er=d.useCallback(async(b,I)=>{if(window.confirm(`Delete "${I}"?`))try{await W.deleteSessionFile(x.id,b),s===b&&(i(null),o(""),l(null),c(null),g(!1)),await et()}catch(te){const Ye=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ye}`)}},[x.id,s,et]),od=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:js,onClick:()=>{Ri()}},{label:"Generate Tests",icon:ni,onClick:()=>{Di()}},{label:"Explain",icon:Ys,onClick:()=>{Nr()}},{label:"Delete",icon:so,onClick:()=>{Er(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:js,onClick:()=>{Ri()}},{label:"Run Tests",icon:ni,onClick:()=>{Di()}}],[Ri,Di,Nr,Er]),Lt=d.useCallback(async(b,I)=>{Ie(null),p&&s&&h!==null&&R(te=>te.map(Ye=>Ye.path===s?{...Ye,content:h,modified:!0}:Ye));const F=w.find(te=>te.path===b);if(F){i(b),o(I),l(F.content),c(F.content),g(F.modified);return}i(b),o(I),m(!0),g(!1);try{const te=x.id?await W.getSessionFileContent(x.id,b):await W.getFileContent(b);l(te.content),c(te.content),R(Ye=>[...Ye,{path:b,name:I,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{m(!1)}},[x.id,p,s,h,w]),Rr=d.useCallback(async()=>{var b;if(!(!s||h===null||!x.id)){y(!0);try{await W.saveSessionFile(x.id,s,h),l(h),g(!1),$h(Date.now()),R(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const I=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(I)&&L(F=>F+1)}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,x.id]),Xo=d.useCallback(b=>{const I=w.find(F=>F.path===b);if(!(I!=null&&I.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(R(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),g(te.modified)}else i(null),o(""),l(null),c(null),g(!1)}},[w,s]);d.useEffect(()=>{const b=I=>{(I.metaKey||I.ctrlKey)&&I.key==="s"&&(I.preventDefault(),p&&s&&Rr()),(I.metaKey||I.ctrlKey)&&I.key==="p"&&(I.preventDefault(),U(F=>!F),K("")),(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),xs(F=>!F)),I.key==="Escape"&&B&&U(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[p,s,Rr,B]),d.useEffect(()=>{B&&A.current&&A.current.focus()},[B]);const Jo=Lh(x.files),Is=G?Jo.filter(b=>b.path.toLowerCase().includes(G.toLowerCase())):Jo;d.useEffect(()=>{const b=x.files.find(I=>I.name==="index.html"&&I.type==="file");b&&Lt(b.path,b.name)},[]);const ad=d.useCallback(b=>{b!==void 0&&(c(b),g(b!==a),To(b.split(`
256
+ `).length))},[a]),ld=d.useCallback(b=>{j.current=b;const I=b;if(I!=null&&I.onDidChangeCursorPosition&&I.onDidChangeCursorPosition(F=>{Ih({line:F.position.lineNumber,column:F.position.column})}),I!=null&&I.getModel){const F=I.getModel();F!=null&&F.getLineCount&&To(F.getLineCount())}},[]),cd=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await W.createSessionFile(x.id,b.trim()),await et()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[x.id,et]),hd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await W.createSessionDirectory(x.id,b.trim()),await et()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[x.id,et]),Zo=d.useCallback(async()=>{try{const b=await W.previewChanges(x.id,"preview current changes");As(b)}catch{}},[x.id]),dd=d.useCallback(()=>{As(null),et()},[et]),ud=d.useCallback(b=>{As(null),et()},[et]),fd=d.useCallback(()=>{As(null)},[]),Qo=s?Dh(x.files,s):void 0,md=((ta=n.split(".").pop())==null?void 0:ta.toUpperCase())||"",{showHelp:pd,setShowHelp:ea}=gx({onToggleBuild:()=>{Pe&&Fo()}}),gd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:js,action:()=>_("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:an,action:()=>_("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:ns,action:()=>oe(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Dr,action:()=>_("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:Wt,action:()=>_("deploy")},{id:"git",label:"Git Status",category:"command",icon:ze,action:()=>_("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:oa,action:()=>_("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:ee,action:()=>{U(!0),K("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:ln,action:()=>He()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:aa,action:()=>P(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:ze,action:()=>Zo()},{id:"insights",label:"Build Insights",category:"command",icon:tn,action:()=>_("insights")},{id:"docs",label:"Documentation",category:"command",icon:Ys,action:()=>_("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:os,action:()=>Os(!0)}],[_,He,Zo]),Pi=d.useMemo(()=>{if(!Pe)return"idle";const b=(ae.phase||x.status||"").toLowerCase();return b.includes("starting")||b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[Pe,ae.phase,x.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.jsx("button",{onClick:()=>{p&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:x.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:x.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${x.status==="completed"||x.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:x.status}),Mo.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Kx,{tokenHistory:Mo})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>P(b=>!b),title:k?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:k?r.jsx(aa,{size:16}):r.jsx(Su,{size:16})}),r.jsx("button",{onClick:()=>oe(b=>!b),title:J?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:J?r.jsx(xu,{size:16}):r.jsx(bu,{size:16})}),r.jsx("button",{onClick:He,title:V?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${V?"text-primary":"text-muted hover:text-ink"}`,children:V?r.jsx(cc,{size:16}):r.jsx(ln,{size:16})})]}),!Pe&&r.jsx(he,{variant:"primary",size:"sm",icon:Ut,onClick:()=>{if(!(x.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}Si(!0)},title:"Start build for this project",children:"Build"}),!Pe&&Pi==="complete"&&r.jsx(he,{variant:"ghost",size:"sm",icon:on,onClick:()=>wr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Tt,{icon:os,label:"Natural language search",size:"sm",onClick:()=>Os(!0)}),Pe&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[We?r.jsx(he,{variant:"ghost",size:"sm",icon:Ut,onClick:Gh,title:"Resume build",children:"Resume"}):r.jsx(he,{variant:"ghost",size:"sm",icon:Zl,onClick:Vh,title:"Pause build",children:"Pause"}),r.jsx(he,{variant:"danger",size:"sm",icon:sr,onClick:Fo,title:"Stop build",children:"Stop"})]}),r.jsx(Tt,{icon:js,label:"Review project",size:"sm",onClick:Ri,disabled:!!(le!=null&&le.loading)}),r.jsx(Tt,{icon:ni,label:"Run tests",size:"sm",onClick:Di,disabled:!!(le!=null&&le.loading)}),r.jsx(Tt,{icon:Ys,label:"Explain project",size:"sm",onClick:Nr,disabled:!!(le!=null&&le.loading)}),r.jsx(he,{variant:"secondary",size:"sm",icon:Wt,onClick:()=>_("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(xx,{onClick:()=>ea(!0)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex-1",children:r.jsx(nx,{phase:Pi,iteration:ae.iteration,maxIterations:ae.maxIterations,cost:ae.cost,startTime:ae.startTime,isRunning:Pe})}),Pe&&r.jsx("div",{className:"flex-shrink-0 pr-2",children:r.jsx(yv,{gatePassRate:.8,testCoverage:ae.iteration>2?60:20,iteration:ae.iteration,maxIterations:ae.maxIterations,phase:Pi,compact:!0})})]}),r.jsx(Mx,{sessionId:x.id,onRestore:et}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(dn,{orientation:"vertical",children:[r.jsx(Zs,{defaultSize:70,minSize:40,children:r.jsxs(dn,{orientation:"horizontal",className:"h-full",children:[k&&r.jsx(Zs,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Po("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${wi==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(oo,{size:14}),"Files",Sr&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Po("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${wi==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Vl,{size:14}),"Chat"]}),wi==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:cd,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(mr,{size:12})," New"]}),r.jsxs("button",{onClick:hd,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(Pd,{size:12})," New"]})]})]}),wi==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:x.files.length>0?r.jsx(Mh,{nodes:x.files,selectedPath:s,onSelect:Lt,onDelete:Er,onContextMenu:sd}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(rn,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(vv,{sessionId:x.id,defaultMode:z})})})]})}),k&&r.jsx(un,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(Zs,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:an},{id:"preview",label:"Preview",icon:js},{id:"deploy",label:"Deploy",icon:Wt},{id:"config",label:"Config",icon:oa},{id:"secrets",label:"Secrets",icon:du},{id:"prd",label:"Spec",icon:mi},{id:"dashboard",label:"Dashboard",icon:Dr},{id:"git",label:"Git",icon:ze},{id:"cicd",label:"CI/CD",icon:ze},{id:"insights",label:"Insights",icon:tn},{id:"docs",label:"Docs",icon:Ys}].map(b=>r.jsxs("button",{role:"tab","aria-selected":f===b.id,onClick:()=>_(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Lt(b.path,b.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Zn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:I=>{I.stopPropagation(),Xo(b.path)},onKeyDown:I=>{I.key==="Enter"&&(I.stopPropagation(),Xo(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(_t,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),v&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Qo!=null?Ph(Qo):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:md}),p&&r.jsx("button",{onClick:Rr,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),Qe===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(bt,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Jh,className:"text-xs font-medium px-2 py-0.5 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors",children:"Reload"}),r.jsx("button",{onClick:()=>Ie(null),className:"text-xs font-medium px-2 py-0.5 rounded border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Dismiss"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:u?r.jsx(jd,{}):r.jsx(Wi,{name:"Editor",children:r.jsx(Vf,{value:h??"",language:zv(n),theme:"vs",onChange:ad,onMount:ld,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})}),r.jsx(Yx,{selectedFile:s,fileName:n,isModified:p,isSaving:v,lastSavedAt:Oh,lineCount:Fh,cursorLine:Bo.line,cursorColumn:Bo.column,buildTime:ae.phase==="complete"&&ae.startTime?Math.floor((Date.now()-ae.startTime)/1e3):void 0,sessionId:x.id,prd:x.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(ee,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Cmd+P"})," to quick open"]})]})]}),f==="preview"&&r.jsx(Wi,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${Ao?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:$!=null&&$.running||se!=null&&se.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Tt,{icon:Jl,label:"Back",size:"sm",onClick:id,disabled:wt<=0}),r.jsx(Tt,{icon:eo,label:"Forward",size:"sm",onClick:rd,disabled:wt>=Ni.length-1}),r.jsx(rv,{onClick:()=>{kr(!0),L(b=>b+1)}}),r.jsx("input",{value:Yo,onChange:b=>jr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&nd(Yo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(Xx,{selectedDevice:Hh,onDeviceChange:Wh,containerWidth:qh}),r.jsx(Qx,{zoom:Cr,onZoomChange:Uh}),r.jsx(sv,{url:Ct}),r.jsx(tv,{}),r.jsx(nv,{url:Ct}),r.jsx(Tt,{icon:as,label:"Open in new tab",size:"sm",onClick:()=>window.open(Ct,"_blank")}),r.jsx(iv,{isFullscreen:Ao,onToggle:()=>Kh(b=>!b)}),($==null?void 0:$.running)&&r.jsxs("button",{onClick:Zh,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded border border-danger/40 bg-danger/10 text-danger hover:bg-danger/20 transition-colors",children:[r.jsx(sr,{size:12}),"Stop"]})]}):se?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:se.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),$&&$.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${$.running?"bg-green-50 border-green-200 text-green-700":$.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":$.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${$.running?"bg-green-500":$.status==="starting"?"bg-yellow-500 animate-pulse":$.status==="error"?"bg-red-500":"bg-gray-400"}`}),$.running&&$.portless_url&&r.jsxs("span",{children:["Running at ",$.portless_url]}),$.running&&$.port&&!$.portless_url&&r.jsxs("span",{children:["Running on port ",$.port]}),$.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),$.status==="error"&&!$.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),$.status==="error"&&$.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",$.auto_fix_status]}),$.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:$.command})]}),$!=null&&$.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[Ci&&r.jsx(zl,{}),r.jsx("div",{ref:vs,className:`flex-1 bg-white overflow-auto flex justify-center ${Ci?"hidden":""}`,children:r.jsx("div",{className:`${zo} h-full preview-zoom-${Cr}`,children:r.jsx("iframe",{ref:D,src:Ct,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{kr(!1),vs.current&&$o(vs.current.clientWidth)}},E)})}),r.jsx(Tl,{messages:Oo})]}):se!=null&&se.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[Ci&&r.jsx(zl,{}),r.jsx("div",{ref:vs,className:`flex-1 bg-white overflow-auto flex justify-center ${Ci?"hidden":""}`,children:r.jsx("div",{className:`${zo} h-full preview-zoom-${Cr}`,children:r.jsx("iframe",{ref:D,src:Ct,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{kr(!1),vs.current&&$o(vs.current.clientWidth)}},E)})}),r.jsx(Tl,{messages:Oo})]}):se?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:se.type==="api"||se.type==="python-api"?r.jsx(Hd,{size:28,className:"text-primary"}):se.type==="library"?r.jsx(Ql,{size:28,className:"text-primary"}):se.type==="go-app"||se.type==="rust-app"?r.jsx(ns,{size:28,className:"text-primary"}):r.jsx(rn,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:se.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:se.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[se.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:se.dev_command}),r.jsxs("button",{onClick:()=>bs(se.dev_command||void 0),disabled:$s,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary/90 transition-colors disabled:opacity-50",children:[r.jsx(Ut,{size:12}),$s?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:se.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:se.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Xt,onChange:b=>Xh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Xt.trim()&&bs(Xt.trim())},placeholder:"e.g. npm run dev",className:"flex-1 px-3 py-1.5 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx("button",{onClick:()=>Xt.trim()&&bs(Xt.trim()),disabled:$s||!Xt.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-btn border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:"Run"})]})]})]}),qo&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:qo})]}),($==null?void 0:$.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:Qh,disabled:Uo,className:"text-xs px-2 py-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:Uo?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>bs(se.dev_command||Xt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),$.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",$.auto_fix_status]}),$.auto_fix_attempts!==void 0&&$.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",$.auto_fix_attempts,"/3"]})]}),$.output.length>0&&r.jsx("pre",{className:"text-[11px] font-mono text-danger/70 bg-danger/5 p-2 rounded max-h-32 overflow-y-auto whitespace-pre-wrap",children:$.output.slice(-10).join(`
257
+ `)})]}),se.port&&!($!=null&&$.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",se.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:T})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{onClick:()=>{Y(b),sessionStorage.setItem(`pl_provider_${x.id}`,b),W.setProvider(b).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${T===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{xe(b),sessionStorage.setItem(`pl_buildmode_${x.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${z===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:x.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:x.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),f==="secrets"&&r.jsx(Av,{}),f==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),x.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:x.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),f==="deploy"&&r.jsx(fx,{sessionId:x.id}),f==="dashboard"&&(de===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Dr,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.jsx("p",{className:"text-sm text-muted max-w-md",children:"The Loki Dashboard provides task boards, RARV timeline, quality gates, and cost tracking. Start it to see project analytics."}),r.jsx("button",{onClick:async()=>{_e(null);try{const b=await fetch(`http://127.0.0.1:${fe}/health`);_e(b.ok)}catch{_e(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[[{id:"overview",label:"Overview"},{id:"tasks",label:"Tasks"},{id:"timeline",label:"RARV Timeline"},{id:"quality",label:"Quality"},{id:"cost",label:"Cost"}].map(b=>r.jsx("button",{onClick:()=>ue(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ie===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${fe}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(as,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${fe}/#${ie}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),f==="git"&&r.jsx(Px,{sessionId:x.id}),f==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Tv,{sessionId:e.id})}),f==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Ov,{sessionId:x.id})}),f==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kv,{filesCreated:x.files.filter(b=>b.type==="file").length,filesModified:0,linesGenerated:0,testsGenerated:0,testPassRate:0,totalTokens:0,phaseBreakdown:[],totalTimeSecs:ae.startTime?Math.floor((Date.now()-ae.startTime)/1e3):0,qualityScore:0,totalCost:ae.cost,iterations:ae.iteration,provider:T})})]})]})})]})}),J&&r.jsx(un,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),J&&r.jsx(Zs,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Wi,{name:"ActivityPanel",children:r.jsx(ix,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:x.status==="running"||x.status==="in_progress",buildMode:z,buildEvents:Bh,onFileClick:b=>Lt(b,b.split("/").pop()||b)})})})]})}),(le==null?void 0:le.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[le.type==="review"?"Reviewing project":le.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[le.elapsed,"s"]})]})}),q&&r.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(Tt,{icon:_t,label:"Close",size:"sm",onClick:()=>Q(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:q})]}),S&&r.jsx(Dm,{x:S.x,y:S.y,items:od(S),onClose:()=>N(null)}),B&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>U(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:A,type:"text",value:G,onChange:b=>K(b.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:b=>{b.key==="Enter"&&Is.length>0&&(Lt(Is[0].path,Is[0].name),U(!1)),b.key==="Escape"&&U(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Is.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Lt(b.path,b.name),U(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Zn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),Is.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(_x,{open:pd,onClose:()=>ea(!1)}),r.jsx(Sx,{isOpen:ht,onClose:()=>xs(!1),commands:gd,sessionId:x.id,onFileSelect:Lt}),Do&&r.jsx(Tx,{data:Do,onAcceptAll:dd,onAcceptSelected:ud,onReject:fd,onClose:()=>As(null)}),r.jsx(Ux,{phase:Pi,buildTime:ae.startTime?Math.floor((Date.now()-ae.startTime)/1e3):void 0}),Th&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>wr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>wr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(_t,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(Ev,{sessionId:x.id,files:x.files.map(b=>({path:b.path,type:b.type})),phases:["planning","building","testing","reviewing","complete"],checkpoints:[],qualityGates:[],totalIterations:ae.iteration||ae.maxIterations})})]})}),Ah&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>Os(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>Os(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(_t,{size:16})})]}),r.jsx(Mv,{sessionId:x.id,onOpenFile:(b,I)=>{Lt(b,b.split("/").pop()||b),Os(!1)},className:"p-4"})]})}),zh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>Si(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Bv,{complexity:z==="quick"?"simple":z==="max"?"complex":"standard",provider:T,estimatedIterations:ae.maxIterations,onConfirm:async()=>{Si(!1);try{const b=x.prd||"";await W.startSession({prd:b,provider:T,projectDir:x.path}),Ze(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>Si(!1)})})})]})}function Iv(){const{sessionId:e}=Nd(),t=Ed(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),W.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Wi,{name:"ProjectWorkspace",children:r.jsx($v,{session:s,onClose:()=>t("/")})})})})}const wb=Object.freeze(Object.defineProperty({__proto__:null,default:Iv},Symbol.toStringTag,{value:"Module"}));export{gr as L,wb as P,ju as S};