@minimalcorp/tsunagi 0.1.49 → 0.1.51

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 (112) hide show
  1. package/.next/standalone/apps/web/.next/BUILD_ID +1 -1
  2. package/.next/standalone/apps/web/.next/build-manifest.json +3 -3
  3. package/.next/standalone/apps/web/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/apps/web/.next/server/app/_global-error.html +1 -1
  5. package/.next/standalone/apps/web/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/standalone/apps/web/.next/server/app/_not-found.html +1 -1
  13. package/.next/standalone/apps/web/.next/server/app/_not-found.rsc +2 -2
  14. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/.next/standalone/apps/web/.next/server/app/index.html +1 -1
  21. package/.next/standalone/apps/web/.next/server/app/index.rsc +3 -3
  22. package/.next/standalone/apps/web/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  23. package/.next/standalone/apps/web/.next/server/app/index.segments/_full.segment.rsc +3 -3
  24. package/.next/standalone/apps/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  25. package/.next/standalone/apps/web/.next/server/app/index.segments/_index.segment.rsc +2 -2
  26. package/.next/standalone/apps/web/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  27. package/.next/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  28. package/.next/standalone/apps/web/.next/server/app/settings/page.js.nft.json +1 -1
  29. package/.next/standalone/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  30. package/.next/standalone/apps/web/.next/server/app/settings.html +1 -1
  31. package/.next/standalone/apps/web/.next/server/app/settings.rsc +3 -3
  32. package/.next/standalone/apps/web/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  33. package/.next/standalone/apps/web/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  34. package/.next/standalone/apps/web/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  35. package/.next/standalone/apps/web/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  36. package/.next/standalone/apps/web/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  37. package/.next/standalone/apps/web/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  38. package/.next/standalone/apps/web/.next/server/app/tasks/[id]/page.js.nft.json +1 -1
  39. package/.next/standalone/apps/web/.next/server/app/tasks/[id]/page_client-reference-manifest.js +1 -1
  40. package/.next/standalone/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0m9m3y5._.js +3 -0
  41. package/.next/standalone/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0mo_9ei._.js +1 -1
  42. package/.next/standalone/apps/web/.next/server/chunks/ssr/[root-of-the-server]__11y.qj~._.js +3 -0
  43. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0bru-z.._.js +3 -0
  44. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0ejfw_6._.js +3 -0
  45. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0g.cd6a._.js +1 -1
  46. package/.next/standalone/apps/web/.next/server/chunks/ssr/apps_web_src_app_settings_page_tsx_0i6itlb._.js +3 -1
  47. package/.next/standalone/apps/web/.next/server/chunks/ssr/apps_web_src_app_tasks_[id]_page_tsx_0jshsm2._.js +12 -12
  48. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_102_61p._.js → node_modules_02g1ce1._.js} +1 -1
  49. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0_j5e9s._.js → node_modules_09jfkt3._.js} +1 -1
  50. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_1132ajp._.js → node_modules_0c2_xkv._.js} +1 -1
  51. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_05v_qny._.js → node_modules_0j9ao3l._.js} +1 -1
  52. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0mn5p-q._.js → node_modules_0k-a_k6._.js} +1 -1
  53. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0j-2rnz._.js → node_modules_0ne_55f._.js} +1 -1
  54. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0esrd80._.js → node_modules_0o9r9wn._.js} +1 -1
  55. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0bwy~wk._.js → node_modules_0wrve0t._.js} +1 -1
  56. package/.next/standalone/apps/web/.next/server/middleware-build-manifest.js +3 -3
  57. package/.next/standalone/apps/web/.next/server/pages/404.html +1 -1
  58. package/.next/standalone/apps/web/.next/server/pages/500.html +1 -1
  59. package/.next/standalone/apps/web/.next/server/server-reference-manifest.js +1 -1
  60. package/.next/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
  61. package/.next/standalone/apps/web/.next/static/chunks/008lct.76g--1.js +1 -0
  62. package/.next/standalone/apps/web/.next/static/chunks/0gpkw.1e6kcpn.js +1 -0
  63. package/.next/standalone/apps/web/.next/static/chunks/0k4w860cwzuyy.css +4 -0
  64. package/.next/standalone/apps/web/.next/static/chunks/0makl-d3f0_qh.js +2878 -0
  65. package/.next/standalone/apps/web/.next/static/chunks/{0hcpu00flu9x6.js → 0tcznr_934_ai.js} +1 -1
  66. package/.next/standalone/apps/web/.next/static/chunks/0v6gxm~ldhmma.js +1 -0
  67. package/.next/standalone/apps/web/.next/static/chunks/0wv-.6vqubfpy.js +23 -0
  68. package/.next/standalone/apps/web/.next/static/chunks/0xy-wfkab7_5n.js +7 -0
  69. package/.next/standalone/apps/web/package.json +3 -0
  70. package/.next/standalone/apps/web/public/vad/ort-wasm-simd-threaded.mjs +59 -0
  71. package/.next/standalone/apps/web/public/vad/ort-wasm-simd-threaded.wasm +0 -0
  72. package/.next/standalone/apps/web/public/vad/silero_vad_v5.onnx +0 -0
  73. package/.next/standalone/apps/web/public/vad/vad.worklet.bundle.min.js +1 -0
  74. package/dist/cli.js +0 -1
  75. package/dist/server/index.js +0 -5
  76. package/dist/server/lib/asr-models.d.ts +7 -0
  77. package/dist/server/lib/asr-models.js +51 -0
  78. package/dist/server/lib/process-port.js +1 -1
  79. package/dist/server/lib/voice-debug-log.d.ts +4 -4
  80. package/dist/server/lib/voice-debug-log.js +1 -1
  81. package/dist/server/lib/whisper-process.d.ts +19 -2
  82. package/dist/server/lib/whisper-process.js +123 -26
  83. package/dist/server/routes/whisper.js +39 -51
  84. package/dist/whisper-server/README.md +12 -4
  85. package/dist/whisper-server/download_model.py +8 -3
  86. package/dist/whisper-server/requirements.txt +1 -0
  87. package/dist/whisper-server/run.sh +7 -2
  88. package/dist/whisper-server/server.py +90 -17
  89. package/npm-shrinkwrap.json +2 -2
  90. package/package.json +1 -1
  91. package/.next/standalone/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0m52zsj._.js +0 -3
  92. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0_2b4wf._.js +0 -3
  93. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0s18_3n._.js +0 -3
  94. package/.next/standalone/apps/web/.next/server/chunks/ssr/node_modules_0.lo~su._.js +0 -3
  95. package/.next/standalone/apps/web/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_0qttwc4._.js +0 -3
  96. package/.next/standalone/apps/web/.next/static/chunks/04g3fzo25y9_g.js +0 -23
  97. package/.next/standalone/apps/web/.next/static/chunks/06sk6d3k059.n.js +0 -1
  98. package/.next/standalone/apps/web/.next/static/chunks/0imnlpmbrdgiv.js +0 -5
  99. package/.next/standalone/apps/web/.next/static/chunks/0n.xodexdkf03.js +0 -1
  100. package/.next/standalone/apps/web/.next/static/chunks/0u-820sh7-.-1.js +0 -1
  101. package/.next/standalone/apps/web/.next/static/chunks/13~5_8644~sbn.css +0 -4
  102. package/dist/llm-server/README.md +0 -27
  103. package/dist/llm-server/download_model.py +0 -14
  104. package/dist/llm-server/requirements.txt +0 -2
  105. package/dist/llm-server/run.sh +0 -59
  106. package/dist/server/lib/llm-process.d.ts +0 -29
  107. package/dist/server/lib/llm-process.js +0 -261
  108. package/dist/server/routes/llm.d.ts +0 -2
  109. package/dist/server/routes/llm.js +0 -23
  110. /package/.next/standalone/apps/web/.next/static/{oezQccA9cBsGwIkuMGqIY → 1z7N6ZhcQwVJOkcsbIi4M}/_buildManifest.js +0 -0
  111. /package/.next/standalone/apps/web/.next/static/{oezQccA9cBsGwIkuMGqIY → 1z7N6ZhcQwVJOkcsbIi4M}/_clientMiddlewareManifest.js +0 -0
  112. /package/.next/standalone/apps/web/.next/static/{oezQccA9cBsGwIkuMGqIY → 1z7N6ZhcQwVJOkcsbIi4M}/_ssgManifest.js +0 -0
@@ -1,24 +1,24 @@
1
- module.exports=[81814,a=>{"use strict";let b,c,d,e,f,g,h,i,j,k,l,m;var n,o,p,q=a.i(87924),r=a.i(72131),s=a.i(50944),u=a.i(210),v=a.i(60137);let w=(0,v.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),x=(0,v.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),y=(0,v.default)("folder-x",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);var z=a.i(99464);let A=(0,v.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var B=a.i(81560),C=a.i(91399),D=a.i(92712),E=a.i(67060),F=a.i(21034),G=a.i(78512),H=a.i(88381),I=a.i(33508),J=a.i(96221);let K=(0,v.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);var L=a.i(92e3);let M=(0,v.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var N=a.i(67453),O=a.i(62722),P=a.i(63588),Q=a.i(90002),R=a.i(39524),S=a.i(56026),T=a.i(1464),U=a.i(29801);function V({entry:a}){if(!a||"idle"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(K,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"idle"})]});if("connecting"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(J.Loader2,{className:"w-3 h-3 animate-spin"}),(0,q.jsx)("span",{children:"connecting"})]});if("error"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-destructive",children:[(0,q.jsx)(L.AlertCircle,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"error"})]});if("exited"===a.terminal||"paused"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(M,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:a.terminal})]});switch(a.claude){case"running":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-primary",children:[(0,q.jsx)(J.Loader2,{className:"w-3 h-3 animate-spin"}),(0,q.jsx)("span",{children:"running"})]});case"waiting":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-warning",children:[(0,q.jsx)(P.MessageSquare,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"waiting"})]});case"success":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-success",children:[(0,q.jsx)(N.CheckCircle2,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"success"})]});case"failure":case"error":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-destructive",children:[(0,q.jsx)(O.XCircle,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"failure"===a.claude?"failure":"error"})]});default:return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(K,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"idle"})]})}}function W({tabs:a,activeTabId:b,onTabChange:c,onTabCreateTerminal:d,onTabCreateClaude:e,localLlmOption:f,onTabCreateLocalLlm:g,onTabDelete:h,tabStatusMap:i,onVoiceInputTranscribed:j}){let k=(0,r.useRef)([]),[l,m]=(0,r.useState)({left:0,width:0}),[n,o]=(0,r.useState)(null);(0,r.useEffect)(()=>{let c=a.findIndex(a=>a.tab_id===b);if(-1!==c&&k.current[c]){let a=k.current[c];a&&m({left:a.offsetLeft,width:a.offsetWidth})}},[b,a]);let p=new Map,s=0;for(let b of a)"terminal"===b.mode&&(s+=1,p.set(b.tab_id,s));return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q.ConfirmDialog,{open:null!==n,onOpenChange:a=>{a.open||o(null)},title:"Delete Tab",message:n?.isRunning?"This tab is running. Are you sure you want to delete it?":"Delete this tab?",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{n&&h(n.tabId)},variant:"danger"}),(0,q.jsxs)("div",{className:"relative flex items-center gap-2 overflow-x-auto border-b border-border pb-1",children:[a.map((a,d)=>{let e=b===a.tab_id,g=i?.get(a.tab_id),h=(g?.claude==="running"||g?.claude==="waiting")&&g?.terminal==="connected";return(0,q.jsxs)("div",{ref:a=>{k.current[d]=a},onClick:()=>c(a.tab_id),className:`
1
+ module.exports=[81814,a=>{"use strict";let b,c,d,e,f,g,h,i,j,k,l,m;var n,o,p,q=a.i(87924),r=a.i(72131),s=a.i(50944),u=a.i(210),v=a.i(60137);let w=(0,v.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),x=(0,v.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),y=(0,v.default)("folder-x",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);var z=a.i(99464);let A=(0,v.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var B=a.i(81560),C=a.i(91399),D=a.i(92712),E=a.i(67060),F=a.i(21034),G=a.i(78512),H=a.i(88381),I=a.i(33508),J=a.i(96221);let K=(0,v.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);var L=a.i(92e3);let M=(0,v.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var N=a.i(67453),O=a.i(62722),P=a.i(63588),Q=a.i(90002),R=a.i(39524),S=a.i(4975);function T({store:a}){let b=(0,r.useSyncExternalStore)(a.subscribe,a.getSnapshot,()=>0);return(0,q.jsx)("div",{"aria-hidden":!0,className:"h-1.5 w-16 overflow-hidden rounded-full bg-background/60",children:(0,q.jsx)("div",{className:"h-full rounded-full bg-destructive",style:{width:`${Math.round(100*b)}%`}})})}function U({voiceInput:a}){let{enabled:b,serverReady:c,status:d,levelStore:e,toggle:f}=a;if(!b)return null;let g="listening"===d;return(0,q.jsxs)("div",{className:g?"inline-flex items-center gap-2 rounded-md bg-destructive/10 p-1":"inline-flex",children:[(0,q.jsx)(R.Button,{size:"icon",variant:g?"destructive":"default",onClick:f,disabled:"starting"===d||"off"===d&&!c,title:g?"音声入力を停止":c?"音声入力を開始(話した部分が自動で入力されます)":"音声認識サーバーが起動していません(Settingsから起動してください)",children:"starting"===d?(0,q.jsx)(J.Loader2,{className:"w-4 h-4 animate-spin"}):(0,q.jsx)(S.Mic,{className:"w-4 h-4"})}),g&&(0,q.jsx)(T,{store:e})]})}var V=a.i(1464),W=a.i(29801);function X({entry:a}){if(!a||"idle"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(K,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"idle"})]});if("connecting"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(J.Loader2,{className:"w-3 h-3 animate-spin"}),(0,q.jsx)("span",{children:"connecting"})]});if("error"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-destructive",children:[(0,q.jsx)(L.AlertCircle,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"error"})]});if("exited"===a.terminal||"paused"===a.terminal)return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(M,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:a.terminal})]});switch(a.claude){case"running":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-primary",children:[(0,q.jsx)(J.Loader2,{className:"w-3 h-3 animate-spin"}),(0,q.jsx)("span",{children:"running"})]});case"waiting":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-warning",children:[(0,q.jsx)(P.MessageSquare,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"waiting"})]});case"success":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-success",children:[(0,q.jsx)(N.CheckCircle2,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"success"})]});case"failure":case"error":return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-destructive",children:[(0,q.jsx)(O.XCircle,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"failure"===a.claude?"failure":"error"})]});default:return(0,q.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,q.jsx)(K,{className:"w-3 h-3"}),(0,q.jsx)("span",{children:"idle"})]})}}function Y({tabs:a,activeTabId:b,onTabChange:c,onTabCreateTerminal:d,onTabCreateClaude:e,localLlmOption:f,onTabCreateLocalLlm:g,onTabDelete:h,tabStatusMap:i,voiceInput:j}){let k=(0,r.useRef)([]),[l,m]=(0,r.useState)({left:0,width:0}),[n,o]=(0,r.useState)(null);(0,r.useEffect)(()=>{let c=a.findIndex(a=>a.tab_id===b);if(-1!==c&&k.current[c]){let a=k.current[c];a&&m({left:a.offsetLeft,width:a.offsetWidth})}},[b,a]);let p=new Map,s=0;for(let b of a)"terminal"===b.mode&&(s+=1,p.set(b.tab_id,s));return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q.ConfirmDialog,{open:null!==n,onOpenChange:a=>{a.open||o(null)},title:"Delete Tab",message:n?.isRunning?"This tab is running. Are you sure you want to delete it?":"Delete this tab?",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{n&&h(n.tabId)},variant:"danger"}),(0,q.jsxs)("div",{className:"relative flex items-center gap-2 overflow-x-auto border-b border-border pb-1",children:[a.map((a,d)=>{let e=b===a.tab_id,g=i?.get(a.tab_id),h=(g?.claude==="running"||g?.claude==="waiting")&&g?.terminal==="connected";return(0,q.jsxs)("div",{ref:a=>{k.current[d]=a},onClick:()=>c(a.tab_id),className:`
2
2
  flex items-center gap-2 px-4 pt-1 pb-2 h-10 flex-shrink-0 transition-colors cursor-pointer
3
3
  ${e?"text-primary":h?"text-primary-light":"text-muted-foreground hover:text-foreground"}
4
- `,children:[(0,q.jsx)("div",{className:"font-medium flex items-center gap-2",children:"terminal"===a.mode?(0,q.jsxs)("span",{className:"text-xs",children:["terminal ",p.get(a.tab_id)]}):(0,q.jsxs)(q.Fragment,{children:[("local"===a.mode||"ollama"===a.mode||"lmstudio"===a.mode)&&(0,q.jsx)("span",{title:(0,U.localLlmTabLabel)(f?.provider??null),children:(0,q.jsx)(T.LocalLlmTabIcon,{provider:f?.provider??null,className:"w-3 h-3"})}),(0,q.jsx)(V,{entry:g})]})}),(0,q.jsx)(R.Button,{variant:"ghost",size:"icon-xs",onClick:b=>{b.stopPropagation(),o({tabId:a.tab_id,isRunning:h})},children:(0,q.jsx)(I.X,{className:"w-4 h-4"})})]},a.tab_id)}),(0,q.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 ml-auto",children:[j&&(0,q.jsx)(S.VoiceInputButton,{onTranscribed:j}),(0,q.jsx)("div",{className:"w-px self-stretch bg-theme"}),d&&(0,q.jsx)(R.Button,{size:"icon",onClick:d,title:"Open terminal",children:(0,q.jsx)(A,{className:"w-4 h-4"})}),(0,q.jsx)(R.Button,{size:"icon",onClick:e,title:"Claude Code",children:(0,q.jsx)(T.ClaudeIcon,{className:"w-4 h-4"})}),f&&(0,q.jsx)("span",{title:f.model?`${(0,U.localLlmTabLabel)(f.provider)}: ${f.model}`:"ローカルLLMのモデルが未設定です(Settings で設定)",children:(0,q.jsx)(R.Button,{size:"icon",onClick:g,disabled:!f.model,children:(0,q.jsx)(T.LocalLlmTabIcon,{provider:f.provider,className:"w-4 h-4"})})})]}),(0,q.jsx)("div",{className:"absolute bottom-0 h-0.5 bg-primary transition-[left,width]",style:{left:`${l.left}px`,width:`${l.width}px`}})]})]})}var X=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,Z=(a,b,c,d)=>{for(var e,f=d>1?void 0:d?Y(b,c):b,g=a.length-1;g>=0;g--)(e=a[g])&&(f=(d?e(b,c,f):e(f))||f);return d&&f&&X(b,c,f),f},$=(a,b)=>(c,d)=>b(c,d,a),_="Terminal input",aa="Too much output to announce, navigate to rows manually to read";function ab(a,b,c,d){var e;e=a=a.replace(/\r?\n/g,"\r"),a=c.decPrivateModes.bracketedPasteMode&&!0!==d.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+e+"\x1b[201~":e,c.triggerDataEvent(a,!0),b.value=""}function ac(a,b,c){let d=c.getBoundingClientRect(),e=a.clientX-d.left-10,f=a.clientY-d.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${e}px`,b.style.top=`${f}px`,b.style.zIndex="1000",b.focus()}function ad(a,b,c,d,e){ac(a,b,c),e&&d.rightClickSelect(a),b.value=d.selectionText,b.select()}function ae(a){return a>65535?String.fromCharCode(((a-=65536)>>10)+55296)+String.fromCharCode(a%1024+56320):String.fromCharCode(a)}function af(a,b=0,c=a.length){let d="";for(let e=b;e<c;++e){let b=a[e];b>65535?(b-=65536,d+=String.fromCharCode((b>>10)+55296)+String.fromCharCode(b%1024+56320)):d+=String.fromCharCode(b)}return d}var ag=class{constructor(){this._interim=0}clear(){this._interim=0}decode(a,b){let c=a.length;if(!c)return 0;let d=0,e=0;if(this._interim){let c=a.charCodeAt(e++);56320<=c&&c<=57343?b[d++]=(this._interim-55296)*1024+c-56320+65536:(b[d++]=this._interim,b[d++]=c),this._interim=0}for(let f=e;f<c;++f){let e=a.charCodeAt(f);if(55296<=e&&e<=56319){if(++f>=c)return this._interim=e,d;let g=a.charCodeAt(f);56320<=g&&g<=57343?b[d++]=(e-55296)*1024+g-56320+65536:(b[d++]=e,b[d++]=g);continue}65279!==e&&(b[d++]=e)}return d}},ah=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(a,b){let c=a.length;if(!c)return 0;let d=0,e,f,g,h,i=0,j=0;if(this.interim[0]){let e=!1,f=this.interim[0];f&=(224&f)==192?31:(240&f)==224?15:7;let g=0,h;for(;(h=63&this.interim[++g])&&g<4;)f<<=6,f|=h;let i=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,k=i-g;for(;j<k;){if(j>=c)return 0;if((192&(h=a[j++]))!=128){j--,e=!0;break}this.interim[g++]=h,f<<=6,f|=63&h}e||(2===i?f<128?j--:b[d++]=f:3===i?f<2048||f>=55296&&f<=57343||65279===f||(b[d++]=f):f<65536||f>1114111||(b[d++]=f)),this.interim.fill(0)}let k=c-4,l=j;for(;l<c;){for(;l<k&&!(128&(e=a[l]))&&!(128&(f=a[l+1]))&&!(128&(g=a[l+2]))&&!(128&(h=a[l+3]));)b[d++]=e,b[d++]=f,b[d++]=g,b[d++]=h,l+=4;if((e=a[l++])<128)b[d++]=e;else if((224&e)==192){if(l>=c)return this.interim[0]=e,d;if((192&(f=a[l++]))!=128||(i=(31&e)<<6|63&f)<128){l--;continue}b[d++]=i}else if((240&e)==224){if(l>=c)return this.interim[0]=e,d;if((192&(f=a[l++]))!=128){l--;continue}if(l>=c)return this.interim[0]=e,this.interim[1]=f,d;if((192&(g=a[l++]))!=128){l--;continue}if((i=(15&e)<<12|(63&f)<<6|63&g)<2048||i>=55296&&i<=57343||65279===i)continue;b[d++]=i}else if((248&e)==240){if(l>=c)return this.interim[0]=e,d;if((192&(f=a[l++]))!=128){l--;continue}if(l>=c)return this.interim[0]=e,this.interim[1]=f,d;if((192&(g=a[l++]))!=128){l--;continue}if(l>=c)return this.interim[0]=e,this.interim[1]=f,this.interim[2]=g,d;if((192&(h=a[l++]))!=128){l--;continue}if((i=(7&e)<<18|(63&f)<<12|(63&g)<<6|63&h)<65536||i>1114111)continue;b[d++]=i}}return d}},ai=class a{constructor(){this.fg=0,this.bg=0,this.extended=new aj}static toColorRGB(a){return[a>>>16&255,a>>>8&255,255&a]}static fromColorRGB(a){return(255&a[0])<<16|(255&a[1])<<8|255&a[2]}clone(){let b=new a;return b.fg=this.fg,b.bg=this.bg,b.extended=this.extended.clone(),b}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},aj=class a{constructor(a=0,b=0){this._ext=0,this._urlId=0,this._ext=a,this._urlId=b}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(a){this._ext=a}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(a){this._ext&=-0x1c000001,this._ext|=a<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(a){this._ext&=-0x4000000,this._ext|=0x3ffffff&a}get urlId(){return this._urlId}set urlId(a){this._urlId=a}get underlineVariantOffset(){let a=(0xe0000000&this._ext)>>29;return a<0?0xfffffff8^a:a}set underlineVariantOffset(a){this._ext&=0x1fffffff,this._ext|=a<<29&0xe0000000}clone(){return new a(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},ak=class a extends ai{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new aj,this.combinedData=""}static fromCharData(b){let c=new a;return c.setFromCharData(b),c}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?ae(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(a){this.fg=a[0],this.bg=0;let b=!1;if(a[1].length>2)b=!0;else if(2===a[1].length){let c=a[1].charCodeAt(0);if(55296<=c&&c<=56319){let d=a[1].charCodeAt(1);56320<=d&&d<=57343?this.content=(c-55296)*1024+d-56320+65536|a[2]<<22:b=!0}else b=!0}else this.content=a[1].charCodeAt(0)|a[2]<<22;b&&(this.combinedData=a[1],this.content=2097152|a[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},al="di$target",am="di$dependencies",an=new Map;function ao(a){if(an.has(a))return an.get(a);let b=function(a,c,d){var e,f,g;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");e=b,f=a,g=d,f[al]===f?f[am].push({id:e,index:g}):(f[am]=[{id:e,index:g}],f[al]=f)};return b._id=a,an.set(a,b),b}var ap=ao("BufferService"),aq=ao("CoreMouseService"),ar=ao("CoreService"),as=ao("CharsetService"),at=ao("InstantiationService"),au=ao("LogService"),av=ao("OptionsService"),aw=ao("OscLinkService"),ax=ao("UnicodeService"),ay=ao("DecorationService"),az=class{constructor(a,b,c){this._bufferService=a,this._optionsService=b,this._oscLinkService=c}provideLinks(a,b){let c=this._bufferService.buffer.lines.get(a-1);if(!c)return void b(void 0);let d=[],e=this._optionsService.rawOptions.linkHandler,f=new ak,g=c.getTrimmedLength(),h=-1,i=-1,j=!1;for(let b=0;b<g;b++)if(!(-1===i&&!c.hasContent(b))){if(c.loadCell(b,f),f.hasExtendedAttrs()&&f.extended.urlId)if(-1===i){i=b,h=f.extended.urlId;continue}else j=f.extended.urlId!==h;else -1!==i&&(j=!0);if(j||-1!==i&&b===g-1){let c=this._oscLinkService.getLinkData(h)?.uri;if(c){let f={start:{x:i+1,y:a},end:{x:b+ +(!j&&b===g-1),y:a}},h=!1;if(!e?.allowNonHttpProtocols)try{let a=new URL(c);["http:","https:"].includes(a.protocol)||(h=!0)}catch{h=!0}h||d.push({text:c,range:f,activate:(a,b)=>e?e.activate(a,b,f):function(a){if(confirm(`Do you want to navigate to ${a}?
4
+ `,children:[(0,q.jsx)("div",{className:"font-medium flex items-center gap-2",children:"terminal"===a.mode?(0,q.jsxs)("span",{className:"text-xs",children:["terminal ",p.get(a.tab_id)]}):(0,q.jsxs)(q.Fragment,{children:[("local"===a.mode||"ollama"===a.mode||"lmstudio"===a.mode)&&(0,q.jsx)("span",{title:(0,W.localLlmTabLabel)(f?.provider??null),children:(0,q.jsx)(V.LocalLlmTabIcon,{provider:f?.provider??null,className:"w-3 h-3"})}),(0,q.jsx)(X,{entry:g})]})}),(0,q.jsx)(R.Button,{variant:"ghost",size:"icon-xs",onClick:b=>{b.stopPropagation(),o({tabId:a.tab_id,isRunning:h})},children:(0,q.jsx)(I.X,{className:"w-4 h-4"})})]},a.tab_id)}),(0,q.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 ml-auto",children:[j&&(0,q.jsx)(U,{voiceInput:j}),(0,q.jsx)("div",{className:"w-px self-stretch bg-theme"}),d&&(0,q.jsx)(R.Button,{size:"icon",onClick:d,title:"Open terminal",children:(0,q.jsx)(A,{className:"w-4 h-4"})}),(0,q.jsx)(R.Button,{size:"icon",onClick:e,title:"Claude Code",children:(0,q.jsx)(V.ClaudeIcon,{className:"w-4 h-4"})}),f&&(0,q.jsx)("span",{title:f.model?`${(0,W.localLlmTabLabel)(f.provider)}: ${f.model}`:"ローカルLLMのモデルが未設定です(Settings で設定)",children:(0,q.jsx)(R.Button,{size:"icon",onClick:g,disabled:!f.model,children:(0,q.jsx)(V.LocalLlmTabIcon,{provider:f.provider,className:"w-4 h-4"})})})]}),(0,q.jsx)("div",{className:"absolute bottom-0 h-0.5 bg-primary transition-[left,width]",style:{left:`${l.left}px`,width:`${l.width}px`}})]})]})}let Z=(0,v.default)("audio-lines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);function $({utterances:a}){return 0===a.length?null:(0,q.jsx)("div",{className:"pointer-events-none absolute inset-x-4 bottom-8 z-10 flex justify-center",children:(0,q.jsx)("div",{className:"w-full max-w-2xl space-y-1 rounded-md border bg-card/95 p-3 text-sm text-card-foreground shadow-md",children:a.map(a=>(0,q.jsxs)("div",{className:"flex items-start gap-2",children:["speaking"===a.phase?(0,q.jsx)(Z,{className:"mt-0.5 size-4 shrink-0 animate-pulse text-destructive"}):"finalizing"===a.phase?(0,q.jsx)(J.Loader2,{className:"mt-0.5 size-4 shrink-0 animate-spin text-muted-foreground"}):(0,q.jsx)(N.CheckCircle2,{className:"mt-0.5 size-4 shrink-0 text-success"}),(0,q.jsx)("p",{className:"speaking"===a.phase?"text-muted-foreground":void 0,children:a.text||"…"})]},a.id))})})}var _=a.i(6828),aa=a.i(46057);let ab=["running","running_external"];function ac(){let a=0,b=new Set;return{subscribe:a=>(b.add(a),()=>b.delete(a)),getSnapshot:()=>a,set:c=>{c!==a&&(a=c,b.forEach(a=>a()))}}}var ad=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,af=(a,b,c,d)=>{for(var e,f=d>1?void 0:d?ae(b,c):b,g=a.length-1;g>=0;g--)(e=a[g])&&(f=(d?e(b,c,f):e(f))||f);return d&&f&&ad(b,c,f),f},ag=(a,b)=>(c,d)=>b(c,d,a),ah="Terminal input",ai="Too much output to announce, navigate to rows manually to read";function aj(a,b,c,d){var e;e=a=a.replace(/\r?\n/g,"\r"),a=c.decPrivateModes.bracketedPasteMode&&!0!==d.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+e+"\x1b[201~":e,c.triggerDataEvent(a,!0),b.value=""}function ak(a,b,c){let d=c.getBoundingClientRect(),e=a.clientX-d.left-10,f=a.clientY-d.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${e}px`,b.style.top=`${f}px`,b.style.zIndex="1000",b.focus()}function al(a,b,c,d,e){ak(a,b,c),e&&d.rightClickSelect(a),b.value=d.selectionText,b.select()}function am(a){return a>65535?String.fromCharCode(((a-=65536)>>10)+55296)+String.fromCharCode(a%1024+56320):String.fromCharCode(a)}function an(a,b=0,c=a.length){let d="";for(let e=b;e<c;++e){let b=a[e];b>65535?(b-=65536,d+=String.fromCharCode((b>>10)+55296)+String.fromCharCode(b%1024+56320)):d+=String.fromCharCode(b)}return d}var ao=class{constructor(){this._interim=0}clear(){this._interim=0}decode(a,b){let c=a.length;if(!c)return 0;let d=0,e=0;if(this._interim){let c=a.charCodeAt(e++);56320<=c&&c<=57343?b[d++]=(this._interim-55296)*1024+c-56320+65536:(b[d++]=this._interim,b[d++]=c),this._interim=0}for(let f=e;f<c;++f){let e=a.charCodeAt(f);if(55296<=e&&e<=56319){if(++f>=c)return this._interim=e,d;let g=a.charCodeAt(f);56320<=g&&g<=57343?b[d++]=(e-55296)*1024+g-56320+65536:(b[d++]=e,b[d++]=g);continue}65279!==e&&(b[d++]=e)}return d}},ap=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(a,b){let c=a.length;if(!c)return 0;let d=0,e,f,g,h,i=0,j=0;if(this.interim[0]){let e=!1,f=this.interim[0];f&=(224&f)==192?31:(240&f)==224?15:7;let g=0,h;for(;(h=63&this.interim[++g])&&g<4;)f<<=6,f|=h;let i=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,k=i-g;for(;j<k;){if(j>=c)return 0;if((192&(h=a[j++]))!=128){j--,e=!0;break}this.interim[g++]=h,f<<=6,f|=63&h}e||(2===i?f<128?j--:b[d++]=f:3===i?f<2048||f>=55296&&f<=57343||65279===f||(b[d++]=f):f<65536||f>1114111||(b[d++]=f)),this.interim.fill(0)}let k=c-4,l=j;for(;l<c;){for(;l<k&&!(128&(e=a[l]))&&!(128&(f=a[l+1]))&&!(128&(g=a[l+2]))&&!(128&(h=a[l+3]));)b[d++]=e,b[d++]=f,b[d++]=g,b[d++]=h,l+=4;if((e=a[l++])<128)b[d++]=e;else if((224&e)==192){if(l>=c)return this.interim[0]=e,d;if((192&(f=a[l++]))!=128||(i=(31&e)<<6|63&f)<128){l--;continue}b[d++]=i}else if((240&e)==224){if(l>=c)return this.interim[0]=e,d;if((192&(f=a[l++]))!=128){l--;continue}if(l>=c)return this.interim[0]=e,this.interim[1]=f,d;if((192&(g=a[l++]))!=128){l--;continue}if((i=(15&e)<<12|(63&f)<<6|63&g)<2048||i>=55296&&i<=57343||65279===i)continue;b[d++]=i}else if((248&e)==240){if(l>=c)return this.interim[0]=e,d;if((192&(f=a[l++]))!=128){l--;continue}if(l>=c)return this.interim[0]=e,this.interim[1]=f,d;if((192&(g=a[l++]))!=128){l--;continue}if(l>=c)return this.interim[0]=e,this.interim[1]=f,this.interim[2]=g,d;if((192&(h=a[l++]))!=128){l--;continue}if((i=(7&e)<<18|(63&f)<<12|(63&g)<<6|63&h)<65536||i>1114111)continue;b[d++]=i}}return d}},aq=class a{constructor(){this.fg=0,this.bg=0,this.extended=new ar}static toColorRGB(a){return[a>>>16&255,a>>>8&255,255&a]}static fromColorRGB(a){return(255&a[0])<<16|(255&a[1])<<8|255&a[2]}clone(){let b=new a;return b.fg=this.fg,b.bg=this.bg,b.extended=this.extended.clone(),b}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ar=class a{constructor(a=0,b=0){this._ext=0,this._urlId=0,this._ext=a,this._urlId=b}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(a){this._ext=a}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(a){this._ext&=-0x1c000001,this._ext|=a<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(a){this._ext&=-0x4000000,this._ext|=0x3ffffff&a}get urlId(){return this._urlId}set urlId(a){this._urlId=a}get underlineVariantOffset(){let a=(0xe0000000&this._ext)>>29;return a<0?0xfffffff8^a:a}set underlineVariantOffset(a){this._ext&=0x1fffffff,this._ext|=a<<29&0xe0000000}clone(){return new a(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},as=class a extends aq{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ar,this.combinedData=""}static fromCharData(b){let c=new a;return c.setFromCharData(b),c}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?am(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(a){this.fg=a[0],this.bg=0;let b=!1;if(a[1].length>2)b=!0;else if(2===a[1].length){let c=a[1].charCodeAt(0);if(55296<=c&&c<=56319){let d=a[1].charCodeAt(1);56320<=d&&d<=57343?this.content=(c-55296)*1024+d-56320+65536|a[2]<<22:b=!0}else b=!0}else this.content=a[1].charCodeAt(0)|a[2]<<22;b&&(this.combinedData=a[1],this.content=2097152|a[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},at="di$target",au="di$dependencies",av=new Map;function aw(a){if(av.has(a))return av.get(a);let b=function(a,c,d){var e,f,g;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");e=b,f=a,g=d,f[at]===f?f[au].push({id:e,index:g}):(f[au]=[{id:e,index:g}],f[at]=f)};return b._id=a,av.set(a,b),b}var ax=aw("BufferService"),ay=aw("CoreMouseService"),az=aw("CoreService"),aA=aw("CharsetService"),aB=aw("InstantiationService"),aC=aw("LogService"),aD=aw("OptionsService"),aE=aw("OscLinkService"),aF=aw("UnicodeService"),aG=aw("DecorationService"),aH=class{constructor(a,b,c){this._bufferService=a,this._optionsService=b,this._oscLinkService=c}provideLinks(a,b){let c=this._bufferService.buffer.lines.get(a-1);if(!c)return void b(void 0);let d=[],e=this._optionsService.rawOptions.linkHandler,f=new as,g=c.getTrimmedLength(),h=-1,i=-1,j=!1;for(let b=0;b<g;b++)if(!(-1===i&&!c.hasContent(b))){if(c.loadCell(b,f),f.hasExtendedAttrs()&&f.extended.urlId)if(-1===i){i=b,h=f.extended.urlId;continue}else j=f.extended.urlId!==h;else -1!==i&&(j=!0);if(j||-1!==i&&b===g-1){let c=this._oscLinkService.getLinkData(h)?.uri;if(c){let f={start:{x:i+1,y:a},end:{x:b+ +(!j&&b===g-1),y:a}},h=!1;if(!e?.allowNonHttpProtocols)try{let a=new URL(c);["http:","https:"].includes(a.protocol)||(h=!0)}catch{h=!0}h||d.push({text:c,range:f,activate:(a,b)=>e?e.activate(a,b,f):function(a){if(confirm(`Do you want to navigate to ${a}?
5
5
 
6
- WARNING: This link could potentially be dangerous`)){let b=window.open();if(b){try{b.opener=null}catch{}b.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}(b),hover:(a,b)=>e?.hover?.(a,b,f),leave:(a,b)=>e?.leave?.(a,b,f)})}j=!1,f.hasExtendedAttrs()&&f.extended.urlId?(i=b,h=f.extended.urlId):(i=-1,h=-1)}}b(d)}};az=Z([$(0,ap),$(1,av),$(2,aw)],az);var aA=ao("CharSizeService"),aB=ao("CoreBrowserService"),aC=ao("MouseService"),aD=ao("RenderService"),aE=ao("SelectionService"),aF=ao("CharacterJoinerService"),aG=ao("ThemeService"),aH=ao("LinkProviderService"),aI=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(a){setTimeout(()=>{throw a.stack?aM.isErrorNoTelemetry(a)?new aM(a.message+`
6
+ WARNING: This link could potentially be dangerous`)){let b=window.open();if(b){try{b.opener=null}catch{}b.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}(b),hover:(a,b)=>e?.hover?.(a,b,f),leave:(a,b)=>e?.leave?.(a,b,f)})}j=!1,f.hasExtendedAttrs()&&f.extended.urlId?(i=b,h=f.extended.urlId):(i=-1,h=-1)}}b(d)}};aH=af([ag(0,ax),ag(1,aD),ag(2,aE)],aH);var aI=aw("CharSizeService"),aJ=aw("CoreBrowserService"),aK=aw("MouseService"),aL=aw("RenderService"),aM=aw("SelectionService"),aN=aw("CharacterJoinerService"),aO=aw("ThemeService"),aP=aw("LinkProviderService"),aQ=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(a){setTimeout(()=>{throw a.stack?aU.isErrorNoTelemetry(a)?new aU(a.message+`
7
7
 
8
8
  `+a.stack):Error(a.message+`
9
9
 
10
- `+a.stack):a},0)}}addListener(a){return this.listeners.push(a),()=>{this._removeListener(a)}}emit(a){this.listeners.forEach(b=>{b(a)})}_removeListener(a){this.listeners.splice(this.listeners.indexOf(a),1)}setUnexpectedErrorHandler(a){this.unexpectedErrorHandler=a}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(a){this.unexpectedErrorHandler(a),this.emit(a)}onUnexpectedExternalError(a){this.unexpectedErrorHandler(a)}};function aJ(a){var b;(b=a)instanceof aL||b instanceof Error&&b.name===aK&&b.message===aK||aI.onUnexpectedError(a)}var aK="Canceled",aL=class extends Error{constructor(){super(aK),this.name=this.message}},aM=class a extends Error{constructor(a){super(a),this.name="CodeExpectedError"}static fromError(b){if(b instanceof a)return b;let c=new a;return c.message=b.message,c.stack=b.stack,c}static isErrorNoTelemetry(a){return"CodeExpectedError"===a.name}},aN=class a extends Error{constructor(b){super(b||"An unexpected bug occurred."),Object.setPrototypeOf(this,a.prototype)}};function aO(a,b=0){return a[a.length-(1+b)]}(a3=a4||={}).isLessThan=function(a){return a<0},a3.isLessThanOrEqual=function(a){return a<=0},a3.isGreaterThan=function(a){return a>0},a3.isNeitherLessOrGreaterThan=function(a){return 0===a},a3.greaterThan=1,a3.lessThan=-1,a3.neitherLessOrGreaterThan=0;var aP=class a{constructor(a){this.iterate=a}forEach(a){this.iterate(b=>(a(b),!0))}toArray(){let a=[];return this.iterate(b=>(a.push(b),!0)),a}filter(b){return new a(a=>this.iterate(c=>!b(c)||a(c)))}map(b){return new a(a=>this.iterate(c=>a(b(c))))}some(a){let b=!1;return this.iterate(c=>!(b=a(c))),b}findFirst(a){let b;return this.iterate(c=>!a(c)||(b=c,!1)),b}findLast(a){let b;return this.iterate(c=>(a(c)&&(b=c),!0)),b}findLastMaxBy(a){let b,c=!0;return this.iterate(d=>((c||a4.isGreaterThan(a(d,b)))&&(c=!1,b=d),!0)),b}};aP.empty=new aP(a=>{});function aQ(a){}function aR(a,b){}function aS(a){if(a5.is(a)){let b=[];for(let c of a)if(c)try{c.dispose()}catch(a){b.push(a)}if(1===b.length)throw b[0];if(b.length>1)throw AggregateError(b,"Encountered errors while disposing of store");return Array.isArray(a)?[]:a}if(a)return a.dispose(),a}function aT(a){let b={dispose:function(a,b){let c=this,d=!1,e;return function(){if(d)return e;if(d=!0,b)try{e=a.apply(c,arguments)}finally{b()}else e=a.apply(c,arguments);return e}}(()=>{aQ(b),a()})};return b}(a=>{function b(a){return a&&"object"==typeof a&&"function"==typeof a[Symbol.iterator]}a.is=b;let c=Object.freeze([]);function*d(a){yield a}a.empty=function(){return c},a.single=d,a.wrap=function(a){return b(a)?a:d(a)},a.from=function(a){return a||c},a.reverse=function*(a){for(let b=a.length-1;b>=0;b--)yield a[b]},a.isEmpty=function(a){return!a||!0===a[Symbol.iterator]().next().done},a.first=function(a){return a[Symbol.iterator]().next().value},a.some=function(a,b){let c=0;for(let d of a)if(b(d,c++))return!0;return!1},a.find=function(a,b){for(let c of a)if(b(c))return c},a.filter=function*(a,b){for(let c of a)b(c)&&(yield c)},a.map=function*(a,b){let c=0;for(let d of a)yield b(d,c++)},a.flatMap=function*(a,b){let c=0;for(let d of a)yield*b(d,c++)},a.concat=function*(...a){for(let b of a)yield*b},a.reduce=function(a,b,c){let d=c;for(let c of a)d=b(d,c);return d},a.slice=function*(a,b,c=a.length){for(b<0&&(b+=a.length),c<0?c+=a.length:c>a.length&&(c=a.length);b<c;b++)yield a[b]},a.consume=function(b,c=1/0){let d=[];if(0===c)return[d,b];let e=b[Symbol.iterator]();for(let b=0;b<c;b++){let b=e.next();if(b.done)return[d,a.empty()];d.push(b.value)}return[d,{[Symbol.iterator]:()=>e}]},a.asyncToArray=async function(a){let b=[];for await(let c of a)b.push(c);return Promise.resolve(b)}})(a5||={});var aU=class a{constructor(){var a;this._toDispose=new Set,this._isDisposed=!1,a=this}dispose(){this._isDisposed||(aQ(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{aS(this._toDispose)}finally{this._toDispose.clear()}}add(b){if(!b)return b;if(b===this)throw Error("Cannot register a disposable on itself!");return aR(b,this),this._isDisposed?a.DISABLE_DISPOSED_WARNING||console.warn(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(b),b}delete(a){if(a){if(a===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(a),a.dispose()}}deleteAndLeak(a){a&&this._toDispose.has(a)&&(this._toDispose.delete(a),aR(a,null))}};aU.DISABLE_DISPOSED_WARNING=!1;var aV=aU,aW=class{constructor(){var a;this._store=new aV,a=this,aR(this._store,this)}dispose(){aQ(this),this._store.dispose()}_register(a){if(a===this)throw Error("Cannot register a disposable on itself!");return this._store.add(a)}};aW.None=Object.freeze({dispose(){}});var aX=class{constructor(){var a;this._isDisposed=!1,a=this}get value(){return this._isDisposed?void 0:this._value}set value(a){this._isDisposed||a===this._value||(this._value?.dispose(),a&&aR(a,this),this._value=a)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,aQ(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let a=this._value;return this._value=void 0,a&&aR(a,null),a}},aY=globalThis,aZ=class a{constructor(b){this.element=b,this.next=a.Undefined,this.prev=a.Undefined}};aZ.Undefined=new aZ(void 0);var a$=class{constructor(){this._first=aZ.Undefined,this._last=aZ.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===aZ.Undefined}clear(){let a=this._first;for(;a!==aZ.Undefined;){let b=a.next;a.prev=aZ.Undefined,a.next=aZ.Undefined,a=b}this._first=aZ.Undefined,this._last=aZ.Undefined,this._size=0}unshift(a){return this._insert(a,!1)}push(a){return this._insert(a,!0)}_insert(a,b){let c=new aZ(a);if(this._first===aZ.Undefined)this._first=c,this._last=c;else if(b){let a=this._last;this._last=c,c.prev=a,a.next=c}else{let a=this._first;this._first=c,c.next=a,a.prev=c}this._size+=1;let d=!1;return()=>{d||(d=!0,this._remove(c))}}shift(){if(this._first!==aZ.Undefined){let a=this._first.element;return this._remove(this._first),a}}pop(){if(this._last!==aZ.Undefined){let a=this._last.element;return this._remove(this._last),a}}_remove(a){if(a.prev!==aZ.Undefined&&a.next!==aZ.Undefined){let b=a.prev;b.next=a.next,a.next.prev=b}else a.prev===aZ.Undefined&&a.next===aZ.Undefined?(this._first=aZ.Undefined,this._last=aZ.Undefined):a.next===aZ.Undefined?(this._last=this._last.prev,this._last.next=aZ.Undefined):a.prev===aZ.Undefined&&(this._first=this._first.next,this._first.prev=aZ.Undefined);this._size-=1}*[Symbol.iterator](){let a=this._first;for(;a!==aZ.Undefined;)yield a.element,a=a.next}},a_=globalThis.performance&&"function"==typeof globalThis.performance.now,a0=class a{static create(b){return new a(b)}constructor(a){this._now=a_&&!1===a?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 -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(a=>{function b(a){}function c(a){return(b,c=null,d)=>{let e=!1,f;return f=a(a=>{if(!e)return f?f.dispose():e=!0,b.call(c,a)},null,d),e&&f.dispose(),f}}function d(a,b,c){return f((c,d=null,e)=>a(a=>c.call(d,b(a)),null,e),c)}function e(a,b,c){return f((c,d=null,e)=>a(a=>b(a)&&c.call(d,a),null,e),c)}function f(a,c){let d,e={onWillAddFirstListener(){d=a(f.fire,f)},onDidRemoveLastListener(){d?.dispose()}};c||b(e);let f=new bd(e);return c?.add(f),f.event}function g(a,c,d=100,e=!1,f=!1,h,i){let j,k,l,m=0,n,o={leakWarningThreshold:h,onWillAddFirstListener(){j=a(a=>{m++,k=c(k,a),e&&!l&&(p.fire(k),k=void 0),n=()=>{let a=k;k=void 0,l=void 0,(!e||m>1)&&p.fire(a),m=0},"number"==typeof d?(clearTimeout(l),l=setTimeout(n,d)):void 0===l&&(l=0,queueMicrotask(n))})},onWillRemoveListener(){f&&m>0&&n?.()},onDidRemoveLastListener(){n=void 0,j.dispose()}};i||b(o);let p=new bd(o);return i?.add(p),p.event}a.None=()=>aW.None,a.defer=function(a,b){return g(a,()=>{},0,void 0,!0,void 0,b)},a.once=c,a.map=d,a.forEach=function(a,b,c){return f((c,d=null,e)=>a(a=>{b(a),c.call(d,a)},null,e),c)},a.filter=e,a.signal=function(a){return a},a.any=function(...a){return(b,c=null,d)=>{var e,f;return e=function(...a){let b=aT(()=>aS(a));return b}(...a.map(a=>a(a=>b.call(c,a)))),(f=d)instanceof Array?f.push(e):f&&f.add(e),e}},a.reduce=function(a,b,c,e){let f=c;return d(a,a=>f=b(f,a),e)},a.debounce=g,a.accumulate=function(b,c=0,d){return a.debounce(b,(a,b)=>a?(a.push(b),a):[b],c,void 0,!0,void 0,d)},a.latch=function(a,b=(a,b)=>a===b,c){let d=!0,f;return e(a,a=>{let c=d||!b(a,f);return d=!1,f=a,c},c)},a.split=function(b,c,d){return[a.filter(b,c,d),a.filter(b,a=>!c(a),d)]},a.buffer=function(a,b=!1,c=[],d){let e=c.slice(),f=a(a=>{e?e.push(a):h.fire(a)});d&&d.add(f);let g=()=>{e?.forEach(a=>h.fire(a)),e=null},h=new bd({onWillAddFirstListener(){f||(f=a(a=>h.fire(a)),d&&d.add(f))},onDidAddFirstListener(){e&&(b?setTimeout(g):g())},onDidRemoveLastListener(){f&&f.dispose(),f=null}});return d&&d.add(h),h.event},a.chain=function(a,b){return(c,d,e)=>{let f=b(new i);return a(function(a){let b=f.evaluate(a);b!==h&&c.call(d,b)},void 0,e)}};let h=Symbol("HaltChainable");class i{constructor(){this.steps=[]}map(a){return this.steps.push(a),this}forEach(a){return this.steps.push(b=>(a(b),b)),this}filter(a){return this.steps.push(b=>a(b)?b:h),this}reduce(a,b){let c=b;return this.steps.push(b=>c=a(c,b)),this}latch(a=(a,b)=>a===b){let b=!0,c;return this.steps.push(d=>{let e=b||!a(d,c);return b=!1,c=d,e?d:h}),this}evaluate(a){for(let b of this.steps)if((a=b(a))===h)break;return a}}a.fromNodeEventEmitter=function(a,b,c=a=>a){let d=(...a)=>e.fire(c(...a)),e=new bd({onWillAddFirstListener:()=>a.on(b,d),onDidRemoveLastListener:()=>a.removeListener(b,d)});return e.event},a.fromDOMEventEmitter=function(a,b,c=a=>a){let d=(...a)=>e.fire(c(...a)),e=new bd({onWillAddFirstListener:()=>a.addEventListener(b,d),onDidRemoveLastListener:()=>a.removeEventListener(b,d)});return e.event},a.toPromise=function(a){return new Promise(b=>c(a)(b))},a.fromPromise=function(a){let b=new bd;return a.then(a=>{b.fire(a)},()=>{b.fire(void 0)}).finally(()=>{b.dispose()}),b.event},a.forward=function(a,b){return a(a=>b.fire(a))},a.runAndSubscribe=function(a,b,c){return b(c),a(a=>b(a))};class j{constructor(a,c){this._observable=a,this._counter=0,this._hasChanged=!1;let d={onWillAddFirstListener:()=>{a.addObserver(this)},onDidRemoveLastListener:()=>{a.removeObserver(this)}};c||b(d),this.emitter=new bd(d),c&&c.add(this.emitter)}beginUpdate(a){this._counter++}handlePossibleChange(a){}handleChange(a,b){this._hasChanged=!0}endUpdate(a){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}a.fromObservable=function(a,b){return new j(a,b).emitter.event},a.fromObservableLight=function(a){return(b,c,d)=>{let e=0,f=!1,g={beginUpdate(){e++},endUpdate(){0==--e&&(a.reportChanges(),f&&(f=!1,b.call(c)))},handlePossibleChange(){},handleChange(){f=!0}};a.addObserver(g),a.reportChanges();let h={dispose(){a.removeObserver(g)}};return d instanceof aV?d.add(h):Array.isArray(d)&&d.push(h),h}}})(a6||={});var a1=class a{constructor(b){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${b}_${a._idPool++}`,a.all.add(this)}start(a){this._stopWatch=new a0,this.listenerCount=a}stop(){if(this._stopWatch){let a=this._stopWatch.elapsed();this.durations.push(a),this.elapsedOverall+=a,this.invocationCount+=1,this._stopWatch=void 0}}};a1.all=new Set,a1._idPool=0;var a2=class a{constructor(b,c,d=(a._idPool++).toString(16).padStart(3,"0")){this._errorHandler=b,this.threshold=c,this.name=d,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(a,b){let c=this.threshold;if(c<=0||b<c)return;this._stacks||(this._stacks=new Map);let d=this._stacks.get(a.value)||0;if(this._stacks.set(a.value,d+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*c;let[a,d]=this.getMostFrequentStack(),e=`[${this.name}] potential listener LEAK detected, having ${b} listeners already. MOST frequent listener (${d}):`;console.warn(e),console.warn(a);let f=new a9(e,a);this._errorHandler(f)}return()=>{let b=this._stacks.get(a.value)||0;this._stacks.set(a.value,b-1)}}getMostFrequentStack(){if(!this._stacks)return;let a,b=0;for(let[c,d]of this._stacks)(!a||b<d)&&(a=[c,d],b=d);return a}};a2._idPool=1;var a3,a4,a5,a6,a7,a8=class a{constructor(a){this.value=a}static create(){return new a(Error().stack??"")}print(){console.warn(this.value.split(`
10
+ `+a.stack):a},0)}}addListener(a){return this.listeners.push(a),()=>{this._removeListener(a)}}emit(a){this.listeners.forEach(b=>{b(a)})}_removeListener(a){this.listeners.splice(this.listeners.indexOf(a),1)}setUnexpectedErrorHandler(a){this.unexpectedErrorHandler=a}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(a){this.unexpectedErrorHandler(a),this.emit(a)}onUnexpectedExternalError(a){this.unexpectedErrorHandler(a)}};function aR(a){var b;(b=a)instanceof aT||b instanceof Error&&b.name===aS&&b.message===aS||aQ.onUnexpectedError(a)}var aS="Canceled",aT=class extends Error{constructor(){super(aS),this.name=this.message}},aU=class a extends Error{constructor(a){super(a),this.name="CodeExpectedError"}static fromError(b){if(b instanceof a)return b;let c=new a;return c.message=b.message,c.stack=b.stack,c}static isErrorNoTelemetry(a){return"CodeExpectedError"===a.name}},aV=class a extends Error{constructor(b){super(b||"An unexpected bug occurred."),Object.setPrototypeOf(this,a.prototype)}};function aW(a,b=0){return a[a.length-(1+b)]}(bb=bc||={}).isLessThan=function(a){return a<0},bb.isLessThanOrEqual=function(a){return a<=0},bb.isGreaterThan=function(a){return a>0},bb.isNeitherLessOrGreaterThan=function(a){return 0===a},bb.greaterThan=1,bb.lessThan=-1,bb.neitherLessOrGreaterThan=0;var aX=class a{constructor(a){this.iterate=a}forEach(a){this.iterate(b=>(a(b),!0))}toArray(){let a=[];return this.iterate(b=>(a.push(b),!0)),a}filter(b){return new a(a=>this.iterate(c=>!b(c)||a(c)))}map(b){return new a(a=>this.iterate(c=>a(b(c))))}some(a){let b=!1;return this.iterate(c=>!(b=a(c))),b}findFirst(a){let b;return this.iterate(c=>!a(c)||(b=c,!1)),b}findLast(a){let b;return this.iterate(c=>(a(c)&&(b=c),!0)),b}findLastMaxBy(a){let b,c=!0;return this.iterate(d=>((c||bc.isGreaterThan(a(d,b)))&&(c=!1,b=d),!0)),b}};aX.empty=new aX(a=>{});function aY(a){}function aZ(a,b){}function a$(a){if(bd.is(a)){let b=[];for(let c of a)if(c)try{c.dispose()}catch(a){b.push(a)}if(1===b.length)throw b[0];if(b.length>1)throw AggregateError(b,"Encountered errors while disposing of store");return Array.isArray(a)?[]:a}if(a)return a.dispose(),a}function a_(a){let b={dispose:function(a,b){let c=this,d=!1,e;return function(){if(d)return e;if(d=!0,b)try{e=a.apply(c,arguments)}finally{b()}else e=a.apply(c,arguments);return e}}(()=>{aY(b),a()})};return b}(a=>{function b(a){return a&&"object"==typeof a&&"function"==typeof a[Symbol.iterator]}a.is=b;let c=Object.freeze([]);function*d(a){yield a}a.empty=function(){return c},a.single=d,a.wrap=function(a){return b(a)?a:d(a)},a.from=function(a){return a||c},a.reverse=function*(a){for(let b=a.length-1;b>=0;b--)yield a[b]},a.isEmpty=function(a){return!a||!0===a[Symbol.iterator]().next().done},a.first=function(a){return a[Symbol.iterator]().next().value},a.some=function(a,b){let c=0;for(let d of a)if(b(d,c++))return!0;return!1},a.find=function(a,b){for(let c of a)if(b(c))return c},a.filter=function*(a,b){for(let c of a)b(c)&&(yield c)},a.map=function*(a,b){let c=0;for(let d of a)yield b(d,c++)},a.flatMap=function*(a,b){let c=0;for(let d of a)yield*b(d,c++)},a.concat=function*(...a){for(let b of a)yield*b},a.reduce=function(a,b,c){let d=c;for(let c of a)d=b(d,c);return d},a.slice=function*(a,b,c=a.length){for(b<0&&(b+=a.length),c<0?c+=a.length:c>a.length&&(c=a.length);b<c;b++)yield a[b]},a.consume=function(b,c=1/0){let d=[];if(0===c)return[d,b];let e=b[Symbol.iterator]();for(let b=0;b<c;b++){let b=e.next();if(b.done)return[d,a.empty()];d.push(b.value)}return[d,{[Symbol.iterator]:()=>e}]},a.asyncToArray=async function(a){let b=[];for await(let c of a)b.push(c);return Promise.resolve(b)}})(bd||={});var a0=class a{constructor(){var a;this._toDispose=new Set,this._isDisposed=!1,a=this}dispose(){this._isDisposed||(aY(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{a$(this._toDispose)}finally{this._toDispose.clear()}}add(b){if(!b)return b;if(b===this)throw Error("Cannot register a disposable on itself!");return aZ(b,this),this._isDisposed?a.DISABLE_DISPOSED_WARNING||console.warn(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(b),b}delete(a){if(a){if(a===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(a),a.dispose()}}deleteAndLeak(a){a&&this._toDispose.has(a)&&(this._toDispose.delete(a),aZ(a,null))}};a0.DISABLE_DISPOSED_WARNING=!1;var a1=a0,a2=class{constructor(){var a;this._store=new a1,a=this,aZ(this._store,this)}dispose(){aY(this),this._store.dispose()}_register(a){if(a===this)throw Error("Cannot register a disposable on itself!");return this._store.add(a)}};a2.None=Object.freeze({dispose(){}});var a3=class{constructor(){var a;this._isDisposed=!1,a=this}get value(){return this._isDisposed?void 0:this._value}set value(a){this._isDisposed||a===this._value||(this._value?.dispose(),a&&aZ(a,this),this._value=a)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,aY(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let a=this._value;return this._value=void 0,a&&aZ(a,null),a}},a4=globalThis,a5=class a{constructor(b){this.element=b,this.next=a.Undefined,this.prev=a.Undefined}};a5.Undefined=new a5(void 0);var a6=class{constructor(){this._first=a5.Undefined,this._last=a5.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===a5.Undefined}clear(){let a=this._first;for(;a!==a5.Undefined;){let b=a.next;a.prev=a5.Undefined,a.next=a5.Undefined,a=b}this._first=a5.Undefined,this._last=a5.Undefined,this._size=0}unshift(a){return this._insert(a,!1)}push(a){return this._insert(a,!0)}_insert(a,b){let c=new a5(a);if(this._first===a5.Undefined)this._first=c,this._last=c;else if(b){let a=this._last;this._last=c,c.prev=a,a.next=c}else{let a=this._first;this._first=c,c.next=a,a.prev=c}this._size+=1;let d=!1;return()=>{d||(d=!0,this._remove(c))}}shift(){if(this._first!==a5.Undefined){let a=this._first.element;return this._remove(this._first),a}}pop(){if(this._last!==a5.Undefined){let a=this._last.element;return this._remove(this._last),a}}_remove(a){if(a.prev!==a5.Undefined&&a.next!==a5.Undefined){let b=a.prev;b.next=a.next,a.next.prev=b}else a.prev===a5.Undefined&&a.next===a5.Undefined?(this._first=a5.Undefined,this._last=a5.Undefined):a.next===a5.Undefined?(this._last=this._last.prev,this._last.next=a5.Undefined):a.prev===a5.Undefined&&(this._first=this._first.next,this._first.prev=a5.Undefined);this._size-=1}*[Symbol.iterator](){let a=this._first;for(;a!==a5.Undefined;)yield a.element,a=a.next}},a7=globalThis.performance&&"function"==typeof globalThis.performance.now,a8=class a{static create(b){return new a(b)}constructor(a){this._now=a7&&!1===a?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 -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(a=>{function b(a){}function c(a){return(b,c=null,d)=>{let e=!1,f;return f=a(a=>{if(!e)return f?f.dispose():e=!0,b.call(c,a)},null,d),e&&f.dispose(),f}}function d(a,b,c){return f((c,d=null,e)=>a(a=>c.call(d,b(a)),null,e),c)}function e(a,b,c){return f((c,d=null,e)=>a(a=>b(a)&&c.call(d,a),null,e),c)}function f(a,c){let d,e={onWillAddFirstListener(){d=a(f.fire,f)},onDidRemoveLastListener(){d?.dispose()}};c||b(e);let f=new bl(e);return c?.add(f),f.event}function g(a,c,d=100,e=!1,f=!1,h,i){let j,k,l,m=0,n,o={leakWarningThreshold:h,onWillAddFirstListener(){j=a(a=>{m++,k=c(k,a),e&&!l&&(p.fire(k),k=void 0),n=()=>{let a=k;k=void 0,l=void 0,(!e||m>1)&&p.fire(a),m=0},"number"==typeof d?(clearTimeout(l),l=setTimeout(n,d)):void 0===l&&(l=0,queueMicrotask(n))})},onWillRemoveListener(){f&&m>0&&n?.()},onDidRemoveLastListener(){n=void 0,j.dispose()}};i||b(o);let p=new bl(o);return i?.add(p),p.event}a.None=()=>a2.None,a.defer=function(a,b){return g(a,()=>{},0,void 0,!0,void 0,b)},a.once=c,a.map=d,a.forEach=function(a,b,c){return f((c,d=null,e)=>a(a=>{b(a),c.call(d,a)},null,e),c)},a.filter=e,a.signal=function(a){return a},a.any=function(...a){return(b,c=null,d)=>{var e,f;return e=function(...a){let b=a_(()=>a$(a));return b}(...a.map(a=>a(a=>b.call(c,a)))),(f=d)instanceof Array?f.push(e):f&&f.add(e),e}},a.reduce=function(a,b,c,e){let f=c;return d(a,a=>f=b(f,a),e)},a.debounce=g,a.accumulate=function(b,c=0,d){return a.debounce(b,(a,b)=>a?(a.push(b),a):[b],c,void 0,!0,void 0,d)},a.latch=function(a,b=(a,b)=>a===b,c){let d=!0,f;return e(a,a=>{let c=d||!b(a,f);return d=!1,f=a,c},c)},a.split=function(b,c,d){return[a.filter(b,c,d),a.filter(b,a=>!c(a),d)]},a.buffer=function(a,b=!1,c=[],d){let e=c.slice(),f=a(a=>{e?e.push(a):h.fire(a)});d&&d.add(f);let g=()=>{e?.forEach(a=>h.fire(a)),e=null},h=new bl({onWillAddFirstListener(){f||(f=a(a=>h.fire(a)),d&&d.add(f))},onDidAddFirstListener(){e&&(b?setTimeout(g):g())},onDidRemoveLastListener(){f&&f.dispose(),f=null}});return d&&d.add(h),h.event},a.chain=function(a,b){return(c,d,e)=>{let f=b(new i);return a(function(a){let b=f.evaluate(a);b!==h&&c.call(d,b)},void 0,e)}};let h=Symbol("HaltChainable");class i{constructor(){this.steps=[]}map(a){return this.steps.push(a),this}forEach(a){return this.steps.push(b=>(a(b),b)),this}filter(a){return this.steps.push(b=>a(b)?b:h),this}reduce(a,b){let c=b;return this.steps.push(b=>c=a(c,b)),this}latch(a=(a,b)=>a===b){let b=!0,c;return this.steps.push(d=>{let e=b||!a(d,c);return b=!1,c=d,e?d:h}),this}evaluate(a){for(let b of this.steps)if((a=b(a))===h)break;return a}}a.fromNodeEventEmitter=function(a,b,c=a=>a){let d=(...a)=>e.fire(c(...a)),e=new bl({onWillAddFirstListener:()=>a.on(b,d),onDidRemoveLastListener:()=>a.removeListener(b,d)});return e.event},a.fromDOMEventEmitter=function(a,b,c=a=>a){let d=(...a)=>e.fire(c(...a)),e=new bl({onWillAddFirstListener:()=>a.addEventListener(b,d),onDidRemoveLastListener:()=>a.removeEventListener(b,d)});return e.event},a.toPromise=function(a){return new Promise(b=>c(a)(b))},a.fromPromise=function(a){let b=new bl;return a.then(a=>{b.fire(a)},()=>{b.fire(void 0)}).finally(()=>{b.dispose()}),b.event},a.forward=function(a,b){return a(a=>b.fire(a))},a.runAndSubscribe=function(a,b,c){return b(c),a(a=>b(a))};class j{constructor(a,c){this._observable=a,this._counter=0,this._hasChanged=!1;let d={onWillAddFirstListener:()=>{a.addObserver(this)},onDidRemoveLastListener:()=>{a.removeObserver(this)}};c||b(d),this.emitter=new bl(d),c&&c.add(this.emitter)}beginUpdate(a){this._counter++}handlePossibleChange(a){}handleChange(a,b){this._hasChanged=!0}endUpdate(a){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}a.fromObservable=function(a,b){return new j(a,b).emitter.event},a.fromObservableLight=function(a){return(b,c,d)=>{let e=0,f=!1,g={beginUpdate(){e++},endUpdate(){0==--e&&(a.reportChanges(),f&&(f=!1,b.call(c)))},handlePossibleChange(){},handleChange(){f=!0}};a.addObserver(g),a.reportChanges();let h={dispose(){a.removeObserver(g)}};return d instanceof a1?d.add(h):Array.isArray(d)&&d.push(h),h}}})(be||={});var a9=class a{constructor(b){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${b}_${a._idPool++}`,a.all.add(this)}start(a){this._stopWatch=new a8,this.listenerCount=a}stop(){if(this._stopWatch){let a=this._stopWatch.elapsed();this.durations.push(a),this.elapsedOverall+=a,this.invocationCount+=1,this._stopWatch=void 0}}};a9.all=new Set,a9._idPool=0;var ba=class a{constructor(b,c,d=(a._idPool++).toString(16).padStart(3,"0")){this._errorHandler=b,this.threshold=c,this.name=d,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(a,b){let c=this.threshold;if(c<=0||b<c)return;this._stacks||(this._stacks=new Map);let d=this._stacks.get(a.value)||0;if(this._stacks.set(a.value,d+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*c;let[a,d]=this.getMostFrequentStack(),e=`[${this.name}] potential listener LEAK detected, having ${b} listeners already. MOST frequent listener (${d}):`;console.warn(e),console.warn(a);let f=new bh(e,a);this._errorHandler(f)}return()=>{let b=this._stacks.get(a.value)||0;this._stacks.set(a.value,b-1)}}getMostFrequentStack(){if(!this._stacks)return;let a,b=0;for(let[c,d]of this._stacks)(!a||b<d)&&(a=[c,d],b=d);return a}};ba._idPool=1;var bb,bc,bd,be,bf,bg=class a{constructor(a){this.value=a}static create(){return new a(Error().stack??"")}print(){console.warn(this.value.split(`
11
11
  `).slice(2).join(`
12
- `))}},a9=class extends Error{constructor(a,b){super(a),this.name="ListenerLeakError",this.stack=b}},ba=class extends Error{constructor(a,b){super(a),this.name="ListenerRefusalError",this.stack=b}},bb=0,bc=class{constructor(a){this.value=a,this.id=bb++}},bd=class{constructor(a){this._size=0,this._options=a,this._leakageMon=this._options?.leakWarningThreshold?new a2(a?.onListenerError??aJ,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new a1(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(a,b,c)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new ba(`${a}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(this._options?.onListenerError||aJ)(c),aW.None}if(this._disposed)return aW.None;b&&(a=a.bind(b));let d=new bc(a),e;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(d.stack=a8.create(),e=this._leakageMon.check(d.stack,this._size+1)),this._listeners?this._listeners instanceof bc?(this._deliveryQueue??=new be,this._listeners=[this._listeners,d]):this._listeners.push(d):(this._options?.onWillAddFirstListener?.(this),this._listeners=d,this._options?.onDidAddFirstListener?.(this)),this._size++;let f=aT(()=>{a7?.unregister(f),e?.(),this._removeListener(d)});if(c instanceof aV?c.add(f):Array.isArray(c)&&c.push(f),a7){let a=Error().stack.split(`
12
+ `))}},bh=class extends Error{constructor(a,b){super(a),this.name="ListenerLeakError",this.stack=b}},bi=class extends Error{constructor(a,b){super(a),this.name="ListenerRefusalError",this.stack=b}},bj=0,bk=class{constructor(a){this.value=a,this.id=bj++}},bl=class{constructor(a){this._size=0,this._options=a,this._leakageMon=this._options?.leakWarningThreshold?new ba(a?.onListenerError??aR,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new a9(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(a,b,c)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new bi(`${a}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(this._options?.onListenerError||aR)(c),a2.None}if(this._disposed)return a2.None;b&&(a=a.bind(b));let d=new bk(a),e;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(d.stack=bg.create(),e=this._leakageMon.check(d.stack,this._size+1)),this._listeners?this._listeners instanceof bk?(this._deliveryQueue??=new bm,this._listeners=[this._listeners,d]):this._listeners.push(d):(this._options?.onWillAddFirstListener?.(this),this._listeners=d,this._options?.onDidAddFirstListener?.(this)),this._size++;let f=a_(()=>{bf?.unregister(f),e?.(),this._removeListener(d)});if(c instanceof a1?c.add(f):Array.isArray(c)&&c.push(f),bf){let a=Error().stack.split(`
13
13
  `).slice(2,3).join(`
14
- `).trim(),b=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);a7.register(f,b?.[2]??a,f)}return f},this._event}_removeListener(a){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let b=this._listeners,c=b.indexOf(a);if(-1===c)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,b[c]=void 0;let d=this._deliveryQueue.current===this;if(2*this._size<=b.length){let a=0;for(let c=0;c<b.length;c++)b[c]?b[a++]=b[c]:d&&(this._deliveryQueue.end--,a<this._deliveryQueue.i&&this._deliveryQueue.i--);b.length=a}}_deliver(a,b){if(!a)return;let c=this._options?.onListenerError||aJ;try{a.value(b)}catch(a){c(a)}}_deliverQueue(a){let b=a.current._listeners;for(;a.i<a.end;)this._deliver(b[a.i++],a.value);a.reset()}fire(a){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof bc)this._deliver(this._listeners,a);else{let b=this._deliveryQueue;b.enqueue(this,a,this._listeners.length),this._deliverQueue(b)}this._perfMon?.stop()}hasListeners(){return this._size>0}},be=class{constructor(){this.i=-1,this.end=0}enqueue(a,b,c){this.i=0,this.end=c,this.current=a,this.value=b}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},bf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new bd,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new bd,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(a){return this.mapWindowIdToZoomLevel.get(this.getWindowId(a))??0}setZoomLevel(a,b){if(this.getZoomLevel(b)===a)return;let c=this.getWindowId(b);this.mapWindowIdToZoomLevel.set(c,a),this._onDidChangeZoomLevel.fire(c)}getZoomFactor(a){return this.mapWindowIdToZoomFactor.get(this.getWindowId(a))??1}setZoomFactor(a,b){this.mapWindowIdToZoomFactor.set(this.getWindowId(b),a)}setFullscreen(a,b){if(this.isFullscreen(b)===a)return;let c=this.getWindowId(b);this.mapWindowIdToFullScreen.set(c,a),this._onDidChangeFullscreen.fire(c)}isFullscreen(a){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(a))}getWindowId(a){return a.vscodeWindowId}};bf.INSTANCE=new bf,bf.INSTANCE.onDidChangeZoomLevel,bf.INSTANCE.onDidChangeFullscreen;var bg="object"==typeof navigator?navigator.userAgent:"",bh=bg.indexOf("Firefox")>=0,bi=bg.indexOf("AppleWebKit")>=0,bj=bg.indexOf("Chrome")>=0,bk=!bj&&bg.indexOf("Safari")>=0;bg.indexOf("Electron/"),bg.indexOf("Android");var bl=!1;if("function"==typeof aY.matchMedia){let a=aY.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),b=aY.matchMedia("(display-mode: fullscreen)");bl=a.matches,bm=a,"string"==typeof bm&&(bm=aY.matchMedia(bm)),bm.addEventListener("change",({matches:a})=>{bl&&b.matches||(bl=a)})}var bm,bn,bo,bp=!1,bq=!1,br=!1,bs=!1,bt=!1,bu="en",bv=globalThis;"u">typeof bv.vscode&&"u">typeof bv.vscode.process?bo=bv.vscode.process:"u">typeof process&&"string"==typeof process?.versions?.node&&(bo=process);var bw="string"==typeof bo?.versions?.electron&&bo?.type==="renderer";if("object"==typeof bo){bp="win32"===bo.platform,bq="darwin"===bo.platform,(br="linux"===bo.platform)&&bo.env.SNAP&&bo.env.SNAP_REVISION,bo.env.CI||bo.env.BUILD_ARTIFACTSTAGINGDIRECTORY,bu="en";let a=bo.env.VSCODE_NLS_CONFIG;if(a)try{let b=JSON.parse(a);b.userLocale,b.osLocale,bu=b.resolvedLanguage||"en",b.languagePack?.translationsConfigFile}catch{}bs=!0}else"object"!=typeof navigator||bw?console.error("Unable to resolve platform."):(bp=(bn=navigator.userAgent).indexOf("Windows")>=0,bq=bn.indexOf("Macintosh")>=0,(bn.indexOf("Macintosh")>=0||bn.indexOf("iPad")>=0||bn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,br=bn.indexOf("Linux")>=0,bn?.indexOf("Mobi"),bt=!0,bu=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var bx=bp,by=bq,bz=br,bA=bs;bt&&"function"==typeof bv.importScripts&&bv.origin;var bB,bC=bn,bD=bu;(bN=bB||={}).value=function(){return bD},bN.isDefaultVariant=function(){return 2===bD.length?"en"===bD:bD.length>=3&&"e"===bD[0]&&"n"===bD[1]&&"-"===bD[2]},bN.isDefault=function(){return"en"===bD};var bE="function"==typeof bv.postMessage&&!bv.importScripts,bF=(()=>{if(bE){let a=[];bv.addEventListener("message",b=>{if(b.data&&b.data.vscodeScheduleAsyncWork)for(let c=0,d=a.length;c<d;c++){let d=a[c];if(d.id===b.data.vscodeScheduleAsyncWork){a.splice(c,1),d.callback();return}}});let b=0;return c=>{let d=++b;a.push({id:d,callback:c}),bv.postMessage({vscodeScheduleAsyncWork:d},"*")}}return a=>setTimeout(a)})(),bG=!!(bC&&bC.indexOf("Chrome")>=0);bC&&bC.indexOf("Firefox"),!bG&&bC&&bC.indexOf("Safari"),bC&&bC.indexOf("Edg/"),bC&&bC.indexOf("Android");var bH="object"==typeof navigator?navigator:{};bA||document.queryCommandSupported&&document.queryCommandSupported("copy")||bH&&bH.clipboard&&bH.clipboard.writeText,bA||bH&&bH.clipboard&&bH.clipboard.readText,bA||bl||bH.keyboard,"ontouchstart"in aY||bH.maxTouchPoints,aY.PointerEvent&&("ontouchstart"in aY||navigator.maxTouchPoints);var bI=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(a,b){this._keyCodeToStr[a]=b,this._strToKeyCode[b.toLowerCase()]=a}keyCodeToStr(a){return this._keyCodeToStr[a]}strToKeyCode(a){return this._strToKeyCode[a.toLowerCase()]||0}},bJ=new bI,bK=new bI,bL=new bI,bM=Array(230);(bO=bP||={}).toString=function(a){return bJ.keyCodeToStr(a)},bO.fromString=function(a){return bJ.strToKeyCode(a)},bO.toUserSettingsUS=function(a){return bK.keyCodeToStr(a)},bO.toUserSettingsGeneral=function(a){return bL.keyCodeToStr(a)},bO.fromUserSettings=function(a){return bK.strToKeyCode(a)||bL.strToKeyCode(a)},bO.toElectronAccelerator=function(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return bJ.keyCodeToStr(a)};var bN,bO,bP,bQ,bR=class a{constructor(a,b,c,d,e){this.ctrlKey=a,this.shiftKey=b,this.altKey=c,this.metaKey=d,this.keyCode=e}equals(b){return b instanceof a&&this.ctrlKey===b.ctrlKey&&this.shiftKey===b.shiftKey&&this.altKey===b.altKey&&this.metaKey===b.metaKey&&this.keyCode===b.keyCode}getHashCode(){let a=this.ctrlKey?"1":"0",b=this.shiftKey?"1":"0",c=this.altKey?"1":"0",d=this.metaKey?"1":"0";return`K${a}${b}${c}${d}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new bS([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},bS=class{constructor(a){if(0===a.length)throw function(a){return a?Error(`Illegal argument: ${a}`):Error("Illegal argument")}("chords");this.chords=a}getHashCode(){let a="";for(let b=0,c=this.chords.length;b<c;b++)0!==b&&(a+=";"),a+=this.chords[b].getHashCode();return a}equals(a){if(null===a||this.chords.length!==a.chords.length)return!1;for(let b=0;b<this.chords.length;b++)if(!this.chords[b].equals(a.chords[b]))return!1;return!0}},bT=by?256:2048,bU=by?2048:256,bV=class{constructor(a){this._standardKeyboardEventBrand=!0,this.browserEvent=a,this.target=a.target,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.altKey=a.altKey,this.metaKey=a.metaKey,this.altGraphKey=a.getModifierState?.("AltGraph"),this.keyCode=function(a){if(a.charCode){let b=String.fromCharCode(a.charCode).toUpperCase();return bP.fromString(b)}let b=a.keyCode;if(3===b)return 7;if(bh)switch(b){case 59:return 85;case 60:if(bz)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(by)return 57}else if(bi&&(by&&93===b||!by&&92===b))return 57;return bM[b]||0}(a),this.code=a.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,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(a){return this._asKeybinding===a}_computeKeybinding(){let a=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(a=this.keyCode);let b=0;return this.ctrlKey&&(b|=bT),this.altKey&&(b|=512),this.shiftKey&&(b|=1024),this.metaKey&&(b|=bU),b|=a}_computeKeyCodeChord(){let a=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(a=this.keyCode),new bR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,a)}},bW=new WeakMap,bX=class{static getSameOriginWindowChain(a){let b=bW.get(a);if(!b){b=[],bW.set(a,b);let c=a,d;do(d=function(a){if(!a.parent||a.parent===a)return null;try{let b=a.location,c=a.parent.location;if("null"!==b.origin&&"null"!==c.origin&&b.origin!==c.origin)return null}catch{return null}return a.parent}(c))?b.push({window:new WeakRef(c),iframeElement:c.frameElement||null}):b.push({window:new WeakRef(c),iframeElement:null}),c=d;while(c)}return b.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(a,b){if(!b||a===b)return{top:0,left:0};let c=0,d=0;for(let e of this.getSameOriginWindowChain(a)){let a=e.window.deref();if(c+=a?.scrollY??0,d+=a?.scrollX??0,a===b||!e.iframeElement)break;let f=e.iframeElement.getBoundingClientRect();c+=f.top,d+=f.left}return{top:c,left:d}}},bY=class{constructor(a,b){this.timestamp=Date.now(),this.browserEvent=b,this.leftButton=0===b.button,this.middleButton=1===b.button,this.rightButton=2===b.button,this.buttons=b.buttons,this.target=b.target,this.detail=b.detail||1,"dblclick"===b.type&&(this.detail=2),this.ctrlKey=b.ctrlKey,this.shiftKey=b.shiftKey,this.altKey=b.altKey,this.metaKey=b.metaKey,"number"==typeof b.pageX?(this.posx=b.pageX,this.posy=b.pageY):(this.posx=b.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=b.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let c=bX.getPositionOfChildWindowRelativeToAncestorWindow(a,b.view);this.posx-=c.left,this.posy-=c.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},bZ=class{constructor(a,b=0,c=0){this.browserEvent=a||null,this.target=a?a.target||a.targetNode||a.srcElement:null,this.deltaY=c,this.deltaX=b;let d=!1;if(bj){let a=navigator.userAgent.match(/Chrome\/(\d+)/);d=(a?parseInt(a[1]):123)<=122}if(a){let b=a.view?.devicePixelRatio||1;"u">typeof a.wheelDeltaY?d?this.deltaY=a.wheelDeltaY/(120*b):this.deltaY=a.wheelDeltaY/120:"u">typeof a.VERTICAL_AXIS&&a.axis===a.VERTICAL_AXIS?this.deltaY=-a.detail/3:"wheel"===a.type&&(a.deltaMode===a.DOM_DELTA_LINE?bh&&!by?this.deltaY=-a.deltaY/3:this.deltaY=-a.deltaY:this.deltaY=-a.deltaY/40),"u">typeof a.wheelDeltaX?bk&&bx?this.deltaX=-(a.wheelDeltaX/120):d?this.deltaX=a.wheelDeltaX/(120*b):this.deltaX=a.wheelDeltaX/120:"u">typeof a.HORIZONTAL_AXIS&&a.axis===a.HORIZONTAL_AXIS?this.deltaX=-a.detail/3:"wheel"===a.type&&(a.deltaMode===a.DOM_DELTA_LINE?bh&&!by?this.deltaX=-a.deltaX/3:this.deltaX=-a.deltaX:this.deltaX=-a.deltaX/40),0===this.deltaY&&0===this.deltaX&&a.wheelDelta&&(d?this.deltaY=a.wheelDelta/(120*b):this.deltaY=a.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},b$=Object.freeze(function(a,b){let c=setTimeout(a.bind(b),0);return{dispose(){clearTimeout(c)}}});(cQ=bQ||={}).isCancellationToken=function(a){return a===cQ.None||a===cQ.Cancelled||a instanceof b_||!!a&&"object"==typeof a&&"boolean"==typeof a.isCancellationRequested&&"function"==typeof a.onCancellationRequested},cQ.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:a6.None}),cQ.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:b$});var b_=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?b$:(this._emitter||(this._emitter=new bd),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var b0=class{constructor(a,b){this._isDisposed=!1,this._token=-1,"function"==typeof a&&"number"==typeof b&&this.setIfNotSet(a,b)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(a,b){if(this._isDisposed)throw new aN("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,a()},b)}setIfNotSet(a,b){if(this._isDisposed)throw new aN("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,a()},b))}},b1=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(a,b,c=globalThis){if(this.isDisposed)throw new aN("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let d=c.setInterval(()=>{a()},b);this.disposable=aT(()=>{c.clearInterval(d),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(cR=cS||={}).settled=async function(a){let b,c=await Promise.all(a.map(a=>a.then(a=>a,a=>{b||(b=a)})));if("u">typeof b)throw b;return c},cR.withAsyncBody=function(a){return new Promise(async(b,c)=>{try{await a(b,c)}catch(a){c(a)}})};var b2=class a{static fromArray(b){return new a(a=>{a.emitMany(b)})}static fromPromise(b){return new a(async a=>{a.emitMany(await b)})}static fromPromises(b){return new a(async a=>{await Promise.all(b.map(async b=>a.emitOne(await b)))})}static merge(b){return new a(async a=>{await Promise.all(b.map(async b=>{for await(let c of b)a.emitOne(c)}))})}constructor(a,b){this._state=0,this._results=[],this._error=null,this._onReturn=b,this._onStateChanged=new bd,queueMicrotask(async()=>{let b={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(a(b)),this.resolve()}catch(a){this.reject(a)}finally{b.emitOne=void 0,b.emitMany=void 0,b.reject=void 0}})}[Symbol.asyncIterator](){let a=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(a<this._results.length)return{done:!1,value:this._results[a++]};if(1===this._state)return{done:!0,value:void 0};await a6.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(b,c){return new a(async a=>{for await(let d of b)a.emitOne(c(d))})}map(b){return a.map(this,b)}static filter(b,c){return new a(async a=>{for await(let d of b)c(d)&&a.emitOne(d)})}filter(b){return a.filter(this,b)}static coalesce(b){return a.filter(b,a=>!!a)}coalesce(){return a.coalesce(this)}static async toPromise(a){let b=[];for await(let c of a)b.push(c);return b}toPromise(){return a.toPromise(this)}emitOne(a){0===this._state&&(this._results.push(a),this._onStateChanged.fire())}emitMany(a){0===this._state&&(this._results=this._results.concat(a),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(a){0===this._state&&(this._state=2,this._error=a,this._onStateChanged.fire())}};b2.EMPTY=b2.fromArray([]);function b3(a,b){return(b<<5)-b+a|0}function b4(a,b){b=b3(149417,b);for(let c=0,d=a.length;c<d;c++)b=b3(a.charCodeAt(c),b);return b}new DataView(new ArrayBuffer(320));var{registerWindow:b5,getWindow:b6,getDocument:b7,getWindows:b8,getWindowsCount:b9,getWindowId:ca,getWindowById:cb,hasWindow:cc,onDidRegisterWindow:cd,onWillUnregisterWindow:ce,onDidUnregisterWindow:cf}=(b=new Map,c={window:aY,disposables:new aV},b.set(aY.vscodeWindowId,c),d=new bd,e=new bd,f=new bd,{onDidRegisterWindow:d.event,onWillUnregisterWindow:f.event,onDidUnregisterWindow:e.event,registerWindow(a){if(b.has(a.vscodeWindowId))return aW.None;let c=new aV,g={window:a,disposables:c.add(new aV)};return b.set(a.vscodeWindowId,g),c.add(aT(()=>{b.delete(a.vscodeWindowId),e.fire(a)})),c.add(ch(a,cm.BEFORE_UNLOAD,()=>{f.fire(a)})),d.fire(g),c},getWindows:()=>b.values(),getWindowsCount:()=>b.size,getWindowId:a=>a.vscodeWindowId,hasWindow:a=>b.has(a),getWindowById:function(a,d){return("number"==typeof a?b.get(a):void 0)??(d?c:void 0)},getWindow:a=>a?.ownerDocument?.defaultView?a.ownerDocument.defaultView.window:a?.view?a.view.window:aY,getDocument:a=>b6(a).document}),cg=class{constructor(a,b,c,d){this._node=a,this._type=b,this._handler=c,this._options=d||!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 ch(a,b,c,d){return new cg(a,b,c,d)}var ci=function(a,b,c,d){var e;let f=c;return"click"===b||"mousedown"===b||"contextmenu"===b?(e=b6(a),f=function(a){return c(new bY(e,a))}):("keydown"===b||"keypress"===b||"keyup"===b)&&(f=function(a){return c(new bV(a))}),ch(a,b,f,d)},cj=class extends b1{constructor(a){super(),this.defaultTarget=a&&b6(a)}cancelAndSet(a,b,c){return super.cancelAndSet(a,b,c??this.defaultTarget)}},ck=class{constructor(a,b=0){this._runner=a,this.priority=b,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(a){aJ(a)}}static sort(a,b){return b.priority-a.priority}};g=new Map,h=new Map,i=new Map,j=new Map,cT=(a,b,c=0)=>{let d=ca(a),e=new ck(b,c),f=g.get(d);return f||(f=[],g.set(d,f)),f.push(e),i.get(d)||(i.set(d,!0),a.requestAnimationFrame(()=>(a=>{i.set(a,!1);let b=g.get(a)??[];for(h.set(a,b),g.set(a,[]),j.set(a,!0);b.length>0;)b.sort(ck.sort),b.shift().execute();j.set(a,!1)})(d))),e};var cl=class a{constructor(a,b){this.width=a,this.height=b}with(b=this.width,c=this.height){return b!==this.width||c!==this.height?new a(b,c):this}static is(a){return"object"==typeof a&&"number"==typeof a.height&&"number"==typeof a.width}static lift(b){return b instanceof a?b:new a(b.width,b.height)}static equals(a,b){return a===b||!!a&&!!b&&a.width===b.width&&a.height===b.height}};cl.None=new cl(0,0),new class{constructor(){this.mutationObservers=new Map}observe(a,b,c){let d=this.mutationObservers.get(a);d||(d=new Map,this.mutationObservers.set(a,d));let e=function a(b,c){switch(typeof b){case"object":var d,e,f,g;return null===b?b3(349,c):Array.isArray(b)?(d=b,e=b3(104579,e=c),d.reduce((b,c)=>a(c,b),e)):(f=b,g=b3(181387,g=c),Object.keys(f).sort().reduce((b,c)=>(b=b4(c,b),a(f[c],b)),g));case"string":return b4(b,c);case"boolean":return b3(b?433:863,c);case"number":return b3(b,c);case"undefined":return b3(937,c);default:return b3(617,c)}}(c,0),f=d.get(e);if(f)f.users+=1;else{let g=new bd,h=new MutationObserver(a=>g.fire(a));h.observe(a,c);let i=f={users:1,observer:h,onDidMutate:g.event};b.add(aT(()=>{i.users-=1,0===i.users&&(g.dispose(),h.disconnect(),d?.delete(e),d?.size===0&&this.mutationObservers.delete(a))})),d.set(e,f)}return f.onDidMutate}};var cm={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"},cn=class{constructor(a){this.domNode=a,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(a){let b=co(a);this._maxWidth!==b&&(this._maxWidth=b,this.domNode.style.maxWidth=this._maxWidth)}setWidth(a){let b=co(a);this._width!==b&&(this._width=b,this.domNode.style.width=this._width)}setHeight(a){let b=co(a);this._height!==b&&(this._height=b,this.domNode.style.height=this._height)}setTop(a){let b=co(a);this._top!==b&&(this._top=b,this.domNode.style.top=this._top)}setLeft(a){let b=co(a);this._left!==b&&(this._left=b,this.domNode.style.left=this._left)}setBottom(a){let b=co(a);this._bottom!==b&&(this._bottom=b,this.domNode.style.bottom=this._bottom)}setRight(a){let b=co(a);this._right!==b&&(this._right=b,this.domNode.style.right=this._right)}setPaddingTop(a){let b=co(a);this._paddingTop!==b&&(this._paddingTop=b,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(a){let b=co(a);this._paddingLeft!==b&&(this._paddingLeft=b,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(a){let b=co(a);this._paddingBottom!==b&&(this._paddingBottom=b,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(a){let b=co(a);this._paddingRight!==b&&(this._paddingRight=b,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(a){this._fontFamily!==a&&(this._fontFamily=a,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(a){this._fontWeight!==a&&(this._fontWeight=a,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(a){let b=co(a);this._fontSize!==b&&(this._fontSize=b,this.domNode.style.fontSize=this._fontSize)}setFontStyle(a){this._fontStyle!==a&&(this._fontStyle=a,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(a){this._fontFeatureSettings!==a&&(this._fontFeatureSettings=a,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(a){this._fontVariationSettings!==a&&(this._fontVariationSettings=a,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(a){this._textDecoration!==a&&(this._textDecoration=a,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(a){let b=co(a);this._lineHeight!==b&&(this._lineHeight=b,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(a){let b=co(a);this._letterSpacing!==b&&(this._letterSpacing=b,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(a){this._className!==a&&(this._className=a,this.domNode.className=this._className)}toggleClassName(a,b){this.domNode.classList.toggle(a,b),this._className=this.domNode.className}setDisplay(a){this._display!==a&&(this._display=a,this.domNode.style.display=this._display)}setPosition(a){this._position!==a&&(this._position=a,this.domNode.style.position=this._position)}setVisibility(a){this._visibility!==a&&(this._visibility=a,this.domNode.style.visibility=this._visibility)}setColor(a){this._color!==a&&(this._color=a,this.domNode.style.color=this._color)}setBackgroundColor(a){this._backgroundColor!==a&&(this._backgroundColor=a,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(a){this._layerHint!==a&&(this._layerHint=a,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(a){this._boxShadow!==a&&(this._boxShadow=a,this.domNode.style.boxShadow=a)}setContain(a){this._contain!==a&&(this._contain=a,this.domNode.style.contain=this._contain)}setAttribute(a,b){this.domNode.setAttribute(a,b)}removeAttribute(a){this.domNode.removeAttribute(a)}appendChild(a){this.domNode.appendChild(a.domNode)}removeChild(a){this.domNode.removeChild(a.domNode)}};function co(a){return"number"==typeof a?`${a}px`:a}function cp(a){return new cn(a)}var cq=class{constructor(){this._hooks=new aV,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(a,b){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let c=this._onStopCallback;this._onStopCallback=null,a&&c&&c(b)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(a,b,c,d,e){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=d,this._onStopCallback=e;let f=a;try{a.setPointerCapture(b),this._hooks.add(aT(()=>{try{a.releasePointerCapture(b)}catch{}}))}catch{f=b6(a)}this._hooks.add(ch(f,cm.POINTER_MOVE,a=>{a.buttons!==c?this.stopMonitoring(!0):(a.preventDefault(),this._pointerMoveCallback(a))})),this._hooks.add(ch(f,cm.POINTER_UP,a=>this.stopMonitoring(!0)))}};(k=cU||={}).Tap="-xterm-gesturetap",k.Change="-xterm-gesturechange",k.Start="-xterm-gesturestart",k.End="-xterm-gesturesend",k.Contextmenu="-xterm-gesturecontextmenu";var cr=class a extends aW{constructor(){super(),this.dispatched=!1,this.targets=new a$,this.ignoreTargets=new a$,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(a6.runAndSubscribe(cd,({window:a,disposables:b})=>{b.add(ch(a.document,"touchstart",a=>this.onTouchStart(a),{passive:!1})),b.add(ch(a.document,"touchend",b=>this.onTouchEnd(a,b))),b.add(ch(a.document,"touchmove",a=>this.onTouchMove(a),{passive:!1}))},{window:aY,disposables:this._store}))}static addTarget(b){return a.isTouchDevice()?(a.INSTANCE||(a.INSTANCE=new a),aT(a.INSTANCE.targets.push(b))):aW.None}static ignoreTarget(b){return a.isTouchDevice()?(a.INSTANCE||(a.INSTANCE=new a),aT(a.INSTANCE.ignoreTargets.push(b))):aW.None}static isTouchDevice(){return"ontouchstart"in aY||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(a){let b=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let c=0,d=a.targetTouches.length;c<d;c++){let d=a.targetTouches.item(c);this.activeTouches[d.identifier]={id:d.identifier,initialTarget:d.target,initialTimeStamp:b,initialPageX:d.pageX,initialPageY:d.pageY,rollingTimestamps:[b],rollingPageX:[d.pageX],rollingPageY:[d.pageY]};let e=this.newGestureEvent(cU.Start,d.target);e.pageX=d.pageX,e.pageY=d.pageY,this.dispatchEvent(e)}this.dispatched&&(a.preventDefault(),a.stopPropagation(),this.dispatched=!1)}onTouchEnd(b,c){let d=Date.now(),e=Object.keys(this.activeTouches).length;for(let f=0,g=c.changedTouches.length;f<g;f++){let g=c.changedTouches.item(f);if(!this.activeTouches.hasOwnProperty(String(g.identifier))){console.warn("move of an UNKNOWN touch",g);continue}let h=this.activeTouches[g.identifier],i=Date.now()-h.initialTimeStamp;if(i<a.HOLD_DELAY&&30>Math.abs(h.initialPageX-aO(h.rollingPageX))&&30>Math.abs(h.initialPageY-aO(h.rollingPageY))){let a=this.newGestureEvent(cU.Tap,h.initialTarget);a.pageX=aO(h.rollingPageX),a.pageY=aO(h.rollingPageY),this.dispatchEvent(a)}else if(i>=a.HOLD_DELAY&&30>Math.abs(h.initialPageX-aO(h.rollingPageX))&&30>Math.abs(h.initialPageY-aO(h.rollingPageY))){let a=this.newGestureEvent(cU.Contextmenu,h.initialTarget);a.pageX=aO(h.rollingPageX),a.pageY=aO(h.rollingPageY),this.dispatchEvent(a)}else if(1===e){let a=aO(h.rollingPageX),c=aO(h.rollingPageY),e=aO(h.rollingTimestamps)-h.rollingTimestamps[0],f=a-h.rollingPageX[0],g=c-h.rollingPageY[0],i=[...this.targets].filter(a=>h.initialTarget instanceof Node&&a.contains(h.initialTarget));this.inertia(b,i,d,Math.abs(f)/e,f>0?1:-1,a,Math.abs(g)/e,g>0?1:-1,c)}this.dispatchEvent(this.newGestureEvent(cU.End,h.initialTarget)),delete this.activeTouches[g.identifier]}this.dispatched&&(c.preventDefault(),c.stopPropagation(),this.dispatched=!1)}newGestureEvent(a,b){let c=document.createEvent("CustomEvent");return c.initEvent(a,!1,!0),c.initialTarget=b,c.tapCount=0,c}dispatchEvent(b){if(b.type===cU.Tap){let c=new Date().getTime(),d=0;d=c-this._lastSetTapCountTime>a.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=c,b.tapCount=d}else(b.type===cU.Change||b.type===cU.Contextmenu)&&(this._lastSetTapCountTime=0);if(b.initialTarget instanceof Node){for(let a of this.ignoreTargets)if(a.contains(b.initialTarget))return;let a=[];for(let c of this.targets)if(c.contains(b.initialTarget)){let d=0,e=b.initialTarget;for(;e&&e!==c;)d++,e=e.parentElement;a.push([d,c])}for(let[c,d]of(a.sort((a,b)=>a[0]-b[0]),a))d.dispatchEvent(b),this.dispatched=!0}}inertia(b,c,d,e,f,g,h,i,j){this.handle=cT(b,()=>{let k=Date.now(),l=k-d,m=0,n=0,o=!0;e+=a.SCROLL_FRICTION*l,h+=a.SCROLL_FRICTION*l,e>0&&(o=!1,m=f*e*l),h>0&&(o=!1,n=i*h*l);let p=this.newGestureEvent(cU.Change);p.translationX=m,p.translationY=n,c.forEach(a=>a.dispatchEvent(p)),o||this.inertia(b,c,k,e,f,g+m,h,i,j+n)})}onTouchMove(a){let b=Date.now();for(let c=0,d=a.changedTouches.length;c<d;c++){let d=a.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("end of an UNKNOWN touch",d);continue}let e=this.activeTouches[d.identifier],f=this.newGestureEvent(cU.Change,e.initialTarget);f.translationX=d.pageX-aO(e.rollingPageX),f.translationY=d.pageY-aO(e.rollingPageY),f.pageX=d.pageX,f.pageY=d.pageY,this.dispatchEvent(f),e.rollingPageX.length>3&&(e.rollingPageX.shift(),e.rollingPageY.shift(),e.rollingTimestamps.shift()),e.rollingPageX.push(d.pageX),e.rollingPageY.push(d.pageY),e.rollingTimestamps.push(b)}this.dispatched&&(a.preventDefault(),a.stopPropagation(),this.dispatched=!1)}};cr.SCROLL_FRICTION=-.005,cr.HOLD_DELAY=700,cr.CLEAR_TAP_COUNT_TIME=400,Z([function(a,b,c){let d=null,e=null;if("function"==typeof c.value?(d="value",0!==(e=c.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof c.get&&(d="get",e=c.get),!e)throw Error("not supported");let f=`$memoize$${b}`;c[d]=function(...a){return this.hasOwnProperty(f)||Object.defineProperty(this,f,{configurable:!1,enumerable:!1,writable:!1,value:e.apply(this,a)}),this[f]}}],cr,"isTouchDevice",1);var cs=class extends aW{onclick(a,b){this._register(ch(a,cm.CLICK,c=>b(new bY(b6(a),c))))}onmousedown(a,b){this._register(ch(a,cm.MOUSE_DOWN,c=>b(new bY(b6(a),c))))}onmouseover(a,b){this._register(ch(a,cm.MOUSE_OVER,c=>b(new bY(b6(a),c))))}onmouseleave(a,b){this._register(ch(a,cm.MOUSE_LEAVE,c=>b(new bY(b6(a),c))))}onkeydown(a,b){this._register(ch(a,cm.KEY_DOWN,a=>b(new bV(a))))}onkeyup(a,b){this._register(ch(a,cm.KEY_UP,a=>b(new bV(a))))}oninput(a,b){this._register(ch(a,cm.INPUT,b))}onblur(a,b){this._register(ch(a,cm.BLUR,b))}onfocus(a,b){this._register(ch(a,cm.FOCUS,b))}onchange(a,b){this._register(ch(a,cm.CHANGE,b))}ignoreGesture(a){return cr.ignoreTarget(a)}},ct=class extends cs{constructor(a){super(),this._onActivate=a.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=a.bgWidth+"px",this.bgDomNode.style.height=a.bgHeight+"px","u">typeof a.top&&(this.bgDomNode.style.top="0px"),"u">typeof a.left&&(this.bgDomNode.style.left="0px"),"u">typeof a.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof a.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=a.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof a.top&&(this.domNode.style.top=a.top+"px"),"u">typeof a.left&&(this.domNode.style.left=a.left+"px"),"u">typeof a.bottom&&(this.domNode.style.bottom=a.bottom+"px"),"u">typeof a.right&&(this.domNode.style.right=a.right+"px"),this._pointerMoveMonitor=this._register(new cq),this._register(ci(this.bgDomNode,cm.POINTER_DOWN,a=>this._arrowPointerDown(a))),this._register(ci(this.domNode,cm.POINTER_DOWN,a=>this._arrowPointerDown(a))),this._pointerdownRepeatTimer=this._register(new cj),this._pointerdownScheduleRepeatTimer=this._register(new b0)}_arrowPointerDown(a){if(!a.target||!(a.target instanceof Element))return;let b=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,b6(a))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(b,200),this._pointerMoveMonitor.startMonitoring(a.target,a.pointerId,a.buttons,a=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),a.preventDefault()}},cu=class a{constructor(a,b,c,d,e,f,g){this._forceIntegerValues=a,this._scrollStateBrand=void 0,this._forceIntegerValues&&(b|=0,c|=0,d|=0,e|=0,f|=0,g|=0),this.rawScrollLeft=d,this.rawScrollTop=g,b<0&&(b=0),d+b>c&&(d=c-b),d<0&&(d=0),e<0&&(e=0),g+e>f&&(g=f-e),g<0&&(g=0),this.width=b,this.scrollWidth=c,this.scrollLeft=d,this.height=e,this.scrollHeight=f,this.scrollTop=g}equals(a){return this.rawScrollLeft===a.rawScrollLeft&&this.rawScrollTop===a.rawScrollTop&&this.width===a.width&&this.scrollWidth===a.scrollWidth&&this.scrollLeft===a.scrollLeft&&this.height===a.height&&this.scrollHeight===a.scrollHeight&&this.scrollTop===a.scrollTop}withScrollDimensions(b,c){return new a(this._forceIntegerValues,"u">typeof b.width?b.width:this.width,"u">typeof b.scrollWidth?b.scrollWidth:this.scrollWidth,c?this.rawScrollLeft:this.scrollLeft,"u">typeof b.height?b.height:this.height,"u">typeof b.scrollHeight?b.scrollHeight:this.scrollHeight,c?this.rawScrollTop:this.scrollTop)}withScrollPosition(b){return new a(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof b.scrollLeft?b.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof b.scrollTop?b.scrollTop:this.rawScrollTop)}createScrollEvent(a,b){let c=this.width!==a.width,d=this.scrollWidth!==a.scrollWidth,e=this.scrollLeft!==a.scrollLeft,f=this.height!==a.height,g=this.scrollHeight!==a.scrollHeight,h=this.scrollTop!==a.scrollTop;return{inSmoothScrolling:b,oldWidth:a.width,oldScrollWidth:a.scrollWidth,oldScrollLeft:a.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:a.height,oldScrollHeight:a.scrollHeight,oldScrollTop:a.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:c,scrollWidthChanged:d,scrollLeftChanged:e,heightChanged:f,scrollHeightChanged:g,scrollTopChanged:h}}},cv=class extends aW{constructor(a){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new bd),this.onScroll=this._onScroll.event,this._smoothScrollDuration=a.smoothScrollDuration,this._scheduleAtNextAnimationFrame=a.scheduleAtNextAnimationFrame,this._state=new cu(a.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(a){this._smoothScrollDuration=a}validateScrollPosition(a){return this._state.withScrollPosition(a)}getScrollDimensions(){return this._state}setScrollDimensions(a,b){let c=this._state.withScrollDimensions(a,b);this._setState(c,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(a){let b=this._state.withScrollPosition(a);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(b,!1)}setScrollPositionSmooth(a,b){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(a);if(this._smoothScrolling){let c;a={scrollLeft:typeof a.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:a.scrollLeft,scrollTop:typeof a.scrollTop>"u"?this._smoothScrolling.to.scrollTop:a.scrollTop};let d=this._state.withScrollPosition(a);if(this._smoothScrolling.to.scrollLeft===d.scrollLeft&&this._smoothScrolling.to.scrollTop===d.scrollTop)return;c=b?new cy(this._smoothScrolling.from,d,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,d,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=c}else{let b=this._state.withScrollPosition(a);this._smoothScrolling=cy.start(this._state,b,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 a=this._smoothScrolling.tick(),b=this._state.withScrollPosition(a);if(this._setState(b,!0),this._smoothScrolling){if(a.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(a,b){let c=this._state;c.equals(a)||(this._state=a,this._onScroll.fire(this._state.createScrollEvent(c,b)))}},cw=class{constructor(a,b,c){this.scrollLeft=a,this.scrollTop=b,this.isDone=c}};function cx(a,b){let c=b-a;return function(b){return a+c*(1-Math.pow(1-b,3))}}var cy=class a{constructor(a,b,c,d){this.from=a,this.to=b,this.duration=d,this.startTime=c,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(a,b,c){if(Math.abs(a-b)>2.5*c){var d,e;let f,g;return a<b?(f=a+.75*c,g=b-.75*c):(f=a-.75*c,g=b+.75*c),d=cx(a,f),e=cx(g,b),function(a){return a<.33?d(a/.33):e((a-.33)/(1-.33))}}return cx(a,b)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(a){this.to=a.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(a){let b=(a-this.startTime)/this.duration;return b<1?new cw(this.scrollLeft(b),this.scrollTop(b),!1):new cw(this.to.scrollLeft,this.to.scrollTop,!0)}combine(b,c,d){return a.start(b,c,d)}static start(b,c,d){return d+=10,new a(b,c,Date.now()-10,d)}},cz=class extends aW{constructor(a,b,c){super(),this._visibility=a,this._visibleClassName=b,this._invisibleClassName=c,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new b0)}setVisibility(a){this._visibility!==a&&(this._visibility=a,this._updateShouldBeVisible())}setShouldBeVisible(a){this._rawShouldBeVisible=a,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let a=this._applyVisibilitySetting();this._shouldBeVisible!==a&&(this._shouldBeVisible=a,this.ensureVisibility())}setIsNeeded(a){this._isNeeded!==a&&(this._isNeeded=a,this.ensureVisibility())}setDomNode(a){this._domNode=a,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(a){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(a?" fade":"")))}},cA=class extends cs{constructor(a){super(),this._lazyRender=a.lazyRender,this._host=a.host,this._scrollable=a.scrollable,this._scrollByPage=a.scrollByPage,this._scrollbarState=a.scrollbarState,this._visibilityController=this._register(new cz(a.visibility,"visible scrollbar "+a.extraScrollbarClassName,"invisible scrollbar "+a.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new cq),this._shouldRender=!0,this.domNode=cp(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(ch(this.domNode.domNode,cm.POINTER_DOWN,a=>this._domNodePointerDown(a)))}_createArrow(a){let b=this._register(new ct(a));this.domNode.domNode.appendChild(b.bgDomNode),this.domNode.domNode.appendChild(b.domNode)}_createSlider(a,b,c,d){this.slider=cp(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(a),this.slider.setLeft(b),"number"==typeof c&&this.slider.setWidth(c),"number"==typeof d&&this.slider.setHeight(d),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ch(this.slider.domNode,cm.POINTER_DOWN,a=>{0===a.button&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(a){return this._scrollbarState.setVisibleSize(a)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(a){return this._scrollbarState.setScrollSize(a)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(a){return this._scrollbarState.setScrollPosition(a)&&(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(a){a.target===this.domNode.domNode&&this._onPointerDown(a)}delegatePointerDown(a){let b=this.domNode.domNode.getClientRects()[0].top,c=b+this._scrollbarState.getSliderPosition(),d=b+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),e=this._sliderPointerPosition(a);c<=e&&e<=d?0===a.button&&(a.preventDefault(),this._sliderPointerDown(a)):this._onPointerDown(a)}_onPointerDown(a){let b,c;if(a.target===this.domNode.domNode&&"number"==typeof a.offsetX&&"number"==typeof a.offsetY)b=a.offsetX,c=a.offsetY;else{var d;let e,f,g=(e=(d=this.domNode.domNode).getBoundingClientRect(),f=b6(d),{left:e.left+f.scrollX,top:e.top+f.scrollY,width:e.width,height:e.height});b=a.pageX-g.left,c=a.pageY-g.top}let e=this._pointerDownRelativePosition(b,c);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(e):this._scrollbarState.getDesiredScrollPositionFromOffset(e)),0===a.button&&(a.preventDefault(),this._sliderPointerDown(a))}_sliderPointerDown(a){if(!a.target||!(a.target instanceof Element))return;let b=this._sliderPointerPosition(a),c=this._sliderOrthogonalPointerPosition(a),d=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(a.target,a.pointerId,a.buttons,a=>{let e=Math.abs(this._sliderOrthogonalPointerPosition(a)-c);if(bx&&e>140)return void this._setDesiredScrollPositionNow(d.getScrollPosition());let f=this._sliderPointerPosition(a)-b;this._setDesiredScrollPositionNow(d.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(a){let b={};this.writeScrollPosition(b,a),this._scrollable.setScrollPositionNow(b)}updateScrollbarSize(a){this._updateScrollbarSize(a),this._scrollbarState.setScrollbarSize(a),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},cB=class a{constructor(a,b,c,d,e,f){this._scrollbarSize=Math.round(b),this._oppositeScrollbarSize=Math.round(c),this._arrowSize=Math.round(a),this._visibleSize=d,this._scrollSize=e,this._scrollPosition=f,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new a(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(a){let b=Math.round(a);return this._visibleSize!==b&&(this._visibleSize=b,this._refreshComputedValues(),!0)}setScrollSize(a){let b=Math.round(a);return this._scrollSize!==b&&(this._scrollSize=b,this._refreshComputedValues(),!0)}setScrollPosition(a){let b=Math.round(a);return this._scrollPosition!==b&&(this._scrollPosition=b,this._refreshComputedValues(),!0)}setScrollbarSize(a){this._scrollbarSize=Math.round(a)}setOppositeScrollbarSize(a){this._oppositeScrollbarSize=Math.round(a)}static _computeValues(a,b,c,d,e){let f=Math.max(0,c-a),g=Math.max(0,f-2*b),h=d>0&&d>c;if(!h)return{computedAvailableSize:Math.round(f),computedIsNeeded:h,computedSliderSize:Math.round(g),computedSliderRatio:0,computedSliderPosition:0};let i=Math.round(Math.max(20,Math.floor(c*g/d))),j=(g-i)/(d-c);return{computedAvailableSize:Math.round(f),computedIsNeeded:h,computedSliderSize:Math.round(i),computedSliderRatio:j,computedSliderPosition:Math.round(e*j)}}_refreshComputedValues(){let b=a._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=b.computedAvailableSize,this._computedIsNeeded=b.computedIsNeeded,this._computedSliderSize=b.computedSliderSize,this._computedSliderRatio=b.computedSliderRatio,this._computedSliderPosition=b.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(a){return this._computedIsNeeded?Math.round((a-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(a){if(!this._computedIsNeeded)return 0;let b=a-this._arrowSize,c=this._scrollPosition;return b<this._computedSliderPosition?c-=this._visibleSize:c+=this._visibleSize,c}getDesiredScrollPositionFromDelta(a){return this._computedIsNeeded?Math.round((this._computedSliderPosition+a)/this._computedSliderRatio):0}},cC=class extends cA{constructor(a,b,c){let d=a.getScrollDimensions(),e=a.getCurrentScrollPosition();if(super({lazyRender:b.lazyRender,host:c,scrollbarState:new cB(b.horizontalHasArrows?b.arrowSize:0,2===b.horizontal?0:b.horizontalScrollbarSize,2===b.vertical?0:b.verticalScrollbarSize,d.width,d.scrollWidth,e.scrollLeft),visibility:b.horizontal,extraScrollbarClassName:"horizontal",scrollable:a,scrollByPage:b.scrollByPage}),b.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((b.horizontalScrollbarSize-b.horizontalSliderSize)/2),0,void 0,b.horizontalSliderSize)}_updateSlider(a,b){this.slider.setWidth(a),this.slider.setLeft(b)}_renderDomNode(a,b){this.domNode.setWidth(a),this.domNode.setHeight(b),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(a){return this._shouldRender=this._onElementScrollSize(a.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(a.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(a.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(a,b){return a}_sliderPointerPosition(a){return a.pageX}_sliderOrthogonalPointerPosition(a){return a.pageY}_updateScrollbarSize(a){this.slider.setHeight(a)}writeScrollPosition(a,b){a.scrollLeft=b}updateOptions(a){this.updateScrollbarSize(2===a.horizontal?0:a.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===a.vertical?0:a.verticalScrollbarSize),this._visibilityController.setVisibility(a.horizontal),this._scrollByPage=a.scrollByPage}},cD=class extends cA{constructor(a,b,c){let d=a.getScrollDimensions(),e=a.getCurrentScrollPosition();if(super({lazyRender:b.lazyRender,host:c,scrollbarState:new cB(b.verticalHasArrows?b.arrowSize:0,2===b.vertical?0:b.verticalScrollbarSize,0,d.height,d.scrollHeight,e.scrollTop),visibility:b.vertical,extraScrollbarClassName:"vertical",scrollable:a,scrollByPage:b.scrollByPage}),b.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((b.verticalScrollbarSize-b.verticalSliderSize)/2),b.verticalSliderSize,void 0)}_updateSlider(a,b){this.slider.setHeight(a),this.slider.setTop(b)}_renderDomNode(a,b){this.domNode.setWidth(b),this.domNode.setHeight(a),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(a){return this._shouldRender=this._onElementScrollSize(a.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(a.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(a.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(a,b){return b}_sliderPointerPosition(a){return a.pageY}_sliderOrthogonalPointerPosition(a){return a.pageX}_updateScrollbarSize(a){this.slider.setWidth(a)}writeScrollPosition(a,b){a.scrollTop=b}updateOptions(a){this.updateScrollbarSize(2===a.vertical?0:a.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(a.vertical),this._scrollByPage=a.scrollByPage}},cE=class{constructor(a,b,c){this.timestamp=a,this.deltaX=b,this.deltaY=c,this.score=0}},cF=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let a=1,b=0,c=1,d=this._rear;for(;;){let e=d===this._front?a:Math.pow(2,-c);if(a-=e,b+=this._memory[d].score*e,d===this._front)break;d=(this._capacity+d-1)%this._capacity,c++}return b<=.5}acceptStandardWheelEvent(a){if(bj){var b;let c=(b=b6(a.browserEvent),bf.INSTANCE.getZoomFactor(b));this.accept(Date.now(),a.deltaX*c,a.deltaY*c)}else this.accept(Date.now(),a.deltaX,a.deltaY)}accept(a,b,c){let d=null,e=new cE(a,b,c);-1===this._front&&-1===this._rear?(this._memory[0]=e,this._front=0,this._rear=0):(d=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]=e),e.score=this._computeScore(e,d)}_computeScore(a,b){if(Math.abs(a.deltaX)>0&&Math.abs(a.deltaY)>0)return 1;let c=.5;if(this._isAlmostInt(a.deltaX)&&this._isAlmostInt(a.deltaY)||(c+=.25),b){let d=Math.abs(a.deltaX),e=Math.abs(a.deltaY),f=Math.abs(b.deltaX),g=Math.abs(b.deltaY),h=Math.max(Math.min(d,f),1),i=Math.max(Math.min(e,g),1),j=Math.max(e,g);Math.max(d,f)%h==0&&j%i==0&&(c-=.5)}return Math.min(Math.max(c,0),1)}_isAlmostInt(a){return .01>Math.abs(Math.round(a)-a)}};cF.INSTANCE=new cF;var cG=class extends cs{constructor(a,b,c){super(),this._onScroll=this._register(new bd),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new bd),this.onWillScroll=this._onWillScroll.event,this._options=function(a){let b={lazyRender:"u">typeof a.lazyRender&&a.lazyRender,className:"u">typeof a.className?a.className:"",useShadows:!("u">typeof a.useShadows)||a.useShadows,handleMouseWheel:!("u">typeof a.handleMouseWheel)||a.handleMouseWheel,flipAxes:"u">typeof a.flipAxes&&a.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof a.consumeMouseWheelIfScrollbarIsNeeded&&a.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof a.alwaysConsumeMouseWheel&&a.alwaysConsumeMouseWheel,scrollYToX:"u">typeof a.scrollYToX&&a.scrollYToX,mouseWheelScrollSensitivity:"u">typeof a.mouseWheelScrollSensitivity?a.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof a.fastScrollSensitivity?a.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof a.scrollPredominantAxis)||a.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof a.mouseWheelSmoothScroll)||a.mouseWheelSmoothScroll,arrowSize:"u">typeof a.arrowSize?a.arrowSize:11,listenOnDomNode:"u">typeof a.listenOnDomNode?a.listenOnDomNode:null,horizontal:"u">typeof a.horizontal?a.horizontal:1,horizontalScrollbarSize:"u">typeof a.horizontalScrollbarSize?a.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof a.horizontalSliderSize?a.horizontalSliderSize:0,horizontalHasArrows:"u">typeof a.horizontalHasArrows&&a.horizontalHasArrows,vertical:"u">typeof a.vertical?a.vertical:1,verticalScrollbarSize:"u">typeof a.verticalScrollbarSize?a.verticalScrollbarSize:10,verticalHasArrows:"u">typeof a.verticalHasArrows&&a.verticalHasArrows,verticalSliderSize:"u">typeof a.verticalSliderSize?a.verticalSliderSize:0,scrollByPage:"u">typeof a.scrollByPage&&a.scrollByPage};return b.horizontalSliderSize="u">typeof a.horizontalSliderSize?a.horizontalSliderSize:b.horizontalScrollbarSize,b.verticalSliderSize="u">typeof a.verticalSliderSize?a.verticalSliderSize:b.verticalScrollbarSize,by&&(b.className+=" mac"),b}(b),this._scrollable=c,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let d={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new cD(this._scrollable,this._options,d)),this._horizontalScrollbar=this._register(new cC(this._scrollable,this._options,d)),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(a),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=cp(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=cp(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=cp(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,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new b0),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=aS(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(a){this._verticalScrollbar.delegatePointerDown(a)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(a){this._scrollable.setScrollDimensions(a,!1)}updateClassName(a){this._options.className=a,by&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(a){"u">typeof a.handleMouseWheel&&(this._options.handleMouseWheel=a.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof a.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=a.mouseWheelScrollSensitivity),"u">typeof a.fastScrollSensitivity&&(this._options.fastScrollSensitivity=a.fastScrollSensitivity),"u">typeof a.scrollPredominantAxis&&(this._options.scrollPredominantAxis=a.scrollPredominantAxis),"u">typeof a.horizontal&&(this._options.horizontal=a.horizontal),"u">typeof a.vertical&&(this._options.vertical=a.vertical),"u">typeof a.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=a.horizontalScrollbarSize),"u">typeof a.verticalScrollbarSize&&(this._options.verticalScrollbarSize=a.verticalScrollbarSize),"u">typeof a.scrollByPage&&(this._options.scrollByPage=a.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(a){this._revealOnScroll=a}delegateScrollFromMouseWheelEvent(a){this._onMouseWheel(new bZ(a))}_setListeningToMouseWheel(a){if(this._mouseWheelToDispose.length>0!==a&&(this._mouseWheelToDispose=aS(this._mouseWheelToDispose),a)){let a=a=>{this._onMouseWheel(new bZ(a))};this._mouseWheelToDispose.push(ch(this._listenOnDomNode,cm.MOUSE_WHEEL,a,{passive:!1}))}}_onMouseWheel(a){if(a.browserEvent?.defaultPrevented)return;let b=cF.INSTANCE;b.acceptStandardWheelEvent(a);let c=!1;if(a.deltaY||a.deltaX){let d=a.deltaY*this._options.mouseWheelScrollSensitivity,e=a.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&e+d===0?e=d=0:Math.abs(d)>=Math.abs(e)?e=0:d=0),this._options.flipAxes&&([d,e]=[e,d]);let f=!by&&a.browserEvent&&a.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!e&&(e=d,d=0),a.browserEvent&&a.browserEvent.altKey&&(e*=this._options.fastScrollSensitivity,d*=this._options.fastScrollSensitivity);let g=this._scrollable.getFutureScrollPosition(),h={};if(d){let a=50*d,b=g.scrollTop-(a<0?Math.floor(a):Math.ceil(a));this._verticalScrollbar.writeScrollPosition(h,b)}if(e){let a=50*e,b=g.scrollLeft-(a<0?Math.floor(a):Math.ceil(a));this._horizontalScrollbar.writeScrollPosition(h,b)}h=this._scrollable.validateScrollPosition(h),(g.scrollLeft!==h.scrollLeft||g.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&b.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),c=!0)}let d=c;!d&&this._options.alwaysConsumeMouseWheel&&(d=!0),!d&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(d=!0),d&&(a.preventDefault(),a.stopPropagation())}_onDidScroll(a){this._shouldRender=this._horizontalScrollbar.onDidScroll(a)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(a)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw 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 a=this._scrollable.getCurrentScrollPosition(),b=a.scrollTop>0,c=a.scrollLeft>0,d=c?" left":"",e=b?" top":"";this._leftShadowDomNode.setClassName(`shadow${d}`),this._topShadowDomNode.setClassName(`shadow${e}`),this._topLeftShadowDomNode.setClassName(`shadow${c||b?" top-left-corner":""}${e}${d}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(a){this._mouseIsOver=!1,this._hide()}_onMouseOver(a){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(),500)}},cH=class extends cG{constructor(a,b,c){super(a,b,c)}setScrollPosition(a){a.reuseAnimation?this._scrollable.setScrollPositionSmooth(a,a.reuseAnimation):this._scrollable.setScrollPositionNow(a)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},cI=class extends aW{constructor(a,b,c,d,e,f,g,h){super(),this._bufferService=c,this._optionsService=g,this._renderService=h,this._onRequestScrollLines=this._register(new bd),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let i=this._register(new cv({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:a=>cT(d.window,a)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{i.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new cH(b,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},i)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(e.onProtocolChange(a=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&a)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(a6.runAndSubscribe(f.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=f.colors.background.css})),a.appendChild(this._scrollableElement.getDomNode()),this._register(aT(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=d.mainDocument.createElement("style"),b.appendChild(this._styleElement),this._register(aT(()=>this._styleElement.remove())),this._register(a6.runAndSubscribe(f.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${f.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${f.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${f.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
15
- `)})),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(a=>this._handleScroll(a)))}scrollLines(a){let b=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:b.scrollTop+a*this._renderService.dimensions.css.cell.height})}scrollToLine(a,b){b&&(this._latestYDisp=a),this._scrollableElement.setScrollPosition({reuseAnimation:!b,scrollTop:a*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(a){void 0!==a&&(this._latestYDisp=a),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(a=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,a!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:a*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(a){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let b=Math.round(a.scrollTop/this._renderService.dimensions.css.cell.height),c=b-this._bufferService.buffer.ydisp;0!==c&&(this._latestYDisp=b,this._onRequestScrollLines.fire(c)),this._isHandlingScroll=!1}};cI=Z([$(2,ap),$(3,aB),$(4,aq),$(5,aG),$(6,av),$(7,aD)],cI);var cJ=class extends aW{constructor(a,b,c,d,e){super(),this._screenElement=a,this._bufferService=b,this._coreBrowserService=c,this._decorationService=d,this._renderService=e,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(a=>this._removeDecoration(a))),this._register(aT(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){let b=this._coreBrowserService.mainDocument.createElement("div");b.classList.add("xterm-decoration"),b.classList.toggle("xterm-decoration-top-layer",a?.options?.layer==="top"),b.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,b.style.height=`${(a.options.height||1)*this._renderService.dimensions.css.cell.height}px`,b.style.top=`${(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,b.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let c=a.options.x??0;return c&&c>this._bufferService.cols&&(b.style.display="none"),this._refreshXPosition(a,b),b}_refreshStyle(a){let b=a.marker.line-this._bufferService.buffers.active.ydisp;if(b<0||b>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let c=this._decorationElements.get(a);c||(c=this._createElement(a),a.element=c,this._decorationElements.set(a,c),this._container.appendChild(c),a.onDispose(()=>{this._decorationElements.delete(a),c.remove()})),c.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(c.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,c.style.height=`${(a.options.height||1)*this._renderService.dimensions.css.cell.height}px`,c.style.top=`${b*this._renderService.dimensions.css.cell.height}px`,c.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),a.onRenderEmitter.fire(c)}}_refreshXPosition(a,b=a.element){if(!b)return;let c=a.options.x??0;"right"===(a.options.anchor||"left")?b.style.right=c?`${c*this._renderService.dimensions.css.cell.width}px`:"":b.style.left=c?`${c*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(a){this._decorationElements.get(a)?.remove(),this._decorationElements.delete(a),a.dispose()}};cJ=Z([$(1,ap),$(2,aB),$(3,ay),$(4,aD)],cJ);var cK=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(a){if(a.options.overviewRulerOptions){for(let b of this._zones)if(b.color===a.options.overviewRulerOptions.color&&b.position===a.options.overviewRulerOptions.position){if(this._lineIntersectsZone(b,a.marker.line))return;if(this._lineAdjacentToZone(b,a.marker.line,a.options.overviewRulerOptions.position))return void this._addLineToZone(b,a.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=a.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=a.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=a.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=a.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:a.options.overviewRulerOptions.color,position:a.options.overviewRulerOptions.position,startBufferLine:a.marker.line,endBufferLine:a.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(a){this._linePadding=a}_lineIntersectsZone(a,b){return b>=a.startBufferLine&&b<=a.endBufferLine}_lineAdjacentToZone(a,b,c){return b>=a.startBufferLine-this._linePadding[c||"full"]&&b<=a.endBufferLine+this._linePadding[c||"full"]}_addLineToZone(a,b){a.startBufferLine=Math.min(a.startBufferLine,b),a.endBufferLine=Math.max(a.endBufferLine,b)}},cL={full:0,left:0,center:0,right:0},cM={full:0,left:0,center:0,right:0},cN={full:0,left:0,center:0,right:0},cO=class extends aW{constructor(a,b,c,d,e,f,g,h){super(),this._viewportElement=a,this._screenElement=b,this._bufferService=c,this._decorationService=d,this._renderService=e,this._optionsService=f,this._themeService=g,this._coreBrowserService=h,this._colorZoneStore=new cK,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(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(aT(()=>this._canvas?.remove()));let i=this._canvas.getContext("2d");if(i)this._ctx=i;else throw 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(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let a=Math.floor((this._canvas.width-1)/3),b=Math.ceil((this._canvas.width-1)/3);cM.full=this._canvas.width,cM.left=a,cM.center=b,cM.right=a,this._refreshDrawHeightConstants(),cN.full=1,cN.left=1,cN.center=1+cM.left,cN.right=1+cM.left+cM.center}_refreshDrawHeightConstants(){cL.full=Math.round(2*this._coreBrowserService.dpr);let a=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);cL.left=a,cL.center=a,cL.right=a}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cL.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cL.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cL.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cL.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(){for(let a of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(a);this._ctx.lineWidth=1,this._renderRulerOutline();let a=this._colorZoneStore.zones;for(let b of a)"full"!==b.position&&this._renderColorZone(b);for(let b of a)"full"===b.position&&this._renderColorZone(b);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(a){this._ctx.fillStyle=a.color,this._ctx.fillRect(cN[a.position||"full"],Math.round((this._canvas.height-1)*(a.startBufferLine/this._bufferService.buffers.active.lines.length)-cL[a.position||"full"]/2),cM[a.position||"full"],Math.round((this._canvas.height-1)*((a.endBufferLine-a.startBufferLine)/this._bufferService.buffers.active.lines.length)+cL[a.position||"full"]))}_queueRefresh(a,b){this._shouldUpdateDimensions=a||this._shouldUpdateDimensions,this._shouldUpdateAnchor=b||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};cO=Z([$(2,ap),$(3,ay),$(4,aD),$(5,av),$(6,aG),$(7,aB)],cO),(l=cV||={}).NUL="\0",l.SOH="\x01",l.STX="\x02",l.ETX="\x03",l.EOT="\x04",l.ENQ="\x05",l.ACK="\x06",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=`
16
- `,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="\x0e",l.SI="\x0f",l.DLE="\x10",l.DC1="\x11",l.DC2="\x12",l.DC3="\x13",l.DC4="\x14",l.NAK="\x15",l.SYN="\x16",l.ETB="\x17",l.CAN="\x18",l.EM="\x19",l.SUB="\x1a",l.ESC="\x1b",l.FS="\x1c",l.GS="\x1d",l.RS="\x1e",l.US="\x1f",l.SP=" ",l.DEL="",(m=cW||={}).PAD="€",m.HOP="",m.BPH="‚",m.NBH="ƒ",m.IND="„",m.NEL="…",m.SSA="†",m.ESA="‡",m.HTS="ˆ",m.HTJ="‰",m.VTS="Š",m.PLD="‹",m.PLU="Œ",m.RI="",m.SS2="Ž",m.SS3="",m.DCS="",m.PU1="‘",m.PU2="’",m.STS="“",m.CCH="”",m.MW="•",m.SPA="–",m.EPA="—",m.SOS="˜",m.SGCI="™",m.SCI="š",m.CSI="›",m.ST="œ",m.OSC="",m.PM="ž",m.APC="Ÿ",(cX||={}).ST=`${cV.ESC}\\`;var cP=class{constructor(a,b,c,d,e,f){this._textarea=a,this._compositionView=b,this._bufferService=c,this._optionsService=d,this._coreService=e,this._renderService=f,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(a){this._compositionView.textContent=a.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(a){if(this._isComposing||this._isSendingComposition){if(20===a.keyCode||229===a.keyCode||16===a.keyCode||17===a.keyCode||18===a.keyCode)return!1;this._finalizeComposition(!1)}return 229!==a.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(a){if(this._compositionView.classList.remove("active"),this._isComposing=!1,a){let a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let b;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,(b=this._isComposing?this._textarea.value.substring(a.start,this._compositionPosition.start):this._textarea.value.substring(a.start)).length>0&&this._coreService.triggerDataEvent(b,!0)}},0)}else{this._isSendingComposition=!1;let a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){let a=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let b=this._textarea.value,c=b.replace(a,"");this._dataAlreadySent=c,b.length>a.length?this._coreService.triggerDataEvent(c,!0):b.length<a.length?this._coreService.triggerDataEvent(`${cV.DEL}`,!0):b.length===a.length&&b!==a&&this._coreService.triggerDataEvent(b,!0)}},0)}updateCompositionElements(a){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),b=this._renderService.dimensions.css.cell.height,c=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,d=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=d+"px",this._compositionView.style.top=c+"px",this._compositionView.style.height=b+"px",this._compositionView.style.lineHeight=b+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let e=this._compositionView.getBoundingClientRect();this._textarea.style.left=d+"px",this._textarea.style.top=c+"px",this._textarea.style.width=Math.max(e.width,1)+"px",this._textarea.style.height=Math.max(e.height,1)+"px",this._textarea.style.lineHeight=e.height+"px"}a||setTimeout(()=>this.updateCompositionElements(!0),0)}}};cP=Z([$(2,ap),$(3,av),$(4,ar),$(5,aD)],cP);var cQ,cR,cS,cT,cU,cV,cW,cX,cY,cZ=0,c$=0,c_=0,c0=0,c1={css:"#00000000",rgba:0};(eF=cY||={}).toCss=function(a,b,c,d){return void 0!==d?`#${c9(a)}${c9(b)}${c9(c)}${c9(d)}`:`#${c9(a)}${c9(b)}${c9(c)}`},eF.toRgba=function(a,b,c,d=255){return(a<<24|b<<16|c<<8|d)>>>0},eF.toColor=function(a,b,c,d){return{css:eF.toCss(a,b,c,d),rgba:eF.toRgba(a,b,c,d)}};var c2=eG||={};function c3(a,b){return c0=Math.round(255*b),[cZ,c$,c_]=eJ.toChannels(a.rgba),{css:cY.toCss(cZ,c$,c_,c0),rgba:cY.toRgba(cZ,c$,c_,c0)}}c2.blend=function(a,b){if(1==(c0=(255&b.rgba)/255))return{css:b.css,rgba:b.rgba};let c=b.rgba>>24&255,d=b.rgba>>16&255,e=b.rgba>>8&255,f=a.rgba>>24&255,g=a.rgba>>16&255,h=a.rgba>>8&255;return cZ=f+Math.round((c-f)*c0),c$=g+Math.round((d-g)*c0),c_=h+Math.round((e-h)*c0),{css:cY.toCss(cZ,c$,c_),rgba:cY.toRgba(cZ,c$,c_)}},c2.isOpaque=function(a){return(255&a.rgba)==255},c2.ensureContrastRatio=function(a,b,c){let d=eJ.ensureContrastRatio(a.rgba,b.rgba,c);if(d)return cY.toColor(d>>24&255,d>>16&255,d>>8&255)},c2.opaque=function(a){let b=(255|a.rgba)>>>0;return[cZ,c$,c_]=eJ.toChannels(b),{css:cY.toCss(cZ,c$,c_),rgba:b}},c2.opacity=c3,c2.multiplyOpacity=function(a,b){return c0=255&a.rgba,c3(a,c0*b/255)},c2.toColorRGB=function(a){return[a.rgba>>24&255,a.rgba>>16&255,a.rgba>>8&255]},(a=>{let b,c;try{let a=document.createElement("canvas");a.width=1,a.height=1;let d=a.getContext("2d",{willReadFrequently:!0});d&&((b=d).globalCompositeOperation="copy",c=b.createLinearGradient(0,0,1,1))}catch{}a.toColor=function(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return cZ=parseInt(a.slice(1,2).repeat(2),16),c$=parseInt(a.slice(2,3).repeat(2),16),c_=parseInt(a.slice(3,4).repeat(2),16),cY.toColor(cZ,c$,c_);case 5:return cZ=parseInt(a.slice(1,2).repeat(2),16),c$=parseInt(a.slice(2,3).repeat(2),16),c_=parseInt(a.slice(3,4).repeat(2),16),c0=parseInt(a.slice(4,5).repeat(2),16),cY.toColor(cZ,c$,c_,c0);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let d=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(d)return cZ=parseInt(d[1]),c$=parseInt(d[2]),c_=parseInt(d[3]),c0=Math.round((void 0===d[5]?1:parseFloat(d[5]))*255),cY.toColor(cZ,c$,c_,c0);if(!b||!c||(b.fillStyle=c,b.fillStyle=a,"string"!=typeof b.fillStyle)||(b.fillRect(0,0,1,1),[cZ,c$,c_,c0]=b.getImageData(0,0,1,1).data,255!==c0))throw Error("css.toColor: Unsupported css format");return{rgba:cY.toRgba(cZ,c$,c_,c0),css:a}}})(eH||={});var c4=eI||={};function c5(a,b,c){let d=a/255,e=b/255,f=c/255;return .2126*(d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.0722*(f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4))}c4.relativeLuminance=function(a){return c5(a>>16&255,a>>8&255,255&a)},c4.relativeLuminance2=c5;var c6=eJ||={};function c7(a,b,c){let d=a>>24&255,e=a>>16&255,f=a>>8&255,g=b>>24&255,h=b>>16&255,i=b>>8&255,j=da(eI.relativeLuminance2(g,h,i),eI.relativeLuminance2(d,e,f));for(;j<c&&(g>0||h>0||i>0);)g-=Math.max(0,Math.ceil(.1*g)),h-=Math.max(0,Math.ceil(.1*h)),i-=Math.max(0,Math.ceil(.1*i)),j=da(eI.relativeLuminance2(g,h,i),eI.relativeLuminance2(d,e,f));return(g<<24|h<<16|i<<8|255)>>>0}function c8(a,b,c){let d=a>>24&255,e=a>>16&255,f=a>>8&255,g=b>>24&255,h=b>>16&255,i=b>>8&255,j=da(eI.relativeLuminance2(g,h,i),eI.relativeLuminance2(d,e,f));for(;j<c&&(g<255||h<255||i<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),h=Math.min(255,h+Math.ceil((255-h)*.1)),i=Math.min(255,i+Math.ceil((255-i)*.1)),j=da(eI.relativeLuminance2(g,h,i),eI.relativeLuminance2(d,e,f));return(g<<24|h<<16|i<<8|255)>>>0}function c9(a){let b=a.toString(16);return b.length<2?"0"+b:b}function da(a,b){return a<b?(b+.05)/(a+.05):(a+.05)/(b+.05)}c6.blend=function(a,b){if(1==(c0=(255&b)/255))return b;let c=a>>24&255,d=a>>16&255,e=a>>8&255;return cZ=c+Math.round(((b>>24&255)-c)*c0),c$=d+Math.round(((b>>16&255)-d)*c0),c_=e+Math.round(((b>>8&255)-e)*c0),cY.toRgba(cZ,c$,c_)},c6.ensureContrastRatio=function(a,b,c){let d=eI.relativeLuminance(a>>8),e=eI.relativeLuminance(b>>8);if(da(d,e)<c){if(e<d){let e=c7(a,b,c),f=da(d,eI.relativeLuminance(e>>8));if(f<c){let g=c8(a,b,c);return f>da(d,eI.relativeLuminance(g>>8))?e:g}return e}let f=c8(a,b,c),g=da(d,eI.relativeLuminance(f>>8));if(g<c){let e=c7(a,b,c);return g>da(d,eI.relativeLuminance(e>>8))?f:e}return f}},c6.reduceLuminance=c7,c6.increaseLuminance=c8,c6.toChannels=function(a){return[a>>24&255,a>>16&255,a>>8&255,255&a]};var db=class extends ai{constructor(a,b,c){super(),this.content=0,this.combinedData="",this.fg=a.fg,this.bg=a.bg,this.combinedData=b,this._width=c}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(a){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},dc=class{constructor(a){this._bufferService=a,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ak}register(a){let b={id:this._nextCharacterJoinerId++,handler:a};return this._characterJoiners.push(b),b.id}deregister(a){for(let b=0;b<this._characterJoiners.length;b++)if(this._characterJoiners[b].id===a)return this._characterJoiners.splice(b,1),!0;return!1}getJoinedCharacters(a){if(0===this._characterJoiners.length)return[];let b=this._bufferService.buffer.lines.get(a);if(!b||0===b.length)return[];let c=[],d=b.translateToString(!0),e=0,f=0,g=0,h=b.getFg(0),i=b.getBg(0);for(let a=0;a<b.getTrimmedLength();a++)if(b.loadCell(a,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==h||this._workCell.bg!==i){if(a-e>1){let a=this._getJoinedRanges(d,g,f,b,e);for(let b=0;b<a.length;b++)c.push(a[b])}e=a,g=f,h=this._workCell.fg,i=this._workCell.bg}f+=this._workCell.getChars().length||1}if(this._bufferService.cols-e>1){let a=this._getJoinedRanges(d,g,f,b,e);for(let b=0;b<a.length;b++)c.push(a[b])}return c}_getJoinedRanges(a,b,c,d,e){let f=a.substring(b,c),g=[];try{g=this._characterJoiners[0].handler(f)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let b=this._characterJoiners[a].handler(f);for(let a=0;a<b.length;a++)dc._mergeRanges(g,b[a])}catch(a){console.error(a)}return this._stringRangesToCellRanges(g,d,e),g}_stringRangesToCellRanges(a,b,c){let d=0,e=!1,f=0,g=a[0];if(g){for(let h=c;h<this._bufferService.cols;h++){let c=b.getWidth(h),i=b.getString(h).length||1;if(0!==c){if(!e&&g[0]<=f&&(g[0]=h,e=!0),g[1]<=f){if(g[1]=h,!(g=a[++d]))break;g[0]<=f?(g[0]=h,e=!0):e=!1}f+=i}}g&&(g[1]=this._bufferService.cols)}}static _mergeRanges(a,b){let c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(c){if(b[1]<=e[0])return a[d-1][1]=b[1],a;if(b[1]<=e[1])return a[d-1][1]=Math.max(b[1],e[1]),a.splice(d,1),a;a.splice(d,1),d--}else{if(b[1]<=e[0])return a.splice(d,0,b),a;if(b[1]<=e[1])return e[0]=Math.min(b[0],e[0]),a;b[0]<e[1]&&(e[0]=Math.min(b[0],e[0]),c=!0);continue}}return c?a[a.length-1][1]=b[1]:a.push(b),a}};function dd(){return{width:0,height:0}}dc=Z([$(0,ap)],dc);var de=class{constructor(a,b,c,d,e,f,g){this._document=a,this._characterJoinerService=b,this._optionsService=c,this._coreBrowserService=d,this._coreService=e,this._decorationService=f,this._themeService=g,this._workCell=new ak,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(a,b,c){this._selectionStart=a,this._selectionEnd=b,this._columnSelectMode=c}createRow(a,b,c,d,e,f,g,h,i,j,k){let l=[],m=this._characterJoinerService.getJoinedCharacters(b),n=this._themeService.colors,o=a.getNoBgTrimmedLength();c&&o<f+1&&(o=f+1);let p,q=0,r="",s=0,u=0,v=0,w=0,x=!1,y=0,z=!1,A=0,B=0,C=[],D=-1!==j&&-1!==k;for(let E=0;E<o;E++){let o;a.loadCell(E,this._workCell);let F=this._workCell.getWidth();if(0===F)continue;let G=!1,H=E>=B,I=E,J=this._workCell;if(m.length>0&&E===m[0][0]&&H){let d=m.shift(),e=this._isCellInSelection(d[0],b);for(s=d[0]+1;s<d[1];s++)H&&=e===this._isCellInSelection(s,b);(H&&=!c||f<d[0]||f>=d[1])?(G=!0,J=new db(this._workCell,a.translateToString(!0,d[0],d[1]),d[1]-d[0]),I=d[1]-1,F=J.getWidth()):B=d[1]}let K=this._isCellInSelection(E,b),L=c&&E===f,M=D&&E>=j&&E<=k,N=!1;this._decorationService.forEachDecorationAtCell(E,b,void 0,a=>{N=!0});let O=J.getChars()||" ";if(" "===O&&(J.isUnderline()||J.isOverline())&&(O=" "),A=F*h-i.get(O,J.isBold(),J.isItalic()),p)if(q&&(K&&z||!K&&!z&&J.bg===u)&&(K&&z&&n.selectionForeground||J.fg===v)&&J.extended.ext===w&&M===x&&A===y&&!L&&!G&&!N&&H){J.isInvisible()?r+=" ":r+=O,q++;continue}else q&&(p.textContent=r),p=this._document.createElement("span"),q=0,r="";else p=this._document.createElement("span");if(u=J.bg,v=J.fg,w=J.extended.ext,x=M,y=A,z=K,G&&f>=E&&f<=I&&(f=E),!this._coreService.isCursorHidden&&L&&this._coreService.isCursorInitialized){if(C.push("xterm-cursor"),this._coreBrowserService.isFocused)g&&C.push("xterm-cursor-blink"),C.push("bar"===d?"xterm-cursor-bar":"underline"===d?"xterm-cursor-underline":"xterm-cursor-block");else if(e)switch(e){case"outline":C.push("xterm-cursor-outline");break;case"block":C.push("xterm-cursor-block");break;case"bar":C.push("xterm-cursor-bar");break;case"underline":C.push("xterm-cursor-underline")}}if(J.isBold()&&C.push("xterm-bold"),J.isItalic()&&C.push("xterm-italic"),J.isDim()&&C.push("xterm-dim"),r=J.isInvisible()?" ":J.getChars()||" ",J.isUnderline()&&(C.push(`xterm-underline-${J.extended.underlineStyle}`)," "===r&&(r=" "),!J.isUnderlineColorDefault()))if(J.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${ai.toColorRGB(J.getUnderlineColor()).join(",")})`;else{let a=J.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&J.isBold()&&a<8&&(a+=8),p.style.textDecorationColor=n.ansi[a].css}J.isOverline()&&(C.push("xterm-overline")," "===r&&(r=" ")),J.isStrikethrough()&&C.push("xterm-strikethrough"),M&&(p.style.textDecoration="underline");let P=J.getFgColor(),Q=J.getFgColorMode(),R=J.getBgColor(),S=J.getBgColorMode(),T=!!J.isInverse();if(T){let a=P;P=R,R=a;let b=Q;Q=S,S=b}let U,V,W=!1;switch(this._decorationService.forEachDecorationAtCell(E,b,void 0,a=>{"top"!==a.options.layer&&W||(a.backgroundColorRGB&&(S=0x3000000,R=a.backgroundColorRGB.rgba>>8&0xffffff,U=a.backgroundColorRGB),a.foregroundColorRGB&&(Q=0x3000000,P=a.foregroundColorRGB.rgba>>8&0xffffff,V=a.foregroundColorRGB),W="top"===a.options.layer)}),!W&&K&&(R=(U=this._coreBrowserService.isFocused?n.selectionBackgroundOpaque:n.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,S=0x3000000,W=!0,n.selectionForeground&&(Q=0x3000000,P=n.selectionForeground.rgba>>8&0xffffff,V=n.selectionForeground)),W&&C.push("xterm-decoration-top"),S){case 0x1000000:case 0x2000000:o=n.ansi[R],C.push(`xterm-bg-${R}`);break;case 0x3000000:o=cY.toColor(R>>16,R>>8&255,255&R),this._addStyle(p,`background-color:#${df((R>>>0).toString(16),"0",6)}`);break;default:T?(o=n.foreground,C.push("xterm-bg-257")):o=n.background}switch(U||J.isDim()&&(U=eG.multiplyOpacity(o,.5)),Q){case 0x1000000:case 0x2000000:J.isBold()&&P<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(P+=8),this._applyMinimumContrast(p,o,n.ansi[P],J,U,void 0)||C.push(`xterm-fg-${P}`);break;case 0x3000000:let X=cY.toColor(P>>16&255,P>>8&255,255&P);this._applyMinimumContrast(p,o,X,J,U,V)||this._addStyle(p,`color:#${df(P.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,o,n.foreground,J,U,V)||T&&C.push("xterm-fg-257")}C.length&&(p.className=C.join(" "),C.length=0),L||G||N||!H?p.textContent=r:q++,A!==this.defaultSpacing&&(p.style.letterSpacing=`${A}px`),l.push(p),E=I}return p&&q&&(p.textContent=r),l}_applyMinimumContrast(a,b,c,d,e,f){var g,h,i;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(h=g=d.getCode())&&h<=57558||9472<=(i=g)&&i<=9631)return!1;let j=this._getContrastCache(d),k;if(e||f||(k=j.getColor(b.rgba,c.rgba)),void 0===k){let a=this._optionsService.rawOptions.minimumContrastRatio/(d.isDim()?2:1);k=eG.ensureContrastRatio(e||b,f||c,a),j.setColor((e||b).rgba,(f||c).rgba,k??null)}return!!k&&(this._addStyle(a,`color:${k.css}`),!0)}_getContrastCache(a){return a.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(a,b){a.setAttribute("style",`${a.getAttribute("style")||""}${b};`)}_isCellInSelection(a,b){let c=this._selectionStart,d=this._selectionEnd;return!!c&&!!d&&(this._columnSelectMode?c[0]<=d[0]?a>=c[0]&&b>=c[1]&&a<d[0]&&b<=d[1]:a<c[0]&&b>=c[1]&&a>=d[0]&&b<=d[1]:b>c[1]&&b<d[1]||c[1]===d[1]&&b===c[1]&&a>=c[0]&&a<d[0]||c[1]<d[1]&&b===d[1]&&a<d[0]||c[1]<d[1]&&b===c[1]&&a>=c[0])}};function df(a,b,c){for(;a.length<c;)a=b+a;return a}de=Z([$(1,aF),$(2,av),$(3,aB),$(4,ar),$(5,ay),$(6,aG)],de);var dg=class{constructor(a,b){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=a.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 c=a.createElement("span");c.classList.add("xterm-char-measure-element");let d=a.createElement("span");d.classList.add("xterm-char-measure-element"),d.style.fontWeight="bold";let e=a.createElement("span");e.classList.add("xterm-char-measure-element"),e.style.fontStyle="italic";let f=a.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontWeight="bold",f.style.fontStyle="italic",this._measureElements=[c,d,e,f],this._container.appendChild(c),this._container.appendChild(d),this._container.appendChild(e),this._container.appendChild(f),b.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(a,b,c,d){a===this._font&&b===this._fontSize&&c===this._weight&&d===this._weightBold||(this._font=a,this._fontSize=b,this._weight=c,this._weightBold=d,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${c}`,this._measureElements[1].style.fontWeight=`${d}`,this._measureElements[2].style.fontWeight=`${c}`,this._measureElements[3].style.fontWeight=`${d}`,this.clear())}get(a,b,c){let d=0;if(!b&&!c&&1===a.length&&(d=a.charCodeAt(0))<256){if(-9999!==this._flat[d])return this._flat[d];let b=this._measure(a,0);return b>0&&(this._flat[d]=b),b}let e=a;b&&(e+="B"),c&&(e+="I");let f=this._holey.get(e);if(void 0===f){let d=0;b&&(d|=1),c&&(d|=2),(f=this._measure(a,d))>0&&this._holey.set(e,f)}return f}_measure(a,b){let c=this._measureElements[b];return c.textContent=a.repeat(32),c.offsetWidth/32}},dh=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(a,b,c,d=!1){if(this.selectionStart=b,this.selectionEnd=c,!b||!c||b[0]===c[0]&&b[1]===c[1])return void this.clear();let e=a.buffers.active.ydisp,f=b[1]-e,g=c[1]-e,h=Math.max(f,0),i=Math.min(g,a.rows-1);h>=a.rows||i<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=d,this.viewportStartRow=f,this.viewportEndRow=g,this.viewportCappedStartRow=h,this.viewportCappedEndRow=i,this.startCol=b[0],this.endCol=c[0])}isCellSelected(a,b,c){return!!this.hasSelection&&(c-=a.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?b>=this.startCol&&c>=this.viewportCappedStartRow&&b<this.endCol&&c<=this.viewportCappedEndRow:b<this.startCol&&c>=this.viewportCappedStartRow&&b>=this.endCol&&c<=this.viewportCappedEndRow:c>this.viewportStartRow&&c<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&c===this.viewportStartRow&&b>=this.startCol&&b<this.endCol||this.viewportStartRow<this.viewportEndRow&&c===this.viewportEndRow&&b<this.endCol||this.viewportStartRow<this.viewportEndRow&&c===this.viewportStartRow&&b>=this.startCol)}},di="xterm-dom-renderer-owner-",dj="xterm-rows",dk="xterm-fg-",dl="xterm-bg-",dm="xterm-focus",dn="xterm-selection",dp=1,dq=class extends aW{constructor(a,b,c,d,e,f,g,h,i,j,k,l,m,n){super(),this._terminal=a,this._document=b,this._element=c,this._screenElement=d,this._viewportElement=e,this._helperContainer=f,this._linkifier2=g,this._charSizeService=i,this._optionsService=j,this._bufferService=k,this._coreService=l,this._coreBrowserService=m,this._themeService=n,this._terminalClass=dp++,this._rowElements=[],this._selectionRenderModel=new dh,this.onRequestRedraw=this._register(new bd).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(dj),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(dn),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:dd(),cell:dd()},device:{canvas:dd(),cell:dd(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(a=>this._injectCss(a))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(de,document),this._element.classList.add(di+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(a=>this._handleLinkHover(a))),this._register(this._linkifier2.onHideLinkUnderline(a=>this._handleLinkLeave(a))),this._register(aT(()=>{this._element.classList.remove(di+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new dg(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 a=this._coreBrowserService.dpr;for(let b of(this.dimensions.device.char.width=this._charSizeService.width*a,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*a),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/a),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/a),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,this._rowElements))b.style.width=`${this.dimensions.css.canvas.width}px`,b.style.height=`${this.dimensions.css.cell.height}px`,b.style.lineHeight=`${this.dimensions.css.cell.height}px`,b.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let b=`${this._terminalSelector} .${dj} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=b,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(a){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let b=`${this._terminalSelector} .${dj} { pointer-events: none; color: ${a.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;b+=`${this._terminalSelector} .${dj} .xterm-dim { color: ${eG.multiplyOpacity(a.foreground,.5).css};}${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 c=`blink_underline_${this._terminalClass}`,d=`blink_bar_${this._terminalClass}`,e=`blink_block_${this._terminalClass}`;for(let[f,g]of(b+=`@keyframes ${c} { 50% { border-bottom-style: hidden; }}@keyframes ${d} { 50% { box-shadow: none; }}@keyframes ${e} { 0% { background-color: ${a.cursor.css}; color: ${a.cursorAccent.css}; } 50% { background-color: inherit; color: ${a.cursor.css}; }}${this._terminalSelector} .${dj}.${dm} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${c} 1s step-end infinite;}${this._terminalSelector} .${dj}.${dm} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${d} 1s step-end infinite;}${this._terminalSelector} .${dj}.${dm} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${e} 1s step-end infinite;}${this._terminalSelector} .${dj} .xterm-cursor.xterm-cursor-block { background-color: ${a.cursor.css}; color: ${a.cursorAccent.css};}${this._terminalSelector} .${dj} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${a.cursor.css} !important; color: ${a.cursorAccent.css} !important;}${this._terminalSelector} .${dj} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${a.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${dj} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${a.cursor.css} inset;}${this._terminalSelector} .${dj} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${a.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${dn} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${dn} div { position: absolute; background-color: ${a.selectionBackgroundOpaque.css};}${this._terminalSelector} .${dn} div { position: absolute; background-color: ${a.selectionInactiveBackgroundOpaque.css};}`,a.ansi.entries()))b+=`${this._terminalSelector} .${dk}${f} { color: ${g.css}; }${this._terminalSelector} .${dk}${f}.xterm-dim { color: ${eG.multiplyOpacity(g,.5).css}; }${this._terminalSelector} .${dl}${f} { background-color: ${g.css}; }`;b+=`${this._terminalSelector} .${dk}257 { color: ${eG.opaque(a.background).css}; }${this._terminalSelector} .${dk}257.xterm-dim { color: ${eG.multiplyOpacity(eG.opaque(a.background),.5).css}; }${this._terminalSelector} .${dl}257 { background-color: ${a.foreground.css}; }`,this._themeStyleElement.textContent=b}_setDefaultSpacing(){let a=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${a}px`,this._rowFactory.defaultSpacing=a}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(a,b){for(let a=this._rowElements.length;a<=b;a++){let a=this._document.createElement("div");this._rowContainer.appendChild(a),this._rowElements.push(a)}for(;this._rowElements.length>b;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(a,b){this._refreshRowElements(a,b),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(dm),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(dm),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(a,b,c){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(a,b,c),this.renderRows(0,this._bufferService.rows-1),!a||!b||(this._selectionRenderModel.update(this._terminal,a,b,c),!this._selectionRenderModel.hasSelection))return;let d=this._selectionRenderModel.viewportStartRow,e=this._selectionRenderModel.viewportEndRow,f=this._selectionRenderModel.viewportCappedStartRow,g=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(c){let c=a[0]>b[0];h.appendChild(this._createSelectionElement(f,c?b[0]:a[0],c?a[0]:b[0],g-f+1))}else{let c=d===f?a[0]:0,i=f===e?b[0]:this._bufferService.cols;if(h.appendChild(this._createSelectionElement(f,c,i)),h.appendChild(this._createSelectionElement(f+1,0,this._bufferService.cols,g-f-1)),f!==g){let a=e===g?b[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(g,0,a))}}this._selectionContainer.appendChild(h)}_createSelectionElement(a,b,c,d=1){let e=this._document.createElement("div"),f=b*this.dimensions.css.cell.width,g=this.dimensions.css.cell.width*(c-b);return f+g>this.dimensions.css.canvas.width&&(g=this.dimensions.css.canvas.width-f),e.style.height=`${d*this.dimensions.css.cell.height}px`,e.style.top=`${a*this.dimensions.css.cell.height}px`,e.style.left=`${f}px`,e.style.width=`${g}px`,e}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 a of this._rowElements)a.replaceChildren()}renderRows(a,b){let c=this._bufferService.buffer,d=c.ybase+c.y,e=Math.min(c.x,this._bufferService.cols-1),f=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,g=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let i=a;i<=b;i++){let a=i+c.ydisp,b=this._rowElements[i],j=c.lines.get(a);if(!b||!j)break;b.replaceChildren(...this._rowFactory.createRow(j,a,a===d,g,h,e,f,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${di}${this._terminalClass}`}_handleLinkHover(a){this._setCellUnderline(a.x1,a.x2,a.y1,a.y2,a.cols,!0)}_handleLinkLeave(a){this._setCellUnderline(a.x1,a.x2,a.y1,a.y2,a.cols,!1)}_setCellUnderline(a,b,c,d,e,f){c<0&&(a=0),d<0&&(b=0);let g=this._bufferService.rows-1;c=Math.max(Math.min(c,g),0),d=Math.max(Math.min(d,g),0),e=Math.min(e,this._bufferService.cols);let h=this._bufferService.buffer,i=h.ybase+h.y,j=Math.min(h.x,e-1),k=this._optionsService.rawOptions.cursorBlink,l=this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=c;g<=d;++g){let n=g+h.ydisp,o=this._rowElements[g],p=h.lines.get(n);if(!o||!p)break;o.replaceChildren(...this._rowFactory.createRow(p,n,n===i,l,m,j,k,this.dimensions.css.cell.width,this._widthCache,f?g===c?a:0:-1,f?(g===d?b:e)-1:-1))}}};dq=Z([$(7,at),$(8,aA),$(9,av),$(10,ap),$(11,ar),$(12,aB),$(13,aG)],dq);var dr=class extends aW{constructor(a,b,c){super(),this._optionsService=c,this.width=0,this.height=0,this._onCharSizeChange=this._register(new bd),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new du(this._optionsService))}catch{this._measureStrategy=this._register(new dt(a,b,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let a=this._measureStrategy.measure();(a.width!==this.width||a.height!==this.height)&&(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};dr=Z([$(2,av)],dr);var ds=class extends aW{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(a,b){void 0!==a&&a>0&&void 0!==b&&b>0&&(this._result.width=a,this._result.height=b)}},dt=class extends ds{constructor(a,b,c){super(),this._document=a,this._parentElement=b,this._optionsService=c,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}},du=class extends ds{constructor(a){super(),this._optionsService=a,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let b=this._ctx.measureText("W");if(!("width"in b&&"fontBoundingBoxAscent"in b&&"fontBoundingBoxDescent"in b))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let a=this._ctx.measureText("W");return this._validateAndSet(a.width,a.fontBoundingBoxAscent+a.fontBoundingBoxDescent),this._result}},dv=class extends aW{constructor(a,b,c){super(),this._textarea=a,this._window=b,this.mainDocument=c,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new dw(this._window)),this._onDprChange=this._register(new bd),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new bd),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(a=>this._screenDprMonitor.setWindow(a))),this._register(a6.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ch(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ch(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(a){this._window!==a&&(this._window=a,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},dw=class extends aW{constructor(a){super(),this._parentWindow=a,this._windowResizeListener=this._register(new aX),this._onDprChange=this._register(new bd),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(aT(()=>this.clearListener()))}setWindow(a){this._parentWindow=a,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ch(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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)}},dx=class extends aW{constructor(){super(),this.linkProviders=[],this._register(aT(()=>this.linkProviders.length=0))}registerLinkProvider(a){return this.linkProviders.push(a),{dispose:()=>{let b=this.linkProviders.indexOf(a);-1!==b&&this.linkProviders.splice(b,1)}}}};function dy(a,b,c){let d=c.getBoundingClientRect(),e=a.getComputedStyle(c),f=parseInt(e.getPropertyValue("padding-left")),g=parseInt(e.getPropertyValue("padding-top"));return[b.clientX-d.left-f,b.clientY-d.top-g]}var dz=class{constructor(a,b){this._renderService=a,this._charSizeService=b}getCoords(a,b,c,d,e){return function(a,b,c,d,e,f,g,h,i){if(!f)return;let j=dy(a,b,c);return j[0]=Math.ceil((j[0]+(i?g/2:0))/g),j[1]=Math.ceil(j[1]/h),j[0]=Math.min(Math.max(j[0],1),d+ +!!i),j[1]=Math.min(Math.max(j[1],1),e),j}(window,a,b,c,d,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,e)}getMouseReportCoords(a,b){let c=dy(window,a,b);if(this._charSizeService.hasValidSize)return c[0]=Math.min(Math.max(c[0],0),this._renderService.dimensions.css.canvas.width-1),c[1]=Math.min(Math.max(c[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(c[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(c[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(c[0]),y:Math.floor(c[1])}}};dz=Z([$(0,aD),$(1,aA)],dz);var dA=class{constructor(a,b){this._renderCallback=a,this._coreBrowserService=b,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(a){return this._refreshCallbacks.push(a),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(a,b,c){this._rowCount=c,a=void 0!==a?a:0,b=void 0!==b?b:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,a):a,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,b):b,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let a=Math.max(this._rowStart,0),b=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,b),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let a of this._refreshCallbacks)a(0);this._refreshCallbacks=[]}},dB={},dC={getSafariVersion:()=>dK,isChromeOS:()=>dQ,isFirefox:()=>dH,isIpad:()=>dM,isIphone:()=>dN,isLegacyEdge:()=>dI,isLinux:()=>dP,isMac:()=>dL,isNode:()=>dE,isSafari:()=>dJ,isWindows:()=>dO};for(var dD in dC)X(dB,dD,{get:dC[dD],enumerable:!0});var dE="u">typeof process&&"title"in process,dF=dE?"node":navigator.userAgent,dG=dE?"node":navigator.platform,dH=dF.includes("Firefox"),dI=dF.includes("Edge"),dJ=/^((?!chrome|android).)*safari/i.test(dF);function dK(){if(!dJ)return 0;let a=dF.match(/Version\/(\d+)/);return null===a||a.length<2?0:parseInt(a[1])}var dL=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(dG),dM="iPad"===dG,dN="iPhone"===dG,dO=["Windows","Win16","Win32","WinCE"].includes(dG),dP=dG.indexOf("Linux")>=0,dQ=/\bCrOS\b/.test(dF),dR=class{constructor(){this._tasks=[],this._i=0}enqueue(a){this._tasks.push(a),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(a){this._idleCallback=void 0;let b=0,c=0,d=a.timeRemaining(),e=0;for(;this._i<this._tasks.length;){if(b=performance.now(),this._tasks[this._i]()||this._i++,1.5*(c=Math.max(b=Math.max(1,performance.now()-b),c))>(e=a.timeRemaining())){d-b<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(d-b))}ms`),this._start();return}d=e}this.clear()}},dS=class extends dR{_requestCallback(a){return setTimeout(()=>a(this._createDeadline(16)))}_cancelCallback(a){clearTimeout(a)}_createDeadline(a){let b=performance.now()+a;return{timeRemaining:()=>Math.max(0,b-performance.now())}}},dT=class extends dR{_requestCallback(a){return requestIdleCallback(a)}_cancelCallback(a){cancelIdleCallback(a)}},dU=!dE&&"requestIdleCallback"in window?dT:dS,dV=class{constructor(){this._queue=new dU}set(a){this._queue.clear(),this._queue.enqueue(a)}flush(){this._queue.flush()}},dW=class extends aW{constructor(a,b,c,d,e,f,g,h,i){super(),this._rowCount=a,this._optionsService=c,this._charSizeService=d,this._coreService=e,this._coreBrowserService=h,this._renderer=this._register(new aX),this._pausedResizeTask=new dV,this._observerDisposable=this._register(new aX),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 bd),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new bd),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new bd),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new bd),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new dA((a,b)=>this._renderRows(a,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new dX(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(aT(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(g.onResize(()=>this._fullRefresh())),this._register(g.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(f.onDecorationRegistered(()=>this._fullRefresh())),this._register(f.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(g.cols,g.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(g.buffer.y,g.buffer.y,!0))),this._register(i.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,b),this._register(this._coreBrowserService.onWindowChange(a=>this._registerIntersectionObserver(a,b)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(a,b){if("IntersectionObserver"in a){let c=new a.IntersectionObserver(a=>this._handleIntersectionChange(a[a.length-1]),{threshold:0});c.observe(b),this._observerDisposable.value=aT(()=>c.disconnect())}}_handleIntersectionChange(a){this._isPaused=void 0===a.isIntersecting?0===a.intersectionRatio:!a.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(a,b,c=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(a,b);let d=this._syncOutputHandler.flush();d&&(a=Math.min(a,d.start),b=Math.max(b,d.end)),c||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(a,b,this._rowCount)}_renderRows(a,b){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(a,b);a=Math.min(a,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(a,b),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:a,end:b}),this._onRender.fire({start:a,end:b}),this._isNextRenderRedrawOnly=!0}}resize(a,b){this._rowCount=b,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(a){this._renderer.value=a,this._renderer.value&&(this._renderer.value.onRequestRedraw(a=>this.refreshRows(a.start,a.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(a){return this._renderDebouncer.addRefreshCallback(a)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(a,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(a,b)):this._renderer.value.handleResize(a,b),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(a,b,c){this._selectionState.start=a,this._selectionState.end=b,this._selectionState.columnSelectMode=c,this._renderer.value?.handleSelectionChanged(a,b,c)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};dW=Z([$(2,av),$(3,aA),$(4,ar),$(5,ay),$(6,ap),$(7,aB),$(8,aG)],dW);var dX=class{constructor(a,b,c){this._coreBrowserService=a,this._coreService=b,this._onTimeout=c,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(a,b){this._isBuffering?(this._start=Math.min(this._start,a),this._end=Math.max(this._end,b)):(this._start=a,this._end=b,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let a={start:this._start,end:this._end};return this._isBuffering=!1,a}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function dY(a,b,c,d){return d0(Math.abs(a-dZ(a,c)-(b-dZ(b,c)))-function(a,b,c){let d=0,e=a-dZ(a,c),f=b-dZ(b,c);for(let g=0;g<Math.abs(e-f);g++){let f="A"===function(a,b){return a>b?"A":"B"}(a,b)?-1:1;c.buffer.lines.get(e+f*g)?.isWrapped&&d++}return d}(a,b,c),d_(a>b?"A":"B",d))}function dZ(a,b){let c=0,d=b.buffer.lines.get(a),e=d?.isWrapped;for(;e&&a>=0&&a<b.rows;)c++,d=b.buffer.lines.get(--a),e=d?.isWrapped;return c}function d$(a,b,c,d,e,f){let g=a,h=b,i="";for(;(g!==c||h!==d)&&h>=0&&h<f.buffer.lines.length;)g+=e?1:-1,e&&g>f.cols-1?(i+=f.buffer.translateBufferLineToString(h,!1,a,g),g=0,a=0,h++):!e&&g<0&&(i+=f.buffer.translateBufferLineToString(h,!1,0,a+1),a=g=f.cols-1,h--);return i+f.buffer.translateBufferLineToString(h,!1,a,g)}function d_(a,b){return cV.ESC+(b?"O":"[")+a}function d0(a,b){a=Math.floor(a);let c="";for(let d=0;d<a;d++)c+=b;return c}var d1=class{constructor(a){this._bufferService=a,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?a%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)-1]:[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[a,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[Math.max(a,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let a=this.selectionStart,b=this.selectionEnd;return!!a&&!!b&&(a[1]>b[1]||a[1]===b[1]&&a[0]>b[0])}handleTrim(a){return this.selectionStart&&(this.selectionStart[1]-=a),this.selectionEnd&&(this.selectionEnd[1]-=a),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function d2(a,b){if(a.start.y>a.end.y)throw Error(`Buffer range end (${a.end.x}, ${a.end.y}) cannot be before start (${a.start.x}, ${a.start.y})`);return b*(a.end.y-a.start.y)+(a.end.x-a.start.x+1)}var d3=RegExp(" ","g"),d4=class extends aW{constructor(a,b,c,d,e,f,g,h,i){super(),this._element=a,this._screenElement=b,this._linkifier=c,this._bufferService=d,this._coreService=e,this._mouseService=f,this._optionsService=g,this._renderService=h,this._coreBrowserService=i,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ak,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new bd),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new bd),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new bd),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new bd),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=a=>this._handleMouseMove(a),this._mouseUpListener=a=>this._handleMouseUp(a),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(a=>this._handleTrim(a)),this._register(this._bufferService.buffers.onBufferActivate(a=>this._handleBufferActivate(a))),this.enable(),this._model=new d1(this._bufferService),this._activeSelectionMode=0,this._register(aT(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(a=>{a.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 a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd;return!!a&&!!b&&(a[0]!==b[0]||a[1]!==b[1])}get selectionText(){let a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd;if(!a||!b)return"";let c=this._bufferService.buffer,d=[];if(3===this._activeSelectionMode){if(a[0]===b[0])return"";let e=a[0]<b[0]?a[0]:b[0],f=a[0]<b[0]?b[0]:a[0];for(let g=a[1];g<=b[1];g++){let a=c.translateBufferLineToString(g,!0,e,f);d.push(a)}}else{let e=a[1]===b[1]?b[0]:void 0;d.push(c.translateBufferLineToString(a[1],!0,a[0],e));for(let e=a[1]+1;e<=b[1]-1;e++){let a=c.lines.get(e),b=c.translateBufferLineToString(e,!0);a?.isWrapped?d[d.length-1]+=b:d.push(b)}if(a[1]!==b[1]){let a=c.lines.get(b[1]),e=c.translateBufferLineToString(b[1],!0,0,b[0]);a&&a.isWrapped?d[d.length-1]+=e:d.push(e)}}return d.map(a=>a.replace(d3," ")).join(dO?`\r
14
+ `).trim(),b=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);bf.register(f,b?.[2]??a,f)}return f},this._event}_removeListener(a){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let b=this._listeners,c=b.indexOf(a);if(-1===c)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,b[c]=void 0;let d=this._deliveryQueue.current===this;if(2*this._size<=b.length){let a=0;for(let c=0;c<b.length;c++)b[c]?b[a++]=b[c]:d&&(this._deliveryQueue.end--,a<this._deliveryQueue.i&&this._deliveryQueue.i--);b.length=a}}_deliver(a,b){if(!a)return;let c=this._options?.onListenerError||aR;try{a.value(b)}catch(a){c(a)}}_deliverQueue(a){let b=a.current._listeners;for(;a.i<a.end;)this._deliver(b[a.i++],a.value);a.reset()}fire(a){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof bk)this._deliver(this._listeners,a);else{let b=this._deliveryQueue;b.enqueue(this,a,this._listeners.length),this._deliverQueue(b)}this._perfMon?.stop()}hasListeners(){return this._size>0}},bm=class{constructor(){this.i=-1,this.end=0}enqueue(a,b,c){this.i=0,this.end=c,this.current=a,this.value=b}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},bn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new bl,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new bl,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(a){return this.mapWindowIdToZoomLevel.get(this.getWindowId(a))??0}setZoomLevel(a,b){if(this.getZoomLevel(b)===a)return;let c=this.getWindowId(b);this.mapWindowIdToZoomLevel.set(c,a),this._onDidChangeZoomLevel.fire(c)}getZoomFactor(a){return this.mapWindowIdToZoomFactor.get(this.getWindowId(a))??1}setZoomFactor(a,b){this.mapWindowIdToZoomFactor.set(this.getWindowId(b),a)}setFullscreen(a,b){if(this.isFullscreen(b)===a)return;let c=this.getWindowId(b);this.mapWindowIdToFullScreen.set(c,a),this._onDidChangeFullscreen.fire(c)}isFullscreen(a){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(a))}getWindowId(a){return a.vscodeWindowId}};bn.INSTANCE=new bn,bn.INSTANCE.onDidChangeZoomLevel,bn.INSTANCE.onDidChangeFullscreen;var bo="object"==typeof navigator?navigator.userAgent:"",bp=bo.indexOf("Firefox")>=0,bq=bo.indexOf("AppleWebKit")>=0,br=bo.indexOf("Chrome")>=0,bs=!br&&bo.indexOf("Safari")>=0;bo.indexOf("Electron/"),bo.indexOf("Android");var bt=!1;if("function"==typeof a4.matchMedia){let a=a4.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),b=a4.matchMedia("(display-mode: fullscreen)");bt=a.matches,bu=a,"string"==typeof bu&&(bu=a4.matchMedia(bu)),bu.addEventListener("change",({matches:a})=>{bt&&b.matches||(bt=a)})}var bu,bv,bw,bx=!1,by=!1,bz=!1,bA=!1,bB=!1,bC="en",bD=globalThis;"u">typeof bD.vscode&&"u">typeof bD.vscode.process?bw=bD.vscode.process:"u">typeof process&&"string"==typeof process?.versions?.node&&(bw=process);var bE="string"==typeof bw?.versions?.electron&&bw?.type==="renderer";if("object"==typeof bw){bx="win32"===bw.platform,by="darwin"===bw.platform,(bz="linux"===bw.platform)&&bw.env.SNAP&&bw.env.SNAP_REVISION,bw.env.CI||bw.env.BUILD_ARTIFACTSTAGINGDIRECTORY,bC="en";let a=bw.env.VSCODE_NLS_CONFIG;if(a)try{let b=JSON.parse(a);b.userLocale,b.osLocale,bC=b.resolvedLanguage||"en",b.languagePack?.translationsConfigFile}catch{}bA=!0}else"object"!=typeof navigator||bE?console.error("Unable to resolve platform."):(bx=(bv=navigator.userAgent).indexOf("Windows")>=0,by=bv.indexOf("Macintosh")>=0,(bv.indexOf("Macintosh")>=0||bv.indexOf("iPad")>=0||bv.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,bz=bv.indexOf("Linux")>=0,bv?.indexOf("Mobi"),bB=!0,bC=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var bF=bx,bG=by,bH=bz,bI=bA;bB&&"function"==typeof bD.importScripts&&bD.origin;var bJ,bK=bv,bL=bC;(bV=bJ||={}).value=function(){return bL},bV.isDefaultVariant=function(){return 2===bL.length?"en"===bL:bL.length>=3&&"e"===bL[0]&&"n"===bL[1]&&"-"===bL[2]},bV.isDefault=function(){return"en"===bL};var bM="function"==typeof bD.postMessage&&!bD.importScripts,bN=(()=>{if(bM){let a=[];bD.addEventListener("message",b=>{if(b.data&&b.data.vscodeScheduleAsyncWork)for(let c=0,d=a.length;c<d;c++){let d=a[c];if(d.id===b.data.vscodeScheduleAsyncWork){a.splice(c,1),d.callback();return}}});let b=0;return c=>{let d=++b;a.push({id:d,callback:c}),bD.postMessage({vscodeScheduleAsyncWork:d},"*")}}return a=>setTimeout(a)})(),bO=!!(bK&&bK.indexOf("Chrome")>=0);bK&&bK.indexOf("Firefox"),!bO&&bK&&bK.indexOf("Safari"),bK&&bK.indexOf("Edg/"),bK&&bK.indexOf("Android");var bP="object"==typeof navigator?navigator:{};bI||document.queryCommandSupported&&document.queryCommandSupported("copy")||bP&&bP.clipboard&&bP.clipboard.writeText,bI||bP&&bP.clipboard&&bP.clipboard.readText,bI||bt||bP.keyboard,"ontouchstart"in a4||bP.maxTouchPoints,a4.PointerEvent&&("ontouchstart"in a4||navigator.maxTouchPoints);var bQ=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(a,b){this._keyCodeToStr[a]=b,this._strToKeyCode[b.toLowerCase()]=a}keyCodeToStr(a){return this._keyCodeToStr[a]}strToKeyCode(a){return this._strToKeyCode[a.toLowerCase()]||0}},bR=new bQ,bS=new bQ,bT=new bQ,bU=Array(230);(bW=bX||={}).toString=function(a){return bR.keyCodeToStr(a)},bW.fromString=function(a){return bR.strToKeyCode(a)},bW.toUserSettingsUS=function(a){return bS.keyCodeToStr(a)},bW.toUserSettingsGeneral=function(a){return bT.keyCodeToStr(a)},bW.fromUserSettings=function(a){return bS.strToKeyCode(a)||bT.strToKeyCode(a)},bW.toElectronAccelerator=function(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return bR.keyCodeToStr(a)};var bV,bW,bX,bY,bZ=class a{constructor(a,b,c,d,e){this.ctrlKey=a,this.shiftKey=b,this.altKey=c,this.metaKey=d,this.keyCode=e}equals(b){return b instanceof a&&this.ctrlKey===b.ctrlKey&&this.shiftKey===b.shiftKey&&this.altKey===b.altKey&&this.metaKey===b.metaKey&&this.keyCode===b.keyCode}getHashCode(){let a=this.ctrlKey?"1":"0",b=this.shiftKey?"1":"0",c=this.altKey?"1":"0",d=this.metaKey?"1":"0";return`K${a}${b}${c}${d}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new b$([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},b$=class{constructor(a){if(0===a.length)throw function(a){return a?Error(`Illegal argument: ${a}`):Error("Illegal argument")}("chords");this.chords=a}getHashCode(){let a="";for(let b=0,c=this.chords.length;b<c;b++)0!==b&&(a+=";"),a+=this.chords[b].getHashCode();return a}equals(a){if(null===a||this.chords.length!==a.chords.length)return!1;for(let b=0;b<this.chords.length;b++)if(!this.chords[b].equals(a.chords[b]))return!1;return!0}},b_=bG?256:2048,b0=bG?2048:256,b1=class{constructor(a){this._standardKeyboardEventBrand=!0,this.browserEvent=a,this.target=a.target,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.altKey=a.altKey,this.metaKey=a.metaKey,this.altGraphKey=a.getModifierState?.("AltGraph"),this.keyCode=function(a){if(a.charCode){let b=String.fromCharCode(a.charCode).toUpperCase();return bX.fromString(b)}let b=a.keyCode;if(3===b)return 7;if(bp)switch(b){case 59:return 85;case 60:if(bH)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(bG)return 57}else if(bq&&(bG&&93===b||!bG&&92===b))return 57;return bU[b]||0}(a),this.code=a.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,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(a){return this._asKeybinding===a}_computeKeybinding(){let a=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(a=this.keyCode);let b=0;return this.ctrlKey&&(b|=b_),this.altKey&&(b|=512),this.shiftKey&&(b|=1024),this.metaKey&&(b|=b0),b|=a}_computeKeyCodeChord(){let a=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(a=this.keyCode),new bZ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,a)}},b2=new WeakMap,b3=class{static getSameOriginWindowChain(a){let b=b2.get(a);if(!b){b=[],b2.set(a,b);let c=a,d;do(d=function(a){if(!a.parent||a.parent===a)return null;try{let b=a.location,c=a.parent.location;if("null"!==b.origin&&"null"!==c.origin&&b.origin!==c.origin)return null}catch{return null}return a.parent}(c))?b.push({window:new WeakRef(c),iframeElement:c.frameElement||null}):b.push({window:new WeakRef(c),iframeElement:null}),c=d;while(c)}return b.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(a,b){if(!b||a===b)return{top:0,left:0};let c=0,d=0;for(let e of this.getSameOriginWindowChain(a)){let a=e.window.deref();if(c+=a?.scrollY??0,d+=a?.scrollX??0,a===b||!e.iframeElement)break;let f=e.iframeElement.getBoundingClientRect();c+=f.top,d+=f.left}return{top:c,left:d}}},b4=class{constructor(a,b){this.timestamp=Date.now(),this.browserEvent=b,this.leftButton=0===b.button,this.middleButton=1===b.button,this.rightButton=2===b.button,this.buttons=b.buttons,this.target=b.target,this.detail=b.detail||1,"dblclick"===b.type&&(this.detail=2),this.ctrlKey=b.ctrlKey,this.shiftKey=b.shiftKey,this.altKey=b.altKey,this.metaKey=b.metaKey,"number"==typeof b.pageX?(this.posx=b.pageX,this.posy=b.pageY):(this.posx=b.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=b.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let c=b3.getPositionOfChildWindowRelativeToAncestorWindow(a,b.view);this.posx-=c.left,this.posy-=c.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},b5=class{constructor(a,b=0,c=0){this.browserEvent=a||null,this.target=a?a.target||a.targetNode||a.srcElement:null,this.deltaY=c,this.deltaX=b;let d=!1;if(br){let a=navigator.userAgent.match(/Chrome\/(\d+)/);d=(a?parseInt(a[1]):123)<=122}if(a){let b=a.view?.devicePixelRatio||1;"u">typeof a.wheelDeltaY?d?this.deltaY=a.wheelDeltaY/(120*b):this.deltaY=a.wheelDeltaY/120:"u">typeof a.VERTICAL_AXIS&&a.axis===a.VERTICAL_AXIS?this.deltaY=-a.detail/3:"wheel"===a.type&&(a.deltaMode===a.DOM_DELTA_LINE?bp&&!bG?this.deltaY=-a.deltaY/3:this.deltaY=-a.deltaY:this.deltaY=-a.deltaY/40),"u">typeof a.wheelDeltaX?bs&&bF?this.deltaX=-(a.wheelDeltaX/120):d?this.deltaX=a.wheelDeltaX/(120*b):this.deltaX=a.wheelDeltaX/120:"u">typeof a.HORIZONTAL_AXIS&&a.axis===a.HORIZONTAL_AXIS?this.deltaX=-a.detail/3:"wheel"===a.type&&(a.deltaMode===a.DOM_DELTA_LINE?bp&&!bG?this.deltaX=-a.deltaX/3:this.deltaX=-a.deltaX:this.deltaX=-a.deltaX/40),0===this.deltaY&&0===this.deltaX&&a.wheelDelta&&(d?this.deltaY=a.wheelDelta/(120*b):this.deltaY=a.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},b6=Object.freeze(function(a,b){let c=setTimeout(a.bind(b),0);return{dispose(){clearTimeout(c)}}});(cY=bY||={}).isCancellationToken=function(a){return a===cY.None||a===cY.Cancelled||a instanceof b7||!!a&&"object"==typeof a&&"boolean"==typeof a.isCancellationRequested&&"function"==typeof a.onCancellationRequested},cY.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:be.None}),cY.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:b6});var b7=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?b6:(this._emitter||(this._emitter=new bl),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var b8=class{constructor(a,b){this._isDisposed=!1,this._token=-1,"function"==typeof a&&"number"==typeof b&&this.setIfNotSet(a,b)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(a,b){if(this._isDisposed)throw new aV("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,a()},b)}setIfNotSet(a,b){if(this._isDisposed)throw new aV("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,a()},b))}},b9=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(a,b,c=globalThis){if(this.isDisposed)throw new aV("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let d=c.setInterval(()=>{a()},b);this.disposable=a_(()=>{c.clearInterval(d),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(cZ=c$||={}).settled=async function(a){let b,c=await Promise.all(a.map(a=>a.then(a=>a,a=>{b||(b=a)})));if("u">typeof b)throw b;return c},cZ.withAsyncBody=function(a){return new Promise(async(b,c)=>{try{await a(b,c)}catch(a){c(a)}})};var ca=class a{static fromArray(b){return new a(a=>{a.emitMany(b)})}static fromPromise(b){return new a(async a=>{a.emitMany(await b)})}static fromPromises(b){return new a(async a=>{await Promise.all(b.map(async b=>a.emitOne(await b)))})}static merge(b){return new a(async a=>{await Promise.all(b.map(async b=>{for await(let c of b)a.emitOne(c)}))})}constructor(a,b){this._state=0,this._results=[],this._error=null,this._onReturn=b,this._onStateChanged=new bl,queueMicrotask(async()=>{let b={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(a(b)),this.resolve()}catch(a){this.reject(a)}finally{b.emitOne=void 0,b.emitMany=void 0,b.reject=void 0}})}[Symbol.asyncIterator](){let a=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(a<this._results.length)return{done:!1,value:this._results[a++]};if(1===this._state)return{done:!0,value:void 0};await be.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(b,c){return new a(async a=>{for await(let d of b)a.emitOne(c(d))})}map(b){return a.map(this,b)}static filter(b,c){return new a(async a=>{for await(let d of b)c(d)&&a.emitOne(d)})}filter(b){return a.filter(this,b)}static coalesce(b){return a.filter(b,a=>!!a)}coalesce(){return a.coalesce(this)}static async toPromise(a){let b=[];for await(let c of a)b.push(c);return b}toPromise(){return a.toPromise(this)}emitOne(a){0===this._state&&(this._results.push(a),this._onStateChanged.fire())}emitMany(a){0===this._state&&(this._results=this._results.concat(a),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(a){0===this._state&&(this._state=2,this._error=a,this._onStateChanged.fire())}};ca.EMPTY=ca.fromArray([]);function cb(a,b){return(b<<5)-b+a|0}function cc(a,b){b=cb(149417,b);for(let c=0,d=a.length;c<d;c++)b=cb(a.charCodeAt(c),b);return b}new DataView(new ArrayBuffer(320));var{registerWindow:cd,getWindow:ce,getDocument:cf,getWindows:cg,getWindowsCount:ch,getWindowId:ci,getWindowById:cj,hasWindow:ck,onDidRegisterWindow:cl,onWillUnregisterWindow:cm,onDidUnregisterWindow:cn}=(b=new Map,c={window:a4,disposables:new a1},b.set(a4.vscodeWindowId,c),d=new bl,e=new bl,f=new bl,{onDidRegisterWindow:d.event,onWillUnregisterWindow:f.event,onDidUnregisterWindow:e.event,registerWindow(a){if(b.has(a.vscodeWindowId))return a2.None;let c=new a1,g={window:a,disposables:c.add(new a1)};return b.set(a.vscodeWindowId,g),c.add(a_(()=>{b.delete(a.vscodeWindowId),e.fire(a)})),c.add(cp(a,cu.BEFORE_UNLOAD,()=>{f.fire(a)})),d.fire(g),c},getWindows:()=>b.values(),getWindowsCount:()=>b.size,getWindowId:a=>a.vscodeWindowId,hasWindow:a=>b.has(a),getWindowById:function(a,d){return("number"==typeof a?b.get(a):void 0)??(d?c:void 0)},getWindow:a=>a?.ownerDocument?.defaultView?a.ownerDocument.defaultView.window:a?.view?a.view.window:a4,getDocument:a=>ce(a).document}),co=class{constructor(a,b,c,d){this._node=a,this._type=b,this._handler=c,this._options=d||!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 cp(a,b,c,d){return new co(a,b,c,d)}var cq=function(a,b,c,d){var e;let f=c;return"click"===b||"mousedown"===b||"contextmenu"===b?(e=ce(a),f=function(a){return c(new b4(e,a))}):("keydown"===b||"keypress"===b||"keyup"===b)&&(f=function(a){return c(new b1(a))}),cp(a,b,f,d)},cr=class extends b9{constructor(a){super(),this.defaultTarget=a&&ce(a)}cancelAndSet(a,b,c){return super.cancelAndSet(a,b,c??this.defaultTarget)}},cs=class{constructor(a,b=0){this._runner=a,this.priority=b,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(a){aR(a)}}static sort(a,b){return b.priority-a.priority}};g=new Map,h=new Map,i=new Map,j=new Map,c_=(a,b,c=0)=>{let d=ci(a),e=new cs(b,c),f=g.get(d);return f||(f=[],g.set(d,f)),f.push(e),i.get(d)||(i.set(d,!0),a.requestAnimationFrame(()=>(a=>{i.set(a,!1);let b=g.get(a)??[];for(h.set(a,b),g.set(a,[]),j.set(a,!0);b.length>0;)b.sort(cs.sort),b.shift().execute();j.set(a,!1)})(d))),e};var ct=class a{constructor(a,b){this.width=a,this.height=b}with(b=this.width,c=this.height){return b!==this.width||c!==this.height?new a(b,c):this}static is(a){return"object"==typeof a&&"number"==typeof a.height&&"number"==typeof a.width}static lift(b){return b instanceof a?b:new a(b.width,b.height)}static equals(a,b){return a===b||!!a&&!!b&&a.width===b.width&&a.height===b.height}};ct.None=new ct(0,0),new class{constructor(){this.mutationObservers=new Map}observe(a,b,c){let d=this.mutationObservers.get(a);d||(d=new Map,this.mutationObservers.set(a,d));let e=function a(b,c){switch(typeof b){case"object":var d,e,f,g;return null===b?cb(349,c):Array.isArray(b)?(d=b,e=cb(104579,e=c),d.reduce((b,c)=>a(c,b),e)):(f=b,g=cb(181387,g=c),Object.keys(f).sort().reduce((b,c)=>(b=cc(c,b),a(f[c],b)),g));case"string":return cc(b,c);case"boolean":return cb(b?433:863,c);case"number":return cb(b,c);case"undefined":return cb(937,c);default:return cb(617,c)}}(c,0),f=d.get(e);if(f)f.users+=1;else{let g=new bl,h=new MutationObserver(a=>g.fire(a));h.observe(a,c);let i=f={users:1,observer:h,onDidMutate:g.event};b.add(a_(()=>{i.users-=1,0===i.users&&(g.dispose(),h.disconnect(),d?.delete(e),d?.size===0&&this.mutationObservers.delete(a))})),d.set(e,f)}return f.onDidMutate}};var cu={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"},cv=class{constructor(a){this.domNode=a,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(a){let b=cw(a);this._maxWidth!==b&&(this._maxWidth=b,this.domNode.style.maxWidth=this._maxWidth)}setWidth(a){let b=cw(a);this._width!==b&&(this._width=b,this.domNode.style.width=this._width)}setHeight(a){let b=cw(a);this._height!==b&&(this._height=b,this.domNode.style.height=this._height)}setTop(a){let b=cw(a);this._top!==b&&(this._top=b,this.domNode.style.top=this._top)}setLeft(a){let b=cw(a);this._left!==b&&(this._left=b,this.domNode.style.left=this._left)}setBottom(a){let b=cw(a);this._bottom!==b&&(this._bottom=b,this.domNode.style.bottom=this._bottom)}setRight(a){let b=cw(a);this._right!==b&&(this._right=b,this.domNode.style.right=this._right)}setPaddingTop(a){let b=cw(a);this._paddingTop!==b&&(this._paddingTop=b,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(a){let b=cw(a);this._paddingLeft!==b&&(this._paddingLeft=b,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(a){let b=cw(a);this._paddingBottom!==b&&(this._paddingBottom=b,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(a){let b=cw(a);this._paddingRight!==b&&(this._paddingRight=b,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(a){this._fontFamily!==a&&(this._fontFamily=a,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(a){this._fontWeight!==a&&(this._fontWeight=a,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(a){let b=cw(a);this._fontSize!==b&&(this._fontSize=b,this.domNode.style.fontSize=this._fontSize)}setFontStyle(a){this._fontStyle!==a&&(this._fontStyle=a,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(a){this._fontFeatureSettings!==a&&(this._fontFeatureSettings=a,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(a){this._fontVariationSettings!==a&&(this._fontVariationSettings=a,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(a){this._textDecoration!==a&&(this._textDecoration=a,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(a){let b=cw(a);this._lineHeight!==b&&(this._lineHeight=b,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(a){let b=cw(a);this._letterSpacing!==b&&(this._letterSpacing=b,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(a){this._className!==a&&(this._className=a,this.domNode.className=this._className)}toggleClassName(a,b){this.domNode.classList.toggle(a,b),this._className=this.domNode.className}setDisplay(a){this._display!==a&&(this._display=a,this.domNode.style.display=this._display)}setPosition(a){this._position!==a&&(this._position=a,this.domNode.style.position=this._position)}setVisibility(a){this._visibility!==a&&(this._visibility=a,this.domNode.style.visibility=this._visibility)}setColor(a){this._color!==a&&(this._color=a,this.domNode.style.color=this._color)}setBackgroundColor(a){this._backgroundColor!==a&&(this._backgroundColor=a,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(a){this._layerHint!==a&&(this._layerHint=a,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(a){this._boxShadow!==a&&(this._boxShadow=a,this.domNode.style.boxShadow=a)}setContain(a){this._contain!==a&&(this._contain=a,this.domNode.style.contain=this._contain)}setAttribute(a,b){this.domNode.setAttribute(a,b)}removeAttribute(a){this.domNode.removeAttribute(a)}appendChild(a){this.domNode.appendChild(a.domNode)}removeChild(a){this.domNode.removeChild(a.domNode)}};function cw(a){return"number"==typeof a?`${a}px`:a}function cx(a){return new cv(a)}var cy=class{constructor(){this._hooks=new a1,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(a,b){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let c=this._onStopCallback;this._onStopCallback=null,a&&c&&c(b)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(a,b,c,d,e){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=d,this._onStopCallback=e;let f=a;try{a.setPointerCapture(b),this._hooks.add(a_(()=>{try{a.releasePointerCapture(b)}catch{}}))}catch{f=ce(a)}this._hooks.add(cp(f,cu.POINTER_MOVE,a=>{a.buttons!==c?this.stopMonitoring(!0):(a.preventDefault(),this._pointerMoveCallback(a))})),this._hooks.add(cp(f,cu.POINTER_UP,a=>this.stopMonitoring(!0)))}};(k=c0||={}).Tap="-xterm-gesturetap",k.Change="-xterm-gesturechange",k.Start="-xterm-gesturestart",k.End="-xterm-gesturesend",k.Contextmenu="-xterm-gesturecontextmenu";var cz=class a extends a2{constructor(){super(),this.dispatched=!1,this.targets=new a6,this.ignoreTargets=new a6,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(be.runAndSubscribe(cl,({window:a,disposables:b})=>{b.add(cp(a.document,"touchstart",a=>this.onTouchStart(a),{passive:!1})),b.add(cp(a.document,"touchend",b=>this.onTouchEnd(a,b))),b.add(cp(a.document,"touchmove",a=>this.onTouchMove(a),{passive:!1}))},{window:a4,disposables:this._store}))}static addTarget(b){return a.isTouchDevice()?(a.INSTANCE||(a.INSTANCE=new a),a_(a.INSTANCE.targets.push(b))):a2.None}static ignoreTarget(b){return a.isTouchDevice()?(a.INSTANCE||(a.INSTANCE=new a),a_(a.INSTANCE.ignoreTargets.push(b))):a2.None}static isTouchDevice(){return"ontouchstart"in a4||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(a){let b=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let c=0,d=a.targetTouches.length;c<d;c++){let d=a.targetTouches.item(c);this.activeTouches[d.identifier]={id:d.identifier,initialTarget:d.target,initialTimeStamp:b,initialPageX:d.pageX,initialPageY:d.pageY,rollingTimestamps:[b],rollingPageX:[d.pageX],rollingPageY:[d.pageY]};let e=this.newGestureEvent(c0.Start,d.target);e.pageX=d.pageX,e.pageY=d.pageY,this.dispatchEvent(e)}this.dispatched&&(a.preventDefault(),a.stopPropagation(),this.dispatched=!1)}onTouchEnd(b,c){let d=Date.now(),e=Object.keys(this.activeTouches).length;for(let f=0,g=c.changedTouches.length;f<g;f++){let g=c.changedTouches.item(f);if(!this.activeTouches.hasOwnProperty(String(g.identifier))){console.warn("move of an UNKNOWN touch",g);continue}let h=this.activeTouches[g.identifier],i=Date.now()-h.initialTimeStamp;if(i<a.HOLD_DELAY&&30>Math.abs(h.initialPageX-aW(h.rollingPageX))&&30>Math.abs(h.initialPageY-aW(h.rollingPageY))){let a=this.newGestureEvent(c0.Tap,h.initialTarget);a.pageX=aW(h.rollingPageX),a.pageY=aW(h.rollingPageY),this.dispatchEvent(a)}else if(i>=a.HOLD_DELAY&&30>Math.abs(h.initialPageX-aW(h.rollingPageX))&&30>Math.abs(h.initialPageY-aW(h.rollingPageY))){let a=this.newGestureEvent(c0.Contextmenu,h.initialTarget);a.pageX=aW(h.rollingPageX),a.pageY=aW(h.rollingPageY),this.dispatchEvent(a)}else if(1===e){let a=aW(h.rollingPageX),c=aW(h.rollingPageY),e=aW(h.rollingTimestamps)-h.rollingTimestamps[0],f=a-h.rollingPageX[0],g=c-h.rollingPageY[0],i=[...this.targets].filter(a=>h.initialTarget instanceof Node&&a.contains(h.initialTarget));this.inertia(b,i,d,Math.abs(f)/e,f>0?1:-1,a,Math.abs(g)/e,g>0?1:-1,c)}this.dispatchEvent(this.newGestureEvent(c0.End,h.initialTarget)),delete this.activeTouches[g.identifier]}this.dispatched&&(c.preventDefault(),c.stopPropagation(),this.dispatched=!1)}newGestureEvent(a,b){let c=document.createEvent("CustomEvent");return c.initEvent(a,!1,!0),c.initialTarget=b,c.tapCount=0,c}dispatchEvent(b){if(b.type===c0.Tap){let c=new Date().getTime(),d=0;d=c-this._lastSetTapCountTime>a.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=c,b.tapCount=d}else(b.type===c0.Change||b.type===c0.Contextmenu)&&(this._lastSetTapCountTime=0);if(b.initialTarget instanceof Node){for(let a of this.ignoreTargets)if(a.contains(b.initialTarget))return;let a=[];for(let c of this.targets)if(c.contains(b.initialTarget)){let d=0,e=b.initialTarget;for(;e&&e!==c;)d++,e=e.parentElement;a.push([d,c])}for(let[c,d]of(a.sort((a,b)=>a[0]-b[0]),a))d.dispatchEvent(b),this.dispatched=!0}}inertia(b,c,d,e,f,g,h,i,j){this.handle=c_(b,()=>{let k=Date.now(),l=k-d,m=0,n=0,o=!0;e+=a.SCROLL_FRICTION*l,h+=a.SCROLL_FRICTION*l,e>0&&(o=!1,m=f*e*l),h>0&&(o=!1,n=i*h*l);let p=this.newGestureEvent(c0.Change);p.translationX=m,p.translationY=n,c.forEach(a=>a.dispatchEvent(p)),o||this.inertia(b,c,k,e,f,g+m,h,i,j+n)})}onTouchMove(a){let b=Date.now();for(let c=0,d=a.changedTouches.length;c<d;c++){let d=a.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("end of an UNKNOWN touch",d);continue}let e=this.activeTouches[d.identifier],f=this.newGestureEvent(c0.Change,e.initialTarget);f.translationX=d.pageX-aW(e.rollingPageX),f.translationY=d.pageY-aW(e.rollingPageY),f.pageX=d.pageX,f.pageY=d.pageY,this.dispatchEvent(f),e.rollingPageX.length>3&&(e.rollingPageX.shift(),e.rollingPageY.shift(),e.rollingTimestamps.shift()),e.rollingPageX.push(d.pageX),e.rollingPageY.push(d.pageY),e.rollingTimestamps.push(b)}this.dispatched&&(a.preventDefault(),a.stopPropagation(),this.dispatched=!1)}};cz.SCROLL_FRICTION=-.005,cz.HOLD_DELAY=700,cz.CLEAR_TAP_COUNT_TIME=400,af([function(a,b,c){let d=null,e=null;if("function"==typeof c.value?(d="value",0!==(e=c.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof c.get&&(d="get",e=c.get),!e)throw Error("not supported");let f=`$memoize$${b}`;c[d]=function(...a){return this.hasOwnProperty(f)||Object.defineProperty(this,f,{configurable:!1,enumerable:!1,writable:!1,value:e.apply(this,a)}),this[f]}}],cz,"isTouchDevice",1);var cA=class extends a2{onclick(a,b){this._register(cp(a,cu.CLICK,c=>b(new b4(ce(a),c))))}onmousedown(a,b){this._register(cp(a,cu.MOUSE_DOWN,c=>b(new b4(ce(a),c))))}onmouseover(a,b){this._register(cp(a,cu.MOUSE_OVER,c=>b(new b4(ce(a),c))))}onmouseleave(a,b){this._register(cp(a,cu.MOUSE_LEAVE,c=>b(new b4(ce(a),c))))}onkeydown(a,b){this._register(cp(a,cu.KEY_DOWN,a=>b(new b1(a))))}onkeyup(a,b){this._register(cp(a,cu.KEY_UP,a=>b(new b1(a))))}oninput(a,b){this._register(cp(a,cu.INPUT,b))}onblur(a,b){this._register(cp(a,cu.BLUR,b))}onfocus(a,b){this._register(cp(a,cu.FOCUS,b))}onchange(a,b){this._register(cp(a,cu.CHANGE,b))}ignoreGesture(a){return cz.ignoreTarget(a)}},cB=class extends cA{constructor(a){super(),this._onActivate=a.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=a.bgWidth+"px",this.bgDomNode.style.height=a.bgHeight+"px","u">typeof a.top&&(this.bgDomNode.style.top="0px"),"u">typeof a.left&&(this.bgDomNode.style.left="0px"),"u">typeof a.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof a.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=a.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof a.top&&(this.domNode.style.top=a.top+"px"),"u">typeof a.left&&(this.domNode.style.left=a.left+"px"),"u">typeof a.bottom&&(this.domNode.style.bottom=a.bottom+"px"),"u">typeof a.right&&(this.domNode.style.right=a.right+"px"),this._pointerMoveMonitor=this._register(new cy),this._register(cq(this.bgDomNode,cu.POINTER_DOWN,a=>this._arrowPointerDown(a))),this._register(cq(this.domNode,cu.POINTER_DOWN,a=>this._arrowPointerDown(a))),this._pointerdownRepeatTimer=this._register(new cr),this._pointerdownScheduleRepeatTimer=this._register(new b8)}_arrowPointerDown(a){if(!a.target||!(a.target instanceof Element))return;let b=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ce(a))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(b,200),this._pointerMoveMonitor.startMonitoring(a.target,a.pointerId,a.buttons,a=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),a.preventDefault()}},cC=class a{constructor(a,b,c,d,e,f,g){this._forceIntegerValues=a,this._scrollStateBrand=void 0,this._forceIntegerValues&&(b|=0,c|=0,d|=0,e|=0,f|=0,g|=0),this.rawScrollLeft=d,this.rawScrollTop=g,b<0&&(b=0),d+b>c&&(d=c-b),d<0&&(d=0),e<0&&(e=0),g+e>f&&(g=f-e),g<0&&(g=0),this.width=b,this.scrollWidth=c,this.scrollLeft=d,this.height=e,this.scrollHeight=f,this.scrollTop=g}equals(a){return this.rawScrollLeft===a.rawScrollLeft&&this.rawScrollTop===a.rawScrollTop&&this.width===a.width&&this.scrollWidth===a.scrollWidth&&this.scrollLeft===a.scrollLeft&&this.height===a.height&&this.scrollHeight===a.scrollHeight&&this.scrollTop===a.scrollTop}withScrollDimensions(b,c){return new a(this._forceIntegerValues,"u">typeof b.width?b.width:this.width,"u">typeof b.scrollWidth?b.scrollWidth:this.scrollWidth,c?this.rawScrollLeft:this.scrollLeft,"u">typeof b.height?b.height:this.height,"u">typeof b.scrollHeight?b.scrollHeight:this.scrollHeight,c?this.rawScrollTop:this.scrollTop)}withScrollPosition(b){return new a(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof b.scrollLeft?b.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof b.scrollTop?b.scrollTop:this.rawScrollTop)}createScrollEvent(a,b){let c=this.width!==a.width,d=this.scrollWidth!==a.scrollWidth,e=this.scrollLeft!==a.scrollLeft,f=this.height!==a.height,g=this.scrollHeight!==a.scrollHeight,h=this.scrollTop!==a.scrollTop;return{inSmoothScrolling:b,oldWidth:a.width,oldScrollWidth:a.scrollWidth,oldScrollLeft:a.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:a.height,oldScrollHeight:a.scrollHeight,oldScrollTop:a.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:c,scrollWidthChanged:d,scrollLeftChanged:e,heightChanged:f,scrollHeightChanged:g,scrollTopChanged:h}}},cD=class extends a2{constructor(a){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new bl),this.onScroll=this._onScroll.event,this._smoothScrollDuration=a.smoothScrollDuration,this._scheduleAtNextAnimationFrame=a.scheduleAtNextAnimationFrame,this._state=new cC(a.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(a){this._smoothScrollDuration=a}validateScrollPosition(a){return this._state.withScrollPosition(a)}getScrollDimensions(){return this._state}setScrollDimensions(a,b){let c=this._state.withScrollDimensions(a,b);this._setState(c,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(a){let b=this._state.withScrollPosition(a);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(b,!1)}setScrollPositionSmooth(a,b){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(a);if(this._smoothScrolling){let c;a={scrollLeft:typeof a.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:a.scrollLeft,scrollTop:typeof a.scrollTop>"u"?this._smoothScrolling.to.scrollTop:a.scrollTop};let d=this._state.withScrollPosition(a);if(this._smoothScrolling.to.scrollLeft===d.scrollLeft&&this._smoothScrolling.to.scrollTop===d.scrollTop)return;c=b?new cG(this._smoothScrolling.from,d,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,d,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=c}else{let b=this._state.withScrollPosition(a);this._smoothScrolling=cG.start(this._state,b,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 a=this._smoothScrolling.tick(),b=this._state.withScrollPosition(a);if(this._setState(b,!0),this._smoothScrolling){if(a.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(a,b){let c=this._state;c.equals(a)||(this._state=a,this._onScroll.fire(this._state.createScrollEvent(c,b)))}},cE=class{constructor(a,b,c){this.scrollLeft=a,this.scrollTop=b,this.isDone=c}};function cF(a,b){let c=b-a;return function(b){return a+c*(1-Math.pow(1-b,3))}}var cG=class a{constructor(a,b,c,d){this.from=a,this.to=b,this.duration=d,this.startTime=c,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(a,b,c){if(Math.abs(a-b)>2.5*c){var d,e;let f,g;return a<b?(f=a+.75*c,g=b-.75*c):(f=a-.75*c,g=b+.75*c),d=cF(a,f),e=cF(g,b),function(a){return a<.33?d(a/.33):e((a-.33)/(1-.33))}}return cF(a,b)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(a){this.to=a.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(a){let b=(a-this.startTime)/this.duration;return b<1?new cE(this.scrollLeft(b),this.scrollTop(b),!1):new cE(this.to.scrollLeft,this.to.scrollTop,!0)}combine(b,c,d){return a.start(b,c,d)}static start(b,c,d){return d+=10,new a(b,c,Date.now()-10,d)}},cH=class extends a2{constructor(a,b,c){super(),this._visibility=a,this._visibleClassName=b,this._invisibleClassName=c,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new b8)}setVisibility(a){this._visibility!==a&&(this._visibility=a,this._updateShouldBeVisible())}setShouldBeVisible(a){this._rawShouldBeVisible=a,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let a=this._applyVisibilitySetting();this._shouldBeVisible!==a&&(this._shouldBeVisible=a,this.ensureVisibility())}setIsNeeded(a){this._isNeeded!==a&&(this._isNeeded=a,this.ensureVisibility())}setDomNode(a){this._domNode=a,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(a){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(a?" fade":"")))}},cI=class extends cA{constructor(a){super(),this._lazyRender=a.lazyRender,this._host=a.host,this._scrollable=a.scrollable,this._scrollByPage=a.scrollByPage,this._scrollbarState=a.scrollbarState,this._visibilityController=this._register(new cH(a.visibility,"visible scrollbar "+a.extraScrollbarClassName,"invisible scrollbar "+a.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new cy),this._shouldRender=!0,this.domNode=cx(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(cp(this.domNode.domNode,cu.POINTER_DOWN,a=>this._domNodePointerDown(a)))}_createArrow(a){let b=this._register(new cB(a));this.domNode.domNode.appendChild(b.bgDomNode),this.domNode.domNode.appendChild(b.domNode)}_createSlider(a,b,c,d){this.slider=cx(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(a),this.slider.setLeft(b),"number"==typeof c&&this.slider.setWidth(c),"number"==typeof d&&this.slider.setHeight(d),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(cp(this.slider.domNode,cu.POINTER_DOWN,a=>{0===a.button&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(a){return this._scrollbarState.setVisibleSize(a)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(a){return this._scrollbarState.setScrollSize(a)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(a){return this._scrollbarState.setScrollPosition(a)&&(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(a){a.target===this.domNode.domNode&&this._onPointerDown(a)}delegatePointerDown(a){let b=this.domNode.domNode.getClientRects()[0].top,c=b+this._scrollbarState.getSliderPosition(),d=b+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),e=this._sliderPointerPosition(a);c<=e&&e<=d?0===a.button&&(a.preventDefault(),this._sliderPointerDown(a)):this._onPointerDown(a)}_onPointerDown(a){let b,c;if(a.target===this.domNode.domNode&&"number"==typeof a.offsetX&&"number"==typeof a.offsetY)b=a.offsetX,c=a.offsetY;else{var d;let e,f,g=(e=(d=this.domNode.domNode).getBoundingClientRect(),f=ce(d),{left:e.left+f.scrollX,top:e.top+f.scrollY,width:e.width,height:e.height});b=a.pageX-g.left,c=a.pageY-g.top}let e=this._pointerDownRelativePosition(b,c);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(e):this._scrollbarState.getDesiredScrollPositionFromOffset(e)),0===a.button&&(a.preventDefault(),this._sliderPointerDown(a))}_sliderPointerDown(a){if(!a.target||!(a.target instanceof Element))return;let b=this._sliderPointerPosition(a),c=this._sliderOrthogonalPointerPosition(a),d=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(a.target,a.pointerId,a.buttons,a=>{let e=Math.abs(this._sliderOrthogonalPointerPosition(a)-c);if(bF&&e>140)return void this._setDesiredScrollPositionNow(d.getScrollPosition());let f=this._sliderPointerPosition(a)-b;this._setDesiredScrollPositionNow(d.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(a){let b={};this.writeScrollPosition(b,a),this._scrollable.setScrollPositionNow(b)}updateScrollbarSize(a){this._updateScrollbarSize(a),this._scrollbarState.setScrollbarSize(a),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},cJ=class a{constructor(a,b,c,d,e,f){this._scrollbarSize=Math.round(b),this._oppositeScrollbarSize=Math.round(c),this._arrowSize=Math.round(a),this._visibleSize=d,this._scrollSize=e,this._scrollPosition=f,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new a(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(a){let b=Math.round(a);return this._visibleSize!==b&&(this._visibleSize=b,this._refreshComputedValues(),!0)}setScrollSize(a){let b=Math.round(a);return this._scrollSize!==b&&(this._scrollSize=b,this._refreshComputedValues(),!0)}setScrollPosition(a){let b=Math.round(a);return this._scrollPosition!==b&&(this._scrollPosition=b,this._refreshComputedValues(),!0)}setScrollbarSize(a){this._scrollbarSize=Math.round(a)}setOppositeScrollbarSize(a){this._oppositeScrollbarSize=Math.round(a)}static _computeValues(a,b,c,d,e){let f=Math.max(0,c-a),g=Math.max(0,f-2*b),h=d>0&&d>c;if(!h)return{computedAvailableSize:Math.round(f),computedIsNeeded:h,computedSliderSize:Math.round(g),computedSliderRatio:0,computedSliderPosition:0};let i=Math.round(Math.max(20,Math.floor(c*g/d))),j=(g-i)/(d-c);return{computedAvailableSize:Math.round(f),computedIsNeeded:h,computedSliderSize:Math.round(i),computedSliderRatio:j,computedSliderPosition:Math.round(e*j)}}_refreshComputedValues(){let b=a._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=b.computedAvailableSize,this._computedIsNeeded=b.computedIsNeeded,this._computedSliderSize=b.computedSliderSize,this._computedSliderRatio=b.computedSliderRatio,this._computedSliderPosition=b.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(a){return this._computedIsNeeded?Math.round((a-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(a){if(!this._computedIsNeeded)return 0;let b=a-this._arrowSize,c=this._scrollPosition;return b<this._computedSliderPosition?c-=this._visibleSize:c+=this._visibleSize,c}getDesiredScrollPositionFromDelta(a){return this._computedIsNeeded?Math.round((this._computedSliderPosition+a)/this._computedSliderRatio):0}},cK=class extends cI{constructor(a,b,c){let d=a.getScrollDimensions(),e=a.getCurrentScrollPosition();if(super({lazyRender:b.lazyRender,host:c,scrollbarState:new cJ(b.horizontalHasArrows?b.arrowSize:0,2===b.horizontal?0:b.horizontalScrollbarSize,2===b.vertical?0:b.verticalScrollbarSize,d.width,d.scrollWidth,e.scrollLeft),visibility:b.horizontal,extraScrollbarClassName:"horizontal",scrollable:a,scrollByPage:b.scrollByPage}),b.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((b.horizontalScrollbarSize-b.horizontalSliderSize)/2),0,void 0,b.horizontalSliderSize)}_updateSlider(a,b){this.slider.setWidth(a),this.slider.setLeft(b)}_renderDomNode(a,b){this.domNode.setWidth(a),this.domNode.setHeight(b),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(a){return this._shouldRender=this._onElementScrollSize(a.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(a.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(a.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(a,b){return a}_sliderPointerPosition(a){return a.pageX}_sliderOrthogonalPointerPosition(a){return a.pageY}_updateScrollbarSize(a){this.slider.setHeight(a)}writeScrollPosition(a,b){a.scrollLeft=b}updateOptions(a){this.updateScrollbarSize(2===a.horizontal?0:a.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===a.vertical?0:a.verticalScrollbarSize),this._visibilityController.setVisibility(a.horizontal),this._scrollByPage=a.scrollByPage}},cL=class extends cI{constructor(a,b,c){let d=a.getScrollDimensions(),e=a.getCurrentScrollPosition();if(super({lazyRender:b.lazyRender,host:c,scrollbarState:new cJ(b.verticalHasArrows?b.arrowSize:0,2===b.vertical?0:b.verticalScrollbarSize,0,d.height,d.scrollHeight,e.scrollTop),visibility:b.vertical,extraScrollbarClassName:"vertical",scrollable:a,scrollByPage:b.scrollByPage}),b.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((b.verticalScrollbarSize-b.verticalSliderSize)/2),b.verticalSliderSize,void 0)}_updateSlider(a,b){this.slider.setHeight(a),this.slider.setTop(b)}_renderDomNode(a,b){this.domNode.setWidth(b),this.domNode.setHeight(a),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(a){return this._shouldRender=this._onElementScrollSize(a.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(a.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(a.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(a,b){return b}_sliderPointerPosition(a){return a.pageY}_sliderOrthogonalPointerPosition(a){return a.pageX}_updateScrollbarSize(a){this.slider.setWidth(a)}writeScrollPosition(a,b){a.scrollTop=b}updateOptions(a){this.updateScrollbarSize(2===a.vertical?0:a.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(a.vertical),this._scrollByPage=a.scrollByPage}},cM=class{constructor(a,b,c){this.timestamp=a,this.deltaX=b,this.deltaY=c,this.score=0}},cN=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let a=1,b=0,c=1,d=this._rear;for(;;){let e=d===this._front?a:Math.pow(2,-c);if(a-=e,b+=this._memory[d].score*e,d===this._front)break;d=(this._capacity+d-1)%this._capacity,c++}return b<=.5}acceptStandardWheelEvent(a){if(br){var b;let c=(b=ce(a.browserEvent),bn.INSTANCE.getZoomFactor(b));this.accept(Date.now(),a.deltaX*c,a.deltaY*c)}else this.accept(Date.now(),a.deltaX,a.deltaY)}accept(a,b,c){let d=null,e=new cM(a,b,c);-1===this._front&&-1===this._rear?(this._memory[0]=e,this._front=0,this._rear=0):(d=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]=e),e.score=this._computeScore(e,d)}_computeScore(a,b){if(Math.abs(a.deltaX)>0&&Math.abs(a.deltaY)>0)return 1;let c=.5;if(this._isAlmostInt(a.deltaX)&&this._isAlmostInt(a.deltaY)||(c+=.25),b){let d=Math.abs(a.deltaX),e=Math.abs(a.deltaY),f=Math.abs(b.deltaX),g=Math.abs(b.deltaY),h=Math.max(Math.min(d,f),1),i=Math.max(Math.min(e,g),1),j=Math.max(e,g);Math.max(d,f)%h==0&&j%i==0&&(c-=.5)}return Math.min(Math.max(c,0),1)}_isAlmostInt(a){return .01>Math.abs(Math.round(a)-a)}};cN.INSTANCE=new cN;var cO=class extends cA{constructor(a,b,c){super(),this._onScroll=this._register(new bl),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new bl),this.onWillScroll=this._onWillScroll.event,this._options=function(a){let b={lazyRender:"u">typeof a.lazyRender&&a.lazyRender,className:"u">typeof a.className?a.className:"",useShadows:!("u">typeof a.useShadows)||a.useShadows,handleMouseWheel:!("u">typeof a.handleMouseWheel)||a.handleMouseWheel,flipAxes:"u">typeof a.flipAxes&&a.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof a.consumeMouseWheelIfScrollbarIsNeeded&&a.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof a.alwaysConsumeMouseWheel&&a.alwaysConsumeMouseWheel,scrollYToX:"u">typeof a.scrollYToX&&a.scrollYToX,mouseWheelScrollSensitivity:"u">typeof a.mouseWheelScrollSensitivity?a.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof a.fastScrollSensitivity?a.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof a.scrollPredominantAxis)||a.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof a.mouseWheelSmoothScroll)||a.mouseWheelSmoothScroll,arrowSize:"u">typeof a.arrowSize?a.arrowSize:11,listenOnDomNode:"u">typeof a.listenOnDomNode?a.listenOnDomNode:null,horizontal:"u">typeof a.horizontal?a.horizontal:1,horizontalScrollbarSize:"u">typeof a.horizontalScrollbarSize?a.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof a.horizontalSliderSize?a.horizontalSliderSize:0,horizontalHasArrows:"u">typeof a.horizontalHasArrows&&a.horizontalHasArrows,vertical:"u">typeof a.vertical?a.vertical:1,verticalScrollbarSize:"u">typeof a.verticalScrollbarSize?a.verticalScrollbarSize:10,verticalHasArrows:"u">typeof a.verticalHasArrows&&a.verticalHasArrows,verticalSliderSize:"u">typeof a.verticalSliderSize?a.verticalSliderSize:0,scrollByPage:"u">typeof a.scrollByPage&&a.scrollByPage};return b.horizontalSliderSize="u">typeof a.horizontalSliderSize?a.horizontalSliderSize:b.horizontalScrollbarSize,b.verticalSliderSize="u">typeof a.verticalSliderSize?a.verticalSliderSize:b.verticalScrollbarSize,bG&&(b.className+=" mac"),b}(b),this._scrollable=c,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let d={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new cL(this._scrollable,this._options,d)),this._horizontalScrollbar=this._register(new cK(this._scrollable,this._options,d)),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(a),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=cx(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=cx(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=cx(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,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new b8),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=a$(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(a){this._verticalScrollbar.delegatePointerDown(a)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(a){this._scrollable.setScrollDimensions(a,!1)}updateClassName(a){this._options.className=a,bG&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(a){"u">typeof a.handleMouseWheel&&(this._options.handleMouseWheel=a.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof a.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=a.mouseWheelScrollSensitivity),"u">typeof a.fastScrollSensitivity&&(this._options.fastScrollSensitivity=a.fastScrollSensitivity),"u">typeof a.scrollPredominantAxis&&(this._options.scrollPredominantAxis=a.scrollPredominantAxis),"u">typeof a.horizontal&&(this._options.horizontal=a.horizontal),"u">typeof a.vertical&&(this._options.vertical=a.vertical),"u">typeof a.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=a.horizontalScrollbarSize),"u">typeof a.verticalScrollbarSize&&(this._options.verticalScrollbarSize=a.verticalScrollbarSize),"u">typeof a.scrollByPage&&(this._options.scrollByPage=a.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(a){this._revealOnScroll=a}delegateScrollFromMouseWheelEvent(a){this._onMouseWheel(new b5(a))}_setListeningToMouseWheel(a){if(this._mouseWheelToDispose.length>0!==a&&(this._mouseWheelToDispose=a$(this._mouseWheelToDispose),a)){let a=a=>{this._onMouseWheel(new b5(a))};this._mouseWheelToDispose.push(cp(this._listenOnDomNode,cu.MOUSE_WHEEL,a,{passive:!1}))}}_onMouseWheel(a){if(a.browserEvent?.defaultPrevented)return;let b=cN.INSTANCE;b.acceptStandardWheelEvent(a);let c=!1;if(a.deltaY||a.deltaX){let d=a.deltaY*this._options.mouseWheelScrollSensitivity,e=a.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&e+d===0?e=d=0:Math.abs(d)>=Math.abs(e)?e=0:d=0),this._options.flipAxes&&([d,e]=[e,d]);let f=!bG&&a.browserEvent&&a.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!e&&(e=d,d=0),a.browserEvent&&a.browserEvent.altKey&&(e*=this._options.fastScrollSensitivity,d*=this._options.fastScrollSensitivity);let g=this._scrollable.getFutureScrollPosition(),h={};if(d){let a=50*d,b=g.scrollTop-(a<0?Math.floor(a):Math.ceil(a));this._verticalScrollbar.writeScrollPosition(h,b)}if(e){let a=50*e,b=g.scrollLeft-(a<0?Math.floor(a):Math.ceil(a));this._horizontalScrollbar.writeScrollPosition(h,b)}h=this._scrollable.validateScrollPosition(h),(g.scrollLeft!==h.scrollLeft||g.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&b.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),c=!0)}let d=c;!d&&this._options.alwaysConsumeMouseWheel&&(d=!0),!d&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(d=!0),d&&(a.preventDefault(),a.stopPropagation())}_onDidScroll(a){this._shouldRender=this._horizontalScrollbar.onDidScroll(a)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(a)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw 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 a=this._scrollable.getCurrentScrollPosition(),b=a.scrollTop>0,c=a.scrollLeft>0,d=c?" left":"",e=b?" top":"";this._leftShadowDomNode.setClassName(`shadow${d}`),this._topShadowDomNode.setClassName(`shadow${e}`),this._topLeftShadowDomNode.setClassName(`shadow${c||b?" top-left-corner":""}${e}${d}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(a){this._mouseIsOver=!1,this._hide()}_onMouseOver(a){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(),500)}},cP=class extends cO{constructor(a,b,c){super(a,b,c)}setScrollPosition(a){a.reuseAnimation?this._scrollable.setScrollPositionSmooth(a,a.reuseAnimation):this._scrollable.setScrollPositionNow(a)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},cQ=class extends a2{constructor(a,b,c,d,e,f,g,h){super(),this._bufferService=c,this._optionsService=g,this._renderService=h,this._onRequestScrollLines=this._register(new bl),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let i=this._register(new cD({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:a=>c_(d.window,a)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{i.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new cP(b,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},i)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(e.onProtocolChange(a=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&a)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(be.runAndSubscribe(f.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=f.colors.background.css})),a.appendChild(this._scrollableElement.getDomNode()),this._register(a_(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=d.mainDocument.createElement("style"),b.appendChild(this._styleElement),this._register(a_(()=>this._styleElement.remove())),this._register(be.runAndSubscribe(f.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${f.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${f.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${f.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
15
+ `)})),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(a=>this._handleScroll(a)))}scrollLines(a){let b=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:b.scrollTop+a*this._renderService.dimensions.css.cell.height})}scrollToLine(a,b){b&&(this._latestYDisp=a),this._scrollableElement.setScrollPosition({reuseAnimation:!b,scrollTop:a*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(a){void 0!==a&&(this._latestYDisp=a),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(a=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,a!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:a*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(a){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let b=Math.round(a.scrollTop/this._renderService.dimensions.css.cell.height),c=b-this._bufferService.buffer.ydisp;0!==c&&(this._latestYDisp=b,this._onRequestScrollLines.fire(c)),this._isHandlingScroll=!1}};cQ=af([ag(2,ax),ag(3,aJ),ag(4,ay),ag(5,aO),ag(6,aD),ag(7,aL)],cQ);var cR=class extends a2{constructor(a,b,c,d,e){super(),this._screenElement=a,this._bufferService=b,this._coreBrowserService=c,this._decorationService=d,this._renderService=e,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(a=>this._removeDecoration(a))),this._register(a_(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){let b=this._coreBrowserService.mainDocument.createElement("div");b.classList.add("xterm-decoration"),b.classList.toggle("xterm-decoration-top-layer",a?.options?.layer==="top"),b.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,b.style.height=`${(a.options.height||1)*this._renderService.dimensions.css.cell.height}px`,b.style.top=`${(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,b.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let c=a.options.x??0;return c&&c>this._bufferService.cols&&(b.style.display="none"),this._refreshXPosition(a,b),b}_refreshStyle(a){let b=a.marker.line-this._bufferService.buffers.active.ydisp;if(b<0||b>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let c=this._decorationElements.get(a);c||(c=this._createElement(a),a.element=c,this._decorationElements.set(a,c),this._container.appendChild(c),a.onDispose(()=>{this._decorationElements.delete(a),c.remove()})),c.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(c.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,c.style.height=`${(a.options.height||1)*this._renderService.dimensions.css.cell.height}px`,c.style.top=`${b*this._renderService.dimensions.css.cell.height}px`,c.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),a.onRenderEmitter.fire(c)}}_refreshXPosition(a,b=a.element){if(!b)return;let c=a.options.x??0;"right"===(a.options.anchor||"left")?b.style.right=c?`${c*this._renderService.dimensions.css.cell.width}px`:"":b.style.left=c?`${c*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(a){this._decorationElements.get(a)?.remove(),this._decorationElements.delete(a),a.dispose()}};cR=af([ag(1,ax),ag(2,aJ),ag(3,aG),ag(4,aL)],cR);var cS=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(a){if(a.options.overviewRulerOptions){for(let b of this._zones)if(b.color===a.options.overviewRulerOptions.color&&b.position===a.options.overviewRulerOptions.position){if(this._lineIntersectsZone(b,a.marker.line))return;if(this._lineAdjacentToZone(b,a.marker.line,a.options.overviewRulerOptions.position))return void this._addLineToZone(b,a.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=a.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=a.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=a.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=a.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:a.options.overviewRulerOptions.color,position:a.options.overviewRulerOptions.position,startBufferLine:a.marker.line,endBufferLine:a.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(a){this._linePadding=a}_lineIntersectsZone(a,b){return b>=a.startBufferLine&&b<=a.endBufferLine}_lineAdjacentToZone(a,b,c){return b>=a.startBufferLine-this._linePadding[c||"full"]&&b<=a.endBufferLine+this._linePadding[c||"full"]}_addLineToZone(a,b){a.startBufferLine=Math.min(a.startBufferLine,b),a.endBufferLine=Math.max(a.endBufferLine,b)}},cT={full:0,left:0,center:0,right:0},cU={full:0,left:0,center:0,right:0},cV={full:0,left:0,center:0,right:0},cW=class extends a2{constructor(a,b,c,d,e,f,g,h){super(),this._viewportElement=a,this._screenElement=b,this._bufferService=c,this._decorationService=d,this._renderService=e,this._optionsService=f,this._themeService=g,this._coreBrowserService=h,this._colorZoneStore=new cS,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(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(a_(()=>this._canvas?.remove()));let i=this._canvas.getContext("2d");if(i)this._ctx=i;else throw 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(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let a=Math.floor((this._canvas.width-1)/3),b=Math.ceil((this._canvas.width-1)/3);cU.full=this._canvas.width,cU.left=a,cU.center=b,cU.right=a,this._refreshDrawHeightConstants(),cV.full=1,cV.left=1,cV.center=1+cU.left,cV.right=1+cU.left+cU.center}_refreshDrawHeightConstants(){cT.full=Math.round(2*this._coreBrowserService.dpr);let a=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);cT.left=a,cT.center=a,cT.right=a}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cT.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cT.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cT.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cT.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(){for(let a of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(a);this._ctx.lineWidth=1,this._renderRulerOutline();let a=this._colorZoneStore.zones;for(let b of a)"full"!==b.position&&this._renderColorZone(b);for(let b of a)"full"===b.position&&this._renderColorZone(b);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(a){this._ctx.fillStyle=a.color,this._ctx.fillRect(cV[a.position||"full"],Math.round((this._canvas.height-1)*(a.startBufferLine/this._bufferService.buffers.active.lines.length)-cT[a.position||"full"]/2),cU[a.position||"full"],Math.round((this._canvas.height-1)*((a.endBufferLine-a.startBufferLine)/this._bufferService.buffers.active.lines.length)+cT[a.position||"full"]))}_queueRefresh(a,b){this._shouldUpdateDimensions=a||this._shouldUpdateDimensions,this._shouldUpdateAnchor=b||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};cW=af([ag(2,ax),ag(3,aG),ag(4,aL),ag(5,aD),ag(6,aO),ag(7,aJ)],cW),(l=c1||={}).NUL="\0",l.SOH="\x01",l.STX="\x02",l.ETX="\x03",l.EOT="\x04",l.ENQ="\x05",l.ACK="\x06",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=`
16
+ `,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="\x0e",l.SI="\x0f",l.DLE="\x10",l.DC1="\x11",l.DC2="\x12",l.DC3="\x13",l.DC4="\x14",l.NAK="\x15",l.SYN="\x16",l.ETB="\x17",l.CAN="\x18",l.EM="\x19",l.SUB="\x1a",l.ESC="\x1b",l.FS="\x1c",l.GS="\x1d",l.RS="\x1e",l.US="\x1f",l.SP=" ",l.DEL="",(m=c2||={}).PAD="€",m.HOP="",m.BPH="‚",m.NBH="ƒ",m.IND="„",m.NEL="…",m.SSA="†",m.ESA="‡",m.HTS="ˆ",m.HTJ="‰",m.VTS="Š",m.PLD="‹",m.PLU="Œ",m.RI="",m.SS2="Ž",m.SS3="",m.DCS="",m.PU1="‘",m.PU2="’",m.STS="“",m.CCH="”",m.MW="•",m.SPA="–",m.EPA="—",m.SOS="˜",m.SGCI="™",m.SCI="š",m.CSI="›",m.ST="œ",m.OSC="",m.PM="ž",m.APC="Ÿ",(c3||={}).ST=`${c1.ESC}\\`;var cX=class{constructor(a,b,c,d,e,f){this._textarea=a,this._compositionView=b,this._bufferService=c,this._optionsService=d,this._coreService=e,this._renderService=f,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(a){this._compositionView.textContent=a.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(a){if(this._isComposing||this._isSendingComposition){if(20===a.keyCode||229===a.keyCode||16===a.keyCode||17===a.keyCode||18===a.keyCode)return!1;this._finalizeComposition(!1)}return 229!==a.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(a){if(this._compositionView.classList.remove("active"),this._isComposing=!1,a){let a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let b;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,(b=this._isComposing?this._textarea.value.substring(a.start,this._compositionPosition.start):this._textarea.value.substring(a.start)).length>0&&this._coreService.triggerDataEvent(b,!0)}},0)}else{this._isSendingComposition=!1;let a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){let a=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let b=this._textarea.value,c=b.replace(a,"");this._dataAlreadySent=c,b.length>a.length?this._coreService.triggerDataEvent(c,!0):b.length<a.length?this._coreService.triggerDataEvent(`${c1.DEL}`,!0):b.length===a.length&&b!==a&&this._coreService.triggerDataEvent(b,!0)}},0)}updateCompositionElements(a){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),b=this._renderService.dimensions.css.cell.height,c=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,d=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=d+"px",this._compositionView.style.top=c+"px",this._compositionView.style.height=b+"px",this._compositionView.style.lineHeight=b+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let e=this._compositionView.getBoundingClientRect();this._textarea.style.left=d+"px",this._textarea.style.top=c+"px",this._textarea.style.width=Math.max(e.width,1)+"px",this._textarea.style.height=Math.max(e.height,1)+"px",this._textarea.style.lineHeight=e.height+"px"}a||setTimeout(()=>this.updateCompositionElements(!0),0)}}};cX=af([ag(2,ax),ag(3,aD),ag(4,az),ag(5,aL)],cX);var cY,cZ,c$,c_,c0,c1,c2,c3,c4,c5=0,c6=0,c7=0,c8=0,c9={css:"#00000000",rgba:0};(eN=c4||={}).toCss=function(a,b,c,d){return void 0!==d?`#${dh(a)}${dh(b)}${dh(c)}${dh(d)}`:`#${dh(a)}${dh(b)}${dh(c)}`},eN.toRgba=function(a,b,c,d=255){return(a<<24|b<<16|c<<8|d)>>>0},eN.toColor=function(a,b,c,d){return{css:eN.toCss(a,b,c,d),rgba:eN.toRgba(a,b,c,d)}};var da=eO||={};function db(a,b){return c8=Math.round(255*b),[c5,c6,c7]=eR.toChannels(a.rgba),{css:c4.toCss(c5,c6,c7,c8),rgba:c4.toRgba(c5,c6,c7,c8)}}da.blend=function(a,b){if(1==(c8=(255&b.rgba)/255))return{css:b.css,rgba:b.rgba};let c=b.rgba>>24&255,d=b.rgba>>16&255,e=b.rgba>>8&255,f=a.rgba>>24&255,g=a.rgba>>16&255,h=a.rgba>>8&255;return c5=f+Math.round((c-f)*c8),c6=g+Math.round((d-g)*c8),c7=h+Math.round((e-h)*c8),{css:c4.toCss(c5,c6,c7),rgba:c4.toRgba(c5,c6,c7)}},da.isOpaque=function(a){return(255&a.rgba)==255},da.ensureContrastRatio=function(a,b,c){let d=eR.ensureContrastRatio(a.rgba,b.rgba,c);if(d)return c4.toColor(d>>24&255,d>>16&255,d>>8&255)},da.opaque=function(a){let b=(255|a.rgba)>>>0;return[c5,c6,c7]=eR.toChannels(b),{css:c4.toCss(c5,c6,c7),rgba:b}},da.opacity=db,da.multiplyOpacity=function(a,b){return c8=255&a.rgba,db(a,c8*b/255)},da.toColorRGB=function(a){return[a.rgba>>24&255,a.rgba>>16&255,a.rgba>>8&255]},(a=>{let b,c;try{let a=document.createElement("canvas");a.width=1,a.height=1;let d=a.getContext("2d",{willReadFrequently:!0});d&&((b=d).globalCompositeOperation="copy",c=b.createLinearGradient(0,0,1,1))}catch{}a.toColor=function(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return c5=parseInt(a.slice(1,2).repeat(2),16),c6=parseInt(a.slice(2,3).repeat(2),16),c7=parseInt(a.slice(3,4).repeat(2),16),c4.toColor(c5,c6,c7);case 5:return c5=parseInt(a.slice(1,2).repeat(2),16),c6=parseInt(a.slice(2,3).repeat(2),16),c7=parseInt(a.slice(3,4).repeat(2),16),c8=parseInt(a.slice(4,5).repeat(2),16),c4.toColor(c5,c6,c7,c8);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let d=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(d)return c5=parseInt(d[1]),c6=parseInt(d[2]),c7=parseInt(d[3]),c8=Math.round((void 0===d[5]?1:parseFloat(d[5]))*255),c4.toColor(c5,c6,c7,c8);if(!b||!c||(b.fillStyle=c,b.fillStyle=a,"string"!=typeof b.fillStyle)||(b.fillRect(0,0,1,1),[c5,c6,c7,c8]=b.getImageData(0,0,1,1).data,255!==c8))throw Error("css.toColor: Unsupported css format");return{rgba:c4.toRgba(c5,c6,c7,c8),css:a}}})(eP||={});var dc=eQ||={};function dd(a,b,c){let d=a/255,e=b/255,f=c/255;return .2126*(d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.0722*(f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4))}dc.relativeLuminance=function(a){return dd(a>>16&255,a>>8&255,255&a)},dc.relativeLuminance2=dd;var de=eR||={};function df(a,b,c){let d=a>>24&255,e=a>>16&255,f=a>>8&255,g=b>>24&255,h=b>>16&255,i=b>>8&255,j=di(eQ.relativeLuminance2(g,h,i),eQ.relativeLuminance2(d,e,f));for(;j<c&&(g>0||h>0||i>0);)g-=Math.max(0,Math.ceil(.1*g)),h-=Math.max(0,Math.ceil(.1*h)),i-=Math.max(0,Math.ceil(.1*i)),j=di(eQ.relativeLuminance2(g,h,i),eQ.relativeLuminance2(d,e,f));return(g<<24|h<<16|i<<8|255)>>>0}function dg(a,b,c){let d=a>>24&255,e=a>>16&255,f=a>>8&255,g=b>>24&255,h=b>>16&255,i=b>>8&255,j=di(eQ.relativeLuminance2(g,h,i),eQ.relativeLuminance2(d,e,f));for(;j<c&&(g<255||h<255||i<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),h=Math.min(255,h+Math.ceil((255-h)*.1)),i=Math.min(255,i+Math.ceil((255-i)*.1)),j=di(eQ.relativeLuminance2(g,h,i),eQ.relativeLuminance2(d,e,f));return(g<<24|h<<16|i<<8|255)>>>0}function dh(a){let b=a.toString(16);return b.length<2?"0"+b:b}function di(a,b){return a<b?(b+.05)/(a+.05):(a+.05)/(b+.05)}de.blend=function(a,b){if(1==(c8=(255&b)/255))return b;let c=a>>24&255,d=a>>16&255,e=a>>8&255;return c5=c+Math.round(((b>>24&255)-c)*c8),c6=d+Math.round(((b>>16&255)-d)*c8),c7=e+Math.round(((b>>8&255)-e)*c8),c4.toRgba(c5,c6,c7)},de.ensureContrastRatio=function(a,b,c){let d=eQ.relativeLuminance(a>>8),e=eQ.relativeLuminance(b>>8);if(di(d,e)<c){if(e<d){let e=df(a,b,c),f=di(d,eQ.relativeLuminance(e>>8));if(f<c){let g=dg(a,b,c);return f>di(d,eQ.relativeLuminance(g>>8))?e:g}return e}let f=dg(a,b,c),g=di(d,eQ.relativeLuminance(f>>8));if(g<c){let e=df(a,b,c);return g>di(d,eQ.relativeLuminance(e>>8))?f:e}return f}},de.reduceLuminance=df,de.increaseLuminance=dg,de.toChannels=function(a){return[a>>24&255,a>>16&255,a>>8&255,255&a]};var dj=class extends aq{constructor(a,b,c){super(),this.content=0,this.combinedData="",this.fg=a.fg,this.bg=a.bg,this.combinedData=b,this._width=c}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(a){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},dk=class{constructor(a){this._bufferService=a,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new as}register(a){let b={id:this._nextCharacterJoinerId++,handler:a};return this._characterJoiners.push(b),b.id}deregister(a){for(let b=0;b<this._characterJoiners.length;b++)if(this._characterJoiners[b].id===a)return this._characterJoiners.splice(b,1),!0;return!1}getJoinedCharacters(a){if(0===this._characterJoiners.length)return[];let b=this._bufferService.buffer.lines.get(a);if(!b||0===b.length)return[];let c=[],d=b.translateToString(!0),e=0,f=0,g=0,h=b.getFg(0),i=b.getBg(0);for(let a=0;a<b.getTrimmedLength();a++)if(b.loadCell(a,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==h||this._workCell.bg!==i){if(a-e>1){let a=this._getJoinedRanges(d,g,f,b,e);for(let b=0;b<a.length;b++)c.push(a[b])}e=a,g=f,h=this._workCell.fg,i=this._workCell.bg}f+=this._workCell.getChars().length||1}if(this._bufferService.cols-e>1){let a=this._getJoinedRanges(d,g,f,b,e);for(let b=0;b<a.length;b++)c.push(a[b])}return c}_getJoinedRanges(a,b,c,d,e){let f=a.substring(b,c),g=[];try{g=this._characterJoiners[0].handler(f)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let b=this._characterJoiners[a].handler(f);for(let a=0;a<b.length;a++)dk._mergeRanges(g,b[a])}catch(a){console.error(a)}return this._stringRangesToCellRanges(g,d,e),g}_stringRangesToCellRanges(a,b,c){let d=0,e=!1,f=0,g=a[0];if(g){for(let h=c;h<this._bufferService.cols;h++){let c=b.getWidth(h),i=b.getString(h).length||1;if(0!==c){if(!e&&g[0]<=f&&(g[0]=h,e=!0),g[1]<=f){if(g[1]=h,!(g=a[++d]))break;g[0]<=f?(g[0]=h,e=!0):e=!1}f+=i}}g&&(g[1]=this._bufferService.cols)}}static _mergeRanges(a,b){let c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(c){if(b[1]<=e[0])return a[d-1][1]=b[1],a;if(b[1]<=e[1])return a[d-1][1]=Math.max(b[1],e[1]),a.splice(d,1),a;a.splice(d,1),d--}else{if(b[1]<=e[0])return a.splice(d,0,b),a;if(b[1]<=e[1])return e[0]=Math.min(b[0],e[0]),a;b[0]<e[1]&&(e[0]=Math.min(b[0],e[0]),c=!0);continue}}return c?a[a.length-1][1]=b[1]:a.push(b),a}};function dl(){return{width:0,height:0}}dk=af([ag(0,ax)],dk);var dm=class{constructor(a,b,c,d,e,f,g){this._document=a,this._characterJoinerService=b,this._optionsService=c,this._coreBrowserService=d,this._coreService=e,this._decorationService=f,this._themeService=g,this._workCell=new as,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(a,b,c){this._selectionStart=a,this._selectionEnd=b,this._columnSelectMode=c}createRow(a,b,c,d,e,f,g,h,i,j,k){let l=[],m=this._characterJoinerService.getJoinedCharacters(b),n=this._themeService.colors,o=a.getNoBgTrimmedLength();c&&o<f+1&&(o=f+1);let p,q=0,r="",s=0,u=0,v=0,w=0,x=!1,y=0,z=!1,A=0,B=0,C=[],D=-1!==j&&-1!==k;for(let E=0;E<o;E++){let o;a.loadCell(E,this._workCell);let F=this._workCell.getWidth();if(0===F)continue;let G=!1,H=E>=B,I=E,J=this._workCell;if(m.length>0&&E===m[0][0]&&H){let d=m.shift(),e=this._isCellInSelection(d[0],b);for(s=d[0]+1;s<d[1];s++)H&&=e===this._isCellInSelection(s,b);(H&&=!c||f<d[0]||f>=d[1])?(G=!0,J=new dj(this._workCell,a.translateToString(!0,d[0],d[1]),d[1]-d[0]),I=d[1]-1,F=J.getWidth()):B=d[1]}let K=this._isCellInSelection(E,b),L=c&&E===f,M=D&&E>=j&&E<=k,N=!1;this._decorationService.forEachDecorationAtCell(E,b,void 0,a=>{N=!0});let O=J.getChars()||" ";if(" "===O&&(J.isUnderline()||J.isOverline())&&(O=" "),A=F*h-i.get(O,J.isBold(),J.isItalic()),p)if(q&&(K&&z||!K&&!z&&J.bg===u)&&(K&&z&&n.selectionForeground||J.fg===v)&&J.extended.ext===w&&M===x&&A===y&&!L&&!G&&!N&&H){J.isInvisible()?r+=" ":r+=O,q++;continue}else q&&(p.textContent=r),p=this._document.createElement("span"),q=0,r="";else p=this._document.createElement("span");if(u=J.bg,v=J.fg,w=J.extended.ext,x=M,y=A,z=K,G&&f>=E&&f<=I&&(f=E),!this._coreService.isCursorHidden&&L&&this._coreService.isCursorInitialized){if(C.push("xterm-cursor"),this._coreBrowserService.isFocused)g&&C.push("xterm-cursor-blink"),C.push("bar"===d?"xterm-cursor-bar":"underline"===d?"xterm-cursor-underline":"xterm-cursor-block");else if(e)switch(e){case"outline":C.push("xterm-cursor-outline");break;case"block":C.push("xterm-cursor-block");break;case"bar":C.push("xterm-cursor-bar");break;case"underline":C.push("xterm-cursor-underline")}}if(J.isBold()&&C.push("xterm-bold"),J.isItalic()&&C.push("xterm-italic"),J.isDim()&&C.push("xterm-dim"),r=J.isInvisible()?" ":J.getChars()||" ",J.isUnderline()&&(C.push(`xterm-underline-${J.extended.underlineStyle}`)," "===r&&(r=" "),!J.isUnderlineColorDefault()))if(J.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${aq.toColorRGB(J.getUnderlineColor()).join(",")})`;else{let a=J.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&J.isBold()&&a<8&&(a+=8),p.style.textDecorationColor=n.ansi[a].css}J.isOverline()&&(C.push("xterm-overline")," "===r&&(r=" ")),J.isStrikethrough()&&C.push("xterm-strikethrough"),M&&(p.style.textDecoration="underline");let P=J.getFgColor(),Q=J.getFgColorMode(),R=J.getBgColor(),S=J.getBgColorMode(),T=!!J.isInverse();if(T){let a=P;P=R,R=a;let b=Q;Q=S,S=b}let U,V,W=!1;switch(this._decorationService.forEachDecorationAtCell(E,b,void 0,a=>{"top"!==a.options.layer&&W||(a.backgroundColorRGB&&(S=0x3000000,R=a.backgroundColorRGB.rgba>>8&0xffffff,U=a.backgroundColorRGB),a.foregroundColorRGB&&(Q=0x3000000,P=a.foregroundColorRGB.rgba>>8&0xffffff,V=a.foregroundColorRGB),W="top"===a.options.layer)}),!W&&K&&(R=(U=this._coreBrowserService.isFocused?n.selectionBackgroundOpaque:n.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,S=0x3000000,W=!0,n.selectionForeground&&(Q=0x3000000,P=n.selectionForeground.rgba>>8&0xffffff,V=n.selectionForeground)),W&&C.push("xterm-decoration-top"),S){case 0x1000000:case 0x2000000:o=n.ansi[R],C.push(`xterm-bg-${R}`);break;case 0x3000000:o=c4.toColor(R>>16,R>>8&255,255&R),this._addStyle(p,`background-color:#${dn((R>>>0).toString(16),"0",6)}`);break;default:T?(o=n.foreground,C.push("xterm-bg-257")):o=n.background}switch(U||J.isDim()&&(U=eO.multiplyOpacity(o,.5)),Q){case 0x1000000:case 0x2000000:J.isBold()&&P<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(P+=8),this._applyMinimumContrast(p,o,n.ansi[P],J,U,void 0)||C.push(`xterm-fg-${P}`);break;case 0x3000000:let X=c4.toColor(P>>16&255,P>>8&255,255&P);this._applyMinimumContrast(p,o,X,J,U,V)||this._addStyle(p,`color:#${dn(P.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,o,n.foreground,J,U,V)||T&&C.push("xterm-fg-257")}C.length&&(p.className=C.join(" "),C.length=0),L||G||N||!H?p.textContent=r:q++,A!==this.defaultSpacing&&(p.style.letterSpacing=`${A}px`),l.push(p),E=I}return p&&q&&(p.textContent=r),l}_applyMinimumContrast(a,b,c,d,e,f){var g,h,i;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(h=g=d.getCode())&&h<=57558||9472<=(i=g)&&i<=9631)return!1;let j=this._getContrastCache(d),k;if(e||f||(k=j.getColor(b.rgba,c.rgba)),void 0===k){let a=this._optionsService.rawOptions.minimumContrastRatio/(d.isDim()?2:1);k=eO.ensureContrastRatio(e||b,f||c,a),j.setColor((e||b).rgba,(f||c).rgba,k??null)}return!!k&&(this._addStyle(a,`color:${k.css}`),!0)}_getContrastCache(a){return a.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(a,b){a.setAttribute("style",`${a.getAttribute("style")||""}${b};`)}_isCellInSelection(a,b){let c=this._selectionStart,d=this._selectionEnd;return!!c&&!!d&&(this._columnSelectMode?c[0]<=d[0]?a>=c[0]&&b>=c[1]&&a<d[0]&&b<=d[1]:a<c[0]&&b>=c[1]&&a>=d[0]&&b<=d[1]:b>c[1]&&b<d[1]||c[1]===d[1]&&b===c[1]&&a>=c[0]&&a<d[0]||c[1]<d[1]&&b===d[1]&&a<d[0]||c[1]<d[1]&&b===c[1]&&a>=c[0])}};function dn(a,b,c){for(;a.length<c;)a=b+a;return a}dm=af([ag(1,aN),ag(2,aD),ag(3,aJ),ag(4,az),ag(5,aG),ag(6,aO)],dm);var dp=class{constructor(a,b){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=a.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 c=a.createElement("span");c.classList.add("xterm-char-measure-element");let d=a.createElement("span");d.classList.add("xterm-char-measure-element"),d.style.fontWeight="bold";let e=a.createElement("span");e.classList.add("xterm-char-measure-element"),e.style.fontStyle="italic";let f=a.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontWeight="bold",f.style.fontStyle="italic",this._measureElements=[c,d,e,f],this._container.appendChild(c),this._container.appendChild(d),this._container.appendChild(e),this._container.appendChild(f),b.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(a,b,c,d){a===this._font&&b===this._fontSize&&c===this._weight&&d===this._weightBold||(this._font=a,this._fontSize=b,this._weight=c,this._weightBold=d,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${c}`,this._measureElements[1].style.fontWeight=`${d}`,this._measureElements[2].style.fontWeight=`${c}`,this._measureElements[3].style.fontWeight=`${d}`,this.clear())}get(a,b,c){let d=0;if(!b&&!c&&1===a.length&&(d=a.charCodeAt(0))<256){if(-9999!==this._flat[d])return this._flat[d];let b=this._measure(a,0);return b>0&&(this._flat[d]=b),b}let e=a;b&&(e+="B"),c&&(e+="I");let f=this._holey.get(e);if(void 0===f){let d=0;b&&(d|=1),c&&(d|=2),(f=this._measure(a,d))>0&&this._holey.set(e,f)}return f}_measure(a,b){let c=this._measureElements[b];return c.textContent=a.repeat(32),c.offsetWidth/32}},dq=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(a,b,c,d=!1){if(this.selectionStart=b,this.selectionEnd=c,!b||!c||b[0]===c[0]&&b[1]===c[1])return void this.clear();let e=a.buffers.active.ydisp,f=b[1]-e,g=c[1]-e,h=Math.max(f,0),i=Math.min(g,a.rows-1);h>=a.rows||i<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=d,this.viewportStartRow=f,this.viewportEndRow=g,this.viewportCappedStartRow=h,this.viewportCappedEndRow=i,this.startCol=b[0],this.endCol=c[0])}isCellSelected(a,b,c){return!!this.hasSelection&&(c-=a.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?b>=this.startCol&&c>=this.viewportCappedStartRow&&b<this.endCol&&c<=this.viewportCappedEndRow:b<this.startCol&&c>=this.viewportCappedStartRow&&b>=this.endCol&&c<=this.viewportCappedEndRow:c>this.viewportStartRow&&c<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&c===this.viewportStartRow&&b>=this.startCol&&b<this.endCol||this.viewportStartRow<this.viewportEndRow&&c===this.viewportEndRow&&b<this.endCol||this.viewportStartRow<this.viewportEndRow&&c===this.viewportStartRow&&b>=this.startCol)}},dr="xterm-dom-renderer-owner-",ds="xterm-rows",dt="xterm-fg-",du="xterm-bg-",dv="xterm-focus",dw="xterm-selection",dx=1,dy=class extends a2{constructor(a,b,c,d,e,f,g,h,i,j,k,l,m,n){super(),this._terminal=a,this._document=b,this._element=c,this._screenElement=d,this._viewportElement=e,this._helperContainer=f,this._linkifier2=g,this._charSizeService=i,this._optionsService=j,this._bufferService=k,this._coreService=l,this._coreBrowserService=m,this._themeService=n,this._terminalClass=dx++,this._rowElements=[],this._selectionRenderModel=new dq,this.onRequestRedraw=this._register(new bl).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ds),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(dw),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:dl(),cell:dl()},device:{canvas:dl(),cell:dl(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(a=>this._injectCss(a))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(dm,document),this._element.classList.add(dr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(a=>this._handleLinkHover(a))),this._register(this._linkifier2.onHideLinkUnderline(a=>this._handleLinkLeave(a))),this._register(a_(()=>{this._element.classList.remove(dr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new dp(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 a=this._coreBrowserService.dpr;for(let b of(this.dimensions.device.char.width=this._charSizeService.width*a,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*a),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/a),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/a),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,this._rowElements))b.style.width=`${this.dimensions.css.canvas.width}px`,b.style.height=`${this.dimensions.css.cell.height}px`,b.style.lineHeight=`${this.dimensions.css.cell.height}px`,b.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let b=`${this._terminalSelector} .${ds} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=b,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(a){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let b=`${this._terminalSelector} .${ds} { pointer-events: none; color: ${a.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;b+=`${this._terminalSelector} .${ds} .xterm-dim { color: ${eO.multiplyOpacity(a.foreground,.5).css};}${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 c=`blink_underline_${this._terminalClass}`,d=`blink_bar_${this._terminalClass}`,e=`blink_block_${this._terminalClass}`;for(let[f,g]of(b+=`@keyframes ${c} { 50% { border-bottom-style: hidden; }}@keyframes ${d} { 50% { box-shadow: none; }}@keyframes ${e} { 0% { background-color: ${a.cursor.css}; color: ${a.cursorAccent.css}; } 50% { background-color: inherit; color: ${a.cursor.css}; }}${this._terminalSelector} .${ds}.${dv} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${c} 1s step-end infinite;}${this._terminalSelector} .${ds}.${dv} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${d} 1s step-end infinite;}${this._terminalSelector} .${ds}.${dv} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${e} 1s step-end infinite;}${this._terminalSelector} .${ds} .xterm-cursor.xterm-cursor-block { background-color: ${a.cursor.css}; color: ${a.cursorAccent.css};}${this._terminalSelector} .${ds} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${a.cursor.css} !important; color: ${a.cursorAccent.css} !important;}${this._terminalSelector} .${ds} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${a.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ds} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${a.cursor.css} inset;}${this._terminalSelector} .${ds} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${a.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${dw} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${dw} div { position: absolute; background-color: ${a.selectionBackgroundOpaque.css};}${this._terminalSelector} .${dw} div { position: absolute; background-color: ${a.selectionInactiveBackgroundOpaque.css};}`,a.ansi.entries()))b+=`${this._terminalSelector} .${dt}${f} { color: ${g.css}; }${this._terminalSelector} .${dt}${f}.xterm-dim { color: ${eO.multiplyOpacity(g,.5).css}; }${this._terminalSelector} .${du}${f} { background-color: ${g.css}; }`;b+=`${this._terminalSelector} .${dt}257 { color: ${eO.opaque(a.background).css}; }${this._terminalSelector} .${dt}257.xterm-dim { color: ${eO.multiplyOpacity(eO.opaque(a.background),.5).css}; }${this._terminalSelector} .${du}257 { background-color: ${a.foreground.css}; }`,this._themeStyleElement.textContent=b}_setDefaultSpacing(){let a=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${a}px`,this._rowFactory.defaultSpacing=a}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(a,b){for(let a=this._rowElements.length;a<=b;a++){let a=this._document.createElement("div");this._rowContainer.appendChild(a),this._rowElements.push(a)}for(;this._rowElements.length>b;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(a,b){this._refreshRowElements(a,b),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(dv),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(dv),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(a,b,c){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(a,b,c),this.renderRows(0,this._bufferService.rows-1),!a||!b||(this._selectionRenderModel.update(this._terminal,a,b,c),!this._selectionRenderModel.hasSelection))return;let d=this._selectionRenderModel.viewportStartRow,e=this._selectionRenderModel.viewportEndRow,f=this._selectionRenderModel.viewportCappedStartRow,g=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(c){let c=a[0]>b[0];h.appendChild(this._createSelectionElement(f,c?b[0]:a[0],c?a[0]:b[0],g-f+1))}else{let c=d===f?a[0]:0,i=f===e?b[0]:this._bufferService.cols;if(h.appendChild(this._createSelectionElement(f,c,i)),h.appendChild(this._createSelectionElement(f+1,0,this._bufferService.cols,g-f-1)),f!==g){let a=e===g?b[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(g,0,a))}}this._selectionContainer.appendChild(h)}_createSelectionElement(a,b,c,d=1){let e=this._document.createElement("div"),f=b*this.dimensions.css.cell.width,g=this.dimensions.css.cell.width*(c-b);return f+g>this.dimensions.css.canvas.width&&(g=this.dimensions.css.canvas.width-f),e.style.height=`${d*this.dimensions.css.cell.height}px`,e.style.top=`${a*this.dimensions.css.cell.height}px`,e.style.left=`${f}px`,e.style.width=`${g}px`,e}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 a of this._rowElements)a.replaceChildren()}renderRows(a,b){let c=this._bufferService.buffer,d=c.ybase+c.y,e=Math.min(c.x,this._bufferService.cols-1),f=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,g=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let i=a;i<=b;i++){let a=i+c.ydisp,b=this._rowElements[i],j=c.lines.get(a);if(!b||!j)break;b.replaceChildren(...this._rowFactory.createRow(j,a,a===d,g,h,e,f,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${dr}${this._terminalClass}`}_handleLinkHover(a){this._setCellUnderline(a.x1,a.x2,a.y1,a.y2,a.cols,!0)}_handleLinkLeave(a){this._setCellUnderline(a.x1,a.x2,a.y1,a.y2,a.cols,!1)}_setCellUnderline(a,b,c,d,e,f){c<0&&(a=0),d<0&&(b=0);let g=this._bufferService.rows-1;c=Math.max(Math.min(c,g),0),d=Math.max(Math.min(d,g),0),e=Math.min(e,this._bufferService.cols);let h=this._bufferService.buffer,i=h.ybase+h.y,j=Math.min(h.x,e-1),k=this._optionsService.rawOptions.cursorBlink,l=this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=c;g<=d;++g){let n=g+h.ydisp,o=this._rowElements[g],p=h.lines.get(n);if(!o||!p)break;o.replaceChildren(...this._rowFactory.createRow(p,n,n===i,l,m,j,k,this.dimensions.css.cell.width,this._widthCache,f?g===c?a:0:-1,f?(g===d?b:e)-1:-1))}}};dy=af([ag(7,aB),ag(8,aI),ag(9,aD),ag(10,ax),ag(11,az),ag(12,aJ),ag(13,aO)],dy);var dz=class extends a2{constructor(a,b,c){super(),this._optionsService=c,this.width=0,this.height=0,this._onCharSizeChange=this._register(new bl),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new dC(this._optionsService))}catch{this._measureStrategy=this._register(new dB(a,b,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let a=this._measureStrategy.measure();(a.width!==this.width||a.height!==this.height)&&(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};dz=af([ag(2,aD)],dz);var dA=class extends a2{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(a,b){void 0!==a&&a>0&&void 0!==b&&b>0&&(this._result.width=a,this._result.height=b)}},dB=class extends dA{constructor(a,b,c){super(),this._document=a,this._parentElement=b,this._optionsService=c,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}},dC=class extends dA{constructor(a){super(),this._optionsService=a,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let b=this._ctx.measureText("W");if(!("width"in b&&"fontBoundingBoxAscent"in b&&"fontBoundingBoxDescent"in b))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let a=this._ctx.measureText("W");return this._validateAndSet(a.width,a.fontBoundingBoxAscent+a.fontBoundingBoxDescent),this._result}},dD=class extends a2{constructor(a,b,c){super(),this._textarea=a,this._window=b,this.mainDocument=c,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new dE(this._window)),this._onDprChange=this._register(new bl),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new bl),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(a=>this._screenDprMonitor.setWindow(a))),this._register(be.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(cp(this._textarea,"focus",()=>this._isFocused=!0)),this._register(cp(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(a){this._window!==a&&(this._window=a,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},dE=class extends a2{constructor(a){super(),this._parentWindow=a,this._windowResizeListener=this._register(new a3),this._onDprChange=this._register(new bl),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(a_(()=>this.clearListener()))}setWindow(a){this._parentWindow=a,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=cp(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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)}},dF=class extends a2{constructor(){super(),this.linkProviders=[],this._register(a_(()=>this.linkProviders.length=0))}registerLinkProvider(a){return this.linkProviders.push(a),{dispose:()=>{let b=this.linkProviders.indexOf(a);-1!==b&&this.linkProviders.splice(b,1)}}}};function dG(a,b,c){let d=c.getBoundingClientRect(),e=a.getComputedStyle(c),f=parseInt(e.getPropertyValue("padding-left")),g=parseInt(e.getPropertyValue("padding-top"));return[b.clientX-d.left-f,b.clientY-d.top-g]}var dH=class{constructor(a,b){this._renderService=a,this._charSizeService=b}getCoords(a,b,c,d,e){return function(a,b,c,d,e,f,g,h,i){if(!f)return;let j=dG(a,b,c);return j[0]=Math.ceil((j[0]+(i?g/2:0))/g),j[1]=Math.ceil(j[1]/h),j[0]=Math.min(Math.max(j[0],1),d+ +!!i),j[1]=Math.min(Math.max(j[1],1),e),j}(window,a,b,c,d,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,e)}getMouseReportCoords(a,b){let c=dG(window,a,b);if(this._charSizeService.hasValidSize)return c[0]=Math.min(Math.max(c[0],0),this._renderService.dimensions.css.canvas.width-1),c[1]=Math.min(Math.max(c[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(c[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(c[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(c[0]),y:Math.floor(c[1])}}};dH=af([ag(0,aL),ag(1,aI)],dH);var dI=class{constructor(a,b){this._renderCallback=a,this._coreBrowserService=b,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(a){return this._refreshCallbacks.push(a),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(a,b,c){this._rowCount=c,a=void 0!==a?a:0,b=void 0!==b?b:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,a):a,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,b):b,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let a=Math.max(this._rowStart,0),b=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,b),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let a of this._refreshCallbacks)a(0);this._refreshCallbacks=[]}},dJ={},dK={getSafariVersion:()=>dS,isChromeOS:()=>dY,isFirefox:()=>dP,isIpad:()=>dU,isIphone:()=>dV,isLegacyEdge:()=>dQ,isLinux:()=>dX,isMac:()=>dT,isNode:()=>dM,isSafari:()=>dR,isWindows:()=>dW};for(var dL in dK)ad(dJ,dL,{get:dK[dL],enumerable:!0});var dM="u">typeof process&&"title"in process,dN=dM?"node":navigator.userAgent,dO=dM?"node":navigator.platform,dP=dN.includes("Firefox"),dQ=dN.includes("Edge"),dR=/^((?!chrome|android).)*safari/i.test(dN);function dS(){if(!dR)return 0;let a=dN.match(/Version\/(\d+)/);return null===a||a.length<2?0:parseInt(a[1])}var dT=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(dO),dU="iPad"===dO,dV="iPhone"===dO,dW=["Windows","Win16","Win32","WinCE"].includes(dO),dX=dO.indexOf("Linux")>=0,dY=/\bCrOS\b/.test(dN),dZ=class{constructor(){this._tasks=[],this._i=0}enqueue(a){this._tasks.push(a),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(a){this._idleCallback=void 0;let b=0,c=0,d=a.timeRemaining(),e=0;for(;this._i<this._tasks.length;){if(b=performance.now(),this._tasks[this._i]()||this._i++,1.5*(c=Math.max(b=Math.max(1,performance.now()-b),c))>(e=a.timeRemaining())){d-b<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(d-b))}ms`),this._start();return}d=e}this.clear()}},d$=class extends dZ{_requestCallback(a){return setTimeout(()=>a(this._createDeadline(16)))}_cancelCallback(a){clearTimeout(a)}_createDeadline(a){let b=performance.now()+a;return{timeRemaining:()=>Math.max(0,b-performance.now())}}},d_=class extends dZ{_requestCallback(a){return requestIdleCallback(a)}_cancelCallback(a){cancelIdleCallback(a)}},d0=!dM&&"requestIdleCallback"in window?d_:d$,d1=class{constructor(){this._queue=new d0}set(a){this._queue.clear(),this._queue.enqueue(a)}flush(){this._queue.flush()}},d2=class extends a2{constructor(a,b,c,d,e,f,g,h,i){super(),this._rowCount=a,this._optionsService=c,this._charSizeService=d,this._coreService=e,this._coreBrowserService=h,this._renderer=this._register(new a3),this._pausedResizeTask=new d1,this._observerDisposable=this._register(new a3),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 bl),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new bl),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new bl),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new bl),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new dI((a,b)=>this._renderRows(a,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new d3(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(a_(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(g.onResize(()=>this._fullRefresh())),this._register(g.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(f.onDecorationRegistered(()=>this._fullRefresh())),this._register(f.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(g.cols,g.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(g.buffer.y,g.buffer.y,!0))),this._register(i.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,b),this._register(this._coreBrowserService.onWindowChange(a=>this._registerIntersectionObserver(a,b)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(a,b){if("IntersectionObserver"in a){let c=new a.IntersectionObserver(a=>this._handleIntersectionChange(a[a.length-1]),{threshold:0});c.observe(b),this._observerDisposable.value=a_(()=>c.disconnect())}}_handleIntersectionChange(a){this._isPaused=void 0===a.isIntersecting?0===a.intersectionRatio:!a.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(a,b,c=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(a,b);let d=this._syncOutputHandler.flush();d&&(a=Math.min(a,d.start),b=Math.max(b,d.end)),c||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(a,b,this._rowCount)}_renderRows(a,b){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(a,b);a=Math.min(a,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(a,b),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:a,end:b}),this._onRender.fire({start:a,end:b}),this._isNextRenderRedrawOnly=!0}}resize(a,b){this._rowCount=b,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(a){this._renderer.value=a,this._renderer.value&&(this._renderer.value.onRequestRedraw(a=>this.refreshRows(a.start,a.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(a){return this._renderDebouncer.addRefreshCallback(a)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(a,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(a,b)):this._renderer.value.handleResize(a,b),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(a,b,c){this._selectionState.start=a,this._selectionState.end=b,this._selectionState.columnSelectMode=c,this._renderer.value?.handleSelectionChanged(a,b,c)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};d2=af([ag(2,aD),ag(3,aI),ag(4,az),ag(5,aG),ag(6,ax),ag(7,aJ),ag(8,aO)],d2);var d3=class{constructor(a,b,c){this._coreBrowserService=a,this._coreService=b,this._onTimeout=c,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(a,b){this._isBuffering?(this._start=Math.min(this._start,a),this._end=Math.max(this._end,b)):(this._start=a,this._end=b,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let a={start:this._start,end:this._end};return this._isBuffering=!1,a}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function d4(a,b,c,d){return d8(Math.abs(a-d5(a,c)-(b-d5(b,c)))-function(a,b,c){let d=0,e=a-d5(a,c),f=b-d5(b,c);for(let g=0;g<Math.abs(e-f);g++){let f="A"===function(a,b){return a>b?"A":"B"}(a,b)?-1:1;c.buffer.lines.get(e+f*g)?.isWrapped&&d++}return d}(a,b,c),d7(a>b?"A":"B",d))}function d5(a,b){let c=0,d=b.buffer.lines.get(a),e=d?.isWrapped;for(;e&&a>=0&&a<b.rows;)c++,d=b.buffer.lines.get(--a),e=d?.isWrapped;return c}function d6(a,b,c,d,e,f){let g=a,h=b,i="";for(;(g!==c||h!==d)&&h>=0&&h<f.buffer.lines.length;)g+=e?1:-1,e&&g>f.cols-1?(i+=f.buffer.translateBufferLineToString(h,!1,a,g),g=0,a=0,h++):!e&&g<0&&(i+=f.buffer.translateBufferLineToString(h,!1,0,a+1),a=g=f.cols-1,h--);return i+f.buffer.translateBufferLineToString(h,!1,a,g)}function d7(a,b){return c1.ESC+(b?"O":"[")+a}function d8(a,b){a=Math.floor(a);let c="";for(let d=0;d<a;d++)c+=b;return c}var d9=class{constructor(a){this._bufferService=a,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?a%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)-1]:[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[a,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[Math.max(a,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let a=this.selectionStart,b=this.selectionEnd;return!!a&&!!b&&(a[1]>b[1]||a[1]===b[1]&&a[0]>b[0])}handleTrim(a){return this.selectionStart&&(this.selectionStart[1]-=a),this.selectionEnd&&(this.selectionEnd[1]-=a),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function ea(a,b){if(a.start.y>a.end.y)throw Error(`Buffer range end (${a.end.x}, ${a.end.y}) cannot be before start (${a.start.x}, ${a.start.y})`);return b*(a.end.y-a.start.y)+(a.end.x-a.start.x+1)}var eb=RegExp(" ","g"),ec=class extends a2{constructor(a,b,c,d,e,f,g,h,i){super(),this._element=a,this._screenElement=b,this._linkifier=c,this._bufferService=d,this._coreService=e,this._mouseService=f,this._optionsService=g,this._renderService=h,this._coreBrowserService=i,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new as,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new bl),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new bl),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new bl),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new bl),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=a=>this._handleMouseMove(a),this._mouseUpListener=a=>this._handleMouseUp(a),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(a=>this._handleTrim(a)),this._register(this._bufferService.buffers.onBufferActivate(a=>this._handleBufferActivate(a))),this.enable(),this._model=new d9(this._bufferService),this._activeSelectionMode=0,this._register(a_(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(a=>{a.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 a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd;return!!a&&!!b&&(a[0]!==b[0]||a[1]!==b[1])}get selectionText(){let a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd;if(!a||!b)return"";let c=this._bufferService.buffer,d=[];if(3===this._activeSelectionMode){if(a[0]===b[0])return"";let e=a[0]<b[0]?a[0]:b[0],f=a[0]<b[0]?b[0]:a[0];for(let g=a[1];g<=b[1];g++){let a=c.translateBufferLineToString(g,!0,e,f);d.push(a)}}else{let e=a[1]===b[1]?b[0]:void 0;d.push(c.translateBufferLineToString(a[1],!0,a[0],e));for(let e=a[1]+1;e<=b[1]-1;e++){let a=c.lines.get(e),b=c.translateBufferLineToString(e,!0);a?.isWrapped?d[d.length-1]+=b:d.push(b)}if(a[1]!==b[1]){let a=c.lines.get(b[1]),e=c.translateBufferLineToString(b[1],!0,0,b[0]);a&&a.isWrapped?d[d.length-1]+=e:d.push(e)}}return d.map(a=>a.replace(eb," ")).join(dW?`\r
17
17
  `:`
18
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(a){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),dP&&a&&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:3===this._activeSelectionMode})}_isClickInSelection(a){let b=this._getMouseBufferCoords(a),c=this._model.finalSelectionStart,d=this._model.finalSelectionEnd;return!!c&&!!d&&!!b&&this._areCoordsInSelection(b,c,d)}isCellInSelection(a,b){let c=this._model.finalSelectionStart,d=this._model.finalSelectionEnd;return!!c&&!!d&&this._areCoordsInSelection([a,b],c,d)}_areCoordsInSelection(a,b,c){return a[1]>b[1]&&a[1]<c[1]||b[1]===c[1]&&a[1]===b[1]&&a[0]>=b[0]&&a[0]<c[0]||b[1]<c[1]&&a[1]===c[1]&&a[0]<c[0]||b[1]<c[1]&&a[1]===b[1]&&a[0]>=b[0]}_selectWordAtCursor(a,b){let c=this._linkifier.currentLink?.link?.range;if(c)return this._model.selectionStart=[c.start.x-1,c.start.y-1],this._model.selectionStartLength=d2(c,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let d=this._getMouseBufferCoords(a);return!!d&&(this._selectWordAt(d,b),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(a,b){this._model.clearSelection(),a=Math.max(a,0),b=Math.min(b,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,a],this._model.selectionEnd=[this._bufferService.cols,b],this.refresh(),this._onSelectionChange.fire()}_handleTrim(a){this._model.handleTrim(a)&&this.refresh()}_getMouseBufferCoords(a){let b=this._mouseService.getCoords(a,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(b)return b[0]--,b[1]--,b[1]+=this._bufferService.buffer.ydisp,b}_getMouseEventScrollAmount(a){let b=dy(this._coreBrowserService.window,a,this._screenElement)[1],c=this._renderService.dimensions.css.canvas.height;return b>=0&&b<=c?0:(b>c&&(b-=c),(b=Math.min(Math.max(b,-50),50)/50)/Math.abs(b)+Math.round(14*b))}shouldForceSelection(a){return dL?a.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:a.shiftKey}handleMouseDown(a){if(this._mouseDownTimeStamp=a.timeStamp,!(2===a.button&&this.hasSelection)&&0===a.button){if(!this._enabled){if(!this.shouldForceSelection(a))return;a.stopPropagation()}a.preventDefault(),this._dragScrollAmount=0,this._enabled&&a.shiftKey?this._handleIncrementalClick(a):1===a.detail?this._handleSingleClick(a):2===a.detail?this._handleDoubleClick(a):3===a.detail&&this._handleTripleClick(a),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(a){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(a))}_handleSingleClick(a){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(a),this._model.selectionStart=this._getMouseBufferCoords(a),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let b=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);b&&b.length!==this._model.selectionStart[0]&&0===b.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(a){this._selectWordAtCursor(a,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(a){let b=this._getMouseBufferCoords(a);b&&(this._activeSelectionMode=2,this._selectLineAt(b[1]))}shouldColumnSelect(a){return a.altKey&&!(dL&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(a){if(a.stopImmediatePropagation(),!this._model.selectionStart)return;let b=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(a),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(a),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let c=this._bufferService.buffer;if(this._model.selectionEnd[1]<c.lines.length){let a=c.lines.get(this._model.selectionEnd[1]);a&&0===a.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}b&&b[0]===this._model.selectionEnd[0]&&b[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 a=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(a.ydisp+this._bufferService.rows,a.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=a.ydisp),this.refresh()}}_handleMouseUp(a){let b=a.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&b<500&&a.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let b=this._mouseService.getCoords(a,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(b&&void 0!==b[0]&&void 0!==b[1]){let a=function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u;let v,w=c.buffer.x,x=c.buffer.y;if(!c.buffer.hasScrollback){let u,v,y;return e=w,(0===dY(f=x,b,g=c,h=d).length?"":d0(d$(e,f,e,f-dZ(f,g),!1,g).length,d_("D",h)))+dY(x,b,c,d)+(i=w,j=x,k=a,u=dY(j,l=b,m=c,n=d).length>0?l-dZ(l,m):j,y=(o=i,p=j,v=dY(q=k,r=l,s=m,n).length>0?r-dZ(r,s):p,o<q&&v<=r||o>=q&&v<r?"C":"D"),d0(d$(i,u,k,l,"C"===y,m).length,d_(y,n)))}if(x===b)return v=w>a?"D":"C",d0(Math.abs(w-a),d_(v,d));v=x>b?"D":"C";let y=Math.abs(x-b);return d0((u=x>b?a:w,c.cols-u+(y-1)*c.cols+1+((x>b?w:a)-1)),d_(v,d))}(b[0]-1,b[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(a,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd,c=!!a&&!!b&&(a[0]!==b[0]||a[1]!==b[1]);if(!c){this._oldHasSelection&&this._fireOnSelectionChange(a,b,c);return}!a||!b||this._oldSelectionStart&&this._oldSelectionEnd&&a[0]===this._oldSelectionStart[0]&&a[1]===this._oldSelectionStart[1]&&b[0]===this._oldSelectionEnd[0]&&b[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(a,b,c)}_fireOnSelectionChange(a,b,c){this._oldSelectionStart=a,this._oldSelectionEnd=b,this._oldHasSelection=c,this._onSelectionChange.fire()}_handleBufferActivate(a){this.clearSelection(),this._trimListener.dispose(),this._trimListener=a.activeBuffer.lines.onTrim(a=>this._handleTrim(a))}_convertViewportColToCharacterIndex(a,b){let c=b;for(let d=0;b>=d;d++){let e=a.loadCell(d,this._workCell).getChars().length;0===this._workCell.getWidth()?c--:e>1&&b!==d&&(c+=e-1)}return c}setSelection(a,b,c){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[a,b],this._model.selectionStartLength=c,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(a){this._isClickInSelection(a)||(this._selectWordAtCursor(a,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(a,b,c=!0,d=!0){if(a[0]>=this._bufferService.cols)return;let e=this._bufferService.buffer,f=e.lines.get(a[1]);if(!f)return;let g=e.translateBufferLineToString(a[1],!1),h=this._convertViewportColToCharacterIndex(f,a[0]),i=h,j=a[0]-h,k=0,l=0,m=0,n=0;if(" "===g.charAt(h)){for(;h>0&&" "===g.charAt(h-1);)h--;for(;i<g.length&&" "===g.charAt(i+1);)i++}else{let b=a[0],c=a[0];0===f.getWidth(b)&&(k++,b--),2===f.getWidth(c)&&(l++,c++);let d=f.getString(c).length;for(d>1&&(n+=d-1,i+=d-1);b>0&&h>0&&!this._isCharWordSeparator(f.loadCell(b-1,this._workCell));){f.loadCell(b-1,this._workCell);let a=this._workCell.getChars().length;0===this._workCell.getWidth()?(k++,b--):a>1&&(m+=a-1,h-=a-1),h--,b--}for(;c<f.length&&i+1<g.length&&!this._isCharWordSeparator(f.loadCell(c+1,this._workCell));){f.loadCell(c+1,this._workCell);let a=this._workCell.getChars().length;2===this._workCell.getWidth()?(l++,c++):a>1&&(n+=a-1,i+=a-1),i++,c++}}i++;let o=h+j-k+m,p=Math.min(this._bufferService.cols,i-h+k+l-m-n);if(!(!b&&""===g.slice(h,i).trim())){if(c&&0===o&&32!==f.getCodePoint(0)){let b=e.lines.get(a[1]-1);if(b&&f.isWrapped&&32!==b.getCodePoint(this._bufferService.cols-1)){let b=this._getWordAt([this._bufferService.cols-1,a[1]-1],!1,!0,!1);if(b){let a=this._bufferService.cols-b.start;o-=a,p+=a}}}if(d&&o+p===this._bufferService.cols&&32!==f.getCodePoint(this._bufferService.cols-1)){let b=e.lines.get(a[1]+1);if(b?.isWrapped&&32!==b.getCodePoint(0)){let b=this._getWordAt([0,a[1]+1],!1,!1,!0);b&&(p+=b.length)}}return{start:o,length:p}}}_selectWordAt(a,b){let c=this._getWordAt(a,b);if(c){for(;c.start<0;)c.start+=this._bufferService.cols,a[1]--;this._model.selectionStart=[c.start,a[1]],this._model.selectionStartLength=c.length}}_selectToWordAt(a){let b=this._getWordAt(a,!0);if(b){let c=a[1];for(;b.start<0;)b.start+=this._bufferService.cols,c--;if(!this._model.areSelectionValuesReversed())for(;b.start+b.length>this._bufferService.cols;)b.length-=this._bufferService.cols,c++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?b.start:b.start+b.length,c]}}_isCharWordSeparator(a){return 0!==a.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(a.getChars())>=0}_selectLineAt(a){let b=this._bufferService.buffer.getWrappedRangeForLine(a),c={start:{x:0,y:b.first},end:{x:this._bufferService.cols-1,y:b.last}};this._model.selectionStart=[0,b.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=d2(c,this._bufferService.cols)}};d4=Z([$(3,ap),$(4,ar),$(5,aC),$(6,av),$(7,aD),$(8,aB)],d4);var d5=class{constructor(){this._data={}}set(a,b,c){this._data[a]||(this._data[a]={}),this._data[a][b]=c}get(a,b){return this._data[a]?this._data[a][b]:void 0}clear(){this._data={}}},d6=class{constructor(){this._color=new d5,this._css=new d5}setCss(a,b,c){this._css.set(a,b,c)}getCss(a,b){return this._css.get(a,b)}setColor(a,b,c){this._color.set(a,b,c)}getColor(a,b){return this._color.get(a,b)}clear(){this._color.clear(),this._css.clear()}},d7=Object.freeze((()=>{let a=[eH.toColor("#2e3436"),eH.toColor("#cc0000"),eH.toColor("#4e9a06"),eH.toColor("#c4a000"),eH.toColor("#3465a4"),eH.toColor("#75507b"),eH.toColor("#06989a"),eH.toColor("#d3d7cf"),eH.toColor("#555753"),eH.toColor("#ef2929"),eH.toColor("#8ae234"),eH.toColor("#fce94f"),eH.toColor("#729fcf"),eH.toColor("#ad7fa8"),eH.toColor("#34e2e2"),eH.toColor("#eeeeec")],b=[0,95,135,175,215,255];for(let c=0;c<216;c++){let d=b[c/36%6|0],e=b[c/6%6|0],f=b[c%6];a.push({css:cY.toCss(d,e,f),rgba:cY.toRgba(d,e,f)})}for(let b=0;b<24;b++){let c=8+10*b;a.push({css:cY.toCss(c,c,c),rgba:cY.toRgba(c,c,c)})}return a})()),d8=eH.toColor("#ffffff"),d9=eH.toColor("#000000"),ea=eH.toColor("#ffffff"),eb={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},ec=class extends aW{constructor(a){super(),this._optionsService=a,this._contrastCache=new d6,this._halfContrastCache=new d6,this._onChangeColors=this._register(new bd),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:d8,background:d9,cursor:ea,cursorAccent:d9,selectionForeground:void 0,selectionBackgroundTransparent:eb,selectionBackgroundOpaque:eG.blend(d9,eb),selectionInactiveBackgroundTransparent:eb,selectionInactiveBackgroundOpaque:eG.blend(d9,eb),scrollbarSliderBackground:eG.opacity(d8,.2),scrollbarSliderHoverBackground:eG.opacity(d8,.4),scrollbarSliderActiveBackground:eG.opacity(d8,.5),overviewRulerBorder:d8,ansi:d7.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(a={}){let b=this._colors;if(b.foreground=ed(a.foreground,d8),b.background=ed(a.background,d9),b.cursor=eG.blend(b.background,ed(a.cursor,ea)),b.cursorAccent=eG.blend(b.background,ed(a.cursorAccent,d9)),b.selectionBackgroundTransparent=ed(a.selectionBackground,eb),b.selectionBackgroundOpaque=eG.blend(b.background,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundTransparent=ed(a.selectionInactiveBackground,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundOpaque=eG.blend(b.background,b.selectionInactiveBackgroundTransparent),b.selectionForeground=a.selectionForeground?ed(a.selectionForeground,c1):void 0,b.selectionForeground===c1&&(b.selectionForeground=void 0),eG.isOpaque(b.selectionBackgroundTransparent)&&(b.selectionBackgroundTransparent=eG.opacity(b.selectionBackgroundTransparent,.3)),eG.isOpaque(b.selectionInactiveBackgroundTransparent)&&(b.selectionInactiveBackgroundTransparent=eG.opacity(b.selectionInactiveBackgroundTransparent,.3)),b.scrollbarSliderBackground=ed(a.scrollbarSliderBackground,eG.opacity(b.foreground,.2)),b.scrollbarSliderHoverBackground=ed(a.scrollbarSliderHoverBackground,eG.opacity(b.foreground,.4)),b.scrollbarSliderActiveBackground=ed(a.scrollbarSliderActiveBackground,eG.opacity(b.foreground,.5)),b.overviewRulerBorder=ed(a.overviewRulerBorder,d8),b.ansi=d7.slice(),b.ansi[0]=ed(a.black,d7[0]),b.ansi[1]=ed(a.red,d7[1]),b.ansi[2]=ed(a.green,d7[2]),b.ansi[3]=ed(a.yellow,d7[3]),b.ansi[4]=ed(a.blue,d7[4]),b.ansi[5]=ed(a.magenta,d7[5]),b.ansi[6]=ed(a.cyan,d7[6]),b.ansi[7]=ed(a.white,d7[7]),b.ansi[8]=ed(a.brightBlack,d7[8]),b.ansi[9]=ed(a.brightRed,d7[9]),b.ansi[10]=ed(a.brightGreen,d7[10]),b.ansi[11]=ed(a.brightYellow,d7[11]),b.ansi[12]=ed(a.brightBlue,d7[12]),b.ansi[13]=ed(a.brightMagenta,d7[13]),b.ansi[14]=ed(a.brightCyan,d7[14]),b.ansi[15]=ed(a.brightWhite,d7[15]),a.extendedAnsi){let c=Math.min(b.ansi.length-16,a.extendedAnsi.length);for(let d=0;d<c;d++)b.ansi[d+16]=ed(a.extendedAnsi[d],d7[d+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(a){this._restoreColor(a),this._onChangeColors.fire(this.colors)}_restoreColor(a){if(void 0===a){for(let a=0;a<this._restoreColors.ansi.length;++a)this._colors.ansi[a]=this._restoreColors.ansi[a];return}switch(a){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[a]=this._restoreColors.ansi[a]}}modifyColors(a){a(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function ed(a,b){if(void 0!==a)try{return eH.toColor(a)}catch{}return b}ec=Z([$(0,av)],ec);var ee=class{constructor(...a){for(let[b,c]of(this._entries=new Map,a))this.set(b,c)}set(a,b){let c=this._entries.get(a);return this._entries.set(a,b),c}forEach(a){for(let[b,c]of this._entries.entries())a(b,c)}has(a){return this._entries.has(a)}get(a){return this._entries.get(a)}},ef=class{constructor(){this._services=new ee,this._services.set(at,this)}setService(a,b){this._services.set(a,b)}getService(a){return this._services.get(a)}createInstance(a,...b){let c=(a[am]||[]).sort((a,b)=>a.index-b.index),d=[];for(let b of c){let c=this._services.get(b.id);if(!c)throw Error(`[createInstance] ${a.name} depends on UNKNOWN service ${b.id._id}.`);d.push(c)}let e=c.length>0?c[0].index:b.length;if(b.length!==e)throw Error(`[createInstance] First service dependency of ${a.name} at position ${e+1} conflicts with ${b.length} static arguments`);return new a(...b,...d)}},eg={trace:0,debug:1,info:2,warn:3,error:4,off:5},eh=class extends aW{constructor(a){super(),this._optionsService=a,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=eg[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let b=0;b<a.length;b++)"function"==typeof a[b]&&(a[b]=a[b]())}_log(a,b,c){this._evalLazyOptionalParams(c),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+b,...c)}trace(a,...b){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,a,b)}debug(a,...b){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,a,b)}info(a,...b){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,a,b)}warn(a,...b){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,a,b)}error(a,...b){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,a,b)}};eh=Z([$(0,av)],eh);var ei=class extends aW{constructor(a){super(),this._maxLength=a,this.onDeleteEmitter=this._register(new bd),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new bd),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new bd),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(a){if(this._maxLength===a)return;let b=Array(a);for(let c=0;c<Math.min(a,this.length);c++)b[c]=this._array[this._getCyclicIndex(c)];this._array=b,this._maxLength=a,this._startIndex=0}get length(){return this._length}set length(a){if(a>this._length)for(let b=this._length;b<a;b++)this._array[b]=void 0;this._length=a}get(a){return this._array[this._getCyclicIndex(a)]}set(a,b){this._array[this._getCyclicIndex(a)]=b}push(a){this._array[this._getCyclicIndex(this._length)]=a,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw 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(a,b,...c){if(b){for(let c=a;c<this._length-b;c++)this._array[this._getCyclicIndex(c)]=this._array[this._getCyclicIndex(c+b)];this._length-=b,this.onDeleteEmitter.fire({index:a,amount:b})}for(let b=this._length-1;b>=a;b--)this._array[this._getCyclicIndex(b+c.length)]=this._array[this._getCyclicIndex(b)];for(let b=0;b<c.length;b++)this._array[this._getCyclicIndex(a+b)]=c[b];if(c.length&&this.onInsertEmitter.fire({index:a,amount:c.length}),this._length+c.length>this._maxLength){let a=this._length+c.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=c.length}trimStart(a){a>this._length&&(a=this._length),this._startIndex+=a,this._length-=a,this.onTrimEmitter.fire(a)}shiftElements(a,b,c){if(!(b<=0)){if(a<0||a>=this._length)throw Error("start argument out of range");if(a+c<0)throw Error("Cannot shift elements in list beyond index 0");if(c>0){for(let d=b-1;d>=0;d--)this.set(a+d+c,this.get(a+d));let d=a+b+c-this._length;if(d>0)for(this._length+=d;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let d=0;d<b;d++)this.set(a+d+c,this.get(a+d))}}_getCyclicIndex(a){return(this._startIndex+a)%this._maxLength}},ej=Object.freeze(new ai),ek=0,el=class a{constructor(a,b,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);let d=b||ak.fromCharData([0,"",1,0]);for(let b=0;b<a;++b)this.setCell(b,d);this.length=a}get(a){let b=this._data[3*a+0],c=2097151&b;return[this._data[3*a+1],2097152&b?this._combined[a]:c?ae(c):"",b>>22,2097152&b?this._combined[a].charCodeAt(this._combined[a].length-1):c]}set(a,b){this._data[3*a+1]=b[0],b[1].length>1?(this._combined[a]=b[1],this._data[3*a+0]=2097152|a|b[2]<<22):this._data[3*a+0]=b[1].charCodeAt(0)|b[2]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 0xc00000&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){let b=this._data[3*a+0];return 2097152&b?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&b}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){let b=this._data[3*a+0];return 2097152&b?this._combined[a]:2097151&b?ae(2097151&b):""}isProtected(a){return 0x20000000&this._data[3*a+2]}loadCell(a,b){return ek=3*a,b.content=this._data[ek+0],b.fg=this._data[ek+1],b.bg=this._data[ek+2],2097152&b.content&&(b.combinedData=this._combined[a]),0x10000000&b.bg&&(b.extended=this._extendedAttrs[a]),b}setCell(a,b){2097152&b.content&&(this._combined[a]=b.combinedData),0x10000000&b.bg&&(this._extendedAttrs[a]=b.extended),this._data[3*a+0]=b.content,this._data[3*a+1]=b.fg,this._data[3*a+2]=b.bg}setCellFromCodepoint(a,b,c,d){0x10000000&d.bg&&(this._extendedAttrs[a]=d.extended),this._data[3*a+0]=b|c<<22,this._data[3*a+1]=d.fg,this._data[3*a+2]=d.bg}addCodepointToCell(a,b,c){let d=this._data[3*a+0];2097152&d?this._combined[a]+=ae(b):2097151&d?(this._combined[a]=ae(2097151&d)+ae(b),d&=-2097152,d|=2097152):d=4194304|b,c&&(d&=-0xc00001,d|=c<<22),this._data[3*a+0]=d}insertCells(a,b,c){if((a%=this.length)&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length-a){let d=new ak;for(let c=this.length-a-b-1;c>=0;--c)this.setCell(a+b+c,this.loadCell(a+c,d));for(let d=0;d<b;++d)this.setCell(a+d,c)}else for(let b=a;b<this.length;++b)this.setCell(b,c);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,c)}deleteCells(a,b,c){if(a%=this.length,b<this.length-a){let d=new ak;for(let c=0;c<this.length-a-b;++c)this.setCell(a+c,this.loadCell(a+b+c,d));for(let a=this.length-b;a<this.length;++a)this.setCell(a,c)}else for(let b=a;b<this.length;++b)this.setCell(b,c);a&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),0!==this.getWidth(a)||this.hasContent(a)||this.setCellFromCodepoint(a,0,1,c)}replaceCells(a,b,c,d=!1){if(d){for(a&&2===this.getWidth(a-1)&&!this.isProtected(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length&&2===this.getWidth(b-1)&&!this.isProtected(b)&&this.setCellFromCodepoint(b,0,1,c);a<b&&a<this.length;)this.isProtected(a)||this.setCell(a,c),a++;return}for(a&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length&&2===this.getWidth(b-1)&&this.setCellFromCodepoint(b,0,1,c);a<b&&a<this.length;)this.setCell(a++,c)}resize(a,b){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let c=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*c)this._data=new Uint32Array(this._data.buffer,0,c);else{let a=new Uint32Array(c);a.set(this._data),this._data=a}for(let c=this.length;c<a;++c)this.setCell(c,b)}else{this._data=this._data.subarray(0,c);let b=Object.keys(this._combined);for(let c=0;c<b.length;c++){let d=parseInt(b[c],10);d>=a&&delete this._combined[d]}let d=Object.keys(this._extendedAttrs);for(let b=0;b<d.length;b++){let c=parseInt(d[b],10);c>=a&&delete this._extendedAttrs[c]}}return this.length=a,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,b=!1){if(b){for(let b=0;b<this.length;++b)this.isProtected(b)||this.setCell(b,a);return}this._combined={},this._extendedAttrs={};for(let b=0;b<this.length;++b)this.setCell(b,a)}copyFrom(a){for(let b in this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={},a._combined)this._combined[b]=a._combined[b];for(let b in this._extendedAttrs={},a._extendedAttrs)this._extendedAttrs[b]=a._extendedAttrs[b];this.isWrapped=a.isWrapped}clone(){let b=new a(0);for(let a in b._data=new Uint32Array(this._data),b.length=this.length,this._combined)b._combined[a]=this._combined[a];for(let a in this._extendedAttrs)b._extendedAttrs[a]=this._extendedAttrs[a];return b.isWrapped=this.isWrapped,b}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||0x3000000&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,b,c,d,e){let f=a._data;if(e)for(let e=d-1;e>=0;e--){for(let a=0;a<3;a++)this._data[(c+e)*3+a]=f[(b+e)*3+a];0x10000000&f[(b+e)*3+2]&&(this._extendedAttrs[c+e]=a._extendedAttrs[b+e])}else for(let e=0;e<d;e++){for(let a=0;a<3;a++)this._data[(c+e)*3+a]=f[(b+e)*3+a];0x10000000&f[(b+e)*3+2]&&(this._extendedAttrs[c+e]=a._extendedAttrs[b+e])}let g=Object.keys(a._combined);for(let d=0;d<g.length;d++){let e=parseInt(g[d],10);e>=b&&(this._combined[e-b+c]=a._combined[e])}}translateToString(a,b,c,d){b=b??0,c=c??this.length,a&&(c=Math.min(c,this.getTrimmedLength())),d&&(d.length=0);let e="";for(;b<c;){let a=this._data[3*b+0],c=2097151&a,f=2097152&a?this._combined[b]:c?ae(c):" ";if(e+=f,d)for(let a=0;a<f.length;++a)d.push(b);b+=a>>22||1}return d&&d.push(b),e}};function em(a,b,c){if(b===a.length-1)return a[b].getTrimmedLength();let d=!a[b].hasContent(c-1)&&1===a[b].getWidth(c-1),e=2===a[b+1].getWidth(0);return d&&e?c-1:c}var en=class a{constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new bd),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),aS(this._disposables),this._disposables.length=0)}register(a){return this._disposables.push(a),a}};en._nextId=1;var eo={},ep=eo.B;eo[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:"≥","{":"π","|":"≠","}":"£","~":"·"},eo.A={"#":"£"},eo.B=void 0,eo[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},eo.C=eo[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},eo.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},eo.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},eo.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},eo.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},eo.E=eo[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},eo.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},eo.H=eo[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},eo["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var eq=class{constructor(a,b,c){this._hasScrollback=a,this._optionsService=b,this._bufferService=c,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ej.clone(),this.savedCharset=ep,this.markers=[],this._nullCell=ak.fromCharData([0,"",1,0]),this._whitespaceCell=ak.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new dU,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ei(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(a){return a?(this._nullCell.fg=a.fg,this._nullCell.bg=a.bg,this._nullCell.extended=a.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new aj),this._nullCell}getWhitespaceCell(a){return a?(this._whitespaceCell.fg=a.fg,this._whitespaceCell.bg=a.bg,this._whitespaceCell.extended=a.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new aj),this._whitespaceCell}getBlankLine(a,b){return new el(this._bufferService.cols,this.getNullCell(a),b)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let a=this.ybase+this.y-this.ydisp;return a>=0&&a<this._rows}_getCorrectBufferLength(a){if(!this._hasScrollback)return a;let b=a+this._optionsService.rawOptions.scrollback;return b>0xffffffff?0xffffffff:b}fillViewportRows(a){if(0===this.lines.length){void 0===a&&(a=ej);let b=this._rows;for(;b--;)this.lines.push(this.getBlankLine(a))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ei(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(a,b){let c=this.getNullCell(ej),d=0,e=this._getCorrectBufferLength(b);if(e>this.lines.maxLength&&(this.lines.maxLength=e),this.lines.length>0){if(this._cols<a)for(let b=0;b<this.lines.length;b++)d+=+this.lines.get(b).resize(a,c);let f=0;if(this._rows<b)for(let d=this._rows;d<b;d++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new el(a,c)):this.ybase>0&&this.lines.length<=this.ybase+this.y+f+1?(this.ybase--,f++,this.ydisp>0&&this.ydisp--):this.lines.push(new el(a,c)));else for(let a=this._rows;a>b;a--)this.lines.length>b+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(e<this.lines.maxLength){let a=this.lines.length-e;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=e}this.x=Math.min(this.x,a-1),this.y=Math.min(this.y,b-1),f&&(this.y+=f),this.savedX=Math.min(this.savedX,a-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(a,b),this._cols>a))for(let b=0;b<this.lines.length;b++)d+=+this.lines.get(b).resize(a,c);this._cols=a,this._rows=b,this._memoryCleanupQueue.clear(),d>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let a=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,a=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if((b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return a}get _isReflowEnabled(){let a=this._optionsService.rawOptions.windowsPty;return a&&a.buildNumber?this._hasScrollback&&"conpty"===a.backend&&a.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(a,b){this._cols!==a&&(a>this._cols?this._reflowLarger(a,b):this._reflowSmaller(a,b))}_reflowLarger(a,b){let c=this._optionsService.rawOptions.reflowCursorLine,d=function(a,b,c,d,e,f){let g=[];for(let h=0;h<a.length-1;h++){let i=h,j=a.get(++i);if(!j.isWrapped)continue;let k=[a.get(h)];for(;i<a.length&&j.isWrapped;)k.push(j),j=a.get(++i);if(!f&&d>=h&&d<i){h+=k.length-1;continue}let l=0,m=em(k,0,b),n=1,o=0;for(;n<k.length;){let a=em(k,n,b),d=Math.min(a-o,c-m);k[l].copyCellsFrom(k[n],o,m,d,!1),(m+=d)===c&&(l++,m=0),(o+=d)===a&&(n++,o=0),0===m&&0!==l&&2===k[l-1].getWidth(c-1)&&(k[l].copyCellsFrom(k[l-1],c-1,m++,1,!1),k[l-1].setCell(c-1,e))}k[l].replaceCells(m,c,e);let p=0;for(let a=k.length-1;a>0&&(a>l||0===k[a].getTrimmedLength());a--)p++;p>0&&(g.push(h+k.length-p),g.push(p)),h+=k.length-1}return g}(this.lines,this._cols,a,this.ybase+this.y,this.getNullCell(ej),c);if(d.length>0){let c=function(a,b){let c=[],d=0,e=b[0],f=0;for(let g=0;g<a.length;g++)if(e===g){let c=b[++d];a.onDeleteEmitter.fire({index:g-f,amount:c}),g+=c-1,f+=c,e=b[++d]}else c.push(g);return{layout:c,countRemoved:f}}(this.lines,d);(function(a,b){let c=[];for(let d=0;d<b.length;d++)c.push(a.get(b[d]));for(let b=0;b<c.length;b++)a.set(b,c[b]);a.length=b.length})(this.lines,c.layout),this._reflowLargerAdjustViewport(a,b,c.countRemoved)}}_reflowLargerAdjustViewport(a,b,c){let d=this.getNullCell(ej),e=c;for(;e-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new el(a,d))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-c,0)}_reflowSmaller(a,b){let c=this._optionsService.rawOptions.reflowCursorLine,d=this.getNullCell(ej),e=[],f=0;for(let g=this.lines.length-1;g>=0;g--){let h=this.lines.get(g);if(!h||!h.isWrapped&&h.getTrimmedLength()<=a)continue;let i=[h];for(;h.isWrapped&&g>0;)h=this.lines.get(--g),i.unshift(h);if(!c){let a=this.ybase+this.y;if(a>=g&&a<g+i.length)continue}let j=i[i.length-1].getTrimmedLength(),k=function(a,b,c){let d=[],e=a.map((c,d)=>em(a,d,b)).reduce((a,b)=>a+b),f=0,g=0,h=0;for(;h<e;){if(e-h<c){d.push(e-h);break}f+=c;let i=em(a,g,b);f>i&&(f-=i,g++);let j=2===a[g].getWidth(f-1);j&&f--;let k=j?c-1:c;d.push(k),h+=k}return d}(i,this._cols,a),l=k.length-i.length,m;m=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+l):Math.max(0,this.lines.length-this.lines.maxLength+l);let n=[];for(let a=0;a<l;a++){let a=this.getBlankLine(ej,!0);n.push(a)}n.length>0&&(e.push({start:g+i.length+f,newLines:n}),f+=n.length),i.push(...n);let o=k.length-1,p=k[o];0===p&&(p=k[--o]);let q=i.length-l-1,r=j;for(;q>=0;){let a=Math.min(r,p);if(void 0===i[o])break;i[o].copyCellsFrom(i[q],r-a,p-a,a,!0),0==(p-=a)&&(p=k[--o]),0==(r-=a)&&(r=em(i,Math.max(--q,0),this._cols))}for(let b=0;b<i.length;b++)k[b]<a&&i[b].setCell(k[b],d);let s=l-m;for(;s-- >0;)0===this.ybase?this.y<b-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+f)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+l,this.ybase+b-1)}if(e.length>0){let a=[],b=[];for(let a=0;a<this.lines.length;a++)b.push(this.lines.get(a));let c=this.lines.length,d=c-1,g=0,h=e[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+f);let i=0;for(let j=Math.min(this.lines.maxLength-1,c+f-1);j>=0;j--)if(h&&h.start>d+i){for(let a=h.newLines.length-1;a>=0;a--)this.lines.set(j--,h.newLines[a]);j++,a.push({index:d+1,amount:h.newLines.length}),i+=h.newLines.length,h=e[++g]}else this.lines.set(j,b[d--]);let j=0;for(let b=a.length-1;b>=0;b--)a[b].index+=j,this.lines.onInsertEmitter.fire(a[b]),j+=a[b].amount;let k=Math.max(0,c+f-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(a,b,c=0,d){let e=this.lines.get(a);return e?e.translateToString(b,c,d):""}getWrappedRangeForLine(a){let b=a,c=a;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;c+1<this.lines.length&&this.lines.get(c+1).isWrapped;)c++;return{first:b,last:c}}setupTabStops(a){for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0);a<this._cols;a+=this._optionsService.rawOptions.tabStopWidth)this.tabs[a]=!0}prevStop(a){for(null==a&&(a=this.x);!this.tabs[--a]&&a>0;);return a>=this._cols?this._cols-1:a<0?0:a}nextStop(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a<this._cols;);return a>=this._cols?this._cols-1:a<0?0:a}clearMarkers(a){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].line===a&&(this.markers[b].dispose(),this.markers.splice(b--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let a=0;a<this.markers.length;a++)this.markers[a].dispose();this.markers.length=0,this._isClearing=!1}addMarker(a){let b=new en(a);return this.markers.push(b),b.register(this.lines.onTrim(a=>{b.line-=a,b.line<0&&b.dispose()})),b.register(this.lines.onInsert(a=>{b.line>=a.index&&(b.line+=a.amount)})),b.register(this.lines.onDelete(a=>{b.line>=a.index&&b.line<a.index+a.amount&&b.dispose(),b.line>a.index&&(b.line-=a.amount)})),b.register(b.onDispose(()=>this._removeMarker(b))),b}_removeMarker(a){this._isClearing||this.markers.splice(this.markers.indexOf(a),1)}},er=class extends aW{constructor(a,b){super(),this._optionsService=a,this._bufferService=b,this._onBufferActivate=this._register(new bd),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 eq(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new eq(!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(a){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(a),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(a,b){this._normal.resize(a,b),this._alt.resize(a,b),this.setupTabStops(a)}setupTabStops(a){this._normal.setupTabStops(a),this._alt.setupTabStops(a)}},es=class extends aW{constructor(a){super(),this.isUserScrolling=!1,this._onResize=this._register(new bd),this.onResize=this._onResize.event,this._onScroll=this._register(new bd),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,2),this.rows=Math.max(a.rawOptions.rows||0,1),this.buffers=this._register(new er(a,this)),this._register(this.buffers.onBufferActivate(a=>{this._onScroll.fire(a.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(a,b){let c=this.cols!==a,d=this.rows!==b;this.cols=a,this.rows=b,this.buffers.resize(a,b),this._onResize.fire({cols:a,rows:b,colsChanged:c,rowsChanged:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,b=!1){let c=this.buffer,d;(d=this._cachedBlankLine)&&d.length===this.cols&&d.getFg(0)===a.fg&&d.getBg(0)===a.bg||(d=c.getBlankLine(a,b),this._cachedBlankLine=d),d.isWrapped=b;let e=c.ybase+c.scrollTop,f=c.ybase+c.scrollBottom;if(0===c.scrollTop){let a=c.lines.isFull;f===c.lines.length-1?a?c.lines.recycle().copyFrom(d):c.lines.push(d.clone()):c.lines.splice(f+1,0,d.clone()),a?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{let a=f-e+1;c.lines.shiftElements(e+1,a-1,-1),c.lines.set(f,d.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(a,b){let c=this.buffer;if(a<0){if(0===c.ydisp)return;this.isUserScrolling=!0}else a+c.ydisp>=c.ybase&&(this.isUserScrolling=!1);let d=c.ydisp;c.ydisp=Math.max(Math.min(c.ydisp+a,c.ybase),0),d!==c.ydisp&&(b||this._onScroll.fire(c.ydisp))}};es=Z([$(0,av)],es);var et={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:dL,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},eu=["normal","bold","100","200","300","400","500","600","700","800","900"],ev=class extends aW{constructor(a){super(),this._onOptionChange=this._register(new bd),this.onOptionChange=this._onOptionChange.event;let b={...et};for(let c in a)if(c in b)try{let d=a[c];b[c]=this._sanitizeAndValidateOption(c,d)}catch(a){console.error(a)}this.rawOptions=b,this.options={...b},this._setupOptions(),this._register(aT(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(a,b){return this.onOptionChange(c=>{c===a&&b(this.rawOptions[a])})}onMultipleOptionChange(a,b){return this.onOptionChange(c=>{-1!==a.indexOf(c)&&b()})}_setupOptions(){let a=a=>{if(!(a in et))throw Error(`No option with key "${a}"`);return this.rawOptions[a]},b=(a,b)=>{if(!(a in et))throw Error(`No option with key "${a}"`);b=this._sanitizeAndValidateOption(a,b),this.rawOptions[a]!==b&&(this.rawOptions[a]=b,this._onOptionChange.fire(a))};for(let c in this.rawOptions){let d={get:a.bind(this,c),set:b.bind(this,c)};Object.defineProperty(this.options,c,d)}}_sanitizeAndValidateOption(a,b){switch(a){case"cursorStyle":var c;if(b||(b=et[a]),"block"!==(c=b)&&"underline"!==c&&"bar"!==c)throw Error(`"${b}" is not a valid value for ${a}`);break;case"wordSeparator":b||(b=et[a]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof b&&1<=b&&b<=1e3)break;b=eu.includes(b)?b:et[a];break;case"cursorWidth":b=Math.floor(b);case"lineHeight":case"tabStopWidth":if(b<1)throw Error(`${a} cannot be less than 1, value: ${b}`);break;case"minimumContrastRatio":b=Math.max(1,Math.min(21,Math.round(10*b)/10));break;case"scrollback":if((b=Math.min(b,0xffffffff))<0)throw Error(`${a} cannot be less than 0, value: ${b}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(b<=0)throw Error(`${a} cannot be less than or equal to 0, value: ${b}`);break;case"rows":case"cols":if(!b&&0!==b)throw Error(`${a} must be numeric, value: ${b}`);break;case"windowsPty":b=b??{}}return b}};function ew(a,b=5){if("object"!=typeof a)return a;let c=Array.isArray(a)?[]:{};for(let d in a)c[d]=b<=1?a[d]:a[d]&&ew(a[d],b-1);return c}var ex=Object.freeze({insertMode:!1}),ey=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ez=class extends aW{constructor(a,b,c){super(),this._bufferService=a,this._logService=b,this._optionsService=c,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new bd),this.onData=this._onData.event,this._onUserInput=this._register(new bd),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new bd),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new bd),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ew(ex),this.decPrivateModes=ew(ey)}reset(){this.modes=ew(ex),this.decPrivateModes=ew(ey)}triggerDataEvent(a,b=!1){if(this._optionsService.rawOptions.disableStdin)return;let c=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&c.ybase!==c.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${a}"`),this._logService.trace("sending data (codes)",()=>a.split("").map(a=>a.charCodeAt(0))),this._onData.fire(a)}triggerBinaryEvent(a){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${a}"`),this._logService.trace("sending binary (codes)",()=>a.split("").map(a=>a.charCodeAt(0))),this._onBinary.fire(a))}};ez=Z([$(0,ap),$(1,au),$(2,av)],ez);var eA={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:a=>4!==a.button&&1===a.action&&(a.ctrl=!1,a.alt=!1,a.shift=!1,!0)},VT200:{events:19,restrict:a=>32!==a.action},DRAG:{events:23,restrict:a=>32!==a.action||3!==a.button},ANY:{events:31,restrict:a=>!0}};function eB(a,b){let c=16*!!a.ctrl|4*!!a.shift|8*!!a.alt;return 4===a.button?(c|=64,c|=a.action):(c|=3&a.button,4&a.button&&(c|=64),8&a.button&&(c|=128),32===a.action?c|=32:0!==a.action||b||(c|=3)),c}var eC=String.fromCharCode,eD={DEFAULT:a=>{let b=[eB(a,!1)+32,a.col+32,a.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1b[M${eC(b[0])}${eC(b[1])}${eC(b[2])}`},SGR:a=>{let b=0===a.action&&4!==a.button?"m":"M";return`\x1b[<${eB(a,!0)};${a.col};${a.row}${b}`},SGR_PIXELS:a=>{let b=0===a.action&&4!==a.button?"m":"M";return`\x1b[<${eB(a,!0)};${a.x};${a.y}${b}`}},eE=class extends aW{constructor(a,b,c){for(let d of(super(),this._bufferService=a,this._coreService=b,this._optionsService=c,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new bd),this.onProtocolChange=this._onProtocolChange.event,Object.keys(eA)))this.addProtocol(d,eA[d]);for(let a of Object.keys(eD))this.addEncoding(a,eD[a]);this.reset()}addProtocol(a,b){this._protocols[a]=b}addEncoding(a,b){this._encodings[a]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(a){if(!this._protocols[a])throw Error(`unknown protocol "${a}"`);this._activeProtocol=a,this._onProtocolChange.fire(this._protocols[a].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(a){if(!this._encodings[a])throw Error(`unknown encoding "${a}"`);this._activeEncoding=a}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(a,b,c){if(0===a.deltaY||a.shiftKey||void 0===b||void 0===c)return 0;let d=this._applyScrollModifier(a.deltaY,a);return a.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=b/c+0,50>Math.abs(a.deltaY)&&(d*=.3),this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):a.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(a,b){return b.altKey||b.ctrlKey||b.shiftKey?a*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:a*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(a){if(a.col<0||a.col>=this._bufferService.cols||a.row<0||a.row>=this._bufferService.rows||4===a.button&&32===a.action||3===a.button&&32!==a.action||4!==a.button&&(2===a.action||3===a.action)||(a.col++,a.row++,32===a.action&&this._lastEvent&&this._equalEvents(this._lastEvent,a,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(a))return!1;let b=this._encodings[this._activeEncoding](a);return b&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=a,!0}explainEvents(a){return{down:!!(1&a),up:!!(2&a),drag:!!(4&a),move:!!(8&a),wheel:!!(16&a)}}_equalEvents(a,b,c){if(c){if(a.x!==b.x||a.y!==b.y)return!1}else if(a.col!==b.col||a.row!==b.row)return!1;return a.button===b.button&&a.action===b.action&&a.ctrl===b.ctrl&&a.alt===b.alt&&a.shift===b.shift}};eE=Z([$(0,ap),$(1,ar),$(2,av)],eE);var eF,eG,eH,eI,eJ,eK,eL=[[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]],eM=[[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]],eN=class{constructor(){if(this.version="6",!eK){(eK=new Uint8Array(65536)).fill(1),eK[0]=0,eK.fill(0,1,32),eK.fill(0,127,160),eK.fill(2,4352,4448),eK[9001]=2,eK[9002]=2,eK.fill(2,11904,42192),eK[12351]=1,eK.fill(2,44032,55204),eK.fill(2,63744,64256),eK.fill(2,65040,65050),eK.fill(2,65072,65136),eK.fill(2,65280,65377),eK.fill(2,65504,65511);for(let a=0;a<eL.length;++a)eK.fill(0,eL[a][0],eL[a][1]+1)}}wcwidth(a){return a<32?0:a<127?1:a<65536?eK[a]:!function(a,b){let c=0,d=b.length-1,e;if(a<b[0][0]||a>b[d][1])return!1;for(;d>=c;)if(a>b[e=c+d>>1][1])c=e+1;else{if(!(a<b[e][0]))return!0;d=e-1}return!1}(a,eM)?a>=131072&&a<=196605||a>=196608&&a<=262141?2:1:0}charProperties(a,b){let c=this.wcwidth(a),d=0===c&&0!==b;if(d){let a=eO.extractWidth(b);0===a?d=!1:a>c&&(c=a)}return eO.createPropertyValue(0,c,d)}},eO=class a{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new bd,this.onChange=this._onChange.event;let a=new eN;this.register(a),this._active=a.version,this._activeProvider=a}static extractShouldJoin(a){return(1&a)!=0}static extractWidth(a){return a>>1&3}static extractCharKind(a){return a>>3}static createPropertyValue(a,b,c=!1){return(0xffffff&a)<<3|(3&b)<<1|!!c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(a){if(!this._providers[a])throw Error(`unknown Unicode version "${a}"`);this._active=a,this._activeProvider=this._providers[a],this._onChange.fire(a)}register(a){this._providers[a.version]=a}wcwidth(a){return this._activeProvider.wcwidth(a)}getStringCellWidth(b){let c=0,d=0,e=b.length;for(let f=0;f<e;++f){let g=b.charCodeAt(f);if(55296<=g&&g<=56319){if(++f>=e)return c+this.wcwidth(g);let a=b.charCodeAt(f);56320<=a&&a<=57343?g=(g-55296)*1024+a-56320+65536:c+=this.wcwidth(a)}let h=this.charProperties(g,d),i=a.extractWidth(h);a.extractShouldJoin(h)&&(i-=a.extractWidth(d)),c+=i,d=h}return c}charProperties(a,b){return this._activeProvider.charProperties(a,b)}},eP=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(a){this.glevel=a,this.charset=this._charsets[a]}setgCharset(a,b){this._charsets[a]=b,this.glevel===a&&(this.charset=b)}};function eQ(a){let b=a.buffer.lines.get(a.buffer.ybase+a.buffer.y-1)?.get(a.cols-1),c=a.buffer.lines.get(a.buffer.ybase+a.buffer.y);c&&b&&(c.isWrapped=0!==b[3]&&32!==b[3])}var eR=class a{constructor(a=32,b=32){if(this.maxLength=a,this.maxSubParamsLength=b,b>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(a),this.length=0,this._subParams=new Int32Array(b),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(a),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(b){let c=new a;if(!b.length)return c;for(let a=+!!Array.isArray(b[0]);a<b.length;++a){let d=b[a];if(Array.isArray(d))for(let a=0;a<d.length;++a)c.addSubParam(d[a]);else c.addParam(d)}return c}clone(){let b=new a(this.maxLength,this.maxSubParamsLength);return b.params.set(this.params),b.length=this.length,b._subParams.set(this._subParams),b._subParamsLength=this._subParamsLength,b._subParamsIdx.set(this._subParamsIdx),b._rejectDigits=this._rejectDigits,b._rejectSubDigits=this._rejectSubDigits,b._digitIsSub=this._digitIsSub,b}toArray(){let a=[];for(let b=0;b<this.length;++b){a.push(this.params[b]);let c=this._subParamsIdx[b]>>8,d=255&this._subParamsIdx[b];d-c>0&&a.push(Array.prototype.slice.call(this._subParams,c,d))}return a}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(a){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(a<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=a>0x7fffffff?0x7fffffff:a}addSubParam(a){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(a<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=a>0x7fffffff?0x7fffffff:a,this._subParamsIdx[this.length-1]++}}hasSubParams(a){return(255&this._subParamsIdx[a])-(this._subParamsIdx[a]>>8)>0}getSubParams(a){let b=this._subParamsIdx[a]>>8,c=255&this._subParamsIdx[a];return c-b>0?this._subParams.subarray(b,c):null}getSubParamsAll(){let a={};for(let b=0;b<this.length;++b){let c=this._subParamsIdx[b]>>8,d=255&this._subParamsIdx[b];d-c>0&&(a[b]=this._subParams.slice(c,d))}return a}addDigit(a){let b;if(this._rejectDigits||!(b=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let c=this._digitIsSub?this._subParams:this.params,d=c[b-1];c[b-1]=~d?Math.min(10*d+a,0x7fffffff):a}},eS=[],eT=class{constructor(){this._state=0,this._active=eS,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(a,b){void 0===this._handlers[a]&&(this._handlers[a]=[]);let c=this._handlers[a];return c.push(b),{dispose:()=>{let a=c.indexOf(b);-1!==a&&c.splice(a,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=eS}reset(){if(2===this._state)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].end(!1);this._stack.paused=!1,this._active=eS,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||eS,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].start();else this._handlerFb(this._id,"START")}_put(a,b,c){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(a,b,c);else this._handlerFb(this._id,"PUT",af(a,b,c))}start(){this.reset(),this._state=1}put(a,b,c){if(3!==this._state){if(1===this._state)for(;b<c;){let c=a[b++];if(59===c){this._state=2,this._start();break}if(c<48||57<c){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+c-48}2===this._state&&c-b>0&&this._put(a,b,c)}}end(a,b=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let c=!1,d=this._active.length-1,e=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,c=b,e=this._stack.fallThrough,this._stack.paused=!1),!e&&!1===c){for(;d>=0&&!0!==(c=this._active[d].end(a));d--)if(c instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,c;d--}for(;d>=0;d--)if((c=this._active[d].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,c}else this._handlerFb(this._id,"END",a);this._active=eS,this._id=-1,this._state=0}}},eU=class{constructor(a){this._handler=a,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(a,b,c){this._hitLimit||(this._data+=af(a,b,c),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(a){let b=!1;if(this._hitLimit)b=!1;else if(a&&(b=this._handler(this._data))instanceof Promise)return b.then(a=>(this._data="",this._hitLimit=!1,a));return this._data="",this._hitLimit=!1,b}},eV=[],eW=class{constructor(){this._handlers=Object.create(null),this._active=eV,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=eV}registerHandler(a,b){void 0===this._handlers[a]&&(this._handlers[a]=[]);let c=this._handlers[a];return c.push(b),{dispose:()=>{let a=c.indexOf(b);-1!==a&&c.splice(a,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}reset(){if(this._active.length)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].unhook(!1);this._stack.paused=!1,this._active=eV,this._ident=0}hook(a,b){if(this.reset(),this._ident=a,this._active=this._handlers[a]||eV,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(a,b,c){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(a,b,c);else this._handlerFb(this._ident,"PUT",af(a,b,c))}unhook(a,b=!0){if(this._active.length){let c=!1,d=this._active.length-1,e=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,c=b,e=this._stack.fallThrough,this._stack.paused=!1),!e&&!1===c){for(;d>=0&&!0!==(c=this._active[d].unhook(a));d--)if(c instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,c;d--}for(;d>=0;d--)if((c=this._active[d].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,c}else this._handlerFb(this._ident,"UNHOOK",a);this._active=eV,this._ident=0}},eX=new eR;eX.addParam(0);var eY=class{constructor(a){this._handler=a,this._data="",this._params=eX,this._hitLimit=!1}hook(a){this._params=a.length>1||a.params[0]?a.clone():eX,this._data="",this._hitLimit=!1}put(a,b,c){this._hitLimit||(this._data+=af(a,b,c),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(a){let b=!1;if(this._hitLimit)b=!1;else if(a&&(b=this._handler(this._data,this._params))instanceof Promise)return b.then(a=>(this._params=eX,this._data="",this._hitLimit=!1,a));return this._params=eX,this._data="",this._hitLimit=!1,b}},eZ=class{constructor(a){this.table=new Uint8Array(a)}setDefault(a,b){this.table.fill(a<<4|b)}add(a,b,c,d){this.table[b<<8|a]=c<<4|d}addMany(a,b,c,d){for(let e=0;e<a.length;e++)this.table[b<<8|a[e]]=c<<4|d}},e$=function(){let a=new eZ(4095),b=Array.apply(null,Array(256)).map((a,b)=>b),c=(a,c)=>b.slice(a,c),d=c(32,127),e=c(0,24);e.push(25),e.push.apply(e,c(28,32));let f=c(0,14),g;for(g in a.setDefault(1,0),a.addMany(d,0,2,0),f)a.addMany([24,26,153,154],g,3,0),a.addMany(c(128,144),g,3,0),a.addMany(c(144,152),g,3,0),a.add(156,g,0,0),a.add(27,g,11,1),a.add(157,g,4,8),a.addMany([152,158,159],g,0,7),a.add(155,g,11,3),a.add(144,g,11,9);return a.addMany(e,0,3,0),a.addMany(e,1,3,1),a.add(127,1,0,1),a.addMany(e,8,0,8),a.addMany(e,3,3,3),a.add(127,3,0,3),a.addMany(e,4,3,4),a.add(127,4,0,4),a.addMany(e,6,3,6),a.addMany(e,5,3,5),a.add(127,5,0,5),a.addMany(e,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(d,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(c(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(d,7,0,7),a.addMany(e,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(c(64,127),3,7,0),a.addMany(c(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(c(48,60),4,8,4),a.addMany(c(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(c(32,64),6,0,6),a.add(127,6,0,6),a.addMany(c(64,127),6,0,0),a.addMany(c(32,48),3,9,5),a.addMany(c(32,48),5,9,5),a.addMany(c(48,64),5,0,6),a.addMany(c(64,127),5,7,0),a.addMany(c(32,48),4,9,5),a.addMany(c(32,48),1,9,2),a.addMany(c(32,48),2,9,2),a.addMany(c(48,127),2,10,0),a.addMany(c(48,80),1,10,0),a.addMany(c(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(c(96,127),1,10,0),a.add(80,1,11,9),a.addMany(e,9,0,9),a.add(127,9,0,9),a.addMany(c(28,32),9,0,9),a.addMany(c(32,48),9,9,12),a.addMany(c(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(e,11,0,11),a.addMany(c(32,128),11,0,11),a.addMany(c(28,32),11,0,11),a.addMany(e,10,0,10),a.add(127,10,0,10),a.addMany(c(28,32),10,0,10),a.addMany(c(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(c(32,48),10,9,12),a.addMany(e,12,0,12),a.add(127,12,0,12),a.addMany(c(28,32),12,0,12),a.addMany(c(32,48),12,9,12),a.addMany(c(48,64),12,0,11),a.addMany(c(64,127),12,12,13),a.addMany(c(64,127),10,12,13),a.addMany(c(64,127),9,12,13),a.addMany(e,13,13,13),a.addMany(d,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(160,0,2,0),a.add(160,8,5,8),a.add(160,6,0,6),a.add(160,11,0,11),a.add(160,13,13,13),a}(),e_=class extends aW{constructor(a=e$){super(),this._transitions=a,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new eR,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(a,b,c)=>{},this._executeHandlerFb=a=>{},this._csiHandlerFb=(a,b)=>{},this._escHandlerFb=a=>{},this._errorHandlerFb=a=>a,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(aT(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new eT),this._dcsParser=this._register(new eW),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(a,b=[64,126]){let c=0;if(a.prefix){if(a.prefix.length>1)throw Error("only one byte as prefix supported");if((c=a.prefix.charCodeAt(0))&&60>c||c>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(a.intermediates){if(a.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let b=0;b<a.intermediates.length;++b){let d=a.intermediates.charCodeAt(b);if(32>d||d>47)throw Error("intermediate must be in range 0x20 .. 0x2f");c<<=8,c|=d}}if(1!==a.final.length)throw Error("final must be a single byte");let d=a.final.charCodeAt(0);if(b[0]>d||d>b[1])throw Error(`final must be in range ${b[0]} .. ${b[1]}`);return c<<=8,c|=d}identToString(a){let b=[];for(;a;)b.push(String.fromCharCode(255&a)),a>>=8;return b.reverse().join("")}setPrintHandler(a){this._printHandler=a}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(a,b){let c=this._identifier(a,[48,126]);void 0===this._escHandlers[c]&&(this._escHandlers[c]=[]);let d=this._escHandlers[c];return d.push(b),{dispose:()=>{let a=d.indexOf(b);-1!==a&&d.splice(a,1)}}}clearEscHandler(a){this._escHandlers[this._identifier(a,[48,126])]&&delete this._escHandlers[this._identifier(a,[48,126])]}setEscHandlerFallback(a){this._escHandlerFb=a}setExecuteHandler(a,b){this._executeHandlers[a.charCodeAt(0)]=b}clearExecuteHandler(a){this._executeHandlers[a.charCodeAt(0)]&&delete this._executeHandlers[a.charCodeAt(0)]}setExecuteHandlerFallback(a){this._executeHandlerFb=a}registerCsiHandler(a,b){let c=this._identifier(a);void 0===this._csiHandlers[c]&&(this._csiHandlers[c]=[]);let d=this._csiHandlers[c];return d.push(b),{dispose:()=>{let a=d.indexOf(b);-1!==a&&d.splice(a,1)}}}clearCsiHandler(a){this._csiHandlers[this._identifier(a)]&&delete this._csiHandlers[this._identifier(a)]}setCsiHandlerFallback(a){this._csiHandlerFb=a}registerDcsHandler(a,b){return this._dcsParser.registerHandler(this._identifier(a),b)}clearDcsHandler(a){this._dcsParser.clearHandler(this._identifier(a))}setDcsHandlerFallback(a){this._dcsParser.setHandlerFallback(a)}registerOscHandler(a,b){return this._oscParser.registerHandler(a,b)}clearOscHandler(a){this._oscParser.clearHandler(a)}setOscHandlerFallback(a){this._oscParser.setHandlerFallback(a)}setErrorHandler(a){this._errorHandler=a}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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(a,b,c,d,e){this._parseStack.state=a,this._parseStack.handlers=b,this._parseStack.handlerPos=c,this._parseStack.transition=d,this._parseStack.chunkPos=e}parse(a,b,c){let d=0,e=0,f=0,g;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,f=this._parseStack.chunkPos+1;else{if(void 0===c||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let b=this._parseStack.handlers,e=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===c&&e>-1){for(;e>=0&&!0!==(g=b[e](this._params));e--)if(g instanceof Promise)return this._parseStack.handlerPos=e,g}this._parseStack.handlers=[];break;case 4:if(!1===c&&e>-1){for(;e>=0&&!0!==(g=b[e]());e--)if(g instanceof Promise)return this._parseStack.handlerPos=e,g}this._parseStack.handlers=[];break;case 6:if(d=a[this._parseStack.chunkPos],g=this._dcsParser.unhook(24!==d&&26!==d,c))return g;27===d&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(d=a[this._parseStack.chunkPos],g=this._oscParser.end(24!==d&&26!==d,c))return g;27===d&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,f=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let c=f;c<b;++c){switch(d=a[c],(e=this._transitions.table[this.currentState<<8|(d<160?d:160)])>>4){case 2:for(let e=c+1;;++e)if(e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160){this._printHandler(a,c,e),c=e-1;break}break;case 3:this._executeHandlers[d]?this._executeHandlers[d]():this._executeHandlerFb(d),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,code:d,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|d],h=f?f.length-1:-1;for(;h>=0&&!0!==(g=f[h](this._params));h--)if(g instanceof Promise)return this._preserveStack(3,f,h,e,c),g;h<0&&this._csiHandlerFb(this._collect<<8|d,this._params),this.precedingJoinState=0;break;case 8:do switch(d){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(d-48)}while(++c<b&&(d=a[c])>47&&d<60)c--;break;case 9:this._collect<<=8,this._collect|=d;break;case 10:let i=this._escHandlers[this._collect<<8|d],j=i?i.length-1:-1;for(;j>=0&&!0!==(g=i[j]());j--)if(g instanceof Promise)return this._preserveStack(4,i,j,e,c),g;j<0&&this._escHandlerFb(this._collect<<8|d),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|d,this._params);break;case 13:for(let e=c+1;;++e)if(e>=b||24===(d=a[e])||26===d||27===d||d>127&&d<160){this._dcsParser.put(a,c,e),c=e-1;break}break;case 14:if(g=this._dcsParser.unhook(24!==d&&26!==d))return this._preserveStack(6,[],0,e,c),g;27===d&&(e|=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 e=c+1;;e++)if(e>=b||(d=a[e])<32||d>127&&d<160){this._oscParser.put(a,c,e),c=e-1;break}break;case 6:if(g=this._oscParser.end(24!==d&&26!==d))return this._preserveStack(5,[],0,e,c),g;27===d&&(e|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&e}}},e0=/^([\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})$/,e1=/^[\da-f]+$/;function e2(a){if(!a)return;let b=a.toLowerCase();if(0===b.indexOf("rgb:")){b=b.slice(4);let a=e0.exec(b);if(a){let b=a[1]?15:a[4]?255:a[7]?4095:65535;return[Math.round(parseInt(a[1]||a[4]||a[7]||a[10],16)/b*255),Math.round(parseInt(a[2]||a[5]||a[8]||a[11],16)/b*255),Math.round(parseInt(a[3]||a[6]||a[9]||a[12],16)/b*255)]}}else if(0===b.indexOf("#")&&(b=b.slice(1),e1.exec(b)&&[3,6,9,12].includes(b.length))){let a=b.length/3,c=[0,0,0];for(let d=0;d<3;++d){let e=parseInt(b.slice(a*d,a*d+a),16);c[d]=1===a?e<<4:2===a?e:3===a?e>>4:e>>8}return c}}function e3(a,b){let c=a.toString(16),d=c.length<2?"0"+c:c;switch(b){case 4:return c[0];case 8:return d;case 12:return(d+d).slice(0,3);default:return d+d}}var e4={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function e5(a,b){if(a>24)return b.setWinLines||!1;switch(a){case 1:return!!b.restoreWin;case 2:return!!b.minimizeWin;case 3:return!!b.setWinPosition;case 4:return!!b.setWinSizePixels;case 5:return!!b.raiseWin;case 6:return!!b.lowerWin;case 7:return!!b.refreshWin;case 8:return!!b.setWinSizeChars;case 9:return!!b.maximizeWin;case 10:return!!b.fullscreenWin;case 11:return!!b.getWinState;case 13:return!!b.getWinPosition;case 14:return!!b.getWinSizePixels;case 15:return!!b.getScreenSizePixels;case 16:return!!b.getCellSizePixels;case 18:return!!b.getWinSizeChars;case 19:return!!b.getScreenSizeChars;case 20:return!!b.getIconTitle;case 21:return!!b.getWinTitle;case 22:return!!b.pushTitle;case 23:return!!b.popTitle;case 24:return!!b.setWinLines}return!1}var e6=0,e7=class extends aW{constructor(a,b,c,d,e,f,g,h,i=new e_){for(let j in super(),this._bufferService=a,this._charsetService=b,this._coreService=c,this._logService=d,this._optionsService=e,this._oscLinkService=f,this._coreMouseService=g,this._unicodeService=h,this._parser=i,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ag,this._utf8Decoder=new ah,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ej.clone(),this._eraseAttrDataInternal=ej.clone(),this._onRequestBell=this._register(new bd),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new bd),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new bd),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new bd),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new bd),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new bd),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new bd),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new bd),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new bd),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new bd),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new bd),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new bd),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new bd),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 e8(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(a=>this._activeBuffer=a.activeBuffer)),this._parser.setCsiHandlerFallback((a,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(a),params:b.toArray()})}),this._parser.setEscHandlerFallback(a=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(a)})}),this._parser.setExecuteHandlerFallback(a=>{this._logService.debug("Unknown EXECUTE code: ",{code:a})}),this._parser.setOscHandlerFallback((a,b,c)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:b,data:c})}),this._parser.setDcsHandlerFallback((a,b,c)=>{"HOOK"===b&&(c=c.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:b,payload:c})}),this._parser.setPrintHandler((a,b,c)=>this.print(a,b,c)),this._parser.registerCsiHandler({final:"@"},a=>this.insertChars(a)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},a=>this.scrollLeft(a)),this._parser.registerCsiHandler({final:"A"},a=>this.cursorUp(a)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},a=>this.scrollRight(a)),this._parser.registerCsiHandler({final:"B"},a=>this.cursorDown(a)),this._parser.registerCsiHandler({final:"C"},a=>this.cursorForward(a)),this._parser.registerCsiHandler({final:"D"},a=>this.cursorBackward(a)),this._parser.registerCsiHandler({final:"E"},a=>this.cursorNextLine(a)),this._parser.registerCsiHandler({final:"F"},a=>this.cursorPrecedingLine(a)),this._parser.registerCsiHandler({final:"G"},a=>this.cursorCharAbsolute(a)),this._parser.registerCsiHandler({final:"H"},a=>this.cursorPosition(a)),this._parser.registerCsiHandler({final:"I"},a=>this.cursorForwardTab(a)),this._parser.registerCsiHandler({final:"J"},a=>this.eraseInDisplay(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},a=>this.eraseInDisplay(a,!0)),this._parser.registerCsiHandler({final:"K"},a=>this.eraseInLine(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},a=>this.eraseInLine(a,!0)),this._parser.registerCsiHandler({final:"L"},a=>this.insertLines(a)),this._parser.registerCsiHandler({final:"M"},a=>this.deleteLines(a)),this._parser.registerCsiHandler({final:"P"},a=>this.deleteChars(a)),this._parser.registerCsiHandler({final:"S"},a=>this.scrollUp(a)),this._parser.registerCsiHandler({final:"T"},a=>this.scrollDown(a)),this._parser.registerCsiHandler({final:"X"},a=>this.eraseChars(a)),this._parser.registerCsiHandler({final:"Z"},a=>this.cursorBackwardTab(a)),this._parser.registerCsiHandler({final:"`"},a=>this.charPosAbsolute(a)),this._parser.registerCsiHandler({final:"a"},a=>this.hPositionRelative(a)),this._parser.registerCsiHandler({final:"b"},a=>this.repeatPrecedingCharacter(a)),this._parser.registerCsiHandler({final:"c"},a=>this.sendDeviceAttributesPrimary(a)),this._parser.registerCsiHandler({prefix:">",final:"c"},a=>this.sendDeviceAttributesSecondary(a)),this._parser.registerCsiHandler({final:"d"},a=>this.linePosAbsolute(a)),this._parser.registerCsiHandler({final:"e"},a=>this.vPositionRelative(a)),this._parser.registerCsiHandler({final:"f"},a=>this.hVPosition(a)),this._parser.registerCsiHandler({final:"g"},a=>this.tabClear(a)),this._parser.registerCsiHandler({final:"h"},a=>this.setMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"h"},a=>this.setModePrivate(a)),this._parser.registerCsiHandler({final:"l"},a=>this.resetMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"l"},a=>this.resetModePrivate(a)),this._parser.registerCsiHandler({final:"m"},a=>this.charAttributes(a)),this._parser.registerCsiHandler({final:"n"},a=>this.deviceStatus(a)),this._parser.registerCsiHandler({prefix:"?",final:"n"},a=>this.deviceStatusPrivate(a)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},a=>this.softReset(a)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},a=>this.setCursorStyle(a)),this._parser.registerCsiHandler({final:"r"},a=>this.setScrollRegion(a)),this._parser.registerCsiHandler({final:"s"},a=>this.saveCursor(a)),this._parser.registerCsiHandler({final:"t"},a=>this.windowOptions(a)),this._parser.registerCsiHandler({final:"u"},a=>this.restoreCursor(a)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},a=>this.insertColumns(a)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},a=>this.deleteColumns(a)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},a=>this.selectProtected(a)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},a=>this.requestMode(a,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},a=>this.requestMode(a,!1)),this._parser.setExecuteHandler(cV.BEL,()=>this.bell()),this._parser.setExecuteHandler(cV.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(cV.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(cV.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(cV.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(cV.BS,()=>this.backspace()),this._parser.setExecuteHandler(cV.HT,()=>this.tab()),this._parser.setExecuteHandler(cV.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(cV.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(cW.IND,()=>this.index()),this._parser.setExecuteHandler(cW.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(cW.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new eU(a=>(this.setTitle(a),this.setIconName(a),!0))),this._parser.registerOscHandler(1,new eU(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new eU(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new eU(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new eU(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new eU(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new eU(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new eU(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new eU(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new eU(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new eU(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new eU(a=>this.restoreCursorColor(a))),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()),eo)this._parser.registerEscHandler({intermediates:"(",final:j},()=>this.selectCharset("("+j)),this._parser.registerEscHandler({intermediates:")",final:j},()=>this.selectCharset(")"+j)),this._parser.registerEscHandler({intermediates:"*",final:j},()=>this.selectCharset("*"+j)),this._parser.registerEscHandler({intermediates:"+",final:j},()=>this.selectCharset("+"+j)),this._parser.registerEscHandler({intermediates:"-",final:j},()=>this.selectCharset("-"+j)),this._parser.registerEscHandler({intermediates:".",final:j},()=>this.selectCharset("."+j)),this._parser.registerEscHandler({intermediates:"/",final:j},()=>this.selectCharset("/"+j));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(a=>(this._logService.error("Parsing error: ",a),a)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new eY((a,b)=>this.requestStatusString(a,b)))}getAttrData(){return this._curAttrData}_preserveStack(a,b,c,d){this._parseStack.paused=!0,this._parseStack.cursorStartX=a,this._parseStack.cursorStartY=b,this._parseStack.decodedLength=c,this._parseStack.position=d}_logSlowResolvingAsync(a){this._logService.logLevel<=3&&Promise.race([a,new Promise((a,b)=>setTimeout(()=>b("#SLOW_TIMEOUT"),5e3))]).catch(a=>{if("#SLOW_TIMEOUT"!==a)throw a;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(a,b){let c,d=this._activeBuffer.x,e=this._activeBuffer.y,f=0,g=this._parseStack.paused;if(g){if(c=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,b))return this._logSlowResolvingAsync(c),c;d=this._parseStack.cursorStartX,e=this._parseStack.cursorStartY,this._parseStack.paused=!1,a.length>131072&&(f=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof a?` "${a}"`:` "${Array.prototype.map.call(a,a=>String.fromCharCode(a)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof a?a.split("").map(a=>a.charCodeAt(0)):a),this._parseBuffer.length<a.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(a.length,131072))),g||this._dirtyRowTracker.clearRange(),a.length>131072)for(let b=f;b<a.length;b+=131072){let f=b+131072<a.length?b+131072:a.length,g="string"==typeof a?this._stringDecoder.decode(a.substring(b,f),this._parseBuffer):this._utf8Decoder.decode(a.subarray(b,f),this._parseBuffer);if(c=this._parser.parse(this._parseBuffer,g))return this._preserveStack(d,e,g,b),this._logSlowResolvingAsync(c),c}else if(!g){let b="string"==typeof a?this._stringDecoder.decode(a,this._parseBuffer):this._utf8Decoder.decode(a,this._parseBuffer);if(c=this._parser.parse(this._parseBuffer,b))return this._preserveStack(d,e,b,0),this._logSlowResolvingAsync(c),c}(this._activeBuffer.x!==d||this._activeBuffer.y!==e)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),i=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);i<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(i,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(a,b,c){let d,e,f=this._charsetService.charset,g=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,i=this._coreService.decPrivateModes.wraparound,j=this._coreService.modes.insertMode,k=this._curAttrData,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&c-b>0&&2===l.getWidth(this._activeBuffer.x-1)&&l.setCellFromCodepoint(this._activeBuffer.x-1,0,1,k);let m=this._parser.precedingJoinState;for(let n=b;n<c;++n){if((d=a[n])<127&&f){let a=f[String.fromCharCode(d)];a&&(d=a.charCodeAt(0))}let b=this._unicodeService.charProperties(d,m);e=eO.extractWidth(b);let c=eO.extractShouldJoin(b),o=c?eO.extractWidth(m):0;if(m=b,g&&this._onA11yChar.fire(ae(d)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+e-o>h){if(i){let a=l,b=this._activeBuffer.x-o;for(this._activeBuffer.x=o,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),l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),o>0&&l instanceof el&&l.copyCellsFrom(a,b,0,o,!1);b<h;)a.setCellFromCodepoint(b++,0,1,k)}else if(this._activeBuffer.x=h-1,2===e)continue}if(c&&this._activeBuffer.x){let a=l.getWidth(this._activeBuffer.x-1)?1:2;l.addCodepointToCell(this._activeBuffer.x-a,d,e);for(let a=e-o;--a>=0;)l.setCellFromCodepoint(this._activeBuffer.x++,0,0,k);continue}if(j&&(l.insertCells(this._activeBuffer.x,e-o,this._activeBuffer.getNullCell(k)),2===l.getWidth(h-1)&&l.setCellFromCodepoint(h-1,0,1,k)),l.setCellFromCodepoint(this._activeBuffer.x++,d,e,k),e>0)for(;--e;)l.setCellFromCodepoint(this._activeBuffer.x++,0,0,k)}this._parser.precedingJoinState=m,this._activeBuffer.x<h&&c-b>0&&0===l.getWidth(this._activeBuffer.x)&&!l.hasContent(this._activeBuffer.x)&&l.setCellFromCodepoint(this._activeBuffer.x,0,1,k),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(a,b){return"t"!==a.final||a.prefix||a.intermediates?this._parser.registerCsiHandler(a,b):this._parser.registerCsiHandler(a,a=>!e5(a.params[0],this._optionsService.rawOptions.windowOptions)||b(a))}registerDcsHandler(a,b){return this._parser.registerDcsHandler(a,new eY(b))}registerEscHandler(a,b){return this._parser.registerEscHandler(a,b)}registerOscHandler(a,b){return this._parser.registerOscHandler(a,new eU(b))}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(){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(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);a.hasWidth(this._activeBuffer.x)&&!a.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let a=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-a),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(a=this._bufferService.cols-1){this._activeBuffer.x=Math.min(a,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(a,b){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=a,this._activeBuffer.y=this._activeBuffer.scrollTop+b):(this._activeBuffer.x=a,this._activeBuffer.y=b),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(a,b){this._restrictCursor(),this._setCursor(this._activeBuffer.x+a,this._activeBuffer.y+b)}cursorUp(a){let b=this._activeBuffer.y-this._activeBuffer.scrollTop;return b>=0?this._moveCursor(0,-Math.min(b,a.params[0]||1)):this._moveCursor(0,-(a.params[0]||1)),!0}cursorDown(a){let b=this._activeBuffer.scrollBottom-this._activeBuffer.y;return b>=0?this._moveCursor(0,Math.min(b,a.params[0]||1)):this._moveCursor(0,a.params[0]||1),!0}cursorForward(a){return this._moveCursor(a.params[0]||1,0),!0}cursorBackward(a){return this._moveCursor(-(a.params[0]||1),0),!0}cursorNextLine(a){return this.cursorDown(a),this._activeBuffer.x=0,!0}cursorPrecedingLine(a){return this.cursorUp(a),this._activeBuffer.x=0,!0}cursorCharAbsolute(a){return this._setCursor((a.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(a){return this._setCursor(a.length>=2?(a.params[1]||1)-1:0,(a.params[0]||1)-1),!0}charPosAbsolute(a){return this._setCursor((a.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(a){return this._moveCursor(a.params[0]||1,0),!0}linePosAbsolute(a){return this._setCursor(this._activeBuffer.x,(a.params[0]||1)-1),!0}vPositionRelative(a){return this._moveCursor(0,a.params[0]||1),!0}hVPosition(a){return this.cursorPosition(a),!0}tabClear(a){let b=a.params[0];return 0===b?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===b&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(a){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=a.params[0]||1;for(;b--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(a){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=a.params[0]||1;for(;b--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(a){let b=a.params[0];return 1===b&&(this._curAttrData.bg|=0x20000000),(2===b||0===b)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(a,b,c,d=!1,e=!1){let f=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);f.replaceCells(b,c,this._activeBuffer.getNullCell(this._eraseAttrData()),e),d&&(f.isWrapped=!1)}_resetBufferLine(a,b=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c&&(c.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),b),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+a),c.isWrapped=!1)}eraseInDisplay(a,b=!1){let c;switch(this._restrictCursor(this._bufferService.cols),a.params[0]){case 0:for(c=this._activeBuffer.y,this._dirtyRowTracker.markDirty(c),this._eraseInBufferLine(c++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,b);c<this._bufferService.rows;c++)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(c);break;case 1:for(c=this._activeBuffer.y,this._dirtyRowTracker.markDirty(c),this._eraseInBufferLine(c,0,this._activeBuffer.x+1,!0,b),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(c+1).isWrapped=!1);c--;)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(c=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,c-1);c--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+c)?.getTrimmedLength(););for(;c>=0;c--)this._bufferService.scroll(this._eraseAttrData())}else{for(c=this._bufferService.rows,this._dirtyRowTracker.markDirty(c-1);c--;)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(0)}break;case 3:let d=this._activeBuffer.lines.length-this._bufferService.rows;d>0&&(this._activeBuffer.lines.trimStart(d),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-d,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-d,0),this._onScroll.fire(0))}return!0}eraseInLine(a,b=!1){switch(this._restrictCursor(this._bufferService.cols),a.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,b);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,b);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,b)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(a){this._restrictCursor();let b=a.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let c=this._activeBuffer.ybase+this._activeBuffer.y,d=this._bufferService.rows-1-this._activeBuffer.scrollBottom,e=this._bufferService.rows-1+this._activeBuffer.ybase-d+1;for(;b--;)this._activeBuffer.lines.splice(e-1,1),this._activeBuffer.lines.splice(c,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(a){this._restrictCursor();let b=a.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let c=this._activeBuffer.ybase+this._activeBuffer.y,d;for(d=this._bufferService.rows-1-this._activeBuffer.scrollBottom,d=this._bufferService.rows-1+this._activeBuffer.ybase-d;b--;)this._activeBuffer.lines.splice(c,1),this._activeBuffer.lines.splice(d,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.insertCells(this._activeBuffer.x,a.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.deleteCells(this._activeBuffer.x,a.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(a){let b=a.params[0]||1;for(;b--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(a){let b=a.params[0]||1;for(;b--;)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(ej));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.deleteCells(0,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.insertCells(0,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.insertCells(this._activeBuffer.x,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.deleteCells(this._activeBuffer.x,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(a.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(a){let b=this._parser.precedingJoinState;if(!b)return!0;let c=a.params[0]||1,d=eO.extractWidth(b),e=this._activeBuffer.x-d,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(e),g=new Uint32Array(f.length*c),h=0;for(let a=0;a<f.length;){let b=f.codePointAt(a)||0;g[h++]=b,a+=b>65535?2:1}let i=h;for(let a=1;a<c;++a)g.copyWithin(i,0,h),i+=h;return this.print(g,0,i),!0}sendDeviceAttributesPrimary(a){return a.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(cV.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(cV.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(a){return a.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(cV.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(cV.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(a.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(cV.ESC+"[>83;40003;0c")),!0}_is(a){return 0===(this._optionsService.rawOptions.termName+"").indexOf(a)}setMode(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ep),this._charsetService.setgCharset(1,ep),this._charsetService.setgCharset(2,ep),this._charsetService.setgCharset(3,ep);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}return!0}resetMode(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===a.params[b]&&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)}return!0}requestMode(a,b){let c,d,e,f;(d=c||={})[d.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",d[d.SET=1]="SET",d[d.RESET=2]="RESET",d[d.PERMANENTLY_SET=3]="PERMANENTLY_SET",d[d.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let g=this._coreService.decPrivateModes,{activeProtocol:h,activeEncoding:i}=this._coreMouseService,j=this._coreService,{buffers:k,cols:l}=this._bufferService,{active:m,alt:n}=k,o=this._optionsService.rawOptions,p=a=>a?1:2,q=a.params[0];return e=q,f=b?2===q?4:4===q?p(j.modes.insertMode):12===q?3:20===q?p(o.convertEol):0:1===q?p(g.applicationCursorKeys):3===q?o.windowOptions.setWinLines?80===l?2:+(132===l):0:6===q?p(g.origin):7===q?p(g.wraparound):8===q?3:9===q?p("X10"===h):12===q?p(o.cursorBlink):25===q?p(!j.isCursorHidden):45===q?p(g.reverseWraparound):66===q?p(g.applicationKeypad):67===q?4:1e3===q?p("VT200"===h):1002===q?p("DRAG"===h):1003===q?p("ANY"===h):1004===q?p(g.sendFocus):1005===q?4:1006===q?p("SGR"===i):1015===q?4:1016===q?p("SGR_PIXELS"===i):1048===q?1:47===q||1047===q||1049===q?p(m===n):2004===q?p(g.bracketedPasteMode):2026===q?p(g.synchronizedOutput):0,j.triggerDataEvent(`${cV.ESC}[${b?"":"?"}${e};${f}$y`),!0}_updateAttrColor(a,b,c,d,e){return 2===b?(a|=0x3000000,a&=-0x1000000,a|=ai.fromColorRGB([c,d,e])):5===b&&(a&=-0x3000100,a|=0x2000000|255&c),a}_extractColor(a,b,c){let d=[0,0,-1,0,0,0],e=0,f=0;do{if(d[f+e]=a.params[b+f],a.hasSubParams(b+f)){let c=a.getSubParams(b+f),g=0;do 5===d[1]&&(e=1),d[f+g+1+e]=c[g];while(++g<c.length&&g+f+1+e<d.length)break}if(5===d[1]&&f+e>=2||2===d[1]&&f+e>=5)break;d[1]&&(e=1)}while(++f+b<a.length&&f+e<d.length)for(let a=2;a<d.length;++a)-1===d[a]&&(d[a]=0);switch(d[0]){case 38:c.fg=this._updateAttrColor(c.fg,d[1],d[3],d[4],d[5]);break;case 48:c.bg=this._updateAttrColor(c.bg,d[1],d[3],d[4],d[5]);break;case 58:c.extended=c.extended.clone(),c.extended.underlineColor=this._updateAttrColor(c.extended.underlineColor,d[1],d[3],d[4],d[5])}return f}_processUnderline(a,b){b.extended=b.extended.clone(),(!~a||a>5)&&(a=1),b.extended.underlineStyle=a,b.fg|=0x10000000,0===a&&(b.fg&=-0x10000001),b.updateExtended()}_processSGR0(a){a.fg=ej.fg,a.bg=ej.bg,a.extended=a.extended.clone(),a.extended.underlineStyle=0,a.extended.underlineColor&=-0x4000000,a.updateExtended()}charAttributes(a){if(1===a.length&&0===a.params[0])return this._processSGR0(this._curAttrData),!0;let b=a.length,c,d=this._curAttrData;for(let e=0;e<b;e++)(c=a.params[e])>=30&&c<=37?(d.fg&=-0x3000100,d.fg|=0x1000000|c-30):c>=40&&c<=47?(d.bg&=-0x3000100,d.bg|=0x1000000|c-40):c>=90&&c<=97?(d.fg&=-0x3000100,d.fg|=0x1000000|c-90|8):c>=100&&c<=107?(d.bg&=-0x3000100,d.bg|=0x1000000|c-100|8):0===c?this._processSGR0(d):1===c?d.fg|=0x8000000:3===c?d.bg|=0x4000000:4===c?(d.fg|=0x10000000,this._processUnderline(a.hasSubParams(e)?a.getSubParams(e)[0]:1,d)):5===c?d.fg|=0x20000000:7===c?d.fg|=0x4000000:8===c?d.fg|=0x40000000:9===c?d.fg|=0x80000000:2===c?d.bg|=0x8000000:21===c?this._processUnderline(2,d):22===c?(d.fg&=-0x8000001,d.bg&=-0x8000001):23===c?d.bg&=-0x4000001:24===c?(d.fg&=-0x10000001,this._processUnderline(0,d)):25===c?d.fg&=-0x20000001:27===c?d.fg&=-0x4000001:28===c?d.fg&=-0x40000001:29===c?d.fg&=0x7fffffff:39===c?(d.fg&=-0x4000000,d.fg|=0xffffff&ej.fg):49===c?(d.bg&=-0x4000000,d.bg|=0xffffff&ej.bg):38===c||48===c||58===c?e+=this._extractColor(a,e,d):53===c?d.bg|=0x40000000:55===c?d.bg&=-0x40000001:59===c?(d.extended=d.extended.clone(),d.extended.underlineColor=-1,d.updateExtended()):100===c?(d.fg&=-0x4000000,d.fg|=0xffffff&ej.fg,d.bg&=-0x4000000,d.bg|=0xffffff&ej.bg):this._logService.debug("Unknown SGR attribute: %d.",c);return!0}deviceStatus(a){switch(a.params[0]){case 5:this._coreService.triggerDataEvent(`${cV.ESC}[0n`);break;case 6:let b=this._activeBuffer.y+1,c=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${cV.ESC}[${b};${c}R`)}return!0}deviceStatusPrivate(a){if(6===a.params[0]){let a=this._activeBuffer.y+1,b=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${cV.ESC}[?${a};${b}R`)}return!0}softReset(a){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ej.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(a){let b=0===a.length?1:a.params[0];if(0===b)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(b){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"}this._coreService.decPrivateModes.cursorBlink=b%2==1}return!0}setScrollRegion(a){let b=a.params[0]||1,c;return(a.length<2||(c=a.params[1])>this._bufferService.rows||0===c)&&(c=this._bufferService.rows),c>b&&(this._activeBuffer.scrollTop=b-1,this._activeBuffer.scrollBottom=c-1,this._setCursor(0,0)),!0}windowOptions(a){if(!e5(a.params[0],this._optionsService.rawOptions.windowOptions))return!0;let b=a.length>1?a.params[1]:0;switch(a.params[0]){case 14:2!==b&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${cV.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===b||2===b)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===b||1===b)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===b||2===b)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===b||1===b)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(a){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(a){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(a){return this._windowTitle=a,this._onTitleChange.fire(a),!0}setIconName(a){return this._iconName=a,!0}setOrReportIndexedColor(a){let b=[],c=a.split(";");for(;c.length>1;){let a=c.shift(),d=c.shift();if(/^\d+$/.exec(a)){let c=parseInt(a);if(e9(c))if("?"===d)b.push({type:0,index:c});else{let a=e2(d);a&&b.push({type:1,index:c,color:a})}}}return b.length&&this._onColor.fire(b),!0}setHyperlink(a){let b=a.indexOf(";");if(-1===b)return!0;let c=a.slice(0,b).trim(),d=a.slice(b+1);return d?this._createHyperlink(c,d):!c.trim()&&this._finishHyperlink()}_createHyperlink(a,b){this._getCurrentLinkId()&&this._finishHyperlink();let c=a.split(":"),d,e=c.findIndex(a=>a.startsWith("id="));return -1!==e&&(d=c[e].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:d,uri:b}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(a,b){let c=a.split(";");for(let a=0;a<c.length&&!(b>=this._specialColors.length);++a,++b)if("?"===c[a])this._onColor.fire([{type:0,index:this._specialColors[b]}]);else{let d=e2(c[a]);d&&this._onColor.fire([{type:1,index:this._specialColors[b],color:d}])}return!0}setOrReportFgColor(a){return this._setOrReportSpecialColor(a,0)}setOrReportBgColor(a){return this._setOrReportSpecialColor(a,1)}setOrReportCursorColor(a){return this._setOrReportSpecialColor(a,2)}restoreIndexedColor(a){if(!a)return this._onColor.fire([{type:2}]),!0;let b=[],c=a.split(";");for(let a=0;a<c.length;++a)if(/^\d+$/.exec(c[a])){let d=parseInt(c[a]);e9(d)&&b.push({type:2,index:d})}return b.length&&this._onColor.fire(b),!0}restoreFgColor(a){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(a){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(a){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,ep),!0}selectCharset(a){return 2!==a.length?this.selectDefaultCharset():"/"===a[0]||this._charsetService.setgCharset(e4[a[0]],eo[a[1]]||ep),!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 a=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,a,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ej.clone(),this._eraseAttrDataInternal=ej.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(a){return this._charsetService.setgLevel(a),!0}screenAlignmentPattern(){let a=new ak;a.content=4194373,a.fg=this._curAttrData.fg,a.bg=this._curAttrData.bg,this._setCursor(0,0);for(let b=0;b<this._bufferService.rows;++b){let c=this._activeBuffer.ybase+this._activeBuffer.y+b,d=this._activeBuffer.lines.get(c);d&&(d.fill(a),d.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(a,b){let c=a=>(this._coreService.triggerDataEvent(`${cV.ESC}${a}${cV.ESC}\\`),!0),d=this._bufferService.buffer,e=this._optionsService.rawOptions;return c('"q'===a?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===a?'P1$r61;1"p':"r"===a?`P1$r${d.scrollTop+1};${d.scrollBottom+1}r`:"m"===a?"P1$r0m":" q"===a?`P1$r${({block:2,underline:4,bar:6})[e.cursorStyle]-!!e.cursorBlink} q`:"P0$r")}markRangeDirty(a,b){this._dirtyRowTracker.markRangeDirty(a,b)}},e8=class{constructor(a){this._bufferService=a,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(a){a<this.start?this.start=a:a>this.end&&(this.end=a)}markRangeDirty(a,b){a>b&&(e6=a,a=b,b=e6),a<this.start&&(this.start=a),b>this.end&&(this.end=b)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function e9(a){return 0<=a&&a<256}e8=Z([$(0,ap)],e8);var fa=class extends aW{constructor(a){super(),this._action=a,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new bd),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(a,b){let c;if(void 0!==b&&this._syncCalls>b){this._syncCalls=0;return}if(this._pendingData+=a.length,this._writeBuffer.push(a),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;c=this._writeBuffer.shift();){this._action(c);let a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(a,b){if(this._pendingData>5e7)throw 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+=a.length,this._writeBuffer.push(a),this._callbacks.push(b),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=a.length,this._writeBuffer.push(a),this._callbacks.push(b)}_innerWrite(a=0,b=!0){let c=a||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let a=this._writeBuffer[this._bufferOffset],d=this._action(a,b);if(d){let a=a=>performance.now()-c>=12?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(c,a);d.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(a);return}let e=this._callbacks[this._bufferOffset];if(e&&e(),this._bufferOffset++,this._pendingData-=a.length,performance.now()-c>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},fb=class{constructor(a){this._bufferService=a,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(a){let b=this._bufferService.buffer;if(void 0===a.id){let c=b.addMarker(b.ybase+b.y),d={data:a,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._dataByLinkId.set(d.id,d),d.id}let c=this._getEntryIdKey(a),d=this._entriesWithId.get(c);if(d)return this.addLineToLink(d.id,b.ybase+b.y),d.id;let e=b.addMarker(b.ybase+b.y),f={id:this._nextId++,key:this._getEntryIdKey(a),data:a,lines:[e]};return e.onDispose(()=>this._removeMarkerFromLink(f,e)),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(a,b){let c=this._dataByLinkId.get(a);if(c&&c.lines.every(a=>a.line!==b)){let a=this._bufferService.buffer.addMarker(b);c.lines.push(a),a.onDispose(()=>this._removeMarkerFromLink(c,a))}}getLinkData(a){return this._dataByLinkId.get(a)?.data}_getEntryIdKey(a){return`${a.id};;${a.uri}`}_removeMarkerFromLink(a,b){let c=a.lines.indexOf(b);-1!==c&&(a.lines.splice(c,1),0===a.lines.length&&(void 0!==a.data.id&&this._entriesWithId.delete(a.key),this._dataByLinkId.delete(a.id)))}};fb=Z([$(0,ap)],fb);var fc=!1,fd=class extends aW{constructor(a){super(),this._windowsWrappingHeuristics=this._register(new aX),this._onBinary=this._register(new bd),this.onBinary=this._onBinary.event,this._onData=this._register(new bd),this.onData=this._onData.event,this._onLineFeed=this._register(new bd),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new bd),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new bd),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new bd),this._instantiationService=new ef,this.optionsService=this._register(new ev(a)),this._instantiationService.setService(av,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(es)),this._instantiationService.setService(ap,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(eh)),this._instantiationService.setService(au,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ez)),this._instantiationService.setService(ar,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(eE)),this._instantiationService.setService(aq,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(eO)),this._instantiationService.setService(ax,this.unicodeService),this._charsetService=this._instantiationService.createInstance(eP),this._instantiationService.setService(as,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(fb),this._instantiationService.setService(aw,this._oscLinkService),this._inputHandler=this._register(new e7(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(a6.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(a6.forward(this._bufferService.onResize,this._onResize)),this._register(a6.forward(this.coreService.onData,this._onData)),this._register(a6.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 fa((a,b)=>this._inputHandler.parse(a,b))),this._register(a6.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new bd),this._onScroll.event(a=>{this._onScrollApi?.fire(a.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(a){for(let b in a)this.optionsService.options[b]=a[b]}write(a,b){this._writeBuffer.write(a,b)}writeSync(a,b){this._logService.logLevel<=3&&!fc&&(this._logService.warn("writeSync is unreliable and will be removed soon."),fc=!0),this._writeBuffer.writeSync(a,b)}input(a,b=!0){this.coreService.triggerDataEvent(a,b)}resize(a,b){isNaN(a)||isNaN(b)||(a=Math.max(a,2),b=Math.max(b,1),this._bufferService.resize(a,b))}scroll(a,b=!1){this._bufferService.scroll(a,b)}scrollLines(a,b){this._bufferService.scrollLines(a,b)}scrollPages(a){this.scrollLines(a*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(a){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(a){let b=a-this._bufferService.buffer.ydisp;0!==b&&this.scrollLines(b)}registerEscHandler(a,b){return this._inputHandler.registerEscHandler(a,b)}registerDcsHandler(a,b){return this._inputHandler.registerDcsHandler(a,b)}registerCsiHandler(a,b){return this._inputHandler.registerCsiHandler(a,b)}registerOscHandler(a,b){return this._inputHandler.registerOscHandler(a,b)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let a=!1,b=this.optionsService.rawOptions.windowsPty;b&&void 0!==b.buildNumber&&void 0!==b.buildNumber?a="conpty"===b.backend&&b.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(a=!0),a?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let a=[];a.push(this.onLineFeed(eQ.bind(null,this._bufferService))),a.push(this.registerCsiHandler({final:"H"},()=>(eQ(this._bufferService),!1))),this._windowsWrappingHeuristics.value=aT(()=>{for(let b of a)b.dispose()})}}},fe={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:["'",'"']},ff=0,fg=class{constructor(a){this._getKey=a,this._array=[],this._insertedValues=[],this._flushInsertedTask=new dU,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new dU,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(a){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(a)}_flushInserted(){let a=this._insertedValues.sort((a,b)=>this._getKey(a)-this._getKey(b)),b=0,c=0,d=Array(this._array.length+this._insertedValues.length);for(let e=0;e<d.length;e++)c>=this._array.length||this._getKey(a[b])<=this._getKey(this._array[c])?(d[e]=a[b],b++):d[e]=this._array[c++];this._array=d,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(a){if(this._flushCleanupInserted(),0===this._array.length)return!1;let b=this._getKey(a);if(void 0===b||-1===(ff=this._search(b))||this._getKey(this._array[ff])!==b)return!1;do if(this._array[ff]===a)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ff),!0;while(++ff<this._array.length&&this._getKey(this._array[ff])===b)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let a=this._deletedIndices.sort((a,b)=>a-b),b=0,c=Array(this._array.length-a.length),d=0;for(let e=0;e<this._array.length;e++)a[b]===e?b++:c[d++]=this._array[e];this._array=c,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(a){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((ff=this._search(a))<0||ff>=this._array.length)&&this._getKey(this._array[ff])===a)do yield this._array[ff];while(++ff<this._array.length&&this._getKey(this._array[ff])===a)}forEachByKey(a,b){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((ff=this._search(a))<0||ff>=this._array.length)&&this._getKey(this._array[ff])===a)do b(this._array[ff]);while(++ff<this._array.length&&this._getKey(this._array[ff])===a)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(a){let b=0,c=this._array.length-1;for(;c>=b;){let d=b+c>>1,e=this._getKey(this._array[d]);if(e>a)c=d-1;else if(e<a)b=d+1;else{for(;d>0&&this._getKey(this._array[d-1])===a;)d--;return d}}return b}},fh=0,fi=0,fj=class extends aW{constructor(){super(),this._decorations=new fg(a=>a?.marker.line),this._onDecorationRegistered=this._register(new bd),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new bd),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(aT(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(a){if(a.marker.isDisposed)return;let b=new fk(a);if(b){let a=b.marker.onDispose(()=>b.dispose()),c=b.onDispose(()=>{c.dispose(),b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),a.dispose())});this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(let a of this._decorations.values())a.dispose();this._decorations.clear()}*getDecorationsAtCell(a,b,c){let d=0,e=0;for(let f of this._decorations.getKeyIterator(b))e=(d=f.options.x??0)+(f.options.width??1),a>=d&&a<e&&(!c||(f.options.layer??"bottom")===c)&&(yield f)}forEachDecorationAtCell(a,b,c,d){this._decorations.forEachByKey(b,b=>{fi=(fh=b.options.x??0)+(b.options.width??1),a>=fh&&a<fi&&(!c||(b.options.layer??"bottom")===c)&&d(b)})}},fk=class extends aV{constructor(a){super(),this.options=a,this.onRenderEmitter=this.add(new bd),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new bd),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=a.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=eH.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=eH.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},fl=class{constructor(a,b=1e3){this._renderCallback=a,this._debounceThresholdMS=b,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(a,b,c){this._rowCount=c,a=void 0!==a?a:0,b=void 0!==b?b:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,a):a,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,b):b;let d=performance.now();if(d-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=d,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=d-this._lastRefreshMs,b=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},b)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let a=Math.max(this._rowStart,0),b=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,b)}},fm=class extends aW{constructor(a,b,c,d){super(),this._terminal=a,this._coreBrowserService=c,this._renderService=d,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let e=this._coreBrowserService.mainDocument;this._accessibilityContainer=e.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=e.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,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=e.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new fl(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
19
- `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ch(e,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(aT(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(a){for(let b=0;b<a;b++)this._handleChar(" ")}_handleChar(a){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==a&&(this._charsToAnnounce+=a):this._charsToAnnounce+=a,a===`
20
- `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=aa)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(a){this._clearLiveRegion(),/\p{Control}/u.test(a)||this._charsToConsume.push(a)}_refreshRows(a,b){this._liveRegionDebouncer.refresh(a,b,this._terminal.rows)}_renderRows(a,b){let c=this._terminal.buffer,d=c.lines.length.toString();for(let e=a;e<=b;e++){let a=c.lines.get(c.ydisp+e),b=[],f=a?.translateToString(!0,void 0,void 0,b)||"",g=(c.ydisp+e+1).toString(),h=this._rowElements[e];h&&(0===f.length?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,b)),h.setAttribute("aria-posinset",g),h.setAttribute("aria-setsize",d),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(a,b){let c,d,e=a.target,f=this._rowElements[0===b?1:this._rowElements.length-2];if(e.getAttribute("aria-posinset")!==(0===b?"1":`${this._terminal.buffer.lines.length}`)&&a.relatedTarget===f){if(0===b?(c=e,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=e,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),0===b){let a=this._createAccessibilityTreeNode();this._rowElements.unshift(a),this._rowContainer.insertAdjacentElement("afterbegin",a)}else{let a=this._createAccessibilityTreeNode();this._rowElements.push(a),this._rowContainer.appendChild(a)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===b?-1:1),this._rowElements[0===b?1:this._rowElements.length-2].focus(),a.preventDefault(),a.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let a=this._coreBrowserService.mainDocument.getSelection();if(!a)return;if(a.isCollapsed){this._rowContainer.contains(a.anchorNode)&&this._terminal.clearSelection();return}if(!a.anchorNode||!a.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:a.anchorNode,offset:a.anchorOffset},c={node:a.focusNode,offset:a.focusOffset};if((b.node.compareDocumentPosition(c.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===c.node&&b.offset>c.offset)&&([b,c]=[c,b]),b.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(b={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(b.node))return;let d=this._rowElements.slice(-1)[0];if(c.node.compareDocumentPosition(d)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(c={node:d,offset:d.textContent?.length??0}),!this._rowContainer.contains(c.node))return;let e=({node:a,offset:b})=>{let c=a instanceof Text?a.parentNode:a,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let e=this._rowColumns.get(c);if(!e)return console.warn("columns is null. Race condition?"),null;let f=b<e.length?e[b]:e.slice(-1)[0]+1;return f>=this._terminal.cols&&(++d,f=0),{row:d,column:f}},f=e(b),g=e(c);if(!(!f||!g)){if(f.row>g.row||f.row===g.row&&f.column>=g.column)throw Error("invalid range");this._terminal.select(f.column,f.row,(g.row-f.row)*this._terminal.cols-f.column+g.column)}}_handleResize(a){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let a=this._rowContainer.children.length;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);for(;this._rowElements.length>a;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let a=this._coreBrowserService.mainDocument.createElement("div");return a.setAttribute("role","listitem"),a.tabIndex=-1,this._refreshRowDimensions(a),a}_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 a=0;a<this._terminal.rows;a++)this._refreshRowDimensions(this._rowElements[a]),this._alignRowWidth(this._rowElements[a])}}_refreshRowDimensions(a){a.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(a){a.style.transform="";let b=a.getBoundingClientRect().width,c=this._rowColumns.get(a)?.slice(-1)?.[0];if(!c)return;let d=c*this._renderService.dimensions.css.cell.width;a.style.transform=`scaleX(${d/b})`}};fm=Z([$(1,at),$(2,aB),$(3,aD)],fm);var fn=class extends aW{constructor(a,b,c,d,e){super(),this._element=a,this._mouseService=b,this._renderService=c,this._bufferService=d,this._linkProviderService=e,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new bd),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new bd),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(aT(()=>{aS(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ch(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ch(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ch(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ch(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(a){this._lastMouseEvent=a;let b=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!b)return;this._isMouseOut=!1;let c=a.composedPath();for(let a=0;a<c.length;a++){let b=c[a];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&b.x===this._lastBufferCell.x&&b.y===this._lastBufferCell.y||(this._handleHover(b),this._lastBufferCell=b)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized){this._clearCurrentLink(),this._askForLink(a,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,b){this._activeProviderReplies&&b||(this._activeProviderReplies?.forEach(a=>{a?.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=a.y);let c=!1;for(let[d,e]of this._linkProviderService.linkProviders.entries())b?this._activeProviderReplies?.get(d)&&(c=this._checkLinkProviderResult(d,a,c)):e.provideLinks(a.y,b=>{if(this._isMouseOut)return;let e=b?.map(a=>({link:a}));this._activeProviderReplies?.set(d,e),c=this._checkLinkProviderResult(d,a,c),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)})}_removeIntersectingLinks(a,b){let c=new Set;for(let d=0;d<b.size;d++){let e=b.get(d);if(e)for(let b=0;b<e.length;b++){let d=e[b],f=d.link.range.start.y<a?0:d.link.range.start.x,g=d.link.range.end.y>a?this._bufferService.cols:d.link.range.end.x;for(let a=f;a<=g;a++){if(c.has(a)){e.splice(b--,1);break}c.add(a)}}}}_checkLinkProviderResult(a,b,c){if(!this._activeProviderReplies)return c;let d=this._activeProviderReplies.get(a),e=!1;for(let b=0;b<a;b++)(!this._activeProviderReplies.has(b)||this._activeProviderReplies.get(b))&&(e=!0);if(!e&&d){let a=d.find(a=>this._linkAtPosition(a.link,b));a&&(c=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!c)for(let a=0;a<this._activeProviderReplies.size;a++){let d=this._activeProviderReplies.get(a)?.find(a=>this._linkAtPosition(a.link,b));if(d){c=!0,this._handleNewLink(d);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){var b,c;if(!this._currentLink)return;let d=this._positionFromMouseEvent(a,this._element,this._mouseService);d&&this._mouseDownLink&&(b=this._mouseDownLink.link,c=this._currentLink.link,b.text===c.text&&b.range.start.x===c.range.start.x&&b.range.start.y===c.range.start.y&&b.range.end.x===c.range.end.x&&b.range.end.y===c.range.end.y)&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,b){this._currentLink&&this._lastMouseEvent&&(!a||!b||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=b)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,aS(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(a){if(!this._lastMouseEvent)return;let b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._linkAtPosition(a.link,b)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:void 0===a.link.decorations||a.link.decorations.underline,pointerCursor:void 0===a.link.decorations||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:a=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==a&&(this._currentLink.state.decorations.pointerCursor=a,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",a))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:b=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==b&&(this._currentLink.state.decorations.underline=b,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,b))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(a=>{if(!this._currentLink)return;let b=0===a.start?0:a.start+1+this._bufferService.buffer.ydisp,c=this._bufferService.buffer.ydisp+1+a.end;if(this._currentLink.link.range.start.y>=b&&this._currentLink.link.range.end.y<=c&&(this._clearCurrentLink(b,c),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(a,b,c){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),b.hover&&b.hover(c,b.text)}_fireUnderlineEvent(a,b){let c=a.range,d=this._bufferService.buffer.ydisp,e=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-d-1,c.end.x,c.end.y-d-1,void 0);(b?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(e)}_linkLeave(a,b,c){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),b.leave&&b.leave(c,b.text)}_linkAtPosition(a,b){let c=a.range.start.y*this._bufferService.cols+a.range.start.x,d=a.range.end.y*this._bufferService.cols+a.range.end.x,e=b.y*this._bufferService.cols+b.x;return c<=e&&e<=d}_positionFromMouseEvent(a,b,c){let d=c.getCoords(a,b,this._bufferService.cols,this._bufferService.rows);if(d)return{x:d[0],y:d[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,b,c,d,e){return{x1:a,y1:b,x2:c,y2:d,cols:this._bufferService.cols,fg:e}}};fn=Z([$(1,aC),$(2,aD),$(3,ap),$(4,aH)],fn);var fo=class extends fd{constructor(a={}){super(a),this._linkifier=this._register(new aX),this.browser=dB,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new aX),this._onCursorMove=this._register(new bd),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new bd),this.onKey=this._onKey.event,this._onRender=this._register(new bd),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new bd),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new bd),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new bd),this.onBell=this._onBell.event,this._onFocus=this._register(new bd),this._onBlur=this._register(new bd),this._onA11yCharEmitter=this._register(new bd),this._onA11yTabEmitter=this._register(new bd),this._onWillOpen=this._register(new bd),this._setup(),this._decorationService=this._instantiationService.createInstance(fj),this._instantiationService.setService(ay,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(dx),this._instantiationService.setService(aH,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(az)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(a=>this.refresh(a?.start??0,a?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(a=>this._reportWindowsOptions(a))),this._register(this._inputHandler.onColor(a=>this._handleColorEvent(a))),this._register(a6.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(a6.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(a6.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(a6.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(a=>this._afterResize(a.cols,a.rows))),this._register(aT(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.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(a){if(this._themeService)for(let b of a){let a,c="";switch(b.index){case 256:a="foreground",c="10";break;case 257:a="background",c="11";break;case 258:a="cursor",c="12";break;default:a="ansi",c="4;"+b.index}switch(b.type){case 0:let d=eG.toColorRGB("ansi"===a?this._themeService.colors.ansi[b.index]:this._themeService.colors[a]);this.coreService.triggerDataEvent(`${cV.ESC}]${c};${function(a,b=16){let[c,d,e]=a;return`rgb:${e3(c,b)}/${e3(d,b)}/${e3(e,b)}`}(d)}${cX.ST}`);break;case 1:if("ansi"===a)this._themeService.modifyColors(a=>a.ansi[b.index]=cY.toColor(...b.color));else{let c=a;this._themeService.modifyColors(a=>a[c]=cY.toColor(...b.color))}break;case 2:this._themeService.restoreColor(b.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(a){a?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(fm,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(a){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(cV.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(cV.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let a=this.buffer.ybase+this.buffer.y,b=this.buffer.lines.get(a);if(!b)return;let c=Math.min(this.buffer.x,this.cols-1),d=this._renderService.dimensions.css.cell.height,e=b.getWidth(c),f=this._renderService.dimensions.css.cell.width*e,g=this.buffer.y*this._renderService.dimensions.css.cell.height,h=c*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=g+"px",this.textarea.style.width=f+"px",this.textarea.style.height=d+"px",this.textarea.style.lineHeight=d+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ch(this.element,"copy",a=>{var b;this.hasSelection()&&(b=this._selectionService,a.clipboardData&&a.clipboardData.setData("text/plain",b.selectionText),a.preventDefault())}));let a=a=>{var b,c,d;return b=this.textarea,c=this.coreService,d=this.optionsService,void(a.stopPropagation(),a.clipboardData&&ab(a.clipboardData.getData("text/plain"),b,c,d))};this._register(ch(this.textarea,"paste",a)),this._register(ch(this.element,"paste",a)),dH?this._register(ch(this.element,"mousedown",a=>{2===a.button&&ad(a,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ch(this.element,"contextmenu",a=>{ad(a,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),dP&&this._register(ch(this.element,"auxclick",a=>{1===a.button&&ac(a,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ch(this.textarea,"keyup",a=>this._keyUp(a),!0)),this._register(ch(this.textarea,"keydown",a=>this._keyDown(a),!0)),this._register(ch(this.textarea,"keypress",a=>this._keyPress(a),!0)),this._register(ch(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ch(this.textarea,"compositionupdate",a=>this._compositionHelper.compositionupdate(a))),this._register(ch(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ch(this.textarea,"input",a=>this._inputEvent(a),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(a){if(!a)throw Error("Terminal requires a parent element.");if(a.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=a.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"),a.appendChild(this.element);let b=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),b.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ch(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),b.appendChild(this.screenElement);let c=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",_),dQ||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",()=>c.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(dv,this.textarea,a.ownerDocument.defaultView??window,this._document?window.document:null)),this._instantiationService.setService(aB,this._coreBrowserService),this._register(ch(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(ch(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(dr,this._document,this._helperContainer),this._instantiationService.setService(aA,this._charSizeService),this._themeService=this._instantiationService.createInstance(ec),this._instantiationService.setService(aG,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(dc),this._instantiationService.setService(aF,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(dW,this.rows,this.screenElement)),this._instantiationService.setService(aD,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(cP,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(dz),this._instantiationService.setService(aC,this._mouseService);let d=this._linkifier.value=this._register(this._instantiationService.createInstance(fn,this.screenElement));this.element.appendChild(b);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(cI,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(d4,this.element,this.screenElement,d)),this._instantiationService.setService(aE,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(a6.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(cJ,this.screenElement)),this._register(ch(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),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(fm,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cO,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cO,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(dq,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let a=this,b=this.element;function c(b){let c,d,e=a._mouseService.getMouseReportCoords(b,a.screenElement);if(!e)return!1;switch(b.overrideType||b.type){case"mousemove":d=32,void 0===b.buttons?(c=3,void 0!==b.button&&(c=b.button<3?b.button:3)):c=1&b.buttons?0:4&b.buttons?1:2&b.buttons?2:3;break;case"mouseup":d=0,c=b.button<3?b.button:3;break;case"mousedown":d=1,c=b.button<3?b.button:3;break;case"wheel":if(a._customWheelEventHandler&&!1===a._customWheelEventHandler(b))return!1;let f=b.deltaY;if(0===f||0===a.coreMouseService.consumeWheelEvent(b,a._renderService?.dimensions?.device?.cell?.height,a._coreBrowserService?.dpr))return!1;d=f<0?0:1,c=4;break;default:return!1}return void 0!==d&&void 0!==c&&!(c>4)&&a.coreMouseService.triggerMouseEvent({col:e.col,row:e.row,x:e.x,y:e.y,button:c,action:d,ctrl:b.ctrlKey,alt:b.altKey,shift:b.shiftKey})}let d={mouseup:null,wheel:null,mousedrag:null,mousemove:null},e=a=>(c(a),a.buttons||(this._document.removeEventListener("mouseup",d.mouseup),d.mousedrag&&this._document.removeEventListener("mousemove",d.mousedrag)),this.cancel(a)),f=a=>(c(a),this.cancel(a,!0)),g=a=>{a.buttons&&c(a)},h=a=>{a.buttons||c(a)};this._register(this.coreMouseService.onProtocolChange(a=>{a?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&a?d.mousemove||(b.addEventListener("mousemove",h),d.mousemove=h):(b.removeEventListener("mousemove",d.mousemove),d.mousemove=null),16&a?d.wheel||(b.addEventListener("wheel",f,{passive:!1}),d.wheel=f):(b.removeEventListener("wheel",d.wheel),d.wheel=null),2&a?d.mouseup||(d.mouseup=e):(this._document.removeEventListener("mouseup",d.mouseup),d.mouseup=null),4&a?d.mousedrag||(d.mousedrag=g):(this._document.removeEventListener("mousemove",d.mousedrag),d.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ch(b,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return c(a),d.mouseup&&this._document.addEventListener("mouseup",d.mouseup),d.mousedrag&&this._document.addEventListener("mousemove",d.mousedrag),this.cancel(a)})),this._register(ch(b,"wheel",b=>{if(!d.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(b))return!1;if(!this.buffer.hasScrollback){if(0===b.deltaY)return!1;if(0===a.coreMouseService.consumeWheelEvent(b,a._renderService?.dimensions?.device?.cell?.height,a._coreBrowserService?.dpr))return this.cancel(b,!0);let c=cV.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(b.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(c,!0),this.cancel(b,!0)}}},{passive:!1}))}refresh(a,b){this._renderService?.refreshRows(a,b)}updateCursorStyle(a){this._selectionService?.shouldColumnSelect(a)?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(a,b){this._viewport?this._viewport.scrollLines(a):super.scrollLines(a,b),this.refresh(0,this.rows-1)}scrollPages(a){this.scrollLines(a*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(a){a&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(a){let b=a-this._bufferService.buffer.ydisp;0!==b&&this.scrollLines(b)}paste(a){ab(a,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(a){this._customKeyEventHandler=a}attachCustomWheelEventHandler(a){this._customWheelEventHandler=a}registerLinkProvider(a){return this._linkProviderService.registerLinkProvider(a)}registerCharacterJoiner(a){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let b=this._characterJoinerService.register(a);return this.refresh(0,this.rows-1),b}deregisterCharacterJoiner(a){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(a)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(a){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+a)}registerDecoration(a){return this._decorationService.registerDecoration(a)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(a,b,c){this._selectionService.setSelection(a,b,c)}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(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(a,b){this._selectionService?.selectLines(a,b)}_keyDown(a){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(a))return!1;let b=this.browser.isMac&&this.options.macOptionIsMeta&&a.altKey;if(!b&&!this._compositionHelper.keydown(a))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;b||"Dead"!==a.key&&"AltGraph"!==a.key||(this._unprocessedDeadKey=!0);let c=function(a,b,c,d){let e={type:0,cancel:!1,key:void 0},f=!!a.shiftKey|2*!!a.altKey|4*!!a.ctrlKey|8*!!a.metaKey;switch(a.keyCode){case 0:"UIKeyInputUpArrow"===a.key?b?e.key=cV.ESC+"OA":e.key=cV.ESC+"[A":"UIKeyInputLeftArrow"===a.key?b?e.key=cV.ESC+"OD":e.key=cV.ESC+"[D":"UIKeyInputRightArrow"===a.key?b?e.key=cV.ESC+"OC":e.key=cV.ESC+"[C":"UIKeyInputDownArrow"===a.key&&(b?e.key=cV.ESC+"OB":e.key=cV.ESC+"[B");break;case 8:e.key=a.ctrlKey?"\b":cV.DEL,a.altKey&&(e.key=cV.ESC+e.key);break;case 9:if(a.shiftKey){e.key=cV.ESC+"[Z";break}e.key=cV.HT,e.cancel=!0;break;case 13:e.key=a.altKey?cV.ESC+cV.CR:cV.CR,e.cancel=!0;break;case 27:e.key=cV.ESC,a.altKey&&(e.key=cV.ESC+cV.ESC),e.cancel=!0;break;case 37:if(a.metaKey)break;f?e.key=cV.ESC+"[1;"+(f+1)+"D":b?e.key=cV.ESC+"OD":e.key=cV.ESC+"[D";break;case 39:if(a.metaKey)break;f?e.key=cV.ESC+"[1;"+(f+1)+"C":b?e.key=cV.ESC+"OC":e.key=cV.ESC+"[C";break;case 38:if(a.metaKey)break;f?e.key=cV.ESC+"[1;"+(f+1)+"A":b?e.key=cV.ESC+"OA":e.key=cV.ESC+"[A";break;case 40:if(a.metaKey)break;f?e.key=cV.ESC+"[1;"+(f+1)+"B":b?e.key=cV.ESC+"OB":e.key=cV.ESC+"[B";break;case 45:a.shiftKey||a.ctrlKey||(e.key=cV.ESC+"[2~");break;case 46:f?e.key=cV.ESC+"[3;"+(f+1)+"~":e.key=cV.ESC+"[3~";break;case 36:f?e.key=cV.ESC+"[1;"+(f+1)+"H":b?e.key=cV.ESC+"OH":e.key=cV.ESC+"[H";break;case 35:f?e.key=cV.ESC+"[1;"+(f+1)+"F":b?e.key=cV.ESC+"OF":e.key=cV.ESC+"[F";break;case 33:a.shiftKey?e.type=2:a.ctrlKey?e.key=cV.ESC+"[5;"+(f+1)+"~":e.key=cV.ESC+"[5~";break;case 34:a.shiftKey?e.type=3:a.ctrlKey?e.key=cV.ESC+"[6;"+(f+1)+"~":e.key=cV.ESC+"[6~";break;case 112:f?e.key=cV.ESC+"[1;"+(f+1)+"P":e.key=cV.ESC+"OP";break;case 113:f?e.key=cV.ESC+"[1;"+(f+1)+"Q":e.key=cV.ESC+"OQ";break;case 114:f?e.key=cV.ESC+"[1;"+(f+1)+"R":e.key=cV.ESC+"OR";break;case 115:f?e.key=cV.ESC+"[1;"+(f+1)+"S":e.key=cV.ESC+"OS";break;case 116:f?e.key=cV.ESC+"[15;"+(f+1)+"~":e.key=cV.ESC+"[15~";break;case 117:f?e.key=cV.ESC+"[17;"+(f+1)+"~":e.key=cV.ESC+"[17~";break;case 118:f?e.key=cV.ESC+"[18;"+(f+1)+"~":e.key=cV.ESC+"[18~";break;case 119:f?e.key=cV.ESC+"[19;"+(f+1)+"~":e.key=cV.ESC+"[19~";break;case 120:f?e.key=cV.ESC+"[20;"+(f+1)+"~":e.key=cV.ESC+"[20~";break;case 121:f?e.key=cV.ESC+"[21;"+(f+1)+"~":e.key=cV.ESC+"[21~";break;case 122:f?e.key=cV.ESC+"[23;"+(f+1)+"~":e.key=cV.ESC+"[23~";break;case 123:f?e.key=cV.ESC+"[24;"+(f+1)+"~":e.key=cV.ESC+"[24~";break;default:if(!a.ctrlKey||a.shiftKey||a.altKey||a.metaKey)if((!c||d)&&a.altKey&&!a.metaKey){let b=fe[a.keyCode]?.[+!!a.shiftKey];if(b)e.key=cV.ESC+b;else if(a.keyCode>=65&&a.keyCode<=90){let b=String.fromCharCode(a.ctrlKey?a.keyCode-64:a.keyCode+32);a.shiftKey&&(b=b.toUpperCase()),e.key=cV.ESC+b}else if(32===a.keyCode)e.key=cV.ESC+(a.ctrlKey?cV.NUL:" ");else if("Dead"===a.key&&a.code.startsWith("Key")){let b=a.code.slice(3,4);a.shiftKey||(b=b.toLowerCase()),e.key=cV.ESC+b,e.cancel=!0}}else!c||a.altKey||a.ctrlKey||a.shiftKey||!a.metaKey?!a.key||a.ctrlKey||a.altKey||a.metaKey||!(a.keyCode>=48)||1!==a.key.length?a.key&&a.ctrlKey&&("_"===a.key&&(e.key=cV.US),"@"===a.key&&(e.key=cV.NUL)):e.key=a.key:65===a.keyCode&&(e.type=1);else a.keyCode>=65&&a.keyCode<=90?e.key=String.fromCharCode(a.keyCode-64):32===a.keyCode?e.key=cV.NUL:a.keyCode>=51&&a.keyCode<=55?e.key=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?e.key=cV.DEL:219===a.keyCode?e.key=cV.ESC:220===a.keyCode?e.key=cV.FS:221===a.keyCode&&(e.key=cV.GS)}return e}(a,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(a),3===c.type||2===c.type){let b=this.rows-1;return this.scrollLines(2===c.type?-b:b),this.cancel(a,!0)}return 1===c.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,a)||(c.cancel&&this.cancel(a,!0),!c.key)||a.key&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&1===a.key.length&&a.key.charCodeAt(0)>=65&&90>=a.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((c.key===cV.ETX||c.key===cV.CR)&&(this.textarea.value=""),this._onKey.fire({key:c.key,domEvent:a}),this._showCursor(),this.coreService.triggerDataEvent(c.key,!0),!this.optionsService.rawOptions.screenReaderMode||a.altKey||a.ctrlKey)?this.cancel(a,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(a,b){let c=a.isMac&&!this.options.macOptionIsMeta&&b.altKey&&!b.ctrlKey&&!b.metaKey||a.isWindows&&b.altKey&&b.ctrlKey&&!b.metaKey||a.isWindows&&b.getModifierState("AltGraph");return"keypress"===b.type?c:c&&(!b.keyCode||b.keyCode>47)}_keyUp(a){var b;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(a)||(16===(b=a).keyCode||17===b.keyCode||18===b.keyCode||this.focus(),this.updateCursorStyle(a),this._keyPressHandled=!1)}_keyPress(a){let b;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(a))return!1;if(this.cancel(a),a.charCode)b=a.charCode;else if(null===a.which||void 0===a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!!b&&(!a.altKey&&!a.ctrlKey&&!a.metaKey||!!this._isThirdLevelShift(this.browser,a))&&(b=String.fromCharCode(b),this._onKey.fire({key:b,domEvent:a}),this._showCursor(),this.coreService.triggerDataEvent(b,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(a){if(a.data&&"insertText"===a.inputType&&(!a.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let b=a.data;return this.coreService.triggerDataEvent(b,!0),this.cancel(a),!0}return!1}resize(a,b){if(a===this.cols&&b===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(a,b)}_afterResize(a,b){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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 a=1;a<this.rows;a++)this.buffer.lines.push(this.buffer.getBlankLine(ej));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let a=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=a,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(cV.ESC+"[I"):this.coreService.triggerDataEvent(cV.ESC+"[O")}_reportWindowsOptions(a){if(this._renderService)switch(a){case 0:let b=this._renderService.dimensions.css.canvas.width.toFixed(0),c=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${cV.ESC}[4;${c};${b}t`);break;case 1:let d=this._renderService.dimensions.css.cell.width.toFixed(0),e=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${cV.ESC}[6;${e};${d}t`)}}cancel(a,b){if(!(!this.options.cancelEvents&&!b))return a.preventDefault(),a.stopPropagation(),!1}},fp=class{constructor(){this._addons=[]}dispose(){for(let a=this._addons.length-1;a>=0;a--)this._addons[a].instance.dispose()}loadAddon(a,b){let c={instance:b,dispose:b.dispose,isDisposed:!1};this._addons.push(c),b.dispose=()=>this._wrappedAddonDispose(c),b.activate(a)}_wrappedAddonDispose(a){if(a.isDisposed)return;let b=-1;for(let c=0;c<this._addons.length;c++)if(this._addons[c]===a){b=c;break}if(-1===b)throw Error("Could not dispose an addon that has not been loaded");a.isDisposed=!0,a.dispose.apply(a.instance),this._addons.splice(b,1)}},fq=class{constructor(a){this._line=a}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(a,b){if(!(a<0||a>=this._line.length))return b?(this._line.loadCell(a,b),b):this._line.loadCell(a,new ak)}translateToString(a,b,c){return this._line.translateToString(a,b,c)}},fr=class{constructor(a,b){this._buffer=a,this.type=b}init(a){return this._buffer=a,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(a){let b=this._buffer.lines.get(a);if(b)return new fq(b)}getNullCell(){return new ak}},fs=class extends aW{constructor(a){super(),this._core=a,this._onBufferChange=this._register(new bd),this.onBufferChange=this._onBufferChange.event,this._normal=new fr(this._core.buffers.normal,"normal"),this._alternate=new fr(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 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)}},ft=class{constructor(a){this._core=a}registerCsiHandler(a,b){return this._core.registerCsiHandler(a,a=>b(a.toArray()))}addCsiHandler(a,b){return this.registerCsiHandler(a,b)}registerDcsHandler(a,b){return this._core.registerDcsHandler(a,(a,c)=>b(a,c.toArray()))}addDcsHandler(a,b){return this.registerDcsHandler(a,b)}registerEscHandler(a,b){return this._core.registerEscHandler(a,b)}addEscHandler(a,b){return this.registerEscHandler(a,b)}registerOscHandler(a,b){return this._core.registerOscHandler(a,b)}addOscHandler(a,b){return this.registerOscHandler(a,b)}},fu=class{constructor(a){this._core=a}register(a){this._core.unicodeService.register(a)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(a){this._core.unicodeService.activeVersion=a}},fv=["cols","rows"],fw=0,fx=class extends aW{constructor(a){super(),this._core=this._register(new fo(a)),this._addonManager=this._register(new fp),this._publicOptions={...this._core.options};let b=a=>this._core.options[a],c=(a,b)=>{this._checkReadonlyOptions(a),this._core.options[a]=b};for(let a in this._core.options){let d={get:b.bind(this,a),set:c.bind(this,a)};Object.defineProperty(this._publicOptions,a,d)}}_checkReadonlyOptions(a){if(fv.includes(a))throw Error(`Option "${a}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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 ft(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new fu(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 fs(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let a=this._core.coreService.decPrivateModes,b="none";switch(this._core.coreMouseService.activeProtocol){case"X10":b="x10";break;case"VT200":b="vt200";break;case"DRAG":b="drag";break;case"ANY":b="any"}return{applicationCursorKeysMode:a.applicationCursorKeys,applicationKeypadMode:a.applicationKeypad,bracketedPasteMode:a.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:b,originMode:a.origin,reverseWraparoundMode:a.reverseWraparound,sendFocusMode:a.sendFocus,synchronizedOutputMode:a.synchronizedOutput,wraparoundMode:a.wraparound}}get options(){return this._publicOptions}set options(a){for(let b in a)this._publicOptions[b]=a[b]}blur(){this._core.blur()}focus(){this._core.focus()}input(a,b=!0){this._core.input(a,b)}resize(a,b){this._verifyIntegers(a,b),this._core.resize(a,b)}open(a){this._core.open(a)}attachCustomKeyEventHandler(a){this._core.attachCustomKeyEventHandler(a)}attachCustomWheelEventHandler(a){this._core.attachCustomWheelEventHandler(a)}registerLinkProvider(a){return this._core.registerLinkProvider(a)}registerCharacterJoiner(a){return this._checkProposedApi(),this._core.registerCharacterJoiner(a)}deregisterCharacterJoiner(a){this._checkProposedApi(),this._core.deregisterCharacterJoiner(a)}registerMarker(a=0){return this._verifyIntegers(a),this._core.registerMarker(a)}registerDecoration(a){return this._checkProposedApi(),this._verifyPositiveIntegers(a.x??0,a.width??0,a.height??0),this._core.registerDecoration(a)}hasSelection(){return this._core.hasSelection()}select(a,b,c){this._verifyIntegers(a,b,c),this._core.select(a,b,c)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(a,b){this._verifyIntegers(a,b),this._core.selectLines(a,b)}dispose(){super.dispose()}scrollLines(a){this._verifyIntegers(a),this._core.scrollLines(a)}scrollPages(a){this._verifyIntegers(a),this._core.scrollPages(a)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(a){this._verifyIntegers(a),this._core.scrollToLine(a)}clear(){this._core.clear()}write(a,b){this._core.write(a,b)}writeln(a,b){this._core.write(a),this._core.write(`\r
21
- `,b)}paste(a){this._core.paste(a)}refresh(a,b){this._verifyIntegers(a,b),this._core.refresh(a,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(a){this._addonManager.loadAddon(this,a)}static get strings(){return{get promptLabel(){return _},set promptLabel(t){_=t},get tooMuchOutput(){return aa},set tooMuchOutput(t){aa=t}}}_verifyIntegers(...a){for(fw of a)if(fw===1/0||isNaN(fw)||fw%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...a){for(fw of a)if(fw&&(fw===1/0||isNaN(fw)||fw%1!=0||fw<0))throw Error("This API only accepts positive integers")}},fy=class{activate(a){this._terminal=a}dispose(){}fit(){let a=this.proposeDimensions();if(!a||!this._terminal||isNaN(a.cols)||isNaN(a.rows))return;let b=this._terminal._core;(this._terminal.rows!==a.rows||this._terminal.cols!==a.cols)&&(b._renderService.clear(),this._terminal.resize(a.cols,a.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let a=this._terminal._core._renderService.dimensions;if(0===a.css.cell.width||0===a.css.cell.height)return;let b=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,c=window.getComputedStyle(this._terminal.element.parentElement),d=parseInt(c.getPropertyValue("height")),e=Math.max(0,parseInt(c.getPropertyValue("width"))),f=window.getComputedStyle(this._terminal.element),g={top:parseInt(f.getPropertyValue("padding-top")),bottom:parseInt(f.getPropertyValue("padding-bottom")),right:parseInt(f.getPropertyValue("padding-right")),left:parseInt(f.getPropertyValue("padding-left"))},h=g.top+g.bottom;return{cols:Math.max(2,Math.floor((e-(g.right+g.left)-b)/a.css.cell.width)),rows:Math.max(1,Math.floor((d-h)/a.css.cell.height))}}},fz=a.i(83915),fA=a.i(80087),fB=a.i(5151),fC=a.i(25015),fD=a.i(33441);let fE=(0,v.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);var fF=a.i(53155);let fG=(0,v.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),fH=(0,v.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var fI=a.i(67511),fI=fI,fJ=a.i(65004),fK=a.i(65025),fL=a.i(92005),fM=a.i(760);let fN={pending:{icon:fH,className:"text-muted-foreground",label:"Pending"},in_progress:{icon:J.Loader2,className:"text-primary animate-spin",label:"In progress"},completed:{icon:fI.default,className:"text-success",label:"Completed"},blocked:{icon:fG,className:"text-warning",label:"Blocked"}};function fO({todos:a,className:b}){let c=(0,fL.computeTodoProgress)(a);return 0===c.total?null:(0,q.jsxs)(fJ.Popover,{children:[(0,q.jsxs)(fJ.PopoverTrigger,{className:(0,fM.cn)("flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 transition-colors hover:bg-accent cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",b),title:"Show tasks",children:[c.current&&(0,q.jsx)("span",{className:"min-w-0 max-w-48 truncate text-[10px] text-muted-foreground",children:c.current}),(0,q.jsx)(fK.Progress,{value:c.completed,max:c.total,className:"w-16 shrink-0 gap-0 [&_[data-slot=progress-track]]:h-[3px]"}),(0,q.jsxs)("span",{className:"shrink-0 text-[10px] text-muted-foreground tabular-nums",children:[c.completed,"/",c.total]})]}),(0,q.jsx)(fJ.PopoverContent,{align:"end",className:"w-80 gap-1 p-2",children:(0,q.jsx)("ul",{className:"max-h-80 space-y-0.5 overflow-y-auto",children:c.items.map((a,b)=>{let{icon:c,className:d,label:e}=fN[a.displayStatus];return(0,q.jsxs)("li",{className:"flex items-start gap-2 rounded-sm px-1 py-1",children:[(0,q.jsx)(c,{className:(0,fM.cn)("mt-0.5 size-3.5 shrink-0",d),"aria-label":e}),(0,q.jsx)("span",{className:(0,fM.cn)("min-w-0 break-words text-xs","completed"===a.displayStatus&&"text-muted-foreground line-through"),children:"in_progress"===a.status&&a.activeForm?a.activeForm:a.content})]},a.id??b)})})})]})}var fP=a.i(6828);let fQ=(0,r.forwardRef)(function({tabId:a,cwd:b,env:c,launchClaude:d=!1,className:e="",initialTodos:f,initialClaudeStatus:g,isActive:h,onTodosUpdated:i,onStatusChange:j},k){let l=(0,r.useRef)(null),m=(0,r.useRef)(null),n=(0,r.useRef)(null),o=(0,r.useRef)(null),p=(0,r.useRef)(a),[s,u]=(0,r.useState)(!1),v=(0,r.useRef)(!1),w=(0,r.useRef)(h),x=(0,r.useRef)("idle"),y=(0,r.useRef)(!1),z=(0,r.useRef)(!1),A=(0,r.useRef)(null),B=(0,r.useRef)(null),D=(0,r.useRef)(null),E=(0,r.useRef)(0),[F,G]=(0,r.useState)("idle"),[H,I]=(0,r.useState)(null),[K,L]=(0,r.useState)(g??"idle"),M=(0,r.useRef)(g??"idle"),[N,O]=(0,r.useState)(f??[]),[P,Q]=(0,r.useState)(!1),{effectiveTheme:S}=(0,fA.useTheme)(),T=(0,r.useRef)(j);T.current=j;let U="dark"===S,V=U?{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"}:{background:"#ffffff",foreground:"#1e1e1e",cursor:"#1e1e1e",selectionBackground:"#add6ff"};async function W(a){try{await fetch((0,C.apiUrl)(`/api/internal/tabs/${a}/interrupt`),{method:"POST"})}catch(a){console.warn("[TerminalView] Failed to notify interrupt:",a)}}function X(){let a=o.current,b=m.current,c=p.current;a&&a.connected&&b&&c&&a.emit("resize",{sessionId:c,cols:b.cols,rows:b.rows})}function Y(a){a.write("\x1b[2J\x1b[3J\x1b[H")}async function Z(e,f,g){G("connecting"),I(null);try{var h,j,k,l;let q,r,s=await fetch((0,C.apiUrl)("/api/terminal/sessions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,env:c,sessionId:e,claude:d}),signal:g});if(!s.ok){let a,b=await s.text().catch(()=>"");try{a=JSON.parse(b).error}catch{}throw a&&I(a),Error(`Failed to create session: ${s.status} ${b}`)}let u=await s.json();if(g.aborted)return;p.current=u.sessionId,u.reused||Y(f),h=u.sessionId,j=u.reused,k=f,l=g,A.current?.dispose(),A.current=null,o.current&&(o.current.removeAllListeners(),o.current.disconnect()),o.current=q=(0,fz.io)((0,C.getServerUrl)(),{transports:["polling","websocket"]}),r=!1,q.on("connect",()=>{let a=y.current;y.current=!0,a?k.writeln("\x1b[90mReconnected.\x1b[0m"):j?(z.current=!0,Y(k)):k.writeln("\x1b[90mConnected.\x1b[0m"),G("connected"),E.current=0,q.emit("join",{room:`tab:${h}`,mode:"terminal"}),a&&w.current&&k.focus()}),q.on("output",({data:a})=>{j&&!r?(r=!0,k.write(a,()=>{z.current=!1,n.current?.fit();let a=m.current;if(a){let b=64===a.cols?63:64;a.resize(b,a.rows),X(),setTimeout(()=>{n.current?.fit(),X()},50)}k.scrollToBottom()})):k.write(a)}),q.on("exit",({exitCode:a})=>{console.log("[TerminalView] PTY exited with code:",a),G("exited"),p.current=null,o.current=null}),q.on("error",({message:a})=>{if(console.error("[TerminalView] Socket error message:",a),a.startsWith("Session not found")&&E.current<1){E.current+=1,$();return}G("error")}),q.on("disconnect",()=>{l.aborted||G(a=>"exited"===a||"paused"===a||"idle"===a?a:"exited")}),q.on("status-changed",({status:a})=>{L(a)}),q.on("todos-updated",({todos:b})=>{O(b),i?.(a,b)}),q.on("editor:open",({sessionId:a,content:b})=>{window.dispatchEvent(new CustomEvent("editor-session-open-request",{detail:{sessionId:a,content:b}}))}),A.current=k.onData(a=>{"\x1b"===a&&("running"===M.current||"waiting"===M.current)&&p.current&&W(p.current),q.connected&&p.current&&q.emit("input",{sessionId:p.current,data:a})})}catch(a){if(a instanceof Error&&"AbortError"===a.name)return;console.error("[TerminalView] connectSession error:",a instanceof Error?a.message:String(a)),G("error")}}async function $(){let b=m.current;if(!b)return;let c=new AbortController;await Z(a,b,c.signal)}(0,r.useEffect)(()=>{T.current?.(a,F,K)},[a,F,K]),(0,r.useLayoutEffect)(()=>{w.current=h}),(0,r.useLayoutEffect)(()=>{x.current=F}),(0,r.useLayoutEffect)(()=>{M.current=K}),(0,r.useEffect)(()=>{h&&m.current?.focus()},[h]),(0,r.useEffect)(()=>{if(s)m.current?.blur();else if(h){let a=l.current?.querySelector("textarea.xterm-helper-textarea");a?.focus()}},[s,h]),(0,r.useEffect)(()=>{"connected"===F&&n.current&&(n.current.fit(),z.current||X())},[F]),(0,r.useEffect)(()=>{if(!l.current)return;let b=l.current,c=new fx({cursorBlink:!0,fontSize:13,fontFamily:'"Cascadia Code", "Fira Code", "Menlo", monospace',theme:V,allowProposedApi:!0}),d=new fy;c.loadAddon(d),c.open(l.current),d.fit(),m.current=c,n.current=d,w.current&&c.focus(),c.attachCustomKeyEventHandler(()=>!v.current),c.buffer.onBufferChange(a=>{"normal"===a.type&&c.refresh(0,c.rows-1)});let e=0,f=a=>{let b=performance.now();""===a.data&&b-e<100?a.stopImmediatePropagation():e=b};b.addEventListener("compositionend",f,!0);let g=null,h=0,i=a=>{if(1!==a.touches.length){g=null;return}g=a.touches[0].clientY,h=c.buffer.active.viewportY},j=a=>{if(null===g||1!==a.touches.length)return;let d=b.clientHeight/c.rows;if(d<=0)return;let e=(g-a.touches[0].clientY)/d;c.scrollToLine(Math.round(h+e))};b.addEventListener("touchstart",i,{passive:!0}),b.addEventListener("touchmove",j,{passive:!0});let k=new ResizeObserver(()=>{!v.current&&(d.fit(),z.current||X())});k.observe(l.current);let p=new AbortController;return Z(a,c,p.signal),()=>{p.abort(),k.disconnect(),b.removeEventListener("compositionend",f,!0),b.removeEventListener("touchstart",i),b.removeEventListener("touchmove",j),A.current?.dispose(),A.current=null,c.dispose(),m.current=null,n.current=null,o.current?.removeAllListeners(),o.current?.disconnect(),o.current=null}},[]),(0,r.useEffect)(()=>{m.current&&(m.current.options.theme=V)},[U]),(0,r.useEffect)(()=>{function a(){v.current=!0,m.current?.blur()}function b(){if(v.current=!1,n.current?.fit(),X(),!w.current)return;let a=l.current?.querySelector("textarea.xterm-helper-textarea");a?.focus()}return window.addEventListener("editor-session-open",a),window.addEventListener("editor-session-done",b),()=>{window.removeEventListener("editor-session-open",a),window.removeEventListener("editor-session-done",b)}},[]),(0,r.useEffect)(()=>{function a(a){let b=o.current;if(!b||!b.connected||B.current)return;B.current=setTimeout(()=>{B.current=null,D.current&&(b.off("health-check-ack",D.current),D.current=null),b.disconnect(),b.connect(),G("connecting")},6e3);let c=()=>{B.current&&(clearTimeout(B.current),B.current=null),D.current=null,a.refocus&&w.current&&m.current?.focus()};D.current=c,b.once("health-check-ack",c),b.emit("health-check")}function b(){"visible"===document.visibilityState&&a({refocus:!0})}let c=setInterval(()=>{"visible"!==document.visibilityState||"connected"===x.current&&a({refocus:!1})},8e3);return document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b),clearInterval(c),B.current&&(clearTimeout(B.current),B.current=null),D.current&&(o.current?.off("health-check-ack",D.current),D.current=null)}},[]),(0,r.useImperativeHandle)(k,()=>({sendInput:a=>{let b=o.current,c=p.current;b?.connected&&c&&b.emit("input",{sessionId:c,data:a})},focus:()=>{m.current?.focus()}}));let _=(0,r.useCallback)(()=>{navigator.clipboard.writeText(a).then(()=>{Q(!0),setTimeout(()=>Q(!1),2e3)})},[a]);async function aa(){let a=p.current;if(a)try{let b=await fetch((0,C.apiUrl)(`/api/terminal/sessions/${a}/claude`),{method:"POST"});if(!b.ok){let a=await b.json().catch(()=>null);throw Error(a?.error||`HTTPエラー: ${b.status}`)}}catch(a){fP.toaster.create({type:"error",title:"Claude を起動できません",description:a instanceof Error?a.message:String(a)})}}let ab="connecting"===F,ac="paused"===F||"exited"===F||"error"===F,ad="connected"===F,ae=a.length>8?`${a.slice(0,8)}…`:a;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)("div",{className:`flex flex-col h-full min-h-0 ${e}`,children:[(0,q.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 border-b border-border flex-shrink-0 bg-card",children:[(0,q.jsx)("span",{className:"font-mono text-xs text-muted-foreground",title:a,children:ae}),(0,q.jsx)(R.Button,{variant:"ghost",size:"icon-xs",onClick:_,className:"text-muted-foreground hover:text-foreground",title:"Copy tab ID",children:P?(0,q.jsx)(fD.Check,{className:"w-3 h-3 text-success"}):(0,q.jsx)(fB.Copy,{className:"w-3 h-3"})}),(0,q.jsxs)(R.Button,{size:"xs",onClick:()=>void aa(),disabled:!ad,title:"Run Claude",children:[(0,q.jsx)(fC.Play,{className:"w-3 h-3"}),"Run Claude"]}),(0,q.jsxs)(R.Button,{variant:"ghost",size:"xs",onClick:()=>u(!0),disabled:!ad,className:"text-muted-foreground hover:text-foreground",title:"Open editor input",children:[(0,q.jsx)(fE,{className:"w-3 h-3"}),"Open Editor"]}),(0,q.jsx)(fO,{todos:N,className:"ml-auto"})]}),(0,q.jsxs)("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[(0,q.jsx)("div",{ref:l,className:"w-full h-full",style:{padding:"4px"}}),ab&&(0,q.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background",children:(0,q.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:[(0,q.jsx)(J.Loader2,{className:"w-4 h-4 animate-spin"}),(0,q.jsx)("span",{children:"Connecting..."})]})}),ac&&(0,q.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/90",children:(0,q.jsxs)("div",{className:"text-center space-y-2",children:["error"===F&&(0,q.jsx)("p",{className:"text-xs text-destructive",children:H??"Connection failed"}),"exited"===F&&(0,q.jsx)("p",{className:"text-xs text-muted-foreground",children:"Session ended"}),"paused"===F&&(0,q.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paused"}),(0,q.jsx)(R.Button,{size:"xs",onClick:$,children:"Reconnect"})]})})]})]}),(0,q.jsx)(fF.MonacoEditorModal,{open:s,onOpenChange:a=>{a.open||u(!1)},onSubmit:a=>{m.current&&a&&m.current.paste(a),u(!1)},title:"Terminal Input",submitLabel:"Paste"})]})});var fR=a.i(12223);let fS=(0,r.forwardRef)(function({task:a,tabs:b,activeTabId:c,onTabChange:d,onTabCreate:e,onTabDelete:f,onTodosUpdated:g,onClaudeStatusChange:h},i){let[j,k]=(0,r.useState)(()=>new Set(c?[c]:[]));(0,r.useEffect)(()=>{c&&k(a=>{if(a.has(c))return a;let b=new Set(a);return b.add(c),b})},[c]);let[l,m]=(0,r.useState)(()=>new Map(b.map(a=>[a.tab_id,{terminal:"connecting",claude:a.status}])));(0,r.useEffect)(()=>{m(a=>{let c=!1,d=new Map(a);for(let a of b)d.has(a.tab_id)||(d.set(a.tab_id,{terminal:"connecting",claude:a.status}),c=!0);return c?d:a})},[b]);let n=(0,r.useRef)(new Map);(0,r.useEffect)(()=>{c&&n.current.get(c)?.focus()},[c]);let o=(0,r.useCallback)((a,b,c)=>{m(d=>{let e=new Map(d);return e.set(a,{terminal:b,claude:c}),e}),h?.(a,c)},[h]);(0,r.useImperativeHandle)(i,()=>({sendInput:(a,b)=>{let c=n.current.get(a);c?.sendInput(b)}}));let p=(0,r.useCallback)(a=>{k(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c}),d(a)},[d]),s=(0,r.useCallback)(async a=>{let b=await e(a);b&&k(a=>{let c=new Set(a);return c.add(b),c})},[e]),u=(0,r.useCallback)(()=>s("terminal"),[s]),v=(0,r.useCallback)(()=>s("claude"),[s]),w=(0,r.useCallback)(()=>s("local"),[s]),{settings:x}=(0,fR.useOllamaSettings)(),{settings:y}=(0,fR.useLmStudioSettings)(),{settings:z}=(0,fR.useLocalLlmSettings)(),B=x?.enabled||y?.enabled?{provider:z?.active?.provider??null,model:z?.active?.model??""}:void 0,C=(0,r.useCallback)(a=>{if(!c)return;let b=n.current.get(c);b?.sendInput(a),b?.focus()},[c]),D=(0,r.useCallback)(a=>{k(b=>{let c=new Set(b);return c.delete(a),c}),m(b=>{let c=new Map(b);return c.delete(a),c}),n.current.delete(a),f(a)},[f]);return(0,q.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,q.jsx)("div",{className:"px-4 pt-4 flex-shrink-0",children:(0,q.jsx)(W,{tabs:b,activeTabId:c,onTabChange:p,onTabCreateTerminal:u,onTabCreateClaude:v,localLlmOption:B,onTabCreateLocalLlm:w,onTabDelete:D,tabStatusMap:l,onVoiceInputTranscribed:b.length>0?C:void 0})}),(0,q.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[b.map(b=>{let d=j.has(b.tab_id),e=b.tab_id===c;return d?(0,q.jsx)("div",{className:"absolute inset-0 flex flex-col px-4 pb-4 pt-2",style:{visibility:e?"visible":"hidden",pointerEvents:e?"auto":"none"},children:(0,q.jsx)(fQ,{ref:a=>{a?n.current.set(b.tab_id,a):n.current.delete(b.tab_id)},tabId:b.tab_id,isActive:e,cwd:a.worktreePath,launchClaude:"terminal"!==b.mode,className:"h-full",initialTodos:b.todos,initialClaudeStatus:b.status,onTodosUpdated:g,onStatusChange:o})},b.tab_id):null}),0===b.length&&(0,q.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-4 px-4",children:[(0,q.jsx)("p",{className:"text-sm text-muted-foreground",children:"起動するタブを選んでください"}),(0,q.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,q.jsxs)(R.Button,{onClick:v,children:[(0,q.jsx)(T.ClaudeIcon,{className:"w-4 h-4"}),"Claude Code"]}),B&&(0,q.jsx)("span",{title:B.model?`${(0,U.localLlmTabLabel)(B.provider)}: ${B.model}`:"ローカルLLMのモデルが未設定です(Settings で設定)",children:(0,q.jsxs)(R.Button,{variant:"outline",onClick:()=>void w(),disabled:!B.model,children:[(0,q.jsx)(T.LocalLlmTabIcon,{provider:B.provider,className:"w-4 h-4"}),(0,U.localLlmTabLabel)(B.provider)]})}),(0,q.jsxs)(R.Button,{variant:"outline",onClick:u,children:[(0,q.jsx)(A,{className:"w-4 h-4"}),"Terminal"]})]})]}),b.length>0&&!c&&(0,q.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Select a tab to view terminal"})]})]})});a.s([],52628),a.i(52628);var fT=a.i(21376);let fU=r.createContext(void 0);function fV(a){let b=r.useContext(fU);if(void 0===b&&!a)throw Error((0,fT.default)(33));return b}let fW=r.createContext(void 0);function fX(a){let b=r.useContext(fW);if(void 0===b&&!a)throw Error((0,fT.default)(36));return b}var fY=a.i(2840),fZ=a.i(4987);let f$=r.forwardRef(function(a,b){let{className:c,render:d,...e}=a,{store:f}=fX(),{arrowRef:g,side:h,align:i,arrowUncentered:j,arrowStyles:k}=fV(),l=f.useState("open");return(0,fY.useRenderElement)("div",a,{ref:[g,b],stateAttributesMapping:fZ.popupStateMapping,state:{open:l,side:h,align:i,uncentered:j},props:{style:k,"aria-hidden":!0,...e}})});var f_=a.i(58418);let f0=r.createContext(void 0);function f1(a=!0){let b=r.useContext(f0);if(void 0===b&&!a)throw Error((0,fT.default)(25));return b}var f2=a.i(74348);let f3={...fZ.popupStateMapping,...f_.transitionStatusMapping},f4=r.forwardRef(function(a,b){let{className:c,render:d,...e}=a,{store:f}=fX(),g=f.useState("open"),h=f.useState("mounted"),i=f.useState("transitionStatus"),j=f.useState("lastOpenChangeReason"),k=f1();return(0,fY.useRenderElement)("div",a,{ref:k?.backdropRef?[b,k.backdropRef]:b,state:{open:g,transitionStatus:i},stateAttributesMapping:f3,props:[{role:"presentation",hidden:!h,style:{pointerEvents:j===f2.REASONS.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},e]})});var f5=a.i(71812),f6=a.i(52034);let f7=r.createContext(void 0);var f8=a.i(71689),f9=a.i(45819),ga=a.i(84991),gb=a.i(25238);function gc(a){let{closeOnClick:b,highlighted:c,id:d,nodeId:e,store:f,typingRef:g,itemRef:h,itemMetadata:i}=a,{events:j}=f.useState("floatingTreeRoot"),k=f1(!0),l=void 0!==k;return r.useMemo(()=>({id:d,role:"menuitem",tabIndex:c?0:-1,onKeyDown(a){" "===a.key&&g?.current&&a.preventDefault()},onMouseMove(a){e&&j.emit("itemhover",{nodeId:e,target:a.currentTarget})},onClick(a){b&&j.emit("close",{domEvent:a,reason:f2.REASONS.itemPress})},onMouseUp(a){if(k){let b=k.initialCursorPointRef.current;if(k.initialCursorPointRef.current=null,l&&b&&1>=Math.abs(a.clientX-b.x)&&1>=Math.abs(a.clientY-b.y)||l&&!gb.isMac&&2===a.button)return}h.current&&f.context.allowMouseUpTriggerRef.current&&(!l||2===a.button)&&(!i||"regular-item"===i.type)&&h.current.click()}}),[b,c,d,j,e,f,g,h,k,l,i])}let gd={type:"regular-item"};function ge(a){let{closeOnClick:b,disabled:c=!1,highlighted:d,id:e,store:f,typingRef:g=f.context.typingRef,nativeButton:h,itemMetadata:i,nodeId:j}=a,k=r.useRef(null),{getButtonProps:l,buttonRef:m}=(0,f9.useButton)({disabled:c,focusableWhenDisabled:!0,native:h,composite:!0}),n=gc({closeOnClick:b,highlighted:d,id:e,nodeId:j,store:f,typingRef:g,itemRef:k,itemMetadata:i}),o=r.useCallback(a=>(0,ga.mergeProps)(n,{onMouseEnter(){"submenu-trigger"===i.type&&i.setActive()}},a,l),[n,l,i]),p=(0,f8.useMergedRefs)(k,m);return r.useMemo(()=>({getItemProps:o,itemRef:p}),[o,p])}var gf=a.i(17585);let gg=r.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}}),gh=((n={})[n.None=0]="None",n[n.GuessFromOrder=1]="GuessFromOrder",n);function gi(a={}){let{label:b,metadata:c,textRef:d,indexGuessBehavior:e,index:f}=a,{register:g,unregister:h,subscribeMapChange:i,elementsRef:j,labelsRef:k,nextIndexRef:l}=r.useContext(gg),m=r.useRef(-1),[n,o]=r.useState(f??(e===gh.GuessFromOrder?()=>{if(-1===m.current){let a=l.current;l.current+=1,m.current=a}return m.current}:-1)),p=r.useRef(null),q=r.useCallback(a=>{if(p.current=a,-1!==n&&null!==a&&(j.current[n]=a,k)){let c=void 0!==b;k.current[n]=c?b:d?.current?.textContent??a.textContent}},[n,j,k,b,d]);return(0,gf.useIsoLayoutEffect)(()=>{if(null!=f)return;let a=p.current;if(a)return g(a,c),()=>{h(a)}},[f,g,h,c]),(0,gf.useIsoLayoutEffect)(()=>{if(null==f)return i(a=>{let b=p.current?a.get(p.current)?.index:null;null!=b&&o(b)})},[f,i,o]),r.useMemo(()=>({ref:q,index:n}),[n,q])}var gj=a.i(98134);let gk=((o={}).checked="data-checked",o.unchecked="data-unchecked",o.disabled="data-disabled",o.highlighted="data-highlighted",o),gl={checked:a=>a?{[gk.checked]:""}:{[gk.unchecked]:""},...f_.transitionStatusMapping};var gm=a.i(62255);let gn=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,nativeButton:g=!1,disabled:h=!1,closeOnClick:i=!1,checked:j,defaultChecked:k,onCheckedChange:l,...m}=a,n=gi({label:f}),o=fV(!0),p=(0,gj.useBaseUiId)(e),{store:s}=fX(),u=s.useState("isActive",n.index),v=s.useState("itemProps"),[w,x]=(0,f6.useControlled)({controlled:j,default:k??!1,name:"MenuCheckboxItem",state:"checked"}),{getItemProps:y,itemRef:z}=ge({closeOnClick:i,disabled:h,highlighted:u,id:p,store:s,nativeButton:g,nodeId:o?.nodeId,itemMetadata:gd}),A=r.useMemo(()=>({disabled:h,highlighted:u,checked:w}),[h,u,w]),B=(0,f5.useStableCallback)(a=>{let b={...(0,gm.createChangeEventDetails)(f2.REASONS.itemPress,a.nativeEvent),preventUnmountOnClose:()=>{}};l?.(!w,b),b.isCanceled||x(a=>!a)}),C=(0,fY.useRenderElement)("div",a,{state:A,stateAttributesMapping:gl,props:[v,{role:"menuitemcheckbox","aria-checked":w,onClick:B},m,y],ref:[z,b,n.ref]});return(0,q.jsx)(f7.Provider,{value:A,children:C})});var go=a.i(77717),gp=a.i(2471);let gq=r.forwardRef(function(a,b){let{render:c,className:d,keepMounted:e=!1,...f}=a,g=function(){let a=r.useContext(f7);if(void 0===a)throw Error((0,fT.default)(30));return a}(),h=r.useRef(null),{transitionStatus:i,setMounted:j}=(0,go.useTransitionStatus)(g.checked);(0,gp.useOpenChangeComplete)({open:g.checked,ref:h,onComplete(){g.checked||j(!1)}});let k={checked:g.checked,disabled:g.disabled,highlighted:g.highlighted,transitionStatus:i};return(0,fY.useRenderElement)("span",a,{state:k,ref:[b,h],stateAttributesMapping:gl,props:{"aria-hidden":!0,...f},enabled:e||g.checked})}),gr=r.createContext(void 0),gs=r.forwardRef(function(a,b){let{render:c,className:d,...e}=a,[f,g]=r.useState(void 0),h=r.useMemo(()=>({setLabelId:g}),[g]),i=(0,fY.useRenderElement)("div",a,{ref:b,props:{role:"group","aria-labelledby":f,...e}});return(0,q.jsx)(gr.Provider,{value:h,children:i})}),gt=r.forwardRef(function(a,b){let{className:c,render:d,id:e,...f}=a,g=(0,gj.useBaseUiId)(e),{setLabelId:h}=function(){let a=r.useContext(gr);if(void 0===a)throw Error((0,fT.default)(31));return a}();return(0,gf.useIsoLayoutEffect)(()=>(h(g),()=>{h(void 0)}),[h,g]),(0,fY.useRenderElement)("div",a,{ref:b,props:{id:g,role:"presentation",...f}})}),gu=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,nativeButton:g=!1,disabled:h=!1,closeOnClick:i=!0,...j}=a,k=gi({label:f}),l=fV(!0),m=(0,gj.useBaseUiId)(e),{store:n}=fX(),o=n.useState("isActive",k.index),p=n.useState("itemProps"),{getItemProps:q,itemRef:r}=ge({closeOnClick:i,disabled:h,highlighted:o,id:m,store:n,nativeButton:g,nodeId:l?.nodeId,itemMetadata:gd});return(0,fY.useRenderElement)("div",a,{state:{disabled:h,highlighted:o},props:[p,j,q],ref:[r,b,k.ref]})}),gv=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,closeOnClick:g=!1,...h}=a,i=r.useRef(null),j=gi({label:f}),k=fV(!0),l=k?.nodeId,m=(0,gj.useBaseUiId)(e),{store:n}=fX(),o=n.useState("isActive",j.index),p=n.useState("itemProps"),q=n.context.typingRef,{getButtonProps:s,buttonRef:u}=(0,f9.useButton)({native:!1,composite:!0}),v=gc({closeOnClick:g,highlighted:o,id:m,nodeId:l,store:n,typingRef:q,itemRef:i}),w=r.useMemo(()=>({highlighted:o}),[o]);return(0,fY.useRenderElement)("a",a,{state:w,props:[p,h,function(a){return(0,ga.mergeProps)(v,a,s)}],ref:[i,u,b,j.ref]})});var gw=a.i(15815),gx=a.i(55061),gy=a.i(80401),gz=a.i(32049),gA=a.i(45037);let gB={...fZ.popupStateMapping,...f_.transitionStatusMapping},gC=r.forwardRef(function(a,b){let{render:c,className:d,finalFocus:e,...f}=a,{store:g}=fX(),{side:h,align:i}=fV(),j=null!=(0,gy.useToolbarRootContext)(!0),k=g.useState("open"),l=g.useState("transitionStatus"),m=g.useState("popupProps"),n=g.useState("mounted"),o=g.useState("instantType"),p=g.useState("activeTriggerElement"),s=g.useState("parent"),u=g.useState("lastOpenChangeReason"),v=g.useState("rootId"),w=g.useState("floatingRootContext"),x=g.useState("floatingTreeRoot"),y=g.useState("closeDelay"),z=g.useState("activeTriggerElement"),A="context-menu"===s.type;(0,gp.useOpenChangeComplete)({open:k,ref:g.context.popupRef,onComplete(){k&&g.context.onOpenChangeComplete?.(!0)}}),r.useEffect(()=>{function a(a){g.setOpen(!1,(0,gm.createChangeEventDetails)(a.reason,a.domEvent))}return x.events.on("close",a),()=>{x.events.off("close",a)}},[x.events,g]);let B=g.useState("hoverEnabled"),C=g.useState("disabled");(0,gx.useHoverFloatingInteraction)(w,{enabled:B&&!C&&!A&&"menubar"!==s.type,closeDelay:y});let D={transitionStatus:l,side:h,align:i,open:k,nested:"menu"===s.type,instant:o},E=r.useCallback(a=>{g.set("popupElement",a)},[g]),F=(0,fY.useRenderElement)("div",a,{state:D,ref:[b,g.context.popupRef,E],stateAttributesMapping:gB,props:[m,{onKeyDown(a){j&&gz.COMPOSITE_KEYS.has(a.key)&&a.stopPropagation()}},(0,gA.getDisabledMountTransitionStyles)(l),f,{"data-rootownerid":v}]}),G=void 0===s.type||A;return(p||"menubar"===s.type&&u!==f2.REASONS.outsidePress)&&(G=!0),(0,q.jsx)(gw.FloatingFocusManager,{context:w,modal:A,disabled:!n,returnFocus:void 0===e?G:e,initialFocus:"menu"!==s.type,restoreFocus:!0,externalTree:"menubar"!==s.type?x:void 0,previousFocusableElement:z,nextFocusableElement:void 0===s.type?g.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:void 0===s.type?g.context.beforeContentFocusGuardRef:void 0,children:F})});var gD=a.i(87263);let gE=r.createContext(void 0),gF=r.forwardRef(function(a,b){let{keepMounted:c=!1,...d}=a,{store:e}=fX();return e.useState("mounted")||c?(0,q.jsx)(gE.Provider,{value:c,children:(0,q.jsx)(gD.FloatingPortal,{ref:b,...d})}):null});var gG=a.i(83065),gH=a.i(76093),gI=a.i(84151),gJ=a.i(93573),gK=a.i(95337);function gL(a){let{children:b,elementsRef:c,labelsRef:d,onMapChange:e}=a,f=(0,f5.useStableCallback)(e),g=r.useRef(0),h=(0,gK.useRefWithInit)(gN).current,i=(0,gK.useRefWithInit)(gM).current,[j,k]=r.useState(0),l=r.useRef(j),m=(0,f5.useStableCallback)((a,b)=>{i.set(a,b??null),l.current+=1,k(l.current)}),n=(0,f5.useStableCallback)(a=>{i.delete(a),l.current+=1,k(l.current)}),o=r.useMemo(()=>{let a=new Map;return Array.from(i.keys()).filter(a=>a.isConnected).sort(gO).forEach((b,c)=>{let d=i.get(b)??{};a.set(b,{...d,index:c})}),a},[i,j]);(0,gf.useIsoLayoutEffect)(()=>{if("function"!=typeof MutationObserver||0===o.size)return;let a=new MutationObserver(a=>{let b=new Set,c=a=>b.has(a)?b.delete(a):b.add(a);a.forEach(a=>{a.removedNodes.forEach(c),a.addedNodes.forEach(c)}),0===b.size&&(l.current+=1,k(l.current))});return o.forEach((b,c)=>{c.parentElement&&a.observe(c.parentElement,{childList:!0})}),()=>{a.disconnect()}},[o]),(0,gf.useIsoLayoutEffect)(()=>{l.current===j&&(c.current.length!==o.size&&(c.current.length=o.size),d&&d.current.length!==o.size&&(d.current.length=o.size),g.current=o.size),f(o)},[f,o,c,d,j]),(0,gf.useIsoLayoutEffect)(()=>()=>{c.current=[]},[c]),(0,gf.useIsoLayoutEffect)(()=>()=>{d&&(d.current=[])},[d]);let p=(0,f5.useStableCallback)(a=>(h.add(a),()=>{h.delete(a)}));(0,gf.useIsoLayoutEffect)(()=>{h.forEach(a=>a(o))},[h,o]);let s=r.useMemo(()=>({register:m,unregister:n,subscribeMapChange:p,elementsRef:c,labelsRef:d,nextIndexRef:g}),[m,n,p,c,d,g]);return(0,q.jsx)(gg.Provider,{value:s,children:b})}function gM(){return new Map}function gN(){return new Set}function gO(a,b){let c=a.compareDocumentPosition(b);return c&Node.DOCUMENT_POSITION_FOLLOWING||c&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:c&Node.DOCUMENT_POSITION_PRECEDING||c&Node.DOCUMENT_POSITION_CONTAINS?1:0}var gP=a.i(32654),gQ=a.i(19382),gR=a.i(84313),gS=a.i(14612);let gT=r.forwardRef(function(a,b){let{anchor:c,positionMethod:d="absolute",className:e,render:f,side:g,align:h,sideOffset:i=0,alignOffset:j=0,collisionBoundary:k="clipping-ancestors",collisionPadding:l=5,arrowPadding:m=5,sticky:n=!1,disableAnchorTracking:o=!1,collisionAvoidance:p=gQ.DROPDOWN_COLLISION_AVOIDANCE,...s}=a,{store:u}=fX(),v=function(){let a=r.useContext(gE);if(void 0===a)throw Error((0,fT.default)(32));return a}(),w=f1(!0),x=u.useState("parent"),y=u.useState("floatingRootContext"),z=u.useState("floatingTreeRoot"),A=u.useState("mounted"),B=u.useState("open"),C=u.useState("modal"),D=u.useState("activeTriggerElement"),E=u.useState("transitionStatus"),F=u.useState("positionerElement"),G=u.useState("instantType"),H=u.useState("hasViewport"),I=u.useState("lastOpenChangeReason"),J=u.useState("floatingNodeId"),K=u.useState("floatingParentNodeId"),L=y.useState("domReferenceElement"),M=r.useRef(null),N=(0,gS.useAnimationsFinished)(F,!1,!1),O=c,P=i,Q=j,R=h,S=p;"context-menu"===x.type&&(O=c??x.context?.anchor,R=R??"start",g||"center"===R||(Q=a.alignOffset??2,P=a.sideOffset??-5));let T=g,U=R;"menu"===x.type?(T=T??"inline-end",U=U??"start",S=a.collisionAvoidance??gQ.POPUP_COLLISION_AVOIDANCE):"menubar"===x.type&&(T=T??"bottom",U=U??"start");let V="context-menu"===x.type,W=(0,gJ.useAnchorPositioning)({anchor:O,floatingRootContext:y,positionMethod:w?"fixed":d,mounted:A,side:T,sideOffset:P,align:U,alignOffset:Q,arrowPadding:V?0:m,collisionBoundary:k,collisionPadding:l,sticky:n,nodeId:J,keepMounted:v,disableAnchorTracking:o,collisionAvoidance:S,shiftCrossAxis:V&&!("side"in S&&"flip"===S.side),externalTree:z,adaptiveOrigin:H?gR.adaptiveOrigin:void 0}),X=r.useMemo(()=>{let a={};return B||(a.pointerEvents="none"),{role:"presentation",hidden:!A,style:{...W.positionerStyles,...a}}},[B,A,W.positionerStyles]);r.useEffect(()=>{function a(a){a.open&&(a.parentNodeId===J&&u.set("hoverEnabled",!1),a.nodeId!==J&&a.parentNodeId===u.select("floatingParentNodeId")&&u.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.siblingOpen)))}return z.events.on("menuopenchange",a),()=>{z.events.off("menuopenchange",a)}},[u,z.events,J]),r.useEffect(()=>{if(null!=u.select("floatingParentNodeId"))return z.events.on("menuopenchange",a),()=>{z.events.off("menuopenchange",a)};function a(a){if(a.open||a.nodeId!==u.select("floatingParentNodeId"))return;let b=a.reason??f2.REASONS.siblingOpen;u.setOpen(!1,(0,gm.createChangeEventDetails)(b))}},[z.events,u]);let Y=(0,gH.useTimeout)();r.useEffect(()=>{B||Y.clear()},[B,Y]),r.useEffect(()=>{function a(a){if(B&&a.nodeId===u.select("floatingParentNodeId"))if(a.target&&D&&D!==a.target){let a=u.select("closeDelay");a>0?Y.isStarted()||Y.start(a,()=>{u.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.siblingOpen))}):u.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.siblingOpen))}else Y.clear()}return z.events.on("itemhover",a),()=>{z.events.off("itemhover",a)}},[z.events,B,D,u,Y]),r.useEffect(()=>{let a={open:B,nodeId:J,parentNodeId:K,reason:u.select("lastOpenChangeReason")};z.events.emit("menuopenchange",a)},[z.events,B,u,J,K]),(0,gf.useIsoLayoutEffect)(()=>{let a=M.current;if(L&&(M.current=L),a&&L&&L!==a){u.set("instantType",void 0);let a=new AbortController;return N(()=>{u.set("instantType","trigger-change")},a.signal),()=>{a.abort()}}},[L,N,u]);let Z={open:B,side:W.side,align:W.align,anchorHidden:W.anchorHidden,nested:"menu"===x.type,instant:G},$=r.useMemo(()=>({side:W.side,align:W.align,arrowRef:W.arrowRef,arrowUncentered:W.arrowUncentered,arrowStyles:W.arrowStyles,nodeId:W.context.nodeId}),[W.side,W.align,W.arrowRef,W.arrowUncentered,W.arrowStyles,W.context.nodeId]),_=(0,fY.useRenderElement)("div",a,{state:Z,stateAttributesMapping:fZ.popupStateMapping,ref:[b,u.useStateSetter("positionerElement")],props:[X,(0,gA.getDisabledMountTransitionStyles)(E),s]}),aa=A&&"menu"!==x.type&&("menubar"!==x.type&&C&&I!==f2.REASONS.triggerHover||"menubar"===x.type&&x.context.modal),ab=null;return"menubar"===x.type?ab=x.context.contentElement:void 0===x.type&&(ab=D),(0,q.jsxs)(fU.Provider,{value:$,children:[aa&&(0,q.jsx)(gP.InternalBackdrop,{ref:"context-menu"===x.type||"nested-context-menu"===x.type?x.context.internalBackdropRef:null,inert:(0,gG.inertValue)(!B),cutout:ab}),(0,q.jsx)(gI.FloatingNode,{id:J,children:(0,q.jsx)(gL,{elementsRef:u.context.itemDomElements,labelsRef:u.context.itemLabels,children:_})})]})}),gU=r.createContext(void 0),gV=r.memo(r.forwardRef(function(a,b){let{render:c,className:d,value:e,defaultValue:f,onValueChange:g,disabled:h=!1,...i}=a,[j,k]=(0,f6.useControlled)({controlled:e,default:f,name:"MenuRadioGroup"}),l=(0,f5.useStableCallback)(g),m=(0,f5.useStableCallback)((a,b)=>{l?.(a,b),b.isCanceled||k(a)}),n=(0,fY.useRenderElement)("div",a,{state:{disabled:h},ref:b,props:{role:"group","aria-disabled":h||void 0,...i}}),o=r.useMemo(()=>({value:j,setValue:m,disabled:h}),[j,m,h]);return(0,q.jsx)(gU.Provider,{value:o,children:n})})),gW=r.createContext(void 0),gX=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,nativeButton:g=!1,disabled:h=!1,closeOnClick:i=!1,value:j,...k}=a,l=gi({label:f}),m=fV(!0),n=(0,gj.useBaseUiId)(e),{store:o}=fX(),p=o.useState("isActive",l.index),s=o.useState("itemProps"),{value:u,setValue:v,disabled:w}=function(){let a=r.useContext(gU);if(void 0===a)throw Error((0,fT.default)(34));return a}(),x=w||h,y=u===j,{getItemProps:z,itemRef:A}=ge({closeOnClick:i,disabled:x,highlighted:p,id:n,store:o,nativeButton:g,nodeId:m?.nodeId,itemMetadata:gd}),B=r.useMemo(()=>({disabled:x,highlighted:p,checked:y}),[x,p,y]),C=(0,f5.useStableCallback)(a=>{v(j,{...(0,gm.createChangeEventDetails)(f2.REASONS.itemPress,a.nativeEvent),preventUnmountOnClose:()=>{}})}),D=(0,fY.useRenderElement)("div",a,{state:B,stateAttributesMapping:gl,props:[s,{role:"menuitemradio","aria-checked":y,onClick:C},k,z],ref:[A,b,l.ref]});return(0,q.jsx)(gW.Provider,{value:B,children:D})}),gY=r.forwardRef(function(a,b){let{render:c,className:d,keepMounted:e=!1,...f}=a,g=function(){let a=r.useContext(gW);if(void 0===a)throw Error((0,fT.default)(35));return a}(),h=r.useRef(null),{transitionStatus:i,setMounted:j}=(0,go.useTransitionStatus)(g.checked);(0,gp.useOpenChangeComplete)({open:g.checked,ref:h,onComplete(){g.checked||j(!1)}});let k={checked:g.checked,disabled:g.disabled,highlighted:g.highlighted,transitionStatus:i};return(0,fY.useRenderElement)("span",a,{state:k,stateAttributesMapping:gl,ref:[b,h],props:{"aria-hidden":!0,...f},enabled:e||g.checked})});var gZ=a.i(21042),g$=a.i(87377),g_=a.i(66173),g0=a.i(37388),g1=a.i(62279),g2=a.i(60349),g3=a.i(25158),g4=a.i(26476),g5=a.i(35850),g6=a.i(632),g7=a.i(6239),g8=a.i(50499),g9=a.i(99570),ha=a.i(85766),hb=a.i(38794);function hc(a,b,c){switch(a){case"vertical":return b;case"horizontal":return c;default:return b||c}}function hd(a,b){return hc(b,a===hb.ARROW_UP||a===hb.ARROW_DOWN,a===hb.ARROW_LEFT||a===hb.ARROW_RIGHT)}function he(a,b,c){return hc(b,a===hb.ARROW_DOWN,c?a===hb.ARROW_LEFT:a===hb.ARROW_RIGHT)||"Enter"===a||" "===a||""===a}var hf=a.i(59750),hg=a.i(88074);let hh=r.createContext(null);function hi(a){let b=r.useContext(hh);if(null===b&&!a)throw Error((0,fT.default)(5));return b}var hj=a.i(25173),hk=a.i(8273),hl=a.i(458),hm=a.i(43216),hn=a.i(46790),ho=a.i(78462),hp=a.i(21017);let hq={...ho.popupStoreSelectors,disabled:(0,hl.createSelector)(a=>"menubar"===a.parent.type&&a.parent.context.disabled||a.disabled),modal:(0,hl.createSelector)(a=>(void 0===a.parent.type||"context-menu"===a.parent.type)&&(a.modal??!0)),allowMouseEnter:(0,hl.createSelector)(a=>a.allowMouseEnter),stickIfOpen:(0,hl.createSelector)(a=>a.stickIfOpen),parent:(0,hl.createSelector)(a=>a.parent),rootId:(0,hl.createSelector)(a=>"menu"===a.parent.type?a.parent.store.select("rootId"):void 0!==a.parent.type?a.parent.context.rootId:a.rootId),activeIndex:(0,hl.createSelector)(a=>a.activeIndex),isActive:(0,hl.createSelector)((a,b)=>a.activeIndex===b),hoverEnabled:(0,hl.createSelector)(a=>a.hoverEnabled),instantType:(0,hl.createSelector)(a=>a.instantType),lastOpenChangeReason:(0,hl.createSelector)(a=>a.openChangeReason),floatingTreeRoot:(0,hl.createSelector)(a=>"menu"===a.parent.type?a.parent.store.select("floatingTreeRoot"):a.floatingTreeRoot),floatingNodeId:(0,hl.createSelector)(a=>a.floatingNodeId),floatingParentNodeId:(0,hl.createSelector)(a=>a.floatingParentNodeId),itemProps:(0,hl.createSelector)(a=>a.itemProps),closeDelay:(0,hl.createSelector)(a=>a.closeDelay),hasViewport:(0,hl.createSelector)(a=>a.hasViewport),keyboardEventRelay:(0,hl.createSelector)(a=>a.keyboardEventRelay?a.keyboardEventRelay:"menu"===a.parent.type?a.parent.store.select("keyboardEventRelay"):void 0)};class hr extends hm.ReactStore{constructor(a){super({...{...(0,ho.createInitialPopupStoreState)(),disabled:!1,modal:!0,allowMouseEnter:!1,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new hn.FloatingTreeStore,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:g0.EMPTY_OBJECT,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1},...a},{positionerRef:r.createRef(),popupRef:r.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:r.createRef(),beforeContentFocusGuardRef:r.createRef(),onOpenChangeComplete:void 0,triggerElements:new hp.PopupTriggerMap},hq),this.unsubscribeParentListener=this.observe("parent",a=>{if(this.unsubscribeParentListener?.(),"menu"===a.type){let b=a.store.select("rootId"),c=a.store.select("floatingTreeRoot"),d=a.store.select("keyboardEventRelay");this.unsubscribeParentListener=a.store.subscribe(()=>{let e=a.store.select("rootId"),f=a.store.select("floatingTreeRoot"),g=a.store.select("keyboardEventRelay");(b!==e||c!==f||d!==g)&&(b=e,c=f,d=g,this.notifyAll())}),this.context.allowMouseUpTriggerRef=a.store.context.allowMouseUpTriggerRef;return}void 0!==a.type&&(this.context.allowMouseUpTriggerRef=a.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(a,b){this.state.floatingRootContext.context.events.emit("setOpen",{open:a,eventDetails:b})}static useStore(a,b){let c=(0,gK.useRefWithInit)(()=>new hr(b)).current;return a??c}unsubscribeParentListener=null}var hs=a.i(86089);let ht=r.createContext(void 0);function hu(){return r.useContext(ht)}let hv=(0,g1.fastComponent)(function(a){let b,c,{children:d,open:e,onOpenChange:f,onOpenChangeComplete:g,defaultOpen:h=!1,disabled:i=!1,modal:j,loopFocus:k=!0,orientation:l="vertical",actionsRef:m,closeParentOnEsc:n=!1,handle:o,triggerId:p,defaultTriggerId:s=null,highlightItemOnHover:u=!0}=a,v=f1(!0),w=fX(!0),x=hi(!0),y=hu(),z=r.useMemo(()=>y&&w?{type:"menu",store:w.store}:x?{type:"menubar",context:x}:v&&!w?{type:"context-menu",context:v}:{type:void 0},[v,w,x,y]),A=hr.useStore(o?.store,{open:h,openProp:e,activeTriggerId:s,triggerIdProp:p,parent:z});(0,g$.useOnFirstRender)(()=>{void 0===e&&!1===A.state.open&&!0===h&&A.update({open:!0,activeTriggerId:s})}),A.useControlledProp("openProp",e),A.useControlledProp("triggerIdProp",p),A.useContextCallback("onOpenChangeComplete",g);let B=A.useState("floatingTreeRoot"),C=(0,gI.useFloatingNodeId)(B),D=(0,gI.useFloatingParentNodeId)();(0,gf.useIsoLayoutEffect)(()=>{v&&!w?A.update({parent:{type:"context-menu",context:v},floatingNodeId:C,floatingParentNodeId:D}):w&&A.update({floatingNodeId:C,floatingParentNodeId:D})},[v,w,C,D,A]);let E=A.useState("open"),F=A.useState("activeTriggerElement"),G=A.useState("positionerElement"),H=A.useState("hoverEnabled"),I=A.useState("modal"),J=A.useState("disabled"),K=A.useState("lastOpenChangeReason"),L=A.useState("parent"),M=A.useState("activeIndex"),N=A.useState("payload"),O=A.useState("floatingParentNodeId"),P=r.useRef(null),Q=null!=O;A.useSyncedValues({disabled:i,modal:void 0===L.type?j:void 0,rootId:(0,gZ.useId)()});let{openMethod:R,triggerProps:S}=(0,hk.useOpenInteractionType)(E);(0,hs.useImplicitActiveTrigger)(A);let{forceUnmount:T}=(0,hs.useOpenStateTransitions)(E,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0})}),U=r.useRef("context-menu"!==L.type),V=(0,gH.useTimeout)();r.useEffect(()=>{if(E||(P.current=null),"context-menu"===L.type){if(!E){V.clear(),U.current=!1;return}V.start(500,()=>{U.current=!0})}},[V,E,L.type]),(0,g_.useScrollLock)(E&&I&&K!==f2.REASONS.triggerHover&&"touch"!==R,G),(0,gf.useIsoLayoutEffect)(()=>{E||H||A.set("hoverEnabled",!0)},[E,H,A]);let W=r.useRef(!0),X=(0,gH.useTimeout)(),Y=(0,f5.useStableCallback)((a,c)=>{let d=c.reason;if(E===a&&c.trigger===F&&K===d||(c.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},a||null!=c.trigger||(c.trigger=F??void 0),f?.(a,c),c.isCanceled))return;let e={open:a,nativeEvent:c.event,reason:c.reason,nested:Q};b?.emit("openchange",e);let g=c.event;if(!1===a&&g?.type==="click"&&"touch"===g.pointerType&&!W.current)return;if(!a&&null!==M){let a=A.context.itemDomElements.current[M];queueMicrotask(()=>{a?.setAttribute("tabindex","-1")})}a&&d===f2.REASONS.triggerFocus?(W.current=!1,X.start(300,()=>{W.current=!0})):(W.current=!0,X.clear());let h=(d===f2.REASONS.triggerPress||d===f2.REASONS.itemPress)&&0===g.detail&&g?.isTrusted,i=!a&&(d===f2.REASONS.escapeKey||null==d),j={open:a,openChangeReason:d};P.current=c.event??null;let k=c.trigger?.id??null;(k||a)&&(j.activeTriggerId=k,j.activeTriggerElement=c.trigger??null),A.update(j),"menubar"===L.type&&(d===f2.REASONS.triggerFocus||d===f2.REASONS.focusOut||d===f2.REASONS.triggerHover||d===f2.REASONS.listNavigation||d===f2.REASONS.siblingOpen)?A.set("instantType","group"):h||i?A.set("instantType",h?"click":"dismiss"):A.set("instantType",void 0)}),Z=r.useCallback(a=>{let b=(0,gm.createChangeEventDetails)(a);return b.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},b},[A]),$=r.useCallback(()=>{A.setOpen(!1,Z(f2.REASONS.imperativeAction))},[A,Z]);r.useImperativeHandle(m,()=>({unmount:T,close:$}),[T,$]),"context-menu"===L.type&&(c=L.context),r.useImperativeHandle(c?.positionerRef,()=>G,[G]),r.useImperativeHandle(c?.actionsRef,()=>({setOpen:Y}),[Y]);let _=(0,hg.useSyncedFloatingRootContext)({popupStore:A,onOpenChange:Y});b=_.context.events,r.useEffect(()=>{let a=({open:a,eventDetails:b})=>Y(a,b);return b.on("setOpen",a),()=>{b?.off("setOpen",a)}},[b,Y]);let aa=(0,g2.useDismiss)(_,{enabled:!J,bubbles:{escapeKey:n&&"menu"===L.type},outsidePress:()=>"context-menu"!==L.type||P.current?.type==="contextmenu"||U.current,externalTree:Q?B:void 0}),ab=(0,hf.useRole)(_,{role:"menu"}),ac=(0,hj.useDirection)(),ad=r.useCallback(a=>{A.select("activeIndex")!==a&&A.set("activeIndex",a)},[A]),ae=function(a,b){let c="rootStore"in a?a.rootStore:a,d=c.useState("open"),e=c.useState("floatingElement"),f=c.useState("domReferenceElement"),g=c.context.dataRef,{listRef:h,activeIndex:i,onNavigate:j=()=>{},enabled:k=!0,selectedIndex:l=null,allowEscape:m=!1,loopFocus:n=!1,nested:o=!1,rtl:p=!1,virtual:q=!1,focusItemOnOpen:s="auto",focusItemOnHover:u=!0,openOnArrowKeyDown:v=!0,disabledIndices:w,orientation:x="vertical",parentOrientation:y,cols:z=1,id:A,resetOnPointerLeave:B=!0,externalTree:C}=b,D=(0,g7.getFloatingFocusElement)(e),E=(0,g5.useValueAsRef)(D),F=(0,gI.useFloatingParentNodeId)(),G=(0,gI.useFloatingTree)(C);(0,gf.useIsoLayoutEffect)(()=>{g.current.orientation=x},[g,x]);let H=(0,g7.isTypeableCombobox)(f),I=r.useRef(s),J=r.useRef(l??-1),K=r.useRef(null),L=r.useRef(!0),M=(0,f5.useStableCallback)(a=>{j(-1===J.current?null:J.current,a)}),N=r.useRef(M),O=r.useRef(!!e),P=r.useRef(d),Q=r.useRef(!1),R=r.useRef(!1),S=(0,g5.useValueAsRef)(w),T=(0,g5.useValueAsRef)(d),U=(0,g5.useValueAsRef)(l),V=(0,g5.useValueAsRef)(B),W=(0,f5.useStableCallback)(()=>{function a(a){q?G?.events.emit("virtualfocus",a):(0,ha.enqueueFocus)(a,{sync:Q.current,preventScroll:!0})}let b=h.current[J.current],c=R.current;b&&a(b),(Q.current?a=>a():requestAnimationFrame)(()=>{let d=h.current[J.current]||b;!d||(b||a(d),Y&&(c||!L.current)&&d.scrollIntoView?.({block:"nearest",inline:"nearest"}))})});(0,gf.useIsoLayoutEffect)(()=>{k&&(d&&e?(J.current=l??-1,I.current&&null!=l&&(R.current=!0,M())):O.current&&(J.current=-1,N.current()))},[k,d,e,l,M]),(0,gf.useIsoLayoutEffect)(()=>{if(k){if(!d){Q.current=!1;return}if(e)if(null==i){if(Q.current=!1,null!=U.current)return;if(O.current&&(J.current=-1,W()),(!P.current||!O.current)&&I.current&&(null!=K.current||!0===I.current&&null==K.current)){let a=0,b=()=>{null==h.current[0]?(a<2&&(a?requestAnimationFrame:queueMicrotask)(b),a+=1):(J.current=null==K.current||he(K.current,x,p)||o?(0,g9.getMinListIndex)(h):(0,g9.getMaxListIndex)(h),K.current=null,M())};b()}}else(0,g9.isIndexOutOfListBounds)(h,i)||(J.current=i,W(),R.current=!1)}},[k,d,e,i,U,o,h,x,p,M,W,S]),(0,gf.useIsoLayoutEffect)(()=>{if(!k||e||!G||q||!O.current)return;let a=G.nodesRef.current,b=a.find(a=>a.id===F)?.context?.elements.floating,c=(0,g7.activeElement)((0,g6.ownerDocument)(e)),d=a.some(a=>a.context&&(0,g7.contains)(a.context.elements.floating,c));b&&!d&&L.current&&b.focus({preventScroll:!0})},[k,e,G,F,q]),(0,gf.useIsoLayoutEffect)(()=>{N.current=M,P.current=d,O.current=!!e}),(0,gf.useIsoLayoutEffect)(()=>{d||(K.current=null,I.current=s)},[d,s]);let X=null!=i,Y=r.useMemo(()=>{function a(a){if(!T.current)return;let b=h.current.indexOf(a.currentTarget);-1!==b&&J.current!==b&&(J.current=b,M(a))}return{onFocus(b){Q.current=!0,a(b)},onClick:({currentTarget:a})=>a.focus({preventScroll:!0}),onMouseMove(b){Q.current=!0,R.current=!1,u&&a(b)},onPointerLeave(a){if(!T.current||!L.current||"touch"===a.pointerType)return;Q.current=!0;let b=a.relatedTarget;if(!(!u||h.current.includes(b))&&V.current&&((0,ha.enqueueFocus)(null,{sync:!0}),J.current=-1,M(a),!q)){let a=E.current,b=(0,g7.activeElement)((0,g6.ownerDocument)(a));a&&(0,g7.contains)(a,b)&&a.focus({preventScroll:!0})}}}},[T,E,u,h,M,V,q]),Z=r.useCallback(()=>y??G?.nodesRef.current.find(a=>a.id===F)?.context?.dataRef?.current.orientation,[F,G,y]),$=(0,f5.useStableCallback)(a=>{var b;let e,g;if(L.current=!1,Q.current=!0,229===a.which||!T.current&&a.currentTarget===E.current)return;if(o&&(b=a.key,e=p?b===hb.ARROW_RIGHT:b===hb.ARROW_LEFT,g=b===hb.ARROW_UP,"both"===x||"horizontal"===x&&z&&z>1?"Escape"===b:hc(x,e,g))){hd(a.key,Z())||(0,g8.stopEvent)(a),c.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.listNavigation,a.nativeEvent)),(0,g4.isHTMLElement)(f)&&(q?G?.events.emit("virtualfocus",f):f.focus());return}let i=J.current,j=(0,g9.getMinListIndex)(h,w),k=(0,g9.getMaxListIndex)(h,w);if(H||("Home"===a.key&&((0,g8.stopEvent)(a),J.current=j,M(a)),"End"===a.key&&((0,g8.stopEvent)(a),J.current=k,M(a))),z>1){let b=Array.from({length:h.current.length},()=>({width:1,height:1})),c=(0,g9.createGridCellMap)(b,z,!1),d=c.findIndex(a=>null!=a&&!(0,g9.isListIndexDisabled)(h,a,w)),e=c.reduce((a,b,c)=>null==b||(0,g9.isListIndexDisabled)(h,b,w)?a:c,-1),f=c[(0,g9.getGridNavigatedIndex)({current:c.map(a=>null!=a?h.current[a]:null)},{event:a,orientation:x,loopFocus:n,rtl:p,cols:z,disabledIndices:(0,g9.getGridCellIndices)([...("function"!=typeof w?w:null)||h.current.map((a,b)=>(0,g9.isListIndexDisabled)(h,b,w)?b:void 0),void 0],c),minIndex:d,maxIndex:e,prevIndex:(0,g9.getGridCellIndexOfCorner)(J.current>k?j:J.current,b,c,z,a.key===hb.ARROW_DOWN?"bl":a.key===(p?hb.ARROW_LEFT:hb.ARROW_RIGHT)?"tr":"tl"),stopEvent:!0})];if(null!=f&&(J.current=f,M(a)),"both"===x)return}if(hd(a.key,x)){if((0,g8.stopEvent)(a),d&&!q&&(0,g7.activeElement)(a.currentTarget.ownerDocument)===a.currentTarget){J.current=he(a.key,x,p)?j:k,M(a);return}he(a.key,x,p)?n?i>=k?m&&i!==h.current.length?J.current=-1:(Q.current=!1,J.current=j):J.current=(0,g9.findNonDisabledListIndex)(h,{startingIndex:i,disabledIndices:w}):J.current=Math.min(k,(0,g9.findNonDisabledListIndex)(h,{startingIndex:i,disabledIndices:w})):n?i<=j?m&&-1!==i?J.current=h.current.length:(Q.current=!1,J.current=k):J.current=(0,g9.findNonDisabledListIndex)(h,{startingIndex:i,decrement:!0,disabledIndices:w}):J.current=Math.max(j,(0,g9.findNonDisabledListIndex)(h,{startingIndex:i,decrement:!0,disabledIndices:w})),(0,g9.isIndexOutOfListBounds)(h,J.current)&&(J.current=-1),M(a)}}),_=r.useMemo(()=>q&&d&&X&&{"aria-activedescendant":`${A}-${i}`},[q,d,X,A,i]),aa=r.useMemo(()=>({"aria-orientation":"both"===x?void 0:x,...!H?_:{},onKeyDown(a){if("Tab"===a.key&&a.shiftKey&&d&&!q){let b=(0,g7.getTarget)(a.nativeEvent);if(b&&!(0,g7.contains)(E.current,b))return;(0,g8.stopEvent)(a),c.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.focusOut,a.nativeEvent)),(0,g4.isHTMLElement)(f)&&f.focus();return}$(a)},onPointerMove(){L.current=!0}}),[_,$,E,x,H,c,d,q,f]),ab=r.useMemo(()=>{function a(a){"auto"===s&&(0,g8.isVirtualClick)(a.nativeEvent)&&(I.current=!q)}function b(a){I.current=s,"auto"===s&&(0,g8.isVirtualPointerEvent)(a.nativeEvent)&&(I.current=!0)}return{onKeyDown(a){var b,d;let e=c.select("open");L.current=!1;let f=a.key.startsWith("Arrow"),g=(b=a.key,d=Z(),hc(d,p?b===hb.ARROW_LEFT:b===hb.ARROW_RIGHT,b===hb.ARROW_DOWN)),i=hd(a.key,x),j=(o?g:i)||"Enter"===a.key||""===a.key.trim();if(q&&e)return $(a);if(e||v||!f){if(j){let b=hd(a.key,Z());K.current=o&&b?null:a.key}if(o){g&&((0,g8.stopEvent)(a),e?(J.current=(0,g9.getMinListIndex)(h,S.current),M(a)):c.setOpen(!0,(0,gm.createChangeEventDetails)(f2.REASONS.listNavigation,a.nativeEvent,a.currentTarget)));return}i&&(null!=U.current&&(J.current=U.current),(0,g8.stopEvent)(a),!e&&v?c.setOpen(!0,(0,gm.createChangeEventDetails)(f2.REASONS.listNavigation,a.nativeEvent,a.currentTarget)):$(a),e&&M(a))}},onFocus(a){c.select("open")&&!q&&(J.current=-1,M(a))},onPointerDown:b,onPointerEnter:b,onMouseDown:a,onClick:a}},[$,S,s,h,o,M,c,v,x,Z,p,U,q]),ac=r.useMemo(()=>({..._,...ab}),[_,ab]);return r.useMemo(()=>k?{reference:ac,floating:aa,item:Y,trigger:ab}:{},[k,ac,aa,ab,Y])}(_,{enabled:!J,listRef:A.context.itemDomElements,activeIndex:M,nested:void 0!==L.type,loopFocus:k,orientation:l,parentOrientation:"menubar"===L.type?L.context.orientation:void 0,rtl:"rtl"===ac,disabledIndices:g0.EMPTY_ARRAY,onNavigate:ad,openOnArrowKeyDown:"context-menu"!==L.type,externalTree:Q?B:void 0,focusItemOnHover:u}),af=r.useCallback(a=>{A.context.typingRef.current=a},[A]),ag=function(a,b){let c="rootStore"in a?a.rootStore:a,d=c.context.dataRef,e=c.useState("open"),{listRef:f,elementsRef:g,activeIndex:h,onMatch:i,onTypingChange:j,enabled:k=!0,resetMs:l=750,selectedIndex:m=null}=b,n=(0,gH.useTimeout)(),o=r.useRef(""),p=r.useRef(m??h??-1),q=r.useRef(null);(0,gf.useIsoLayoutEffect)(()=>{(e||null===m)&&(n.clear(),q.current=null,""!==o.current&&(o.current=""))},[e,m,n]),(0,gf.useIsoLayoutEffect)(()=>{e&&""===o.current&&(p.current=m??h??-1)},[e,m,h]);let s=(0,f5.useStableCallback)(a=>{a?d.current.typing||(d.current.typing=a,j?.(a)):d.current.typing&&(d.current.typing=a,j?.(a))}),u=(0,f5.useStableCallback)(a=>{function b(a,c,d=0){if(0===a.length)return -1;let e=(d%a.length+a.length)%a.length,f=c.toLocaleLowerCase();for(let b=0;b<a.length;b+=1){let c=(e+b)%a.length,d=a[c];if(d?.toLocaleLowerCase().startsWith(f)&&function(a){let b=g?.current[a];return!b||(0,g9.isElementVisible)(b)}(c))return c}return -1}let c=f.current;if(o.current.length>0&&" "===a.key&&((0,g8.stopEvent)(a),s(!0)),o.current.length>0&&" "!==o.current[0]&&-1===b(c,o.current)&&" "!==a.key&&s(!1),null==c||1!==a.key.length||a.ctrlKey||a.metaKey||a.altKey)return;e&&" "!==a.key&&((0,g8.stopEvent)(a),s(!0));let d=""===o.current;d&&(p.current=m??h??-1),c.every(a=>!a||a[0]?.toLocaleLowerCase()!==a[1]?.toLocaleLowerCase())&&o.current===a.key&&(o.current="",p.current=q.current),o.current+=a.key,n.start(l,()=>{o.current="",p.current=q.current,s(!1)});let j=d?m??h??-1:p.current,k=b(c,o.current,(j??0)+1);-1!==k?(i?.(k),q.current=k):" "!==a.key&&(o.current="",s(!1))}),v=(0,f5.useStableCallback)(a=>{let b=a.relatedTarget,d=c.select("domReferenceElement"),e=c.select("floatingElement"),f=(0,g7.contains)(d,b),g=(0,g7.contains)(e,b);f||g||(n.clear(),o.current="",p.current=q.current,s(!1))}),w=r.useMemo(()=>({onKeyDown:u,onBlur:v}),[u,v]),x=r.useMemo(()=>({onKeyDown:u,onBlur:v}),[u,v]);return r.useMemo(()=>k?{reference:w,floating:x}:{},[k,w,x])}(_,{listRef:A.context.itemLabels,elementsRef:A.context.itemDomElements,activeIndex:M,resetMs:gQ.TYPEAHEAD_RESET_MS,onMatch:a=>{E&&a!==M&&A.set("activeIndex",a)},onTypingChange:af}),{getReferenceProps:ah,getFloatingProps:ai,getItemProps:aj,getTriggerProps:ak}=(0,g3.useInteractions)([aa,ab,ae,ag]),al=r.useMemo(()=>{let a=(0,ga.mergeProps)(ah(),{onMouseMove(){A.set("allowMouseEnter",!0)}},S);return delete a.role,a},[ah,A,S]),am=r.useMemo(()=>{let a=ak();if(!a)return a;let b=(0,ga.mergeProps)(a,S);return delete b.role,delete b["aria-controls"],b},[ak,S]),an=r.useMemo(()=>ai({onMouseMove(){A.set("allowMouseEnter",!0),"menu"===L.type&&A.set("hoverEnabled",!1)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(a){let b=A.select("keyboardEventRelay");b&&!a.isPropagationStopped()&&b(a)}}),[ai,L.type,A]),ao=r.useMemo(()=>aj(),[aj]);A.useSyncedValues({floatingRootContext:_,activeTriggerProps:al,inactiveTriggerProps:am,popupProps:an,itemProps:ao});let ap=r.useMemo(()=>({store:A,parent:z}),[A,z]),aq=(0,q.jsx)(fW.Provider,{value:ap,children:"function"==typeof d?d({payload:N}):d});return void 0===L.type||"context-menu"===L.type?(0,q.jsx)(gI.FloatingTree,{externalTree:B,children:aq}):aq});var hw=a.i(35112),hx=a.i(7813),hy=a.i(58240),hz=a.i(9236);let hA=gb.isMac&&gb.isSafari;var hB=a.i(24629),hC=a.i(81751),hD=a.i(29975);function hE(a){let{render:b,className:c,state:d=g0.EMPTY_OBJECT,props:e=g0.EMPTY_ARRAY,refs:f=g0.EMPTY_ARRAY,metadata:g,stateAttributesMapping:h,tag:i="div",...j}=a,{compositeProps:k,compositeRef:l}=function(a={}){let{highlightItemOnHover:b,highlightedIndex:c,onHighlightedIndexChange:d}=(0,hD.useCompositeRootContext)(),{ref:e,index:f}=gi(a),g=c===f,h=r.useRef(null),i=(0,f8.useMergedRefs)(e,h);return{compositeProps:r.useMemo(()=>({tabIndex:g?0:-1,onFocus(){d(f)},onMouseMove(){let a=h.current;if(!b||!a)return;let c=a.hasAttribute("disabled")||"true"===a.ariaDisabled;g||c||a.focus()}}),[g,d,f,b]),compositeRef:i,index:f}}({metadata:g});return(0,fY.useRenderElement)(i,a,{state:d,ref:[...f,l],props:[k,...e,j],stateAttributesMapping:h})}var hF=a.i(25839);let hG=(0,g1.fastComponentRef)(function(a,b){let c,d,e,{render:f,className:g,disabled:h=!1,nativeButton:i=!0,id:j,openOnHover:k,delay:l=100,closeDelay:m=0,handle:n,payload:o,...p}=a,s=fX(!0),u=n?.store??s?.store;if(!u)throw Error((0,fT.default)(85));let v=(0,gj.useBaseUiId)(j),w=u.useState("isTriggerActive",v),x=u.useState("floatingRootContext"),y=u.useState("isOpenedByTrigger",v),z=r.useRef(null),A=(c=f1(!0),d=fX(!0),e=hi(!0),r.useMemo(()=>e?{type:"menubar",context:e}:c&&!d?{type:"context-menu",context:c}:{type:void 0},[c,d,e])),B=(0,hD.useCompositeRootContext)(!0),C=(0,gI.useFloatingTree)(),D=r.useMemo(()=>C??new hn.FloatingTreeStore,[C]),E=(0,gI.useFloatingNodeId)(D),F=(0,gI.useFloatingParentNodeId)(),{registerTrigger:G,isMountedByThisTrigger:H}=(0,hs.useTriggerDataForwarding)(v,z,u,{payload:o,closeDelay:m,parent:A,floatingTreeRoot:D,floatingNodeId:E,floatingParentNodeId:F,keyboardEventRelay:B?.relayKeyboardEvent}),I="menubar"===A.type,J=u.useState("disabled"),K=h||J||I&&A.context.disabled,{getButtonProps:L,buttonRef:M}=(0,f9.useButton)({disabled:K,native:i});r.useEffect(()=>{y||void 0!==A.type||(u.context.allowMouseUpTriggerRef.current=!1)},[u,y,A.type]);let N=r.useRef(null),O=(0,gH.useTimeout)(),P=(0,f5.useStableCallback)(a=>{if(!N.current)return;O.clear(),u.context.allowMouseUpTriggerRef.current=!1;let b=a.target;if((0,g7.contains)(N.current,b)||(0,g7.contains)(u.select("positionerElement"),b)||b===N.current||null!=b&&function a(b){return(0,g4.isHTMLElement)(b)&&b.hasAttribute("data-rootownerid")?b.getAttribute("data-rootownerid")??void 0:(0,g4.isLastTraversableNode)(b)?void 0:a((0,g4.getParentNode)(b))}(b)===u.select("rootId"))return;let c=function(a){let b=a.getBoundingClientRect(),c=window.getComputedStyle(a,"::before"),d=window.getComputedStyle(a,"::after");if("none"===c.content&&"none"===d.content)return b;let e=parseFloat(c.width)||0,f=parseFloat(c.height)||0,g=parseFloat(d.width)||0,h=parseFloat(d.height)||0,i=Math.max(b.width,e,g),j=Math.max(b.height,f,h),k=i-b.width,l=j-b.height;return{left:b.left-k/2,right:b.right+k/2,top:b.top-l/2,bottom:b.bottom+l/2}}(N.current);a.clientX>=c.left-2&&a.clientX<=c.right+2&&a.clientY>=c.top-2&&a.clientY<=c.bottom+2||D.events.emit("close",{domEvent:a,reason:f2.REASONS.cancelOpen})});r.useEffect(()=>{y&&u.select("lastOpenChangeReason")===f2.REASONS.triggerHover&&(0,g6.ownerDocument)(N.current).addEventListener("mouseup",P,{once:!0})},[y,P,u]);let Q=I&&A.context.hasSubmenuOpen,R=k??Q,S=(0,hB.useHoverReferenceInteraction)(x,{enabled:R&&!K&&"context-menu"!==A.type&&(!I||Q&&!H),handleClose:(0,hx.safePolygon)({blockPointerEvents:!I}),mouseOnly:!0,move:!1,restMs:void 0===A.type?l:void 0,delay:{close:m},triggerElementRef:z,externalTree:D,isActiveTrigger:w}),T=function(a,b){let c=(0,gH.useTimeout)(),[d,e]=r.useState(!1);return(0,gf.useIsoLayoutEffect)(()=>{a&&"trigger-hover"===b?(e(!0),c.start(gQ.PATIENT_CLICK_THRESHOLD,()=>{e(!1)})):a||(c.clear(),e(!1))},[a,b,c]),d}(y,u.select("lastOpenChangeReason")),U=(0,hy.useClick)(x,{enabled:!K&&"context-menu"!==A.type,event:y&&I?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:void 0===A.type&&T}),V=function(a,b={}){let c="rootStore"in a?a.rootStore:a,{events:d,dataRef:e}=c.context,{enabled:f=!0,delay:g}=b,h=r.useRef(!1),i=r.useRef(null),j=(0,gH.useTimeout)(),k=r.useRef(!0);r.useEffect(()=>{let a=c.select("domReferenceElement");if(!f)return;let b=(0,g4.getWindow)(a);function d(){let a=c.select("domReferenceElement");!c.select("open")&&(0,g4.isHTMLElement)(a)&&a===(0,g7.activeElement)((0,g6.ownerDocument)(a))&&(h.current=!0)}function e(){k.current=!0}function g(){k.current=!1}return b.addEventListener("blur",d),hA&&(b.addEventListener("keydown",e,!0),b.addEventListener("pointerdown",g,!0)),()=>{b.removeEventListener("blur",d),hA&&(b.removeEventListener("keydown",e,!0),b.removeEventListener("pointerdown",g,!0))}},[c,f]),r.useEffect(()=>{if(f)return d.on("openchange",a),()=>{d.off("openchange",a)};function a(a){if(a.reason===f2.REASONS.triggerPress||a.reason===f2.REASONS.escapeKey){let a=c.select("domReferenceElement");(0,g4.isElement)(a)&&(i.current=a,h.current=!0)}}},[d,f,c]);let l=r.useMemo(()=>({onMouseLeave(){h.current=!1,i.current=null},onFocus(a){let b=a.currentTarget;if(h.current){if(i.current===b)return;h.current=!1,i.current=null}let d=(0,g7.getTarget)(a.nativeEvent);if((0,g4.isElement)(d)){if(hA&&!a.relatedTarget){if(!k.current&&!(0,g7.isTypeableElement)(d))return}else if(!(0,g7.matchesFocusVisible)(d))return}let e=(0,g7.isTargetInsideEnabledTrigger)(a.relatedTarget,c.context.triggerElements),{nativeEvent:f,currentTarget:l}=a,m="function"==typeof g?g():g;c.select("open")&&e||0===m||void 0===m?c.setOpen(!0,(0,gm.createChangeEventDetails)(f2.REASONS.triggerFocus,f,l)):j.start(m,()=>{h.current||c.setOpen(!0,(0,gm.createChangeEventDetails)(f2.REASONS.triggerFocus,f,l))})},onBlur(a){h.current=!1,i.current=null;let b=a.relatedTarget,d=a.nativeEvent,f=(0,g4.isElement)(b)&&b.hasAttribute((0,hz.createAttribute)("focus-guard"))&&"outside"===b.getAttribute("data-type");j.start(0,()=>{let a=c.select("domReferenceElement"),g=(0,g7.activeElement)(a?a.ownerDocument:document);if(!b&&g===a||(0,g7.contains)(e.current.floatingContext?.refs.floating.current,g)||(0,g7.contains)(a,g)||f)return;let h=b??g;(0,g7.isTargetInsideEnabledTrigger)(h,c.context.triggerElements)||c.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.triggerFocus,d))})}}),[e,c,j,g]);return r.useMemo(()=>f?{reference:l,trigger:l}:{},[f,l])}(x,{enabled:!K&&Q}),W=function(a){let{enabled:b=!0,mouseDownAction:c,open:d}=a,e=r.useRef(!1);return r.useMemo(()=>b?{onMouseDown:a=>{("open"===c&&!d||"close"===c&&d)&&(e.current=!0,(0,g6.ownerDocument)(a.currentTarget).addEventListener("click",()=>{e.current=!1},{once:!0}))},onClick:a=>{e.current&&(e.current=!1,a.preventBaseUIHandler())}}:g0.EMPTY_OBJECT,[b,c,d])}({open:y,enabled:I,mouseDownAction:"open"}),X=(0,g3.useInteractions)([U,V]),Y={disabled:K,open:y},Z=u.useState("triggerProps",H),$=[N,b,M,G,z],_=[X.getReferenceProps(),S??g0.EMPTY_OBJECT,Z,{"aria-haspopup":"menu",id:v,onMouseDown:a=>{u.select("open")||(O.start(200,()=>{u.context.allowMouseUpTriggerRef.current=!0}),(0,g6.ownerDocument)(a.currentTarget).addEventListener("mouseup",P,{once:!0}))}},I?{role:"menuitem"}:{},W,p,L],aa=r.useRef(null),ab=(0,f5.useStableCallback)(a=>{hw.flushSync(()=>{u.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.focusOut,a.nativeEvent,a.currentTarget))});let b=(0,hC.getTabbableBeforeElement)(aa.current);b?.focus()}),ac=(0,f5.useStableCallback)(a=>{let b=u.select("positionerElement");if(b&&(0,hC.isOutsideEvent)(a,b))u.context.beforeContentFocusGuardRef.current?.focus();else{hw.flushSync(()=>{u.setOpen(!1,(0,gm.createChangeEventDetails)(f2.REASONS.focusOut,a.nativeEvent,a.currentTarget))});let c=(0,hC.getTabbableAfterElement)(u.context.triggerFocusTargetRef.current||z.current);for(;null!==c&&(0,g7.contains)(b,c);){let a=c;if((c=(0,hC.getNextTabbable)(c))===a)break}c?.focus()}}),ad=(0,fY.useRenderElement)("button",a,{enabled:!I,stateAttributesMapping:fZ.pressableTriggerOpenStateMapping,state:Y,ref:$,props:_});return I?(0,q.jsx)(hE,{tag:"button",render:f,className:g,state:Y,refs:$,props:_,stateAttributesMapping:fZ.pressableTriggerOpenStateMapping}):y?(0,q.jsxs)(r.Fragment,{children:[(0,q.jsx)(hF.FocusGuard,{ref:aa,onFocus:ab},`${v}-pre-focus-guard`),(0,q.jsx)(r.Fragment,{children:ad},v),(0,q.jsx)(hF.FocusGuard,{ref:u.context.triggerFocusTargetRef,onFocus:ac},`${v}-post-focus-guard`)]}):(0,q.jsx)(r.Fragment,{children:ad},v)});var hH=a.i(43538);let hI=((p={}).popupWidth="--popup-width",p.popupHeight="--popup-height",p),hJ={activationDirection:a=>a?{"data-activation-direction":a}:null},hK=r.forwardRef(function(a,b){let{render:c,className:d,children:e,...f}=a,{store:g}=fX(),{side:h}=fV(),i=g.useState("instantType"),{children:j,state:k}=(0,hH.usePopupViewport)({store:g,side:h,cssVars:hI,children:e}),l={activationDirection:k.activationDirection,transitioning:k.transitioning,instant:i};return(0,fY.useRenderElement)("div",a,{state:l,ref:b,props:[f,{children:j}],stateAttributesMapping:hJ})}),hL=r.forwardRef(function(a,b){let{className:c,render:d,orientation:e="horizontal",...f}=a;return(0,fY.useRenderElement)("div",a,{state:{orientation:e},ref:b,props:[{role:"separator","aria-orientation":e},f]})}),hM=r.forwardRef(function(a,b){let{render:c,className:d,label:e,id:f,nativeButton:g=!1,openOnHover:h=!0,delay:i=100,closeDelay:j=0,disabled:k=!1,...l}=a,m=gi(),n=fV(),{store:o}=fX(),p=(0,gj.useBaseUiId)(f),q=o.useState("open"),s=o.useState("floatingRootContext"),u=o.useState("floatingTreeRoot"),v=(0,hs.useTriggerRegistration)(p,o),w=r.useCallback(a=>{let b=v(a);return null!==a&&o.select("open")&&null==o.select("activeTriggerId")&&o.update({activeTriggerId:p,activeTriggerElement:a,closeDelay:j}),b},[v,j,o,p]),x=r.useRef(null),y=r.useCallback(a=>{x.current=a,o.set("activeTriggerElement",a)},[o]),z=hu();if(!z?.parentMenu)throw Error((0,fT.default)(37));o.useSyncedValue("closeDelay",j);let A=z.parentMenu,B=A.useState("itemProps"),C=A.useState("isActive",m.index),D=r.useMemo(()=>({type:"submenu-trigger",setActive(){A.set("activeIndex",m.index)}}),[A,m.index]),E=o.useState("disabled"),F=k||E,{getItemProps:G,itemRef:H}=ge({closeOnClick:!1,disabled:F,highlighted:C,id:p,store:o,typingRef:A.context.typingRef,nativeButton:g,itemMetadata:D,nodeId:n?.nodeId}),I=o.useState("hoverEnabled"),J=A.useState("allowMouseEnter"),K=(0,hB.useHoverReferenceInteraction)(s,{enabled:I&&h&&!F,handleClose:(0,hx.safePolygon)({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:i,delay:J?{open:i,close:j}:0,triggerElementRef:x,externalTree:u}),L=(0,hy.useClick)(s,{enabled:!F,event:"mousedown",toggle:!h,ignoreMouse:h,stickIfOpen:!1}),M=(0,g3.useInteractions)([L]),N=o.useState("triggerProps",!0);return delete N.id,(0,fY.useRenderElement)("div",a,{state:{disabled:F,highlighted:C,open:q},stateAttributesMapping:fZ.triggerOpenStateMapping,props:[M.getReferenceProps(),K,N,B,{tabIndex:q||C?0:-1,onBlur(){C&&A.set("activeIndex",null)}},l,G],ref:[b,m.ref,H,w,y]})});class hN{constructor(){this.store=new hr}open(a){let b=a?this.store.context.triggerElements.getById(a):void 0;if(a&&!b)throw Error((0,fT.default)(83,a));this.store.setOpen(!0,(0,gm.createChangeEventDetails)("imperative-action",void 0,b))}close(){this.store.setOpen(!1,(0,gm.createChangeEventDetails)("imperative-action",void 0,void 0))}get isOpen(){return this.store.state.open}}a.s(["Arrow",0,f$,"Backdrop",0,f4,"CheckboxItem",0,gn,"CheckboxItemIndicator",0,gq,"Group",0,gs,"GroupLabel",0,gt,"Handle",0,hN,"Item",0,gu,"LinkItem",0,gv,"Popup",0,gC,"Portal",0,gF,"Positioner",0,gT,"RadioGroup",0,gV,"RadioItem",0,gX,"RadioItemIndicator",0,gY,"Root",0,hv,"Separator",0,hL,"SubmenuRoot",0,function(a){let b=fX().store,c=r.useMemo(()=>({parentMenu:b}),[b]);return(0,q.jsx)(ht.Provider,{value:c,children:(0,q.jsx)(hv,{...a})})},"SubmenuTrigger",0,hM,"Trigger",0,hG,"Viewport",0,hK,"createHandle",0,function(){return new hN}],74483);var hO=a.i(74483),hO=hO;function hP({...a}){return(0,q.jsx)(hO.Root,{"data-slot":"dropdown-menu",...a})}function hQ({...a}){return(0,q.jsx)(hO.Trigger,{"data-slot":"dropdown-menu-trigger",...a})}function hR({align:a="start",alignOffset:b=0,side:c="bottom",sideOffset:d=4,className:e,...f}){return(0,q.jsx)(hO.Portal,{children:(0,q.jsx)(hO.Positioner,{className:"isolate z-50 outline-none",align:a,alignOffset:b,side:c,sideOffset:d,children:(0,q.jsx)(hO.Popup,{"data-slot":"dropdown-menu-content",className:(0,fM.cn)("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",e),...f})})})}function hS({className:a,inset:b,variant:c="default",...d}){return(0,q.jsx)(hO.Item,{"data-slot":"dropdown-menu-item","data-inset":b,"data-variant":c,className:(0,fM.cn)("group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:*:[svg]:text-destructive",a),...d})}function hT({className:a,...b}){return(0,q.jsx)(hO.Separator,{"data-slot":"dropdown-menu-separator",className:(0,fM.cn)("-mx-1 my-1 h-px bg-border/50",a),...b})}a.i(11989),a.i(6406),a.s(["default",0,function({params:a}){let{id:b}=(0,r.use)(a),c=(0,s.useRouter)(),d=(0,F.useToast)(),[e,f]=(0,r.useState)(null),[g,h]=(0,r.useState)(!0),[i,j]=(0,r.useState)([]),[k,l]=(0,r.useState)(),[m,n]=(0,r.useState)(!0),[o,p]=(0,r.useState)(!1),[v,I]=(0,r.useState)(!1),[J,K]=(0,r.useState)(!0),L=(0,r.useRef)(null);(0,G.useDocumentTitle)(e?.title),(0,H.useTaskEvents)({onTaskCreated:()=>{},onTaskUpdated:a=>{a.id===b&&f(a)},onTaskDeleted:a=>{a===b&&(d.info("Task deleted",e?.title??void 0),c.push("/"))}});let M=(0,r.useCallback)(()=>{fetch((0,C.apiUrl)(`/api/tasks/${b}/read`),{method:"POST"}).catch(()=>{})},[b]),N=(0,r.useCallback)((a,b)=>{("success"===b||"failure"===b||"error"===b)&&M()},[M]),O=(0,r.useRef)(null),P=(0,r.useCallback)(async()=>{if(null!==O.current&&O.current!==b&&K(!0),O.current=b,J){n(!0);try{let a=await fetch((0,C.apiUrl)(`/api/tasks/${b}`));if(!a.ok)throw Error("Failed to fetch task");let c=await a.json(),d=c.data.task,e=d.tabs||[];f(d),h(c.data.worktreeExists),j(e),e.length>0&&l(e[0].tab_id),M()}catch(a){console.error("Failed to load data:",a)}finally{n(!1),K(!1)}}},[b,J,M]);(0,r.useEffect)(()=>{P()},[b,P]);let S=async(a,b)=>{let c=d.loading("Updating task...");try{let e=await fetch((0,C.apiUrl)(`/api/tasks/${a}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!e.ok)throw Error("Failed to update task");let g=await e.json();return f(g.data.task),d.success(c,"Successfully updated task"),{success:!0}}catch(b){console.error("Failed to update task:",b);let a=b instanceof Error?b.message:"Failed to update task";return d.error(c,"Failed to update task",a),{success:!1,errors:[{field:"global",message:"Failed to update task"}]}}},T=async(a="claude")=>{try{let c=await fetch((0,C.apiUrl)(`/api/tasks/${b}/tabs`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:a})});if(!c.ok)throw Error("Failed to create tab");let d=(await c.json()).data.tab;return j(a=>a.some(a=>a.tab_id===d.tab_id)?a:[...a,d]),l(d.tab_id),d.tab_id}catch(a){console.error("Failed to create tab:",a);return}},U=async a=>{try{if(!(await fetch((0,C.apiUrl)(`/api/tasks/${b}/tabs/${a}`),{method:"DELETE"})).ok)throw Error("Failed to delete tab");if(j(b=>b.filter(b=>b.tab_id!==a)),k===a){let b=i.filter(b=>b.tab_id!==a);l(b[0]?.tab_id)}}catch(a){console.error("Failed to delete tab:",a)}},V=async()=>{if(!e)return;let a=d.loading("Opening terminal...",e.worktreePath);try{if(!(await fetch((0,C.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"terminal",owner:e.owner,repo:e.repo,branch:e.branch})})).ok)throw Error("Command execution failed");d.success(a,"Successfully opened terminal",e.worktreePath)}catch(c){let b=c instanceof Error?c.message:"Unknown error";d.error(a,"Failed to open terminal",b)}},W=async()=>{if(!e)return;let a=d.loading("Opening VS Code...",e.worktreePath);try{if(!(await fetch((0,C.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"vscode",owner:e.owner,repo:e.repo,branch:e.branch})})).ok)throw Error("Command execution failed");d.success(a,"Successfully opened VS Code",e.worktreePath)}catch(c){let b=c instanceof Error?c.message:"Unknown error";d.error(a,"Failed to open VS Code",b)}};return m&&!e?(0,q.jsx)("div",{className:"h-screen flex items-center justify-center bg-background",children:(0,q.jsx)(E.LoadingSpinner,{size:"lg",message:"Loading task..."})}):e?(0,q.jsxs)("div",{className:"h-screen flex flex-col bg-background",children:[(0,q.jsx)("div",{className:"sticky top-0 z-50 p-4 border-b border-border bg-card",children:(0,q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,q.jsxs)(R.Button,{variant:"ghost",onClick:()=>c.push("/"),className:"text-primary font-medium hover:bg-primary/10 hover:text-foreground",children:[(0,q.jsx)(u.ArrowLeft,{className:"w-4 h-4"}),"Back to Board"]}),(0,q.jsx)("h1",{className:"text-base font-semibold text-foreground absolute left-1/2 -translate-x-1/2 max-w-[50vw] truncate",children:e.title}),(0,q.jsxs)(hP,{children:[(0,q.jsx)(hQ,{render:(0,q.jsx)(R.Button,{variant:"ghost",size:"icon-lg",className:"text-primary hover:bg-primary/10 hover:text-foreground",title:"Task menu"}),children:(0,q.jsx)(x,{className:"w-5 h-5"})}),(0,q.jsxs)(hR,{align:"end",children:[(0,q.jsxs)(hS,{onClick:()=>p(!0),children:[(0,q.jsx)(z.Pencil,{className:"w-4 h-4"}),"Detail / Edit"]}),g&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(hT,{}),(0,q.jsxs)(hS,{onClick:V,children:[(0,q.jsx)(A,{className:"w-4 h-4"}),"Open Terminal"]}),(0,q.jsxs)(hS,{onClick:W,children:[(0,q.jsx)(w,{className:"w-4 h-4"}),"Open VS Code"]})]}),(0,q.jsx)(hT,{}),(0,q.jsxs)(hS,{className:"text-destructive focus:text-destructive",onClick:()=>I(!0),children:[(0,q.jsx)(B.Trash2,{className:"w-4 h-4"}),"Delete"]})]})]})]})}),(0,q.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:(0,q.jsx)("div",{className:"bg-card flex flex-col flex-1 min-h-0",children:g?(0,q.jsx)(fS,{ref:L,task:e,tabs:i,activeTabId:k,onTabChange:l,onTabCreate:T,onTabDelete:U,onClaudeStatusChange:N}):(0,q.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6 text-center",children:[(0,q.jsx)(y,{className:"size-10 text-muted-foreground"}),(0,q.jsxs)("div",{className:"space-y-1",children:[(0,q.jsx)("p",{className:"font-medium text-foreground",children:"Worktree not found"}),(0,q.jsx)("p",{className:"text-sm text-muted-foreground break-all",children:e.worktreePath})]}),(0,q.jsxs)(R.Button,{variant:"destructive",onClick:()=>I(!0),children:[(0,q.jsx)(B.Trash2,{className:"w-4 h-4"}),"Delete Task"]})]})})}),(0,q.jsx)(D.TaskDialog,{mode:"edit",isOpen:o,onClose:()=>p(!1),task:e,onUpdate:S}),(0,q.jsx)(Q.ConfirmDialog,{open:v,onOpenChange:a=>I(a.open),title:"Delete Task",message:`Delete task "${e.title}"?
18
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(a){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),dX&&a&&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:3===this._activeSelectionMode})}_isClickInSelection(a){let b=this._getMouseBufferCoords(a),c=this._model.finalSelectionStart,d=this._model.finalSelectionEnd;return!!c&&!!d&&!!b&&this._areCoordsInSelection(b,c,d)}isCellInSelection(a,b){let c=this._model.finalSelectionStart,d=this._model.finalSelectionEnd;return!!c&&!!d&&this._areCoordsInSelection([a,b],c,d)}_areCoordsInSelection(a,b,c){return a[1]>b[1]&&a[1]<c[1]||b[1]===c[1]&&a[1]===b[1]&&a[0]>=b[0]&&a[0]<c[0]||b[1]<c[1]&&a[1]===c[1]&&a[0]<c[0]||b[1]<c[1]&&a[1]===b[1]&&a[0]>=b[0]}_selectWordAtCursor(a,b){let c=this._linkifier.currentLink?.link?.range;if(c)return this._model.selectionStart=[c.start.x-1,c.start.y-1],this._model.selectionStartLength=ea(c,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let d=this._getMouseBufferCoords(a);return!!d&&(this._selectWordAt(d,b),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(a,b){this._model.clearSelection(),a=Math.max(a,0),b=Math.min(b,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,a],this._model.selectionEnd=[this._bufferService.cols,b],this.refresh(),this._onSelectionChange.fire()}_handleTrim(a){this._model.handleTrim(a)&&this.refresh()}_getMouseBufferCoords(a){let b=this._mouseService.getCoords(a,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(b)return b[0]--,b[1]--,b[1]+=this._bufferService.buffer.ydisp,b}_getMouseEventScrollAmount(a){let b=dG(this._coreBrowserService.window,a,this._screenElement)[1],c=this._renderService.dimensions.css.canvas.height;return b>=0&&b<=c?0:(b>c&&(b-=c),(b=Math.min(Math.max(b,-50),50)/50)/Math.abs(b)+Math.round(14*b))}shouldForceSelection(a){return dT?a.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:a.shiftKey}handleMouseDown(a){if(this._mouseDownTimeStamp=a.timeStamp,!(2===a.button&&this.hasSelection)&&0===a.button){if(!this._enabled){if(!this.shouldForceSelection(a))return;a.stopPropagation()}a.preventDefault(),this._dragScrollAmount=0,this._enabled&&a.shiftKey?this._handleIncrementalClick(a):1===a.detail?this._handleSingleClick(a):2===a.detail?this._handleDoubleClick(a):3===a.detail&&this._handleTripleClick(a),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(a){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(a))}_handleSingleClick(a){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(a),this._model.selectionStart=this._getMouseBufferCoords(a),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let b=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);b&&b.length!==this._model.selectionStart[0]&&0===b.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(a){this._selectWordAtCursor(a,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(a){let b=this._getMouseBufferCoords(a);b&&(this._activeSelectionMode=2,this._selectLineAt(b[1]))}shouldColumnSelect(a){return a.altKey&&!(dT&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(a){if(a.stopImmediatePropagation(),!this._model.selectionStart)return;let b=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(a),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(a),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let c=this._bufferService.buffer;if(this._model.selectionEnd[1]<c.lines.length){let a=c.lines.get(this._model.selectionEnd[1]);a&&0===a.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}b&&b[0]===this._model.selectionEnd[0]&&b[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 a=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(a.ydisp+this._bufferService.rows,a.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=a.ydisp),this.refresh()}}_handleMouseUp(a){let b=a.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&b<500&&a.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let b=this._mouseService.getCoords(a,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(b&&void 0!==b[0]&&void 0!==b[1]){let a=function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u;let v,w=c.buffer.x,x=c.buffer.y;if(!c.buffer.hasScrollback){let u,v,y;return e=w,(0===d4(f=x,b,g=c,h=d).length?"":d8(d6(e,f,e,f-d5(f,g),!1,g).length,d7("D",h)))+d4(x,b,c,d)+(i=w,j=x,k=a,u=d4(j,l=b,m=c,n=d).length>0?l-d5(l,m):j,y=(o=i,p=j,v=d4(q=k,r=l,s=m,n).length>0?r-d5(r,s):p,o<q&&v<=r||o>=q&&v<r?"C":"D"),d8(d6(i,u,k,l,"C"===y,m).length,d7(y,n)))}if(x===b)return v=w>a?"D":"C",d8(Math.abs(w-a),d7(v,d));v=x>b?"D":"C";let y=Math.abs(x-b);return d8((u=x>b?a:w,c.cols-u+(y-1)*c.cols+1+((x>b?w:a)-1)),d7(v,d))}(b[0]-1,b[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(a,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd,c=!!a&&!!b&&(a[0]!==b[0]||a[1]!==b[1]);if(!c){this._oldHasSelection&&this._fireOnSelectionChange(a,b,c);return}!a||!b||this._oldSelectionStart&&this._oldSelectionEnd&&a[0]===this._oldSelectionStart[0]&&a[1]===this._oldSelectionStart[1]&&b[0]===this._oldSelectionEnd[0]&&b[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(a,b,c)}_fireOnSelectionChange(a,b,c){this._oldSelectionStart=a,this._oldSelectionEnd=b,this._oldHasSelection=c,this._onSelectionChange.fire()}_handleBufferActivate(a){this.clearSelection(),this._trimListener.dispose(),this._trimListener=a.activeBuffer.lines.onTrim(a=>this._handleTrim(a))}_convertViewportColToCharacterIndex(a,b){let c=b;for(let d=0;b>=d;d++){let e=a.loadCell(d,this._workCell).getChars().length;0===this._workCell.getWidth()?c--:e>1&&b!==d&&(c+=e-1)}return c}setSelection(a,b,c){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[a,b],this._model.selectionStartLength=c,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(a){this._isClickInSelection(a)||(this._selectWordAtCursor(a,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(a,b,c=!0,d=!0){if(a[0]>=this._bufferService.cols)return;let e=this._bufferService.buffer,f=e.lines.get(a[1]);if(!f)return;let g=e.translateBufferLineToString(a[1],!1),h=this._convertViewportColToCharacterIndex(f,a[0]),i=h,j=a[0]-h,k=0,l=0,m=0,n=0;if(" "===g.charAt(h)){for(;h>0&&" "===g.charAt(h-1);)h--;for(;i<g.length&&" "===g.charAt(i+1);)i++}else{let b=a[0],c=a[0];0===f.getWidth(b)&&(k++,b--),2===f.getWidth(c)&&(l++,c++);let d=f.getString(c).length;for(d>1&&(n+=d-1,i+=d-1);b>0&&h>0&&!this._isCharWordSeparator(f.loadCell(b-1,this._workCell));){f.loadCell(b-1,this._workCell);let a=this._workCell.getChars().length;0===this._workCell.getWidth()?(k++,b--):a>1&&(m+=a-1,h-=a-1),h--,b--}for(;c<f.length&&i+1<g.length&&!this._isCharWordSeparator(f.loadCell(c+1,this._workCell));){f.loadCell(c+1,this._workCell);let a=this._workCell.getChars().length;2===this._workCell.getWidth()?(l++,c++):a>1&&(n+=a-1,i+=a-1),i++,c++}}i++;let o=h+j-k+m,p=Math.min(this._bufferService.cols,i-h+k+l-m-n);if(!(!b&&""===g.slice(h,i).trim())){if(c&&0===o&&32!==f.getCodePoint(0)){let b=e.lines.get(a[1]-1);if(b&&f.isWrapped&&32!==b.getCodePoint(this._bufferService.cols-1)){let b=this._getWordAt([this._bufferService.cols-1,a[1]-1],!1,!0,!1);if(b){let a=this._bufferService.cols-b.start;o-=a,p+=a}}}if(d&&o+p===this._bufferService.cols&&32!==f.getCodePoint(this._bufferService.cols-1)){let b=e.lines.get(a[1]+1);if(b?.isWrapped&&32!==b.getCodePoint(0)){let b=this._getWordAt([0,a[1]+1],!1,!1,!0);b&&(p+=b.length)}}return{start:o,length:p}}}_selectWordAt(a,b){let c=this._getWordAt(a,b);if(c){for(;c.start<0;)c.start+=this._bufferService.cols,a[1]--;this._model.selectionStart=[c.start,a[1]],this._model.selectionStartLength=c.length}}_selectToWordAt(a){let b=this._getWordAt(a,!0);if(b){let c=a[1];for(;b.start<0;)b.start+=this._bufferService.cols,c--;if(!this._model.areSelectionValuesReversed())for(;b.start+b.length>this._bufferService.cols;)b.length-=this._bufferService.cols,c++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?b.start:b.start+b.length,c]}}_isCharWordSeparator(a){return 0!==a.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(a.getChars())>=0}_selectLineAt(a){let b=this._bufferService.buffer.getWrappedRangeForLine(a),c={start:{x:0,y:b.first},end:{x:this._bufferService.cols-1,y:b.last}};this._model.selectionStart=[0,b.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=ea(c,this._bufferService.cols)}};ec=af([ag(3,ax),ag(4,az),ag(5,aK),ag(6,aD),ag(7,aL),ag(8,aJ)],ec);var ed=class{constructor(){this._data={}}set(a,b,c){this._data[a]||(this._data[a]={}),this._data[a][b]=c}get(a,b){return this._data[a]?this._data[a][b]:void 0}clear(){this._data={}}},ee=class{constructor(){this._color=new ed,this._css=new ed}setCss(a,b,c){this._css.set(a,b,c)}getCss(a,b){return this._css.get(a,b)}setColor(a,b,c){this._color.set(a,b,c)}getColor(a,b){return this._color.get(a,b)}clear(){this._color.clear(),this._css.clear()}},ef=Object.freeze((()=>{let a=[eP.toColor("#2e3436"),eP.toColor("#cc0000"),eP.toColor("#4e9a06"),eP.toColor("#c4a000"),eP.toColor("#3465a4"),eP.toColor("#75507b"),eP.toColor("#06989a"),eP.toColor("#d3d7cf"),eP.toColor("#555753"),eP.toColor("#ef2929"),eP.toColor("#8ae234"),eP.toColor("#fce94f"),eP.toColor("#729fcf"),eP.toColor("#ad7fa8"),eP.toColor("#34e2e2"),eP.toColor("#eeeeec")],b=[0,95,135,175,215,255];for(let c=0;c<216;c++){let d=b[c/36%6|0],e=b[c/6%6|0],f=b[c%6];a.push({css:c4.toCss(d,e,f),rgba:c4.toRgba(d,e,f)})}for(let b=0;b<24;b++){let c=8+10*b;a.push({css:c4.toCss(c,c,c),rgba:c4.toRgba(c,c,c)})}return a})()),eg=eP.toColor("#ffffff"),eh=eP.toColor("#000000"),ei=eP.toColor("#ffffff"),ej={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},ek=class extends a2{constructor(a){super(),this._optionsService=a,this._contrastCache=new ee,this._halfContrastCache=new ee,this._onChangeColors=this._register(new bl),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:eg,background:eh,cursor:ei,cursorAccent:eh,selectionForeground:void 0,selectionBackgroundTransparent:ej,selectionBackgroundOpaque:eO.blend(eh,ej),selectionInactiveBackgroundTransparent:ej,selectionInactiveBackgroundOpaque:eO.blend(eh,ej),scrollbarSliderBackground:eO.opacity(eg,.2),scrollbarSliderHoverBackground:eO.opacity(eg,.4),scrollbarSliderActiveBackground:eO.opacity(eg,.5),overviewRulerBorder:eg,ansi:ef.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(a={}){let b=this._colors;if(b.foreground=el(a.foreground,eg),b.background=el(a.background,eh),b.cursor=eO.blend(b.background,el(a.cursor,ei)),b.cursorAccent=eO.blend(b.background,el(a.cursorAccent,eh)),b.selectionBackgroundTransparent=el(a.selectionBackground,ej),b.selectionBackgroundOpaque=eO.blend(b.background,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundTransparent=el(a.selectionInactiveBackground,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundOpaque=eO.blend(b.background,b.selectionInactiveBackgroundTransparent),b.selectionForeground=a.selectionForeground?el(a.selectionForeground,c9):void 0,b.selectionForeground===c9&&(b.selectionForeground=void 0),eO.isOpaque(b.selectionBackgroundTransparent)&&(b.selectionBackgroundTransparent=eO.opacity(b.selectionBackgroundTransparent,.3)),eO.isOpaque(b.selectionInactiveBackgroundTransparent)&&(b.selectionInactiveBackgroundTransparent=eO.opacity(b.selectionInactiveBackgroundTransparent,.3)),b.scrollbarSliderBackground=el(a.scrollbarSliderBackground,eO.opacity(b.foreground,.2)),b.scrollbarSliderHoverBackground=el(a.scrollbarSliderHoverBackground,eO.opacity(b.foreground,.4)),b.scrollbarSliderActiveBackground=el(a.scrollbarSliderActiveBackground,eO.opacity(b.foreground,.5)),b.overviewRulerBorder=el(a.overviewRulerBorder,eg),b.ansi=ef.slice(),b.ansi[0]=el(a.black,ef[0]),b.ansi[1]=el(a.red,ef[1]),b.ansi[2]=el(a.green,ef[2]),b.ansi[3]=el(a.yellow,ef[3]),b.ansi[4]=el(a.blue,ef[4]),b.ansi[5]=el(a.magenta,ef[5]),b.ansi[6]=el(a.cyan,ef[6]),b.ansi[7]=el(a.white,ef[7]),b.ansi[8]=el(a.brightBlack,ef[8]),b.ansi[9]=el(a.brightRed,ef[9]),b.ansi[10]=el(a.brightGreen,ef[10]),b.ansi[11]=el(a.brightYellow,ef[11]),b.ansi[12]=el(a.brightBlue,ef[12]),b.ansi[13]=el(a.brightMagenta,ef[13]),b.ansi[14]=el(a.brightCyan,ef[14]),b.ansi[15]=el(a.brightWhite,ef[15]),a.extendedAnsi){let c=Math.min(b.ansi.length-16,a.extendedAnsi.length);for(let d=0;d<c;d++)b.ansi[d+16]=el(a.extendedAnsi[d],ef[d+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(a){this._restoreColor(a),this._onChangeColors.fire(this.colors)}_restoreColor(a){if(void 0===a){for(let a=0;a<this._restoreColors.ansi.length;++a)this._colors.ansi[a]=this._restoreColors.ansi[a];return}switch(a){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[a]=this._restoreColors.ansi[a]}}modifyColors(a){a(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function el(a,b){if(void 0!==a)try{return eP.toColor(a)}catch{}return b}ek=af([ag(0,aD)],ek);var em=class{constructor(...a){for(let[b,c]of(this._entries=new Map,a))this.set(b,c)}set(a,b){let c=this._entries.get(a);return this._entries.set(a,b),c}forEach(a){for(let[b,c]of this._entries.entries())a(b,c)}has(a){return this._entries.has(a)}get(a){return this._entries.get(a)}},en=class{constructor(){this._services=new em,this._services.set(aB,this)}setService(a,b){this._services.set(a,b)}getService(a){return this._services.get(a)}createInstance(a,...b){let c=(a[au]||[]).sort((a,b)=>a.index-b.index),d=[];for(let b of c){let c=this._services.get(b.id);if(!c)throw Error(`[createInstance] ${a.name} depends on UNKNOWN service ${b.id._id}.`);d.push(c)}let e=c.length>0?c[0].index:b.length;if(b.length!==e)throw Error(`[createInstance] First service dependency of ${a.name} at position ${e+1} conflicts with ${b.length} static arguments`);return new a(...b,...d)}},eo={trace:0,debug:1,info:2,warn:3,error:4,off:5},ep=class extends a2{constructor(a){super(),this._optionsService=a,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=eo[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let b=0;b<a.length;b++)"function"==typeof a[b]&&(a[b]=a[b]())}_log(a,b,c){this._evalLazyOptionalParams(c),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+b,...c)}trace(a,...b){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,a,b)}debug(a,...b){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,a,b)}info(a,...b){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,a,b)}warn(a,...b){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,a,b)}error(a,...b){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,a,b)}};ep=af([ag(0,aD)],ep);var eq=class extends a2{constructor(a){super(),this._maxLength=a,this.onDeleteEmitter=this._register(new bl),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new bl),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new bl),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(a){if(this._maxLength===a)return;let b=Array(a);for(let c=0;c<Math.min(a,this.length);c++)b[c]=this._array[this._getCyclicIndex(c)];this._array=b,this._maxLength=a,this._startIndex=0}get length(){return this._length}set length(a){if(a>this._length)for(let b=this._length;b<a;b++)this._array[b]=void 0;this._length=a}get(a){return this._array[this._getCyclicIndex(a)]}set(a,b){this._array[this._getCyclicIndex(a)]=b}push(a){this._array[this._getCyclicIndex(this._length)]=a,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw 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(a,b,...c){if(b){for(let c=a;c<this._length-b;c++)this._array[this._getCyclicIndex(c)]=this._array[this._getCyclicIndex(c+b)];this._length-=b,this.onDeleteEmitter.fire({index:a,amount:b})}for(let b=this._length-1;b>=a;b--)this._array[this._getCyclicIndex(b+c.length)]=this._array[this._getCyclicIndex(b)];for(let b=0;b<c.length;b++)this._array[this._getCyclicIndex(a+b)]=c[b];if(c.length&&this.onInsertEmitter.fire({index:a,amount:c.length}),this._length+c.length>this._maxLength){let a=this._length+c.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=c.length}trimStart(a){a>this._length&&(a=this._length),this._startIndex+=a,this._length-=a,this.onTrimEmitter.fire(a)}shiftElements(a,b,c){if(!(b<=0)){if(a<0||a>=this._length)throw Error("start argument out of range");if(a+c<0)throw Error("Cannot shift elements in list beyond index 0");if(c>0){for(let d=b-1;d>=0;d--)this.set(a+d+c,this.get(a+d));let d=a+b+c-this._length;if(d>0)for(this._length+=d;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let d=0;d<b;d++)this.set(a+d+c,this.get(a+d))}}_getCyclicIndex(a){return(this._startIndex+a)%this._maxLength}},er=Object.freeze(new aq),es=0,et=class a{constructor(a,b,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);let d=b||as.fromCharData([0,"",1,0]);for(let b=0;b<a;++b)this.setCell(b,d);this.length=a}get(a){let b=this._data[3*a+0],c=2097151&b;return[this._data[3*a+1],2097152&b?this._combined[a]:c?am(c):"",b>>22,2097152&b?this._combined[a].charCodeAt(this._combined[a].length-1):c]}set(a,b){this._data[3*a+1]=b[0],b[1].length>1?(this._combined[a]=b[1],this._data[3*a+0]=2097152|a|b[2]<<22):this._data[3*a+0]=b[1].charCodeAt(0)|b[2]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 0xc00000&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){let b=this._data[3*a+0];return 2097152&b?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&b}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){let b=this._data[3*a+0];return 2097152&b?this._combined[a]:2097151&b?am(2097151&b):""}isProtected(a){return 0x20000000&this._data[3*a+2]}loadCell(a,b){return es=3*a,b.content=this._data[es+0],b.fg=this._data[es+1],b.bg=this._data[es+2],2097152&b.content&&(b.combinedData=this._combined[a]),0x10000000&b.bg&&(b.extended=this._extendedAttrs[a]),b}setCell(a,b){2097152&b.content&&(this._combined[a]=b.combinedData),0x10000000&b.bg&&(this._extendedAttrs[a]=b.extended),this._data[3*a+0]=b.content,this._data[3*a+1]=b.fg,this._data[3*a+2]=b.bg}setCellFromCodepoint(a,b,c,d){0x10000000&d.bg&&(this._extendedAttrs[a]=d.extended),this._data[3*a+0]=b|c<<22,this._data[3*a+1]=d.fg,this._data[3*a+2]=d.bg}addCodepointToCell(a,b,c){let d=this._data[3*a+0];2097152&d?this._combined[a]+=am(b):2097151&d?(this._combined[a]=am(2097151&d)+am(b),d&=-2097152,d|=2097152):d=4194304|b,c&&(d&=-0xc00001,d|=c<<22),this._data[3*a+0]=d}insertCells(a,b,c){if((a%=this.length)&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length-a){let d=new as;for(let c=this.length-a-b-1;c>=0;--c)this.setCell(a+b+c,this.loadCell(a+c,d));for(let d=0;d<b;++d)this.setCell(a+d,c)}else for(let b=a;b<this.length;++b)this.setCell(b,c);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,c)}deleteCells(a,b,c){if(a%=this.length,b<this.length-a){let d=new as;for(let c=0;c<this.length-a-b;++c)this.setCell(a+c,this.loadCell(a+b+c,d));for(let a=this.length-b;a<this.length;++a)this.setCell(a,c)}else for(let b=a;b<this.length;++b)this.setCell(b,c);a&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),0!==this.getWidth(a)||this.hasContent(a)||this.setCellFromCodepoint(a,0,1,c)}replaceCells(a,b,c,d=!1){if(d){for(a&&2===this.getWidth(a-1)&&!this.isProtected(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length&&2===this.getWidth(b-1)&&!this.isProtected(b)&&this.setCellFromCodepoint(b,0,1,c);a<b&&a<this.length;)this.isProtected(a)||this.setCell(a,c),a++;return}for(a&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length&&2===this.getWidth(b-1)&&this.setCellFromCodepoint(b,0,1,c);a<b&&a<this.length;)this.setCell(a++,c)}resize(a,b){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let c=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*c)this._data=new Uint32Array(this._data.buffer,0,c);else{let a=new Uint32Array(c);a.set(this._data),this._data=a}for(let c=this.length;c<a;++c)this.setCell(c,b)}else{this._data=this._data.subarray(0,c);let b=Object.keys(this._combined);for(let c=0;c<b.length;c++){let d=parseInt(b[c],10);d>=a&&delete this._combined[d]}let d=Object.keys(this._extendedAttrs);for(let b=0;b<d.length;b++){let c=parseInt(d[b],10);c>=a&&delete this._extendedAttrs[c]}}return this.length=a,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,b=!1){if(b){for(let b=0;b<this.length;++b)this.isProtected(b)||this.setCell(b,a);return}this._combined={},this._extendedAttrs={};for(let b=0;b<this.length;++b)this.setCell(b,a)}copyFrom(a){for(let b in this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={},a._combined)this._combined[b]=a._combined[b];for(let b in this._extendedAttrs={},a._extendedAttrs)this._extendedAttrs[b]=a._extendedAttrs[b];this.isWrapped=a.isWrapped}clone(){let b=new a(0);for(let a in b._data=new Uint32Array(this._data),b.length=this.length,this._combined)b._combined[a]=this._combined[a];for(let a in this._extendedAttrs)b._extendedAttrs[a]=this._extendedAttrs[a];return b.isWrapped=this.isWrapped,b}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||0x3000000&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,b,c,d,e){let f=a._data;if(e)for(let e=d-1;e>=0;e--){for(let a=0;a<3;a++)this._data[(c+e)*3+a]=f[(b+e)*3+a];0x10000000&f[(b+e)*3+2]&&(this._extendedAttrs[c+e]=a._extendedAttrs[b+e])}else for(let e=0;e<d;e++){for(let a=0;a<3;a++)this._data[(c+e)*3+a]=f[(b+e)*3+a];0x10000000&f[(b+e)*3+2]&&(this._extendedAttrs[c+e]=a._extendedAttrs[b+e])}let g=Object.keys(a._combined);for(let d=0;d<g.length;d++){let e=parseInt(g[d],10);e>=b&&(this._combined[e-b+c]=a._combined[e])}}translateToString(a,b,c,d){b=b??0,c=c??this.length,a&&(c=Math.min(c,this.getTrimmedLength())),d&&(d.length=0);let e="";for(;b<c;){let a=this._data[3*b+0],c=2097151&a,f=2097152&a?this._combined[b]:c?am(c):" ";if(e+=f,d)for(let a=0;a<f.length;++a)d.push(b);b+=a>>22||1}return d&&d.push(b),e}};function eu(a,b,c){if(b===a.length-1)return a[b].getTrimmedLength();let d=!a[b].hasContent(c-1)&&1===a[b].getWidth(c-1),e=2===a[b+1].getWidth(0);return d&&e?c-1:c}var ev=class a{constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new bl),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),a$(this._disposables),this._disposables.length=0)}register(a){return this._disposables.push(a),a}};ev._nextId=1;var ew={},ex=ew.B;ew[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:"≥","{":"π","|":"≠","}":"£","~":"·"},ew.A={"#":"£"},ew.B=void 0,ew[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},ew.C=ew[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},ew.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},ew.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},ew.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},ew.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},ew.E=ew[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},ew.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},ew.H=ew[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},ew["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ey=class{constructor(a,b,c){this._hasScrollback=a,this._optionsService=b,this._bufferService=c,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=er.clone(),this.savedCharset=ex,this.markers=[],this._nullCell=as.fromCharData([0,"",1,0]),this._whitespaceCell=as.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new d0,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new eq(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(a){return a?(this._nullCell.fg=a.fg,this._nullCell.bg=a.bg,this._nullCell.extended=a.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ar),this._nullCell}getWhitespaceCell(a){return a?(this._whitespaceCell.fg=a.fg,this._whitespaceCell.bg=a.bg,this._whitespaceCell.extended=a.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ar),this._whitespaceCell}getBlankLine(a,b){return new et(this._bufferService.cols,this.getNullCell(a),b)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let a=this.ybase+this.y-this.ydisp;return a>=0&&a<this._rows}_getCorrectBufferLength(a){if(!this._hasScrollback)return a;let b=a+this._optionsService.rawOptions.scrollback;return b>0xffffffff?0xffffffff:b}fillViewportRows(a){if(0===this.lines.length){void 0===a&&(a=er);let b=this._rows;for(;b--;)this.lines.push(this.getBlankLine(a))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new eq(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(a,b){let c=this.getNullCell(er),d=0,e=this._getCorrectBufferLength(b);if(e>this.lines.maxLength&&(this.lines.maxLength=e),this.lines.length>0){if(this._cols<a)for(let b=0;b<this.lines.length;b++)d+=+this.lines.get(b).resize(a,c);let f=0;if(this._rows<b)for(let d=this._rows;d<b;d++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new et(a,c)):this.ybase>0&&this.lines.length<=this.ybase+this.y+f+1?(this.ybase--,f++,this.ydisp>0&&this.ydisp--):this.lines.push(new et(a,c)));else for(let a=this._rows;a>b;a--)this.lines.length>b+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(e<this.lines.maxLength){let a=this.lines.length-e;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=e}this.x=Math.min(this.x,a-1),this.y=Math.min(this.y,b-1),f&&(this.y+=f),this.savedX=Math.min(this.savedX,a-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(a,b),this._cols>a))for(let b=0;b<this.lines.length;b++)d+=+this.lines.get(b).resize(a,c);this._cols=a,this._rows=b,this._memoryCleanupQueue.clear(),d>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let a=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,a=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if((b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return a}get _isReflowEnabled(){let a=this._optionsService.rawOptions.windowsPty;return a&&a.buildNumber?this._hasScrollback&&"conpty"===a.backend&&a.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(a,b){this._cols!==a&&(a>this._cols?this._reflowLarger(a,b):this._reflowSmaller(a,b))}_reflowLarger(a,b){let c=this._optionsService.rawOptions.reflowCursorLine,d=function(a,b,c,d,e,f){let g=[];for(let h=0;h<a.length-1;h++){let i=h,j=a.get(++i);if(!j.isWrapped)continue;let k=[a.get(h)];for(;i<a.length&&j.isWrapped;)k.push(j),j=a.get(++i);if(!f&&d>=h&&d<i){h+=k.length-1;continue}let l=0,m=eu(k,0,b),n=1,o=0;for(;n<k.length;){let a=eu(k,n,b),d=Math.min(a-o,c-m);k[l].copyCellsFrom(k[n],o,m,d,!1),(m+=d)===c&&(l++,m=0),(o+=d)===a&&(n++,o=0),0===m&&0!==l&&2===k[l-1].getWidth(c-1)&&(k[l].copyCellsFrom(k[l-1],c-1,m++,1,!1),k[l-1].setCell(c-1,e))}k[l].replaceCells(m,c,e);let p=0;for(let a=k.length-1;a>0&&(a>l||0===k[a].getTrimmedLength());a--)p++;p>0&&(g.push(h+k.length-p),g.push(p)),h+=k.length-1}return g}(this.lines,this._cols,a,this.ybase+this.y,this.getNullCell(er),c);if(d.length>0){let c=function(a,b){let c=[],d=0,e=b[0],f=0;for(let g=0;g<a.length;g++)if(e===g){let c=b[++d];a.onDeleteEmitter.fire({index:g-f,amount:c}),g+=c-1,f+=c,e=b[++d]}else c.push(g);return{layout:c,countRemoved:f}}(this.lines,d);(function(a,b){let c=[];for(let d=0;d<b.length;d++)c.push(a.get(b[d]));for(let b=0;b<c.length;b++)a.set(b,c[b]);a.length=b.length})(this.lines,c.layout),this._reflowLargerAdjustViewport(a,b,c.countRemoved)}}_reflowLargerAdjustViewport(a,b,c){let d=this.getNullCell(er),e=c;for(;e-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new et(a,d))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-c,0)}_reflowSmaller(a,b){let c=this._optionsService.rawOptions.reflowCursorLine,d=this.getNullCell(er),e=[],f=0;for(let g=this.lines.length-1;g>=0;g--){let h=this.lines.get(g);if(!h||!h.isWrapped&&h.getTrimmedLength()<=a)continue;let i=[h];for(;h.isWrapped&&g>0;)h=this.lines.get(--g),i.unshift(h);if(!c){let a=this.ybase+this.y;if(a>=g&&a<g+i.length)continue}let j=i[i.length-1].getTrimmedLength(),k=function(a,b,c){let d=[],e=a.map((c,d)=>eu(a,d,b)).reduce((a,b)=>a+b),f=0,g=0,h=0;for(;h<e;){if(e-h<c){d.push(e-h);break}f+=c;let i=eu(a,g,b);f>i&&(f-=i,g++);let j=2===a[g].getWidth(f-1);j&&f--;let k=j?c-1:c;d.push(k),h+=k}return d}(i,this._cols,a),l=k.length-i.length,m;m=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+l):Math.max(0,this.lines.length-this.lines.maxLength+l);let n=[];for(let a=0;a<l;a++){let a=this.getBlankLine(er,!0);n.push(a)}n.length>0&&(e.push({start:g+i.length+f,newLines:n}),f+=n.length),i.push(...n);let o=k.length-1,p=k[o];0===p&&(p=k[--o]);let q=i.length-l-1,r=j;for(;q>=0;){let a=Math.min(r,p);if(void 0===i[o])break;i[o].copyCellsFrom(i[q],r-a,p-a,a,!0),0==(p-=a)&&(p=k[--o]),0==(r-=a)&&(r=eu(i,Math.max(--q,0),this._cols))}for(let b=0;b<i.length;b++)k[b]<a&&i[b].setCell(k[b],d);let s=l-m;for(;s-- >0;)0===this.ybase?this.y<b-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+f)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+l,this.ybase+b-1)}if(e.length>0){let a=[],b=[];for(let a=0;a<this.lines.length;a++)b.push(this.lines.get(a));let c=this.lines.length,d=c-1,g=0,h=e[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+f);let i=0;for(let j=Math.min(this.lines.maxLength-1,c+f-1);j>=0;j--)if(h&&h.start>d+i){for(let a=h.newLines.length-1;a>=0;a--)this.lines.set(j--,h.newLines[a]);j++,a.push({index:d+1,amount:h.newLines.length}),i+=h.newLines.length,h=e[++g]}else this.lines.set(j,b[d--]);let j=0;for(let b=a.length-1;b>=0;b--)a[b].index+=j,this.lines.onInsertEmitter.fire(a[b]),j+=a[b].amount;let k=Math.max(0,c+f-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(a,b,c=0,d){let e=this.lines.get(a);return e?e.translateToString(b,c,d):""}getWrappedRangeForLine(a){let b=a,c=a;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;c+1<this.lines.length&&this.lines.get(c+1).isWrapped;)c++;return{first:b,last:c}}setupTabStops(a){for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0);a<this._cols;a+=this._optionsService.rawOptions.tabStopWidth)this.tabs[a]=!0}prevStop(a){for(null==a&&(a=this.x);!this.tabs[--a]&&a>0;);return a>=this._cols?this._cols-1:a<0?0:a}nextStop(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a<this._cols;);return a>=this._cols?this._cols-1:a<0?0:a}clearMarkers(a){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].line===a&&(this.markers[b].dispose(),this.markers.splice(b--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let a=0;a<this.markers.length;a++)this.markers[a].dispose();this.markers.length=0,this._isClearing=!1}addMarker(a){let b=new ev(a);return this.markers.push(b),b.register(this.lines.onTrim(a=>{b.line-=a,b.line<0&&b.dispose()})),b.register(this.lines.onInsert(a=>{b.line>=a.index&&(b.line+=a.amount)})),b.register(this.lines.onDelete(a=>{b.line>=a.index&&b.line<a.index+a.amount&&b.dispose(),b.line>a.index&&(b.line-=a.amount)})),b.register(b.onDispose(()=>this._removeMarker(b))),b}_removeMarker(a){this._isClearing||this.markers.splice(this.markers.indexOf(a),1)}},ez=class extends a2{constructor(a,b){super(),this._optionsService=a,this._bufferService=b,this._onBufferActivate=this._register(new bl),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 ey(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ey(!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(a){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(a),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(a,b){this._normal.resize(a,b),this._alt.resize(a,b),this.setupTabStops(a)}setupTabStops(a){this._normal.setupTabStops(a),this._alt.setupTabStops(a)}},eA=class extends a2{constructor(a){super(),this.isUserScrolling=!1,this._onResize=this._register(new bl),this.onResize=this._onResize.event,this._onScroll=this._register(new bl),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,2),this.rows=Math.max(a.rawOptions.rows||0,1),this.buffers=this._register(new ez(a,this)),this._register(this.buffers.onBufferActivate(a=>{this._onScroll.fire(a.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(a,b){let c=this.cols!==a,d=this.rows!==b;this.cols=a,this.rows=b,this.buffers.resize(a,b),this._onResize.fire({cols:a,rows:b,colsChanged:c,rowsChanged:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,b=!1){let c=this.buffer,d;(d=this._cachedBlankLine)&&d.length===this.cols&&d.getFg(0)===a.fg&&d.getBg(0)===a.bg||(d=c.getBlankLine(a,b),this._cachedBlankLine=d),d.isWrapped=b;let e=c.ybase+c.scrollTop,f=c.ybase+c.scrollBottom;if(0===c.scrollTop){let a=c.lines.isFull;f===c.lines.length-1?a?c.lines.recycle().copyFrom(d):c.lines.push(d.clone()):c.lines.splice(f+1,0,d.clone()),a?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{let a=f-e+1;c.lines.shiftElements(e+1,a-1,-1),c.lines.set(f,d.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(a,b){let c=this.buffer;if(a<0){if(0===c.ydisp)return;this.isUserScrolling=!0}else a+c.ydisp>=c.ybase&&(this.isUserScrolling=!1);let d=c.ydisp;c.ydisp=Math.max(Math.min(c.ydisp+a,c.ybase),0),d!==c.ydisp&&(b||this._onScroll.fire(c.ydisp))}};eA=af([ag(0,aD)],eA);var eB={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:dT,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},eC=["normal","bold","100","200","300","400","500","600","700","800","900"],eD=class extends a2{constructor(a){super(),this._onOptionChange=this._register(new bl),this.onOptionChange=this._onOptionChange.event;let b={...eB};for(let c in a)if(c in b)try{let d=a[c];b[c]=this._sanitizeAndValidateOption(c,d)}catch(a){console.error(a)}this.rawOptions=b,this.options={...b},this._setupOptions(),this._register(a_(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(a,b){return this.onOptionChange(c=>{c===a&&b(this.rawOptions[a])})}onMultipleOptionChange(a,b){return this.onOptionChange(c=>{-1!==a.indexOf(c)&&b()})}_setupOptions(){let a=a=>{if(!(a in eB))throw Error(`No option with key "${a}"`);return this.rawOptions[a]},b=(a,b)=>{if(!(a in eB))throw Error(`No option with key "${a}"`);b=this._sanitizeAndValidateOption(a,b),this.rawOptions[a]!==b&&(this.rawOptions[a]=b,this._onOptionChange.fire(a))};for(let c in this.rawOptions){let d={get:a.bind(this,c),set:b.bind(this,c)};Object.defineProperty(this.options,c,d)}}_sanitizeAndValidateOption(a,b){switch(a){case"cursorStyle":var c;if(b||(b=eB[a]),"block"!==(c=b)&&"underline"!==c&&"bar"!==c)throw Error(`"${b}" is not a valid value for ${a}`);break;case"wordSeparator":b||(b=eB[a]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof b&&1<=b&&b<=1e3)break;b=eC.includes(b)?b:eB[a];break;case"cursorWidth":b=Math.floor(b);case"lineHeight":case"tabStopWidth":if(b<1)throw Error(`${a} cannot be less than 1, value: ${b}`);break;case"minimumContrastRatio":b=Math.max(1,Math.min(21,Math.round(10*b)/10));break;case"scrollback":if((b=Math.min(b,0xffffffff))<0)throw Error(`${a} cannot be less than 0, value: ${b}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(b<=0)throw Error(`${a} cannot be less than or equal to 0, value: ${b}`);break;case"rows":case"cols":if(!b&&0!==b)throw Error(`${a} must be numeric, value: ${b}`);break;case"windowsPty":b=b??{}}return b}};function eE(a,b=5){if("object"!=typeof a)return a;let c=Array.isArray(a)?[]:{};for(let d in a)c[d]=b<=1?a[d]:a[d]&&eE(a[d],b-1);return c}var eF=Object.freeze({insertMode:!1}),eG=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),eH=class extends a2{constructor(a,b,c){super(),this._bufferService=a,this._logService=b,this._optionsService=c,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new bl),this.onData=this._onData.event,this._onUserInput=this._register(new bl),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new bl),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new bl),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=eE(eF),this.decPrivateModes=eE(eG)}reset(){this.modes=eE(eF),this.decPrivateModes=eE(eG)}triggerDataEvent(a,b=!1){if(this._optionsService.rawOptions.disableStdin)return;let c=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&c.ybase!==c.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${a}"`),this._logService.trace("sending data (codes)",()=>a.split("").map(a=>a.charCodeAt(0))),this._onData.fire(a)}triggerBinaryEvent(a){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${a}"`),this._logService.trace("sending binary (codes)",()=>a.split("").map(a=>a.charCodeAt(0))),this._onBinary.fire(a))}};eH=af([ag(0,ax),ag(1,aC),ag(2,aD)],eH);var eI={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:a=>4!==a.button&&1===a.action&&(a.ctrl=!1,a.alt=!1,a.shift=!1,!0)},VT200:{events:19,restrict:a=>32!==a.action},DRAG:{events:23,restrict:a=>32!==a.action||3!==a.button},ANY:{events:31,restrict:a=>!0}};function eJ(a,b){let c=16*!!a.ctrl|4*!!a.shift|8*!!a.alt;return 4===a.button?(c|=64,c|=a.action):(c|=3&a.button,4&a.button&&(c|=64),8&a.button&&(c|=128),32===a.action?c|=32:0!==a.action||b||(c|=3)),c}var eK=String.fromCharCode,eL={DEFAULT:a=>{let b=[eJ(a,!1)+32,a.col+32,a.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1b[M${eK(b[0])}${eK(b[1])}${eK(b[2])}`},SGR:a=>{let b=0===a.action&&4!==a.button?"m":"M";return`\x1b[<${eJ(a,!0)};${a.col};${a.row}${b}`},SGR_PIXELS:a=>{let b=0===a.action&&4!==a.button?"m":"M";return`\x1b[<${eJ(a,!0)};${a.x};${a.y}${b}`}},eM=class extends a2{constructor(a,b,c){for(let d of(super(),this._bufferService=a,this._coreService=b,this._optionsService=c,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new bl),this.onProtocolChange=this._onProtocolChange.event,Object.keys(eI)))this.addProtocol(d,eI[d]);for(let a of Object.keys(eL))this.addEncoding(a,eL[a]);this.reset()}addProtocol(a,b){this._protocols[a]=b}addEncoding(a,b){this._encodings[a]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(a){if(!this._protocols[a])throw Error(`unknown protocol "${a}"`);this._activeProtocol=a,this._onProtocolChange.fire(this._protocols[a].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(a){if(!this._encodings[a])throw Error(`unknown encoding "${a}"`);this._activeEncoding=a}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(a,b,c){if(0===a.deltaY||a.shiftKey||void 0===b||void 0===c)return 0;let d=this._applyScrollModifier(a.deltaY,a);return a.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=b/c+0,50>Math.abs(a.deltaY)&&(d*=.3),this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):a.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(a,b){return b.altKey||b.ctrlKey||b.shiftKey?a*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:a*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(a){if(a.col<0||a.col>=this._bufferService.cols||a.row<0||a.row>=this._bufferService.rows||4===a.button&&32===a.action||3===a.button&&32!==a.action||4!==a.button&&(2===a.action||3===a.action)||(a.col++,a.row++,32===a.action&&this._lastEvent&&this._equalEvents(this._lastEvent,a,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(a))return!1;let b=this._encodings[this._activeEncoding](a);return b&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=a,!0}explainEvents(a){return{down:!!(1&a),up:!!(2&a),drag:!!(4&a),move:!!(8&a),wheel:!!(16&a)}}_equalEvents(a,b,c){if(c){if(a.x!==b.x||a.y!==b.y)return!1}else if(a.col!==b.col||a.row!==b.row)return!1;return a.button===b.button&&a.action===b.action&&a.ctrl===b.ctrl&&a.alt===b.alt&&a.shift===b.shift}};eM=af([ag(0,ax),ag(1,az),ag(2,aD)],eM);var eN,eO,eP,eQ,eR,eS,eT=[[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]],eU=[[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]],eV=class{constructor(){if(this.version="6",!eS){(eS=new Uint8Array(65536)).fill(1),eS[0]=0,eS.fill(0,1,32),eS.fill(0,127,160),eS.fill(2,4352,4448),eS[9001]=2,eS[9002]=2,eS.fill(2,11904,42192),eS[12351]=1,eS.fill(2,44032,55204),eS.fill(2,63744,64256),eS.fill(2,65040,65050),eS.fill(2,65072,65136),eS.fill(2,65280,65377),eS.fill(2,65504,65511);for(let a=0;a<eT.length;++a)eS.fill(0,eT[a][0],eT[a][1]+1)}}wcwidth(a){return a<32?0:a<127?1:a<65536?eS[a]:!function(a,b){let c=0,d=b.length-1,e;if(a<b[0][0]||a>b[d][1])return!1;for(;d>=c;)if(a>b[e=c+d>>1][1])c=e+1;else{if(!(a<b[e][0]))return!0;d=e-1}return!1}(a,eU)?a>=131072&&a<=196605||a>=196608&&a<=262141?2:1:0}charProperties(a,b){let c=this.wcwidth(a),d=0===c&&0!==b;if(d){let a=eW.extractWidth(b);0===a?d=!1:a>c&&(c=a)}return eW.createPropertyValue(0,c,d)}},eW=class a{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new bl,this.onChange=this._onChange.event;let a=new eV;this.register(a),this._active=a.version,this._activeProvider=a}static extractShouldJoin(a){return(1&a)!=0}static extractWidth(a){return a>>1&3}static extractCharKind(a){return a>>3}static createPropertyValue(a,b,c=!1){return(0xffffff&a)<<3|(3&b)<<1|!!c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(a){if(!this._providers[a])throw Error(`unknown Unicode version "${a}"`);this._active=a,this._activeProvider=this._providers[a],this._onChange.fire(a)}register(a){this._providers[a.version]=a}wcwidth(a){return this._activeProvider.wcwidth(a)}getStringCellWidth(b){let c=0,d=0,e=b.length;for(let f=0;f<e;++f){let g=b.charCodeAt(f);if(55296<=g&&g<=56319){if(++f>=e)return c+this.wcwidth(g);let a=b.charCodeAt(f);56320<=a&&a<=57343?g=(g-55296)*1024+a-56320+65536:c+=this.wcwidth(a)}let h=this.charProperties(g,d),i=a.extractWidth(h);a.extractShouldJoin(h)&&(i-=a.extractWidth(d)),c+=i,d=h}return c}charProperties(a,b){return this._activeProvider.charProperties(a,b)}},eX=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(a){this.glevel=a,this.charset=this._charsets[a]}setgCharset(a,b){this._charsets[a]=b,this.glevel===a&&(this.charset=b)}};function eY(a){let b=a.buffer.lines.get(a.buffer.ybase+a.buffer.y-1)?.get(a.cols-1),c=a.buffer.lines.get(a.buffer.ybase+a.buffer.y);c&&b&&(c.isWrapped=0!==b[3]&&32!==b[3])}var eZ=class a{constructor(a=32,b=32){if(this.maxLength=a,this.maxSubParamsLength=b,b>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(a),this.length=0,this._subParams=new Int32Array(b),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(a),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(b){let c=new a;if(!b.length)return c;for(let a=+!!Array.isArray(b[0]);a<b.length;++a){let d=b[a];if(Array.isArray(d))for(let a=0;a<d.length;++a)c.addSubParam(d[a]);else c.addParam(d)}return c}clone(){let b=new a(this.maxLength,this.maxSubParamsLength);return b.params.set(this.params),b.length=this.length,b._subParams.set(this._subParams),b._subParamsLength=this._subParamsLength,b._subParamsIdx.set(this._subParamsIdx),b._rejectDigits=this._rejectDigits,b._rejectSubDigits=this._rejectSubDigits,b._digitIsSub=this._digitIsSub,b}toArray(){let a=[];for(let b=0;b<this.length;++b){a.push(this.params[b]);let c=this._subParamsIdx[b]>>8,d=255&this._subParamsIdx[b];d-c>0&&a.push(Array.prototype.slice.call(this._subParams,c,d))}return a}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(a){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(a<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=a>0x7fffffff?0x7fffffff:a}addSubParam(a){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(a<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=a>0x7fffffff?0x7fffffff:a,this._subParamsIdx[this.length-1]++}}hasSubParams(a){return(255&this._subParamsIdx[a])-(this._subParamsIdx[a]>>8)>0}getSubParams(a){let b=this._subParamsIdx[a]>>8,c=255&this._subParamsIdx[a];return c-b>0?this._subParams.subarray(b,c):null}getSubParamsAll(){let a={};for(let b=0;b<this.length;++b){let c=this._subParamsIdx[b]>>8,d=255&this._subParamsIdx[b];d-c>0&&(a[b]=this._subParams.slice(c,d))}return a}addDigit(a){let b;if(this._rejectDigits||!(b=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let c=this._digitIsSub?this._subParams:this.params,d=c[b-1];c[b-1]=~d?Math.min(10*d+a,0x7fffffff):a}},e$=[],e_=class{constructor(){this._state=0,this._active=e$,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(a,b){void 0===this._handlers[a]&&(this._handlers[a]=[]);let c=this._handlers[a];return c.push(b),{dispose:()=>{let a=c.indexOf(b);-1!==a&&c.splice(a,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=e$}reset(){if(2===this._state)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].end(!1);this._stack.paused=!1,this._active=e$,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||e$,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].start();else this._handlerFb(this._id,"START")}_put(a,b,c){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(a,b,c);else this._handlerFb(this._id,"PUT",an(a,b,c))}start(){this.reset(),this._state=1}put(a,b,c){if(3!==this._state){if(1===this._state)for(;b<c;){let c=a[b++];if(59===c){this._state=2,this._start();break}if(c<48||57<c){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+c-48}2===this._state&&c-b>0&&this._put(a,b,c)}}end(a,b=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let c=!1,d=this._active.length-1,e=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,c=b,e=this._stack.fallThrough,this._stack.paused=!1),!e&&!1===c){for(;d>=0&&!0!==(c=this._active[d].end(a));d--)if(c instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,c;d--}for(;d>=0;d--)if((c=this._active[d].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,c}else this._handlerFb(this._id,"END",a);this._active=e$,this._id=-1,this._state=0}}},e0=class{constructor(a){this._handler=a,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(a,b,c){this._hitLimit||(this._data+=an(a,b,c),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(a){let b=!1;if(this._hitLimit)b=!1;else if(a&&(b=this._handler(this._data))instanceof Promise)return b.then(a=>(this._data="",this._hitLimit=!1,a));return this._data="",this._hitLimit=!1,b}},e1=[],e2=class{constructor(){this._handlers=Object.create(null),this._active=e1,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=e1}registerHandler(a,b){void 0===this._handlers[a]&&(this._handlers[a]=[]);let c=this._handlers[a];return c.push(b),{dispose:()=>{let a=c.indexOf(b);-1!==a&&c.splice(a,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}reset(){if(this._active.length)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].unhook(!1);this._stack.paused=!1,this._active=e1,this._ident=0}hook(a,b){if(this.reset(),this._ident=a,this._active=this._handlers[a]||e1,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(a,b,c){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(a,b,c);else this._handlerFb(this._ident,"PUT",an(a,b,c))}unhook(a,b=!0){if(this._active.length){let c=!1,d=this._active.length-1,e=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,c=b,e=this._stack.fallThrough,this._stack.paused=!1),!e&&!1===c){for(;d>=0&&!0!==(c=this._active[d].unhook(a));d--)if(c instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,c;d--}for(;d>=0;d--)if((c=this._active[d].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,c}else this._handlerFb(this._ident,"UNHOOK",a);this._active=e1,this._ident=0}},e3=new eZ;e3.addParam(0);var e4=class{constructor(a){this._handler=a,this._data="",this._params=e3,this._hitLimit=!1}hook(a){this._params=a.length>1||a.params[0]?a.clone():e3,this._data="",this._hitLimit=!1}put(a,b,c){this._hitLimit||(this._data+=an(a,b,c),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(a){let b=!1;if(this._hitLimit)b=!1;else if(a&&(b=this._handler(this._data,this._params))instanceof Promise)return b.then(a=>(this._params=e3,this._data="",this._hitLimit=!1,a));return this._params=e3,this._data="",this._hitLimit=!1,b}},e5=class{constructor(a){this.table=new Uint8Array(a)}setDefault(a,b){this.table.fill(a<<4|b)}add(a,b,c,d){this.table[b<<8|a]=c<<4|d}addMany(a,b,c,d){for(let e=0;e<a.length;e++)this.table[b<<8|a[e]]=c<<4|d}},e6=function(){let a=new e5(4095),b=Array.apply(null,Array(256)).map((a,b)=>b),c=(a,c)=>b.slice(a,c),d=c(32,127),e=c(0,24);e.push(25),e.push.apply(e,c(28,32));let f=c(0,14),g;for(g in a.setDefault(1,0),a.addMany(d,0,2,0),f)a.addMany([24,26,153,154],g,3,0),a.addMany(c(128,144),g,3,0),a.addMany(c(144,152),g,3,0),a.add(156,g,0,0),a.add(27,g,11,1),a.add(157,g,4,8),a.addMany([152,158,159],g,0,7),a.add(155,g,11,3),a.add(144,g,11,9);return a.addMany(e,0,3,0),a.addMany(e,1,3,1),a.add(127,1,0,1),a.addMany(e,8,0,8),a.addMany(e,3,3,3),a.add(127,3,0,3),a.addMany(e,4,3,4),a.add(127,4,0,4),a.addMany(e,6,3,6),a.addMany(e,5,3,5),a.add(127,5,0,5),a.addMany(e,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(d,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(c(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(d,7,0,7),a.addMany(e,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(c(64,127),3,7,0),a.addMany(c(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(c(48,60),4,8,4),a.addMany(c(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(c(32,64),6,0,6),a.add(127,6,0,6),a.addMany(c(64,127),6,0,0),a.addMany(c(32,48),3,9,5),a.addMany(c(32,48),5,9,5),a.addMany(c(48,64),5,0,6),a.addMany(c(64,127),5,7,0),a.addMany(c(32,48),4,9,5),a.addMany(c(32,48),1,9,2),a.addMany(c(32,48),2,9,2),a.addMany(c(48,127),2,10,0),a.addMany(c(48,80),1,10,0),a.addMany(c(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(c(96,127),1,10,0),a.add(80,1,11,9),a.addMany(e,9,0,9),a.add(127,9,0,9),a.addMany(c(28,32),9,0,9),a.addMany(c(32,48),9,9,12),a.addMany(c(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(e,11,0,11),a.addMany(c(32,128),11,0,11),a.addMany(c(28,32),11,0,11),a.addMany(e,10,0,10),a.add(127,10,0,10),a.addMany(c(28,32),10,0,10),a.addMany(c(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(c(32,48),10,9,12),a.addMany(e,12,0,12),a.add(127,12,0,12),a.addMany(c(28,32),12,0,12),a.addMany(c(32,48),12,9,12),a.addMany(c(48,64),12,0,11),a.addMany(c(64,127),12,12,13),a.addMany(c(64,127),10,12,13),a.addMany(c(64,127),9,12,13),a.addMany(e,13,13,13),a.addMany(d,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(160,0,2,0),a.add(160,8,5,8),a.add(160,6,0,6),a.add(160,11,0,11),a.add(160,13,13,13),a}(),e7=class extends a2{constructor(a=e6){super(),this._transitions=a,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new eZ,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(a,b,c)=>{},this._executeHandlerFb=a=>{},this._csiHandlerFb=(a,b)=>{},this._escHandlerFb=a=>{},this._errorHandlerFb=a=>a,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(a_(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new e_),this._dcsParser=this._register(new e2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(a,b=[64,126]){let c=0;if(a.prefix){if(a.prefix.length>1)throw Error("only one byte as prefix supported");if((c=a.prefix.charCodeAt(0))&&60>c||c>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(a.intermediates){if(a.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let b=0;b<a.intermediates.length;++b){let d=a.intermediates.charCodeAt(b);if(32>d||d>47)throw Error("intermediate must be in range 0x20 .. 0x2f");c<<=8,c|=d}}if(1!==a.final.length)throw Error("final must be a single byte");let d=a.final.charCodeAt(0);if(b[0]>d||d>b[1])throw Error(`final must be in range ${b[0]} .. ${b[1]}`);return c<<=8,c|=d}identToString(a){let b=[];for(;a;)b.push(String.fromCharCode(255&a)),a>>=8;return b.reverse().join("")}setPrintHandler(a){this._printHandler=a}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(a,b){let c=this._identifier(a,[48,126]);void 0===this._escHandlers[c]&&(this._escHandlers[c]=[]);let d=this._escHandlers[c];return d.push(b),{dispose:()=>{let a=d.indexOf(b);-1!==a&&d.splice(a,1)}}}clearEscHandler(a){this._escHandlers[this._identifier(a,[48,126])]&&delete this._escHandlers[this._identifier(a,[48,126])]}setEscHandlerFallback(a){this._escHandlerFb=a}setExecuteHandler(a,b){this._executeHandlers[a.charCodeAt(0)]=b}clearExecuteHandler(a){this._executeHandlers[a.charCodeAt(0)]&&delete this._executeHandlers[a.charCodeAt(0)]}setExecuteHandlerFallback(a){this._executeHandlerFb=a}registerCsiHandler(a,b){let c=this._identifier(a);void 0===this._csiHandlers[c]&&(this._csiHandlers[c]=[]);let d=this._csiHandlers[c];return d.push(b),{dispose:()=>{let a=d.indexOf(b);-1!==a&&d.splice(a,1)}}}clearCsiHandler(a){this._csiHandlers[this._identifier(a)]&&delete this._csiHandlers[this._identifier(a)]}setCsiHandlerFallback(a){this._csiHandlerFb=a}registerDcsHandler(a,b){return this._dcsParser.registerHandler(this._identifier(a),b)}clearDcsHandler(a){this._dcsParser.clearHandler(this._identifier(a))}setDcsHandlerFallback(a){this._dcsParser.setHandlerFallback(a)}registerOscHandler(a,b){return this._oscParser.registerHandler(a,b)}clearOscHandler(a){this._oscParser.clearHandler(a)}setOscHandlerFallback(a){this._oscParser.setHandlerFallback(a)}setErrorHandler(a){this._errorHandler=a}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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(a,b,c,d,e){this._parseStack.state=a,this._parseStack.handlers=b,this._parseStack.handlerPos=c,this._parseStack.transition=d,this._parseStack.chunkPos=e}parse(a,b,c){let d=0,e=0,f=0,g;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,f=this._parseStack.chunkPos+1;else{if(void 0===c||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let b=this._parseStack.handlers,e=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===c&&e>-1){for(;e>=0&&!0!==(g=b[e](this._params));e--)if(g instanceof Promise)return this._parseStack.handlerPos=e,g}this._parseStack.handlers=[];break;case 4:if(!1===c&&e>-1){for(;e>=0&&!0!==(g=b[e]());e--)if(g instanceof Promise)return this._parseStack.handlerPos=e,g}this._parseStack.handlers=[];break;case 6:if(d=a[this._parseStack.chunkPos],g=this._dcsParser.unhook(24!==d&&26!==d,c))return g;27===d&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(d=a[this._parseStack.chunkPos],g=this._oscParser.end(24!==d&&26!==d,c))return g;27===d&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,f=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let c=f;c<b;++c){switch(d=a[c],(e=this._transitions.table[this.currentState<<8|(d<160?d:160)])>>4){case 2:for(let e=c+1;;++e)if(e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160){this._printHandler(a,c,e),c=e-1;break}break;case 3:this._executeHandlers[d]?this._executeHandlers[d]():this._executeHandlerFb(d),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,code:d,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|d],h=f?f.length-1:-1;for(;h>=0&&!0!==(g=f[h](this._params));h--)if(g instanceof Promise)return this._preserveStack(3,f,h,e,c),g;h<0&&this._csiHandlerFb(this._collect<<8|d,this._params),this.precedingJoinState=0;break;case 8:do switch(d){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(d-48)}while(++c<b&&(d=a[c])>47&&d<60)c--;break;case 9:this._collect<<=8,this._collect|=d;break;case 10:let i=this._escHandlers[this._collect<<8|d],j=i?i.length-1:-1;for(;j>=0&&!0!==(g=i[j]());j--)if(g instanceof Promise)return this._preserveStack(4,i,j,e,c),g;j<0&&this._escHandlerFb(this._collect<<8|d),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|d,this._params);break;case 13:for(let e=c+1;;++e)if(e>=b||24===(d=a[e])||26===d||27===d||d>127&&d<160){this._dcsParser.put(a,c,e),c=e-1;break}break;case 14:if(g=this._dcsParser.unhook(24!==d&&26!==d))return this._preserveStack(6,[],0,e,c),g;27===d&&(e|=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 e=c+1;;e++)if(e>=b||(d=a[e])<32||d>127&&d<160){this._oscParser.put(a,c,e),c=e-1;break}break;case 6:if(g=this._oscParser.end(24!==d&&26!==d))return this._preserveStack(5,[],0,e,c),g;27===d&&(e|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&e}}},e8=/^([\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})$/,e9=/^[\da-f]+$/;function fa(a){if(!a)return;let b=a.toLowerCase();if(0===b.indexOf("rgb:")){b=b.slice(4);let a=e8.exec(b);if(a){let b=a[1]?15:a[4]?255:a[7]?4095:65535;return[Math.round(parseInt(a[1]||a[4]||a[7]||a[10],16)/b*255),Math.round(parseInt(a[2]||a[5]||a[8]||a[11],16)/b*255),Math.round(parseInt(a[3]||a[6]||a[9]||a[12],16)/b*255)]}}else if(0===b.indexOf("#")&&(b=b.slice(1),e9.exec(b)&&[3,6,9,12].includes(b.length))){let a=b.length/3,c=[0,0,0];for(let d=0;d<3;++d){let e=parseInt(b.slice(a*d,a*d+a),16);c[d]=1===a?e<<4:2===a?e:3===a?e>>4:e>>8}return c}}function fb(a,b){let c=a.toString(16),d=c.length<2?"0"+c:c;switch(b){case 4:return c[0];case 8:return d;case 12:return(d+d).slice(0,3);default:return d+d}}var fc={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function fd(a,b){if(a>24)return b.setWinLines||!1;switch(a){case 1:return!!b.restoreWin;case 2:return!!b.minimizeWin;case 3:return!!b.setWinPosition;case 4:return!!b.setWinSizePixels;case 5:return!!b.raiseWin;case 6:return!!b.lowerWin;case 7:return!!b.refreshWin;case 8:return!!b.setWinSizeChars;case 9:return!!b.maximizeWin;case 10:return!!b.fullscreenWin;case 11:return!!b.getWinState;case 13:return!!b.getWinPosition;case 14:return!!b.getWinSizePixels;case 15:return!!b.getScreenSizePixels;case 16:return!!b.getCellSizePixels;case 18:return!!b.getWinSizeChars;case 19:return!!b.getScreenSizeChars;case 20:return!!b.getIconTitle;case 21:return!!b.getWinTitle;case 22:return!!b.pushTitle;case 23:return!!b.popTitle;case 24:return!!b.setWinLines}return!1}var fe=0,ff=class extends a2{constructor(a,b,c,d,e,f,g,h,i=new e7){for(let j in super(),this._bufferService=a,this._charsetService=b,this._coreService=c,this._logService=d,this._optionsService=e,this._oscLinkService=f,this._coreMouseService=g,this._unicodeService=h,this._parser=i,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ao,this._utf8Decoder=new ap,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=er.clone(),this._eraseAttrDataInternal=er.clone(),this._onRequestBell=this._register(new bl),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new bl),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new bl),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new bl),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new bl),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new bl),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new bl),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new bl),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new bl),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new bl),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new bl),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new bl),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new bl),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 fg(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(a=>this._activeBuffer=a.activeBuffer)),this._parser.setCsiHandlerFallback((a,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(a),params:b.toArray()})}),this._parser.setEscHandlerFallback(a=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(a)})}),this._parser.setExecuteHandlerFallback(a=>{this._logService.debug("Unknown EXECUTE code: ",{code:a})}),this._parser.setOscHandlerFallback((a,b,c)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:b,data:c})}),this._parser.setDcsHandlerFallback((a,b,c)=>{"HOOK"===b&&(c=c.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:b,payload:c})}),this._parser.setPrintHandler((a,b,c)=>this.print(a,b,c)),this._parser.registerCsiHandler({final:"@"},a=>this.insertChars(a)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},a=>this.scrollLeft(a)),this._parser.registerCsiHandler({final:"A"},a=>this.cursorUp(a)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},a=>this.scrollRight(a)),this._parser.registerCsiHandler({final:"B"},a=>this.cursorDown(a)),this._parser.registerCsiHandler({final:"C"},a=>this.cursorForward(a)),this._parser.registerCsiHandler({final:"D"},a=>this.cursorBackward(a)),this._parser.registerCsiHandler({final:"E"},a=>this.cursorNextLine(a)),this._parser.registerCsiHandler({final:"F"},a=>this.cursorPrecedingLine(a)),this._parser.registerCsiHandler({final:"G"},a=>this.cursorCharAbsolute(a)),this._parser.registerCsiHandler({final:"H"},a=>this.cursorPosition(a)),this._parser.registerCsiHandler({final:"I"},a=>this.cursorForwardTab(a)),this._parser.registerCsiHandler({final:"J"},a=>this.eraseInDisplay(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},a=>this.eraseInDisplay(a,!0)),this._parser.registerCsiHandler({final:"K"},a=>this.eraseInLine(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},a=>this.eraseInLine(a,!0)),this._parser.registerCsiHandler({final:"L"},a=>this.insertLines(a)),this._parser.registerCsiHandler({final:"M"},a=>this.deleteLines(a)),this._parser.registerCsiHandler({final:"P"},a=>this.deleteChars(a)),this._parser.registerCsiHandler({final:"S"},a=>this.scrollUp(a)),this._parser.registerCsiHandler({final:"T"},a=>this.scrollDown(a)),this._parser.registerCsiHandler({final:"X"},a=>this.eraseChars(a)),this._parser.registerCsiHandler({final:"Z"},a=>this.cursorBackwardTab(a)),this._parser.registerCsiHandler({final:"`"},a=>this.charPosAbsolute(a)),this._parser.registerCsiHandler({final:"a"},a=>this.hPositionRelative(a)),this._parser.registerCsiHandler({final:"b"},a=>this.repeatPrecedingCharacter(a)),this._parser.registerCsiHandler({final:"c"},a=>this.sendDeviceAttributesPrimary(a)),this._parser.registerCsiHandler({prefix:">",final:"c"},a=>this.sendDeviceAttributesSecondary(a)),this._parser.registerCsiHandler({final:"d"},a=>this.linePosAbsolute(a)),this._parser.registerCsiHandler({final:"e"},a=>this.vPositionRelative(a)),this._parser.registerCsiHandler({final:"f"},a=>this.hVPosition(a)),this._parser.registerCsiHandler({final:"g"},a=>this.tabClear(a)),this._parser.registerCsiHandler({final:"h"},a=>this.setMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"h"},a=>this.setModePrivate(a)),this._parser.registerCsiHandler({final:"l"},a=>this.resetMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"l"},a=>this.resetModePrivate(a)),this._parser.registerCsiHandler({final:"m"},a=>this.charAttributes(a)),this._parser.registerCsiHandler({final:"n"},a=>this.deviceStatus(a)),this._parser.registerCsiHandler({prefix:"?",final:"n"},a=>this.deviceStatusPrivate(a)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},a=>this.softReset(a)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},a=>this.setCursorStyle(a)),this._parser.registerCsiHandler({final:"r"},a=>this.setScrollRegion(a)),this._parser.registerCsiHandler({final:"s"},a=>this.saveCursor(a)),this._parser.registerCsiHandler({final:"t"},a=>this.windowOptions(a)),this._parser.registerCsiHandler({final:"u"},a=>this.restoreCursor(a)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},a=>this.insertColumns(a)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},a=>this.deleteColumns(a)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},a=>this.selectProtected(a)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},a=>this.requestMode(a,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},a=>this.requestMode(a,!1)),this._parser.setExecuteHandler(c1.BEL,()=>this.bell()),this._parser.setExecuteHandler(c1.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(c1.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(c1.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(c1.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(c1.BS,()=>this.backspace()),this._parser.setExecuteHandler(c1.HT,()=>this.tab()),this._parser.setExecuteHandler(c1.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(c1.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(c2.IND,()=>this.index()),this._parser.setExecuteHandler(c2.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(c2.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new e0(a=>(this.setTitle(a),this.setIconName(a),!0))),this._parser.registerOscHandler(1,new e0(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new e0(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new e0(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new e0(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new e0(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new e0(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new e0(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new e0(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new e0(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new e0(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new e0(a=>this.restoreCursorColor(a))),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()),ew)this._parser.registerEscHandler({intermediates:"(",final:j},()=>this.selectCharset("("+j)),this._parser.registerEscHandler({intermediates:")",final:j},()=>this.selectCharset(")"+j)),this._parser.registerEscHandler({intermediates:"*",final:j},()=>this.selectCharset("*"+j)),this._parser.registerEscHandler({intermediates:"+",final:j},()=>this.selectCharset("+"+j)),this._parser.registerEscHandler({intermediates:"-",final:j},()=>this.selectCharset("-"+j)),this._parser.registerEscHandler({intermediates:".",final:j},()=>this.selectCharset("."+j)),this._parser.registerEscHandler({intermediates:"/",final:j},()=>this.selectCharset("/"+j));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(a=>(this._logService.error("Parsing error: ",a),a)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new e4((a,b)=>this.requestStatusString(a,b)))}getAttrData(){return this._curAttrData}_preserveStack(a,b,c,d){this._parseStack.paused=!0,this._parseStack.cursorStartX=a,this._parseStack.cursorStartY=b,this._parseStack.decodedLength=c,this._parseStack.position=d}_logSlowResolvingAsync(a){this._logService.logLevel<=3&&Promise.race([a,new Promise((a,b)=>setTimeout(()=>b("#SLOW_TIMEOUT"),5e3))]).catch(a=>{if("#SLOW_TIMEOUT"!==a)throw a;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(a,b){let c,d=this._activeBuffer.x,e=this._activeBuffer.y,f=0,g=this._parseStack.paused;if(g){if(c=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,b))return this._logSlowResolvingAsync(c),c;d=this._parseStack.cursorStartX,e=this._parseStack.cursorStartY,this._parseStack.paused=!1,a.length>131072&&(f=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof a?` "${a}"`:` "${Array.prototype.map.call(a,a=>String.fromCharCode(a)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof a?a.split("").map(a=>a.charCodeAt(0)):a),this._parseBuffer.length<a.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(a.length,131072))),g||this._dirtyRowTracker.clearRange(),a.length>131072)for(let b=f;b<a.length;b+=131072){let f=b+131072<a.length?b+131072:a.length,g="string"==typeof a?this._stringDecoder.decode(a.substring(b,f),this._parseBuffer):this._utf8Decoder.decode(a.subarray(b,f),this._parseBuffer);if(c=this._parser.parse(this._parseBuffer,g))return this._preserveStack(d,e,g,b),this._logSlowResolvingAsync(c),c}else if(!g){let b="string"==typeof a?this._stringDecoder.decode(a,this._parseBuffer):this._utf8Decoder.decode(a,this._parseBuffer);if(c=this._parser.parse(this._parseBuffer,b))return this._preserveStack(d,e,b,0),this._logSlowResolvingAsync(c),c}(this._activeBuffer.x!==d||this._activeBuffer.y!==e)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),i=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);i<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(i,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(a,b,c){let d,e,f=this._charsetService.charset,g=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,i=this._coreService.decPrivateModes.wraparound,j=this._coreService.modes.insertMode,k=this._curAttrData,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&c-b>0&&2===l.getWidth(this._activeBuffer.x-1)&&l.setCellFromCodepoint(this._activeBuffer.x-1,0,1,k);let m=this._parser.precedingJoinState;for(let n=b;n<c;++n){if((d=a[n])<127&&f){let a=f[String.fromCharCode(d)];a&&(d=a.charCodeAt(0))}let b=this._unicodeService.charProperties(d,m);e=eW.extractWidth(b);let c=eW.extractShouldJoin(b),o=c?eW.extractWidth(m):0;if(m=b,g&&this._onA11yChar.fire(am(d)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+e-o>h){if(i){let a=l,b=this._activeBuffer.x-o;for(this._activeBuffer.x=o,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),l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),o>0&&l instanceof et&&l.copyCellsFrom(a,b,0,o,!1);b<h;)a.setCellFromCodepoint(b++,0,1,k)}else if(this._activeBuffer.x=h-1,2===e)continue}if(c&&this._activeBuffer.x){let a=l.getWidth(this._activeBuffer.x-1)?1:2;l.addCodepointToCell(this._activeBuffer.x-a,d,e);for(let a=e-o;--a>=0;)l.setCellFromCodepoint(this._activeBuffer.x++,0,0,k);continue}if(j&&(l.insertCells(this._activeBuffer.x,e-o,this._activeBuffer.getNullCell(k)),2===l.getWidth(h-1)&&l.setCellFromCodepoint(h-1,0,1,k)),l.setCellFromCodepoint(this._activeBuffer.x++,d,e,k),e>0)for(;--e;)l.setCellFromCodepoint(this._activeBuffer.x++,0,0,k)}this._parser.precedingJoinState=m,this._activeBuffer.x<h&&c-b>0&&0===l.getWidth(this._activeBuffer.x)&&!l.hasContent(this._activeBuffer.x)&&l.setCellFromCodepoint(this._activeBuffer.x,0,1,k),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(a,b){return"t"!==a.final||a.prefix||a.intermediates?this._parser.registerCsiHandler(a,b):this._parser.registerCsiHandler(a,a=>!fd(a.params[0],this._optionsService.rawOptions.windowOptions)||b(a))}registerDcsHandler(a,b){return this._parser.registerDcsHandler(a,new e4(b))}registerEscHandler(a,b){return this._parser.registerEscHandler(a,b)}registerOscHandler(a,b){return this._parser.registerOscHandler(a,new e0(b))}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(){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(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);a.hasWidth(this._activeBuffer.x)&&!a.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let a=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-a),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(a=this._bufferService.cols-1){this._activeBuffer.x=Math.min(a,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(a,b){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=a,this._activeBuffer.y=this._activeBuffer.scrollTop+b):(this._activeBuffer.x=a,this._activeBuffer.y=b),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(a,b){this._restrictCursor(),this._setCursor(this._activeBuffer.x+a,this._activeBuffer.y+b)}cursorUp(a){let b=this._activeBuffer.y-this._activeBuffer.scrollTop;return b>=0?this._moveCursor(0,-Math.min(b,a.params[0]||1)):this._moveCursor(0,-(a.params[0]||1)),!0}cursorDown(a){let b=this._activeBuffer.scrollBottom-this._activeBuffer.y;return b>=0?this._moveCursor(0,Math.min(b,a.params[0]||1)):this._moveCursor(0,a.params[0]||1),!0}cursorForward(a){return this._moveCursor(a.params[0]||1,0),!0}cursorBackward(a){return this._moveCursor(-(a.params[0]||1),0),!0}cursorNextLine(a){return this.cursorDown(a),this._activeBuffer.x=0,!0}cursorPrecedingLine(a){return this.cursorUp(a),this._activeBuffer.x=0,!0}cursorCharAbsolute(a){return this._setCursor((a.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(a){return this._setCursor(a.length>=2?(a.params[1]||1)-1:0,(a.params[0]||1)-1),!0}charPosAbsolute(a){return this._setCursor((a.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(a){return this._moveCursor(a.params[0]||1,0),!0}linePosAbsolute(a){return this._setCursor(this._activeBuffer.x,(a.params[0]||1)-1),!0}vPositionRelative(a){return this._moveCursor(0,a.params[0]||1),!0}hVPosition(a){return this.cursorPosition(a),!0}tabClear(a){let b=a.params[0];return 0===b?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===b&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(a){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=a.params[0]||1;for(;b--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(a){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=a.params[0]||1;for(;b--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(a){let b=a.params[0];return 1===b&&(this._curAttrData.bg|=0x20000000),(2===b||0===b)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(a,b,c,d=!1,e=!1){let f=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);f.replaceCells(b,c,this._activeBuffer.getNullCell(this._eraseAttrData()),e),d&&(f.isWrapped=!1)}_resetBufferLine(a,b=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c&&(c.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),b),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+a),c.isWrapped=!1)}eraseInDisplay(a,b=!1){let c;switch(this._restrictCursor(this._bufferService.cols),a.params[0]){case 0:for(c=this._activeBuffer.y,this._dirtyRowTracker.markDirty(c),this._eraseInBufferLine(c++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,b);c<this._bufferService.rows;c++)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(c);break;case 1:for(c=this._activeBuffer.y,this._dirtyRowTracker.markDirty(c),this._eraseInBufferLine(c,0,this._activeBuffer.x+1,!0,b),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(c+1).isWrapped=!1);c--;)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(c=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,c-1);c--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+c)?.getTrimmedLength(););for(;c>=0;c--)this._bufferService.scroll(this._eraseAttrData())}else{for(c=this._bufferService.rows,this._dirtyRowTracker.markDirty(c-1);c--;)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(0)}break;case 3:let d=this._activeBuffer.lines.length-this._bufferService.rows;d>0&&(this._activeBuffer.lines.trimStart(d),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-d,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-d,0),this._onScroll.fire(0))}return!0}eraseInLine(a,b=!1){switch(this._restrictCursor(this._bufferService.cols),a.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,b);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,b);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,b)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(a){this._restrictCursor();let b=a.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let c=this._activeBuffer.ybase+this._activeBuffer.y,d=this._bufferService.rows-1-this._activeBuffer.scrollBottom,e=this._bufferService.rows-1+this._activeBuffer.ybase-d+1;for(;b--;)this._activeBuffer.lines.splice(e-1,1),this._activeBuffer.lines.splice(c,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(a){this._restrictCursor();let b=a.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let c=this._activeBuffer.ybase+this._activeBuffer.y,d;for(d=this._bufferService.rows-1-this._activeBuffer.scrollBottom,d=this._bufferService.rows-1+this._activeBuffer.ybase-d;b--;)this._activeBuffer.lines.splice(c,1),this._activeBuffer.lines.splice(d,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.insertCells(this._activeBuffer.x,a.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.deleteCells(this._activeBuffer.x,a.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(a){let b=a.params[0]||1;for(;b--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(a){let b=a.params[0]||1;for(;b--;)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(er));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.deleteCells(0,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.insertCells(0,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.insertCells(this._activeBuffer.x,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.deleteCells(this._activeBuffer.x,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(a.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(a){let b=this._parser.precedingJoinState;if(!b)return!0;let c=a.params[0]||1,d=eW.extractWidth(b),e=this._activeBuffer.x-d,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(e),g=new Uint32Array(f.length*c),h=0;for(let a=0;a<f.length;){let b=f.codePointAt(a)||0;g[h++]=b,a+=b>65535?2:1}let i=h;for(let a=1;a<c;++a)g.copyWithin(i,0,h),i+=h;return this.print(g,0,i),!0}sendDeviceAttributesPrimary(a){return a.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c1.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c1.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(a){return a.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c1.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c1.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(a.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c1.ESC+"[>83;40003;0c")),!0}_is(a){return 0===(this._optionsService.rawOptions.termName+"").indexOf(a)}setMode(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ex),this._charsetService.setgCharset(1,ex),this._charsetService.setgCharset(2,ex),this._charsetService.setgCharset(3,ex);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}return!0}resetMode(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===a.params[b]&&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)}return!0}requestMode(a,b){let c,d,e,f;(d=c||={})[d.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",d[d.SET=1]="SET",d[d.RESET=2]="RESET",d[d.PERMANENTLY_SET=3]="PERMANENTLY_SET",d[d.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let g=this._coreService.decPrivateModes,{activeProtocol:h,activeEncoding:i}=this._coreMouseService,j=this._coreService,{buffers:k,cols:l}=this._bufferService,{active:m,alt:n}=k,o=this._optionsService.rawOptions,p=a=>a?1:2,q=a.params[0];return e=q,f=b?2===q?4:4===q?p(j.modes.insertMode):12===q?3:20===q?p(o.convertEol):0:1===q?p(g.applicationCursorKeys):3===q?o.windowOptions.setWinLines?80===l?2:+(132===l):0:6===q?p(g.origin):7===q?p(g.wraparound):8===q?3:9===q?p("X10"===h):12===q?p(o.cursorBlink):25===q?p(!j.isCursorHidden):45===q?p(g.reverseWraparound):66===q?p(g.applicationKeypad):67===q?4:1e3===q?p("VT200"===h):1002===q?p("DRAG"===h):1003===q?p("ANY"===h):1004===q?p(g.sendFocus):1005===q?4:1006===q?p("SGR"===i):1015===q?4:1016===q?p("SGR_PIXELS"===i):1048===q?1:47===q||1047===q||1049===q?p(m===n):2004===q?p(g.bracketedPasteMode):2026===q?p(g.synchronizedOutput):0,j.triggerDataEvent(`${c1.ESC}[${b?"":"?"}${e};${f}$y`),!0}_updateAttrColor(a,b,c,d,e){return 2===b?(a|=0x3000000,a&=-0x1000000,a|=aq.fromColorRGB([c,d,e])):5===b&&(a&=-0x3000100,a|=0x2000000|255&c),a}_extractColor(a,b,c){let d=[0,0,-1,0,0,0],e=0,f=0;do{if(d[f+e]=a.params[b+f],a.hasSubParams(b+f)){let c=a.getSubParams(b+f),g=0;do 5===d[1]&&(e=1),d[f+g+1+e]=c[g];while(++g<c.length&&g+f+1+e<d.length)break}if(5===d[1]&&f+e>=2||2===d[1]&&f+e>=5)break;d[1]&&(e=1)}while(++f+b<a.length&&f+e<d.length)for(let a=2;a<d.length;++a)-1===d[a]&&(d[a]=0);switch(d[0]){case 38:c.fg=this._updateAttrColor(c.fg,d[1],d[3],d[4],d[5]);break;case 48:c.bg=this._updateAttrColor(c.bg,d[1],d[3],d[4],d[5]);break;case 58:c.extended=c.extended.clone(),c.extended.underlineColor=this._updateAttrColor(c.extended.underlineColor,d[1],d[3],d[4],d[5])}return f}_processUnderline(a,b){b.extended=b.extended.clone(),(!~a||a>5)&&(a=1),b.extended.underlineStyle=a,b.fg|=0x10000000,0===a&&(b.fg&=-0x10000001),b.updateExtended()}_processSGR0(a){a.fg=er.fg,a.bg=er.bg,a.extended=a.extended.clone(),a.extended.underlineStyle=0,a.extended.underlineColor&=-0x4000000,a.updateExtended()}charAttributes(a){if(1===a.length&&0===a.params[0])return this._processSGR0(this._curAttrData),!0;let b=a.length,c,d=this._curAttrData;for(let e=0;e<b;e++)(c=a.params[e])>=30&&c<=37?(d.fg&=-0x3000100,d.fg|=0x1000000|c-30):c>=40&&c<=47?(d.bg&=-0x3000100,d.bg|=0x1000000|c-40):c>=90&&c<=97?(d.fg&=-0x3000100,d.fg|=0x1000000|c-90|8):c>=100&&c<=107?(d.bg&=-0x3000100,d.bg|=0x1000000|c-100|8):0===c?this._processSGR0(d):1===c?d.fg|=0x8000000:3===c?d.bg|=0x4000000:4===c?(d.fg|=0x10000000,this._processUnderline(a.hasSubParams(e)?a.getSubParams(e)[0]:1,d)):5===c?d.fg|=0x20000000:7===c?d.fg|=0x4000000:8===c?d.fg|=0x40000000:9===c?d.fg|=0x80000000:2===c?d.bg|=0x8000000:21===c?this._processUnderline(2,d):22===c?(d.fg&=-0x8000001,d.bg&=-0x8000001):23===c?d.bg&=-0x4000001:24===c?(d.fg&=-0x10000001,this._processUnderline(0,d)):25===c?d.fg&=-0x20000001:27===c?d.fg&=-0x4000001:28===c?d.fg&=-0x40000001:29===c?d.fg&=0x7fffffff:39===c?(d.fg&=-0x4000000,d.fg|=0xffffff&er.fg):49===c?(d.bg&=-0x4000000,d.bg|=0xffffff&er.bg):38===c||48===c||58===c?e+=this._extractColor(a,e,d):53===c?d.bg|=0x40000000:55===c?d.bg&=-0x40000001:59===c?(d.extended=d.extended.clone(),d.extended.underlineColor=-1,d.updateExtended()):100===c?(d.fg&=-0x4000000,d.fg|=0xffffff&er.fg,d.bg&=-0x4000000,d.bg|=0xffffff&er.bg):this._logService.debug("Unknown SGR attribute: %d.",c);return!0}deviceStatus(a){switch(a.params[0]){case 5:this._coreService.triggerDataEvent(`${c1.ESC}[0n`);break;case 6:let b=this._activeBuffer.y+1,c=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c1.ESC}[${b};${c}R`)}return!0}deviceStatusPrivate(a){if(6===a.params[0]){let a=this._activeBuffer.y+1,b=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c1.ESC}[?${a};${b}R`)}return!0}softReset(a){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=er.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(a){let b=0===a.length?1:a.params[0];if(0===b)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(b){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"}this._coreService.decPrivateModes.cursorBlink=b%2==1}return!0}setScrollRegion(a){let b=a.params[0]||1,c;return(a.length<2||(c=a.params[1])>this._bufferService.rows||0===c)&&(c=this._bufferService.rows),c>b&&(this._activeBuffer.scrollTop=b-1,this._activeBuffer.scrollBottom=c-1,this._setCursor(0,0)),!0}windowOptions(a){if(!fd(a.params[0],this._optionsService.rawOptions.windowOptions))return!0;let b=a.length>1?a.params[1]:0;switch(a.params[0]){case 14:2!==b&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c1.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===b||2===b)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===b||1===b)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===b||2===b)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===b||1===b)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(a){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(a){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(a){return this._windowTitle=a,this._onTitleChange.fire(a),!0}setIconName(a){return this._iconName=a,!0}setOrReportIndexedColor(a){let b=[],c=a.split(";");for(;c.length>1;){let a=c.shift(),d=c.shift();if(/^\d+$/.exec(a)){let c=parseInt(a);if(fh(c))if("?"===d)b.push({type:0,index:c});else{let a=fa(d);a&&b.push({type:1,index:c,color:a})}}}return b.length&&this._onColor.fire(b),!0}setHyperlink(a){let b=a.indexOf(";");if(-1===b)return!0;let c=a.slice(0,b).trim(),d=a.slice(b+1);return d?this._createHyperlink(c,d):!c.trim()&&this._finishHyperlink()}_createHyperlink(a,b){this._getCurrentLinkId()&&this._finishHyperlink();let c=a.split(":"),d,e=c.findIndex(a=>a.startsWith("id="));return -1!==e&&(d=c[e].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:d,uri:b}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(a,b){let c=a.split(";");for(let a=0;a<c.length&&!(b>=this._specialColors.length);++a,++b)if("?"===c[a])this._onColor.fire([{type:0,index:this._specialColors[b]}]);else{let d=fa(c[a]);d&&this._onColor.fire([{type:1,index:this._specialColors[b],color:d}])}return!0}setOrReportFgColor(a){return this._setOrReportSpecialColor(a,0)}setOrReportBgColor(a){return this._setOrReportSpecialColor(a,1)}setOrReportCursorColor(a){return this._setOrReportSpecialColor(a,2)}restoreIndexedColor(a){if(!a)return this._onColor.fire([{type:2}]),!0;let b=[],c=a.split(";");for(let a=0;a<c.length;++a)if(/^\d+$/.exec(c[a])){let d=parseInt(c[a]);fh(d)&&b.push({type:2,index:d})}return b.length&&this._onColor.fire(b),!0}restoreFgColor(a){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(a){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(a){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,ex),!0}selectCharset(a){return 2!==a.length?this.selectDefaultCharset():"/"===a[0]||this._charsetService.setgCharset(fc[a[0]],ew[a[1]]||ex),!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 a=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,a,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=er.clone(),this._eraseAttrDataInternal=er.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(a){return this._charsetService.setgLevel(a),!0}screenAlignmentPattern(){let a=new as;a.content=4194373,a.fg=this._curAttrData.fg,a.bg=this._curAttrData.bg,this._setCursor(0,0);for(let b=0;b<this._bufferService.rows;++b){let c=this._activeBuffer.ybase+this._activeBuffer.y+b,d=this._activeBuffer.lines.get(c);d&&(d.fill(a),d.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(a,b){let c=a=>(this._coreService.triggerDataEvent(`${c1.ESC}${a}${c1.ESC}\\`),!0),d=this._bufferService.buffer,e=this._optionsService.rawOptions;return c('"q'===a?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===a?'P1$r61;1"p':"r"===a?`P1$r${d.scrollTop+1};${d.scrollBottom+1}r`:"m"===a?"P1$r0m":" q"===a?`P1$r${({block:2,underline:4,bar:6})[e.cursorStyle]-!!e.cursorBlink} q`:"P0$r")}markRangeDirty(a,b){this._dirtyRowTracker.markRangeDirty(a,b)}},fg=class{constructor(a){this._bufferService=a,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(a){a<this.start?this.start=a:a>this.end&&(this.end=a)}markRangeDirty(a,b){a>b&&(fe=a,a=b,b=fe),a<this.start&&(this.start=a),b>this.end&&(this.end=b)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function fh(a){return 0<=a&&a<256}fg=af([ag(0,ax)],fg);var fi=class extends a2{constructor(a){super(),this._action=a,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new bl),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(a,b){let c;if(void 0!==b&&this._syncCalls>b){this._syncCalls=0;return}if(this._pendingData+=a.length,this._writeBuffer.push(a),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;c=this._writeBuffer.shift();){this._action(c);let a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(a,b){if(this._pendingData>5e7)throw 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+=a.length,this._writeBuffer.push(a),this._callbacks.push(b),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=a.length,this._writeBuffer.push(a),this._callbacks.push(b)}_innerWrite(a=0,b=!0){let c=a||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let a=this._writeBuffer[this._bufferOffset],d=this._action(a,b);if(d){let a=a=>performance.now()-c>=12?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(c,a);d.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(a);return}let e=this._callbacks[this._bufferOffset];if(e&&e(),this._bufferOffset++,this._pendingData-=a.length,performance.now()-c>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},fj=class{constructor(a){this._bufferService=a,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(a){let b=this._bufferService.buffer;if(void 0===a.id){let c=b.addMarker(b.ybase+b.y),d={data:a,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._dataByLinkId.set(d.id,d),d.id}let c=this._getEntryIdKey(a),d=this._entriesWithId.get(c);if(d)return this.addLineToLink(d.id,b.ybase+b.y),d.id;let e=b.addMarker(b.ybase+b.y),f={id:this._nextId++,key:this._getEntryIdKey(a),data:a,lines:[e]};return e.onDispose(()=>this._removeMarkerFromLink(f,e)),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(a,b){let c=this._dataByLinkId.get(a);if(c&&c.lines.every(a=>a.line!==b)){let a=this._bufferService.buffer.addMarker(b);c.lines.push(a),a.onDispose(()=>this._removeMarkerFromLink(c,a))}}getLinkData(a){return this._dataByLinkId.get(a)?.data}_getEntryIdKey(a){return`${a.id};;${a.uri}`}_removeMarkerFromLink(a,b){let c=a.lines.indexOf(b);-1!==c&&(a.lines.splice(c,1),0===a.lines.length&&(void 0!==a.data.id&&this._entriesWithId.delete(a.key),this._dataByLinkId.delete(a.id)))}};fj=af([ag(0,ax)],fj);var fk=!1,fl=class extends a2{constructor(a){super(),this._windowsWrappingHeuristics=this._register(new a3),this._onBinary=this._register(new bl),this.onBinary=this._onBinary.event,this._onData=this._register(new bl),this.onData=this._onData.event,this._onLineFeed=this._register(new bl),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new bl),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new bl),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new bl),this._instantiationService=new en,this.optionsService=this._register(new eD(a)),this._instantiationService.setService(aD,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(eA)),this._instantiationService.setService(ax,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ep)),this._instantiationService.setService(aC,this._logService),this.coreService=this._register(this._instantiationService.createInstance(eH)),this._instantiationService.setService(az,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(eM)),this._instantiationService.setService(ay,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(eW)),this._instantiationService.setService(aF,this.unicodeService),this._charsetService=this._instantiationService.createInstance(eX),this._instantiationService.setService(aA,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(fj),this._instantiationService.setService(aE,this._oscLinkService),this._inputHandler=this._register(new ff(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(be.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(be.forward(this._bufferService.onResize,this._onResize)),this._register(be.forward(this.coreService.onData,this._onData)),this._register(be.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 fi((a,b)=>this._inputHandler.parse(a,b))),this._register(be.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new bl),this._onScroll.event(a=>{this._onScrollApi?.fire(a.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(a){for(let b in a)this.optionsService.options[b]=a[b]}write(a,b){this._writeBuffer.write(a,b)}writeSync(a,b){this._logService.logLevel<=3&&!fk&&(this._logService.warn("writeSync is unreliable and will be removed soon."),fk=!0),this._writeBuffer.writeSync(a,b)}input(a,b=!0){this.coreService.triggerDataEvent(a,b)}resize(a,b){isNaN(a)||isNaN(b)||(a=Math.max(a,2),b=Math.max(b,1),this._bufferService.resize(a,b))}scroll(a,b=!1){this._bufferService.scroll(a,b)}scrollLines(a,b){this._bufferService.scrollLines(a,b)}scrollPages(a){this.scrollLines(a*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(a){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(a){let b=a-this._bufferService.buffer.ydisp;0!==b&&this.scrollLines(b)}registerEscHandler(a,b){return this._inputHandler.registerEscHandler(a,b)}registerDcsHandler(a,b){return this._inputHandler.registerDcsHandler(a,b)}registerCsiHandler(a,b){return this._inputHandler.registerCsiHandler(a,b)}registerOscHandler(a,b){return this._inputHandler.registerOscHandler(a,b)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let a=!1,b=this.optionsService.rawOptions.windowsPty;b&&void 0!==b.buildNumber&&void 0!==b.buildNumber?a="conpty"===b.backend&&b.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(a=!0),a?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let a=[];a.push(this.onLineFeed(eY.bind(null,this._bufferService))),a.push(this.registerCsiHandler({final:"H"},()=>(eY(this._bufferService),!1))),this._windowsWrappingHeuristics.value=a_(()=>{for(let b of a)b.dispose()})}}},fm={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:["'",'"']},fn=0,fo=class{constructor(a){this._getKey=a,this._array=[],this._insertedValues=[],this._flushInsertedTask=new d0,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new d0,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(a){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(a)}_flushInserted(){let a=this._insertedValues.sort((a,b)=>this._getKey(a)-this._getKey(b)),b=0,c=0,d=Array(this._array.length+this._insertedValues.length);for(let e=0;e<d.length;e++)c>=this._array.length||this._getKey(a[b])<=this._getKey(this._array[c])?(d[e]=a[b],b++):d[e]=this._array[c++];this._array=d,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(a){if(this._flushCleanupInserted(),0===this._array.length)return!1;let b=this._getKey(a);if(void 0===b||-1===(fn=this._search(b))||this._getKey(this._array[fn])!==b)return!1;do if(this._array[fn]===a)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(fn),!0;while(++fn<this._array.length&&this._getKey(this._array[fn])===b)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let a=this._deletedIndices.sort((a,b)=>a-b),b=0,c=Array(this._array.length-a.length),d=0;for(let e=0;e<this._array.length;e++)a[b]===e?b++:c[d++]=this._array[e];this._array=c,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(a){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((fn=this._search(a))<0||fn>=this._array.length)&&this._getKey(this._array[fn])===a)do yield this._array[fn];while(++fn<this._array.length&&this._getKey(this._array[fn])===a)}forEachByKey(a,b){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((fn=this._search(a))<0||fn>=this._array.length)&&this._getKey(this._array[fn])===a)do b(this._array[fn]);while(++fn<this._array.length&&this._getKey(this._array[fn])===a)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(a){let b=0,c=this._array.length-1;for(;c>=b;){let d=b+c>>1,e=this._getKey(this._array[d]);if(e>a)c=d-1;else if(e<a)b=d+1;else{for(;d>0&&this._getKey(this._array[d-1])===a;)d--;return d}}return b}},fp=0,fq=0,fr=class extends a2{constructor(){super(),this._decorations=new fo(a=>a?.marker.line),this._onDecorationRegistered=this._register(new bl),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new bl),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(a_(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(a){if(a.marker.isDisposed)return;let b=new fs(a);if(b){let a=b.marker.onDispose(()=>b.dispose()),c=b.onDispose(()=>{c.dispose(),b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),a.dispose())});this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(let a of this._decorations.values())a.dispose();this._decorations.clear()}*getDecorationsAtCell(a,b,c){let d=0,e=0;for(let f of this._decorations.getKeyIterator(b))e=(d=f.options.x??0)+(f.options.width??1),a>=d&&a<e&&(!c||(f.options.layer??"bottom")===c)&&(yield f)}forEachDecorationAtCell(a,b,c,d){this._decorations.forEachByKey(b,b=>{fq=(fp=b.options.x??0)+(b.options.width??1),a>=fp&&a<fq&&(!c||(b.options.layer??"bottom")===c)&&d(b)})}},fs=class extends a1{constructor(a){super(),this.options=a,this.onRenderEmitter=this.add(new bl),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new bl),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=a.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=eP.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=eP.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},ft=class{constructor(a,b=1e3){this._renderCallback=a,this._debounceThresholdMS=b,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(a,b,c){this._rowCount=c,a=void 0!==a?a:0,b=void 0!==b?b:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,a):a,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,b):b;let d=performance.now();if(d-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=d,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=d-this._lastRefreshMs,b=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},b)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let a=Math.max(this._rowStart,0),b=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,b)}},fu=class extends a2{constructor(a,b,c,d){super(),this._terminal=a,this._coreBrowserService=c,this._renderService=d,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let e=this._coreBrowserService.mainDocument;this._accessibilityContainer=e.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=e.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,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=e.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new ft(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
19
+ `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(cp(e,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(a_(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(a){for(let b=0;b<a;b++)this._handleChar(" ")}_handleChar(a){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==a&&(this._charsToAnnounce+=a):this._charsToAnnounce+=a,a===`
20
+ `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=ai)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(a){this._clearLiveRegion(),/\p{Control}/u.test(a)||this._charsToConsume.push(a)}_refreshRows(a,b){this._liveRegionDebouncer.refresh(a,b,this._terminal.rows)}_renderRows(a,b){let c=this._terminal.buffer,d=c.lines.length.toString();for(let e=a;e<=b;e++){let a=c.lines.get(c.ydisp+e),b=[],f=a?.translateToString(!0,void 0,void 0,b)||"",g=(c.ydisp+e+1).toString(),h=this._rowElements[e];h&&(0===f.length?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,b)),h.setAttribute("aria-posinset",g),h.setAttribute("aria-setsize",d),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(a,b){let c,d,e=a.target,f=this._rowElements[0===b?1:this._rowElements.length-2];if(e.getAttribute("aria-posinset")!==(0===b?"1":`${this._terminal.buffer.lines.length}`)&&a.relatedTarget===f){if(0===b?(c=e,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=e,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),0===b){let a=this._createAccessibilityTreeNode();this._rowElements.unshift(a),this._rowContainer.insertAdjacentElement("afterbegin",a)}else{let a=this._createAccessibilityTreeNode();this._rowElements.push(a),this._rowContainer.appendChild(a)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===b?-1:1),this._rowElements[0===b?1:this._rowElements.length-2].focus(),a.preventDefault(),a.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let a=this._coreBrowserService.mainDocument.getSelection();if(!a)return;if(a.isCollapsed){this._rowContainer.contains(a.anchorNode)&&this._terminal.clearSelection();return}if(!a.anchorNode||!a.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:a.anchorNode,offset:a.anchorOffset},c={node:a.focusNode,offset:a.focusOffset};if((b.node.compareDocumentPosition(c.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===c.node&&b.offset>c.offset)&&([b,c]=[c,b]),b.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(b={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(b.node))return;let d=this._rowElements.slice(-1)[0];if(c.node.compareDocumentPosition(d)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(c={node:d,offset:d.textContent?.length??0}),!this._rowContainer.contains(c.node))return;let e=({node:a,offset:b})=>{let c=a instanceof Text?a.parentNode:a,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let e=this._rowColumns.get(c);if(!e)return console.warn("columns is null. Race condition?"),null;let f=b<e.length?e[b]:e.slice(-1)[0]+1;return f>=this._terminal.cols&&(++d,f=0),{row:d,column:f}},f=e(b),g=e(c);if(!(!f||!g)){if(f.row>g.row||f.row===g.row&&f.column>=g.column)throw Error("invalid range");this._terminal.select(f.column,f.row,(g.row-f.row)*this._terminal.cols-f.column+g.column)}}_handleResize(a){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let a=this._rowContainer.children.length;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);for(;this._rowElements.length>a;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let a=this._coreBrowserService.mainDocument.createElement("div");return a.setAttribute("role","listitem"),a.tabIndex=-1,this._refreshRowDimensions(a),a}_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 a=0;a<this._terminal.rows;a++)this._refreshRowDimensions(this._rowElements[a]),this._alignRowWidth(this._rowElements[a])}}_refreshRowDimensions(a){a.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(a){a.style.transform="";let b=a.getBoundingClientRect().width,c=this._rowColumns.get(a)?.slice(-1)?.[0];if(!c)return;let d=c*this._renderService.dimensions.css.cell.width;a.style.transform=`scaleX(${d/b})`}};fu=af([ag(1,aB),ag(2,aJ),ag(3,aL)],fu);var fv=class extends a2{constructor(a,b,c,d,e){super(),this._element=a,this._mouseService=b,this._renderService=c,this._bufferService=d,this._linkProviderService=e,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new bl),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new bl),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(a_(()=>{a$(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(cp(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(cp(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(cp(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(cp(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(a){this._lastMouseEvent=a;let b=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!b)return;this._isMouseOut=!1;let c=a.composedPath();for(let a=0;a<c.length;a++){let b=c[a];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&b.x===this._lastBufferCell.x&&b.y===this._lastBufferCell.y||(this._handleHover(b),this._lastBufferCell=b)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized){this._clearCurrentLink(),this._askForLink(a,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,b){this._activeProviderReplies&&b||(this._activeProviderReplies?.forEach(a=>{a?.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=a.y);let c=!1;for(let[d,e]of this._linkProviderService.linkProviders.entries())b?this._activeProviderReplies?.get(d)&&(c=this._checkLinkProviderResult(d,a,c)):e.provideLinks(a.y,b=>{if(this._isMouseOut)return;let e=b?.map(a=>({link:a}));this._activeProviderReplies?.set(d,e),c=this._checkLinkProviderResult(d,a,c),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)})}_removeIntersectingLinks(a,b){let c=new Set;for(let d=0;d<b.size;d++){let e=b.get(d);if(e)for(let b=0;b<e.length;b++){let d=e[b],f=d.link.range.start.y<a?0:d.link.range.start.x,g=d.link.range.end.y>a?this._bufferService.cols:d.link.range.end.x;for(let a=f;a<=g;a++){if(c.has(a)){e.splice(b--,1);break}c.add(a)}}}}_checkLinkProviderResult(a,b,c){if(!this._activeProviderReplies)return c;let d=this._activeProviderReplies.get(a),e=!1;for(let b=0;b<a;b++)(!this._activeProviderReplies.has(b)||this._activeProviderReplies.get(b))&&(e=!0);if(!e&&d){let a=d.find(a=>this._linkAtPosition(a.link,b));a&&(c=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!c)for(let a=0;a<this._activeProviderReplies.size;a++){let d=this._activeProviderReplies.get(a)?.find(a=>this._linkAtPosition(a.link,b));if(d){c=!0,this._handleNewLink(d);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){var b,c;if(!this._currentLink)return;let d=this._positionFromMouseEvent(a,this._element,this._mouseService);d&&this._mouseDownLink&&(b=this._mouseDownLink.link,c=this._currentLink.link,b.text===c.text&&b.range.start.x===c.range.start.x&&b.range.start.y===c.range.start.y&&b.range.end.x===c.range.end.x&&b.range.end.y===c.range.end.y)&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,b){this._currentLink&&this._lastMouseEvent&&(!a||!b||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=b)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,a$(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(a){if(!this._lastMouseEvent)return;let b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._linkAtPosition(a.link,b)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:void 0===a.link.decorations||a.link.decorations.underline,pointerCursor:void 0===a.link.decorations||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:a=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==a&&(this._currentLink.state.decorations.pointerCursor=a,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",a))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:b=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==b&&(this._currentLink.state.decorations.underline=b,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,b))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(a=>{if(!this._currentLink)return;let b=0===a.start?0:a.start+1+this._bufferService.buffer.ydisp,c=this._bufferService.buffer.ydisp+1+a.end;if(this._currentLink.link.range.start.y>=b&&this._currentLink.link.range.end.y<=c&&(this._clearCurrentLink(b,c),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(a,b,c){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),b.hover&&b.hover(c,b.text)}_fireUnderlineEvent(a,b){let c=a.range,d=this._bufferService.buffer.ydisp,e=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-d-1,c.end.x,c.end.y-d-1,void 0);(b?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(e)}_linkLeave(a,b,c){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),b.leave&&b.leave(c,b.text)}_linkAtPosition(a,b){let c=a.range.start.y*this._bufferService.cols+a.range.start.x,d=a.range.end.y*this._bufferService.cols+a.range.end.x,e=b.y*this._bufferService.cols+b.x;return c<=e&&e<=d}_positionFromMouseEvent(a,b,c){let d=c.getCoords(a,b,this._bufferService.cols,this._bufferService.rows);if(d)return{x:d[0],y:d[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,b,c,d,e){return{x1:a,y1:b,x2:c,y2:d,cols:this._bufferService.cols,fg:e}}};fv=af([ag(1,aK),ag(2,aL),ag(3,ax),ag(4,aP)],fv);var fw=class extends fl{constructor(a={}){super(a),this._linkifier=this._register(new a3),this.browser=dJ,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new a3),this._onCursorMove=this._register(new bl),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new bl),this.onKey=this._onKey.event,this._onRender=this._register(new bl),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new bl),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new bl),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new bl),this.onBell=this._onBell.event,this._onFocus=this._register(new bl),this._onBlur=this._register(new bl),this._onA11yCharEmitter=this._register(new bl),this._onA11yTabEmitter=this._register(new bl),this._onWillOpen=this._register(new bl),this._setup(),this._decorationService=this._instantiationService.createInstance(fr),this._instantiationService.setService(aG,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(dF),this._instantiationService.setService(aP,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(aH)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(a=>this.refresh(a?.start??0,a?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(a=>this._reportWindowsOptions(a))),this._register(this._inputHandler.onColor(a=>this._handleColorEvent(a))),this._register(be.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(be.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(be.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(be.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(a=>this._afterResize(a.cols,a.rows))),this._register(a_(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.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(a){if(this._themeService)for(let b of a){let a,c="";switch(b.index){case 256:a="foreground",c="10";break;case 257:a="background",c="11";break;case 258:a="cursor",c="12";break;default:a="ansi",c="4;"+b.index}switch(b.type){case 0:let d=eO.toColorRGB("ansi"===a?this._themeService.colors.ansi[b.index]:this._themeService.colors[a]);this.coreService.triggerDataEvent(`${c1.ESC}]${c};${function(a,b=16){let[c,d,e]=a;return`rgb:${fb(c,b)}/${fb(d,b)}/${fb(e,b)}`}(d)}${c3.ST}`);break;case 1:if("ansi"===a)this._themeService.modifyColors(a=>a.ansi[b.index]=c4.toColor(...b.color));else{let c=a;this._themeService.modifyColors(a=>a[c]=c4.toColor(...b.color))}break;case 2:this._themeService.restoreColor(b.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(a){a?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(fu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(a){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(c1.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(c1.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let a=this.buffer.ybase+this.buffer.y,b=this.buffer.lines.get(a);if(!b)return;let c=Math.min(this.buffer.x,this.cols-1),d=this._renderService.dimensions.css.cell.height,e=b.getWidth(c),f=this._renderService.dimensions.css.cell.width*e,g=this.buffer.y*this._renderService.dimensions.css.cell.height,h=c*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=g+"px",this.textarea.style.width=f+"px",this.textarea.style.height=d+"px",this.textarea.style.lineHeight=d+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(cp(this.element,"copy",a=>{var b;this.hasSelection()&&(b=this._selectionService,a.clipboardData&&a.clipboardData.setData("text/plain",b.selectionText),a.preventDefault())}));let a=a=>{var b,c,d;return b=this.textarea,c=this.coreService,d=this.optionsService,void(a.stopPropagation(),a.clipboardData&&aj(a.clipboardData.getData("text/plain"),b,c,d))};this._register(cp(this.textarea,"paste",a)),this._register(cp(this.element,"paste",a)),dP?this._register(cp(this.element,"mousedown",a=>{2===a.button&&al(a,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(cp(this.element,"contextmenu",a=>{al(a,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),dX&&this._register(cp(this.element,"auxclick",a=>{1===a.button&&ak(a,this.textarea,this.screenElement)}))}_bindKeys(){this._register(cp(this.textarea,"keyup",a=>this._keyUp(a),!0)),this._register(cp(this.textarea,"keydown",a=>this._keyDown(a),!0)),this._register(cp(this.textarea,"keypress",a=>this._keyPress(a),!0)),this._register(cp(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(cp(this.textarea,"compositionupdate",a=>this._compositionHelper.compositionupdate(a))),this._register(cp(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(cp(this.textarea,"input",a=>this._inputEvent(a),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(a){if(!a)throw Error("Terminal requires a parent element.");if(a.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=a.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"),a.appendChild(this.element);let b=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),b.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(cp(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),b.appendChild(this.screenElement);let c=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ah),dY||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",()=>c.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(dD,this.textarea,a.ownerDocument.defaultView??window,this._document?window.document:null)),this._instantiationService.setService(aJ,this._coreBrowserService),this._register(cp(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(cp(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(dz,this._document,this._helperContainer),this._instantiationService.setService(aI,this._charSizeService),this._themeService=this._instantiationService.createInstance(ek),this._instantiationService.setService(aO,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(dk),this._instantiationService.setService(aN,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(d2,this.rows,this.screenElement)),this._instantiationService.setService(aL,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(cX,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(dH),this._instantiationService.setService(aK,this._mouseService);let d=this._linkifier.value=this._register(this._instantiationService.createInstance(fv,this.screenElement));this.element.appendChild(b);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(cQ,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ec,this.element,this.screenElement,d)),this._instantiationService.setService(aM,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(be.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(cR,this.screenElement)),this._register(cp(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),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(fu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cW,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cW,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(dy,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let a=this,b=this.element;function c(b){let c,d,e=a._mouseService.getMouseReportCoords(b,a.screenElement);if(!e)return!1;switch(b.overrideType||b.type){case"mousemove":d=32,void 0===b.buttons?(c=3,void 0!==b.button&&(c=b.button<3?b.button:3)):c=1&b.buttons?0:4&b.buttons?1:2&b.buttons?2:3;break;case"mouseup":d=0,c=b.button<3?b.button:3;break;case"mousedown":d=1,c=b.button<3?b.button:3;break;case"wheel":if(a._customWheelEventHandler&&!1===a._customWheelEventHandler(b))return!1;let f=b.deltaY;if(0===f||0===a.coreMouseService.consumeWheelEvent(b,a._renderService?.dimensions?.device?.cell?.height,a._coreBrowserService?.dpr))return!1;d=f<0?0:1,c=4;break;default:return!1}return void 0!==d&&void 0!==c&&!(c>4)&&a.coreMouseService.triggerMouseEvent({col:e.col,row:e.row,x:e.x,y:e.y,button:c,action:d,ctrl:b.ctrlKey,alt:b.altKey,shift:b.shiftKey})}let d={mouseup:null,wheel:null,mousedrag:null,mousemove:null},e=a=>(c(a),a.buttons||(this._document.removeEventListener("mouseup",d.mouseup),d.mousedrag&&this._document.removeEventListener("mousemove",d.mousedrag)),this.cancel(a)),f=a=>(c(a),this.cancel(a,!0)),g=a=>{a.buttons&&c(a)},h=a=>{a.buttons||c(a)};this._register(this.coreMouseService.onProtocolChange(a=>{a?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&a?d.mousemove||(b.addEventListener("mousemove",h),d.mousemove=h):(b.removeEventListener("mousemove",d.mousemove),d.mousemove=null),16&a?d.wheel||(b.addEventListener("wheel",f,{passive:!1}),d.wheel=f):(b.removeEventListener("wheel",d.wheel),d.wheel=null),2&a?d.mouseup||(d.mouseup=e):(this._document.removeEventListener("mouseup",d.mouseup),d.mouseup=null),4&a?d.mousedrag||(d.mousedrag=g):(this._document.removeEventListener("mousemove",d.mousedrag),d.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(cp(b,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return c(a),d.mouseup&&this._document.addEventListener("mouseup",d.mouseup),d.mousedrag&&this._document.addEventListener("mousemove",d.mousedrag),this.cancel(a)})),this._register(cp(b,"wheel",b=>{if(!d.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(b))return!1;if(!this.buffer.hasScrollback){if(0===b.deltaY)return!1;if(0===a.coreMouseService.consumeWheelEvent(b,a._renderService?.dimensions?.device?.cell?.height,a._coreBrowserService?.dpr))return this.cancel(b,!0);let c=c1.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(b.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(c,!0),this.cancel(b,!0)}}},{passive:!1}))}refresh(a,b){this._renderService?.refreshRows(a,b)}updateCursorStyle(a){this._selectionService?.shouldColumnSelect(a)?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(a,b){this._viewport?this._viewport.scrollLines(a):super.scrollLines(a,b),this.refresh(0,this.rows-1)}scrollPages(a){this.scrollLines(a*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(a){a&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(a){let b=a-this._bufferService.buffer.ydisp;0!==b&&this.scrollLines(b)}paste(a){aj(a,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(a){this._customKeyEventHandler=a}attachCustomWheelEventHandler(a){this._customWheelEventHandler=a}registerLinkProvider(a){return this._linkProviderService.registerLinkProvider(a)}registerCharacterJoiner(a){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let b=this._characterJoinerService.register(a);return this.refresh(0,this.rows-1),b}deregisterCharacterJoiner(a){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(a)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(a){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+a)}registerDecoration(a){return this._decorationService.registerDecoration(a)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(a,b,c){this._selectionService.setSelection(a,b,c)}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(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(a,b){this._selectionService?.selectLines(a,b)}_keyDown(a){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(a))return!1;let b=this.browser.isMac&&this.options.macOptionIsMeta&&a.altKey;if(!b&&!this._compositionHelper.keydown(a))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;b||"Dead"!==a.key&&"AltGraph"!==a.key||(this._unprocessedDeadKey=!0);let c=function(a,b,c,d){let e={type:0,cancel:!1,key:void 0},f=!!a.shiftKey|2*!!a.altKey|4*!!a.ctrlKey|8*!!a.metaKey;switch(a.keyCode){case 0:"UIKeyInputUpArrow"===a.key?b?e.key=c1.ESC+"OA":e.key=c1.ESC+"[A":"UIKeyInputLeftArrow"===a.key?b?e.key=c1.ESC+"OD":e.key=c1.ESC+"[D":"UIKeyInputRightArrow"===a.key?b?e.key=c1.ESC+"OC":e.key=c1.ESC+"[C":"UIKeyInputDownArrow"===a.key&&(b?e.key=c1.ESC+"OB":e.key=c1.ESC+"[B");break;case 8:e.key=a.ctrlKey?"\b":c1.DEL,a.altKey&&(e.key=c1.ESC+e.key);break;case 9:if(a.shiftKey){e.key=c1.ESC+"[Z";break}e.key=c1.HT,e.cancel=!0;break;case 13:e.key=a.altKey?c1.ESC+c1.CR:c1.CR,e.cancel=!0;break;case 27:e.key=c1.ESC,a.altKey&&(e.key=c1.ESC+c1.ESC),e.cancel=!0;break;case 37:if(a.metaKey)break;f?e.key=c1.ESC+"[1;"+(f+1)+"D":b?e.key=c1.ESC+"OD":e.key=c1.ESC+"[D";break;case 39:if(a.metaKey)break;f?e.key=c1.ESC+"[1;"+(f+1)+"C":b?e.key=c1.ESC+"OC":e.key=c1.ESC+"[C";break;case 38:if(a.metaKey)break;f?e.key=c1.ESC+"[1;"+(f+1)+"A":b?e.key=c1.ESC+"OA":e.key=c1.ESC+"[A";break;case 40:if(a.metaKey)break;f?e.key=c1.ESC+"[1;"+(f+1)+"B":b?e.key=c1.ESC+"OB":e.key=c1.ESC+"[B";break;case 45:a.shiftKey||a.ctrlKey||(e.key=c1.ESC+"[2~");break;case 46:f?e.key=c1.ESC+"[3;"+(f+1)+"~":e.key=c1.ESC+"[3~";break;case 36:f?e.key=c1.ESC+"[1;"+(f+1)+"H":b?e.key=c1.ESC+"OH":e.key=c1.ESC+"[H";break;case 35:f?e.key=c1.ESC+"[1;"+(f+1)+"F":b?e.key=c1.ESC+"OF":e.key=c1.ESC+"[F";break;case 33:a.shiftKey?e.type=2:a.ctrlKey?e.key=c1.ESC+"[5;"+(f+1)+"~":e.key=c1.ESC+"[5~";break;case 34:a.shiftKey?e.type=3:a.ctrlKey?e.key=c1.ESC+"[6;"+(f+1)+"~":e.key=c1.ESC+"[6~";break;case 112:f?e.key=c1.ESC+"[1;"+(f+1)+"P":e.key=c1.ESC+"OP";break;case 113:f?e.key=c1.ESC+"[1;"+(f+1)+"Q":e.key=c1.ESC+"OQ";break;case 114:f?e.key=c1.ESC+"[1;"+(f+1)+"R":e.key=c1.ESC+"OR";break;case 115:f?e.key=c1.ESC+"[1;"+(f+1)+"S":e.key=c1.ESC+"OS";break;case 116:f?e.key=c1.ESC+"[15;"+(f+1)+"~":e.key=c1.ESC+"[15~";break;case 117:f?e.key=c1.ESC+"[17;"+(f+1)+"~":e.key=c1.ESC+"[17~";break;case 118:f?e.key=c1.ESC+"[18;"+(f+1)+"~":e.key=c1.ESC+"[18~";break;case 119:f?e.key=c1.ESC+"[19;"+(f+1)+"~":e.key=c1.ESC+"[19~";break;case 120:f?e.key=c1.ESC+"[20;"+(f+1)+"~":e.key=c1.ESC+"[20~";break;case 121:f?e.key=c1.ESC+"[21;"+(f+1)+"~":e.key=c1.ESC+"[21~";break;case 122:f?e.key=c1.ESC+"[23;"+(f+1)+"~":e.key=c1.ESC+"[23~";break;case 123:f?e.key=c1.ESC+"[24;"+(f+1)+"~":e.key=c1.ESC+"[24~";break;default:if(!a.ctrlKey||a.shiftKey||a.altKey||a.metaKey)if((!c||d)&&a.altKey&&!a.metaKey){let b=fm[a.keyCode]?.[+!!a.shiftKey];if(b)e.key=c1.ESC+b;else if(a.keyCode>=65&&a.keyCode<=90){let b=String.fromCharCode(a.ctrlKey?a.keyCode-64:a.keyCode+32);a.shiftKey&&(b=b.toUpperCase()),e.key=c1.ESC+b}else if(32===a.keyCode)e.key=c1.ESC+(a.ctrlKey?c1.NUL:" ");else if("Dead"===a.key&&a.code.startsWith("Key")){let b=a.code.slice(3,4);a.shiftKey||(b=b.toLowerCase()),e.key=c1.ESC+b,e.cancel=!0}}else!c||a.altKey||a.ctrlKey||a.shiftKey||!a.metaKey?!a.key||a.ctrlKey||a.altKey||a.metaKey||!(a.keyCode>=48)||1!==a.key.length?a.key&&a.ctrlKey&&("_"===a.key&&(e.key=c1.US),"@"===a.key&&(e.key=c1.NUL)):e.key=a.key:65===a.keyCode&&(e.type=1);else a.keyCode>=65&&a.keyCode<=90?e.key=String.fromCharCode(a.keyCode-64):32===a.keyCode?e.key=c1.NUL:a.keyCode>=51&&a.keyCode<=55?e.key=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?e.key=c1.DEL:219===a.keyCode?e.key=c1.ESC:220===a.keyCode?e.key=c1.FS:221===a.keyCode&&(e.key=c1.GS)}return e}(a,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(a),3===c.type||2===c.type){let b=this.rows-1;return this.scrollLines(2===c.type?-b:b),this.cancel(a,!0)}return 1===c.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,a)||(c.cancel&&this.cancel(a,!0),!c.key)||a.key&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&1===a.key.length&&a.key.charCodeAt(0)>=65&&90>=a.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((c.key===c1.ETX||c.key===c1.CR)&&(this.textarea.value=""),this._onKey.fire({key:c.key,domEvent:a}),this._showCursor(),this.coreService.triggerDataEvent(c.key,!0),!this.optionsService.rawOptions.screenReaderMode||a.altKey||a.ctrlKey)?this.cancel(a,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(a,b){let c=a.isMac&&!this.options.macOptionIsMeta&&b.altKey&&!b.ctrlKey&&!b.metaKey||a.isWindows&&b.altKey&&b.ctrlKey&&!b.metaKey||a.isWindows&&b.getModifierState("AltGraph");return"keypress"===b.type?c:c&&(!b.keyCode||b.keyCode>47)}_keyUp(a){var b;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(a)||(16===(b=a).keyCode||17===b.keyCode||18===b.keyCode||this.focus(),this.updateCursorStyle(a),this._keyPressHandled=!1)}_keyPress(a){let b;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(a))return!1;if(this.cancel(a),a.charCode)b=a.charCode;else if(null===a.which||void 0===a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!!b&&(!a.altKey&&!a.ctrlKey&&!a.metaKey||!!this._isThirdLevelShift(this.browser,a))&&(b=String.fromCharCode(b),this._onKey.fire({key:b,domEvent:a}),this._showCursor(),this.coreService.triggerDataEvent(b,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(a){if(a.data&&"insertText"===a.inputType&&(!a.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let b=a.data;return this.coreService.triggerDataEvent(b,!0),this.cancel(a),!0}return!1}resize(a,b){if(a===this.cols&&b===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(a,b)}_afterResize(a,b){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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 a=1;a<this.rows;a++)this.buffer.lines.push(this.buffer.getBlankLine(er));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let a=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=a,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(c1.ESC+"[I"):this.coreService.triggerDataEvent(c1.ESC+"[O")}_reportWindowsOptions(a){if(this._renderService)switch(a){case 0:let b=this._renderService.dimensions.css.canvas.width.toFixed(0),c=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${c1.ESC}[4;${c};${b}t`);break;case 1:let d=this._renderService.dimensions.css.cell.width.toFixed(0),e=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${c1.ESC}[6;${e};${d}t`)}}cancel(a,b){if(!(!this.options.cancelEvents&&!b))return a.preventDefault(),a.stopPropagation(),!1}},fx=class{constructor(){this._addons=[]}dispose(){for(let a=this._addons.length-1;a>=0;a--)this._addons[a].instance.dispose()}loadAddon(a,b){let c={instance:b,dispose:b.dispose,isDisposed:!1};this._addons.push(c),b.dispose=()=>this._wrappedAddonDispose(c),b.activate(a)}_wrappedAddonDispose(a){if(a.isDisposed)return;let b=-1;for(let c=0;c<this._addons.length;c++)if(this._addons[c]===a){b=c;break}if(-1===b)throw Error("Could not dispose an addon that has not been loaded");a.isDisposed=!0,a.dispose.apply(a.instance),this._addons.splice(b,1)}},fy=class{constructor(a){this._line=a}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(a,b){if(!(a<0||a>=this._line.length))return b?(this._line.loadCell(a,b),b):this._line.loadCell(a,new as)}translateToString(a,b,c){return this._line.translateToString(a,b,c)}},fz=class{constructor(a,b){this._buffer=a,this.type=b}init(a){return this._buffer=a,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(a){let b=this._buffer.lines.get(a);if(b)return new fy(b)}getNullCell(){return new as}},fA=class extends a2{constructor(a){super(),this._core=a,this._onBufferChange=this._register(new bl),this.onBufferChange=this._onBufferChange.event,this._normal=new fz(this._core.buffers.normal,"normal"),this._alternate=new fz(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 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)}},fB=class{constructor(a){this._core=a}registerCsiHandler(a,b){return this._core.registerCsiHandler(a,a=>b(a.toArray()))}addCsiHandler(a,b){return this.registerCsiHandler(a,b)}registerDcsHandler(a,b){return this._core.registerDcsHandler(a,(a,c)=>b(a,c.toArray()))}addDcsHandler(a,b){return this.registerDcsHandler(a,b)}registerEscHandler(a,b){return this._core.registerEscHandler(a,b)}addEscHandler(a,b){return this.registerEscHandler(a,b)}registerOscHandler(a,b){return this._core.registerOscHandler(a,b)}addOscHandler(a,b){return this.registerOscHandler(a,b)}},fC=class{constructor(a){this._core=a}register(a){this._core.unicodeService.register(a)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(a){this._core.unicodeService.activeVersion=a}},fD=["cols","rows"],fE=0,fF=class extends a2{constructor(a){super(),this._core=this._register(new fw(a)),this._addonManager=this._register(new fx),this._publicOptions={...this._core.options};let b=a=>this._core.options[a],c=(a,b)=>{this._checkReadonlyOptions(a),this._core.options[a]=b};for(let a in this._core.options){let d={get:b.bind(this,a),set:c.bind(this,a)};Object.defineProperty(this._publicOptions,a,d)}}_checkReadonlyOptions(a){if(fD.includes(a))throw Error(`Option "${a}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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 fB(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new fC(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 fA(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let a=this._core.coreService.decPrivateModes,b="none";switch(this._core.coreMouseService.activeProtocol){case"X10":b="x10";break;case"VT200":b="vt200";break;case"DRAG":b="drag";break;case"ANY":b="any"}return{applicationCursorKeysMode:a.applicationCursorKeys,applicationKeypadMode:a.applicationKeypad,bracketedPasteMode:a.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:b,originMode:a.origin,reverseWraparoundMode:a.reverseWraparound,sendFocusMode:a.sendFocus,synchronizedOutputMode:a.synchronizedOutput,wraparoundMode:a.wraparound}}get options(){return this._publicOptions}set options(a){for(let b in a)this._publicOptions[b]=a[b]}blur(){this._core.blur()}focus(){this._core.focus()}input(a,b=!0){this._core.input(a,b)}resize(a,b){this._verifyIntegers(a,b),this._core.resize(a,b)}open(a){this._core.open(a)}attachCustomKeyEventHandler(a){this._core.attachCustomKeyEventHandler(a)}attachCustomWheelEventHandler(a){this._core.attachCustomWheelEventHandler(a)}registerLinkProvider(a){return this._core.registerLinkProvider(a)}registerCharacterJoiner(a){return this._checkProposedApi(),this._core.registerCharacterJoiner(a)}deregisterCharacterJoiner(a){this._checkProposedApi(),this._core.deregisterCharacterJoiner(a)}registerMarker(a=0){return this._verifyIntegers(a),this._core.registerMarker(a)}registerDecoration(a){return this._checkProposedApi(),this._verifyPositiveIntegers(a.x??0,a.width??0,a.height??0),this._core.registerDecoration(a)}hasSelection(){return this._core.hasSelection()}select(a,b,c){this._verifyIntegers(a,b,c),this._core.select(a,b,c)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(a,b){this._verifyIntegers(a,b),this._core.selectLines(a,b)}dispose(){super.dispose()}scrollLines(a){this._verifyIntegers(a),this._core.scrollLines(a)}scrollPages(a){this._verifyIntegers(a),this._core.scrollPages(a)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(a){this._verifyIntegers(a),this._core.scrollToLine(a)}clear(){this._core.clear()}write(a,b){this._core.write(a,b)}writeln(a,b){this._core.write(a),this._core.write(`\r
21
+ `,b)}paste(a){this._core.paste(a)}refresh(a,b){this._verifyIntegers(a,b),this._core.refresh(a,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(a){this._addonManager.loadAddon(this,a)}static get strings(){return{get promptLabel(){return ah},set promptLabel(t){ah=t},get tooMuchOutput(){return ai},set tooMuchOutput(t){ai=t}}}_verifyIntegers(...a){for(fE of a)if(fE===1/0||isNaN(fE)||fE%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...a){for(fE of a)if(fE&&(fE===1/0||isNaN(fE)||fE%1!=0||fE<0))throw Error("This API only accepts positive integers")}},fG=class{activate(a){this._terminal=a}dispose(){}fit(){let a=this.proposeDimensions();if(!a||!this._terminal||isNaN(a.cols)||isNaN(a.rows))return;let b=this._terminal._core;(this._terminal.rows!==a.rows||this._terminal.cols!==a.cols)&&(b._renderService.clear(),this._terminal.resize(a.cols,a.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let a=this._terminal._core._renderService.dimensions;if(0===a.css.cell.width||0===a.css.cell.height)return;let b=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,c=window.getComputedStyle(this._terminal.element.parentElement),d=parseInt(c.getPropertyValue("height")),e=Math.max(0,parseInt(c.getPropertyValue("width"))),f=window.getComputedStyle(this._terminal.element),g={top:parseInt(f.getPropertyValue("padding-top")),bottom:parseInt(f.getPropertyValue("padding-bottom")),right:parseInt(f.getPropertyValue("padding-right")),left:parseInt(f.getPropertyValue("padding-left"))},h=g.top+g.bottom;return{cols:Math.max(2,Math.floor((e-(g.right+g.left)-b)/a.css.cell.width)),rows:Math.max(1,Math.floor((d-h)/a.css.cell.height))}}},fH=a.i(83915),fI=a.i(80087),fJ=a.i(5151),fK=a.i(25015),fL=a.i(33441);let fM=(0,v.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);var fN=a.i(53155);let fO=(0,v.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),fP=(0,v.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var fQ=a.i(67511),fQ=fQ,fR=a.i(65004),fS=a.i(65025),fT=a.i(92005),fU=a.i(760);let fV={pending:{icon:fP,className:"text-muted-foreground",label:"Pending"},in_progress:{icon:J.Loader2,className:"text-primary animate-spin",label:"In progress"},completed:{icon:fQ.default,className:"text-success",label:"Completed"},blocked:{icon:fO,className:"text-warning",label:"Blocked"}};function fW({todos:a,className:b}){let c=(0,fT.computeTodoProgress)(a);return 0===c.total?null:(0,q.jsxs)(fR.Popover,{children:[(0,q.jsxs)(fR.PopoverTrigger,{className:(0,fU.cn)("flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 transition-colors hover:bg-accent cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",b),title:"Show tasks",children:[c.current&&(0,q.jsx)("span",{className:"min-w-0 max-w-48 truncate text-[10px] text-muted-foreground",children:c.current}),(0,q.jsx)(fS.Progress,{value:c.completed,max:c.total,className:"w-16 shrink-0 gap-0 [&_[data-slot=progress-track]]:h-[3px]"}),(0,q.jsxs)("span",{className:"shrink-0 text-[10px] text-muted-foreground tabular-nums",children:[c.completed,"/",c.total]})]}),(0,q.jsx)(fR.PopoverContent,{align:"end",className:"w-80 gap-1 p-2",children:(0,q.jsx)("ul",{className:"max-h-80 space-y-0.5 overflow-y-auto",children:c.items.map((a,b)=>{let{icon:c,className:d,label:e}=fV[a.displayStatus];return(0,q.jsxs)("li",{className:"flex items-start gap-2 rounded-sm px-1 py-1",children:[(0,q.jsx)(c,{className:(0,fU.cn)("mt-0.5 size-3.5 shrink-0",d),"aria-label":e}),(0,q.jsx)("span",{className:(0,fU.cn)("min-w-0 break-words text-xs","completed"===a.displayStatus&&"text-muted-foreground line-through"),children:"in_progress"===a.status&&a.activeForm?a.activeForm:a.content})]},a.id??b)})})})]})}let fX=(0,r.forwardRef)(function({tabId:a,cwd:b,env:c,launchClaude:d=!1,className:e="",initialTodos:f,initialClaudeStatus:g,isActive:h,onTodosUpdated:i,onStatusChange:j},k){let l=(0,r.useRef)(null),m=(0,r.useRef)(null),n=(0,r.useRef)(null),o=(0,r.useRef)(null),p=(0,r.useRef)(a),[s,u]=(0,r.useState)(!1),v=(0,r.useRef)(!1),w=(0,r.useRef)(h),x=(0,r.useRef)("idle"),y=(0,r.useRef)(!1),z=(0,r.useRef)(!1),A=(0,r.useRef)(null),B=(0,r.useRef)(null),D=(0,r.useRef)(null),E=(0,r.useRef)(0),[F,G]=(0,r.useState)("idle"),[H,I]=(0,r.useState)(null),[K,L]=(0,r.useState)(g??"idle"),M=(0,r.useRef)(g??"idle"),[N,O]=(0,r.useState)(f??[]),[P,Q]=(0,r.useState)(!1),{effectiveTheme:S}=(0,fI.useTheme)(),T=(0,r.useRef)(j);T.current=j;let U="dark"===S,V=U?{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"}:{background:"#ffffff",foreground:"#1e1e1e",cursor:"#1e1e1e",selectionBackground:"#add6ff"};async function W(a){try{await fetch((0,C.apiUrl)(`/api/internal/tabs/${a}/interrupt`),{method:"POST"})}catch(a){console.warn("[TerminalView] Failed to notify interrupt:",a)}}function X(){let a=o.current,b=m.current,c=p.current;a&&a.connected&&b&&c&&a.emit("resize",{sessionId:c,cols:b.cols,rows:b.rows})}function Y(a){a.write("\x1b[2J\x1b[3J\x1b[H")}async function Z(e,f,g){G("connecting"),I(null);try{var h,j,k,l;let q,r,s=await fetch((0,C.apiUrl)("/api/terminal/sessions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,env:c,sessionId:e,claude:d}),signal:g});if(!s.ok){let a,b=await s.text().catch(()=>"");try{a=JSON.parse(b).error}catch{}throw a&&I(a),Error(`Failed to create session: ${s.status} ${b}`)}let u=await s.json();if(g.aborted)return;p.current=u.sessionId,u.reused||Y(f),h=u.sessionId,j=u.reused,k=f,l=g,A.current?.dispose(),A.current=null,o.current&&(o.current.removeAllListeners(),o.current.disconnect()),o.current=q=(0,fH.io)((0,C.getServerUrl)(),{transports:["polling","websocket"]}),r=!1,q.on("connect",()=>{let a=y.current;y.current=!0,a?k.writeln("\x1b[90mReconnected.\x1b[0m"):j?(z.current=!0,Y(k)):k.writeln("\x1b[90mConnected.\x1b[0m"),G("connected"),E.current=0,q.emit("join",{room:`tab:${h}`,mode:"terminal"}),a&&w.current&&k.focus()}),q.on("output",({data:a})=>{j&&!r?(r=!0,k.write(a,()=>{z.current=!1,n.current?.fit();let a=m.current;if(a){let b=64===a.cols?63:64;a.resize(b,a.rows),X(),setTimeout(()=>{n.current?.fit(),X()},50)}k.scrollToBottom()})):k.write(a)}),q.on("exit",({exitCode:a})=>{console.log("[TerminalView] PTY exited with code:",a),G("exited"),p.current=null,o.current=null}),q.on("error",({message:a})=>{if(console.error("[TerminalView] Socket error message:",a),a.startsWith("Session not found")&&E.current<1){E.current+=1,$();return}G("error")}),q.on("disconnect",()=>{l.aborted||G(a=>"exited"===a||"paused"===a||"idle"===a?a:"exited")}),q.on("status-changed",({status:a})=>{L(a)}),q.on("todos-updated",({todos:b})=>{O(b),i?.(a,b)}),q.on("editor:open",({sessionId:a,content:b})=>{window.dispatchEvent(new CustomEvent("editor-session-open-request",{detail:{sessionId:a,content:b}}))}),A.current=k.onData(a=>{"\x1b"===a&&("running"===M.current||"waiting"===M.current)&&p.current&&W(p.current),q.connected&&p.current&&q.emit("input",{sessionId:p.current,data:a})})}catch(a){if(a instanceof Error&&"AbortError"===a.name)return;console.error("[TerminalView] connectSession error:",a instanceof Error?a.message:String(a)),G("error")}}async function $(){let b=m.current;if(!b)return;let c=new AbortController;await Z(a,b,c.signal)}(0,r.useEffect)(()=>{T.current?.(a,F,K)},[a,F,K]),(0,r.useLayoutEffect)(()=>{w.current=h}),(0,r.useLayoutEffect)(()=>{x.current=F}),(0,r.useLayoutEffect)(()=>{M.current=K}),(0,r.useEffect)(()=>{h&&m.current?.focus()},[h]),(0,r.useEffect)(()=>{if(s)m.current?.blur();else if(h){let a=l.current?.querySelector("textarea.xterm-helper-textarea");a?.focus()}},[s,h]),(0,r.useEffect)(()=>{"connected"===F&&n.current&&(n.current.fit(),z.current||X())},[F]),(0,r.useEffect)(()=>{if(!l.current)return;let b=l.current,c=new fF({cursorBlink:!0,fontSize:13,fontFamily:'"Cascadia Code", "Fira Code", "Menlo", monospace',theme:V,allowProposedApi:!0}),d=new fG;c.loadAddon(d),c.open(l.current),d.fit(),m.current=c,n.current=d,w.current&&c.focus(),c.attachCustomKeyEventHandler(()=>!v.current),c.buffer.onBufferChange(a=>{"normal"===a.type&&c.refresh(0,c.rows-1)});let e=0,f=a=>{let b=performance.now();""===a.data&&b-e<100?a.stopImmediatePropagation():e=b};b.addEventListener("compositionend",f,!0);let g=null,h=0,i=a=>{if(1!==a.touches.length){g=null;return}g=a.touches[0].clientY,h=c.buffer.active.viewportY},j=a=>{if(null===g||1!==a.touches.length)return;let d=b.clientHeight/c.rows;if(d<=0)return;let e=(g-a.touches[0].clientY)/d;c.scrollToLine(Math.round(h+e))};b.addEventListener("touchstart",i,{passive:!0}),b.addEventListener("touchmove",j,{passive:!0});let k=new ResizeObserver(()=>{!v.current&&(d.fit(),z.current||X())});k.observe(l.current);let p=new AbortController;return Z(a,c,p.signal),()=>{p.abort(),k.disconnect(),b.removeEventListener("compositionend",f,!0),b.removeEventListener("touchstart",i),b.removeEventListener("touchmove",j),A.current?.dispose(),A.current=null,c.dispose(),m.current=null,n.current=null,o.current?.removeAllListeners(),o.current?.disconnect(),o.current=null}},[]),(0,r.useEffect)(()=>{m.current&&(m.current.options.theme=V)},[U]),(0,r.useEffect)(()=>{function a(){v.current=!0,m.current?.blur()}function b(){if(v.current=!1,n.current?.fit(),X(),!w.current)return;let a=l.current?.querySelector("textarea.xterm-helper-textarea");a?.focus()}return window.addEventListener("editor-session-open",a),window.addEventListener("editor-session-done",b),()=>{window.removeEventListener("editor-session-open",a),window.removeEventListener("editor-session-done",b)}},[]),(0,r.useEffect)(()=>{function a(a){let b=o.current;if(!b||!b.connected||B.current)return;B.current=setTimeout(()=>{B.current=null,D.current&&(b.off("health-check-ack",D.current),D.current=null),b.disconnect(),b.connect(),G("connecting")},6e3);let c=()=>{B.current&&(clearTimeout(B.current),B.current=null),D.current=null,a.refocus&&w.current&&m.current?.focus()};D.current=c,b.once("health-check-ack",c),b.emit("health-check")}function b(){"visible"===document.visibilityState&&a({refocus:!0})}let c=setInterval(()=>{"visible"!==document.visibilityState||"connected"===x.current&&a({refocus:!1})},8e3);return document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b),clearInterval(c),B.current&&(clearTimeout(B.current),B.current=null),D.current&&(o.current?.off("health-check-ack",D.current),D.current=null)}},[]),(0,r.useImperativeHandle)(k,()=>({sendInput:a=>{let b=o.current,c=p.current;b?.connected&&c&&b.emit("input",{sessionId:c,data:a})},focus:()=>{m.current?.focus()}}));let aa=(0,r.useCallback)(()=>{navigator.clipboard.writeText(a).then(()=>{Q(!0),setTimeout(()=>Q(!1),2e3)})},[a]);async function ab(){let a=p.current;if(a)try{let b=await fetch((0,C.apiUrl)(`/api/terminal/sessions/${a}/claude`),{method:"POST"});if(!b.ok){let a=await b.json().catch(()=>null);throw Error(a?.error||`HTTPエラー: ${b.status}`)}}catch(a){_.toaster.create({type:"error",title:"Claude を起動できません",description:a instanceof Error?a.message:String(a)})}}let ac="connecting"===F,ad="paused"===F||"exited"===F||"error"===F,ae="connected"===F,af=a.length>8?`${a.slice(0,8)}…`:a;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)("div",{className:`flex flex-col h-full min-h-0 ${e}`,children:[(0,q.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 border-b border-border flex-shrink-0 bg-card",children:[(0,q.jsx)("span",{className:"font-mono text-xs text-muted-foreground",title:a,children:af}),(0,q.jsx)(R.Button,{variant:"ghost",size:"icon-xs",onClick:aa,className:"text-muted-foreground hover:text-foreground",title:"Copy tab ID",children:P?(0,q.jsx)(fL.Check,{className:"w-3 h-3 text-success"}):(0,q.jsx)(fJ.Copy,{className:"w-3 h-3"})}),(0,q.jsxs)(R.Button,{size:"xs",onClick:()=>void ab(),disabled:!ae,title:"Run Claude",children:[(0,q.jsx)(fK.Play,{className:"w-3 h-3"}),"Run Claude"]}),(0,q.jsxs)(R.Button,{variant:"ghost",size:"xs",onClick:()=>u(!0),disabled:!ae,className:"text-muted-foreground hover:text-foreground",title:"Open editor input",children:[(0,q.jsx)(fM,{className:"w-3 h-3"}),"Open Editor"]}),(0,q.jsx)(fW,{todos:N,className:"ml-auto"})]}),(0,q.jsxs)("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[(0,q.jsx)("div",{ref:l,className:"w-full h-full",style:{padding:"4px"}}),ac&&(0,q.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background",children:(0,q.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:[(0,q.jsx)(J.Loader2,{className:"w-4 h-4 animate-spin"}),(0,q.jsx)("span",{children:"Connecting..."})]})}),ad&&(0,q.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/90",children:(0,q.jsxs)("div",{className:"text-center space-y-2",children:["error"===F&&(0,q.jsx)("p",{className:"text-xs text-destructive",children:H??"Connection failed"}),"exited"===F&&(0,q.jsx)("p",{className:"text-xs text-muted-foreground",children:"Session ended"}),"paused"===F&&(0,q.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paused"}),(0,q.jsx)(R.Button,{size:"xs",onClick:$,children:"Reconnect"})]})})]})]}),(0,q.jsx)(fN.MonacoEditorModal,{open:s,onOpenChange:a=>{a.open||u(!1)},onSubmit:a=>{m.current&&a&&m.current.paste(a),u(!1)},title:"Terminal Input",submitLabel:"Paste"})]})});var fY=a.i(12223);let fZ=(0,r.forwardRef)(function({task:b,tabs:c,activeTabId:d,onTabChange:e,onTabCreate:f,onTabDelete:g,onTodosUpdated:h,onClaudeStatusChange:i},j){let[k,l]=(0,r.useState)(()=>new Set(d?[d]:[]));(0,r.useEffect)(()=>{d&&l(a=>{if(a.has(d))return a;let b=new Set(a);return b.add(d),b})},[d]);let[m,n]=(0,r.useState)(()=>new Map(c.map(a=>[a.tab_id,{terminal:"connecting",claude:a.status}])));(0,r.useEffect)(()=>{n(a=>{let b=!1,d=new Map(a);for(let a of c)d.has(a.tab_id)||(d.set(a.tab_id,{terminal:"connecting",claude:a.status}),b=!0);return b?d:a})},[c]);let o=(0,r.useRef)(new Map);(0,r.useEffect)(()=>{d&&o.current.get(d)?.focus()},[d]);let p=(0,r.useCallback)((a,b,c)=>{n(d=>{let e=new Map(d);return e.set(a,{terminal:b,claude:c}),e}),i?.(a,c)},[i]);(0,r.useImperativeHandle)(j,()=>({sendInput:(a,b)=>{let c=o.current.get(a);c?.sendInput(b)}}));let s=(0,r.useCallback)(a=>{l(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c}),e(a)},[e]),u=(0,r.useCallback)(async a=>{let b=await f(a);b&&l(a=>{let c=new Set(a);return c.add(b),c})},[f]),v=(0,r.useCallback)(()=>u("terminal"),[u]),w=(0,r.useCallback)(()=>u("claude"),[u]),x=(0,r.useCallback)(()=>u("local"),[u]),{settings:y}=(0,fY.useOllamaSettings)(),{settings:z}=(0,fY.useLmStudioSettings)(),{settings:B}=(0,fY.useLocalLlmSettings)(),D=y?.enabled||z?.enabled?{provider:B?.active?.provider??null,model:B?.active?.model??""}:void 0,E=function({onFinal:b}){let[c,d]=(0,r.useState)(!1),[e,f]=(0,r.useState)(null),[g,h]=(0,r.useState)("off"),[i,j]=(0,r.useState)([]),[k]=(0,r.useState)(ac),l=(0,r.useRef)(null),m=(0,r.useRef)(0),n=(0,r.useRef)(null),o=(0,r.useRef)([]),p=(0,r.useRef)([]),q=(0,r.useRef)(!1),s=(0,r.useRef)(0),u=(0,r.useRef)(Promise.resolve()),v=(0,r.useRef)(b),w=(0,r.useRef)(!1);(0,r.useEffect)(()=>{v.current=b},[b]),(0,r.useEffect)(()=>{d("true"===localStorage.getItem(aa.VOICE_INPUT_ENABLED_STORAGE_KEY))},[]),(0,r.useEffect)(()=>{if(!c)return;let a=!1,b=async()=>{try{let b=await fetch((0,C.apiUrl)("/api/whisper/server/status")),c=await b.json();a||f(c.step)}catch{a||f("not_running")}};b();let d=setInterval(b,5e3);return()=>{a=!0,clearInterval(d)}},[c]);let x=(0,r.useCallback)(a=>{j(b=>b.filter(b=>b.id!==a))},[]),y=(0,r.useCallback)((a,b)=>{j(c=>c.map(c=>c.id===a?{id:a,text:b,phase:"final"}:c)),setTimeout(()=>x(a),2e3)},[x]),z=(0,r.useCallback)(async(b,c)=>{let{utils:d}=await a.A(43985),e=d.encodeWAV(b,1,16e3,1,16),f=new FormData,g=localStorage.getItem(aa.WHISPER_PROMPT_STORAGE_KEY);g&&f.append("prompt",g),f.append("interim",String(c)),f.append("file",new Blob([e],{type:"audio/wav"}),"speech.wav");let h=await fetch((0,C.apiUrl)("/api/whisper/transcribe"),{method:"POST",body:f});if(!h.ok){let a=await h.json().catch(()=>null);throw Error(a?.error||`HTTPエラー: ${h.status}`)}return await h.json()},[]),A=(0,r.useCallback)(a=>{q.current=!0,s.current=o.current.length,z(function(a){let b=new Float32Array(a.reduce((a,b)=>a+b.length,0)),c=0;for(let d of a)b.set(d,c),c+=d.length;return b}(o.current),!0).then(({text:b})=>{j(c=>c.map(c=>c.id===a&&"speaking"===c.phase?{...c,text:b}:c))}).catch(()=>{}).finally(()=>{q.current=!1})},[z]),B=(0,r.useCallback)((a,b)=>{let c=z(b.subarray(0,Math.max(0,b.length-16e3)),!1);u.current=u.current.then(async()=>{try{let{text:b}=await c;b?(v.current(b),y(a,b)):x(a)}catch(b){x(a),_.toaster.create({type:"error",title:"文字起こしに失敗しました",description:b instanceof Error?b.message:String(b)})}})},[z,x,y]),D=(0,r.useCallback)(async()=>{let a=l.current;l.current=null,n.current=null,o.current=[],p.current=[],k.set(0),j(a=>a.filter(a=>"speaking"!==a.phase)),h("off"),await a?.destroy().catch(()=>{})},[k]),E=(0,r.useCallback)(async()=>{h("starting");try{let{MicVAD:b}=await a.A(43985),c=Math.ceil(9.375)+1,d=await b.new({model:"v5",baseAssetPath:"/vad/",onnxWASMBasePath:"/vad/",positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,redemptionMs:1300,preSpeechPadMs:300,minSpeechMs:300,ortConfig:a=>{a.env.logLevel="error",a.env.wasm.numThreads=1},onFrameProcessed:(a,b)=>{k.set(function(a){let b=0;for(let c=0;c<a.length;c++)b+=a[c]*a[c];let c=Math.sqrt(b/a.length);return Math.min(1,Math.max(0,((c>0?20*Math.log10(c):-60)- -60)/50))}(b));let d=n.current;if(null===d){let a=p.current;a.push(b),a.length>c&&a.shift();return}o.current.push(b);let e=o.current.length-s.current;!q.current&&32*e>=800&&A(d)},onSpeechStart:()=>{let a=++m.current;n.current=a,o.current=p.current,p.current=[],s.current=0,j(b=>[...b,{id:a,text:"",phase:"speaking"}])},onVADMisfire:()=>{let a=n.current;n.current=null,o.current=[],null!==a&&x(a)},onSpeechEnd:a=>{let b=n.current;n.current=null,o.current=[],null!==b&&(j(a=>a.map(a=>a.id===b?{...a,phase:"finalizing"}:a)),B(b,a))}});if(w.current)return void await d.destroy();l.current=d,h("listening")}catch(a){h("off"),_.toaster.create({type:"error",title:"音声入力を開始できませんでした",description:a instanceof Error?a.message:String(a)})}},[B,k,x,A]),F=(0,r.useCallback)(()=>{"listening"===g?D():"off"===g&&E()},[g,E,D]);return(0,r.useEffect)(()=>(w.current=!1,()=>{w.current=!0,l.current?.destroy().catch(()=>{}),l.current=null}),[]),{enabled:c,serverReady:null!==e&&ab.includes(e),status:g,utterances:i,levelStore:k,toggle:F}}({onFinal:(0,r.useCallback)(a=>{if(!d)return;let b=o.current.get(d);b?.sendInput(a),b?.focus()},[d])}),F=(0,r.useCallback)(a=>{l(b=>{let c=new Set(b);return c.delete(a),c}),n(b=>{let c=new Map(b);return c.delete(a),c}),o.current.delete(a),g(a)},[g]);return(0,q.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,q.jsx)("div",{className:"px-4 pt-4 flex-shrink-0",children:(0,q.jsx)(Y,{tabs:c,activeTabId:d,onTabChange:s,onTabCreateTerminal:v,onTabCreateClaude:w,localLlmOption:D,onTabCreateLocalLlm:x,onTabDelete:F,tabStatusMap:m,voiceInput:c.length>0||"off"!==E.status?E:void 0})}),(0,q.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[c.map(a=>{let c=k.has(a.tab_id),e=a.tab_id===d;return c?(0,q.jsx)("div",{className:"absolute inset-0 flex flex-col px-4 pb-4 pt-2",style:{visibility:e?"visible":"hidden",pointerEvents:e?"auto":"none"},children:(0,q.jsx)(fX,{ref:b=>{b?o.current.set(a.tab_id,b):o.current.delete(a.tab_id)},tabId:a.tab_id,isActive:e,cwd:b.worktreePath,launchClaude:"terminal"!==a.mode,className:"h-full",initialTodos:a.todos,initialClaudeStatus:a.status,onTodosUpdated:h,onStatusChange:p})},a.tab_id):null}),0===c.length&&(0,q.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-4 px-4",children:[(0,q.jsx)("p",{className:"text-sm text-muted-foreground",children:"起動するタブを選んでください"}),(0,q.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,q.jsxs)(R.Button,{onClick:w,children:[(0,q.jsx)(V.ClaudeIcon,{className:"w-4 h-4"}),"Claude Code"]}),D&&(0,q.jsx)("span",{title:D.model?`${(0,W.localLlmTabLabel)(D.provider)}: ${D.model}`:"ローカルLLMのモデルが未設定です(Settings で設定)",children:(0,q.jsxs)(R.Button,{variant:"outline",onClick:()=>void x(),disabled:!D.model,children:[(0,q.jsx)(V.LocalLlmTabIcon,{provider:D.provider,className:"w-4 h-4"}),(0,W.localLlmTabLabel)(D.provider)]})}),(0,q.jsxs)(R.Button,{variant:"outline",onClick:v,children:[(0,q.jsx)(A,{className:"w-4 h-4"}),"Terminal"]})]})]}),(0,q.jsx)($,{utterances:E.utterances}),c.length>0&&!d&&(0,q.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Select a tab to view terminal"})]})]})});a.s([],52628),a.i(52628);var f$=a.i(21376);let f_=r.createContext(void 0);function f0(a){let b=r.useContext(f_);if(void 0===b&&!a)throw Error((0,f$.default)(33));return b}let f1=r.createContext(void 0);function f2(a){let b=r.useContext(f1);if(void 0===b&&!a)throw Error((0,f$.default)(36));return b}var f3=a.i(2840),f4=a.i(4987);let f5=r.forwardRef(function(a,b){let{className:c,render:d,...e}=a,{store:f}=f2(),{arrowRef:g,side:h,align:i,arrowUncentered:j,arrowStyles:k}=f0(),l=f.useState("open");return(0,f3.useRenderElement)("div",a,{ref:[g,b],stateAttributesMapping:f4.popupStateMapping,state:{open:l,side:h,align:i,uncentered:j},props:{style:k,"aria-hidden":!0,...e}})});var f6=a.i(58418);let f7=r.createContext(void 0);function f8(a=!0){let b=r.useContext(f7);if(void 0===b&&!a)throw Error((0,f$.default)(25));return b}var f9=a.i(74348);let ga={...f4.popupStateMapping,...f6.transitionStatusMapping},gb=r.forwardRef(function(a,b){let{className:c,render:d,...e}=a,{store:f}=f2(),g=f.useState("open"),h=f.useState("mounted"),i=f.useState("transitionStatus"),j=f.useState("lastOpenChangeReason"),k=f8();return(0,f3.useRenderElement)("div",a,{ref:k?.backdropRef?[b,k.backdropRef]:b,state:{open:g,transitionStatus:i},stateAttributesMapping:ga,props:[{role:"presentation",hidden:!h,style:{pointerEvents:j===f9.REASONS.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},e]})});var gc=a.i(71812),gd=a.i(52034);let ge=r.createContext(void 0);var gf=a.i(71689),gg=a.i(45819),gh=a.i(84991),gi=a.i(25238);function gj(a){let{closeOnClick:b,highlighted:c,id:d,nodeId:e,store:f,typingRef:g,itemRef:h,itemMetadata:i}=a,{events:j}=f.useState("floatingTreeRoot"),k=f8(!0),l=void 0!==k;return r.useMemo(()=>({id:d,role:"menuitem",tabIndex:c?0:-1,onKeyDown(a){" "===a.key&&g?.current&&a.preventDefault()},onMouseMove(a){e&&j.emit("itemhover",{nodeId:e,target:a.currentTarget})},onClick(a){b&&j.emit("close",{domEvent:a,reason:f9.REASONS.itemPress})},onMouseUp(a){if(k){let b=k.initialCursorPointRef.current;if(k.initialCursorPointRef.current=null,l&&b&&1>=Math.abs(a.clientX-b.x)&&1>=Math.abs(a.clientY-b.y)||l&&!gi.isMac&&2===a.button)return}h.current&&f.context.allowMouseUpTriggerRef.current&&(!l||2===a.button)&&(!i||"regular-item"===i.type)&&h.current.click()}}),[b,c,d,j,e,f,g,h,k,l,i])}let gk={type:"regular-item"};function gl(a){let{closeOnClick:b,disabled:c=!1,highlighted:d,id:e,store:f,typingRef:g=f.context.typingRef,nativeButton:h,itemMetadata:i,nodeId:j}=a,k=r.useRef(null),{getButtonProps:l,buttonRef:m}=(0,gg.useButton)({disabled:c,focusableWhenDisabled:!0,native:h,composite:!0}),n=gj({closeOnClick:b,highlighted:d,id:e,nodeId:j,store:f,typingRef:g,itemRef:k,itemMetadata:i}),o=r.useCallback(a=>(0,gh.mergeProps)(n,{onMouseEnter(){"submenu-trigger"===i.type&&i.setActive()}},a,l),[n,l,i]),p=(0,gf.useMergedRefs)(k,m);return r.useMemo(()=>({getItemProps:o,itemRef:p}),[o,p])}var gm=a.i(17585);let gn=r.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}}),go=((n={})[n.None=0]="None",n[n.GuessFromOrder=1]="GuessFromOrder",n);function gp(a={}){let{label:b,metadata:c,textRef:d,indexGuessBehavior:e,index:f}=a,{register:g,unregister:h,subscribeMapChange:i,elementsRef:j,labelsRef:k,nextIndexRef:l}=r.useContext(gn),m=r.useRef(-1),[n,o]=r.useState(f??(e===go.GuessFromOrder?()=>{if(-1===m.current){let a=l.current;l.current+=1,m.current=a}return m.current}:-1)),p=r.useRef(null),q=r.useCallback(a=>{if(p.current=a,-1!==n&&null!==a&&(j.current[n]=a,k)){let c=void 0!==b;k.current[n]=c?b:d?.current?.textContent??a.textContent}},[n,j,k,b,d]);return(0,gm.useIsoLayoutEffect)(()=>{if(null!=f)return;let a=p.current;if(a)return g(a,c),()=>{h(a)}},[f,g,h,c]),(0,gm.useIsoLayoutEffect)(()=>{if(null==f)return i(a=>{let b=p.current?a.get(p.current)?.index:null;null!=b&&o(b)})},[f,i,o]),r.useMemo(()=>({ref:q,index:n}),[n,q])}var gq=a.i(98134);let gr=((o={}).checked="data-checked",o.unchecked="data-unchecked",o.disabled="data-disabled",o.highlighted="data-highlighted",o),gs={checked:a=>a?{[gr.checked]:""}:{[gr.unchecked]:""},...f6.transitionStatusMapping};var gt=a.i(62255);let gu=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,nativeButton:g=!1,disabled:h=!1,closeOnClick:i=!1,checked:j,defaultChecked:k,onCheckedChange:l,...m}=a,n=gp({label:f}),o=f0(!0),p=(0,gq.useBaseUiId)(e),{store:s}=f2(),u=s.useState("isActive",n.index),v=s.useState("itemProps"),[w,x]=(0,gd.useControlled)({controlled:j,default:k??!1,name:"MenuCheckboxItem",state:"checked"}),{getItemProps:y,itemRef:z}=gl({closeOnClick:i,disabled:h,highlighted:u,id:p,store:s,nativeButton:g,nodeId:o?.nodeId,itemMetadata:gk}),A=r.useMemo(()=>({disabled:h,highlighted:u,checked:w}),[h,u,w]),B=(0,gc.useStableCallback)(a=>{let b={...(0,gt.createChangeEventDetails)(f9.REASONS.itemPress,a.nativeEvent),preventUnmountOnClose:()=>{}};l?.(!w,b),b.isCanceled||x(a=>!a)}),C=(0,f3.useRenderElement)("div",a,{state:A,stateAttributesMapping:gs,props:[v,{role:"menuitemcheckbox","aria-checked":w,onClick:B},m,y],ref:[z,b,n.ref]});return(0,q.jsx)(ge.Provider,{value:A,children:C})});var gv=a.i(77717),gw=a.i(2471);let gx=r.forwardRef(function(a,b){let{render:c,className:d,keepMounted:e=!1,...f}=a,g=function(){let a=r.useContext(ge);if(void 0===a)throw Error((0,f$.default)(30));return a}(),h=r.useRef(null),{transitionStatus:i,setMounted:j}=(0,gv.useTransitionStatus)(g.checked);(0,gw.useOpenChangeComplete)({open:g.checked,ref:h,onComplete(){g.checked||j(!1)}});let k={checked:g.checked,disabled:g.disabled,highlighted:g.highlighted,transitionStatus:i};return(0,f3.useRenderElement)("span",a,{state:k,ref:[b,h],stateAttributesMapping:gs,props:{"aria-hidden":!0,...f},enabled:e||g.checked})}),gy=r.createContext(void 0),gz=r.forwardRef(function(a,b){let{render:c,className:d,...e}=a,[f,g]=r.useState(void 0),h=r.useMemo(()=>({setLabelId:g}),[g]),i=(0,f3.useRenderElement)("div",a,{ref:b,props:{role:"group","aria-labelledby":f,...e}});return(0,q.jsx)(gy.Provider,{value:h,children:i})}),gA=r.forwardRef(function(a,b){let{className:c,render:d,id:e,...f}=a,g=(0,gq.useBaseUiId)(e),{setLabelId:h}=function(){let a=r.useContext(gy);if(void 0===a)throw Error((0,f$.default)(31));return a}();return(0,gm.useIsoLayoutEffect)(()=>(h(g),()=>{h(void 0)}),[h,g]),(0,f3.useRenderElement)("div",a,{ref:b,props:{id:g,role:"presentation",...f}})}),gB=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,nativeButton:g=!1,disabled:h=!1,closeOnClick:i=!0,...j}=a,k=gp({label:f}),l=f0(!0),m=(0,gq.useBaseUiId)(e),{store:n}=f2(),o=n.useState("isActive",k.index),p=n.useState("itemProps"),{getItemProps:q,itemRef:r}=gl({closeOnClick:i,disabled:h,highlighted:o,id:m,store:n,nativeButton:g,nodeId:l?.nodeId,itemMetadata:gk});return(0,f3.useRenderElement)("div",a,{state:{disabled:h,highlighted:o},props:[p,j,q],ref:[r,b,k.ref]})}),gC=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,closeOnClick:g=!1,...h}=a,i=r.useRef(null),j=gp({label:f}),k=f0(!0),l=k?.nodeId,m=(0,gq.useBaseUiId)(e),{store:n}=f2(),o=n.useState("isActive",j.index),p=n.useState("itemProps"),q=n.context.typingRef,{getButtonProps:s,buttonRef:u}=(0,gg.useButton)({native:!1,composite:!0}),v=gj({closeOnClick:g,highlighted:o,id:m,nodeId:l,store:n,typingRef:q,itemRef:i}),w=r.useMemo(()=>({highlighted:o}),[o]);return(0,f3.useRenderElement)("a",a,{state:w,props:[p,h,function(a){return(0,gh.mergeProps)(v,a,s)}],ref:[i,u,b,j.ref]})});var gD=a.i(15815),gE=a.i(55061),gF=a.i(80401),gG=a.i(32049),gH=a.i(45037);let gI={...f4.popupStateMapping,...f6.transitionStatusMapping},gJ=r.forwardRef(function(a,b){let{render:c,className:d,finalFocus:e,...f}=a,{store:g}=f2(),{side:h,align:i}=f0(),j=null!=(0,gF.useToolbarRootContext)(!0),k=g.useState("open"),l=g.useState("transitionStatus"),m=g.useState("popupProps"),n=g.useState("mounted"),o=g.useState("instantType"),p=g.useState("activeTriggerElement"),s=g.useState("parent"),u=g.useState("lastOpenChangeReason"),v=g.useState("rootId"),w=g.useState("floatingRootContext"),x=g.useState("floatingTreeRoot"),y=g.useState("closeDelay"),z=g.useState("activeTriggerElement"),A="context-menu"===s.type;(0,gw.useOpenChangeComplete)({open:k,ref:g.context.popupRef,onComplete(){k&&g.context.onOpenChangeComplete?.(!0)}}),r.useEffect(()=>{function a(a){g.setOpen(!1,(0,gt.createChangeEventDetails)(a.reason,a.domEvent))}return x.events.on("close",a),()=>{x.events.off("close",a)}},[x.events,g]);let B=g.useState("hoverEnabled"),C=g.useState("disabled");(0,gE.useHoverFloatingInteraction)(w,{enabled:B&&!C&&!A&&"menubar"!==s.type,closeDelay:y});let D={transitionStatus:l,side:h,align:i,open:k,nested:"menu"===s.type,instant:o},E=r.useCallback(a=>{g.set("popupElement",a)},[g]),F=(0,f3.useRenderElement)("div",a,{state:D,ref:[b,g.context.popupRef,E],stateAttributesMapping:gI,props:[m,{onKeyDown(a){j&&gG.COMPOSITE_KEYS.has(a.key)&&a.stopPropagation()}},(0,gH.getDisabledMountTransitionStyles)(l),f,{"data-rootownerid":v}]}),G=void 0===s.type||A;return(p||"menubar"===s.type&&u!==f9.REASONS.outsidePress)&&(G=!0),(0,q.jsx)(gD.FloatingFocusManager,{context:w,modal:A,disabled:!n,returnFocus:void 0===e?G:e,initialFocus:"menu"!==s.type,restoreFocus:!0,externalTree:"menubar"!==s.type?x:void 0,previousFocusableElement:z,nextFocusableElement:void 0===s.type?g.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:void 0===s.type?g.context.beforeContentFocusGuardRef:void 0,children:F})});var gK=a.i(87263);let gL=r.createContext(void 0),gM=r.forwardRef(function(a,b){let{keepMounted:c=!1,...d}=a,{store:e}=f2();return e.useState("mounted")||c?(0,q.jsx)(gL.Provider,{value:c,children:(0,q.jsx)(gK.FloatingPortal,{ref:b,...d})}):null});var gN=a.i(83065),gO=a.i(76093),gP=a.i(84151),gQ=a.i(93573),gR=a.i(95337);function gS(a){let{children:b,elementsRef:c,labelsRef:d,onMapChange:e}=a,f=(0,gc.useStableCallback)(e),g=r.useRef(0),h=(0,gR.useRefWithInit)(gU).current,i=(0,gR.useRefWithInit)(gT).current,[j,k]=r.useState(0),l=r.useRef(j),m=(0,gc.useStableCallback)((a,b)=>{i.set(a,b??null),l.current+=1,k(l.current)}),n=(0,gc.useStableCallback)(a=>{i.delete(a),l.current+=1,k(l.current)}),o=r.useMemo(()=>{let a=new Map;return Array.from(i.keys()).filter(a=>a.isConnected).sort(gV).forEach((b,c)=>{let d=i.get(b)??{};a.set(b,{...d,index:c})}),a},[i,j]);(0,gm.useIsoLayoutEffect)(()=>{if("function"!=typeof MutationObserver||0===o.size)return;let a=new MutationObserver(a=>{let b=new Set,c=a=>b.has(a)?b.delete(a):b.add(a);a.forEach(a=>{a.removedNodes.forEach(c),a.addedNodes.forEach(c)}),0===b.size&&(l.current+=1,k(l.current))});return o.forEach((b,c)=>{c.parentElement&&a.observe(c.parentElement,{childList:!0})}),()=>{a.disconnect()}},[o]),(0,gm.useIsoLayoutEffect)(()=>{l.current===j&&(c.current.length!==o.size&&(c.current.length=o.size),d&&d.current.length!==o.size&&(d.current.length=o.size),g.current=o.size),f(o)},[f,o,c,d,j]),(0,gm.useIsoLayoutEffect)(()=>()=>{c.current=[]},[c]),(0,gm.useIsoLayoutEffect)(()=>()=>{d&&(d.current=[])},[d]);let p=(0,gc.useStableCallback)(a=>(h.add(a),()=>{h.delete(a)}));(0,gm.useIsoLayoutEffect)(()=>{h.forEach(a=>a(o))},[h,o]);let s=r.useMemo(()=>({register:m,unregister:n,subscribeMapChange:p,elementsRef:c,labelsRef:d,nextIndexRef:g}),[m,n,p,c,d,g]);return(0,q.jsx)(gn.Provider,{value:s,children:b})}function gT(){return new Map}function gU(){return new Set}function gV(a,b){let c=a.compareDocumentPosition(b);return c&Node.DOCUMENT_POSITION_FOLLOWING||c&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:c&Node.DOCUMENT_POSITION_PRECEDING||c&Node.DOCUMENT_POSITION_CONTAINS?1:0}var gW=a.i(32654),gX=a.i(19382),gY=a.i(84313),gZ=a.i(14612);let g$=r.forwardRef(function(a,b){let{anchor:c,positionMethod:d="absolute",className:e,render:f,side:g,align:h,sideOffset:i=0,alignOffset:j=0,collisionBoundary:k="clipping-ancestors",collisionPadding:l=5,arrowPadding:m=5,sticky:n=!1,disableAnchorTracking:o=!1,collisionAvoidance:p=gX.DROPDOWN_COLLISION_AVOIDANCE,...s}=a,{store:u}=f2(),v=function(){let a=r.useContext(gL);if(void 0===a)throw Error((0,f$.default)(32));return a}(),w=f8(!0),x=u.useState("parent"),y=u.useState("floatingRootContext"),z=u.useState("floatingTreeRoot"),A=u.useState("mounted"),B=u.useState("open"),C=u.useState("modal"),D=u.useState("activeTriggerElement"),E=u.useState("transitionStatus"),F=u.useState("positionerElement"),G=u.useState("instantType"),H=u.useState("hasViewport"),I=u.useState("lastOpenChangeReason"),J=u.useState("floatingNodeId"),K=u.useState("floatingParentNodeId"),L=y.useState("domReferenceElement"),M=r.useRef(null),N=(0,gZ.useAnimationsFinished)(F,!1,!1),O=c,P=i,Q=j,R=h,S=p;"context-menu"===x.type&&(O=c??x.context?.anchor,R=R??"start",g||"center"===R||(Q=a.alignOffset??2,P=a.sideOffset??-5));let T=g,U=R;"menu"===x.type?(T=T??"inline-end",U=U??"start",S=a.collisionAvoidance??gX.POPUP_COLLISION_AVOIDANCE):"menubar"===x.type&&(T=T??"bottom",U=U??"start");let V="context-menu"===x.type,W=(0,gQ.useAnchorPositioning)({anchor:O,floatingRootContext:y,positionMethod:w?"fixed":d,mounted:A,side:T,sideOffset:P,align:U,alignOffset:Q,arrowPadding:V?0:m,collisionBoundary:k,collisionPadding:l,sticky:n,nodeId:J,keepMounted:v,disableAnchorTracking:o,collisionAvoidance:S,shiftCrossAxis:V&&!("side"in S&&"flip"===S.side),externalTree:z,adaptiveOrigin:H?gY.adaptiveOrigin:void 0}),X=r.useMemo(()=>{let a={};return B||(a.pointerEvents="none"),{role:"presentation",hidden:!A,style:{...W.positionerStyles,...a}}},[B,A,W.positionerStyles]);r.useEffect(()=>{function a(a){a.open&&(a.parentNodeId===J&&u.set("hoverEnabled",!1),a.nodeId!==J&&a.parentNodeId===u.select("floatingParentNodeId")&&u.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.siblingOpen)))}return z.events.on("menuopenchange",a),()=>{z.events.off("menuopenchange",a)}},[u,z.events,J]),r.useEffect(()=>{if(null!=u.select("floatingParentNodeId"))return z.events.on("menuopenchange",a),()=>{z.events.off("menuopenchange",a)};function a(a){if(a.open||a.nodeId!==u.select("floatingParentNodeId"))return;let b=a.reason??f9.REASONS.siblingOpen;u.setOpen(!1,(0,gt.createChangeEventDetails)(b))}},[z.events,u]);let Y=(0,gO.useTimeout)();r.useEffect(()=>{B||Y.clear()},[B,Y]),r.useEffect(()=>{function a(a){if(B&&a.nodeId===u.select("floatingParentNodeId"))if(a.target&&D&&D!==a.target){let a=u.select("closeDelay");a>0?Y.isStarted()||Y.start(a,()=>{u.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.siblingOpen))}):u.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.siblingOpen))}else Y.clear()}return z.events.on("itemhover",a),()=>{z.events.off("itemhover",a)}},[z.events,B,D,u,Y]),r.useEffect(()=>{let a={open:B,nodeId:J,parentNodeId:K,reason:u.select("lastOpenChangeReason")};z.events.emit("menuopenchange",a)},[z.events,B,u,J,K]),(0,gm.useIsoLayoutEffect)(()=>{let a=M.current;if(L&&(M.current=L),a&&L&&L!==a){u.set("instantType",void 0);let a=new AbortController;return N(()=>{u.set("instantType","trigger-change")},a.signal),()=>{a.abort()}}},[L,N,u]);let Z={open:B,side:W.side,align:W.align,anchorHidden:W.anchorHidden,nested:"menu"===x.type,instant:G},$=r.useMemo(()=>({side:W.side,align:W.align,arrowRef:W.arrowRef,arrowUncentered:W.arrowUncentered,arrowStyles:W.arrowStyles,nodeId:W.context.nodeId}),[W.side,W.align,W.arrowRef,W.arrowUncentered,W.arrowStyles,W.context.nodeId]),_=(0,f3.useRenderElement)("div",a,{state:Z,stateAttributesMapping:f4.popupStateMapping,ref:[b,u.useStateSetter("positionerElement")],props:[X,(0,gH.getDisabledMountTransitionStyles)(E),s]}),aa=A&&"menu"!==x.type&&("menubar"!==x.type&&C&&I!==f9.REASONS.triggerHover||"menubar"===x.type&&x.context.modal),ab=null;return"menubar"===x.type?ab=x.context.contentElement:void 0===x.type&&(ab=D),(0,q.jsxs)(f_.Provider,{value:$,children:[aa&&(0,q.jsx)(gW.InternalBackdrop,{ref:"context-menu"===x.type||"nested-context-menu"===x.type?x.context.internalBackdropRef:null,inert:(0,gN.inertValue)(!B),cutout:ab}),(0,q.jsx)(gP.FloatingNode,{id:J,children:(0,q.jsx)(gS,{elementsRef:u.context.itemDomElements,labelsRef:u.context.itemLabels,children:_})})]})}),g_=r.createContext(void 0),g0=r.memo(r.forwardRef(function(a,b){let{render:c,className:d,value:e,defaultValue:f,onValueChange:g,disabled:h=!1,...i}=a,[j,k]=(0,gd.useControlled)({controlled:e,default:f,name:"MenuRadioGroup"}),l=(0,gc.useStableCallback)(g),m=(0,gc.useStableCallback)((a,b)=>{l?.(a,b),b.isCanceled||k(a)}),n=(0,f3.useRenderElement)("div",a,{state:{disabled:h},ref:b,props:{role:"group","aria-disabled":h||void 0,...i}}),o=r.useMemo(()=>({value:j,setValue:m,disabled:h}),[j,m,h]);return(0,q.jsx)(g_.Provider,{value:o,children:n})})),g1=r.createContext(void 0),g2=r.forwardRef(function(a,b){let{render:c,className:d,id:e,label:f,nativeButton:g=!1,disabled:h=!1,closeOnClick:i=!1,value:j,...k}=a,l=gp({label:f}),m=f0(!0),n=(0,gq.useBaseUiId)(e),{store:o}=f2(),p=o.useState("isActive",l.index),s=o.useState("itemProps"),{value:u,setValue:v,disabled:w}=function(){let a=r.useContext(g_);if(void 0===a)throw Error((0,f$.default)(34));return a}(),x=w||h,y=u===j,{getItemProps:z,itemRef:A}=gl({closeOnClick:i,disabled:x,highlighted:p,id:n,store:o,nativeButton:g,nodeId:m?.nodeId,itemMetadata:gk}),B=r.useMemo(()=>({disabled:x,highlighted:p,checked:y}),[x,p,y]),C=(0,gc.useStableCallback)(a=>{v(j,{...(0,gt.createChangeEventDetails)(f9.REASONS.itemPress,a.nativeEvent),preventUnmountOnClose:()=>{}})}),D=(0,f3.useRenderElement)("div",a,{state:B,stateAttributesMapping:gs,props:[s,{role:"menuitemradio","aria-checked":y,onClick:C},k,z],ref:[A,b,l.ref]});return(0,q.jsx)(g1.Provider,{value:B,children:D})}),g3=r.forwardRef(function(a,b){let{render:c,className:d,keepMounted:e=!1,...f}=a,g=function(){let a=r.useContext(g1);if(void 0===a)throw Error((0,f$.default)(35));return a}(),h=r.useRef(null),{transitionStatus:i,setMounted:j}=(0,gv.useTransitionStatus)(g.checked);(0,gw.useOpenChangeComplete)({open:g.checked,ref:h,onComplete(){g.checked||j(!1)}});let k={checked:g.checked,disabled:g.disabled,highlighted:g.highlighted,transitionStatus:i};return(0,f3.useRenderElement)("span",a,{state:k,stateAttributesMapping:gs,ref:[b,h],props:{"aria-hidden":!0,...f},enabled:e||g.checked})});var g4=a.i(21042),g5=a.i(87377),g6=a.i(66173),g7=a.i(37388),g8=a.i(62279),g9=a.i(60349),ha=a.i(25158),hb=a.i(26476),hc=a.i(35850),hd=a.i(632),he=a.i(6239),hf=a.i(50499),hg=a.i(99570),hh=a.i(85766),hi=a.i(38794);function hj(a,b,c){switch(a){case"vertical":return b;case"horizontal":return c;default:return b||c}}function hk(a,b){return hj(b,a===hi.ARROW_UP||a===hi.ARROW_DOWN,a===hi.ARROW_LEFT||a===hi.ARROW_RIGHT)}function hl(a,b,c){return hj(b,a===hi.ARROW_DOWN,c?a===hi.ARROW_LEFT:a===hi.ARROW_RIGHT)||"Enter"===a||" "===a||""===a}var hm=a.i(59750),hn=a.i(88074);let ho=r.createContext(null);function hp(a){let b=r.useContext(ho);if(null===b&&!a)throw Error((0,f$.default)(5));return b}var hq=a.i(25173),hr=a.i(8273),hs=a.i(458),ht=a.i(43216),hu=a.i(46790),hv=a.i(78462),hw=a.i(21017);let hx={...hv.popupStoreSelectors,disabled:(0,hs.createSelector)(a=>"menubar"===a.parent.type&&a.parent.context.disabled||a.disabled),modal:(0,hs.createSelector)(a=>(void 0===a.parent.type||"context-menu"===a.parent.type)&&(a.modal??!0)),allowMouseEnter:(0,hs.createSelector)(a=>a.allowMouseEnter),stickIfOpen:(0,hs.createSelector)(a=>a.stickIfOpen),parent:(0,hs.createSelector)(a=>a.parent),rootId:(0,hs.createSelector)(a=>"menu"===a.parent.type?a.parent.store.select("rootId"):void 0!==a.parent.type?a.parent.context.rootId:a.rootId),activeIndex:(0,hs.createSelector)(a=>a.activeIndex),isActive:(0,hs.createSelector)((a,b)=>a.activeIndex===b),hoverEnabled:(0,hs.createSelector)(a=>a.hoverEnabled),instantType:(0,hs.createSelector)(a=>a.instantType),lastOpenChangeReason:(0,hs.createSelector)(a=>a.openChangeReason),floatingTreeRoot:(0,hs.createSelector)(a=>"menu"===a.parent.type?a.parent.store.select("floatingTreeRoot"):a.floatingTreeRoot),floatingNodeId:(0,hs.createSelector)(a=>a.floatingNodeId),floatingParentNodeId:(0,hs.createSelector)(a=>a.floatingParentNodeId),itemProps:(0,hs.createSelector)(a=>a.itemProps),closeDelay:(0,hs.createSelector)(a=>a.closeDelay),hasViewport:(0,hs.createSelector)(a=>a.hasViewport),keyboardEventRelay:(0,hs.createSelector)(a=>a.keyboardEventRelay?a.keyboardEventRelay:"menu"===a.parent.type?a.parent.store.select("keyboardEventRelay"):void 0)};class hy extends ht.ReactStore{constructor(a){super({...{...(0,hv.createInitialPopupStoreState)(),disabled:!1,modal:!0,allowMouseEnter:!1,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new hu.FloatingTreeStore,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:g7.EMPTY_OBJECT,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1},...a},{positionerRef:r.createRef(),popupRef:r.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:r.createRef(),beforeContentFocusGuardRef:r.createRef(),onOpenChangeComplete:void 0,triggerElements:new hw.PopupTriggerMap},hx),this.unsubscribeParentListener=this.observe("parent",a=>{if(this.unsubscribeParentListener?.(),"menu"===a.type){let b=a.store.select("rootId"),c=a.store.select("floatingTreeRoot"),d=a.store.select("keyboardEventRelay");this.unsubscribeParentListener=a.store.subscribe(()=>{let e=a.store.select("rootId"),f=a.store.select("floatingTreeRoot"),g=a.store.select("keyboardEventRelay");(b!==e||c!==f||d!==g)&&(b=e,c=f,d=g,this.notifyAll())}),this.context.allowMouseUpTriggerRef=a.store.context.allowMouseUpTriggerRef;return}void 0!==a.type&&(this.context.allowMouseUpTriggerRef=a.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(a,b){this.state.floatingRootContext.context.events.emit("setOpen",{open:a,eventDetails:b})}static useStore(a,b){let c=(0,gR.useRefWithInit)(()=>new hy(b)).current;return a??c}unsubscribeParentListener=null}var hz=a.i(86089);let hA=r.createContext(void 0);function hB(){return r.useContext(hA)}let hC=(0,g8.fastComponent)(function(a){let b,c,{children:d,open:e,onOpenChange:f,onOpenChangeComplete:g,defaultOpen:h=!1,disabled:i=!1,modal:j,loopFocus:k=!0,orientation:l="vertical",actionsRef:m,closeParentOnEsc:n=!1,handle:o,triggerId:p,defaultTriggerId:s=null,highlightItemOnHover:u=!0}=a,v=f8(!0),w=f2(!0),x=hp(!0),y=hB(),z=r.useMemo(()=>y&&w?{type:"menu",store:w.store}:x?{type:"menubar",context:x}:v&&!w?{type:"context-menu",context:v}:{type:void 0},[v,w,x,y]),A=hy.useStore(o?.store,{open:h,openProp:e,activeTriggerId:s,triggerIdProp:p,parent:z});(0,g5.useOnFirstRender)(()=>{void 0===e&&!1===A.state.open&&!0===h&&A.update({open:!0,activeTriggerId:s})}),A.useControlledProp("openProp",e),A.useControlledProp("triggerIdProp",p),A.useContextCallback("onOpenChangeComplete",g);let B=A.useState("floatingTreeRoot"),C=(0,gP.useFloatingNodeId)(B),D=(0,gP.useFloatingParentNodeId)();(0,gm.useIsoLayoutEffect)(()=>{v&&!w?A.update({parent:{type:"context-menu",context:v},floatingNodeId:C,floatingParentNodeId:D}):w&&A.update({floatingNodeId:C,floatingParentNodeId:D})},[v,w,C,D,A]);let E=A.useState("open"),F=A.useState("activeTriggerElement"),G=A.useState("positionerElement"),H=A.useState("hoverEnabled"),I=A.useState("modal"),J=A.useState("disabled"),K=A.useState("lastOpenChangeReason"),L=A.useState("parent"),M=A.useState("activeIndex"),N=A.useState("payload"),O=A.useState("floatingParentNodeId"),P=r.useRef(null),Q=null!=O;A.useSyncedValues({disabled:i,modal:void 0===L.type?j:void 0,rootId:(0,g4.useId)()});let{openMethod:R,triggerProps:S}=(0,hr.useOpenInteractionType)(E);(0,hz.useImplicitActiveTrigger)(A);let{forceUnmount:T}=(0,hz.useOpenStateTransitions)(E,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0})}),U=r.useRef("context-menu"!==L.type),V=(0,gO.useTimeout)();r.useEffect(()=>{if(E||(P.current=null),"context-menu"===L.type){if(!E){V.clear(),U.current=!1;return}V.start(500,()=>{U.current=!0})}},[V,E,L.type]),(0,g6.useScrollLock)(E&&I&&K!==f9.REASONS.triggerHover&&"touch"!==R,G),(0,gm.useIsoLayoutEffect)(()=>{E||H||A.set("hoverEnabled",!0)},[E,H,A]);let W=r.useRef(!0),X=(0,gO.useTimeout)(),Y=(0,gc.useStableCallback)((a,c)=>{let d=c.reason;if(E===a&&c.trigger===F&&K===d||(c.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},a||null!=c.trigger||(c.trigger=F??void 0),f?.(a,c),c.isCanceled))return;let e={open:a,nativeEvent:c.event,reason:c.reason,nested:Q};b?.emit("openchange",e);let g=c.event;if(!1===a&&g?.type==="click"&&"touch"===g.pointerType&&!W.current)return;if(!a&&null!==M){let a=A.context.itemDomElements.current[M];queueMicrotask(()=>{a?.setAttribute("tabindex","-1")})}a&&d===f9.REASONS.triggerFocus?(W.current=!1,X.start(300,()=>{W.current=!0})):(W.current=!0,X.clear());let h=(d===f9.REASONS.triggerPress||d===f9.REASONS.itemPress)&&0===g.detail&&g?.isTrusted,i=!a&&(d===f9.REASONS.escapeKey||null==d),j={open:a,openChangeReason:d};P.current=c.event??null;let k=c.trigger?.id??null;(k||a)&&(j.activeTriggerId=k,j.activeTriggerElement=c.trigger??null),A.update(j),"menubar"===L.type&&(d===f9.REASONS.triggerFocus||d===f9.REASONS.focusOut||d===f9.REASONS.triggerHover||d===f9.REASONS.listNavigation||d===f9.REASONS.siblingOpen)?A.set("instantType","group"):h||i?A.set("instantType",h?"click":"dismiss"):A.set("instantType",void 0)}),Z=r.useCallback(a=>{let b=(0,gt.createChangeEventDetails)(a);return b.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},b},[A]),$=r.useCallback(()=>{A.setOpen(!1,Z(f9.REASONS.imperativeAction))},[A,Z]);r.useImperativeHandle(m,()=>({unmount:T,close:$}),[T,$]),"context-menu"===L.type&&(c=L.context),r.useImperativeHandle(c?.positionerRef,()=>G,[G]),r.useImperativeHandle(c?.actionsRef,()=>({setOpen:Y}),[Y]);let _=(0,hn.useSyncedFloatingRootContext)({popupStore:A,onOpenChange:Y});b=_.context.events,r.useEffect(()=>{let a=({open:a,eventDetails:b})=>Y(a,b);return b.on("setOpen",a),()=>{b?.off("setOpen",a)}},[b,Y]);let aa=(0,g9.useDismiss)(_,{enabled:!J,bubbles:{escapeKey:n&&"menu"===L.type},outsidePress:()=>"context-menu"!==L.type||P.current?.type==="contextmenu"||U.current,externalTree:Q?B:void 0}),ab=(0,hm.useRole)(_,{role:"menu"}),ac=(0,hq.useDirection)(),ad=r.useCallback(a=>{A.select("activeIndex")!==a&&A.set("activeIndex",a)},[A]),ae=function(a,b){let c="rootStore"in a?a.rootStore:a,d=c.useState("open"),e=c.useState("floatingElement"),f=c.useState("domReferenceElement"),g=c.context.dataRef,{listRef:h,activeIndex:i,onNavigate:j=()=>{},enabled:k=!0,selectedIndex:l=null,allowEscape:m=!1,loopFocus:n=!1,nested:o=!1,rtl:p=!1,virtual:q=!1,focusItemOnOpen:s="auto",focusItemOnHover:u=!0,openOnArrowKeyDown:v=!0,disabledIndices:w,orientation:x="vertical",parentOrientation:y,cols:z=1,id:A,resetOnPointerLeave:B=!0,externalTree:C}=b,D=(0,he.getFloatingFocusElement)(e),E=(0,hc.useValueAsRef)(D),F=(0,gP.useFloatingParentNodeId)(),G=(0,gP.useFloatingTree)(C);(0,gm.useIsoLayoutEffect)(()=>{g.current.orientation=x},[g,x]);let H=(0,he.isTypeableCombobox)(f),I=r.useRef(s),J=r.useRef(l??-1),K=r.useRef(null),L=r.useRef(!0),M=(0,gc.useStableCallback)(a=>{j(-1===J.current?null:J.current,a)}),N=r.useRef(M),O=r.useRef(!!e),P=r.useRef(d),Q=r.useRef(!1),R=r.useRef(!1),S=(0,hc.useValueAsRef)(w),T=(0,hc.useValueAsRef)(d),U=(0,hc.useValueAsRef)(l),V=(0,hc.useValueAsRef)(B),W=(0,gc.useStableCallback)(()=>{function a(a){q?G?.events.emit("virtualfocus",a):(0,hh.enqueueFocus)(a,{sync:Q.current,preventScroll:!0})}let b=h.current[J.current],c=R.current;b&&a(b),(Q.current?a=>a():requestAnimationFrame)(()=>{let d=h.current[J.current]||b;!d||(b||a(d),Y&&(c||!L.current)&&d.scrollIntoView?.({block:"nearest",inline:"nearest"}))})});(0,gm.useIsoLayoutEffect)(()=>{k&&(d&&e?(J.current=l??-1,I.current&&null!=l&&(R.current=!0,M())):O.current&&(J.current=-1,N.current()))},[k,d,e,l,M]),(0,gm.useIsoLayoutEffect)(()=>{if(k){if(!d){Q.current=!1;return}if(e)if(null==i){if(Q.current=!1,null!=U.current)return;if(O.current&&(J.current=-1,W()),(!P.current||!O.current)&&I.current&&(null!=K.current||!0===I.current&&null==K.current)){let a=0,b=()=>{null==h.current[0]?(a<2&&(a?requestAnimationFrame:queueMicrotask)(b),a+=1):(J.current=null==K.current||hl(K.current,x,p)||o?(0,hg.getMinListIndex)(h):(0,hg.getMaxListIndex)(h),K.current=null,M())};b()}}else(0,hg.isIndexOutOfListBounds)(h,i)||(J.current=i,W(),R.current=!1)}},[k,d,e,i,U,o,h,x,p,M,W,S]),(0,gm.useIsoLayoutEffect)(()=>{if(!k||e||!G||q||!O.current)return;let a=G.nodesRef.current,b=a.find(a=>a.id===F)?.context?.elements.floating,c=(0,he.activeElement)((0,hd.ownerDocument)(e)),d=a.some(a=>a.context&&(0,he.contains)(a.context.elements.floating,c));b&&!d&&L.current&&b.focus({preventScroll:!0})},[k,e,G,F,q]),(0,gm.useIsoLayoutEffect)(()=>{N.current=M,P.current=d,O.current=!!e}),(0,gm.useIsoLayoutEffect)(()=>{d||(K.current=null,I.current=s)},[d,s]);let X=null!=i,Y=r.useMemo(()=>{function a(a){if(!T.current)return;let b=h.current.indexOf(a.currentTarget);-1!==b&&J.current!==b&&(J.current=b,M(a))}return{onFocus(b){Q.current=!0,a(b)},onClick:({currentTarget:a})=>a.focus({preventScroll:!0}),onMouseMove(b){Q.current=!0,R.current=!1,u&&a(b)},onPointerLeave(a){if(!T.current||!L.current||"touch"===a.pointerType)return;Q.current=!0;let b=a.relatedTarget;if(!(!u||h.current.includes(b))&&V.current&&((0,hh.enqueueFocus)(null,{sync:!0}),J.current=-1,M(a),!q)){let a=E.current,b=(0,he.activeElement)((0,hd.ownerDocument)(a));a&&(0,he.contains)(a,b)&&a.focus({preventScroll:!0})}}}},[T,E,u,h,M,V,q]),Z=r.useCallback(()=>y??G?.nodesRef.current.find(a=>a.id===F)?.context?.dataRef?.current.orientation,[F,G,y]),$=(0,gc.useStableCallback)(a=>{var b;let e,g;if(L.current=!1,Q.current=!0,229===a.which||!T.current&&a.currentTarget===E.current)return;if(o&&(b=a.key,e=p?b===hi.ARROW_RIGHT:b===hi.ARROW_LEFT,g=b===hi.ARROW_UP,"both"===x||"horizontal"===x&&z&&z>1?"Escape"===b:hj(x,e,g))){hk(a.key,Z())||(0,hf.stopEvent)(a),c.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.listNavigation,a.nativeEvent)),(0,hb.isHTMLElement)(f)&&(q?G?.events.emit("virtualfocus",f):f.focus());return}let i=J.current,j=(0,hg.getMinListIndex)(h,w),k=(0,hg.getMaxListIndex)(h,w);if(H||("Home"===a.key&&((0,hf.stopEvent)(a),J.current=j,M(a)),"End"===a.key&&((0,hf.stopEvent)(a),J.current=k,M(a))),z>1){let b=Array.from({length:h.current.length},()=>({width:1,height:1})),c=(0,hg.createGridCellMap)(b,z,!1),d=c.findIndex(a=>null!=a&&!(0,hg.isListIndexDisabled)(h,a,w)),e=c.reduce((a,b,c)=>null==b||(0,hg.isListIndexDisabled)(h,b,w)?a:c,-1),f=c[(0,hg.getGridNavigatedIndex)({current:c.map(a=>null!=a?h.current[a]:null)},{event:a,orientation:x,loopFocus:n,rtl:p,cols:z,disabledIndices:(0,hg.getGridCellIndices)([...("function"!=typeof w?w:null)||h.current.map((a,b)=>(0,hg.isListIndexDisabled)(h,b,w)?b:void 0),void 0],c),minIndex:d,maxIndex:e,prevIndex:(0,hg.getGridCellIndexOfCorner)(J.current>k?j:J.current,b,c,z,a.key===hi.ARROW_DOWN?"bl":a.key===(p?hi.ARROW_LEFT:hi.ARROW_RIGHT)?"tr":"tl"),stopEvent:!0})];if(null!=f&&(J.current=f,M(a)),"both"===x)return}if(hk(a.key,x)){if((0,hf.stopEvent)(a),d&&!q&&(0,he.activeElement)(a.currentTarget.ownerDocument)===a.currentTarget){J.current=hl(a.key,x,p)?j:k,M(a);return}hl(a.key,x,p)?n?i>=k?m&&i!==h.current.length?J.current=-1:(Q.current=!1,J.current=j):J.current=(0,hg.findNonDisabledListIndex)(h,{startingIndex:i,disabledIndices:w}):J.current=Math.min(k,(0,hg.findNonDisabledListIndex)(h,{startingIndex:i,disabledIndices:w})):n?i<=j?m&&-1!==i?J.current=h.current.length:(Q.current=!1,J.current=k):J.current=(0,hg.findNonDisabledListIndex)(h,{startingIndex:i,decrement:!0,disabledIndices:w}):J.current=Math.max(j,(0,hg.findNonDisabledListIndex)(h,{startingIndex:i,decrement:!0,disabledIndices:w})),(0,hg.isIndexOutOfListBounds)(h,J.current)&&(J.current=-1),M(a)}}),_=r.useMemo(()=>q&&d&&X&&{"aria-activedescendant":`${A}-${i}`},[q,d,X,A,i]),aa=r.useMemo(()=>({"aria-orientation":"both"===x?void 0:x,...!H?_:{},onKeyDown(a){if("Tab"===a.key&&a.shiftKey&&d&&!q){let b=(0,he.getTarget)(a.nativeEvent);if(b&&!(0,he.contains)(E.current,b))return;(0,hf.stopEvent)(a),c.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.focusOut,a.nativeEvent)),(0,hb.isHTMLElement)(f)&&f.focus();return}$(a)},onPointerMove(){L.current=!0}}),[_,$,E,x,H,c,d,q,f]),ab=r.useMemo(()=>{function a(a){"auto"===s&&(0,hf.isVirtualClick)(a.nativeEvent)&&(I.current=!q)}function b(a){I.current=s,"auto"===s&&(0,hf.isVirtualPointerEvent)(a.nativeEvent)&&(I.current=!0)}return{onKeyDown(a){var b,d;let e=c.select("open");L.current=!1;let f=a.key.startsWith("Arrow"),g=(b=a.key,d=Z(),hj(d,p?b===hi.ARROW_LEFT:b===hi.ARROW_RIGHT,b===hi.ARROW_DOWN)),i=hk(a.key,x),j=(o?g:i)||"Enter"===a.key||""===a.key.trim();if(q&&e)return $(a);if(e||v||!f){if(j){let b=hk(a.key,Z());K.current=o&&b?null:a.key}if(o){g&&((0,hf.stopEvent)(a),e?(J.current=(0,hg.getMinListIndex)(h,S.current),M(a)):c.setOpen(!0,(0,gt.createChangeEventDetails)(f9.REASONS.listNavigation,a.nativeEvent,a.currentTarget)));return}i&&(null!=U.current&&(J.current=U.current),(0,hf.stopEvent)(a),!e&&v?c.setOpen(!0,(0,gt.createChangeEventDetails)(f9.REASONS.listNavigation,a.nativeEvent,a.currentTarget)):$(a),e&&M(a))}},onFocus(a){c.select("open")&&!q&&(J.current=-1,M(a))},onPointerDown:b,onPointerEnter:b,onMouseDown:a,onClick:a}},[$,S,s,h,o,M,c,v,x,Z,p,U,q]),ac=r.useMemo(()=>({..._,...ab}),[_,ab]);return r.useMemo(()=>k?{reference:ac,floating:aa,item:Y,trigger:ab}:{},[k,ac,aa,ab,Y])}(_,{enabled:!J,listRef:A.context.itemDomElements,activeIndex:M,nested:void 0!==L.type,loopFocus:k,orientation:l,parentOrientation:"menubar"===L.type?L.context.orientation:void 0,rtl:"rtl"===ac,disabledIndices:g7.EMPTY_ARRAY,onNavigate:ad,openOnArrowKeyDown:"context-menu"!==L.type,externalTree:Q?B:void 0,focusItemOnHover:u}),af=r.useCallback(a=>{A.context.typingRef.current=a},[A]),ag=function(a,b){let c="rootStore"in a?a.rootStore:a,d=c.context.dataRef,e=c.useState("open"),{listRef:f,elementsRef:g,activeIndex:h,onMatch:i,onTypingChange:j,enabled:k=!0,resetMs:l=750,selectedIndex:m=null}=b,n=(0,gO.useTimeout)(),o=r.useRef(""),p=r.useRef(m??h??-1),q=r.useRef(null);(0,gm.useIsoLayoutEffect)(()=>{(e||null===m)&&(n.clear(),q.current=null,""!==o.current&&(o.current=""))},[e,m,n]),(0,gm.useIsoLayoutEffect)(()=>{e&&""===o.current&&(p.current=m??h??-1)},[e,m,h]);let s=(0,gc.useStableCallback)(a=>{a?d.current.typing||(d.current.typing=a,j?.(a)):d.current.typing&&(d.current.typing=a,j?.(a))}),u=(0,gc.useStableCallback)(a=>{function b(a,c,d=0){if(0===a.length)return -1;let e=(d%a.length+a.length)%a.length,f=c.toLocaleLowerCase();for(let b=0;b<a.length;b+=1){let c=(e+b)%a.length,d=a[c];if(d?.toLocaleLowerCase().startsWith(f)&&function(a){let b=g?.current[a];return!b||(0,hg.isElementVisible)(b)}(c))return c}return -1}let c=f.current;if(o.current.length>0&&" "===a.key&&((0,hf.stopEvent)(a),s(!0)),o.current.length>0&&" "!==o.current[0]&&-1===b(c,o.current)&&" "!==a.key&&s(!1),null==c||1!==a.key.length||a.ctrlKey||a.metaKey||a.altKey)return;e&&" "!==a.key&&((0,hf.stopEvent)(a),s(!0));let d=""===o.current;d&&(p.current=m??h??-1),c.every(a=>!a||a[0]?.toLocaleLowerCase()!==a[1]?.toLocaleLowerCase())&&o.current===a.key&&(o.current="",p.current=q.current),o.current+=a.key,n.start(l,()=>{o.current="",p.current=q.current,s(!1)});let j=d?m??h??-1:p.current,k=b(c,o.current,(j??0)+1);-1!==k?(i?.(k),q.current=k):" "!==a.key&&(o.current="",s(!1))}),v=(0,gc.useStableCallback)(a=>{let b=a.relatedTarget,d=c.select("domReferenceElement"),e=c.select("floatingElement"),f=(0,he.contains)(d,b),g=(0,he.contains)(e,b);f||g||(n.clear(),o.current="",p.current=q.current,s(!1))}),w=r.useMemo(()=>({onKeyDown:u,onBlur:v}),[u,v]),x=r.useMemo(()=>({onKeyDown:u,onBlur:v}),[u,v]);return r.useMemo(()=>k?{reference:w,floating:x}:{},[k,w,x])}(_,{listRef:A.context.itemLabels,elementsRef:A.context.itemDomElements,activeIndex:M,resetMs:gX.TYPEAHEAD_RESET_MS,onMatch:a=>{E&&a!==M&&A.set("activeIndex",a)},onTypingChange:af}),{getReferenceProps:ah,getFloatingProps:ai,getItemProps:aj,getTriggerProps:ak}=(0,ha.useInteractions)([aa,ab,ae,ag]),al=r.useMemo(()=>{let a=(0,gh.mergeProps)(ah(),{onMouseMove(){A.set("allowMouseEnter",!0)}},S);return delete a.role,a},[ah,A,S]),am=r.useMemo(()=>{let a=ak();if(!a)return a;let b=(0,gh.mergeProps)(a,S);return delete b.role,delete b["aria-controls"],b},[ak,S]),an=r.useMemo(()=>ai({onMouseMove(){A.set("allowMouseEnter",!0),"menu"===L.type&&A.set("hoverEnabled",!1)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(a){let b=A.select("keyboardEventRelay");b&&!a.isPropagationStopped()&&b(a)}}),[ai,L.type,A]),ao=r.useMemo(()=>aj(),[aj]);A.useSyncedValues({floatingRootContext:_,activeTriggerProps:al,inactiveTriggerProps:am,popupProps:an,itemProps:ao});let ap=r.useMemo(()=>({store:A,parent:z}),[A,z]),aq=(0,q.jsx)(f1.Provider,{value:ap,children:"function"==typeof d?d({payload:N}):d});return void 0===L.type||"context-menu"===L.type?(0,q.jsx)(gP.FloatingTree,{externalTree:B,children:aq}):aq});var hD=a.i(35112),hE=a.i(7813),hF=a.i(58240),hG=a.i(9236);let hH=gi.isMac&&gi.isSafari;var hI=a.i(24629),hJ=a.i(81751),hK=a.i(29975);function hL(a){let{render:b,className:c,state:d=g7.EMPTY_OBJECT,props:e=g7.EMPTY_ARRAY,refs:f=g7.EMPTY_ARRAY,metadata:g,stateAttributesMapping:h,tag:i="div",...j}=a,{compositeProps:k,compositeRef:l}=function(a={}){let{highlightItemOnHover:b,highlightedIndex:c,onHighlightedIndexChange:d}=(0,hK.useCompositeRootContext)(),{ref:e,index:f}=gp(a),g=c===f,h=r.useRef(null),i=(0,gf.useMergedRefs)(e,h);return{compositeProps:r.useMemo(()=>({tabIndex:g?0:-1,onFocus(){d(f)},onMouseMove(){let a=h.current;if(!b||!a)return;let c=a.hasAttribute("disabled")||"true"===a.ariaDisabled;g||c||a.focus()}}),[g,d,f,b]),compositeRef:i,index:f}}({metadata:g});return(0,f3.useRenderElement)(i,a,{state:d,ref:[...f,l],props:[k,...e,j],stateAttributesMapping:h})}var hM=a.i(25839);let hN=(0,g8.fastComponentRef)(function(a,b){let c,d,e,{render:f,className:g,disabled:h=!1,nativeButton:i=!0,id:j,openOnHover:k,delay:l=100,closeDelay:m=0,handle:n,payload:o,...p}=a,s=f2(!0),u=n?.store??s?.store;if(!u)throw Error((0,f$.default)(85));let v=(0,gq.useBaseUiId)(j),w=u.useState("isTriggerActive",v),x=u.useState("floatingRootContext"),y=u.useState("isOpenedByTrigger",v),z=r.useRef(null),A=(c=f8(!0),d=f2(!0),e=hp(!0),r.useMemo(()=>e?{type:"menubar",context:e}:c&&!d?{type:"context-menu",context:c}:{type:void 0},[c,d,e])),B=(0,hK.useCompositeRootContext)(!0),C=(0,gP.useFloatingTree)(),D=r.useMemo(()=>C??new hu.FloatingTreeStore,[C]),E=(0,gP.useFloatingNodeId)(D),F=(0,gP.useFloatingParentNodeId)(),{registerTrigger:G,isMountedByThisTrigger:H}=(0,hz.useTriggerDataForwarding)(v,z,u,{payload:o,closeDelay:m,parent:A,floatingTreeRoot:D,floatingNodeId:E,floatingParentNodeId:F,keyboardEventRelay:B?.relayKeyboardEvent}),I="menubar"===A.type,J=u.useState("disabled"),K=h||J||I&&A.context.disabled,{getButtonProps:L,buttonRef:M}=(0,gg.useButton)({disabled:K,native:i});r.useEffect(()=>{y||void 0!==A.type||(u.context.allowMouseUpTriggerRef.current=!1)},[u,y,A.type]);let N=r.useRef(null),O=(0,gO.useTimeout)(),P=(0,gc.useStableCallback)(a=>{if(!N.current)return;O.clear(),u.context.allowMouseUpTriggerRef.current=!1;let b=a.target;if((0,he.contains)(N.current,b)||(0,he.contains)(u.select("positionerElement"),b)||b===N.current||null!=b&&function a(b){return(0,hb.isHTMLElement)(b)&&b.hasAttribute("data-rootownerid")?b.getAttribute("data-rootownerid")??void 0:(0,hb.isLastTraversableNode)(b)?void 0:a((0,hb.getParentNode)(b))}(b)===u.select("rootId"))return;let c=function(a){let b=a.getBoundingClientRect(),c=window.getComputedStyle(a,"::before"),d=window.getComputedStyle(a,"::after");if("none"===c.content&&"none"===d.content)return b;let e=parseFloat(c.width)||0,f=parseFloat(c.height)||0,g=parseFloat(d.width)||0,h=parseFloat(d.height)||0,i=Math.max(b.width,e,g),j=Math.max(b.height,f,h),k=i-b.width,l=j-b.height;return{left:b.left-k/2,right:b.right+k/2,top:b.top-l/2,bottom:b.bottom+l/2}}(N.current);a.clientX>=c.left-2&&a.clientX<=c.right+2&&a.clientY>=c.top-2&&a.clientY<=c.bottom+2||D.events.emit("close",{domEvent:a,reason:f9.REASONS.cancelOpen})});r.useEffect(()=>{y&&u.select("lastOpenChangeReason")===f9.REASONS.triggerHover&&(0,hd.ownerDocument)(N.current).addEventListener("mouseup",P,{once:!0})},[y,P,u]);let Q=I&&A.context.hasSubmenuOpen,R=k??Q,S=(0,hI.useHoverReferenceInteraction)(x,{enabled:R&&!K&&"context-menu"!==A.type&&(!I||Q&&!H),handleClose:(0,hE.safePolygon)({blockPointerEvents:!I}),mouseOnly:!0,move:!1,restMs:void 0===A.type?l:void 0,delay:{close:m},triggerElementRef:z,externalTree:D,isActiveTrigger:w}),T=function(a,b){let c=(0,gO.useTimeout)(),[d,e]=r.useState(!1);return(0,gm.useIsoLayoutEffect)(()=>{a&&"trigger-hover"===b?(e(!0),c.start(gX.PATIENT_CLICK_THRESHOLD,()=>{e(!1)})):a||(c.clear(),e(!1))},[a,b,c]),d}(y,u.select("lastOpenChangeReason")),U=(0,hF.useClick)(x,{enabled:!K&&"context-menu"!==A.type,event:y&&I?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:void 0===A.type&&T}),V=function(a,b={}){let c="rootStore"in a?a.rootStore:a,{events:d,dataRef:e}=c.context,{enabled:f=!0,delay:g}=b,h=r.useRef(!1),i=r.useRef(null),j=(0,gO.useTimeout)(),k=r.useRef(!0);r.useEffect(()=>{let a=c.select("domReferenceElement");if(!f)return;let b=(0,hb.getWindow)(a);function d(){let a=c.select("domReferenceElement");!c.select("open")&&(0,hb.isHTMLElement)(a)&&a===(0,he.activeElement)((0,hd.ownerDocument)(a))&&(h.current=!0)}function e(){k.current=!0}function g(){k.current=!1}return b.addEventListener("blur",d),hH&&(b.addEventListener("keydown",e,!0),b.addEventListener("pointerdown",g,!0)),()=>{b.removeEventListener("blur",d),hH&&(b.removeEventListener("keydown",e,!0),b.removeEventListener("pointerdown",g,!0))}},[c,f]),r.useEffect(()=>{if(f)return d.on("openchange",a),()=>{d.off("openchange",a)};function a(a){if(a.reason===f9.REASONS.triggerPress||a.reason===f9.REASONS.escapeKey){let a=c.select("domReferenceElement");(0,hb.isElement)(a)&&(i.current=a,h.current=!0)}}},[d,f,c]);let l=r.useMemo(()=>({onMouseLeave(){h.current=!1,i.current=null},onFocus(a){let b=a.currentTarget;if(h.current){if(i.current===b)return;h.current=!1,i.current=null}let d=(0,he.getTarget)(a.nativeEvent);if((0,hb.isElement)(d)){if(hH&&!a.relatedTarget){if(!k.current&&!(0,he.isTypeableElement)(d))return}else if(!(0,he.matchesFocusVisible)(d))return}let e=(0,he.isTargetInsideEnabledTrigger)(a.relatedTarget,c.context.triggerElements),{nativeEvent:f,currentTarget:l}=a,m="function"==typeof g?g():g;c.select("open")&&e||0===m||void 0===m?c.setOpen(!0,(0,gt.createChangeEventDetails)(f9.REASONS.triggerFocus,f,l)):j.start(m,()=>{h.current||c.setOpen(!0,(0,gt.createChangeEventDetails)(f9.REASONS.triggerFocus,f,l))})},onBlur(a){h.current=!1,i.current=null;let b=a.relatedTarget,d=a.nativeEvent,f=(0,hb.isElement)(b)&&b.hasAttribute((0,hG.createAttribute)("focus-guard"))&&"outside"===b.getAttribute("data-type");j.start(0,()=>{let a=c.select("domReferenceElement"),g=(0,he.activeElement)(a?a.ownerDocument:document);if(!b&&g===a||(0,he.contains)(e.current.floatingContext?.refs.floating.current,g)||(0,he.contains)(a,g)||f)return;let h=b??g;(0,he.isTargetInsideEnabledTrigger)(h,c.context.triggerElements)||c.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.triggerFocus,d))})}}),[e,c,j,g]);return r.useMemo(()=>f?{reference:l,trigger:l}:{},[f,l])}(x,{enabled:!K&&Q}),W=function(a){let{enabled:b=!0,mouseDownAction:c,open:d}=a,e=r.useRef(!1);return r.useMemo(()=>b?{onMouseDown:a=>{("open"===c&&!d||"close"===c&&d)&&(e.current=!0,(0,hd.ownerDocument)(a.currentTarget).addEventListener("click",()=>{e.current=!1},{once:!0}))},onClick:a=>{e.current&&(e.current=!1,a.preventBaseUIHandler())}}:g7.EMPTY_OBJECT,[b,c,d])}({open:y,enabled:I,mouseDownAction:"open"}),X=(0,ha.useInteractions)([U,V]),Y={disabled:K,open:y},Z=u.useState("triggerProps",H),$=[N,b,M,G,z],_=[X.getReferenceProps(),S??g7.EMPTY_OBJECT,Z,{"aria-haspopup":"menu",id:v,onMouseDown:a=>{u.select("open")||(O.start(200,()=>{u.context.allowMouseUpTriggerRef.current=!0}),(0,hd.ownerDocument)(a.currentTarget).addEventListener("mouseup",P,{once:!0}))}},I?{role:"menuitem"}:{},W,p,L],aa=r.useRef(null),ab=(0,gc.useStableCallback)(a=>{hD.flushSync(()=>{u.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.focusOut,a.nativeEvent,a.currentTarget))});let b=(0,hJ.getTabbableBeforeElement)(aa.current);b?.focus()}),ac=(0,gc.useStableCallback)(a=>{let b=u.select("positionerElement");if(b&&(0,hJ.isOutsideEvent)(a,b))u.context.beforeContentFocusGuardRef.current?.focus();else{hD.flushSync(()=>{u.setOpen(!1,(0,gt.createChangeEventDetails)(f9.REASONS.focusOut,a.nativeEvent,a.currentTarget))});let c=(0,hJ.getTabbableAfterElement)(u.context.triggerFocusTargetRef.current||z.current);for(;null!==c&&(0,he.contains)(b,c);){let a=c;if((c=(0,hJ.getNextTabbable)(c))===a)break}c?.focus()}}),ad=(0,f3.useRenderElement)("button",a,{enabled:!I,stateAttributesMapping:f4.pressableTriggerOpenStateMapping,state:Y,ref:$,props:_});return I?(0,q.jsx)(hL,{tag:"button",render:f,className:g,state:Y,refs:$,props:_,stateAttributesMapping:f4.pressableTriggerOpenStateMapping}):y?(0,q.jsxs)(r.Fragment,{children:[(0,q.jsx)(hM.FocusGuard,{ref:aa,onFocus:ab},`${v}-pre-focus-guard`),(0,q.jsx)(r.Fragment,{children:ad},v),(0,q.jsx)(hM.FocusGuard,{ref:u.context.triggerFocusTargetRef,onFocus:ac},`${v}-post-focus-guard`)]}):(0,q.jsx)(r.Fragment,{children:ad},v)});var hO=a.i(43538);let hP=((p={}).popupWidth="--popup-width",p.popupHeight="--popup-height",p),hQ={activationDirection:a=>a?{"data-activation-direction":a}:null},hR=r.forwardRef(function(a,b){let{render:c,className:d,children:e,...f}=a,{store:g}=f2(),{side:h}=f0(),i=g.useState("instantType"),{children:j,state:k}=(0,hO.usePopupViewport)({store:g,side:h,cssVars:hP,children:e}),l={activationDirection:k.activationDirection,transitioning:k.transitioning,instant:i};return(0,f3.useRenderElement)("div",a,{state:l,ref:b,props:[f,{children:j}],stateAttributesMapping:hQ})}),hS=r.forwardRef(function(a,b){let{className:c,render:d,orientation:e="horizontal",...f}=a;return(0,f3.useRenderElement)("div",a,{state:{orientation:e},ref:b,props:[{role:"separator","aria-orientation":e},f]})}),hT=r.forwardRef(function(a,b){let{render:c,className:d,label:e,id:f,nativeButton:g=!1,openOnHover:h=!0,delay:i=100,closeDelay:j=0,disabled:k=!1,...l}=a,m=gp(),n=f0(),{store:o}=f2(),p=(0,gq.useBaseUiId)(f),q=o.useState("open"),s=o.useState("floatingRootContext"),u=o.useState("floatingTreeRoot"),v=(0,hz.useTriggerRegistration)(p,o),w=r.useCallback(a=>{let b=v(a);return null!==a&&o.select("open")&&null==o.select("activeTriggerId")&&o.update({activeTriggerId:p,activeTriggerElement:a,closeDelay:j}),b},[v,j,o,p]),x=r.useRef(null),y=r.useCallback(a=>{x.current=a,o.set("activeTriggerElement",a)},[o]),z=hB();if(!z?.parentMenu)throw Error((0,f$.default)(37));o.useSyncedValue("closeDelay",j);let A=z.parentMenu,B=A.useState("itemProps"),C=A.useState("isActive",m.index),D=r.useMemo(()=>({type:"submenu-trigger",setActive(){A.set("activeIndex",m.index)}}),[A,m.index]),E=o.useState("disabled"),F=k||E,{getItemProps:G,itemRef:H}=gl({closeOnClick:!1,disabled:F,highlighted:C,id:p,store:o,typingRef:A.context.typingRef,nativeButton:g,itemMetadata:D,nodeId:n?.nodeId}),I=o.useState("hoverEnabled"),J=A.useState("allowMouseEnter"),K=(0,hI.useHoverReferenceInteraction)(s,{enabled:I&&h&&!F,handleClose:(0,hE.safePolygon)({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:i,delay:J?{open:i,close:j}:0,triggerElementRef:x,externalTree:u}),L=(0,hF.useClick)(s,{enabled:!F,event:"mousedown",toggle:!h,ignoreMouse:h,stickIfOpen:!1}),M=(0,ha.useInteractions)([L]),N=o.useState("triggerProps",!0);return delete N.id,(0,f3.useRenderElement)("div",a,{state:{disabled:F,highlighted:C,open:q},stateAttributesMapping:f4.triggerOpenStateMapping,props:[M.getReferenceProps(),K,N,B,{tabIndex:q||C?0:-1,onBlur(){C&&A.set("activeIndex",null)}},l,G],ref:[b,m.ref,H,w,y]})});class hU{constructor(){this.store=new hy}open(a){let b=a?this.store.context.triggerElements.getById(a):void 0;if(a&&!b)throw Error((0,f$.default)(83,a));this.store.setOpen(!0,(0,gt.createChangeEventDetails)("imperative-action",void 0,b))}close(){this.store.setOpen(!1,(0,gt.createChangeEventDetails)("imperative-action",void 0,void 0))}get isOpen(){return this.store.state.open}}a.s(["Arrow",0,f5,"Backdrop",0,gb,"CheckboxItem",0,gu,"CheckboxItemIndicator",0,gx,"Group",0,gz,"GroupLabel",0,gA,"Handle",0,hU,"Item",0,gB,"LinkItem",0,gC,"Popup",0,gJ,"Portal",0,gM,"Positioner",0,g$,"RadioGroup",0,g0,"RadioItem",0,g2,"RadioItemIndicator",0,g3,"Root",0,hC,"Separator",0,hS,"SubmenuRoot",0,function(a){let b=f2().store,c=r.useMemo(()=>({parentMenu:b}),[b]);return(0,q.jsx)(hA.Provider,{value:c,children:(0,q.jsx)(hC,{...a})})},"SubmenuTrigger",0,hT,"Trigger",0,hN,"Viewport",0,hR,"createHandle",0,function(){return new hU}],74483);var hV=a.i(74483),hV=hV;function hW({...a}){return(0,q.jsx)(hV.Root,{"data-slot":"dropdown-menu",...a})}function hX({...a}){return(0,q.jsx)(hV.Trigger,{"data-slot":"dropdown-menu-trigger",...a})}function hY({align:a="start",alignOffset:b=0,side:c="bottom",sideOffset:d=4,className:e,...f}){return(0,q.jsx)(hV.Portal,{children:(0,q.jsx)(hV.Positioner,{className:"isolate z-50 outline-none",align:a,alignOffset:b,side:c,sideOffset:d,children:(0,q.jsx)(hV.Popup,{"data-slot":"dropdown-menu-content",className:(0,fU.cn)("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",e),...f})})})}function hZ({className:a,inset:b,variant:c="default",...d}){return(0,q.jsx)(hV.Item,{"data-slot":"dropdown-menu-item","data-inset":b,"data-variant":c,className:(0,fU.cn)("group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:*:[svg]:text-destructive",a),...d})}function h$({className:a,...b}){return(0,q.jsx)(hV.Separator,{"data-slot":"dropdown-menu-separator",className:(0,fU.cn)("-mx-1 my-1 h-px bg-border/50",a),...b})}a.i(11989),a.i(6406),a.s(["default",0,function({params:a}){let{id:b}=(0,r.use)(a),c=(0,s.useRouter)(),d=(0,F.useToast)(),[e,f]=(0,r.useState)(null),[g,h]=(0,r.useState)(!0),[i,j]=(0,r.useState)([]),[k,l]=(0,r.useState)(),[m,n]=(0,r.useState)(!0),[o,p]=(0,r.useState)(!1),[v,I]=(0,r.useState)(!1),[J,K]=(0,r.useState)(!0),L=(0,r.useRef)(null);(0,G.useDocumentTitle)(e?.title),(0,H.useTaskEvents)({onTaskCreated:()=>{},onTaskUpdated:a=>{a.id===b&&f(a)},onTaskDeleted:a=>{a===b&&(d.info("Task deleted",e?.title??void 0),c.push("/"))}});let M=(0,r.useCallback)(()=>{fetch((0,C.apiUrl)(`/api/tasks/${b}/read`),{method:"POST"}).catch(()=>{})},[b]),N=(0,r.useCallback)((a,b)=>{("success"===b||"failure"===b||"error"===b)&&M()},[M]),O=(0,r.useRef)(null),P=(0,r.useCallback)(async()=>{if(null!==O.current&&O.current!==b&&K(!0),O.current=b,J){n(!0);try{let a=await fetch((0,C.apiUrl)(`/api/tasks/${b}`));if(!a.ok)throw Error("Failed to fetch task");let c=await a.json(),d=c.data.task,e=d.tabs||[];f(d),h(c.data.worktreeExists),j(e),e.length>0&&l(e[0].tab_id),M()}catch(a){console.error("Failed to load data:",a)}finally{n(!1),K(!1)}}},[b,J,M]);(0,r.useEffect)(()=>{P()},[b,P]);let S=async(a,b)=>{let c=d.loading("Updating task...");try{let e=await fetch((0,C.apiUrl)(`/api/tasks/${a}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!e.ok)throw Error("Failed to update task");let g=await e.json();return f(g.data.task),d.success(c,"Successfully updated task"),{success:!0}}catch(b){console.error("Failed to update task:",b);let a=b instanceof Error?b.message:"Failed to update task";return d.error(c,"Failed to update task",a),{success:!1,errors:[{field:"global",message:"Failed to update task"}]}}},T=async(a="claude")=>{try{let c=await fetch((0,C.apiUrl)(`/api/tasks/${b}/tabs`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:a})});if(!c.ok)throw Error("Failed to create tab");let d=(await c.json()).data.tab;return j(a=>a.some(a=>a.tab_id===d.tab_id)?a:[...a,d]),l(d.tab_id),d.tab_id}catch(a){console.error("Failed to create tab:",a);return}},U=async a=>{try{if(!(await fetch((0,C.apiUrl)(`/api/tasks/${b}/tabs/${a}`),{method:"DELETE"})).ok)throw Error("Failed to delete tab");if(j(b=>b.filter(b=>b.tab_id!==a)),k===a){let b=i.filter(b=>b.tab_id!==a);l(b[0]?.tab_id)}}catch(a){console.error("Failed to delete tab:",a)}},V=async()=>{if(!e)return;let a=d.loading("Opening terminal...",e.worktreePath);try{if(!(await fetch((0,C.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"terminal",owner:e.owner,repo:e.repo,branch:e.branch})})).ok)throw Error("Command execution failed");d.success(a,"Successfully opened terminal",e.worktreePath)}catch(c){let b=c instanceof Error?c.message:"Unknown error";d.error(a,"Failed to open terminal",b)}},W=async()=>{if(!e)return;let a=d.loading("Opening VS Code...",e.worktreePath);try{if(!(await fetch((0,C.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"vscode",owner:e.owner,repo:e.repo,branch:e.branch})})).ok)throw Error("Command execution failed");d.success(a,"Successfully opened VS Code",e.worktreePath)}catch(c){let b=c instanceof Error?c.message:"Unknown error";d.error(a,"Failed to open VS Code",b)}};return m&&!e?(0,q.jsx)("div",{className:"h-screen flex items-center justify-center bg-background",children:(0,q.jsx)(E.LoadingSpinner,{size:"lg",message:"Loading task..."})}):e?(0,q.jsxs)("div",{className:"h-screen flex flex-col bg-background",children:[(0,q.jsx)("div",{className:"sticky top-0 z-50 p-4 border-b border-border bg-card",children:(0,q.jsxs)("div",{className:"flex items-center justify-between",children:[(0,q.jsxs)(R.Button,{variant:"ghost",onClick:()=>c.push("/"),className:"text-primary font-medium hover:bg-primary/10 hover:text-foreground",children:[(0,q.jsx)(u.ArrowLeft,{className:"w-4 h-4"}),"Back to Board"]}),(0,q.jsx)("h1",{className:"text-base font-semibold text-foreground absolute left-1/2 -translate-x-1/2 max-w-[50vw] truncate",children:e.title}),(0,q.jsxs)(hW,{children:[(0,q.jsx)(hX,{render:(0,q.jsx)(R.Button,{variant:"ghost",size:"icon-lg",className:"text-primary hover:bg-primary/10 hover:text-foreground",title:"Task menu"}),children:(0,q.jsx)(x,{className:"w-5 h-5"})}),(0,q.jsxs)(hY,{align:"end",children:[(0,q.jsxs)(hZ,{onClick:()=>p(!0),children:[(0,q.jsx)(z.Pencil,{className:"w-4 h-4"}),"Detail / Edit"]}),g&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(h$,{}),(0,q.jsxs)(hZ,{onClick:V,children:[(0,q.jsx)(A,{className:"w-4 h-4"}),"Open Terminal"]}),(0,q.jsxs)(hZ,{onClick:W,children:[(0,q.jsx)(w,{className:"w-4 h-4"}),"Open VS Code"]})]}),(0,q.jsx)(h$,{}),(0,q.jsxs)(hZ,{className:"text-destructive focus:text-destructive",onClick:()=>I(!0),children:[(0,q.jsx)(B.Trash2,{className:"w-4 h-4"}),"Delete"]})]})]})]})}),(0,q.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:(0,q.jsx)("div",{className:"bg-card flex flex-col flex-1 min-h-0",children:g?(0,q.jsx)(fZ,{ref:L,task:e,tabs:i,activeTabId:k,onTabChange:l,onTabCreate:T,onTabDelete:U,onClaudeStatusChange:N}):(0,q.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6 text-center",children:[(0,q.jsx)(y,{className:"size-10 text-muted-foreground"}),(0,q.jsxs)("div",{className:"space-y-1",children:[(0,q.jsx)("p",{className:"font-medium text-foreground",children:"Worktree not found"}),(0,q.jsx)("p",{className:"text-sm text-muted-foreground break-all",children:e.worktreePath})]}),(0,q.jsxs)(R.Button,{variant:"destructive",onClick:()=>I(!0),children:[(0,q.jsx)(B.Trash2,{className:"w-4 h-4"}),"Delete Task"]})]})})}),(0,q.jsx)(D.TaskDialog,{mode:"edit",isOpen:o,onClose:()=>p(!1),task:e,onUpdate:S}),(0,q.jsx)(Q.ConfirmDialog,{open:v,onOpenChange:a=>I(a.open),title:"Delete Task",message:`Delete task "${e.title}"?
22
22
 
23
23
  This will also delete the worktree and branch.`,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{if(!e)return;let a=d.loading("Deleting task...",e.title);fetch((0,C.apiUrl)(`/api/tasks/${e.id}`),{method:"DELETE"}).then(()=>{d.success(a,"Successfully deleted task",e.title)}).catch(b=>{let c=b instanceof Error?b.message:"Unknown error";d.error(a,"Failed to delete task",c)}),c.push("/")},variant:"danger"})]}):(0,q.jsx)("div",{className:"h-screen flex items-center justify-center bg-background",children:(0,q.jsx)("div",{className:"text-center text-foreground",children:"Task not found"})})}],81814)}];
24
24