quadwork 1.15.0 → 1.15.1

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 (69) hide show
  1. package/README.md +1 -0
  2. package/out/404.html +1 -1
  3. package/out/__next.__PAGE__.txt +1 -1
  4. package/out/__next._full.txt +2 -2
  5. package/out/__next._head.txt +1 -1
  6. package/out/__next._index.txt +2 -2
  7. package/out/__next._tree.txt +2 -2
  8. package/out/_next/static/chunks/0-w6bd-n2t2n~.css +2 -0
  9. package/out/_next/static/chunks/{0crp2e6jp_uau.js → 0a-o_h2xhfjpa.js} +19 -15
  10. package/out/_next/static/chunks/{136v4hoh5wgyv.js → 0b0p-uvdx~p32.js} +1 -1
  11. package/out/_not-found/__next._full.txt +2 -2
  12. package/out/_not-found/__next._head.txt +1 -1
  13. package/out/_not-found/__next._index.txt +2 -2
  14. package/out/_not-found/__next._not-found.__PAGE__.txt +1 -1
  15. package/out/_not-found/__next._not-found.txt +1 -1
  16. package/out/_not-found/__next._tree.txt +2 -2
  17. package/out/_not-found.html +1 -1
  18. package/out/_not-found.txt +2 -2
  19. package/out/app-shell/__next._full.txt +2 -2
  20. package/out/app-shell/__next._head.txt +1 -1
  21. package/out/app-shell/__next._index.txt +2 -2
  22. package/out/app-shell/__next._tree.txt +2 -2
  23. package/out/app-shell/__next.app-shell.__PAGE__.txt +1 -1
  24. package/out/app-shell/__next.app-shell.txt +1 -1
  25. package/out/app-shell.html +1 -1
  26. package/out/app-shell.txt +2 -2
  27. package/out/index.html +1 -1
  28. package/out/index.txt +2 -2
  29. package/out/project/_/__next._full.txt +3 -3
  30. package/out/project/_/__next._head.txt +1 -1
  31. package/out/project/_/__next._index.txt +2 -2
  32. package/out/project/_/__next._tree.txt +2 -2
  33. package/out/project/_/__next.project.$d$id.__PAGE__.txt +2 -2
  34. package/out/project/_/__next.project.$d$id.txt +1 -1
  35. package/out/project/_/__next.project.txt +1 -1
  36. package/out/project/_/queue/__next._full.txt +2 -2
  37. package/out/project/_/queue/__next._head.txt +1 -1
  38. package/out/project/_/queue/__next._index.txt +2 -2
  39. package/out/project/_/queue/__next._tree.txt +2 -2
  40. package/out/project/_/queue/__next.project.$d$id.queue.__PAGE__.txt +1 -1
  41. package/out/project/_/queue/__next.project.$d$id.queue.txt +1 -1
  42. package/out/project/_/queue/__next.project.$d$id.txt +1 -1
  43. package/out/project/_/queue/__next.project.txt +1 -1
  44. package/out/project/_/queue.html +1 -1
  45. package/out/project/_/queue.txt +2 -2
  46. package/out/project/_.html +1 -1
  47. package/out/project/_.txt +3 -3
  48. package/out/settings/__next._full.txt +2 -2
  49. package/out/settings/__next._head.txt +1 -1
  50. package/out/settings/__next._index.txt +2 -2
  51. package/out/settings/__next._tree.txt +2 -2
  52. package/out/settings/__next.settings.__PAGE__.txt +1 -1
  53. package/out/settings/__next.settings.txt +1 -1
  54. package/out/settings.html +1 -1
  55. package/out/settings.txt +2 -2
  56. package/out/setup/__next._full.txt +2 -2
  57. package/out/setup/__next._head.txt +1 -1
  58. package/out/setup/__next._index.txt +2 -2
  59. package/out/setup/__next._tree.txt +2 -2
  60. package/out/setup/__next.setup.__PAGE__.txt +1 -1
  61. package/out/setup/__next.setup.txt +1 -1
  62. package/out/setup.html +1 -1
  63. package/out/setup.txt +2 -2
  64. package/package.json +1 -1
  65. package/server/index.js +23 -13
  66. package/out/_next/static/chunks/0yjmb1lbyzaa1.css +0 -2
  67. /package/out/_next/static/{yi31oGNueSNboTtRFQmfN → 7Y5Zum_zXjQUpxhbLu7IY}/_buildManifest.js +0 -0
  68. /package/out/_next/static/{yi31oGNueSNboTtRFQmfN → 7Y5Zum_zXjQUpxhbLu7IY}/_clientMiddlewareManifest.js +0 -0
  69. /package/out/_next/static/{yi31oGNueSNboTtRFQmfN → 7Y5Zum_zXjQUpxhbLu7IY}/_ssgManifest.js +0 -0
@@ -1,32 +1,36 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26568,(e,i,r)=>{"use strict";var s=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,o=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,h=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}i.exports=function(e,i){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];i=i||{};var r=1,d=1;function f(e){var i=e.match(n);i&&(r+=i.length);var s=e.lastIndexOf("\n");d=~s?e.length-s:d+e.length}function p(){var e={line:r,column:d};return function(i){return i.position=new _(e),g(o),i}}function _(e){this.start=e,this.end={line:r,column:d},this.source=i.source}function m(s){var n=Error(i.source+":"+r+":"+d+": "+s);if(n.reason=s,n.filename=i.source,n.line=r,n.column=d,n.source=e,i.silent);else throw n}function g(i){var r=i.exec(e);if(r){var s=r[0];return f(s),e=e.slice(s.length),r}}function v(e){var i;for(e=e||[];i=x();)!1!==i&&e.push(i);return e}function x(){var i=p();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return m("End of comment missing");var s=e.slice(2,r-2);return d+=2,f(s),e=e.slice(r),d+=2,i({type:"comment",comment:s})}}_.prototype.content=e,g(o);var b,y=[];for(v(y);b=function(){var e=p(),i=g(a);if(i){if(x(),!g(l))return m("property missing ':'");var r=g(h),n=e({type:"declaration",property:u(i[0].replace(s,"")),value:r?u(r[0].replace(s,"")):""});return g(c),n}}();)!1!==b&&(y.push(b),v(y));return y}},70454,(e,i,r)=>{"use strict";var s=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,i){let r=null;if(!e||"string"!=typeof e)return r;let s=(0,n.default)(e),o="function"==typeof i;return s.forEach(e=>{if("declaration"!==e.type)return;let{property:s,value:n}=e;o?i(s,n,e):n&&((r=r||{})[s]=n)}),r};let n=s(e.r(26568))},65185,(e,i,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.camelCase=void 0;var s=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,o=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,h=function(e,i){return i.toUpperCase()},c=function(e,i){return"".concat(i,"-")};r.camelCase=function(e,i){var r;return(void 0===i&&(i={}),!(r=e)||o.test(r)||s.test(r))?e:(e=e.toLowerCase(),(e=i.reactCompat?e.replace(l,c):e.replace(a,c)).replace(n,h))}},15511,(e,i,r)=>{"use strict";var s=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(70454)),n=e.r(65185);function o(e,i){var r={};return e&&"string"==typeof e&&(0,s.default)(e,function(e,s){e&&s&&(r[(0,n.camelCase)(e,i)]=s)}),r}o.default=o,i.exports=o},4100,(e,i,r)=>{"use strict";var s=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},h=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var i,r=s.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&s.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!o)return!1;for(i in e);return void 0===i||s.call(e,i)},c=function(e,i){o&&"__proto__"===i.name?o(e,i.name,{enumerable:!0,configurable:!0,value:i.newValue,writable:!0}):e[i.name]=i.newValue},d=function(e,i){if("__proto__"===i){if(!s.call(e,i))return;else if(a)return a(e,i).value}return e[i]};i.exports=function e(){var i,r,s,n,o,a,u=arguments[0],f=1,p=arguments.length,_=!1;for("boolean"==typeof u&&(_=u,u=arguments[1]||{},f=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});f<p;++f)if(i=arguments[f],null!=i)for(r in i)s=d(u,r),u!==(n=d(i,r))&&(_&&n&&(h(n)||(o=l(n)))?(o?(o=!1,a=s&&l(s)?s:[]):a=s&&h(s)?s:{},c(u,{name:r,newValue:e(_,a,n)})):void 0!==n&&c(u,{name:r,newValue:n}));return u}},55601,e=>{"use strict";let i,r,s,n,o,a,l,h,c,d,u,f;var p=e.i(43476),_=e.i(71645);function m({label:e,status:i,projectId:r,agentId:s,onStatusChange:n,tooltip:o,children:a}){let l="running"===i?"bg-accent":"error"===i?"bg-error":"bg-text-muted",h=e=>{r&&s&&fetch(`/api/agents?project=${encodeURIComponent(r)}&agent=${encodeURIComponent(s)}&action=${e}`,{method:"POST"}).then(e=>e.json()).then(e=>{n&&e.state&&n(e.state)}).catch(()=>{})};return(0,p.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 h-7 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[i&&(0,p.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${l}`}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:e}),o]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[a,r&&s&&(0,p.jsxs)(p.Fragment,{children:["running"!==i&&(0,p.jsx)("button",{onClick:()=>h("start"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Start",children:"▶"}),"running"===i&&(0,p.jsx)("button",{onClick:()=>h("stop"),className:"text-[10px] text-text-muted hover:text-error transition-colors px-1",title:"Stop",children:"■"}),(0,p.jsx)("button",{onClick:()=>h("restart"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Restart",children:"↻"})]})]})]})}function g({children:e,position:i="below"}){let[r,s]=(0,_.useState)(!1),n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!r)return;let e=e=>{n.current&&!n.current.contains(e.target)&&s(!1)},i=e=>{"Escape"===e.key&&s(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",i)}},[r]),(0,p.jsxs)("div",{ref:n,className:"relative inline-flex items-center",children:[(0,p.jsx)("button",{type:"button",onClick:()=>s(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),r&&(0,p.jsx)("div",{className:`absolute left-0 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg ${"above"===i?"bottom-5":"top-5"}`,children:e})]})}var v=e.i(78759),x=e.i(52368);let b={en:{ready:"Ready when you are",tell:"Tell your team what to build. Try something like:",howToWork:"How to Work",examples:["@head start a new feature: <describe>","@head review the latest PR","@head what's our current sprint?"]},ko:{ready:"언제든지 시작하세요",tell:"팀에게 무엇을 만들지 말해보세요. 예를 들어:",howToWork:"사용 방법",examples:["@head 새로운 기능 시작: <설명>","@head 최신 PR 리뷰해줘","@head 현재 스프린트 상황이 어때?"]}};function y({onInsert:e}){let{locale:i}=(0,x.useLocale)(),r=b[i],[s,n]=(0,_.useState)(!1);return(0,p.jsxs)("div",{className:"flex flex-col items-center justify-center text-center px-6 py-10 gap-3",children:[(0,p.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none","aria-hidden":!0,className:"text-accent",children:[(0,p.jsx)("path",{d:"M6 8h28a2 2 0 0 1 2 2v17a2 2 0 0 1-2 2H16l-7 6v-6h-3a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2Z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),(0,p.jsx)("circle",{cx:"14",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"20",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"26",cy:"18",r:"1.4",fill:"currentColor"})]}),(0,p.jsx)("div",{className:"text-[13px] font-semibold text-text",children:r.ready}),(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:r.tell}),(0,p.jsx)("div",{className:"flex flex-col gap-1.5 mt-1 w-full max-w-sm",children:r.examples.map(i=>(0,p.jsx)("button",{type:"button",onClick:()=>e(i),className:"text-left px-2 py-1 text-[11px] font-mono text-text-muted border border-border hover:text-accent hover:border-accent transition-colors truncate",children:i},i))}),(0,p.jsx)("button",{type:"button",onClick:()=>n(!0),className:"mt-2 text-[11px] text-text-muted underline underline-offset-2 hover:text-text",children:r.howToWork}),(0,p.jsx)(v.default,{open:s,onClose:()=>n(!1)})]})}let S={head:"#00ff88",re1:"#4488ff",re2:"#cc44ff",dev:"#ffcc00",user:"#e0e0e0",system:"#737373"},w=["head","re1","re2","dev","user"],C=[/^.+ is online$/,/disconnected \(timeout\)/,/^.+ disconnected$/,/auto-recovered/,/Resuming agent conversation/,/Loop guard:/],k=[{command:"/artchallenge",description:"SVG art challenge — all agents create artwork (optional theme)"},{command:"/hatmaking",description:"All agents design a hat to wear on their avatar"},{command:"/roastreview",description:"Get all agents to review and roast each other's work"},{command:"/poetry haiku",description:"Agents write a haiku about the codebase"},{command:"/poetry limerick",description:"Agents write a limerick about the codebase"},{command:"/poetry sonnet",description:"Agents write a sonnet about the codebase"},{command:"/summary",description:"Summarize recent messages — tag an agent (e.g. /summary @head)"},{command:"/continue",description:"Resume after loop guard pauses"},{command:"/clear",description:"Clear messages in current channel"}];function E(e){return S[e.toLowerCase()]||"#e0e0e0"}let N=/(^|\s)(@(?:head|dev|re1|re2|user))(?![\w-])/gi;function R({projectId:e,filterSystem:i}){return(0,p.jsx)(j,{projectId:e,filterSystem:i})}function j({projectId:e,filterSystem:i=!1}){let r="general",[s,n]=(0,_.useState)([]),[o,a]=(0,_.useState)(!1),[l,h]=(0,_.useState)(""),c=(0,_.useRef)(0),d=(0,_.useRef)(null),[u,f]=(0,_.useState)(!1),[m,g]=(0,_.useState)(""),[v,x]=(0,_.useState)(!1),[b,S]=(0,_.useState)(0),[R,T]=(0,_.useState)(null),[D,M]=(0,_.useState)(null),L=(0,_.useRef)(0),P=(0,_.useRef)(null),A=(0,_.useRef)(null),B=(0,_.useRef)(!1),I=(0,_.useRef)(!0),O=(0,_.useRef)(0);(0,_.useEffect)(()=>{L.current=0,n([]),a(!1),c.current=0,d.current&&(clearTimeout(d.current),d.current=null)},[e]);let F=(0,_.useCallback)(()=>{fetch(`/api/chat?path=/api/messages&channel=${encodeURIComponent(r)}&cursor=${L.current}${e?`&project=${encodeURIComponent(e)}`:""}`).then(e=>{if(403===e.status)throw O.current<3?T(null):T("Chat authentication failed (403). Set agentchattr_token in Settings or ~/.quadwork/config.json."),Error("auth failed");if(!e.ok)throw Error(`Poll failed: ${e.status}`);return e.json()}).then(e=>{T(null);let i=Array.isArray(e)?e:e.messages||[];if(i.length>0){n(e=>{let r=new Set(e.map(e=>e.id)),s=i.filter(e=>!r.has(e.id));return s.length>0?[...e,...s]:e});let e=Math.max(...i.map(e=>e.id));e>L.current&&(L.current=e)}a(!0)}).catch(()=>{!o&&c.current<3&&(c.current+=1,d.current=setTimeout(F,2e3))})},[r,e,o]);(0,_.useEffect)(()=>{F();let e=setInterval(F,3e3);return()=>{clearInterval(e),d.current&&(clearTimeout(d.current),d.current=null)}},[F]),(0,_.useEffect)(()=>{I.current&&P.current&&(P.current.scrollTop=P.current.scrollHeight)},[s]);let[H,z]=(0,_.useState)(!1),[$,W]=(0,_.useState)(null),[U,K]=(0,_.useState)([]),[q,V]=(0,_.useState)(!1),Y=(0,_.useRef)(null),G=async i=>{if(e){V(!0);try{let r=new FormData;r.append("file",i);let s=await fetch(`/api/upload?project=${encodeURIComponent(e)}`,{method:"POST",body:r});if(!s.ok){let e=await s.json().catch(()=>({error:`${s.status}`}));W(e.error||`Upload failed: ${s.status}`);return}let n=await s.json();K(e=>[...e,{path:n.path,name:n.name}])}catch(e){W(e.message)}finally{V(!1)}}},X=e=>{for(let i of e)i.type.startsWith("image/")&&G(i)};(0,_.useEffect)(()=>{let e=A.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,120)+"px")},[l]);let J=()=>{let i=l.trim();if(!i&&0===U.length||H)return;let s=i.startsWith("/")||/^@(head|dev|re1|re2)\b/i.test(i)?i:`@head ${i}`;z(!0),W(null),fetch(`/api/chat${e?`?project=${encodeURIComponent(e)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s,channel:r,sender:"user",...U.length>0?{attachments:U}:{},...D?{reply_to:D.id}:{}})}).then(e=>{if(!e.ok)throw Error(`Send failed: ${e.status}`);h(""),K([]),M(null),setTimeout(F,300)}).catch(e=>{W(e.message),console.error(e.message)}).finally(()=>z(!1))},Q=e=>{h(l.replace(/@\w*$/,`@${e} `)),f(!1),A.current?.focus()},Z=e=>{h(e.includes(" ")?e:`${e} `),x(!1),A.current?.focus()},ee=w.filter(e=>e.toLowerCase().startsWith(m)),et=k.filter(e=>e.command.toLowerCase().startsWith(l.toLowerCase())),ei=i?s.filter(e=>!function(e){if("system"===e.sender||"join"===e.type||"leave"===e.type)return!0;for(let i of C)if(i.test(e.text))return!0;return!1}(e)):s;return(0,p.jsxs)("div",{className:"flex flex-col h-full bg-bg",children:[R&&(0,p.jsx)("div",{className:"px-3 py-2 bg-red-900/30 border-b border-red-700/50 text-[11px] text-red-400",children:R}),(0,p.jsxs)("div",{ref:P,onScroll:()=>{if(!P.current)return;let{scrollTop:e,scrollHeight:i,clientHeight:r}=P.current;I.current=i-e-r<40},className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-0.5",children:[!o&&0===s.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)("span",{className:"text-xs text-text-muted",children:"Loading messages..."})}),o&&0===ei.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)(y,{onInsert:e=>{h(e),A.current?.focus()}})}),ei.map(i=>{var r;let s;return(0,p.jsxs)("div",{className:"group flex gap-2 text-[12px] leading-5",children:[(0,p.jsx)("span",{className:"text-text-muted shrink-0 w-12 text-right tabular-nums",children:i.time?.slice(0,5)||""}),(0,p.jsx)("span",{className:"shrink-0 font-semibold w-10 text-right",style:{color:E(i.sender)},children:"re1"===(s=(r=i.sender).toLowerCase())?"RE1":"re2"===s?"RE2":r}),(0,p.jsxs)("span",{className:"text-text break-words min-w-0 whitespace-pre-wrap flex-1",children:[function(e){let i=[],r=0,s=0;for(let n of e.matchAll(N)){let o=n.index??0,a=n[1],l=n[2],h=o+a.length;h>r&&i.push(e.slice(r,h));let c=E(l.slice(1).toLowerCase());i.push((0,p.jsx)("span",{className:"inline-block px-1 py-0 rounded font-mono",style:{backgroundColor:`${c}22`,color:c},children:l},`m${s++}`)),r=h+l.length}return r<e.length&&i.push(e.slice(r)),i.length>0?i:[e]}(i.text),i.attachments&&i.attachments.length>0&&(0,p.jsx)("span",{className:"flex gap-2 mt-1",children:i.attachments.map(i=>(0,p.jsx)("a",{href:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(i.name)}`,target:"_blank",rel:"noopener noreferrer",children:(0,p.jsx)("img",{src:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(i.name)}`,alt:i.name,className:"max-w-[200px] max-h-[150px] object-cover border border-border rounded hover:border-accent transition-colors"})},i.name))})]}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(M({id:i.id,sender:i.sender}),new Set(["head","dev","re1","re2"]).has(i.sender.toLowerCase())){let e=`@${i.sender} `;h(i=>i.startsWith(e)?i:e)}A.current?.focus()},className:"shrink-0 self-start opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-[10px] text-text-muted hover:text-text px-1 py-0.5 border border-border/50 rounded",title:`Reply to message #${i.id}`,children:"reply"})]},i.id)})]}),(0,p.jsxs)("div",{className:"relative shrink-0 border-t border-border",children:[u&&ee.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 border border-border bg-bg-surface",children:ee.map(e=>(0,p.jsxs)("button",{onClick:()=>Q(e),className:"w-full text-left px-3 py-1 text-[12px] hover:bg-[#1a1a1a] transition-colors",style:{color:E(e)},children:["@",e]},e))}),v&&et.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-60 overflow-y-auto border border-border bg-bg-surface z-10",children:et.map((e,i)=>{let r=i===Math.min(b,et.length-1);return(0,p.jsxs)("button",{onClick:()=>Z(e.command),onMouseEnter:()=>S(i),className:`w-full text-left px-3 py-1 transition-colors flex items-baseline gap-2 ${r?"bg-[#1a1a1a]":"hover:bg-[#1a1a1a]"}`,children:[(0,p.jsx)("span",{className:"text-[12px] text-accent font-mono",children:e.command}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:e.description})]},e.command)})}),$&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-red-400 bg-red-900/20 border-b border-red-700/40",children:$}),D&&(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 text-[11px] text-text-muted bg-bg-surface border-b border-border/50",children:[(0,p.jsxs)("span",{children:["Replying to ",(0,p.jsxs)("span",{style:{color:E(D.sender)},children:["@",D.sender]})," #",D.id]}),(0,p.jsx)("button",{type:"button",onClick:()=>M(null),className:"ml-auto hover:text-text",title:"Cancel reply (Esc)",children:"✕"})]}),(0,p.jsxs)("div",{className:"flex items-end gap-1 px-1",children:[(0,p.jsx)("textarea",{ref:A,rows:1,value:l,onChange:e=>(e=>{h(e);let i=e.match(/@(\w*)$/);if(i){f(!0),g(i[1].toLowerCase()),x(!1);return}if(f(!1),e.startsWith("/")){let i=e.slice(1).includes(" "),r=e.startsWith("/poetry");x(!i||r),S(0)}else x(!1)})(e.target.value),onCompositionStart:()=>{B.current=!0},onCompositionEnd:()=>{B.current=!1},onKeyDown:e=>{if("Tab"===e.key&&u&&ee.length>0){e.preventDefault(),Q(ee[0]);return}if(v&&et.length>0){if("ArrowDown"===e.key){e.preventDefault(),S(e=>(e+1)%et.length);return}if("ArrowUp"===e.key){e.preventDefault(),S(e=>(e-1+et.length)%et.length);return}if("Tab"===e.key||"Enter"===e.key&&!e.shiftKey){e.preventDefault();let i=Math.min(b,et.length-1);Z(et[i].command);return}}"Enter"!==e.key||e.shiftKey||B.current||e.nativeEvent.isComposing||(e.preventDefault(),J()),"Escape"===e.key&&(f(!1),x(!1),D&&M(null))},onPaste:e=>{let i=e.clipboardData?.items;if(!i)return;let r=[];for(let e of Array.from(i))if(e.type.startsWith("image/")){let i=e.getAsFile();i&&r.push(i)}r.length>0&&(e.preventDefault(),X(r))},onDrop:e=>{let i=e.dataTransfer?.files;if(!i)return;let r=Array.from(i).filter(e=>e.type.startsWith("image/"));r.length>0&&(e.preventDefault(),X(r))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},placeholder:`Message #${r}...`,disabled:H,className:"flex-1 bg-transparent px-2 py-2 text-[12px] font-mono text-text placeholder:text-text-muted outline-none focus:ring-1 focus:ring-accent disabled:opacity-50 resize-none overflow-y-auto leading-snug",style:{maxHeight:120}}),(0,p.jsx)("input",{ref:Y,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:e=>{let i=e.target.files;i&&i.length>0&&X(Array.from(i)),e.target.value=""}}),(0,p.jsx)("button",{type:"button",onClick:()=>Y.current?.click(),disabled:q,className:"shrink-0 px-1.5 py-2 text-[13px] text-text-muted hover:text-accent transition-colors disabled:opacity-30",title:"Attach image",children:"📎"}),(0,p.jsx)("button",{onClick:J,disabled:H||!l.trim()&&0===U.length,className:"shrink-0 px-2 py-2 text-[11px] font-mono text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Send (Enter)",children:H?"…":"Send"})]}),(U.length>0||q)&&(0,p.jsxs)("div",{className:"flex gap-2 px-2 py-1 flex-wrap",children:[U.map((i,r)=>(0,p.jsxs)("div",{className:"relative group",children:[(0,p.jsx)("img",{src:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(i.name)}`,alt:i.name,className:"h-16 max-w-[200px] object-cover border border-border rounded"}),(0,p.jsx)("button",{type:"button",onClick:()=>K(e=>e.filter((e,i)=>i!==r)),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-bg border border-border rounded-full text-[10px] text-text-muted hover:text-error opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",title:"Remove",children:"×"})]},i.name)),q&&(0,p.jsx)("div",{className:"h-16 w-16 border border-border rounded flex items-center justify-center",children:(0,p.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"..."})})]})]})]})}function T(){}function D(){}let M=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P={};function A(e,i){return((i||P).jsx?L:M).test(e)}let B=/[ \t\n\f\r]/g;function I(e){return""===e.replace(B,"")}class O{constructor(e,i){this.attribute=i,this.property=e}}O.prototype.attribute="",O.prototype.booleanish=!1,O.prototype.boolean=!1,O.prototype.commaOrSpaceSeparated=!1,O.prototype.commaSeparated=!1,O.prototype.defined=!1,O.prototype.mustUseProperty=!1,O.prototype.number=!1,O.prototype.overloadedBoolean=!1,O.prototype.property="",O.prototype.spaceSeparated=!1,O.prototype.space=void 0;let F=0,H=V(),z=V(),$=V(),W=V(),U=V(),K=V(),q=V();function V(){return 2**++F}e.s(["boolean",0,H,"booleanish",0,z,"commaOrSpaceSeparated",0,q,"commaSeparated",0,K,"number",0,W,"overloadedBoolean",0,$,"spaceSeparated",0,U],744);var Y=e.i(744);let G=Object.keys(Y);class X extends O{constructor(e,i,r,s){let n=-1;if(super(e,i),function(e,i,r){r&&(e[i]=r)}(this,"space",s),"number"==typeof r)for(;++n<G.length;){const e=G[n];!function(e,i,r){r&&(e[i]=r)}(this,G[n],(r&Y[e])===Y[e])}}}function J(e){return e.toLowerCase()}X.prototype.defined=!0;let Q=/[A-Z]/g,Z=/-[a-z]/g,ee=/^data[-\w.:]+$/i;function et(e){return"-"+e.toLowerCase()}function ei(e){return e.charAt(1).toUpperCase()}let er={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class es{constructor(e,i,r){this.normal=i,this.property=e,r&&(this.space=r)}}function en(e,i){let r={},s={};for(let i of e)Object.assign(r,i.property),Object.assign(s,i.normal);return new es(r,s,i)}function eo(e){let i={},r={};for(let[s,n]of Object.entries(e.properties)){let o=new X(s,e.transform(e.attributes||{},s),n,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),i[s]=o,r[J(s)]=s,r[J(o.attribute)]=s}return new es(i,r,e.space)}es.prototype.normal={},es.prototype.property={},es.prototype.space=void 0;let ea=eo({properties:{ariaActiveDescendant:null,ariaAtomic:z,ariaAutoComplete:null,ariaBusy:z,ariaChecked:z,ariaColCount:W,ariaColIndex:W,ariaColSpan:W,ariaControls:U,ariaCurrent:null,ariaDescribedBy:U,ariaDetails:null,ariaDisabled:z,ariaDropEffect:U,ariaErrorMessage:null,ariaExpanded:z,ariaFlowTo:U,ariaGrabbed:z,ariaHasPopup:null,ariaHidden:z,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:U,ariaLevel:W,ariaLive:null,ariaModal:z,ariaMultiLine:z,ariaMultiSelectable:z,ariaOrientation:null,ariaOwns:U,ariaPlaceholder:null,ariaPosInSet:W,ariaPressed:z,ariaReadOnly:z,ariaRelevant:null,ariaRequired:z,ariaRoleDescription:U,ariaRowCount:W,ariaRowIndex:W,ariaRowSpan:W,ariaSelected:z,ariaSetSize:W,ariaSort:null,ariaValueMax:W,ariaValueMin:W,ariaValueNow:W,ariaValueText:null,role:null},transform:(e,i)=>"role"===i?i:"aria-"+i.slice(4).toLowerCase()});function el(e,i){return i in e?e[i]:i}function eh(e,i){return el(e,i.toLowerCase())}let ec=eo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:K,acceptCharset:U,accessKey:U,action:null,allow:null,allowFullScreen:H,allowPaymentRequest:H,allowUserMedia:H,alt:null,as:null,async:H,autoCapitalize:null,autoComplete:U,autoFocus:H,autoPlay:H,blocking:U,capture:null,charSet:null,checked:H,cite:null,className:U,cols:W,colSpan:null,content:null,contentEditable:z,controls:H,controlsList:U,coords:W|K,crossOrigin:null,data:null,dateTime:null,decoding:null,default:H,defer:H,dir:null,dirName:null,disabled:H,download:$,draggable:z,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:H,formTarget:null,headers:U,height:W,hidden:$,high:W,href:null,hrefLang:null,htmlFor:U,httpEquiv:U,id:null,imageSizes:null,imageSrcSet:null,inert:H,inputMode:null,integrity:null,is:null,isMap:H,itemId:null,itemProp:U,itemRef:U,itemScope:H,itemType:U,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:H,low:W,manifest:null,max:null,maxLength:W,media:null,method:null,min:null,minLength:W,multiple:H,muted:H,name:null,nonce:null,noModule:H,noValidate:H,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:H,optimum:W,pattern:null,ping:U,placeholder:null,playsInline:H,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:H,referrerPolicy:null,rel:U,required:H,reversed:H,rows:W,rowSpan:W,sandbox:U,scope:null,scoped:H,seamless:H,selected:H,shadowRootClonable:H,shadowRootDelegatesFocus:H,shadowRootMode:null,shape:null,size:W,sizes:null,slot:null,span:W,spellCheck:z,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W,step:null,style:null,tabIndex:W,target:null,title:null,translate:null,type:null,typeMustMatch:H,useMap:null,value:z,width:W,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:U,axis:null,background:null,bgColor:null,border:W,borderColor:null,bottomMargin:W,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:H,declare:H,event:null,face:null,frame:null,frameBorder:null,hSpace:W,leftMargin:W,link:null,longDesc:null,lowSrc:null,marginHeight:W,marginWidth:W,noResize:H,noHref:H,noShade:H,noWrap:H,object:null,profile:null,prompt:null,rev:null,rightMargin:W,rules:null,scheme:null,scrolling:z,standby:null,summary:null,text:null,topMargin:W,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:H,disableRemotePlayback:H,prefix:null,property:null,results:W,security:null,unselectable:null},space:"html",transform:eh}),ed=eo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:q,accentHeight:W,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W,amplitude:W,arabicForm:null,ascent:W,attributeName:null,attributeType:null,azimuth:W,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W,by:null,calcMode:null,capHeight:W,className:U,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:W,diffuseConstant:W,direction:null,display:null,dur:null,divisor:W,dominantBaseline:null,download:H,dx:null,dy:null,edgeMode:null,editable:null,elevation:W,enableBackground:null,end:null,event:null,exponent:W,externalResourcesRequired:null,fill:null,fillOpacity:W,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:K,g2:K,glyphName:K,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W,horizOriginX:W,horizOriginY:W,id:null,ideographic:W,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W,k:W,k1:W,k2:W,k3:W,k4:W,kernelMatrix:q,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:W,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:W,overlineThickness:W,paintOrder:null,panose1:null,path:null,pathLength:W,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:U,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W,pointsAtY:W,pointsAtZ:W,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:q,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:q,rev:q,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:q,requiredFeatures:q,requiredFonts:q,requiredFormats:q,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:W,specularExponent:W,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W,strikethroughThickness:W,string:null,stroke:null,strokeDashArray:q,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W,strokeOpacity:W,strokeWidth:null,style:null,surfaceScale:W,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:q,tabIndex:W,tableValues:null,target:null,targetX:W,targetY:W,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:q,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W,underlineThickness:W,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W,values:null,vAlphabetic:W,vMathematical:W,vectorEffect:null,vHanging:W,vIdeographic:W,version:null,vertAdvY:W,vertOriginX:W,vertOriginY:W,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:el}),eu=eo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,i)=>"xlink:"+i.slice(5).toLowerCase()}),ef=eo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:eh}),ep=eo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,i)=>"xml:"+i.slice(3).toLowerCase()}),e_=en([ea,ec,eu,ef,ep],"html"),em=en([ea,ed,eu,ef,ep],"svg");var eg=e.i(15511);let ev=eb("end"),ex=eb("start");function eb(e){return function(i){let r=i&&i.position&&i.position[e]||{};if("number"==typeof r.line&&r.line>0&&"number"==typeof r.column&&r.column>0)return{line:r.line,column:r.column,offset:"number"==typeof r.offset&&r.offset>-1?r.offset:void 0}}}function ey(e){return e&&"object"==typeof e?"position"in e||"type"in e?ew(e.position):"start"in e||"end"in e?ew(e):"line"in e||"column"in e?eS(e):"":""}function eS(e){return eC(e&&e.line)+":"+eC(e&&e.column)}function ew(e){return eS(e&&e.start)+"-"+eS(e&&e.end)}function eC(e){return e&&"number"==typeof e?e:1}class ek extends Error{constructor(e,i,r){super(),"string"==typeof i&&(r=i,i=void 0);let s="",n={},o=!1;if(i&&(n="line"in i&&"column"in i||"start"in i&&"end"in i?{place:i}:"type"in i?{ancestors:[i],place:i.position}:{...i}),"string"==typeof e?s=e:!n.cause&&e&&(o=!0,s=e.message,n.cause=e),!n.ruleId&&!n.source&&"string"==typeof r){const e=r.indexOf(":");-1===e?n.ruleId=r:(n.source=r.slice(0,e),n.ruleId=r.slice(e+1))}if(!n.place&&n.ancestors&&n.ancestors){const e=n.ancestors[n.ancestors.length-1];e&&(n.place=e.position)}const a=n.place&&"start"in n.place?n.place.start:n.place;this.ancestors=n.ancestors||void 0,this.cause=n.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=ey(n.place)||"1:1",this.place=n.place||void 0,this.reason=this.message,this.ruleId=n.ruleId||void 0,this.source=n.source||void 0,this.stack=o&&n.cause&&"string"==typeof n.cause.stack?n.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ek.prototype.file="",ek.prototype.name="",ek.prototype.reason="",ek.prototype.message="",ek.prototype.stack="",ek.prototype.column=void 0,ek.prototype.line=void 0,ek.prototype.ancestors=void 0,ek.prototype.cause=void 0,ek.prototype.fatal=void 0,ek.prototype.place=void 0,ek.prototype.ruleId=void 0,ek.prototype.source=void 0;let eE={}.hasOwnProperty,eN=new Map,eR=/[A-Z]/g,ej=new Set(["table","tbody","thead","tfoot","tr"]),eT=new Set(["td","th"]),eD="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function eM(e,i,r){var s,n,o,a,l,h,c,d,u;let f,p,_,m,g,v,x,b,y,S,w;return"element"===i.type?(s=e,n=i,o=r,p=f=s.schema,"svg"===n.tagName.toLowerCase()&&"html"===f.space&&(s.schema=em),s.ancestors.push(n),_=eB(s,n.tagName,!1),m=function(e,i){let r,s,n={};for(s in i.properties)if("children"!==s&&eE.call(i.properties,s)){let o=function(e,i,r){let s=function(e,i){let r=J(i),s=i,n=O;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&"data"===r.slice(0,4)&&ee.test(i)){if("-"===i.charAt(4)){let e=i.slice(5).replace(Z,ei);s="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=i.slice(4);if(!Z.test(e)){let r=e.replace(Q,et);"-"!==r.charAt(0)&&(r="-"+r),i="data"+r}}n=X}return new n(s,i)}(e.schema,i);if(!(null==r||"number"==typeof r&&Number.isNaN(r))){var n;let i;if(Array.isArray(r)&&(r=s.commaSeparated?(i={},(""===(n=r)[n.length-1]?[...n,""]:n).join((i.padRight?" ":"")+","+(!1===i.padLeft?"":" ")).trim()):r.join(" ").trim()),"style"===s.property){let i="object"==typeof r?r:function(e,i){try{return(0,eg.default)(i,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};let i=new ek("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=eD+"#cannot-parse-style-attribute",i}}(e,String(r));return"css"===e.stylePropertyNameCase&&(i=function(e){let i,r={};for(i in e)eE.call(e,i)&&(r[function(e){let i=e.replace(eR,eO);return"ms-"===i.slice(0,3)&&(i="-"+i),i}(i)]=e[i]);return r}(i)),["style",i]}return["react"===e.elementAttributeNameCase&&s.space?er[s.property]||s.property:s.attribute,r]}}(e,s,i.properties[s]);if(o){let[s,a]=o;e.tableCellAlignToStyle&&"align"===s&&"string"==typeof a&&eT.has(i.tagName)?r=a:n[s]=a}}return r&&((n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r),n}(s,n),g=eA(s,n),ej.has(n.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&I(e.value):I(e))})),eL(s,m,_,n),eP(m,g),s.ancestors.pop(),s.schema=f,s.create(n,_,m,o)):"mdxFlowExpression"===i.type||"mdxTextExpression"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater){let r=i.data.estree.body[0];return T("ExpressionStatement"===r.type),e.evaluater.evaluateExpression(r.expression)}eI(e,i.position)}(e,i):"mdxJsxFlowElement"===i.type||"mdxJsxTextElement"===i.type?(a=e,l=i,h=r,x=v=a.schema,"svg"===l.name&&"html"===v.space&&(a.schema=em),a.ancestors.push(l),b=null===l.name?a.Fragment:eB(a,l.name,!0),y=function(e,i){let r={};for(let s of i.attributes)if("mdxJsxExpressionAttribute"===s.type)if(s.data&&s.data.estree&&e.evaluater){let i=s.data.estree.body[0];T("ExpressionStatement"===i.type);let n=i.expression;T("ObjectExpression"===n.type);let o=n.properties[0];T("SpreadElement"===o.type),Object.assign(r,e.evaluater.evaluateExpression(o.argument))}else eI(e,i.position);else{let n,o=s.name;if(s.value&&"object"==typeof s.value)if(s.value.data&&s.value.data.estree&&e.evaluater){let i=s.value.data.estree.body[0];T("ExpressionStatement"===i.type),n=e.evaluater.evaluateExpression(i.expression)}else eI(e,i.position);else n=null===s.value||s.value;r[o]=n}return r}(a,l),S=eA(a,l),eL(a,y,b,l),eP(y,S),a.ancestors.pop(),a.schema=v,a.create(l,b,y,h)):"mdxjsEsm"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(i.data.estree);eI(e,i.position)}(e,i):"root"===i.type?(c=e,d=i,u=r,eP(w={},eA(c,d)),c.create(d,c.Fragment,w,u)):"text"===i.type?i.value:void 0}function eL(e,i,r,s){"string"!=typeof r&&r!==e.Fragment&&e.passNode&&(i.node=s)}function eP(e,i){if(i.length>0){let r=i.length>1?i:i[0];r&&(e.children=r)}}function eA(e,i){let r=[],s=-1,n=e.passKeys?new Map:eN;for(;++s<i.children.length;){let o,a=i.children[s];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let i=n.get(e)||0;o=e+"-"+i,n.set(e,i+1)}}let l=eM(e,a,o);void 0!==l&&r.push(l)}return r}function eB(e,i,r){let s;if(r)if(i.includes(".")){let e,r=i.split("."),n=-1;for(;++n<r.length;){let i=A(r[n])?{type:"Identifier",name:r[n]}:{type:"Literal",value:r[n]};e=e?{type:"MemberExpression",object:e,property:i,computed:!!(n&&"Literal"===i.type),optional:!1}:i}T(e,"always a result"),s=e}else s=A(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};else s={type:"Literal",value:i};if("Literal"===s.type){let i=s.value;return eE.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(s);eI(e)}function eI(e,i){let r=new ek("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=eD+"#cannot-handle-mdx-estrees-without-createevaluater",r}function eO(e){return"-"+e.toLowerCase()}let eF={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},eH={};function ez(e,i,r){var s;if((s=e)&&"object"==typeof s){if("value"in e)return"html"!==e.type||r?e.value:"";if(i&&"alt"in e&&e.alt)return e.alt;if("children"in e)return e$(e.children,i,r)}return Array.isArray(e)?e$(e,i,r):""}function e$(e,i,r){let s=[],n=-1;for(;++n<e.length;)s[n]=ez(e[n],i,r);return s.join("")}function eW(e,i,r,s){let n,o=e.length,a=0;if(i=i<0?-i>o?0:o+i:i>o?o:i,r=r>0?r:0,s.length<1e4)(n=Array.from(s)).unshift(i,r),e.splice(...n);else for(r&&e.splice(i,r);a<s.length;)(n=s.slice(a,a+1e4)).unshift(i,0),e.splice(...n),a+=1e4,i+=1e4}function eU(e,i){return e.length>0?(eW(e,e.length,0,i),e):i}let eK={}.hasOwnProperty,eq=e3(/[A-Za-z]/),eV=e3(/[\dA-Za-z]/),eY=e3(/[#-'*+\--9=?A-Z^-~]/);function eG(e){return null!==e&&(e<32||127===e)}let eX=e3(/\d/),eJ=e3(/[\dA-Fa-f]/),eQ=e3(/[!-/:-@[-`{-~]/);function eZ(e){return null!==e&&e<-2}function e0(e){return null!==e&&(e<0||32===e)}function e1(e){return -2===e||-1===e||32===e}let e2=e3(/\p{P}|\p{S}/u),e5=e3(/\s/);function e3(e){return function(i){return null!==i&&i>-1&&e.test(String.fromCharCode(i))}}function e4(e,i,r,s){let n=s?s-1:1/0,o=0;return function(s){return e1(s)?(e.enter(r),function s(a){return e1(a)&&o++<n?(e.consume(a),s):(e.exit(r),i(a))}(s)):i(s)}}let e6={tokenize:function(e){let i,r=e.attempt(this.parser.constructs.contentInitial,function(i){return null===i?void e.consume(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e4(e,r,"linePrefix"))},function(r){return e.enter("paragraph"),function r(s){let n=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=n),i=n,function i(s){if(null===s){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return eZ(s)?(e.consume(s),e.exit("chunkText"),r):(e.consume(s),i)}(s)}(r)});return r}},e9={tokenize:function(e){let i,r,s,n=this,o=[],a=0;return l;function l(i){if(a<o.length){let r=o[a];return n.containerState=r[1],e.attempt(r[0].continuation,h,c)(i)}return c(i)}function h(e){if(a++,n.containerState._closeFlow){let r;n.containerState._closeFlow=void 0,i&&v();let s=n.events.length,o=s;for(;o--;)if("exit"===n.events[o][0]&&"chunkFlow"===n.events[o][1].type){r=n.events[o][1].end;break}g(a);let l=s;for(;l<n.events.length;)n.events[l][1].end={...r},l++;return eW(n.events,o+1,0,n.events.slice(s)),n.events.length=l,c(e)}return l(e)}function c(r){if(a===o.length){if(!i)return f(r);if(i.currentConstruct&&i.currentConstruct.concrete)return _(r);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(e8,d,u)(r)}function d(e){return i&&v(),g(a),f(e)}function u(e){return n.parser.lazy[n.now().line]=a!==o.length,s=n.now().offset,_(e)}function f(i){return n.containerState={},e.attempt(e8,p,_)(i)}function p(e){return a++,o.push([n.currentConstruct,n.containerState]),f(e)}function _(s){if(null===s){i&&v(),g(0),e.consume(s);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:r}),function i(r){if(null===r){m(e.exit("chunkFlow"),!0),g(0),e.consume(r);return}return eZ(r)?(e.consume(r),m(e.exit("chunkFlow")),a=0,n.interrupt=void 0,l):(e.consume(r),i)}(s)}function m(e,o){let l=n.sliceStream(e);if(o&&l.push(null),e.previous=r,r&&(r.next=e),r=e,i.defineSkip(e.start),i.write(l),n.parser.lazy[e.start.line]){let e,r,o=i.events.length;for(;o--;)if(i.events[o][1].start.offset<s&&(!i.events[o][1].end||i.events[o][1].end.offset>s))return;let l=n.events.length,h=l;for(;h--;)if("exit"===n.events[h][0]&&"chunkFlow"===n.events[h][1].type){if(e){r=n.events[h][1].end;break}e=!0}for(g(a),o=l;o<n.events.length;)n.events[o][1].end={...r},o++;eW(n.events,h+1,0,n.events.slice(l)),n.events.length=o}}function g(i){let r=o.length;for(;r-- >i;){let i=o[r];n.containerState=i[1],i[0].exit.call(n,e)}o.length=i}function v(){i.write([null]),r=void 0,i=void 0,n.containerState._closeFlow=void 0}}},e8={tokenize:function(e,i,r){return e4(e,e.attempt(this.parser.constructs.document,i,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},e7={partial:!0,tokenize:function(e,i,r){return function(i){return e1(i)?e4(e,s,"linePrefix")(i):s(i)};function s(e){return null===e||eZ(e)?i(e):r(e)}}};class te{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,i){let r=null==i?1/0:i;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,i,r){this.setCursor(Math.trunc(e));let s=this.right.splice(this.right.length-(i||0),1/0);return r&&tt(this.left,r),s.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),tt(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),tt(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let i=this.left.splice(e,1/0);tt(this.right,i.reverse())}else{let i=this.right.splice(this.left.length+this.right.length-e,1/0);tt(this.left,i.reverse())}}}function tt(e,i){let r=0;if(i.length<1e4)e.push(...i);else for(;r<i.length;)e.push(...i.slice(r,r+1e4)),r+=1e4}function ti(e){let i,r,s,n,o,a,l,h={},c=-1,d=new te(e);for(;++c<d.length;){for(;c in h;)c=h[c];if(i=d.get(c),c&&"chunkFlow"===i[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((s=0)<(a=i[1]._tokenizer.events).length&&"lineEndingBlank"===a[s][1].type&&(s+=2),s<a.length&&"content"===a[s][1].type))for(;++s<a.length&&"content"!==a[s][1].type;)"chunkText"===a[s][1].type&&(a[s][1]._isInFirstContentOfListItem=!0,s++);if("enter"===i[0])i[1].contentType&&(Object.assign(h,function(e,i){let r,s,n=e.get(i)[1],o=e.get(i)[2],a=i-1,l=[],h=n._tokenizer;!h&&(h=o.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(h._contentTypeTextTrailing=!0));let c=h.events,d=[],u={},f=-1,p=n,_=0,m=0,g=[0];for(;p;){for(;e.get(++a)[1]!==p;);l.push(a),!p._tokenizer&&(r=o.sliceStream(p),p.next||r.push(null),s&&h.defineSkip(p.start),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=!0),h.write(r),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=void 0)),s=p,p=p.next}for(p=n;++f<c.length;)"exit"===c[f][0]&&"enter"===c[f-1][0]&&c[f][1].type===c[f-1][1].type&&c[f][1].start.line!==c[f][1].end.line&&(m=f+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(h.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let i=c.slice(g[f],g[f+1]),r=l.pop();d.push([r,r+i.length-1]),e.splice(r,2,i)}for(d.reverse(),f=-1;++f<d.length;)u[_+d[f][0]]=_+d[f][1],_+=d[f][1]-d[f][0]-1;return u}(d,c)),c=h[c],l=!0);else if(i[1]._container){for(s=c,r=void 0;s--;)if("lineEnding"===(n=d.get(s))[1].type||"lineEndingBlank"===n[1].type)"enter"===n[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),n[1].type="lineEnding",r=s);else if("linePrefix"===n[1].type||"listItemIndent"===n[1].type);else break;r&&(i[1].end={...d.get(r)[1].start},(o=d.slice(r,c)).unshift(i),d.splice(r,c-r+1,o))}}return eW(e,0,1/0,d.slice(0)),!l}let tr={resolve:function(e){return ti(e),e},tokenize:function(e,i){let r;return function(i){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),s(i)};function s(i){return null===i?n(i):eZ(i)?e.check(ts,o,n)(i):(e.consume(i),s)}function n(r){return e.exit("chunkContent"),e.exit("content"),i(r)}function o(i){return e.consume(i),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}},ts={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e4(e,n,"linePrefix")};function n(n){if(null===n||eZ(n))return r(n);let o=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(n):e.interrupt(s.parser.constructs.flow,r,i)(n)}}},tn={tokenize:function(e){let i=this,r=e.attempt(e7,function(s){return null===s?void e.consume(s):(e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),i.currentConstruct=void 0,r)},e.attempt(this.parser.constructs.flowInitial,s,e4(e,e.attempt(this.parser.constructs.flow,s,e.attempt(tr,s)),"linePrefix")));return r;function s(s){return null===s?void e.consume(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i.currentConstruct=void 0,r)}}},to={resolveAll:tc()},ta=th("string"),tl=th("text");function th(e){return{resolveAll:tc("text"===e?td:void 0),tokenize:function(i){let r=this,s=this.parser.constructs[e],n=i.attempt(s,o,a);return o;function o(e){return h(e)?n(e):a(e)}function a(e){return null===e?void i.consume(e):(i.enter("data"),i.consume(e),l)}function l(e){return h(e)?(i.exit("data"),n(e)):(i.consume(e),l)}function h(e){if(null===e)return!0;let i=s[e],n=-1;if(i)for(;++n<i.length;){let e=i[n];if(!e.previous||e.previous.call(r,r.previous))return!0}return!1}}}}function tc(e){return function(i,r){let s,n=-1;for(;++n<=i.length;)void 0===s?i[n]&&"data"===i[n][1].type&&(s=n,n++):i[n]&&"data"===i[n][1].type||(n!==s+2&&(i[s][1].end=i[n-1][1].end,i.splice(s+2,n-s-2),n=s+2),s=void 0);return e?e(i,r):i}}function td(e,i){let r=0;for(;++r<=e.length;)if((r===e.length||"lineEnding"===e[r][1].type)&&"data"===e[r-1][1].type){let s,n=e[r-1][1],o=i.sliceStream(n),a=o.length,l=-1,h=0;for(;a--;){let e=o[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)h++,l--;if(l)break;l=-1}else if(-2===e)s=!0,h++;else if(-1===e);else{a++;break}}if(i._contentTypeTextTrailing&&r===e.length&&(h=0),h){let o={type:r===e.length||s||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:n.start._bufferIndex+l,_index:n.start._index+a,line:n.end.line,column:n.end.column-h,offset:n.end.offset-h},end:{...n.end}};n.end={...o.start},n.start.offset===n.end.offset?Object.assign(n,o):(e.splice(r,0,["enter",o,i],["exit",o,i]),r+=2)}r++}return e}function tu(e){return null===e||e0(e)||e5(e)?1:e2(e)?2:void 0}function tf(e,i,r){let s=[],n=-1;for(;++n<e.length;){let o=e[n].resolveAll;o&&!s.includes(o)&&(i=o(i,r),s.push(o))}return i}let tp={name:"attention",resolveAll:function(e,i){let r,s,n,o,a,l,h,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(r=d;r--;)if("exit"===e[r][0]&&"attentionSequence"===e[r][1].type&&e[r][1]._open&&i.sliceSerialize(e[r][1]).charCodeAt(0)===i.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[r][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[r][1].end},f={...e[d][1].start};t_(u,-l),t_(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:f},n={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[d][1].start}},s={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[d][1].start={...a.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=eU(h,[["enter",e[r][1],i],["exit",e[r][1],i]])),h=eU(h,[["enter",s,i],["enter",o,i],["exit",o,i],["enter",n,i]]),h=eU(h,tf(i.parser.constructs.insideSpan.null,e.slice(r+1,d),i)),h=eU(h,[["exit",n,i],["enter",a,i],["exit",a,i],["exit",s,i]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,h=eU(h,[["enter",e[d][1],i],["exit",e[d][1],i]])):c=0,eW(e,r-1,d-r+3,h),d=r+h.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,i){let r,s=this.parser.constructs.attentionMarkers.null,n=this.previous,o=tu(n);return function(a){return r=a,e.enter("attentionSequence"),function a(l){if(l===r)return e.consume(l),a;let h=e.exit("attentionSequence"),c=tu(l),d=!c||2===c&&o||s.includes(l),u=!o||2===o&&c||s.includes(n);return h._open=!!(42===r?d:d&&(o||!u)),h._close=!!(42===r?u:u&&(c||!d)),i(l)}(a)}}};function t_(e,i){e.column+=i,e.offset+=i,e._bufferIndex+=i}let tm={continuation:{tokenize:function(e,i,r){let s=this;return function(i){return e1(i)?e4(e,n,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):n(i)};function n(s){return e.attempt(tm,i,r)(s)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,i,r){let s=this;return function(i){if(62===i){let r=s.containerState;return r.open||(e.enter("blockQuote",{_container:!0}),r.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),n}return r(i)};function n(r){return e1(r)?(e.enter("blockQuotePrefixWhitespace"),e.consume(r),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),i):(e.exit("blockQuotePrefix"),i(r))}}},tg={name:"characterEscape",tokenize:function(e,i,r){return function(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s};function s(s){return eQ(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),i):r(s)}}},tv=document.createElement("i");function tx(e){let i="&"+e+";";tv.innerHTML=i;let r=tv.textContent;return(59!==r.charCodeAt(r.length-1)||"semi"===e)&&r!==i&&r}let tb={name:"characterReference",tokenize:function(e,i,r){let s,n,o=this,a=0;return function(i){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(i),e.exit("characterReferenceMarker"),l};function l(i){return 35===i?(e.enter("characterReferenceMarkerNumeric"),e.consume(i),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),s=31,n=eV,c(i))}function h(i){return 88===i||120===i?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(i),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,n=eJ,c):(e.enter("characterReferenceValue"),s=7,n=eX,c(i))}function c(l){if(59===l&&a){let s=e.exit("characterReferenceValue");return n!==eV||tx(o.sliceSerialize(s))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),i):r(l)}return n(l)&&a++<s?(e.consume(l),c):r(l)}}},ty={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return null===i?r(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tS={concrete:!0,name:"codeFenced",tokenize:function(e,i,r){let s,n=this,o={partial:!0,tokenize:function(e,i,r){let o=0;return function(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),a};function a(i){return e.enter("codeFencedFence"),e1(i)?e4(e,h,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):h(i)}function h(i){return i===s?(e.enter("codeFencedFenceSequence"),function i(n){return n===s?(o++,e.consume(n),i):o>=l?(e.exit("codeFencedFenceSequence"),e1(n)?e4(e,c,"whitespace")(n):c(n)):r(n)}(i)):r(i)}function c(s){return null===s||eZ(s)?(e.exit("codeFencedFence"),i(s)):r(s)}}},a=0,l=0;return function(i){var o;let c;return o=i,a=(c=n.events[n.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,s=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function i(n){return n===s?(l++,e.consume(n),i):l<3?r(n):(e.exit("codeFencedFenceSequence"),e1(n)?e4(e,h,"whitespace")(n):h(n))}(o)};function h(o){return null===o||eZ(o)?(e.exit("codeFencedFence"),n.interrupt?i(o):e.check(ty,d,_)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||eZ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(n)):e1(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),e4(e,c,"whitespace")(n)):96===n&&n===s?r(n):(e.consume(n),i)}(o))}function c(i){return null===i||eZ(i)?h(i):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||eZ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(n)):96===n&&n===s?r(n):(e.consume(n),i)}(i))}function d(i){return e.attempt(o,_,u)(i)}function u(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),f}function f(i){return a>0&&e1(i)?e4(e,p,"linePrefix",a+1)(i):p(i)}function p(i){return null===i||eZ(i)?e.check(ty,d,_)(i):(e.enter("codeFlowValue"),function i(r){return null===r||eZ(r)?(e.exit("codeFlowValue"),p(r)):(e.consume(r),i)}(i))}function _(r){return e.exit("codeFenced"),i(r)}}},tw={name:"codeIndented",tokenize:function(e,i,r){let s=this;return function(i){return e.enter("codeIndented"),e4(e,n,"linePrefix",5)(i)};function n(i){let n=s.events[s.events.length-1];return n&&"linePrefix"===n[1].type&&n[2].sliceSerialize(n[1],!0).length>=4?function i(r){return null===r?o(r):eZ(r)?e.attempt(tC,i,o)(r):(e.enter("codeFlowValue"),function r(s){return null===s||eZ(s)?(e.exit("codeFlowValue"),i(s)):(e.consume(s),r)}(r))}(i):r(i)}function o(r){return e.exit("codeIndented"),i(r)}}},tC={partial:!0,tokenize:function(e,i,r){let s=this;return n;function n(i){return s.parser.lazy[s.now().line]?r(i):eZ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):e4(e,o,"linePrefix",5)(i)}function o(e){let o=s.events[s.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(e):eZ(e)?n(e):r(e)}}};function tk(e,i,r,s,n,o,a,l,h){let c=h||1/0,d=0;return function(i){return 60===i?(e.enter(s),e.enter(n),e.enter(o),e.consume(i),e.exit(o),u):null===i||32===i||41===i||eG(i)?r(i):(e.enter(s),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),_(i))};function u(r){return 62===r?(e.enter(o),e.consume(r),e.exit(o),e.exit(n),e.exit(s),i):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(r))}function f(i){return 62===i?(e.exit("chunkString"),e.exit(l),u(i)):null===i||60===i||eZ(i)?r(i):(e.consume(i),92===i?p:f)}function p(i){return 60===i||62===i||92===i?(e.consume(i),f):f(i)}function _(n){return!d&&(null===n||41===n||e0(n))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(s),i(n)):d<c&&40===n?(e.consume(n),d++,_):41===n?(e.consume(n),d--,_):null===n||32===n||40===n||eG(n)?r(n):(e.consume(n),92===n?m:_)}function m(i){return 40===i||41===i||92===i?(e.consume(i),_):_(i)}}function tE(e,i,r,s,n,o){let a,l=this,h=0;return function(i){return e.enter(s),e.enter(n),e.consume(i),e.exit(n),e.enter(o),c};function c(u){return h>999||null===u||91===u||93===u&&!a||94===u&&!h&&"_hiddenFootnoteSupport"in l.parser.constructs?r(u):93===u?(e.exit(o),e.enter(n),e.consume(u),e.exit(n),e.exit(s),i):eZ(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(i){return null===i||91===i||93===i||eZ(i)||h++>999?(e.exit("chunkString"),c(i)):(e.consume(i),a||(a=!e1(i)),92===i?u:d)}function u(i){return 91===i||92===i||93===i?(e.consume(i),h++,d):d(i)}}function tN(e,i,r,s,n,o){let a;return function(i){return 34===i||39===i||40===i?(e.enter(s),e.enter(n),e.consume(i),e.exit(n),a=40===i?41:i,l):r(i)};function l(r){return r===a?(e.enter(n),e.consume(r),e.exit(n),e.exit(s),i):(e.enter(o),h(r))}function h(i){return i===a?(e.exit(o),l(a)):null===i?r(i):eZ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e4(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(i))}function c(i){return i===a||null===i||eZ(i)?(e.exit("chunkString"),h(i)):(e.consume(i),92===i?d:c)}function d(i){return i===a||92===i?(e.consume(i),c):c(i)}}function tR(e,i){let r;return function s(n){return eZ(n)?(e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),r=!0,s):e1(n)?e4(e,s,r?"linePrefix":"lineSuffix")(n):i(n)}}function tj(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let tT={partial:!0,tokenize:function(e,i,r){return function(i){return e0(i)?tR(e,s)(i):r(i)};function s(i){return tN(e,n,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(i)}function n(i){return e1(i)?e4(e,o,"whitespace")(i):o(i)}function o(e){return null===e||eZ(e)?i(e):r(e)}}},tD=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],tM=["pre","script","style","textarea"],tL={partial:!0,tokenize:function(e,i,r){return function(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(e7,i,r)}}},tP={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return eZ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):r(i)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tA={name:"labelEnd",resolveAll:function(e){let i=-1,r=[];for(;++i<e.length;){let s=e[i][1];if(r.push(e[i]),"labelImage"===s.type||"labelLink"===s.type||"labelEnd"===s.type){let e="labelImage"===s.type?4:2;s.type="data",i+=e}}return e.length!==r.length&&eW(e,0,e.length,r),e},resolveTo:function(e,i){let r,s,n,o,a=e.length,l=0;for(;a--;)if(r=e[a][1],s){if("link"===r.type||"labelLink"===r.type&&r._inactive)break;"enter"===e[a][0]&&"labelLink"===r.type&&(r._inactive=!0)}else if(n){if("enter"===e[a][0]&&("labelImage"===r.type||"labelLink"===r.type)&&!r._balanced&&(s=a,"labelLink"!==r.type)){l=2;break}}else"labelEnd"===r.type&&(n=a);let h={type:"labelLink"===e[s][1].type?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[n][1].end}},d={type:"labelText",start:{...e[s+l+2][1].end},end:{...e[n-2][1].start}};return o=eU(o=[["enter",h,i],["enter",c,i]],e.slice(s+1,s+l+3)),o=eU(o,[["enter",d,i]]),o=eU(o,tf(i.parser.constructs.insideSpan.null,e.slice(s+l+4,n-3),i)),o=eU(o,[["exit",d,i],e[n-2],e[n-1],["exit",c,i]]),o=eU(o,e.slice(n+1)),o=eU(o,[["exit",h,i]]),eW(e,s,e.length,o),e},tokenize:function(e,i,r){let s,n,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){s=o.events[a][1];break}return function(i){return s?s._inactive?d(i):(n=o.parser.defined.includes(tj(o.sliceSerialize({start:s.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelEnd"),l):r(i)};function l(i){return 40===i?e.attempt(tB,c,n?c:d)(i):91===i?e.attempt(tI,c,n?h:d)(i):n?c(i):d(i)}function h(i){return e.attempt(tO,c,d)(i)}function c(e){return i(e)}function d(e){return s._balanced=!0,r(e)}}},tB={tokenize:function(e,i,r){return function(i){return e.enter("resource"),e.enter("resourceMarker"),e.consume(i),e.exit("resourceMarker"),s};function s(i){return e0(i)?tR(e,n)(i):n(i)}function n(i){return 41===i?c(i):tk(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(i)}function o(i){return e0(i)?tR(e,l)(i):c(i)}function a(e){return r(e)}function l(i){return 34===i||39===i||40===i?tN(e,h,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(i):c(i)}function h(i){return e0(i)?tR(e,c)(i):c(i)}function c(s){return 41===s?(e.enter("resourceMarker"),e.consume(s),e.exit("resourceMarker"),e.exit("resource"),i):r(s)}}},tI={tokenize:function(e,i,r){let s=this;return function(i){return tE.call(s,e,n,o,"reference","referenceMarker","referenceString")(i)};function n(e){return s.parser.defined.includes(tj(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?i(e):r(e)}function o(e){return r(e)}}},tO={tokenize:function(e,i,r){return function(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s};function s(s){return 93===s?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),i):r(s)}}},tF={name:"labelStartImage",resolveAll:tA.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(i),e.exit("labelImageMarker"),n};function n(i){return 91===i?(e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelImage"),o):r(i)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tH={name:"labelStartLink",resolveAll:tA.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),n};function n(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tz={name:"lineEnding",tokenize:function(e,i){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e4(e,i,"linePrefix")}}},t$={name:"thematicBreak",tokenize:function(e,i,r){let s,n=0;return function(o){var a;return e.enter("thematicBreak"),s=a=o,function o(a){return a===s?(e.enter("thematicBreakSequence"),function i(r){return r===s?(e.consume(r),n++,i):(e.exit("thematicBreakSequence"),e1(r)?e4(e,o,"whitespace")(r):o(r))}(a)):n>=3&&(null===a||eZ(a))?(e.exit("thematicBreak"),i(a)):r(a)}(a)}}},tW={continuation:{tokenize:function(e,i,r){let s=this;return s.containerState._closeFlow=void 0,e.check(e7,function(r){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,e4(e,i,"listItemIndent",s.containerState.size+1)(r)},function(r){return s.containerState.furtherBlankLines||!e1(r)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,n(r)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(tK,i,n)(r))});function n(n){return s.containerState._closeFlow=!0,s.interrupt=void 0,e4(e,e.attempt(tW,i,r),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(n)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,i,r){let s=this,n=s.events[s.events.length-1],o=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,a=0;return function(i){let n=s.containerState.type||(42===i||43===i||45===i?"listUnordered":"listOrdered");if("listUnordered"===n?!s.containerState.marker||i===s.containerState.marker:eX(i)){if(s.containerState.type||(s.containerState.type=n,e.enter(n,{_container:!0})),"listUnordered"===n)return e.enter("listItemPrefix"),42===i||45===i?e.check(t$,r,l)(i):l(i);if(!s.interrupt||49===i)return e.enter("listItemPrefix"),e.enter("listItemValue"),function i(n){return eX(n)&&++a<10?(e.consume(n),i):(!s.interrupt||a<2)&&(s.containerState.marker?n===s.containerState.marker:41===n||46===n)?(e.exit("listItemValue"),l(n)):r(n)}(i)}return r(i)};function l(i){return e.enter("listItemMarker"),e.consume(i),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||i,e.check(e7,s.interrupt?r:h,e.attempt(tU,d,c))}function h(e){return s.containerState.initialBlankLine=!0,o++,d(e)}function c(i){return e1(i)?(e.enter("listItemPrefixWhitespace"),e.consume(i),e.exit("listItemPrefixWhitespace"),d):r(i)}function d(r){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,i(r)}}},tU={partial:!0,tokenize:function(e,i,r){let s=this;return e4(e,function(e){let n=s.events[s.events.length-1];return!e1(e)&&n&&"listItemPrefixWhitespace"===n[1].type?i(e):r(e)},"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},tK={partial:!0,tokenize:function(e,i,r){let s=this;return e4(e,function(e){let n=s.events[s.events.length-1];return n&&"listItemIndent"===n[1].type&&n[2].sliceSerialize(n[1],!0).length===s.containerState.size?i(e):r(e)},"listItemIndent",s.containerState.size+1)}},tq={name:"setextUnderline",resolveTo:function(e,i){let r,s,n,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){r=o;break}"paragraph"===e[o][1].type&&(s=o)}else"content"===e[o][1].type&&e.splice(o,1),n||"definition"!==e[o][1].type||(n=o);let a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",n?(e.splice(s,0,["enter",a,i]),e.splice(n+1,0,["exit",e[r][1],i]),e[r][1].end={...e[n][1].end}):e[r][1]=a,e.push(["exit",a,i]),e},tokenize:function(e,i,r){let s,n=this;return function(i){var a;let l,h=n.events.length;for(;h--;)if("lineEnding"!==n.events[h][1].type&&"linePrefix"!==n.events[h][1].type&&"content"!==n.events[h][1].type){l="paragraph"===n.events[h][1].type;break}return!n.parser.lazy[n.now().line]&&(n.interrupt||l)?(e.enter("setextHeadingLine"),s=i,a=i,e.enter("setextHeadingLineSequence"),function i(r){return r===s?(e.consume(r),i):(e.exit("setextHeadingLineSequence"),e1(r)?e4(e,o,"lineSuffix")(r):o(r))}(a)):r(i)};function o(s){return null===s||eZ(s)?(e.exit("setextHeadingLine"),i(s)):r(s)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,i,r){let s,n=this;return function(i){var s;return e.enter("definition"),s=i,tE.call(n,e,o,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(s)};function o(i){return(s=tj(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),58===i)?(e.enter("definitionMarker"),e.consume(i),e.exit("definitionMarker"),a):r(i)}function a(i){return e0(i)?tR(e,l)(i):l(i)}function l(i){return tk(e,h,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(i)}function h(i){return e.attempt(tT,c,c)(i)}function c(i){return e1(i)?e4(e,d,"whitespace")(i):d(i)}function d(o){return null===o||eZ(o)?(e.exit("definition"),n.parser.defined.push(s),i(o)):r(o)}}}},"disable",0,{null:[]},"document",0,{42:tW,43:tW,45:tW,48:tW,49:tW,50:tW,51:tW,52:tW,53:tW,54:tW,55:tW,56:tW,57:tW,62:tm},"flow",0,{35:{name:"headingAtx",resolve:function(e,i){let r,s,n=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),n-2>o&&"whitespace"===e[n][1].type&&(n-=2),"atxHeadingSequence"===e[n][1].type&&(o===n-1||n-4>o&&"whitespace"===e[n-2][1].type)&&(n-=o+1===n?2:4),n>o&&(r={type:"atxHeadingText",start:e[o][1].start,end:e[n][1].end},s={type:"chunkText",start:e[o][1].start,end:e[n][1].end,contentType:"text"},eW(e,o,n-o+1,[["enter",r,i],["enter",s,i],["exit",s,i],["exit",r,i]])),e},tokenize:function(e,i,r){let s=0;return function(n){var o;return e.enter("atxHeading"),o=n,e.enter("atxHeadingSequence"),function n(o){return 35===o&&s++<6?(e.consume(o),n):null===o||e0(o)?(e.exit("atxHeadingSequence"),function r(s){return 35===s?(e.enter("atxHeadingSequence"),function i(s){return 35===s?(e.consume(s),i):(e.exit("atxHeadingSequence"),r(s))}(s)):null===s||eZ(s)?(e.exit("atxHeading"),i(s)):e1(s)?e4(e,r,"whitespace")(s):(e.enter("atxHeadingText"),function i(s){return null===s||35===s||e0(s)?(e.exit("atxHeadingText"),r(s)):(e.consume(s),i)}(s))}(o)):r(o)}(o)}}},42:t$,45:[tq,t$],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let i=e.length;for(;i--&&("enter"!==e[i][0]||"htmlFlow"!==e[i][1].type););return i>1&&"linePrefix"===e[i-2][1].type&&(e[i][1].start=e[i-2][1].start,e[i+1][1].start=e[i-2][1].start,e.splice(i-2,2)),e},tokenize:function(e,i,r){let s,n,o,a,l,h=this;return function(i){var r;return r=i,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(r),c};function c(a){return 33===a?(e.consume(a),d):47===a?(e.consume(a),n=!0,p):63===a?(e.consume(a),s=3,h.interrupt?i:L):eq(a)?(e.consume(a),o=String.fromCharCode(a),_):r(a)}function d(n){return 45===n?(e.consume(n),s=2,u):91===n?(e.consume(n),s=5,a=0,f):eq(n)?(e.consume(n),s=4,h.interrupt?i:L):r(n)}function u(s){return 45===s?(e.consume(s),h.interrupt?i:L):r(s)}function f(s){let n="CDATA[";return s===n.charCodeAt(a++)?(e.consume(s),a===n.length)?h.interrupt?i:k:f:r(s)}function p(i){return eq(i)?(e.consume(i),o=String.fromCharCode(i),_):r(i)}function _(a){if(null===a||47===a||62===a||e0(a)){let l=47===a,c=o.toLowerCase();return!l&&!n&&tM.includes(c)?(s=1,h.interrupt?i(a):k(a)):tD.includes(o.toLowerCase())?(s=6,l)?(e.consume(a),m):h.interrupt?i(a):k(a):(s=7,h.interrupt&&!h.parser.lazy[h.now().line]?r(a):n?function i(r){return e1(r)?(e.consume(r),i):w(r)}(a):g(a))}return 45===a||eV(a)?(e.consume(a),o+=String.fromCharCode(a),_):r(a)}function m(s){return 62===s?(e.consume(s),h.interrupt?i:k):r(s)}function g(i){return 47===i?(e.consume(i),w):58===i||95===i||eq(i)?(e.consume(i),v):e1(i)?(e.consume(i),g):w(i)}function v(i){return 45===i||46===i||58===i||95===i||eV(i)?(e.consume(i),v):x(i)}function x(i){return 61===i?(e.consume(i),b):e1(i)?(e.consume(i),x):g(i)}function b(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),l=i,y):e1(i)?(e.consume(i),b):function i(r){return null===r||34===r||39===r||47===r||60===r||61===r||62===r||96===r||e0(r)?x(r):(e.consume(r),i)}(i)}function y(i){return i===l?(e.consume(i),l=null,S):null===i||eZ(i)?r(i):(e.consume(i),y)}function S(e){return 47===e||62===e||e1(e)?g(e):r(e)}function w(i){return 62===i?(e.consume(i),C):r(i)}function C(i){return null===i||eZ(i)?k(i):e1(i)?(e.consume(i),C):r(i)}function k(i){return 45===i&&2===s?(e.consume(i),j):60===i&&1===s?(e.consume(i),T):62===i&&4===s?(e.consume(i),P):63===i&&3===s?(e.consume(i),L):93===i&&5===s?(e.consume(i),M):eZ(i)&&(6===s||7===s)?(e.exit("htmlFlowData"),e.check(tL,A,E)(i)):null===i||eZ(i)?(e.exit("htmlFlowData"),E(i)):(e.consume(i),k)}function E(i){return e.check(tP,N,A)(i)}function N(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),R}function R(i){return null===i||eZ(i)?E(i):(e.enter("htmlFlowData"),k(i))}function j(i){return 45===i?(e.consume(i),L):k(i)}function T(i){return 47===i?(e.consume(i),o="",D):k(i)}function D(i){if(62===i){let r=o.toLowerCase();return tM.includes(r)?(e.consume(i),P):k(i)}return eq(i)&&o.length<8?(e.consume(i),o+=String.fromCharCode(i),D):k(i)}function M(i){return 93===i?(e.consume(i),L):k(i)}function L(i){return 62===i?(e.consume(i),P):45===i&&2===s?(e.consume(i),L):k(i)}function P(i){return null===i||eZ(i)?(e.exit("htmlFlowData"),A(i)):(e.consume(i),P)}function A(r){return e.exit("htmlFlow"),i(r)}}},61:tq,95:t$,96:tS,126:tS},"flowInitial",0,{[-2]:tw,[-1]:tw,32:tw},"insideSpan",0,{null:[tp,to]},"string",0,{38:tb,92:tg},"text",0,{[-5]:tz,[-4]:tz,[-3]:tz,33:tF,38:tb,42:tp,60:[{name:"autolink",tokenize:function(e,i,r){let s=0;return function(i){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),n};function n(i){return eq(i)?(e.consume(i),o):64===i?r(i):l(i)}function o(i){return 43===i||45===i||46===i||eV(i)?(s=1,function i(r){return 58===r?(e.consume(r),s=0,a):(43===r||45===r||46===r||eV(r))&&s++<32?(e.consume(r),i):(s=0,l(r))}(i)):l(i)}function a(s){return 62===s?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(s),e.exit("autolinkMarker"),e.exit("autolink"),i):null===s||32===s||60===s||eG(s)?r(s):(e.consume(s),a)}function l(i){return 64===i?(e.consume(i),h):eY(i)?(e.consume(i),l):r(i)}function h(n){return eV(n)?function n(o){return 46===o?(e.consume(o),s=0,h):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),i):function i(o){if((45===o||eV(o))&&s++<63){let r=45===o?i:n;return e.consume(o),r}return r(o)}(o)}(n):r(n)}}},{name:"htmlText",tokenize:function(e,i,r){let s,n,o,a=this;return function(i){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(i),l};function l(i){return 33===i?(e.consume(i),h):47===i?(e.consume(i),y):63===i?(e.consume(i),x):eq(i)?(e.consume(i),w):r(i)}function h(i){return 45===i?(e.consume(i),c):91===i?(e.consume(i),n=0,p):eq(i)?(e.consume(i),v):r(i)}function c(i){return 45===i?(e.consume(i),f):r(i)}function d(i){return null===i?r(i):45===i?(e.consume(i),u):eZ(i)?(o=d,D(i)):(e.consume(i),d)}function u(i){return 45===i?(e.consume(i),f):d(i)}function f(e){return 62===e?T(e):45===e?u(e):d(e)}function p(i){let s="CDATA[";return i===s.charCodeAt(n++)?(e.consume(i),n===s.length?_:p):r(i)}function _(i){return null===i?r(i):93===i?(e.consume(i),m):eZ(i)?(o=_,D(i)):(e.consume(i),_)}function m(i){return 93===i?(e.consume(i),g):_(i)}function g(i){return 62===i?T(i):93===i?(e.consume(i),g):_(i)}function v(i){return null===i||62===i?T(i):eZ(i)?(o=v,D(i)):(e.consume(i),v)}function x(i){return null===i?r(i):63===i?(e.consume(i),b):eZ(i)?(o=x,D(i)):(e.consume(i),x)}function b(e){return 62===e?T(e):x(e)}function y(i){return eq(i)?(e.consume(i),S):r(i)}function S(i){return 45===i||eV(i)?(e.consume(i),S):function i(r){return eZ(r)?(o=i,D(r)):e1(r)?(e.consume(r),i):T(r)}(i)}function w(i){return 45===i||eV(i)?(e.consume(i),w):47===i||62===i||e0(i)?C(i):r(i)}function C(i){return 47===i?(e.consume(i),T):58===i||95===i||eq(i)?(e.consume(i),k):eZ(i)?(o=C,D(i)):e1(i)?(e.consume(i),C):T(i)}function k(i){return 45===i||46===i||58===i||95===i||eV(i)?(e.consume(i),k):function i(r){return 61===r?(e.consume(r),E):eZ(r)?(o=i,D(r)):e1(r)?(e.consume(r),i):C(r)}(i)}function E(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),s=i,N):eZ(i)?(o=E,D(i)):e1(i)?(e.consume(i),E):(e.consume(i),R)}function N(i){return i===s?(e.consume(i),s=void 0,j):null===i?r(i):eZ(i)?(o=N,D(i)):(e.consume(i),N)}function R(i){return null===i||34===i||39===i||60===i||61===i||96===i?r(i):47===i||62===i||e0(i)?C(i):(e.consume(i),R)}function j(e){return 47===e||62===e||e0(e)?C(e):r(e)}function T(s){return 62===s?(e.consume(s),e.exit("htmlTextData"),e.exit("htmlText"),i):r(s)}function D(i){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),M}function M(i){return e1(i)?e4(e,L,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):L(i)}function L(i){return e.enter("htmlTextData"),o(i)}}}],91:tH,92:[{name:"hardBreakEscape",tokenize:function(e,i,r){return function(i){return e.enter("hardBreakEscape"),e.consume(i),s};function s(s){return eZ(s)?(e.exit("hardBreakEscape"),i(s)):r(s)}}},tg],93:tA,95:tp,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let i,r,s=e.length-4,n=3;if(("lineEnding"===e[3][1].type||"space"===e[n][1].type)&&("lineEnding"===e[s][1].type||"space"===e[s][1].type)){for(i=n;++i<s;)if("codeTextData"===e[i][1].type){e[n][1].type="codeTextPadding",e[s][1].type="codeTextPadding",n+=2,s-=2;break}}for(i=n-1,s++;++i<=s;)void 0===r?i!==s&&"lineEnding"!==e[i][1].type&&(r=i):(i===s||"lineEnding"===e[i][1].type)&&(e[r][1].type="codeTextData",i!==r+2&&(e[r][1].end=e[i-1][1].end,e.splice(r+2,i-r-2),s-=i-r-2,i=r+2),r=void 0);return e},tokenize:function(e,i,r){let s,n,o=0;return function(i){return e.enter("codeText"),e.enter("codeTextSequence"),function i(r){return 96===r?(e.consume(r),o++,i):(e.exit("codeTextSequence"),a(r))}(i)};function a(h){return null===h?r(h):32===h?(e.enter("space"),e.consume(h),e.exit("space"),a):96===h?(n=e.enter("codeTextSequence"),s=0,function r(a){return 96===a?(e.consume(a),s++,r):s===o?(e.exit("codeTextSequence"),e.exit("codeText"),i(a)):(n.type="codeTextData",l(a))}(h)):eZ(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(h))}function l(i){return null===i||32===i||96===i||eZ(i)?(e.exit("codeTextData"),a(i)):(e.consume(i),l)}}}}],4127);var tV=e.i(4127);let tY=/[\0\t\n\r]/g;function tG(e,i){let r=Number.parseInt(e,i);return r<9||11===r||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(65535&r)==65535||(65535&r)==65534||r>1114111?"�":String.fromCodePoint(r)}let tX=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tJ(e,i,r){if(i)return i;if(35===r.charCodeAt(0)){let e=r.charCodeAt(1),i=120===e||88===e;return tG(r.slice(i?2:1),i?16:10)}return tx(r)||e}let tQ={}.hasOwnProperty;function tZ(e){return{line:e.line,column:e.column,offset:e.offset}}function t0(e,i){if(e)throw Error("Cannot close `"+e.type+"` ("+ey({start:e.start,end:e.end})+"): a different token (`"+i.type+"`, "+ey({start:i.start,end:i.end})+") is open");throw Error("Cannot close document, a token (`"+i.type+"`, "+ey({start:i.start,end:i.end})+") is still open")}function t1(e){let i=this;i.parser=function(r){var s,n;let o,a,l,h;return"object"==typeof(s={...i.data("settings"),...e,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})&&(n=s,s=void 0),(function(e){let i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(v),autolinkProtocol:c,autolinkEmail:c,atxHeading:s(_),blockQuote:s(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:s(p),codeFencedFenceInfo:n,codeFencedFenceMeta:n,codeIndented:s(p,n),codeText:s(function(){return{type:"inlineCode",value:""}},n),codeTextData:c,data:c,codeFlowValue:c,definition:s(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:n,definitionLabelString:n,definitionTitleString:n,emphasis:s(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:s(m),hardBreakTrailing:s(m),htmlFlow:s(g,n),htmlFlowData:c,htmlText:s(g,n),htmlTextData:c,image:s(function(){return{type:"image",title:null,url:"",alt:null}}),label:n,link:s(v),listItem:s(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:s(x,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:s(x),paragraph:s(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:n,resourceDestinationString:n,resourceTitleString:n,setextHeading:s(_),strong:s(function(){return{type:"strong",children:[]}}),thematicBreak:s(function(){return{type:"thematicBreak"}})},exit:{atxHeading:a(),atxHeadingSequence:function(e){let i=this.stack[this.stack.length-1];i.depth||(i.depth=this.sliceSerialize(e).length)},autolink:a(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:a(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:f,characterReferenceMarkerNumeric:f,characterReferenceValue:function(e){let i,r=this.sliceSerialize(e),s=this.data.characterReferenceType;s?(i=tG(r,"characterReferenceMarkerNumeric"===s?10:16),this.data.characterReferenceType=void 0):i=tx(r);let n=this.stack[this.stack.length-1];n.value+=i},characterReference:function(e){this.stack.pop().position.end=tZ(e.end)},codeFenced:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:a(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tj(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:a(),hardBreakEscape:a(u),hardBreakTrailing:a(u),htmlFlow:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],i=this.resume(),r=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===r.type?r.children=e.children:r.alt=i},labelText:function(e){let i=this.sliceSerialize(e),r=this.stack[this.stack.length-2];r.label=i.replace(tX,tJ),r.identifier=tj(i).toLowerCase()},lineEnding:function(e){let r=this.stack[this.stack.length-1];if(this.data.atHardBreak){r.children[r.children.length-1].position.end=tZ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(r.type)&&(c.call(this,e),d.call(this,e))},link:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tj(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:a(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:a(),thematicBreak:a()}};!function e(i,r){let s=-1;for(;++s<r.length;){let n=r[s];Array.isArray(n)?e(i,n):function(e,i){let r;for(r in i)if(tQ.call(i,r))switch(r){case"canContainEols":{let s=i[r];s&&e[r].push(...s);break}case"transforms":{let s=i[r];s&&e[r].push(...s);break}case"enter":case"exit":{let s=i[r];s&&Object.assign(e[r],s)}}}(i,n)}}(i,(e||{}).mdastExtensions||[]);let r={};return function(e){let s={type:"root",children:[]},a={stack:[s],tokenStack:[],config:i,enter:o,exit:l,buffer:n,resume:h,data:r},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,i,r){let s,n,o,a,l=i-1,h=-1,c=!1;for(;++l<=r;){let i=e[l];switch(i[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===i[0]?h++:h--,a=void 0;break;case"lineEndingBlank":"enter"===i[0]&&(!s||a||h||o||(o=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!h&&"enter"===i[0]&&"listItemPrefix"===i[1].type||-1===h&&"exit"===i[0]&&("listUnordered"===i[1].type||"listOrdered"===i[1].type)){if(s){let a=l;for(n=void 0;a--;){let i=e[a];if("lineEnding"===i[1].type||"lineEndingBlank"===i[1].type){if("exit"===i[0])continue;n&&(e[n][1].type="lineEndingBlank",c=!0),i[1].type="lineEnding",n=a}else if("linePrefix"===i[1].type||"blockQuotePrefix"===i[1].type||"blockQuotePrefixWhitespace"===i[1].type||"blockQuoteMarker"===i[1].type||"listItemIndent"===i[1].type);else break}o&&(!n||o<n)&&(s._spread=!0),s.end=Object.assign({},n?e[n][1].start:i[1].end),e.splice(n||l,0,["exit",s,i[2]]),l++,r++}if("listItemPrefix"===i[1].type){let n={type:"listItem",_spread:!1,start:Object.assign({},i[1].start),end:void 0};s=n,e.splice(l,0,["enter",n,i[2]]),l++,r++,o=void 0,a=!0}}}return e[i][1]._spread=c,r}(e,c.pop(),d));for(d=-1;++d<e.length;){let r=i[e[d][0]];tQ.call(r,e[d][1].type)&&r[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||t0).call(a,void 0,e[0])}for(s.position={start:tZ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tZ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<i.transforms.length;)s=i.transforms[d](s)||s;return s};function s(e,i){return function(r){o.call(this,e(r),r),i&&i.call(this,r)}}function n(){this.stack.push({type:"fragment",children:[]})}function o(e,i,r){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([i,r||void 0]),e.position={start:tZ(i.start),end:void 0}}function a(e){return function(i){e&&e.call(this,i),l.call(this,i)}}function l(e,i){let r=this.stack.pop(),s=this.tokenStack.pop();if(s)s[0].type!==e.type&&(i?i.call(this,e,s[0]):(s[1]||t0).call(this,e,s[0]));else throw Error("Cannot close `"+e.type+"` ("+ey({start:e.start,end:e.end})+"): it’s not open");r.position.end=tZ(e.end)}function h(){var e;return e=this.stack.pop(),ez(e,"boolean"!=typeof eH.includeImageAlt||eH.includeImageAlt,"boolean"!=typeof eH.includeHtml||eH.includeHtml)}function c(e){let i=this.stack[this.stack.length-1].children,r=i[i.length-1];r&&"text"===r.type||((r={type:"text",value:""}).position={start:tZ(e.start),end:void 0},i.push(r)),this.stack.push(r)}function d(e){let i=this.stack.pop();i.value+=this.sliceSerialize(e),i.position.end=tZ(e.end)}function u(){this.data.atHardBreak=!0}function f(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function _(){return{type:"heading",depth:0,children:[]}}function m(){return{type:"break"}}function g(){return{type:"html",value:""}}function v(){return{type:"link",title:null,url:"",children:[]}}function x(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(n)(function(e){for(;!ti(e););return e}((function(e){let i={constructs:function(e){let i={},r=-1;for(;++r<e.length;)!function(e,i){let r;for(r in i){let s,n=(eK.call(e,r)?e[r]:void 0)||(e[r]={}),o=i[r];if(o)for(s in o){eK.call(n,s)||(n[s]=[]);let e=o[s];!function(e,i){let r=-1,s=[];for(;++r<i.length;)("after"===i[r].add?e:s).push(i[r]);eW(e,0,0,s)}(n[s],Array.isArray(e)?e:e?[e]:[])}}}(i,e[r]);return i}([tV,...(e||{}).extensions||[]]),content:r(e6),defined:[],document:r(e9),flow:r(tn),lazy:{},string:r(ta),text:r(tl)};return i;function r(e){return function(r){return function(e,i,r){let s={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},o=[],a=[],l=[],h={attempt:_(function(e,i){m(e,i.from)}),check:_(p),consume:function(e){eZ(e)?(s.line++,s.column=1,s.offset+=-3===e?2:1,g()):-1!==e&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===a[s._index].length&&(s._bufferIndex=-1,s._index++)),c.previous=e},enter:function(e,i){let r=i||{};return r.type=e,r.start=f(),c.events.push(["enter",r,c]),l.push(r),r},exit:function(e){let i=l.pop();return i.end=f(),c.events.push(["exit",i,c]),i},interrupt:_(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){n[e.line]=e.column,g()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,i){return function(e,i){let r,s=-1,n=[];for(;++s<e.length;){let o,a=e[s];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=i?" ":" ";break;case -1:if(!i&&r)continue;o=" ";break;default:o=String.fromCharCode(a)}r=-2===a,n.push(o)}return n.join("")}(u(e),i)},sliceStream:u,write:function(e){return(a=eU(a,e),function(){let e;for(;s._index<a.length;){let r=a[s._index];if("string"==typeof r)for(e=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===e&&s._bufferIndex<r.length;){var i;i=r.charCodeAt(s._bufferIndex),d=d(i)}else d=d(r)}}(),null!==a[a.length-1])?[]:(m(i,0),c.events=tf(o,c.events,c),c.events)}},d=i.tokenize.call(c,h);return i.resolveAll&&o.push(i),c;function u(e){return function(e,i){let r,s=i.start._index,n=i.start._bufferIndex,o=i.end._index,a=i.end._bufferIndex;if(s===o)r=[e[s].slice(n,a)];else{if(r=e.slice(s,o),n>-1){let e=r[0];"string"==typeof e?r[0]=e.slice(n):r.shift()}a>0&&r.push(e[o].slice(0,a))}return r}(a,e)}function f(){let{_bufferIndex:e,_index:i,line:r,column:n,offset:o}=s;return{_bufferIndex:e,_index:i,line:r,column:n,offset:o}}function p(e,i){i.restore()}function _(e,i){return function(r,n,o){var a;let d,u,p,_;return Array.isArray(r)?m(r):"tokenize"in r?m([r]):(a=r,function(e){let i=null!==e&&a[e],r=null!==e&&a.null;return m([...Array.isArray(i)?i:i?[i]:[],...Array.isArray(r)?r:r?[r]:[]])(e)});function m(e){return(d=e,u=0,0===e.length)?o:v(e[u])}function v(e){return function(r){let n,o,a,d,u;return(n=f(),o=c.previous,a=c.currentConstruct,d=c.events.length,u=Array.from(l),_={from:d,restore:function(){s=n,c.previous=o,c.currentConstruct=a,c.events.length=d,l=u,g()}},p=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(r):e.tokenize.call(i?Object.assign(Object.create(c),i):c,h,x,b)(r)}}function x(i){return e(p,_),n}function b(e){return(_.restore(),++u<d.length)?v(d[u]):o}}}function m(e,i){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&eW(c.events,i,c.events.length-i,e.resolve(c.events.slice(i),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){s.line in n&&s.column<2&&(s.column=n[s.line],s.offset+=n[s.line]-1)}}(i,e,r)}}})(n).document().write((a=1,l="",h=!0,function(e,i,r){let s,n,c,d,u,f=[];for(e=l+("string"==typeof e?e.toString():new TextDecoder(i||void 0).decode(e)),c=0,l="",h&&(65279===e.charCodeAt(0)&&c++,h=void 0);c<e.length;){if(tY.lastIndex=c,d=(s=tY.exec(e))&&void 0!==s.index?s.index:e.length,u=e.charCodeAt(d),!s){l=e.slice(c);break}if(10===u&&c===d&&o)f.push(-3),o=void 0;else switch(o&&(f.push(-5),o=void 0),c<d&&(f.push(e.slice(c,d)),a+=d-c),u){case 0:f.push(65533),a++;break;case 9:for(n=4*Math.ceil(a/4),f.push(-2);a++<n;)f.push(-1);break;case 10:f.push(-4),a=1;break;default:o=!0,a=1}c=d+1}return r&&(o&&f.push(-5),l&&f.push(l),f.push(null)),f})(r,s,!0))))}}let t2="object"==typeof self?self:globalThis,t5=e=>{var i;let r,s;return(i=new Map,r=(e,r)=>(i.set(r,e),e),s=n=>{if(i.has(n))return i.get(n);let[o,a]=e[n];switch(o){case 0:case -1:return r(a,n);case 1:{let e=r([],n);for(let i of a)e.push(s(i));return e}case 2:{let e=r({},n);for(let[i,r]of a)e[s(i)]=s(r);return e}case 3:return r(new Date(a),n);case 4:{let{source:e,flags:i}=a;return r(new RegExp(e,i),n)}case 5:{let e=r(new Map,n);for(let[i,r]of a)e.set(s(i),s(r));return e}case 6:{let e=r(new Set,n);for(let i of a)e.add(s(i));return e}case 7:{let{name:e,message:i}=a;return r(new t2[e](i),n)}case 8:return r(BigInt(a),n);case"BigInt":return r(Object(BigInt(a)),n);case"ArrayBuffer":return r(new Uint8Array(a).buffer,a);case"DataView":{let{buffer:e}=new Uint8Array(a);return r(new DataView(e),a)}}return r(new t2[o](a),n)})(0)},{toString:t3}={},{keys:t4}=Object,t6=e=>{let i=typeof e;if("object"!==i||!e)return[0,i];let r=t3.call(e).slice(8,-1);switch(r){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,r]}return r.includes("Array")?[1,r]:r.includes("Error")?[7,r]:[2,r]},t9=([e,i])=>0===e&&("function"===i||"symbol"===i),t8=(e,{json:i,lossy:r}={})=>{var s,n,o;let a,l,h=[];return(s=!(i||r),n=!!i,o=new Map,a=(e,i)=>{let r=h.push(e)-1;return o.set(i,r),r},l=e=>{if(o.has(e))return o.get(e);let[i,r]=t6(e);switch(i){case 0:{let n=e;switch(r){case"bigint":i=8,n=e.toString();break;case"function":case"symbol":if(s)throw TypeError("unable to serialize "+r);n=null;break;case"undefined":return a([-1],e)}return a([i,n],e)}case 1:{if(r){let i=e;return"DataView"===r?i=new Uint8Array(e.buffer):"ArrayBuffer"===r&&(i=new Uint8Array(e)),a([r,[...i]],e)}let s=[],n=a([i,s],e);for(let i of e)s.push(l(i));return n}case 2:{if(r)switch(r){case"BigInt":return a([r,e.toString()],e);case"Boolean":case"Number":case"String":return a([r,e.valueOf()],e)}if(n&&"toJSON"in e)return l(e.toJSON());let o=[],h=a([i,o],e);for(let i of t4(e))(s||!t9(t6(e[i])))&&o.push([l(i),l(e[i])]);return h}case 3:return a([i,e.toISOString()],e);case 4:{let{source:r,flags:s}=e;return a([i,{source:r,flags:s}],e)}case 5:{let r=[],n=a([i,r],e);for(let[i,n]of e)(s||!(t9(t6(i))||t9(t6(n))))&&r.push([l(i),l(n)]);return n}case 6:{let r=[],n=a([i,r],e);for(let i of e)(s||!t9(t6(i)))&&r.push(l(i));return n}}let{message:h}=e;return a([i,{name:r,message:h}],e)})(e),h},t7="function"==typeof structuredClone?(e,i)=>i&&("json"in i||"lossy"in i)?t5(t8(e,i)):structuredClone(e):(e,i)=>t5(t8(e,i));function ie(e){let i=[],r=-1,s=0,n=0;for(;++r<e.length;){let o=e.charCodeAt(r),a="";if(37===o&&eV(e.charCodeAt(r+1))&&eV(e.charCodeAt(r+2)))n=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let i=e.charCodeAt(r+1);o<56320&&i>56319&&i<57344?(a=String.fromCharCode(o,i),n=1):a="�"}else a=String.fromCharCode(o);a&&(i.push(e.slice(s,r),encodeURIComponent(a)),s=r+n+1,a=""),n&&(r+=n,n=0)}return i.join("")+e.slice(s)}function it(e,i){let r=[{type:"text",value:"↩"}];return i>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),r}function ii(e,i){return"Back to reference "+(e+1)+(i>1?"-"+i:"")}let ir=function(e){var i,r;if(null==e)return io;if("function"==typeof e)return is(e);if("object"==typeof e){return Array.isArray(e)?function(e){let i=[],r=-1;for(;++r<e.length;)i[r]=ir(e[r]);return is(function(...e){let r=-1;for(;++r<i.length;)if(i[r].apply(this,e))return!0;return!1})}(e):(i=e,is(function(e){let r;for(r in i)if(e[r]!==i[r])return!1;return!0}))}if("string"==typeof e){return r=e,is(function(e){return e&&e.type===r})}throw Error("Expected function, string, or object as test")};function is(e){return function(i,r,s){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(i)&&e.call(this,i,"number"==typeof r?r:void 0,s||void 0))}}function io(){return!0}let ia=[];function il(e,i,r,s){var n,o,a;let l,h,c,d,u,f;"function"==typeof i&&"function"!=typeof r?(h=void 0,c=i,l=r):(h=i,c=r,l=s),n=h,o=function(e,i){let r=i[i.length-1],s=r?r.children.indexOf(e):void 0;return c(e,s,r)},a=l,"function"==typeof n&&"function"!=typeof o?(a=o,o=n):d=n,u=ir(d),f=a?-1:1,(function e(i,r,s){let l=i&&"object"==typeof i?i:{};if("string"==typeof l.type){let e="string"==typeof l.tagName?l.tagName:"string"==typeof l.name?l.name:void 0;Object.defineProperty(h,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return h;function h(){var l;let h,c,d,p=ia;if((!n||u(i,r,s[s.length-1]||void 0))&&!1===(p=Array.isArray(l=o(i,s))?l:"number"==typeof l?[!0,l]:null==l?ia:[l])[0])return p;if("children"in i&&i.children&&i.children&&"skip"!==p[0])for(c=(a?i.children.length:-1)+f,d=s.concat(i);c>-1&&c<i.children.length;){if(!1===(h=e(i.children[c],c,d)())[0])return h;c="number"==typeof h[1]?h[1]:c+f}return p}})(e,void 0,[])()}function ih(e,i){let r=i.referenceType,s="]";if("collapsed"===r?s+="[]":"full"===r&&(s+="["+(i.label||i.identifier)+"]"),"imageReference"===i.type)return[{type:"text",value:"!["+i.alt+s}];let n=e.all(i),o=n[0];o&&"text"===o.type?o.value="["+o.value:n.unshift({type:"text",value:"["});let a=n[n.length-1];return a&&"text"===a.type?a.value+=s:n.push({type:"text",value:s}),n}function ic(e){let i=e.spread;return null==i?e.children.length>1:i}function id(e,i,r){let s=0,n=e.length;if(i){let i=e.codePointAt(s);for(;9===i||32===i;)s++,i=e.codePointAt(s)}if(r){let i=e.codePointAt(n-1);for(;9===i||32===i;)n--,i=e.codePointAt(n-1)}return n>s?e.slice(s,n):""}let iu={blockquote:function(e,i){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(i),!0)};return e.patch(i,r),e.applyData(i,r)},break:function(e,i){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(i,r),[e.applyData(i,r),{type:"text",value:"\n"}]},code:function(e,i){let r=i.value?i.value+"\n":"",s={},n=i.lang?i.lang.split(/\s+/):[];n.length>0&&(s.className=["language-"+n[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:r}]};return i.meta&&(o.data={meta:i.meta}),e.patch(i,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(i,o)]},e.patch(i,o),o},delete:function(e,i){let r={type:"element",tagName:"del",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},emphasis:function(e,i){let r={type:"element",tagName:"em",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},footnoteReference:function(e,i){let r,s="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=String(i.identifier).toUpperCase(),o=ie(n.toLowerCase()),a=e.footnoteOrder.indexOf(n),l=e.footnoteCounts.get(n);void 0===l?(l=0,e.footnoteOrder.push(n),r=e.footnoteOrder.length):r=a+1,l+=1,e.footnoteCounts.set(n,l);let h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(i,h);let c={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(i,c),e.applyData(i,c)},heading:function(e,i){let r={type:"element",tagName:"h"+i.depth,properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},html:function(e,i){if(e.options.allowDangerousHtml){let r={type:"raw",value:i.value};return e.patch(i,r),e.applyData(i,r)}},imageReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return ih(e,i);let n={src:ie(s.url||""),alt:i.alt};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"img",properties:n,children:[]};return e.patch(i,o),e.applyData(i,o)},image:function(e,i){let r={src:ie(i.url)};null!==i.alt&&void 0!==i.alt&&(r.alt=i.alt),null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(i,s),e.applyData(i,s)},inlineCode:function(e,i){let r={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};e.patch(i,r);let s={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(i,s),e.applyData(i,s)},linkReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return ih(e,i);let n={href:ie(s.url||"")};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"a",properties:n,children:e.all(i)};return e.patch(i,o),e.applyData(i,o)},link:function(e,i){let r={href:ie(i.url)};null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"a",properties:r,children:e.all(i)};return e.patch(i,s),e.applyData(i,s)},listItem:function(e,i,r){let s=e.all(i),n=r?function(e){let i=!1;if("list"===e.type){i=e.spread||!1;let r=e.children,s=-1;for(;!i&&++s<r.length;)i=ic(r[s])}return i}(r):ic(i),o={},a=[];if("boolean"==typeof i.checked){let e,r=s[0];r&&"element"===r.type&&"p"===r.tagName?e=r:(e={type:"element",tagName:"p",properties:{},children:[]},s.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<s.length;){let e=s[l];(n||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||n?a.push(e):a.push(...e.children)}let h=s[s.length-1];h&&(n||"element"!==h.type||"p"!==h.tagName)&&a.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:o,children:a};return e.patch(i,c),e.applyData(i,c)},list:function(e,i){let r={},s=e.all(i),n=-1;for("number"==typeof i.start&&1!==i.start&&(r.start=i.start);++n<s.length;){let e=s[n];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}let o={type:"element",tagName:i.ordered?"ol":"ul",properties:r,children:e.wrap(s,!0)};return e.patch(i,o),e.applyData(i,o)},paragraph:function(e,i){let r={type:"element",tagName:"p",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},root:function(e,i){let r={type:"root",children:e.wrap(e.all(i))};return e.patch(i,r),e.applyData(i,r)},strong:function(e,i){let r={type:"element",tagName:"strong",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},table:function(e,i){let r=e.all(i),s=r.shift(),n=[];if(s){let r={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(i.children[0],r),n.push(r)}if(r.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},o=ex(i.children[1]),a=ev(i.children[i.children.length-1]);o&&a&&(s.position={start:o,end:a}),n.push(s)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(n,!0)};return e.patch(i,o),e.applyData(i,o)},tableCell:function(e,i){let r={type:"element",tagName:"td",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},tableRow:function(e,i,r){let s=r?r.children:void 0,n=0===(s?s.indexOf(i):1)?"th":"td",o=r&&"table"===r.type?r.align:void 0,a=o?o.length:i.children.length,l=-1,h=[];for(;++l<a;){let r=i.children[l],s={},a=o?o[l]:void 0;a&&(s.align=a);let c={type:"element",tagName:n,properties:s,children:[]};r&&(c.children=e.all(r),e.patch(r,c),c=e.applyData(r,c)),h.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(i,c),e.applyData(i,c)},text:function(e,i){let r={type:"text",value:function(e){let i=String(e),r=/\r?\n|\r/g,s=r.exec(i),n=0,o=[];for(;s;)o.push(id(i.slice(n,s.index),n>0,!0),s[0]),n=s.index+s[0].length,s=r.exec(i);return o.push(id(i.slice(n),n>0,!1)),o.join("")}(String(i.value))};return e.patch(i,r),e.applyData(i,r)},thematicBreak:function(e,i){let r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(i,r),e.applyData(i,r)},toml:ip,yaml:ip,definition:ip,footnoteDefinition:ip};function ip(){}let i_={}.hasOwnProperty,im={};function ig(e,i){e.position&&(i.position=function(e){let i=ex(e),r=ev(e);if(i&&r)return{start:i,end:r}}(e))}function iv(e,i){let r=i;if(e&&e.data){let i=e.data.hName,s=e.data.hChildren,n=e.data.hProperties;"string"==typeof i&&("element"===r.type?r.tagName=i:r={type:"element",tagName:i,properties:{},children:"children"in r?r.children:[r]}),"element"===r.type&&n&&Object.assign(r.properties,t7(n)),"children"in r&&r.children&&null!=s&&(r.children=s)}return r}function ix(e,i){let r=[],s=-1;for(i&&r.push({type:"text",value:"\n"});++s<e.length;)s&&r.push({type:"text",value:"\n"}),r.push(e[s]);return i&&e.length>0&&r.push({type:"text",value:"\n"}),r}function ib(e){let i=0,r=e.charCodeAt(i);for(;9===r||32===r;)i++,r=e.charCodeAt(i);return e.slice(i)}function iy(e,i){let r,s,n,o,a=(r=i||im,s=new Map,n=new Map,o={all:function(e){let i=[];if("children"in e){let r=e.children,s=-1;for(;++s<r.length;){let n=o.one(r[s],e);if(n){if(s&&"break"===r[s-1].type&&(Array.isArray(n)||"text"!==n.type||(n.value=ib(n.value)),!Array.isArray(n)&&"element"===n.type)){let e=n.children[0];e&&"text"===e.type&&(e.value=ib(e.value))}Array.isArray(n)?i.push(...n):i.push(n)}}}return i},applyData:iv,definitionById:s,footnoteById:n,footnoteCounts:new Map,footnoteOrder:[],handlers:{...iu,...r.handlers},one:function(e,i){let r=e.type,s=o.handlers[r];if(i_.call(o.handlers,r)&&s)return s(o,e,i);if(o.options.passThrough&&o.options.passThrough.includes(r)){if("children"in e){let{children:i,...r}=e,s=t7(r);return s.children=o.all(e),s}return t7(e)}return(o.options.unknownHandler||function(e,i){let r=i.data||{},s="value"in i&&!(i_.call(r,"hProperties")||i_.call(r,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:e.all(i)};return e.patch(i,s),e.applyData(i,s)})(o,e,i)},options:r,patch:ig,wrap:ix},il(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let i="definition"===e.type?s:n,r=String(e.identifier).toUpperCase();i.has(r)||i.set(r,e)}}),o),l=a.one(e,void 0),h=function(e){let i="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||it,s=e.options.footnoteBackLabel||ii,n=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],h=-1;for(;++h<e.footnoteOrder.length;){let n=e.footnoteById.get(e.footnoteOrder[h]);if(!n)continue;let o=e.all(n),a=String(n.identifier).toUpperCase(),c=ie(a.toLowerCase()),d=0,u=[],f=e.footnoteCounts.get(a);for(;void 0!==f&&++d<=f;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof r?r:r(h,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof s?s:s(h,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...u)}else o.push(...u);let _={type:"element",tagName:"li",properties:{id:i+"fn-"+c},children:e.wrap(o,!0)};e.patch(n,_),l.push(_)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...t7(a),id:"footnote-label"},children:[{type:"text",value:n}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(a),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return h&&(T("children"in c),c.children.push({type:"text",value:"\n"},h)),c}function iS(e,i){return e&&"run"in e?async function(r,s){let n=iy(r,{file:s,...i});await e.run(n,s)}:function(r,s){return iy(r,{file:s,...e||i})}}function iw(e){if(e)throw e}var iC=e.i(4100);function ik(e){if("object"!=typeof e||null===e)return!1;let i=Object.getPrototypeOf(e);return(null===i||i===Object.prototype||null===Object.getPrototypeOf(i))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let iE=function(e,i){let r;if(void 0!==i&&"string"!=typeof i)throw TypeError('"ext" argument must be a string');iT(e);let s=0,n=-1,o=e.length;if(void 0===i||0===i.length||i.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else n<0&&(r=!0,n=o+1);return n<0?"":e.slice(s,n)}if(i===e)return"";let a=-1,l=i.length-1;for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else a<0&&(r=!0,a=o+1),l>-1&&(e.codePointAt(o)===i.codePointAt(l--)?l<0&&(n=o):(l=-1,n=a));return s===n?n=a:n<0&&(n=e.length),e.slice(s,n)},iN=function(e){let i;if(iT(e),0===e.length)return".";let r=-1,s=e.length;for(;--s;)if(47===e.codePointAt(s)){if(i){r=s;break}}else i||(i=!0);return r<0?47===e.codePointAt(0)?"/":".":1===r&&47===e.codePointAt(0)?"//":e.slice(0,r)},iR=function(e){let i;iT(e);let r=e.length,s=-1,n=0,o=-1,a=0;for(;r--;){let l=e.codePointAt(r);if(47===l){if(i){n=r+1;break}continue}s<0&&(i=!0,s=r+1),46===l?o<0?o=r:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||s<0||0===a||1===a&&o===s-1&&o===n+1?"":e.slice(o,s)},ij=function(...e){var i;let r,s,n,o=-1;for(;++o<e.length;)iT(e[o]),e[o]&&(n=void 0===n?e[o]:n+"/"+e[o]);return void 0===n?".":(iT(i=n),r=47===i.codePointAt(0),0!==(s=function(e,i){let r,s,n="",o=0,a=-1,l=0,h=-1;for(;++h<=e.length;){if(h<e.length)r=e.codePointAt(h);else if(47===r)break;else r=47;if(47===r){if(a===h-1||1===l);else if(a!==h-1&&2===l){if(n.length<2||2!==o||46!==n.codePointAt(n.length-1)||46!==n.codePointAt(n.length-2)){if(n.length>2){if((s=n.lastIndexOf("/"))!==n.length-1){s<0?(n="",o=0):o=(n=n.slice(0,s)).length-1-n.lastIndexOf("/"),a=h,l=0;continue}}else if(n.length>0){n="",o=0,a=h,l=0;continue}}i&&(n=n.length>0?n+"/..":"..",o=2)}else n.length>0?n+="/"+e.slice(a+1,h):n=e.slice(a+1,h),o=h-a-1;a=h,l=0}else 46===r&&l>-1?l++:l=-1}return n}(i,!r)).length||r||(s="."),s.length>0&&47===i.codePointAt(i.length-1)&&(s+="/"),r?"/"+s:s)};function iT(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function iD(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let iM=["history","path","basename","stem","extname","dirname"];class iL{constructor(e){let i,r;i=e?iD(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in i?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<iM.length;){const e=iM[s];e in i&&void 0!==i[e]&&null!==i[e]&&(this[e]="history"===e?[...i[e]]:i[e])}for(r in i)iM.includes(r)||(this[r]=i[r])}get basename(){return"string"==typeof this.path?iE(this.path):void 0}set basename(e){iA(e,"basename"),iP(e,"basename"),this.path=ij(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?iN(this.path):void 0}set dirname(e){iB(this.basename,"dirname"),this.path=ij(e||"",this.basename)}get extname(){return"string"==typeof this.path?iR(this.path):void 0}set extname(e){if(iP(e,"extname"),iB(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=ij(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){iD(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!iD(e)){let i=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let i=e.pathname,r=-1;for(;++r<i.length;)if(37===i.codePointAt(r)&&50===i.codePointAt(r+1)){let e=i.codePointAt(r+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(i)}(e)}(e)),iA(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?iE(this.path,this.extname):void 0}set stem(e){iA(e,"stem"),iP(e,"stem"),this.path=ij(this.dirname||"",e+(this.extname||""))}fail(e,i,r){let s=this.message(e,i,r);throw s.fatal=!0,s}info(e,i,r){let s=this.message(e,i,r);return s.fatal=void 0,s}message(e,i,r){let s=new ek(e,i,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function iP(e,i){if(e&&e.includes("/"))throw Error("`"+i+"` cannot be a path: did not expect `/`")}function iA(e,i){if(!e)throw Error("`"+i+"` cannot be empty")}function iB(e,i){if(!e)throw Error("Setting `"+i+"` requires `path` to be set too")}let iI=function(e){let i=this.constructor.prototype,r=i[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,i),s},iO={}.hasOwnProperty;class iF extends iI{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],i={run:function(...i){let r=-1,s=i.pop();if("function"!=typeof s)throw TypeError("Expected function as last argument, not "+s);!function n(o,...a){let l=e[++r],h=-1;if(o)return void s(o);for(;++h<i.length;)(null===a[h]||void 0===a[h])&&(a[h]=i[h]);i=a,l?(function(e,i){let r;return function(...i){let o,a=e.length>i.length;a&&i.push(s);try{o=e.apply(this,i)}catch(e){if(a&&r)throw e;return s(e)}a||(o&&o.then&&"function"==typeof o.then?o.then(n,s):o instanceof Error?s(o):n(o))};function s(e,...n){r||(r=!0,i(e,...n))}function n(e){s(null,e)}})(l,n)(...a):s(null,...a)}(null,...i)},use:function(r){if("function"!=typeof r)throw TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),i}};return i}()}copy(){let e=new iF,i=-1;for(;++i<this.attachers.length;){let r=this.attachers[i];e.use(...r)}return e.data((0,iC.default)(!0,{},this.namespace)),e}data(e,i){return"string"==typeof e?2==arguments.length?(iW("data",this.frozen),this.namespace[e]=i,this):iO.call(this.namespace,e)&&this.namespace[e]||void 0:e?(iW("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...i]=this.attachers[this.freezeIndex];if(!1===i[0])continue;!0===i[0]&&(i[0]=void 0);let r=e.call(this,...i);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let i=iq(e),r=this.parser||this.Parser;return iz("parse",r),r(String(i),i)}process(e,i){let r=this;return this.freeze(),iz("process",this.parser||this.Parser),i$("process",this.compiler||this.Compiler),i?s(void 0,i):new Promise(s);function s(s,n){let o=iq(e),a=r.parse(o);function l(e,r){e||!r?n(e):s?s(r):(T(i,"`done` is defined if `resolve` is not"),i(void 0,r))}r.run(a,o,function(e,i,s){var n,o;if(e||!i||!s)return l(e);let a=r.stringify(i,s);"string"==typeof(n=a)||(o=n)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?s.value=a:s.result=a,l(e,s)})}}processSync(e){let i,r=!1;return this.freeze(),iz("processSync",this.parser||this.Parser),i$("processSync",this.compiler||this.Compiler),this.process(e,function(e,s){r=!0,iw(e),i=s}),iK("processSync","process",r),T(i,"we either bailed on an error or have a tree"),i}run(e,i,r){iU(e),this.freeze();let s=this.transformers;return r||"function"!=typeof i||(r=i,i=void 0),r?n(void 0,r):new Promise(n);function n(n,o){T("function"!=typeof i,"`file` can’t be a `done` anymore, we checked");let a=iq(i);s.run(e,a,function(i,s,a){let l=s||e;i?o(i):n?n(l):(T(r,"`done` is defined if `resolve` is not"),r(void 0,l,a))})}}runSync(e,i){let r,s=!1;return this.run(e,i,function(e,i){iw(e),r=i,s=!0}),iK("runSync","run",s),T(r,"we either bailed on an error or have a tree"),r}stringify(e,i){this.freeze();let r=iq(i),s=this.compiler||this.Compiler;return i$("stringify",s),iU(e),s(e,r)}use(e,...i){let r=this.attachers,s=this.namespace;if(iW("use",this.frozen),null==e);else if("function"==typeof e)a(e,i);else if("object"==typeof e)Array.isArray(e)?o(e):n(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function n(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(s.settings=(0,iC.default)(!0,s.settings,e.settings))}function o(e){let i=-1;if(null==e);else if(Array.isArray(e))for(;++i<e.length;)!function(e){if("function"==typeof e)a(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[i,...r]=e;a(i,r)}else n(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[i]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function a(e,i){let s=-1,n=-1;for(;++s<r.length;)if(r[s][0]===e){n=s;break}if(-1===n)r.push([e,...i]);else if(i.length>0){let[s,...o]=i,a=r[n][1];ik(a)&&ik(s)&&(s=(0,iC.default)(!0,a,s)),r[n]=[e,s,...o]}}}}let iH=new iF().freeze();function iz(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `parser`")}function i$(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `compiler`")}function iW(e,i){if(i)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function iU(e){if(!ik(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function iK(e,i,r){if(!r)throw Error("`"+e+"` finished async. Use `"+i+"` instead")}function iq(e){var i;return(i=e)&&"object"==typeof i&&"message"in i&&"messages"in i?e:new iL(e)}let iV=[],iY={allowDangerousHtml:!0},iG=/^(https?|ircs?|mailto|xmpp)$/i,iX=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function iJ(e){var i;let r,s,n,o,a,l=(r=(i=e).rehypePlugins||iV,s=i.remarkPlugins||iV,n=i.remarkRehypeOptions?{...i.remarkRehypeOptions,...iY}:iY,iH().use(t1).use(s).use(iS,n).use(r)),h=(o=e.children||"",a=new iL,"string"==typeof o?a.value=o:D("Unexpected value `"+o+"` for `children` prop, expected `string`"),a);return function(e,i){let r=i.allowedElements,s=i.allowElement,n=i.components,o=i.disallowedElements,a=i.skipHtml,l=i.unwrapDisallowed,h=i.urlTransform||iQ;for(let e of iX)Object.hasOwn(i,e.from)&&D("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return r&&o&&D("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),il(e,function(e,i,n){if("raw"===e.type&&n&&"number"==typeof i)return a?n.children.splice(i,1):n.children[i]={type:"text",value:e.value},i;if("element"===e.type){let i;for(i in eF)if(Object.hasOwn(eF,i)&&Object.hasOwn(e.properties,i)){let r=e.properties[i],s=eF[i];(null===s||s.includes(e.tagName))&&(e.properties[i]=h(String(r||""),i,e))}}if("element"===e.type){let a=r?!r.includes(e.tagName):!!o&&o.includes(e.tagName);if(!a&&s&&"number"==typeof i&&(a=!s(e,i,n)),a&&n&&"number"==typeof i)return l&&e.children?n.children.splice(i,1,...e.children):n.children.splice(i,1),i}}),function(e,i){var r,s,n,o;let a;if(!i||void 0===i.Fragment)throw TypeError("Expected `Fragment` in options");let l=i.filePath||void 0;if(i.development){if("function"!=typeof i.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=l,s=i.jsxDEV,a=function(e,i,n,o){let a=Array.isArray(n.children),l=ex(e);return s(i,n,o,a,{columnNumber:l?l.column-1:void 0,fileName:r,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof i.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof i.jsxs)throw TypeError("Expected `jsxs` in production options");n=i.jsx,o=i.jsxs,a=function(e,i,r,s){let a=Array.isArray(r.children)?o:n;return s?a(i,r,s):a(i,r)}}let h={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:a,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:!1!==i.passKeys,passNode:i.passNode||!1,schema:"svg"===i.space?em:e_,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==i.tableCellAlignToStyle},c=eM(h,e,void 0);return c&&"string"!=typeof c?c:h.create(e,h.Fragment,{children:c||void 0},void 0)}(e,{Fragment:p.Fragment,components:n,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0})}(l.runSync(l.parse(h),h),e)}function iQ(e){let i=e.indexOf(":"),r=e.indexOf("?"),s=e.indexOf("#"),n=e.indexOf("/");return -1===i||-1!==n&&i>n||-1!==r&&i>r||-1!==s&&i>s||iG.test(e.slice(0,i))?e:""}function iZ({projectId:e,startInEditMode:i=!1}){let[r,s]=(0,_.useState)(""),[n,o]=(0,_.useState)(null),[a,l]=(0,_.useState)(i),[h,c]=(0,_.useState)(""),[d,u]=(0,_.useState)(!1),[f,m]=(0,_.useState)(null),g=(0,_.useRef)(!1);g.current=a;let v=(0,_.useRef)(i),x=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();o(!!r.exists),g.current||s(r.content||""),v.current&&(c(r.content||""),v.current=!1),m(null)}catch(e){m(e.message)}},[e]);(0,_.useEffect)(()=>{x();let e=setInterval(x,1e4);return()=>clearInterval(e)},[x]);let b=async()=>{u(!0),m(null);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})});if(!i.ok)throw Error(`${i.status}`);s(h),l(!1)}catch(e){m(e.message)}finally{u(!1)}},y=async()=>{u(!0);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"});if(!i.ok)throw Error(`${i.status}`);await x()}catch(e){m(e.message)}finally{u(!1)}};return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0 border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",f]}),!a&&n&&(0,p.jsx)("button",{onClick:()=>{c(r),l(!0)},className:"text-[10px] text-text-muted hover:text-accent uppercase tracking-wider",children:"Edit"}),a&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("button",{onClick:b,disabled:d,className:"text-[10px] text-accent hover:text-accent-dim uppercase tracking-wider disabled:opacity-50",children:d?"Saving…":"Save"}),(0,p.jsx)("button",{onClick:()=>{l(!1),c(""),x()},disabled:d,className:"text-[10px] text-text-muted hover:text-text uppercase tracking-wider disabled:opacity-50",children:"Cancel"})]})]})]}),a&&(0,p.jsx)("div",{className:"shrink-0 px-3 py-1.5 border-b border-border bg-bg-surface text-[10px] text-text-muted leading-snug",children:"⚠️ Editing manually may conflict with the Head agent. Use the chat panel to ask Head to update the queue when possible."}),(0,p.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:!1===n?(0,p.jsxs)("div",{className:"p-3 text-[11px] text-text-muted",children:[(0,p.jsx)("p",{className:"mb-2",children:"No OVERNIGHT-QUEUE.md for this project yet."}),(0,p.jsx)("button",{onClick:y,disabled:d,className:"px-2 py-1 border border-border hover:border-accent hover:text-accent text-[11px] disabled:opacity-50",children:"Create OVERNIGHT-QUEUE.md from template"})]}):a?(0,p.jsx)("textarea",{value:h,onChange:e=>c(e.target.value),spellCheck:!1,className:"w-full h-full p-3 bg-bg text-text text-[11px] font-mono resize-none outline-none"}):(0,p.jsx)("div",{className:"p-3 text-[12px] text-text prose prose-invert prose-sm max-w-none [&_h1]:text-[14px] [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-2 [&_h2]:text-[13px] [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1.5 [&_h3]:text-[12px] [&_h3]:font-semibold [&_h3]:mt-2 [&_h3]:mb-1 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ul]:pl-4 [&_ul]:list-disc [&_ol]:my-1.5 [&_ol]:pl-4 [&_ol]:list-decimal [&_li]:my-0.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-2 [&_blockquote]:text-text-muted [&_hr]:my-3 [&_hr]:border-border [&_code]:bg-bg-surface [&_code]:px-1 [&_code]:rounded [&_code]:text-[11px] [&_strong]:text-text [&_a]:text-accent [&_a]:underline",children:(0,p.jsx)(iJ,{children:r})})})]})}function i0({open:e,projectId:i,onClose:r}){return((0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),e)?(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"queue-modal-title",children:(0,p.jsxs)("div",{className:"relative mx-4 w-full max-w-3xl h-[80vh] flex flex-col rounded-lg border border-white/10 bg-neutral-950 shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,p.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/10",children:[(0,p.jsx)("h2",{id:"queue-modal-title",className:"text-[12px] font-semibold text-white",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})})]}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(iZ,{projectId:i,startInEditMode:!0})})]})}):null}let i1={en:{loading:"Loading batch progress…",currentBatchNone:"Current Batch: (none)",noActiveBatch:"No active batch. Ask Head to start one via the chat.",currentBatch:e=>`Current Batch: Batch ${e}`,complete:"✅ COMPLETE",allMerged:e=>`All ${e} items merged. Waiting for the next batch.`,itemsCount:e=>`(${e} items)`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Current Batch"}),"— progress tracker for the active batch. Polls GitHub to resolve each issue's status (queued → in review → approved → merged)."]})},ko:{loading:"배치 진행 상황 로딩 중...",currentBatchNone:"현재 배치: (없음)",noActiveBatch:"활성 배치가 없습니다. 채팅에서 Head에게 시작을 요청하세요.",currentBatch:e=>`현재 배치: ${e}번`,complete:"✅ 완료",allMerged:e=>`${e}개 항목 모두 병합됨. 다음 배치를 기다리는 중.`,itemsCount:e=>`(${e}개 항목)`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"현재 배치"})," - 활성 배치 진행 상황 추적기입니다. GitHub를 조회해 각 이슈 상태를 대기 → 검토 중 → 승인 → 병합 순으로 추적합니다."]})}};function i2({percent:e}){let i=Math.round(e/100*20);return(0,p.jsxs)("span",{className:"font-mono text-[11px] tabular-nums whitespace-nowrap",children:[(0,p.jsx)("span",{className:"text-accent",children:"█".repeat(i)}),(0,p.jsx)("span",{className:"text-text-muted",children:"░".repeat(20-i)})]})}function i5({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=i1[i],[s,n]=(0,_.useState)(null),o=(0,_.useCallback)(()=>{fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&n(e)}).catch(()=>{})},[e]);return((0,_.useEffect)(()=>{o();let e=setInterval(o,3e4);return()=>clearInterval(e)},[o]),s)?s.items&&0!==s.items.length?s.complete?(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.currentBatch(s.batch_number??"—")}),(0,p.jsx)("span",{className:"text-[10px] text-accent",children:r.complete})]}),(0,p.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:r.allMerged(s.items.length)})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-border/40",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.currentBatch(s.batch_number??"—")}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted",children:r.itemsCount(s.items.length)}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsx)("div",{className:"max-h-40 overflow-y-auto",children:s.items.map(e=>{let i=(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 font-mono",children:[(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0 tabular-nums",children:["#",e.issue_number]}),(0,p.jsx)(i2,{percent:e.progress}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted tabular-nums shrink-0 w-9 text-right",children:[e.progress,"%"]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.label})]});return e.url?(0,p.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block hover:bg-[#1a1a1a] transition-colors border-b border-border/30",children:i},e.issue_number):(0,p.jsx)("div",{children:i},e.issue_number)})}),s.summary&&(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border/40",children:s.summary})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsx)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.currentBatchNone})}),(0,p.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:r.noActiveBatch})]}):(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border",children:r.loading})}let i3={en:{rateLimitCritical:e=>`GitHub Rate Limit CRITICAL: 0 remaining. Resets in ${e}m.`,rateLimitLow:(e,i,r)=>`GitHub Rate Limit LOW: ${e}/${i} remaining. Resets in ${r}m.`,issues:e=>`Issues (${e})`,issuesHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Issues"})," — open issues in this repository. Agents will pick these up automatically if they are part of the overnight queue."]}),noIssues:"No open issues.",recentlyClosed:"Recently closed",noneYet:"None yet.",prs:e=>`Pull Requests (${e})`,prsHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Pull Requests"})," — active PRs in this repository. Shows review status from RE1/RE2 and CI status."]}),noPrs:"No active PRs.",recentlyMerged:"Recently merged / closed",overnightQueueHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"OVERNIGHT-QUEUE.md"})," — a list of issue numbers (one per line) for agents to process autonomously. Edit this file to add or remove tasks from the queue."]}),edit:"Edit"},ko:{rateLimitCritical:e=>`GitHub API 제한 위험: 잔여 0개. ${e}분 후 초기화됩니다.`,rateLimitLow:(e,i,r)=>`GitHub API 제한 낮음: ${e}/${i} 남음. ${r}분 후 초기화됩니다.`,issues:e=>`이슈 (${e})`,issuesHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"이슈"})," - 이 저장소의 열려 있는 이슈들입니다. 야간 큐에 포함되면 에이전트가 자동으로 작업을 시작합니다."]}),noIssues:"열린 이슈가 없습니다.",recentlyClosed:"최근 닫힌 이슈",noneYet:"아직 없습니다.",prs:e=>`풀 리퀘스트 (${e})`,prsHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"풀 리퀘스트"})," - 이 저장소의 활성화된 PR들입니다. RE1/RE2의 리뷰 상태와 CI 상태를 보여줍니다."]}),noPrs:"활성 PR이 없습니다.",recentlyMerged:"최근 머지/닫힘",overnightQueueHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"OVERNIGHT-QUEUE.md"})," - 에이전트가 자율적으로 처리할 이슈 번호 목록(한 줄에 하나씩)입니다. 이 파일을 편집하여 큐에 작업을 추가하거나 제거할 수 있습니다."]}),edit:"편집"}};function i4({color:e}){return(0,p.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${e}`})}function i6({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=i3[i],[s,n]=(0,_.useState)([]),[o,a]=(0,_.useState)([]),[l,h]=(0,_.useState)([]),[c,d]=(0,_.useState)([]),[u,f]=(0,_.useState)(!1),[m,v]=(0,_.useState)(null);(0,_.useEffect)(()=>{let i=!1;return fetch(`/api/queue?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(r=>{if(!i&&r&&!r.exists)return fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"})}).catch(()=>{}),()=>{i=!0}},[e]);let b=(0,_.useCallback)(()=>{fetch(`/api/github/issues?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&n(e)}).catch(()=>{}),fetch(`/api/github/prs?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&a(e)}).catch(()=>{}),fetch(`/api/github/closed-issues?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&h(e)}).catch(()=>{}),fetch(`/api/github/merged-prs?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&d(e)}).catch(()=>{})},[e]);return(0,_.useEffect)(()=>{let e=()=>{fetch("/api/github/rate-limit").then(e=>e.ok?e.json():null).then(e=>{e&&v(e)}).catch(()=>{})};e();let i=setInterval(e,6e4);return()=>clearInterval(i)},[]),(0,_.useEffect)(()=>{b();let e=setInterval(b,3e4);return()=>clearInterval(e)},[b]),(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[m&&(m.critical||m.low)&&(0,p.jsx)("div",{className:`px-3 py-1 text-[10px] shrink-0 ${m.critical?"bg-error/20 text-error":"bg-[#ffcc00]/20 text-[#ffcc00]"}`,children:m.critical?r.rateLimitCritical(m.resetInMinutes):r.rateLimitLow(m.remaining,m.limit,m.resetInMinutes)}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row",children:[(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col border-b lg:border-b-0 lg:border-r border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.issues(s.length)}),(0,p.jsx)(g,{children:r.issuesHelp})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===s.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:r.noIssues}),s.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i4,{color:"OPEN"===e.state?"bg-accent":"bg-error"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login})]},e.number)),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:r.recentlyClosed}),0===l.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:r.noneYet}),l.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`closed-${e.number}`))]})]}),(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.prs(o.length)}),(0,p.jsx)(g,{children:r.prsHelp})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===o.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:r.noPrs}),o.map(e=>{let i=e.reviews||[],r=e.reviewDecision||"REVIEW_REQUIRED",s={};for(let e of i){let i=(e.body||"").trim();/^(?:RE2|Reviewer2|T2b)\b/i.test(i)?s.re2=e.state:(/^(?:RE1|Reviewer1|T2a)\b/i.test(i)||/^##\s*Verdict/i.test(i))&&(s.re1=e.state)}return(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i4,{color:"APPROVED"===r?"bg-accent":"CHANGES_REQUESTED"===r?"bg-error":"bg-[#ffcc00]"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login}),["re1","re2"].map(e=>{let i=s[e];return(0,p.jsxs)("span",{className:`text-[10px] shrink-0 ${i?"APPROVED"===i?"text-accent":"CHANGES_REQUESTED"===i?"text-error":"text-[#ffcc00]":"text-text-muted"}`,children:[e,":",i?"APPROVED"===i?"ok":"CHANGES_REQUESTED"===i?"chg":"rev":"—"]},e)}),(0,p.jsx)("span",{className:`text-[10px] shrink-0 ${function(e){if(!e||0===e.length)return"text-text-muted";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"text-accent":i.some(e=>"FAILURE"===e||"ERROR"===e)?"text-error":"text-[#ffcc00]"}(e.statusCheckRollup)}`,children:function(e){if(!e||0===e.length)return"—";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"pass":i.some(e=>"FAILURE"===e||"ERROR"===e)?"fail":"run"}(e.statusCheckRollup)})]},e.number)}),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:r.recentlyMerged}),0===c.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:r.noneYet}),c.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`merged-${e.number}`))]})]})]}),(0,p.jsx)("div",{className:"shrink-0",children:(0,p.jsx)(i5,{projectId:e})}),(0,p.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5 border-t border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsx)(g,{position:"above",children:r.overnightQueueHelp})]}),(0,p.jsx)("button",{onClick:()=>f(!0),className:"px-2 py-0.5 text-[10px] text-text-muted hover:text-accent border border-border hover:border-accent transition-colors uppercase tracking-wider",children:r.edit})]}),(0,p.jsx)(i0,{open:u,projectId:e,onClose:()=>f(!1)})]})}var i9=e.i(67449);let i8={en:{server:{title:"Server",stop:"Stop",confirmStop:"Confirm Stop?",restart:"Restart",resetAgents:"Reset Agents",healthGaveUp:"AC auto-restart failed 3x — manual restart required",healthRestarted:e=>`AC auto-restarted at ${e}`,stopped:"Stopped",failed:"Failed",error:"Error",acRestarted:e=>`AC restarted (PID: ${e}) — resetting agents...`,acAndAgentsRestarted:e=>`AC + ${e} agent${1!==e?"s":""} restarted`,agentResetFailed:"AC restarted — agent reset failed",resetResult:(e,i)=>`Reset — ${e} of ${i} agent${1!==i?"s":""} restarted`},system:{keepAwake:"Keep Mac Awake",keepAwakeAbout:"About Keep Mac Awake",keepAwakeHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Keep Mac Awake"})," runs macOS ",(0,p.jsx)("code",{children:"caffeinate"})," to stop the screen, disk, and system idle timers from sleeping your Mac during an overnight run. Make sure the laptop is plugged in — caffeinate blocks sleep but not battery drain."]}),autoAwakeOn:"Auto-awake ON: caffeinate starts/stops with batch lifecycle",autoAwakeOff:"Auto-awake OFF: manual Start/Stop only",awakeFor:e=>`Awake for ${e} more — keep Mac plugged in`,awakeIndefinitely:"Awake indefinitely — keep Mac plugged in",awakeDesc:"Prevents your Mac from sleeping during overnight runs.",awake:"Awake",start:"Start",on:"on",sound:"Notification Sound",soundAbout:"About Notification Sound",soundHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Notification Sound"})," plays a brief chime when an agent posts a new message (not your own sends, not system events). Sound choice picks one of the bundled chimes. Background-only mode suppresses the chime while the tab is focused — ding only when you're looking elsewhere. All prefs persist in localStorage."]}),soundDesc:"Plays a chime when an agent posts a new message.",soundLabel:"Sound",soundBgOnly:"Only when tab is in background",awakeStatusActive:"Batch active — auto-started caffeinate.",awakeStatusComplete:"Batch complete — awake paused.",awakeStatusNew:"New batch detected — auto-started caffeinate.",keepAwakeModalTitle:"Keep Awake",keepAwakeModalAbout:"About Keep Awake",keepAwakeModalHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Keep Awake"})," prevents your Mac from sleeping for the duration you set. Use this when you want agents to keep working overnight.",(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),"Under the hood, this runs macOS's ",(0,p.jsx)("code",{children:"caffeinate"})," command. While it's active your screen, disk, and system idle timers are all paused — make sure your Mac is ",(0,p.jsx)("b",{children:"plugged in"})," to avoid draining the battery."]}),makeSurePluggedIn:"Make sure Mac is plugged in",for:"for",hours:"hours",untilStopped:"Until stopped (no expiry)"}},ko:{server:{title:"서버",stop:"중지",confirmStop:"정말 중지?",restart:"재시작",resetAgents:"에이전트 초기화",healthGaveUp:"AC 자동 재시작 3회 실패 — 수동 재시작이 필요합니다",healthRestarted:e=>`AC가 ${e}에 자동 재시작되었습니다`,stopped:"중지됨",failed:"실패",error:"오류",acRestarted:e=>`AC 재시작됨 (PID: ${e}) — 에이전트 초기화 중...`,acAndAgentsRestarted:e=>`AC 및 ${e}개 에이전트 재시작됨`,agentResetFailed:"AC 재시작됨 — 에이전트 초기화 실패",resetResult:(e,i)=>`초기화 완료 — ${i}개 중 ${e}개 에이전트 재시작됨`},system:{keepAwake:"Mac 절전 방지",keepAwakeAbout:"Mac 절전 방지 정보",keepAwakeHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Mac 절전 방지"}),"는 macOS의 ",(0,p.jsx)("code",{children:"caffeinate"}),"를 실행해 야간 작업 중 Mac이 절전 상태로 들어가는 것을 막습니다. 충전기를 연결해 두세요. caffeinate는 절전은 막지만 배터리 소모를 막아주지는 않습니다."]}),autoAwakeOn:"자동 절전 방지 켬: 배치 상태에 따라 caffeinate 시작/종료",autoAwakeOff:"자동 절전 방지 끔: 수동 시작/종료만 가능",awakeFor:e=>`앞으로 ${e} 동안 절전 방지 — 전원을 연결해 두세요`,awakeIndefinitely:"무기한 절전 방지 중 — 전원을 연결해 두세요",awakeDesc:"야간 작업 중 Mac이 잠들지 않도록 합니다.",awake:"절전 방지 중",start:"시작",on:"켬",sound:"알림음",soundAbout:"알림음 정보",soundHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"알림음"}),"은 에이전트가 새 메시지를 보낼 때 짧은 알림음을 재생합니다. 내 메시지나 시스템 이벤트에는 울리지 않습니다. 사운드 선택으로 내장 알림음 중 하나를 고를 수 있고, 백그라운드 전용 모드는 탭이 포커스된 동안에는 알림음을 막습니다. 모든 설정은 localStorage에 저장됩니다."]}),soundDesc:"에이전트가 새 메시지를 보낼 때 알림음을 재생합니다.",soundLabel:"알림음",soundBgOnly:"탭이 백그라운드에 있을 때만",awakeStatusActive:"배치 실행 중 — caffeinate를 자동으로 시작했습니다.",awakeStatusComplete:"배치 완료 — 절전 방지를 일시 중단했습니다.",awakeStatusNew:"새 배치 감지 — caffeinate를 자동으로 시작했습니다.",keepAwakeModalTitle:"절전 방지",keepAwakeModalAbout:"절전 방지 정보",keepAwakeModalHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"절전 방지"}),"는 설정한 시간 동안 Mac이 절전 상태로 들어가는 것을 막습니다. 에이전트가 밤새 작업하게 하려면 이 기능을 사용하세요.",(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),"내부적으로는 macOS의 ",(0,p.jsx)("code",{children:"caffeinate"})," 명령을 실행합니다. 실행 중에는 화면, 디스크, 시스템 유휴 타이머가 모두 정지됩니다. 배터리 소모를 막으려면 Mac에 ",(0,p.jsx)("b",{children:"전원을 연결"}),"해 두세요."]}),makeSurePluggedIn:"전원을 연결해 두세요",for:"시간:",hours:"시간",untilStopped:"중지할 때까지 (만료 없음)"}}};function i7({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=i8[i].server,[s,n]=(0,_.useState)(null),[o,a]=(0,_.useState)(null),[l,h]=(0,_.useState)(!1),[c,d]=(0,_.useState)(null);(0,_.useEffect)(()=>{let i=()=>{fetch(`/api/agentchattr/${encodeURIComponent(e)}/health`).then(e=>e.ok?e.json():null).then(e=>{if(!e)return void d(null);if(e.autoRestart?.gaveUp)d(r.healthGaveUp);else if(e.autoRestart?.lastRestart)if(300>Math.round((Date.now()-e.autoRestart.lastRestart)/1e3)){let i=new Date(e.autoRestart.lastRestart).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});d(r.healthRestarted(i))}else d(null);else d(null)}).catch(()=>d(null))};i();let s=setInterval(i,3e4);return()=>clearInterval(s)},[e,r]);let u=()=>{setTimeout(()=>a(null),3e3)};(0,_.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>h(!1),4e3);return()=>clearTimeout(e)},[l]);let f=async()=>{if(!l)return void h(!0);h(!1),n("stop");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/stop`,{method:"POST"}),s=await i.json();a(s.ok?r.stopped:r.failed)}catch{a(r.error)}n(null),u()},m=async()=>{n("restart");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/restart`,{method:"POST"}),s=await i.json();if(s.ok&&s.pid){a(r.acRestarted(s.pid));try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),s=await i.json();s.ok?a(r.acAndAgentsRestarted(s.restarted)):a(r.agentResetFailed)}catch{a(r.agentResetFailed)}}else a(s.error||r.failed)}catch{a(r.error)}n(null),u()},g=async()=>{n("reset");try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),s=await i.json();a(s.ok?r.resetResult(s.restarted,s.total):s.error||r.failed)}catch{a(r.error)}n(null),u()};return(0,p.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,p.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:r.title}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("button",{onClick:f,disabled:!!s,className:`px-1.5 py-0.5 text-[10px] border transition-colors disabled:opacity-50 ${l?"text-error border-error/60 bg-error/10 hover:bg-error/20":"text-text-muted border-border hover:text-error hover:border-error/40"}`,children:"stop"===s?"...":l?r.confirmStop:r.stop}),(0,p.jsx)("button",{onClick:m,disabled:!!s,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"restart"===s?"...":r.restart}),(0,p.jsx)("button",{onClick:g,disabled:!!s,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"reset"===s?"...":r.resetAgents})]}),o&&(0,p.jsx)("div",{className:"text-[10px] text-accent",children:o}),c&&!o&&(0,p.jsx)("div",{className:`text-[10px] ${c.includes("failed")||c.includes("실패")?"text-error":"text-[#ffcc00]"}`,children:c})]})}function re(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function rt(e){let i=Math.floor(e/3600),r=Math.floor(e%3600/60);return i>0?`${i}h ${r}m`:`${r}m`}function ri({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=i8[i].system,[s,n]=(0,_.useState)(!1),[o,a]=(0,_.useState)(null),[l,h]=(0,_.useState)(""),[c,d]=(0,_.useState)(!1),[u,f]=(0,_.useState)(String(3)),[m,g]=(0,_.useState)(!1),[v,b]=(0,_.useState)(!1),[y,S]=(0,_.useState)(!1),[w,C]=(0,_.useState)(null),k=(0,_.useRef)(!1),E=(0,_.useRef)(null),N=(0,_.useRef)(!1),R=(0,_.useRef)(!1);R.current=s,k.current=y;let[j,T]=(0,_.useState)(!1),[D,M]=(0,_.useState)(!1),[L,P]=(0,_.useState)(!0),[A,B]=(0,_.useState)("soft-chime"),[I,O]=(0,_.useState)(!0);(0,_.useEffect)(()=>{P((0,i9.getNotificationEnabled)()),B((0,i9.getNotificationChoice)()),O((0,i9.getNotificationBackgroundOnly)())},[]);let F=(0,_.useCallback)(()=>{fetch("/api/caffeinate/status").then(e=>e.ok?e.json():null).then(e=>{e&&(n(e.active),a(e.remaining),h(e.platform))}).catch(()=>{})},[]);(0,_.useEffect)(()=>{F();let e=setInterval(F,5e3);return()=>clearInterval(e)},[F]);let H=e=>{fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:e})}).then(e=>e.json()).then(i=>{i.ok&&(n(!0),a(e||null))}).catch(()=>{}),d(!1)};(0,_.useEffect)(()=>{S(!1),C(null),E.current=null,N.current=!1,fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.awake_auto&&S(!0)}).catch(()=>{})},[e]);let z=(0,_.useCallback)(async()=>{let i=!y;S(i),i||(C(null),E.current=null,N.current=!1);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.awake_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[y,e]),$=(0,_.useCallback)(()=>{let e=parseFloat(u),i=Math.round(3600*(Number.isFinite(e)?re(e):8));fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:i})}).then(e=>e.json()).then(e=>{e.ok&&(n(!0),a(i),N.current=!1)}).catch(()=>{})},[u]),W=(0,_.useCallback)(()=>{fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{n(!1),a(null)}).catch(()=>{})},[]);(0,_.useEffect)(()=>{if(!y)return;let i=async()=>{if(k.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=E.current;if(E.current={complete:s.complete,hasItems:n},!o){!n||s.complete||R.current||($(),C(r.awakeStatusActive)),n&&s.complete&&R.current&&(W(),C(r.awakeStatusComplete));return}n&&s.complete&&!o.complete&&R.current&&(W(),C(r.awakeStatusComplete),N.current=!1),!n||s.complete||!o.complete&&o.hasItems||R.current||N.current||($(),C(r.awakeStatusNew))}catch{}};i();let s=setInterval(i,3e4);return()=>clearInterval(s)},[y,e,$,W,r]);let U=!l||"darwin"===l;return(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6 relative",children:[U&&(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:r.keepAwake}),(0,p.jsx)("button",{type:"button","aria-label":r.keepAwakeAbout,onClick:()=>T(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),(0,p.jsxs)("button",{type:"button",onClick:z,title:y?r.autoAwakeOn:r.autoAwakeOff,className:`ml-1 px-1.5 py-0.5 text-[10px] border transition-colors ${y?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",y?"●":"○"]})]}),j&&(0,p.jsx)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:r.keepAwakeHelp}),w&&(0,p.jsx)("div",{className:"text-[10px] text-accent bg-accent/5 border border-border/50 px-1.5 py-0.5 mt-0.5",children:w}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:s&&null!==o&&o>0?r.awakeFor(rt(o)):s&&null===o?r.awakeIndefinitely:r.awakeDesc}),(0,p.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:(0,p.jsxs)("button",{onClick:()=>s?void(N.current=!0,fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{n(!1),a(null)}).catch(()=>{})):d(!c),title:"Keep Mac awake (caffeinate)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${s?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[s?r.awake:r.start,s&&null!==o&&o>0&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:rt(o)}),s&&null===o&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:r.on})]})})]}),U&&(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:r.sound}),(0,p.jsx)("button",{type:"button","aria-label":r.soundAbout,onClick:()=>M(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),D&&(0,p.jsx)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:r.soundHelp}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:r.soundDesc}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:[(0,p.jsxs)("button",{type:"button",onClick:()=>{let e=!L;P(e),(0,i9.setNotificationEnabled)(e)},title:L?"Notification sound on (click to mute)":"Notification sound off (click to unmute)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${L?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[L?"🔔":"🔕"," ",r.soundLabel]}),L&&(0,p.jsx)("select",{value:A,onChange:e=>(e=>{if(B(e),(0,i9.setNotificationChoice)(e),L)try{let i=new Audio(`/sounds/${e}.mp3`);i.volume=.6,i.play().catch(()=>{})}catch{}})(e.target.value),title:"Notification sound",className:"bg-transparent border border-border px-1 py-0.5 text-[10px] text-text outline-none focus:border-accent cursor-pointer",children:i9.NOTIFICATION_SOUND_OPTIONS.map(e=>(0,p.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))})]}),L&&(0,p.jsxs)("label",{className:"flex items-center gap-1 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:I,onChange:e=>{var i;O(i=e.target.checked),(0,i9.setNotificationBackgroundOnly)(i)}}),r.soundBgOnly]})]}),c&&!s&&(0,p.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 p-2 border border-border bg-bg-surface z-20 min-w-[220px] flex flex-col gap-1.5",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.keepAwakeModalTitle}),(0,p.jsx)("button",{type:"button","aria-label":r.keepAwakeModalAbout,onClick:()=>b(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),v&&(0,p.jsx)("div",{className:"p-1.5 text-[10px] leading-snug text-text bg-bg border border-border/60 rounded",children:r.keepAwakeModalHelp}),(0,p.jsx)("p",{className:"text-[10px] text-[#ffcc00]",children:r.makeSurePluggedIn}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:r.for}),(0,p.jsx)("input",{type:"number",value:u,onChange:e=>f(e.target.value),onBlur:()=>{let e=parseFloat(u);f(String(Math.round(10*(Number.isFinite(e)?re(e):3))/10))},disabled:m,min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-text outline-none focus:border-accent text-center disabled:opacity-40"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.hours})]}),(0,p.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:m,onChange:e=>g(e.target.checked)}),r.untilStopped]}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(m)return void H(0);let e=parseFloat(u);H(Math.round(3600*(Number.isFinite(e)?re(e):3)))},className:"self-start px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors",children:r.start})]})]})}function rr({projectId:e}){return(0,p.jsx)("div",{className:"border-t border-border px-3 py-2",children:(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6",children:[(0,p.jsx)(i7,{projectId:e}),(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsx)(ri,{projectId:e})]})})}var rs=e.i(47167),rn=Object.defineProperty,ro=Object.getOwnPropertyDescriptor,ra=(e,i,r,s)=>{for(var n,o=s>1?void 0:s?ro(i,r):i,a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s?n(i,r,o):n(o))||o);return s&&o&&rn(i,r,o),o},rl=(e,i)=>(r,s)=>i(r,s,e),rh="Terminal input",rc="Too much output to announce, navigate to rows manually to read";function rd(e,i,r,s){var n;n=e=e.replace(/\r?\n/g,"\r"),e=r.decPrivateModes.bracketedPasteMode&&!0!==s.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,r.triggerDataEvent(e,!0),i.value=""}function ru(e,i,r){let s=r.getBoundingClientRect(),n=e.clientX-s.left-10,o=e.clientY-s.top-10;i.style.width="20px",i.style.height="20px",i.style.left=`${n}px`,i.style.top=`${o}px`,i.style.zIndex="1000",i.focus()}function rf(e,i,r,s,n){ru(e,i,r),n&&s.rightClickSelect(e),i.value=s.selectionText,i.select()}function rp(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function r_(e,i=0,r=e.length){let s="";for(let n=i;n<r;++n){let i=e[n];i>65535?(i-=65536,s+=String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):s+=String.fromCharCode(i)}return s}var rm=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n=0;if(this._interim){let r=e.charCodeAt(n++);56320<=r&&r<=57343?i[s++]=(this._interim-55296)*1024+r-56320+65536:(i[s++]=this._interim,i[s++]=r),this._interim=0}for(let o=n;o<r;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return this._interim=n,s;let a=e.charCodeAt(o);56320<=a&&a<=57343?i[s++]=(n-55296)*1024+a-56320+65536:(i[s++]=n,i[s++]=a);continue}65279!==n&&(i[s++]=n)}return s}},rg=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let n=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let a=0,l;for(;(l=63&this.interim[++a])&&a<4;)o<<=6,o|=l;let h=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,d=h-a;for(;c<d;){if(c>=r)return 0;if((192&(l=e[c++]))!=128){c--,n=!0;break}this.interim[a++]=l,o<<=6,o|=63&l}n||(2===h?o<128?c--:i[s++]=o:3===h?o<2048||o>=55296&&o<=57343||65279===o||(i[s++]=o):o<65536||o>1114111||(i[s++]=o)),this.interim.fill(0)}let d=r-4,u=c;for(;u<r;){for(;u<d&&!(128&(n=e[u]))&&!(128&(o=e[u+1]))&&!(128&(a=e[u+2]))&&!(128&(l=e[u+3]));)i[s++]=n,i[s++]=o,i[s++]=a,i[s++]=l,u+=4;if((n=e[u++])<128)i[s++]=n;else if((224&n)==192){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128||(h=(31&n)<<6|63&o)<128){u--;continue}i[s++]=h}else if((240&n)==224){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(a=e[u++]))!=128){u--;continue}if((h=(15&n)<<12|(63&o)<<6|63&a)<2048||h>=55296&&h<=57343||65279===h)continue;i[s++]=h}else if((248&n)==240){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(a=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,s;if((192&(l=e[u++]))!=128){u--;continue}if((h=(7&n)<<18|(63&o)<<12|(63&a)<<6|63&l)<65536||h>1114111)continue;i[s++]=h}}return s}},rv=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rx}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let i=new e;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}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}},rx=class e{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},rb=class e extends rv{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rx,this.combinedData=""}static fromCharData(i){let r=new e;return r.setFromCharData(i),r}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?rp(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(2===e[1].length){let r=e[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ry="di$target",rS="di$dependencies",rw=new Map;function rC(e){if(rw.has(e))return rw.get(e);let i=function(e,r,s){var n,o,a;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=i,o=e,a=s,o[ry]===o?o[rS].push({id:n,index:a}):(o[rS]=[{id:n,index:a}],o[ry]=o)};return i._id=e,rw.set(e,i),i}var rk=rC("BufferService"),rE=rC("CoreMouseService"),rN=rC("CoreService"),rR=rC("CharsetService"),rj=rC("InstantiationService"),rT=rC("LogService"),rD=rC("OptionsService"),rM=rC("OscLinkService"),rL=rC("UnicodeService"),rP=rC("DecorationService"),rA=class{constructor(e,i,r){this._bufferService=e,this._optionsService=i,this._oscLinkService=r}provideLinks(e,i){let r=this._bufferService.buffer.lines.get(e-1);if(!r)return void i(void 0);let s=[],n=this._optionsService.rawOptions.linkHandler,o=new rb,a=r.getTrimmedLength(),l=-1,h=-1,c=!1;for(let i=0;i<a;i++)if(!(-1===h&&!r.hasContent(i))){if(r.loadCell(i,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===h){h=i,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else -1!==h&&(c=!0);if(c||-1!==h&&i===a-1){let r=this._oscLinkService.getLinkData(l)?.uri;if(r){let o={start:{x:h+1,y:e},end:{x:i+ +(!c&&i===a-1),y:e}},l=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(r);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||s.push({text:r,range:o,activate:(e,i)=>n?n.activate(e,i,o):function(e){if(confirm(`Do you want to navigate to ${e}?
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26568,(e,i,r)=>{"use strict";var s=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,o=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,h=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}i.exports=function(e,i){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];i=i||{};var r=1,d=1;function f(e){var i=e.match(n);i&&(r+=i.length);var s=e.lastIndexOf("\n");d=~s?e.length-s:d+e.length}function p(){var e={line:r,column:d};return function(i){return i.position=new m(e),g(o),i}}function m(e){this.start=e,this.end={line:r,column:d},this.source=i.source}function _(s){var n=Error(i.source+":"+r+":"+d+": "+s);if(n.reason=s,n.filename=i.source,n.line=r,n.column=d,n.source=e,i.silent);else throw n}function g(i){var r=i.exec(e);if(r){var s=r[0];return f(s),e=e.slice(s.length),r}}function v(e){var i;for(e=e||[];i=x();)!1!==i&&e.push(i);return e}function x(){var i=p();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return _("End of comment missing");var s=e.slice(2,r-2);return d+=2,f(s),e=e.slice(r),d+=2,i({type:"comment",comment:s})}}m.prototype.content=e,g(o);var b,y=[];for(v(y);b=function(){var e=p(),i=g(a);if(i){if(x(),!g(l))return _("property missing ':'");var r=g(h),n=e({type:"declaration",property:u(i[0].replace(s,"")),value:r?u(r[0].replace(s,"")):""});return g(c),n}}();)!1!==b&&(y.push(b),v(y));return y}},70454,(e,i,r)=>{"use strict";var s=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,i){let r=null;if(!e||"string"!=typeof e)return r;let s=(0,n.default)(e),o="function"==typeof i;return s.forEach(e=>{if("declaration"!==e.type)return;let{property:s,value:n}=e;o?i(s,n,e):n&&((r=r||{})[s]=n)}),r};let n=s(e.r(26568))},65185,(e,i,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.camelCase=void 0;var s=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,o=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,h=function(e,i){return i.toUpperCase()},c=function(e,i){return"".concat(i,"-")};r.camelCase=function(e,i){var r;return(void 0===i&&(i={}),!(r=e)||o.test(r)||s.test(r))?e:(e=e.toLowerCase(),(e=i.reactCompat?e.replace(l,c):e.replace(a,c)).replace(n,h))}},15511,(e,i,r)=>{"use strict";var s=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(70454)),n=e.r(65185);function o(e,i){var r={};return e&&"string"==typeof e&&(0,s.default)(e,function(e,s){e&&s&&(r[(0,n.camelCase)(e,i)]=s)}),r}o.default=o,i.exports=o},4100,(e,i,r)=>{"use strict";var s=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},h=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var i,r=s.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&s.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!o)return!1;for(i in e);return void 0===i||s.call(e,i)},c=function(e,i){o&&"__proto__"===i.name?o(e,i.name,{enumerable:!0,configurable:!0,value:i.newValue,writable:!0}):e[i.name]=i.newValue},d=function(e,i){if("__proto__"===i){if(!s.call(e,i))return;else if(a)return a(e,i).value}return e[i]};i.exports=function e(){var i,r,s,n,o,a,u=arguments[0],f=1,p=arguments.length,m=!1;for("boolean"==typeof u&&(m=u,u=arguments[1]||{},f=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});f<p;++f)if(i=arguments[f],null!=i)for(r in i)s=d(u,r),u!==(n=d(i,r))&&(m&&n&&(h(n)||(o=l(n)))?(o?(o=!1,a=s&&l(s)?s:[]):a=s&&h(s)?s:{},c(u,{name:r,newValue:e(m,a,n)})):void 0!==n&&c(u,{name:r,newValue:n}));return u}},55601,e=>{"use strict";let i,r,s,n,o,a,l,h,c,d,u,f;var p=e.i(43476),m=e.i(71645);function _({label:e,status:i,projectId:r,agentId:s,onStatusChange:n,tooltip:o,children:a}){let l="running"===i?"bg-accent":"error"===i?"bg-error":"bg-text-muted",h=e=>{r&&s&&fetch(`/api/agents?project=${encodeURIComponent(r)}&agent=${encodeURIComponent(s)}&action=${e}`,{method:"POST"}).then(e=>e.json()).then(e=>{n&&e.state&&n(e.state)}).catch(()=>{})};return(0,p.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 h-7 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[i&&(0,p.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${l}`}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:e}),o]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[a,r&&s&&(0,p.jsxs)(p.Fragment,{children:["running"!==i&&(0,p.jsx)("button",{onClick:()=>h("start"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Start",children:"▶"}),"running"===i&&(0,p.jsx)("button",{onClick:()=>h("stop"),className:"text-[10px] text-text-muted hover:text-error transition-colors px-1",title:"Stop",children:"■"}),(0,p.jsx)("button",{onClick:()=>h("restart"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Restart",children:"↻"})]})]})]})}function g({children:e,position:i="below"}){let[r,s]=(0,m.useState)(!1),n=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(!r)return;let e=e=>{n.current&&!n.current.contains(e.target)&&s(!1)},i=e=>{"Escape"===e.key&&s(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",i)}},[r]),(0,p.jsxs)("div",{ref:n,className:"relative inline-flex items-center",children:[(0,p.jsx)("button",{type:"button",onClick:()=>s(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),r&&(0,p.jsx)("div",{className:`absolute left-0 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg ${"above"===i?"bottom-5":"top-5"}`,children:e})]})}var v=e.i(78759),x=e.i(52368);let b={en:{ready:"Ready when you are",tell:"Tell your team what to build. Try something like:",howToWork:"How to Work",examples:["@head start a new feature: <describe>","@head review the latest PR","@head what's our current sprint?"]},ko:{ready:"언제든지 시작하세요",tell:"팀에게 무엇을 만들지 말해보세요. 예를 들어:",howToWork:"사용 방법",examples:["@head 새로운 기능 시작: <설명>","@head 최신 PR 리뷰해줘","@head 현재 스프린트 상황이 어때?"]}};function y({onInsert:e}){let{locale:i}=(0,x.useLocale)(),r=b[i],[s,n]=(0,m.useState)(!1);return(0,p.jsxs)("div",{className:"flex flex-col items-center justify-center text-center px-6 py-10 gap-3",children:[(0,p.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none","aria-hidden":!0,className:"text-accent",children:[(0,p.jsx)("path",{d:"M6 8h28a2 2 0 0 1 2 2v17a2 2 0 0 1-2 2H16l-7 6v-6h-3a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2Z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),(0,p.jsx)("circle",{cx:"14",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"20",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"26",cy:"18",r:"1.4",fill:"currentColor"})]}),(0,p.jsx)("div",{className:"text-[13px] font-semibold text-text",children:r.ready}),(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:r.tell}),(0,p.jsx)("div",{className:"flex flex-col gap-1.5 mt-1 w-full max-w-sm",children:r.examples.map(i=>(0,p.jsx)("button",{type:"button",onClick:()=>e(i),className:"text-left px-2 py-1 text-[11px] font-mono text-text-muted border border-border hover:text-accent hover:border-accent transition-colors truncate",children:i},i))}),(0,p.jsx)("button",{type:"button",onClick:()=>n(!0),className:"mt-2 text-[11px] text-text-muted underline underline-offset-2 hover:text-text",children:r.howToWork}),(0,p.jsx)(v.default,{open:s,onClose:()=>n(!1)})]})}let S="qw-chat-presets",w=[{id:"default-1",title:"Queue Check — Trigger",message:`@head @dev @re1 @re2 – Queue check.
2
+ @head: Merge any PR with both approvals, assign next from ~/.quadwork/{{project}}/OVERNIGHT-QUEUE.md.
3
+ @dev: Work on assigned ticket or address review feedback.
4
+ @re1 & @re2: Review open PRs. If @dev pushed fixes, re-review. Post verdict on PR AND notify @dev here.
5
+ ALL: Communicate via this chat by tagging agents. Your terminal is NOT visible.`},{id:"default-2",title:"Suffix Reminder",message:"All agents: ignore numeric suffixes in your identity. dev, dev-1, dev-2 are the same Dev agent. re1, re1-2 are the same RE1. re2, re2-2 are the same RE2. head, head-2 are the same Head. When tagging others, use the base name (@dev, @re1, @re2, @head). When checking for mentions to you, match your base role name regardless of suffix."},{id:"default-3",title:"Check Queue Format",message:"@head Check your OVERNIGHT-QUEUE.md formatting. Each Active Batch item must start with `- #<number>` (dash, space, hash, issue number). Do NOT use `- Issue #598` format — only `- #598 description`. The Current Batch panel won't recognize items in any other format. Fix if needed and confirm."},{id:"default-4",title:"Agent Online Check",message:"@head Are you online? If so, ping @dev, @re1, and @re2 to confirm whether they are online and available."}];function C({projectId:e,onSend:i}){let[r,s]=(0,m.useState)(!1),[n,o]=(0,m.useState)([]),[a,l]=(0,m.useState)(null),[h,c]=(0,m.useState)(""),[d,u]=(0,m.useState)("");(0,m.useEffect)(()=>{o(function(){try{let e=localStorage.getItem(S);if(!e)return localStorage.setItem(S,JSON.stringify(w)),w;return JSON.parse(e)}catch{return w}}())},[]);let f=(0,m.useCallback)(e=>{o(e),localStorage.setItem(S,JSON.stringify(e))},[]);return r?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("button",{type:"button",onClick:()=>s(!1),className:"shrink-0 px-1.5 py-2 text-[10px] text-accent transition-colors",title:"Close presets",children:"Preset"}),(0,p.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>{s(!1),l(null)}}),(0,p.jsxs)("div",{className:"absolute bottom-full left-0 right-0 mb-1 z-50 border border-border bg-bg-surface max-h-[60vh] overflow-y-auto",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/50",children:[(0,p.jsx)("span",{className:"text-[11px] text-text font-semibold",children:"Message Presets"}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[(0,p.jsx)("button",{type:"button",onClick:()=>{l({id:"",title:"",message:""}),c(""),u("")},className:"text-[10px] text-accent hover:underline",children:"+ New"}),(0,p.jsx)("button",{type:"button",onClick:()=>{s(!1),l(null)},className:"text-[11px] text-text-muted hover:text-text",children:"✕"})]})]}),a?(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("input",{type:"text",value:h,onChange:e=>c(e.target.value),placeholder:"Preset title",className:"w-full bg-transparent border border-border px-2 py-1 text-[11px] text-text outline-none focus:border-accent"}),(0,p.jsx)("textarea",{value:d,onChange:e=>u(e.target.value),placeholder:"Message body",rows:5,className:"w-full bg-transparent border border-border px-2 py-1 text-[11px] text-text outline-none focus:border-accent resize-y font-mono"}),(0,p.jsxs)("div",{className:"flex gap-2",children:[(0,p.jsx)("button",{type:"button",onClick:()=>{h.trim()&&d.trim()&&(a&&a.id?f(n.map(e=>e.id===a.id?{...e,title:h,message:d}:e)):f([...n,{id:`preset-${Date.now()}`,title:h,message:d}]),l(null))},disabled:!h.trim()||!d.trim(),className:"px-2 py-0.5 text-[10px] text-accent border border-accent/40 hover:bg-accent/10 transition-colors disabled:opacity-30",children:"Save"}),(0,p.jsx)("button",{type:"button",onClick:()=>l(null),className:"px-2 py-0.5 text-[10px] text-text-muted border border-border hover:text-text transition-colors",children:"Cancel"})]})]}):(0,p.jsxs)("div",{className:"divide-y divide-border/30",children:[0===n.length&&(0,p.jsx)("div",{className:"px-3 py-4 text-[11px] text-text-muted text-center",children:'No presets. Click "+ New" to create one.'}),n.map(r=>(0,p.jsx)("div",{className:"px-3 py-2 hover:bg-accent/5 group",children:(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsxs)("button",{type:"button",onClick:()=>{i(r.message.replace(/\{\{project\}\}/g,e)),s(!1)},className:"text-left flex-1 min-w-0",children:[(0,p.jsx)("div",{className:"text-[11px] text-text font-medium truncate",children:r.title}),(0,p.jsxs)("div",{className:"text-[10px] text-text-muted truncate mt-0.5",children:[r.message.slice(0,80),r.message.length>80?"…":""]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2 shrink-0",children:[(0,p.jsx)("button",{type:"button",onClick:()=>{l(r),c(r.title),u(r.message)},className:"text-[10px] text-text-muted hover:text-accent",title:"Edit",children:"✎"}),(0,p.jsx)("button",{type:"button",onClick:()=>{var e;return e=r.id,void f(n.filter(i=>i.id!==e))},className:"text-[10px] text-text-muted hover:text-error",title:"Delete",children:"✕"})]})]})},r.id))]})]})]}):(0,p.jsx)("button",{type:"button",onClick:()=>s(!0),className:"shrink-0 px-1.5 py-2 text-[10px] text-text-muted hover:text-accent transition-colors",title:"Message presets",children:"Preset"})}let k={head:"#00ff88",re1:"#4488ff",re2:"#cc44ff",dev:"#ffcc00",user:"#e0e0e0",system:"#737373"},E=["head","re1","re2","dev","user"],N=[/^.+ is online$/,/disconnected \(timeout\)/,/^.+ disconnected$/,/auto-recovered/,/Resuming agent conversation/,/Loop guard:/],R=[{command:"/artchallenge",description:"SVG art challenge — all agents create artwork (optional theme)"},{command:"/hatmaking",description:"All agents design a hat to wear on their avatar"},{command:"/roastreview",description:"Get all agents to review and roast each other's work"},{command:"/poetry haiku",description:"Agents write a haiku about the codebase"},{command:"/poetry limerick",description:"Agents write a limerick about the codebase"},{command:"/poetry sonnet",description:"Agents write a sonnet about the codebase"},{command:"/summary",description:"Summarize recent messages — tag an agent (e.g. /summary @head)"},{command:"/continue",description:"Resume after loop guard pauses"},{command:"/clear",description:"Clear messages in current channel"}];function j(e){return k[e.toLowerCase()]||"#e0e0e0"}let T=/(^|\s)(@(?:head|dev|re1|re2|user))(?![\w-])/gi;function D({projectId:e,filterSystem:i}){return(0,p.jsx)(M,{projectId:e,filterSystem:i})}function M({projectId:e,filterSystem:i=!1}){let r="general",[s,n]=(0,m.useState)([]),[o,a]=(0,m.useState)(!1),[l,h]=(0,m.useState)(""),c=(0,m.useRef)(0),d=(0,m.useRef)(null),[u,f]=(0,m.useState)(!1),[_,g]=(0,m.useState)(""),[v,x]=(0,m.useState)(!1),[b,S]=(0,m.useState)(0),[w,k]=(0,m.useState)(null),[D,P]=(0,m.useState)(null),L=(0,m.useRef)(0),A=(0,m.useRef)(null),B=(0,m.useRef)(null),I=(0,m.useRef)(!1),O=(0,m.useRef)(!0),F=(0,m.useRef)(0);(0,m.useEffect)(()=>{L.current=0,n([]),a(!1),c.current=0,d.current&&(clearTimeout(d.current),d.current=null)},[e]);let z=(0,m.useCallback)(()=>{fetch(`/api/chat?path=/api/messages&channel=${encodeURIComponent(r)}&cursor=${L.current}${e?`&project=${encodeURIComponent(e)}`:""}`).then(e=>{if(403===e.status)throw F.current<3?k(null):k("Chat authentication failed (403). Set agentchattr_token in Settings or ~/.quadwork/config.json."),Error("auth failed");if(!e.ok)throw Error(`Poll failed: ${e.status}`);return e.json()}).then(e=>{k(null);let i=Array.isArray(e)?e:e.messages||[];if(i.length>0){n(e=>{let r=new Set(e.map(e=>e.id)),s=i.filter(e=>!r.has(e.id));return s.length>0?[...e,...s]:e});let e=Math.max(...i.map(e=>e.id));e>L.current&&(L.current=e)}a(!0)}).catch(()=>{!o&&c.current<3&&(c.current+=1,d.current=setTimeout(z,2e3))})},[r,e,o]);(0,m.useEffect)(()=>{z();let e=setInterval(z,3e3);return()=>{clearInterval(e),d.current&&(clearTimeout(d.current),d.current=null)}},[z]),(0,m.useEffect)(()=>{O.current&&A.current&&(A.current.scrollTop=A.current.scrollHeight)},[s]);let[H,$]=(0,m.useState)(!1),[W,U]=(0,m.useState)(null),[K,q]=(0,m.useState)([]),[V,Y]=(0,m.useState)(!1),G=(0,m.useRef)(null),X=async i=>{if(e){Y(!0);try{let r=new FormData;r.append("file",i);let s=await fetch(`/api/upload?project=${encodeURIComponent(e)}`,{method:"POST",body:r});if(!s.ok){let e=await s.json().catch(()=>({error:`${s.status}`}));U(e.error||`Upload failed: ${s.status}`);return}let n=await s.json();q(e=>[...e,{path:n.path,name:n.name}])}catch(e){U(e.message)}finally{Y(!1)}}},J=e=>{for(let i of e)i.type.startsWith("image/")&&X(i)};(0,m.useEffect)(()=>{let e=B.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,120)+"px")},[l]);let Q=()=>{let i=l.trim();if(!i&&0===K.length||H)return;let s=i.startsWith("/")||/^@(head|dev|re1|re2)\b/i.test(i)?i:`@head ${i}`;$(!0),U(null),fetch(`/api/chat${e?`?project=${encodeURIComponent(e)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s,channel:r,sender:"user",...K.length>0?{attachments:K}:{},...D?{reply_to:D.id}:{}})}).then(e=>{if(!e.ok)throw Error(`Send failed: ${e.status}`);h(""),q([]),P(null),setTimeout(z,300)}).catch(e=>{U(e.message),console.error(e.message)}).finally(()=>$(!1))},Z=(0,m.useCallback)(i=>{if(H)return;let s=i.startsWith("/")||/^@(head|dev|re1|re2)\b/i.test(i)?i:`@head ${i}`;$(!0),U(null),fetch(`/api/chat${e?`?project=${encodeURIComponent(e)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s,channel:r,sender:"user"})}).then(e=>{if(!e.ok)throw Error(`Send failed: ${e.status}`);setTimeout(z,300)}).catch(e=>{U(e.message),console.error(e.message)}).finally(()=>$(!1))},[H,e,r,z]),ee=e=>{h(l.replace(/@\w*$/,`@${e} `)),f(!1),B.current?.focus()},et=e=>{h(e.includes(" ")?e:`${e} `),x(!1),B.current?.focus()},ei=E.filter(e=>e.toLowerCase().startsWith(_)),er=R.filter(e=>e.command.toLowerCase().startsWith(l.toLowerCase())),es=i?s.filter(e=>!function(e){if("system"===e.sender||"join"===e.type||"leave"===e.type)return!0;for(let i of N)if(i.test(e.text))return!0;return!1}(e)):s;return(0,p.jsxs)("div",{className:"flex flex-col h-full bg-bg",children:[w&&(0,p.jsx)("div",{className:"px-3 py-2 bg-red-900/30 border-b border-red-700/50 text-[11px] text-red-400",children:w}),(0,p.jsxs)("div",{ref:A,onScroll:()=>{if(!A.current)return;let{scrollTop:e,scrollHeight:i,clientHeight:r}=A.current;O.current=i-e-r<40},className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-0.5",children:[!o&&0===s.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)("span",{className:"text-xs text-text-muted",children:"Loading messages..."})}),o&&0===es.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)(y,{onInsert:e=>{h(e),B.current?.focus()}})}),es.map(i=>{var r;let s;return(0,p.jsxs)("div",{className:"group flex gap-2 text-[12px] leading-5",children:[(0,p.jsx)("span",{className:"text-text-muted shrink-0 w-12 text-right tabular-nums",children:i.time?.slice(0,5)||""}),(0,p.jsx)("span",{className:"shrink-0 font-semibold w-10 text-right",style:{color:j(i.sender)},children:"re1"===(s=(r=i.sender).toLowerCase())?"RE1":"re2"===s?"RE2":r}),(0,p.jsxs)("span",{className:"text-text break-words min-w-0 whitespace-pre-wrap flex-1",children:[function(e){let i=[],r=0,s=0;for(let n of e.matchAll(T)){let o=n.index??0,a=n[1],l=n[2],h=o+a.length;h>r&&i.push(e.slice(r,h));let c=j(l.slice(1).toLowerCase());i.push((0,p.jsx)("span",{className:"inline-block px-1 py-0 rounded font-mono",style:{backgroundColor:`${c}22`,color:c},children:l},`m${s++}`)),r=h+l.length}return r<e.length&&i.push(e.slice(r)),i.length>0?i:[e]}(i.text),i.attachments&&i.attachments.length>0&&(0,p.jsx)("span",{className:"flex gap-2 mt-1",children:i.attachments.map(i=>(0,p.jsx)("a",{href:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(i.name)}`,target:"_blank",rel:"noopener noreferrer",children:(0,p.jsx)("img",{src:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(i.name)}`,alt:i.name,className:"max-w-[200px] max-h-[150px] object-cover border border-border rounded hover:border-accent transition-colors"})},i.name))})]}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(P({id:i.id,sender:i.sender}),new Set(["head","dev","re1","re2"]).has(i.sender.toLowerCase())){let e=`@${i.sender} `;h(i=>i.startsWith(e)?i:e)}B.current?.focus()},className:"shrink-0 self-start opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-[10px] text-text-muted hover:text-text px-1 py-0.5 border border-border/50 rounded",title:`Reply to message #${i.id}`,children:"reply"})]},i.id)})]}),(0,p.jsxs)("div",{className:"relative shrink-0 border-t border-border",children:[u&&ei.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 border border-border bg-bg-surface",children:ei.map(e=>(0,p.jsxs)("button",{onClick:()=>ee(e),className:"w-full text-left px-3 py-1 text-[12px] hover:bg-[#1a1a1a] transition-colors",style:{color:j(e)},children:["@",e]},e))}),v&&er.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-60 overflow-y-auto border border-border bg-bg-surface z-10",children:er.map((e,i)=>{let r=i===Math.min(b,er.length-1);return(0,p.jsxs)("button",{onClick:()=>et(e.command),onMouseEnter:()=>S(i),className:`w-full text-left px-3 py-1 transition-colors flex items-baseline gap-2 ${r?"bg-[#1a1a1a]":"hover:bg-[#1a1a1a]"}`,children:[(0,p.jsx)("span",{className:"text-[12px] text-accent font-mono",children:e.command}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:e.description})]},e.command)})}),W&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-red-400 bg-red-900/20 border-b border-red-700/40",children:W}),D&&(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 text-[11px] text-text-muted bg-bg-surface border-b border-border/50",children:[(0,p.jsxs)("span",{children:["Replying to ",(0,p.jsxs)("span",{style:{color:j(D.sender)},children:["@",D.sender]})," #",D.id]}),(0,p.jsx)("button",{type:"button",onClick:()=>P(null),className:"ml-auto hover:text-text",title:"Cancel reply (Esc)",children:"✕"})]}),(0,p.jsxs)("div",{className:"flex items-end gap-1 px-1 relative",children:[(0,p.jsx)("textarea",{ref:B,rows:1,value:l,onChange:e=>(e=>{h(e);let i=e.match(/@(\w*)$/);if(i){f(!0),g(i[1].toLowerCase()),x(!1);return}if(f(!1),e.startsWith("/")){let i=e.slice(1).includes(" "),r=e.startsWith("/poetry");x(!i||r),S(0)}else x(!1)})(e.target.value),onCompositionStart:()=>{I.current=!0},onCompositionEnd:()=>{I.current=!1},onKeyDown:e=>{if("Tab"===e.key&&u&&ei.length>0){e.preventDefault(),ee(ei[0]);return}if(v&&er.length>0){if("ArrowDown"===e.key){e.preventDefault(),S(e=>(e+1)%er.length);return}if("ArrowUp"===e.key){e.preventDefault(),S(e=>(e-1+er.length)%er.length);return}if("Tab"===e.key||"Enter"===e.key&&!e.shiftKey){e.preventDefault();let i=Math.min(b,er.length-1);et(er[i].command);return}}"Enter"!==e.key||e.shiftKey||I.current||e.nativeEvent.isComposing||(e.preventDefault(),Q()),"Escape"===e.key&&(f(!1),x(!1),D&&P(null))},onPaste:e=>{let i=e.clipboardData?.items;if(!i)return;let r=[];for(let e of Array.from(i))if(e.type.startsWith("image/")){let i=e.getAsFile();i&&r.push(i)}r.length>0&&(e.preventDefault(),J(r))},onDrop:e=>{let i=e.dataTransfer?.files;if(!i)return;let r=Array.from(i).filter(e=>e.type.startsWith("image/"));r.length>0&&(e.preventDefault(),J(r))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},placeholder:`Message #${r}...`,disabled:H,className:"flex-1 bg-transparent px-2 py-2 text-[12px] font-mono text-text placeholder:text-text-muted outline-none focus:ring-1 focus:ring-accent disabled:opacity-50 resize-none overflow-y-auto leading-snug",style:{maxHeight:120}}),(0,p.jsx)("input",{ref:G,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:e=>{let i=e.target.files;i&&i.length>0&&J(Array.from(i)),e.target.value=""}}),(0,p.jsx)(C,{projectId:e||"",onSend:Z}),(0,p.jsx)("button",{type:"button",onClick:()=>G.current?.click(),disabled:V,className:"shrink-0 px-1.5 py-2 text-[13px] text-text-muted hover:text-accent transition-colors disabled:opacity-30",title:"Attach image",children:"📎"}),(0,p.jsx)("button",{onClick:Q,disabled:H||!l.trim()&&0===K.length,className:"shrink-0 px-2 py-2 text-[11px] font-mono text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Send (Enter)",children:H?"…":"Send"})]}),(K.length>0||V)&&(0,p.jsxs)("div",{className:"flex gap-2 px-2 py-1 flex-wrap",children:[K.map((i,r)=>(0,p.jsxs)("div",{className:"relative group",children:[(0,p.jsx)("img",{src:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(i.name)}`,alt:i.name,className:"h-16 max-w-[200px] object-cover border border-border rounded"}),(0,p.jsx)("button",{type:"button",onClick:()=>q(e=>e.filter((e,i)=>i!==r)),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-bg border border-border rounded-full text-[10px] text-text-muted hover:text-error opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",title:"Remove",children:"×"})]},i.name)),V&&(0,p.jsx)("div",{className:"h-16 w-16 border border-border rounded flex items-center justify-center",children:(0,p.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"..."})})]})]})]})}function P(){}function L(){}let A=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,B=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,I={};function O(e,i){return((i||I).jsx?B:A).test(e)}let F=/[ \t\n\f\r]/g;function z(e){return""===e.replace(F,"")}class H{constructor(e,i){this.attribute=i,this.property=e}}H.prototype.attribute="",H.prototype.booleanish=!1,H.prototype.boolean=!1,H.prototype.commaOrSpaceSeparated=!1,H.prototype.commaSeparated=!1,H.prototype.defined=!1,H.prototype.mustUseProperty=!1,H.prototype.number=!1,H.prototype.overloadedBoolean=!1,H.prototype.property="",H.prototype.spaceSeparated=!1,H.prototype.space=void 0;let $=0,W=X(),U=X(),K=X(),q=X(),V=X(),Y=X(),G=X();function X(){return 2**++$}e.s(["boolean",0,W,"booleanish",0,U,"commaOrSpaceSeparated",0,G,"commaSeparated",0,Y,"number",0,q,"overloadedBoolean",0,K,"spaceSeparated",0,V],744);var J=e.i(744);let Q=Object.keys(J);class Z extends H{constructor(e,i,r,s){let n=-1;if(super(e,i),function(e,i,r){r&&(e[i]=r)}(this,"space",s),"number"==typeof r)for(;++n<Q.length;){const e=Q[n];!function(e,i,r){r&&(e[i]=r)}(this,Q[n],(r&J[e])===J[e])}}}function ee(e){return e.toLowerCase()}Z.prototype.defined=!0;let et=/[A-Z]/g,ei=/-[a-z]/g,er=/^data[-\w.:]+$/i;function es(e){return"-"+e.toLowerCase()}function en(e){return e.charAt(1).toUpperCase()}let eo={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class ea{constructor(e,i,r){this.normal=i,this.property=e,r&&(this.space=r)}}function el(e,i){let r={},s={};for(let i of e)Object.assign(r,i.property),Object.assign(s,i.normal);return new ea(r,s,i)}function eh(e){let i={},r={};for(let[s,n]of Object.entries(e.properties)){let o=new Z(s,e.transform(e.attributes||{},s),n,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),i[s]=o,r[ee(s)]=s,r[ee(o.attribute)]=s}return new ea(i,r,e.space)}ea.prototype.normal={},ea.prototype.property={},ea.prototype.space=void 0;let ec=eh({properties:{ariaActiveDescendant:null,ariaAtomic:U,ariaAutoComplete:null,ariaBusy:U,ariaChecked:U,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:V,ariaCurrent:null,ariaDescribedBy:V,ariaDetails:null,ariaDisabled:U,ariaDropEffect:V,ariaErrorMessage:null,ariaExpanded:U,ariaFlowTo:V,ariaGrabbed:U,ariaHasPopup:null,ariaHidden:U,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:V,ariaLevel:q,ariaLive:null,ariaModal:U,ariaMultiLine:U,ariaMultiSelectable:U,ariaOrientation:null,ariaOwns:V,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:U,ariaReadOnly:U,ariaRelevant:null,ariaRequired:U,ariaRoleDescription:V,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:U,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform:(e,i)=>"role"===i?i:"aria-"+i.slice(4).toLowerCase()});function ed(e,i){return i in e?e[i]:i}function eu(e,i){return ed(e,i.toLowerCase())}let ef=eh({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Y,acceptCharset:V,accessKey:V,action:null,allow:null,allowFullScreen:W,allowPaymentRequest:W,allowUserMedia:W,alt:null,as:null,async:W,autoCapitalize:null,autoComplete:V,autoFocus:W,autoPlay:W,blocking:V,capture:null,charSet:null,checked:W,cite:null,className:V,cols:q,colSpan:null,content:null,contentEditable:U,controls:W,controlsList:V,coords:q|Y,crossOrigin:null,data:null,dateTime:null,decoding:null,default:W,defer:W,dir:null,dirName:null,disabled:W,download:K,draggable:U,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:W,formTarget:null,headers:V,height:q,hidden:K,high:q,href:null,hrefLang:null,htmlFor:V,httpEquiv:V,id:null,imageSizes:null,imageSrcSet:null,inert:W,inputMode:null,integrity:null,is:null,isMap:W,itemId:null,itemProp:V,itemRef:V,itemScope:W,itemType:V,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:W,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:W,muted:W,name:null,nonce:null,noModule:W,noValidate:W,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:W,optimum:q,pattern:null,ping:V,placeholder:null,playsInline:W,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:W,referrerPolicy:null,rel:V,required:W,reversed:W,rows:q,rowSpan:q,sandbox:V,scope:null,scoped:W,seamless:W,selected:W,shadowRootClonable:W,shadowRootDelegatesFocus:W,shadowRootMode:null,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:U,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:W,useMap:null,value:U,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:V,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:W,declare:W,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:W,noHref:W,noShade:W,noWrap:W,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:U,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:W,disableRemotePlayback:W,prefix:null,property:null,results:q,security:null,unselectable:null},space:"html",transform:eu}),ep=eh({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:G,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:V,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:W,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Y,g2:Y,glyphName:Y,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:G,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:V,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:G,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:G,rev:G,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:G,requiredFeatures:G,requiredFonts:G,requiredFormats:G,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:G,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:G,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:G,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ed}),em=eh({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,i)=>"xlink:"+i.slice(5).toLowerCase()}),e_=eh({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:eu}),eg=eh({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,i)=>"xml:"+i.slice(3).toLowerCase()}),ev=el([ec,ef,em,e_,eg],"html"),ex=el([ec,ep,em,e_,eg],"svg");var eb=e.i(15511);let ey=ew("end"),eS=ew("start");function ew(e){return function(i){let r=i&&i.position&&i.position[e]||{};if("number"==typeof r.line&&r.line>0&&"number"==typeof r.column&&r.column>0)return{line:r.line,column:r.column,offset:"number"==typeof r.offset&&r.offset>-1?r.offset:void 0}}}function eC(e){return e&&"object"==typeof e?"position"in e||"type"in e?eE(e.position):"start"in e||"end"in e?eE(e):"line"in e||"column"in e?ek(e):"":""}function ek(e){return eN(e&&e.line)+":"+eN(e&&e.column)}function eE(e){return ek(e&&e.start)+"-"+ek(e&&e.end)}function eN(e){return e&&"number"==typeof e?e:1}class eR extends Error{constructor(e,i,r){super(),"string"==typeof i&&(r=i,i=void 0);let s="",n={},o=!1;if(i&&(n="line"in i&&"column"in i||"start"in i&&"end"in i?{place:i}:"type"in i?{ancestors:[i],place:i.position}:{...i}),"string"==typeof e?s=e:!n.cause&&e&&(o=!0,s=e.message,n.cause=e),!n.ruleId&&!n.source&&"string"==typeof r){const e=r.indexOf(":");-1===e?n.ruleId=r:(n.source=r.slice(0,e),n.ruleId=r.slice(e+1))}if(!n.place&&n.ancestors&&n.ancestors){const e=n.ancestors[n.ancestors.length-1];e&&(n.place=e.position)}const a=n.place&&"start"in n.place?n.place.start:n.place;this.ancestors=n.ancestors||void 0,this.cause=n.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=eC(n.place)||"1:1",this.place=n.place||void 0,this.reason=this.message,this.ruleId=n.ruleId||void 0,this.source=n.source||void 0,this.stack=o&&n.cause&&"string"==typeof n.cause.stack?n.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}eR.prototype.file="",eR.prototype.name="",eR.prototype.reason="",eR.prototype.message="",eR.prototype.stack="",eR.prototype.column=void 0,eR.prototype.line=void 0,eR.prototype.ancestors=void 0,eR.prototype.cause=void 0,eR.prototype.fatal=void 0,eR.prototype.place=void 0,eR.prototype.ruleId=void 0,eR.prototype.source=void 0;let ej={}.hasOwnProperty,eT=new Map,eD=/[A-Z]/g,eM=new Set(["table","tbody","thead","tfoot","tr"]),eP=new Set(["td","th"]),eL="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function eA(e,i,r){var s,n,o,a,l,h,c,d,u;let f,p,m,_,g,v,x,b,y,S,w;return"element"===i.type?(s=e,n=i,o=r,p=f=s.schema,"svg"===n.tagName.toLowerCase()&&"html"===f.space&&(s.schema=ex),s.ancestors.push(n),m=eF(s,n.tagName,!1),_=function(e,i){let r,s,n={};for(s in i.properties)if("children"!==s&&ej.call(i.properties,s)){let o=function(e,i,r){let s=function(e,i){let r=ee(i),s=i,n=H;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&"data"===r.slice(0,4)&&er.test(i)){if("-"===i.charAt(4)){let e=i.slice(5).replace(ei,en);s="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=i.slice(4);if(!ei.test(e)){let r=e.replace(et,es);"-"!==r.charAt(0)&&(r="-"+r),i="data"+r}}n=Z}return new n(s,i)}(e.schema,i);if(!(null==r||"number"==typeof r&&Number.isNaN(r))){var n;let i;if(Array.isArray(r)&&(r=s.commaSeparated?(i={},(""===(n=r)[n.length-1]?[...n,""]:n).join((i.padRight?" ":"")+","+(!1===i.padLeft?"":" ")).trim()):r.join(" ").trim()),"style"===s.property){let i="object"==typeof r?r:function(e,i){try{return(0,eb.default)(i,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};let i=new eR("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=eL+"#cannot-parse-style-attribute",i}}(e,String(r));return"css"===e.stylePropertyNameCase&&(i=function(e){let i,r={};for(i in e)ej.call(e,i)&&(r[function(e){let i=e.replace(eD,eH);return"ms-"===i.slice(0,3)&&(i="-"+i),i}(i)]=e[i]);return r}(i)),["style",i]}return["react"===e.elementAttributeNameCase&&s.space?eo[s.property]||s.property:s.attribute,r]}}(e,s,i.properties[s]);if(o){let[s,a]=o;e.tableCellAlignToStyle&&"align"===s&&"string"==typeof a&&eP.has(i.tagName)?r=a:n[s]=a}}return r&&((n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r),n}(s,n),g=eO(s,n),eM.has(n.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&z(e.value):z(e))})),eB(s,_,m,n),eI(_,g),s.ancestors.pop(),s.schema=f,s.create(n,m,_,o)):"mdxFlowExpression"===i.type||"mdxTextExpression"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater){let r=i.data.estree.body[0];return P("ExpressionStatement"===r.type),e.evaluater.evaluateExpression(r.expression)}ez(e,i.position)}(e,i):"mdxJsxFlowElement"===i.type||"mdxJsxTextElement"===i.type?(a=e,l=i,h=r,x=v=a.schema,"svg"===l.name&&"html"===v.space&&(a.schema=ex),a.ancestors.push(l),b=null===l.name?a.Fragment:eF(a,l.name,!0),y=function(e,i){let r={};for(let s of i.attributes)if("mdxJsxExpressionAttribute"===s.type)if(s.data&&s.data.estree&&e.evaluater){let i=s.data.estree.body[0];P("ExpressionStatement"===i.type);let n=i.expression;P("ObjectExpression"===n.type);let o=n.properties[0];P("SpreadElement"===o.type),Object.assign(r,e.evaluater.evaluateExpression(o.argument))}else ez(e,i.position);else{let n,o=s.name;if(s.value&&"object"==typeof s.value)if(s.value.data&&s.value.data.estree&&e.evaluater){let i=s.value.data.estree.body[0];P("ExpressionStatement"===i.type),n=e.evaluater.evaluateExpression(i.expression)}else ez(e,i.position);else n=null===s.value||s.value;r[o]=n}return r}(a,l),S=eO(a,l),eB(a,y,b,l),eI(y,S),a.ancestors.pop(),a.schema=v,a.create(l,b,y,h)):"mdxjsEsm"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(i.data.estree);ez(e,i.position)}(e,i):"root"===i.type?(c=e,d=i,u=r,eI(w={},eO(c,d)),c.create(d,c.Fragment,w,u)):"text"===i.type?i.value:void 0}function eB(e,i,r,s){"string"!=typeof r&&r!==e.Fragment&&e.passNode&&(i.node=s)}function eI(e,i){if(i.length>0){let r=i.length>1?i:i[0];r&&(e.children=r)}}function eO(e,i){let r=[],s=-1,n=e.passKeys?new Map:eT;for(;++s<i.children.length;){let o,a=i.children[s];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let i=n.get(e)||0;o=e+"-"+i,n.set(e,i+1)}}let l=eA(e,a,o);void 0!==l&&r.push(l)}return r}function eF(e,i,r){let s;if(r)if(i.includes(".")){let e,r=i.split("."),n=-1;for(;++n<r.length;){let i=O(r[n])?{type:"Identifier",name:r[n]}:{type:"Literal",value:r[n]};e=e?{type:"MemberExpression",object:e,property:i,computed:!!(n&&"Literal"===i.type),optional:!1}:i}P(e,"always a result"),s=e}else s=O(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};else s={type:"Literal",value:i};if("Literal"===s.type){let i=s.value;return ej.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(s);ez(e)}function ez(e,i){let r=new eR("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=eL+"#cannot-handle-mdx-estrees-without-createevaluater",r}function eH(e){return"-"+e.toLowerCase()}let e$={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},eW={};function eU(e,i,r){var s;if((s=e)&&"object"==typeof s){if("value"in e)return"html"!==e.type||r?e.value:"";if(i&&"alt"in e&&e.alt)return e.alt;if("children"in e)return eK(e.children,i,r)}return Array.isArray(e)?eK(e,i,r):""}function eK(e,i,r){let s=[],n=-1;for(;++n<e.length;)s[n]=eU(e[n],i,r);return s.join("")}function eq(e,i,r,s){let n,o=e.length,a=0;if(i=i<0?-i>o?0:o+i:i>o?o:i,r=r>0?r:0,s.length<1e4)(n=Array.from(s)).unshift(i,r),e.splice(...n);else for(r&&e.splice(i,r);a<s.length;)(n=s.slice(a,a+1e4)).unshift(i,0),e.splice(...n),a+=1e4,i+=1e4}function eV(e,i){return e.length>0?(eq(e,e.length,0,i),e):i}let eY={}.hasOwnProperty,eG=e9(/[A-Za-z]/),eX=e9(/[\dA-Za-z]/),eJ=e9(/[#-'*+\--9=?A-Z^-~]/);function eQ(e){return null!==e&&(e<32||127===e)}let eZ=e9(/\d/),e0=e9(/[\dA-Fa-f]/),e1=e9(/[!-/:-@[-`{-~]/);function e2(e){return null!==e&&e<-2}function e5(e){return null!==e&&(e<0||32===e)}function e3(e){return -2===e||-1===e||32===e}let e4=e9(/\p{P}|\p{S}/u),e6=e9(/\s/);function e9(e){return function(i){return null!==i&&i>-1&&e.test(String.fromCharCode(i))}}function e8(e,i,r,s){let n=s?s-1:1/0,o=0;return function(s){return e3(s)?(e.enter(r),function s(a){return e3(a)&&o++<n?(e.consume(a),s):(e.exit(r),i(a))}(s)):i(s)}}let e7={tokenize:function(e){let i,r=e.attempt(this.parser.constructs.contentInitial,function(i){return null===i?void e.consume(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e8(e,r,"linePrefix"))},function(r){return e.enter("paragraph"),function r(s){let n=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=n),i=n,function i(s){if(null===s){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return e2(s)?(e.consume(s),e.exit("chunkText"),r):(e.consume(s),i)}(s)}(r)});return r}},te={tokenize:function(e){let i,r,s,n=this,o=[],a=0;return l;function l(i){if(a<o.length){let r=o[a];return n.containerState=r[1],e.attempt(r[0].continuation,h,c)(i)}return c(i)}function h(e){if(a++,n.containerState._closeFlow){let r;n.containerState._closeFlow=void 0,i&&v();let s=n.events.length,o=s;for(;o--;)if("exit"===n.events[o][0]&&"chunkFlow"===n.events[o][1].type){r=n.events[o][1].end;break}g(a);let l=s;for(;l<n.events.length;)n.events[l][1].end={...r},l++;return eq(n.events,o+1,0,n.events.slice(s)),n.events.length=l,c(e)}return l(e)}function c(r){if(a===o.length){if(!i)return f(r);if(i.currentConstruct&&i.currentConstruct.concrete)return m(r);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(tt,d,u)(r)}function d(e){return i&&v(),g(a),f(e)}function u(e){return n.parser.lazy[n.now().line]=a!==o.length,s=n.now().offset,m(e)}function f(i){return n.containerState={},e.attempt(tt,p,m)(i)}function p(e){return a++,o.push([n.currentConstruct,n.containerState]),f(e)}function m(s){if(null===s){i&&v(),g(0),e.consume(s);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:r}),function i(r){if(null===r){_(e.exit("chunkFlow"),!0),g(0),e.consume(r);return}return e2(r)?(e.consume(r),_(e.exit("chunkFlow")),a=0,n.interrupt=void 0,l):(e.consume(r),i)}(s)}function _(e,o){let l=n.sliceStream(e);if(o&&l.push(null),e.previous=r,r&&(r.next=e),r=e,i.defineSkip(e.start),i.write(l),n.parser.lazy[e.start.line]){let e,r,o=i.events.length;for(;o--;)if(i.events[o][1].start.offset<s&&(!i.events[o][1].end||i.events[o][1].end.offset>s))return;let l=n.events.length,h=l;for(;h--;)if("exit"===n.events[h][0]&&"chunkFlow"===n.events[h][1].type){if(e){r=n.events[h][1].end;break}e=!0}for(g(a),o=l;o<n.events.length;)n.events[o][1].end={...r},o++;eq(n.events,h+1,0,n.events.slice(l)),n.events.length=o}}function g(i){let r=o.length;for(;r-- >i;){let i=o[r];n.containerState=i[1],i[0].exit.call(n,e)}o.length=i}function v(){i.write([null]),r=void 0,i=void 0,n.containerState._closeFlow=void 0}}},tt={tokenize:function(e,i,r){return e8(e,e.attempt(this.parser.constructs.document,i,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},ti={partial:!0,tokenize:function(e,i,r){return function(i){return e3(i)?e8(e,s,"linePrefix")(i):s(i)};function s(e){return null===e||e2(e)?i(e):r(e)}}};class tr{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,i){let r=null==i?1/0:i;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,i,r){this.setCursor(Math.trunc(e));let s=this.right.splice(this.right.length-(i||0),1/0);return r&&ts(this.left,r),s.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),ts(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ts(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let i=this.left.splice(e,1/0);ts(this.right,i.reverse())}else{let i=this.right.splice(this.left.length+this.right.length-e,1/0);ts(this.left,i.reverse())}}}function ts(e,i){let r=0;if(i.length<1e4)e.push(...i);else for(;r<i.length;)e.push(...i.slice(r,r+1e4)),r+=1e4}function tn(e){let i,r,s,n,o,a,l,h={},c=-1,d=new tr(e);for(;++c<d.length;){for(;c in h;)c=h[c];if(i=d.get(c),c&&"chunkFlow"===i[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((s=0)<(a=i[1]._tokenizer.events).length&&"lineEndingBlank"===a[s][1].type&&(s+=2),s<a.length&&"content"===a[s][1].type))for(;++s<a.length&&"content"!==a[s][1].type;)"chunkText"===a[s][1].type&&(a[s][1]._isInFirstContentOfListItem=!0,s++);if("enter"===i[0])i[1].contentType&&(Object.assign(h,function(e,i){let r,s,n=e.get(i)[1],o=e.get(i)[2],a=i-1,l=[],h=n._tokenizer;!h&&(h=o.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(h._contentTypeTextTrailing=!0));let c=h.events,d=[],u={},f=-1,p=n,m=0,_=0,g=[0];for(;p;){for(;e.get(++a)[1]!==p;);l.push(a),!p._tokenizer&&(r=o.sliceStream(p),p.next||r.push(null),s&&h.defineSkip(p.start),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=!0),h.write(r),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=void 0)),s=p,p=p.next}for(p=n;++f<c.length;)"exit"===c[f][0]&&"enter"===c[f-1][0]&&c[f][1].type===c[f-1][1].type&&c[f][1].start.line!==c[f][1].end.line&&(_=f+1,g.push(_),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(h.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let i=c.slice(g[f],g[f+1]),r=l.pop();d.push([r,r+i.length-1]),e.splice(r,2,i)}for(d.reverse(),f=-1;++f<d.length;)u[m+d[f][0]]=m+d[f][1],m+=d[f][1]-d[f][0]-1;return u}(d,c)),c=h[c],l=!0);else if(i[1]._container){for(s=c,r=void 0;s--;)if("lineEnding"===(n=d.get(s))[1].type||"lineEndingBlank"===n[1].type)"enter"===n[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),n[1].type="lineEnding",r=s);else if("linePrefix"===n[1].type||"listItemIndent"===n[1].type);else break;r&&(i[1].end={...d.get(r)[1].start},(o=d.slice(r,c)).unshift(i),d.splice(r,c-r+1,o))}}return eq(e,0,1/0,d.slice(0)),!l}let to={resolve:function(e){return tn(e),e},tokenize:function(e,i){let r;return function(i){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),s(i)};function s(i){return null===i?n(i):e2(i)?e.check(ta,o,n)(i):(e.consume(i),s)}function n(r){return e.exit("chunkContent"),e.exit("content"),i(r)}function o(i){return e.consume(i),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}},ta={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e8(e,n,"linePrefix")};function n(n){if(null===n||e2(n))return r(n);let o=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(n):e.interrupt(s.parser.constructs.flow,r,i)(n)}}},tl={tokenize:function(e){let i=this,r=e.attempt(ti,function(s){return null===s?void e.consume(s):(e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),i.currentConstruct=void 0,r)},e.attempt(this.parser.constructs.flowInitial,s,e8(e,e.attempt(this.parser.constructs.flow,s,e.attempt(to,s)),"linePrefix")));return r;function s(s){return null===s?void e.consume(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i.currentConstruct=void 0,r)}}},th={resolveAll:tf()},tc=tu("string"),td=tu("text");function tu(e){return{resolveAll:tf("text"===e?tp:void 0),tokenize:function(i){let r=this,s=this.parser.constructs[e],n=i.attempt(s,o,a);return o;function o(e){return h(e)?n(e):a(e)}function a(e){return null===e?void i.consume(e):(i.enter("data"),i.consume(e),l)}function l(e){return h(e)?(i.exit("data"),n(e)):(i.consume(e),l)}function h(e){if(null===e)return!0;let i=s[e],n=-1;if(i)for(;++n<i.length;){let e=i[n];if(!e.previous||e.previous.call(r,r.previous))return!0}return!1}}}}function tf(e){return function(i,r){let s,n=-1;for(;++n<=i.length;)void 0===s?i[n]&&"data"===i[n][1].type&&(s=n,n++):i[n]&&"data"===i[n][1].type||(n!==s+2&&(i[s][1].end=i[n-1][1].end,i.splice(s+2,n-s-2),n=s+2),s=void 0);return e?e(i,r):i}}function tp(e,i){let r=0;for(;++r<=e.length;)if((r===e.length||"lineEnding"===e[r][1].type)&&"data"===e[r-1][1].type){let s,n=e[r-1][1],o=i.sliceStream(n),a=o.length,l=-1,h=0;for(;a--;){let e=o[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)h++,l--;if(l)break;l=-1}else if(-2===e)s=!0,h++;else if(-1===e);else{a++;break}}if(i._contentTypeTextTrailing&&r===e.length&&(h=0),h){let o={type:r===e.length||s||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:n.start._bufferIndex+l,_index:n.start._index+a,line:n.end.line,column:n.end.column-h,offset:n.end.offset-h},end:{...n.end}};n.end={...o.start},n.start.offset===n.end.offset?Object.assign(n,o):(e.splice(r,0,["enter",o,i],["exit",o,i]),r+=2)}r++}return e}function tm(e){return null===e||e5(e)||e6(e)?1:e4(e)?2:void 0}function t_(e,i,r){let s=[],n=-1;for(;++n<e.length;){let o=e[n].resolveAll;o&&!s.includes(o)&&(i=o(i,r),s.push(o))}return i}let tg={name:"attention",resolveAll:function(e,i){let r,s,n,o,a,l,h,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(r=d;r--;)if("exit"===e[r][0]&&"attentionSequence"===e[r][1].type&&e[r][1]._open&&i.sliceSerialize(e[r][1]).charCodeAt(0)===i.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[r][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[r][1].end},f={...e[d][1].start};tv(u,-l),tv(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:f},n={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[d][1].start}},s={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[d][1].start={...a.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=eV(h,[["enter",e[r][1],i],["exit",e[r][1],i]])),h=eV(h,[["enter",s,i],["enter",o,i],["exit",o,i],["enter",n,i]]),h=eV(h,t_(i.parser.constructs.insideSpan.null,e.slice(r+1,d),i)),h=eV(h,[["exit",n,i],["enter",a,i],["exit",a,i],["exit",s,i]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,h=eV(h,[["enter",e[d][1],i],["exit",e[d][1],i]])):c=0,eq(e,r-1,d-r+3,h),d=r+h.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,i){let r,s=this.parser.constructs.attentionMarkers.null,n=this.previous,o=tm(n);return function(a){return r=a,e.enter("attentionSequence"),function a(l){if(l===r)return e.consume(l),a;let h=e.exit("attentionSequence"),c=tm(l),d=!c||2===c&&o||s.includes(l),u=!o||2===o&&c||s.includes(n);return h._open=!!(42===r?d:d&&(o||!u)),h._close=!!(42===r?u:u&&(c||!d)),i(l)}(a)}}};function tv(e,i){e.column+=i,e.offset+=i,e._bufferIndex+=i}let tx={continuation:{tokenize:function(e,i,r){let s=this;return function(i){return e3(i)?e8(e,n,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):n(i)};function n(s){return e.attempt(tx,i,r)(s)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,i,r){let s=this;return function(i){if(62===i){let r=s.containerState;return r.open||(e.enter("blockQuote",{_container:!0}),r.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),n}return r(i)};function n(r){return e3(r)?(e.enter("blockQuotePrefixWhitespace"),e.consume(r),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),i):(e.exit("blockQuotePrefix"),i(r))}}},tb={name:"characterEscape",tokenize:function(e,i,r){return function(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s};function s(s){return e1(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),i):r(s)}}},ty=document.createElement("i");function tS(e){let i="&"+e+";";ty.innerHTML=i;let r=ty.textContent;return(59!==r.charCodeAt(r.length-1)||"semi"===e)&&r!==i&&r}let tw={name:"characterReference",tokenize:function(e,i,r){let s,n,o=this,a=0;return function(i){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(i),e.exit("characterReferenceMarker"),l};function l(i){return 35===i?(e.enter("characterReferenceMarkerNumeric"),e.consume(i),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),s=31,n=eX,c(i))}function h(i){return 88===i||120===i?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(i),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,n=e0,c):(e.enter("characterReferenceValue"),s=7,n=eZ,c(i))}function c(l){if(59===l&&a){let s=e.exit("characterReferenceValue");return n!==eX||tS(o.sliceSerialize(s))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),i):r(l)}return n(l)&&a++<s?(e.consume(l),c):r(l)}}},tC={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return null===i?r(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tk={concrete:!0,name:"codeFenced",tokenize:function(e,i,r){let s,n=this,o={partial:!0,tokenize:function(e,i,r){let o=0;return function(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),a};function a(i){return e.enter("codeFencedFence"),e3(i)?e8(e,h,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):h(i)}function h(i){return i===s?(e.enter("codeFencedFenceSequence"),function i(n){return n===s?(o++,e.consume(n),i):o>=l?(e.exit("codeFencedFenceSequence"),e3(n)?e8(e,c,"whitespace")(n):c(n)):r(n)}(i)):r(i)}function c(s){return null===s||e2(s)?(e.exit("codeFencedFence"),i(s)):r(s)}}},a=0,l=0;return function(i){var o;let c;return o=i,a=(c=n.events[n.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,s=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function i(n){return n===s?(l++,e.consume(n),i):l<3?r(n):(e.exit("codeFencedFenceSequence"),e3(n)?e8(e,h,"whitespace")(n):h(n))}(o)};function h(o){return null===o||e2(o)?(e.exit("codeFencedFence"),n.interrupt?i(o):e.check(tC,d,m)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||e2(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(n)):e3(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),e8(e,c,"whitespace")(n)):96===n&&n===s?r(n):(e.consume(n),i)}(o))}function c(i){return null===i||e2(i)?h(i):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||e2(n)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(n)):96===n&&n===s?r(n):(e.consume(n),i)}(i))}function d(i){return e.attempt(o,m,u)(i)}function u(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),f}function f(i){return a>0&&e3(i)?e8(e,p,"linePrefix",a+1)(i):p(i)}function p(i){return null===i||e2(i)?e.check(tC,d,m)(i):(e.enter("codeFlowValue"),function i(r){return null===r||e2(r)?(e.exit("codeFlowValue"),p(r)):(e.consume(r),i)}(i))}function m(r){return e.exit("codeFenced"),i(r)}}},tE={name:"codeIndented",tokenize:function(e,i,r){let s=this;return function(i){return e.enter("codeIndented"),e8(e,n,"linePrefix",5)(i)};function n(i){let n=s.events[s.events.length-1];return n&&"linePrefix"===n[1].type&&n[2].sliceSerialize(n[1],!0).length>=4?function i(r){return null===r?o(r):e2(r)?e.attempt(tN,i,o)(r):(e.enter("codeFlowValue"),function r(s){return null===s||e2(s)?(e.exit("codeFlowValue"),i(s)):(e.consume(s),r)}(r))}(i):r(i)}function o(r){return e.exit("codeIndented"),i(r)}}},tN={partial:!0,tokenize:function(e,i,r){let s=this;return n;function n(i){return s.parser.lazy[s.now().line]?r(i):e2(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):e8(e,o,"linePrefix",5)(i)}function o(e){let o=s.events[s.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(e):e2(e)?n(e):r(e)}}};function tR(e,i,r,s,n,o,a,l,h){let c=h||1/0,d=0;return function(i){return 60===i?(e.enter(s),e.enter(n),e.enter(o),e.consume(i),e.exit(o),u):null===i||32===i||41===i||eQ(i)?r(i):(e.enter(s),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),m(i))};function u(r){return 62===r?(e.enter(o),e.consume(r),e.exit(o),e.exit(n),e.exit(s),i):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(r))}function f(i){return 62===i?(e.exit("chunkString"),e.exit(l),u(i)):null===i||60===i||e2(i)?r(i):(e.consume(i),92===i?p:f)}function p(i){return 60===i||62===i||92===i?(e.consume(i),f):f(i)}function m(n){return!d&&(null===n||41===n||e5(n))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(s),i(n)):d<c&&40===n?(e.consume(n),d++,m):41===n?(e.consume(n),d--,m):null===n||32===n||40===n||eQ(n)?r(n):(e.consume(n),92===n?_:m)}function _(i){return 40===i||41===i||92===i?(e.consume(i),m):m(i)}}function tj(e,i,r,s,n,o){let a,l=this,h=0;return function(i){return e.enter(s),e.enter(n),e.consume(i),e.exit(n),e.enter(o),c};function c(u){return h>999||null===u||91===u||93===u&&!a||94===u&&!h&&"_hiddenFootnoteSupport"in l.parser.constructs?r(u):93===u?(e.exit(o),e.enter(n),e.consume(u),e.exit(n),e.exit(s),i):e2(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(i){return null===i||91===i||93===i||e2(i)||h++>999?(e.exit("chunkString"),c(i)):(e.consume(i),a||(a=!e3(i)),92===i?u:d)}function u(i){return 91===i||92===i||93===i?(e.consume(i),h++,d):d(i)}}function tT(e,i,r,s,n,o){let a;return function(i){return 34===i||39===i||40===i?(e.enter(s),e.enter(n),e.consume(i),e.exit(n),a=40===i?41:i,l):r(i)};function l(r){return r===a?(e.enter(n),e.consume(r),e.exit(n),e.exit(s),i):(e.enter(o),h(r))}function h(i){return i===a?(e.exit(o),l(a)):null===i?r(i):e2(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e8(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(i))}function c(i){return i===a||null===i||e2(i)?(e.exit("chunkString"),h(i)):(e.consume(i),92===i?d:c)}function d(i){return i===a||92===i?(e.consume(i),c):c(i)}}function tD(e,i){let r;return function s(n){return e2(n)?(e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),r=!0,s):e3(n)?e8(e,s,r?"linePrefix":"lineSuffix")(n):i(n)}}function tM(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let tP={partial:!0,tokenize:function(e,i,r){return function(i){return e5(i)?tD(e,s)(i):r(i)};function s(i){return tT(e,n,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(i)}function n(i){return e3(i)?e8(e,o,"whitespace")(i):o(i)}function o(e){return null===e||e2(e)?i(e):r(e)}}},tL=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],tA=["pre","script","style","textarea"],tB={partial:!0,tokenize:function(e,i,r){return function(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(ti,i,r)}}},tI={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return e2(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):r(i)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tO={name:"labelEnd",resolveAll:function(e){let i=-1,r=[];for(;++i<e.length;){let s=e[i][1];if(r.push(e[i]),"labelImage"===s.type||"labelLink"===s.type||"labelEnd"===s.type){let e="labelImage"===s.type?4:2;s.type="data",i+=e}}return e.length!==r.length&&eq(e,0,e.length,r),e},resolveTo:function(e,i){let r,s,n,o,a=e.length,l=0;for(;a--;)if(r=e[a][1],s){if("link"===r.type||"labelLink"===r.type&&r._inactive)break;"enter"===e[a][0]&&"labelLink"===r.type&&(r._inactive=!0)}else if(n){if("enter"===e[a][0]&&("labelImage"===r.type||"labelLink"===r.type)&&!r._balanced&&(s=a,"labelLink"!==r.type)){l=2;break}}else"labelEnd"===r.type&&(n=a);let h={type:"labelLink"===e[s][1].type?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[n][1].end}},d={type:"labelText",start:{...e[s+l+2][1].end},end:{...e[n-2][1].start}};return o=eV(o=[["enter",h,i],["enter",c,i]],e.slice(s+1,s+l+3)),o=eV(o,[["enter",d,i]]),o=eV(o,t_(i.parser.constructs.insideSpan.null,e.slice(s+l+4,n-3),i)),o=eV(o,[["exit",d,i],e[n-2],e[n-1],["exit",c,i]]),o=eV(o,e.slice(n+1)),o=eV(o,[["exit",h,i]]),eq(e,s,e.length,o),e},tokenize:function(e,i,r){let s,n,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){s=o.events[a][1];break}return function(i){return s?s._inactive?d(i):(n=o.parser.defined.includes(tM(o.sliceSerialize({start:s.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelEnd"),l):r(i)};function l(i){return 40===i?e.attempt(tF,c,n?c:d)(i):91===i?e.attempt(tz,c,n?h:d)(i):n?c(i):d(i)}function h(i){return e.attempt(tH,c,d)(i)}function c(e){return i(e)}function d(e){return s._balanced=!0,r(e)}}},tF={tokenize:function(e,i,r){return function(i){return e.enter("resource"),e.enter("resourceMarker"),e.consume(i),e.exit("resourceMarker"),s};function s(i){return e5(i)?tD(e,n)(i):n(i)}function n(i){return 41===i?c(i):tR(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(i)}function o(i){return e5(i)?tD(e,l)(i):c(i)}function a(e){return r(e)}function l(i){return 34===i||39===i||40===i?tT(e,h,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(i):c(i)}function h(i){return e5(i)?tD(e,c)(i):c(i)}function c(s){return 41===s?(e.enter("resourceMarker"),e.consume(s),e.exit("resourceMarker"),e.exit("resource"),i):r(s)}}},tz={tokenize:function(e,i,r){let s=this;return function(i){return tj.call(s,e,n,o,"reference","referenceMarker","referenceString")(i)};function n(e){return s.parser.defined.includes(tM(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?i(e):r(e)}function o(e){return r(e)}}},tH={tokenize:function(e,i,r){return function(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s};function s(s){return 93===s?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),i):r(s)}}},t$={name:"labelStartImage",resolveAll:tO.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(i),e.exit("labelImageMarker"),n};function n(i){return 91===i?(e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelImage"),o):r(i)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tW={name:"labelStartLink",resolveAll:tO.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),n};function n(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tU={name:"lineEnding",tokenize:function(e,i){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e8(e,i,"linePrefix")}}},tK={name:"thematicBreak",tokenize:function(e,i,r){let s,n=0;return function(o){var a;return e.enter("thematicBreak"),s=a=o,function o(a){return a===s?(e.enter("thematicBreakSequence"),function i(r){return r===s?(e.consume(r),n++,i):(e.exit("thematicBreakSequence"),e3(r)?e8(e,o,"whitespace")(r):o(r))}(a)):n>=3&&(null===a||e2(a))?(e.exit("thematicBreak"),i(a)):r(a)}(a)}}},tq={continuation:{tokenize:function(e,i,r){let s=this;return s.containerState._closeFlow=void 0,e.check(ti,function(r){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,e8(e,i,"listItemIndent",s.containerState.size+1)(r)},function(r){return s.containerState.furtherBlankLines||!e3(r)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,n(r)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(tY,i,n)(r))});function n(n){return s.containerState._closeFlow=!0,s.interrupt=void 0,e8(e,e.attempt(tq,i,r),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(n)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,i,r){let s=this,n=s.events[s.events.length-1],o=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,a=0;return function(i){let n=s.containerState.type||(42===i||43===i||45===i?"listUnordered":"listOrdered");if("listUnordered"===n?!s.containerState.marker||i===s.containerState.marker:eZ(i)){if(s.containerState.type||(s.containerState.type=n,e.enter(n,{_container:!0})),"listUnordered"===n)return e.enter("listItemPrefix"),42===i||45===i?e.check(tK,r,l)(i):l(i);if(!s.interrupt||49===i)return e.enter("listItemPrefix"),e.enter("listItemValue"),function i(n){return eZ(n)&&++a<10?(e.consume(n),i):(!s.interrupt||a<2)&&(s.containerState.marker?n===s.containerState.marker:41===n||46===n)?(e.exit("listItemValue"),l(n)):r(n)}(i)}return r(i)};function l(i){return e.enter("listItemMarker"),e.consume(i),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||i,e.check(ti,s.interrupt?r:h,e.attempt(tV,d,c))}function h(e){return s.containerState.initialBlankLine=!0,o++,d(e)}function c(i){return e3(i)?(e.enter("listItemPrefixWhitespace"),e.consume(i),e.exit("listItemPrefixWhitespace"),d):r(i)}function d(r){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,i(r)}}},tV={partial:!0,tokenize:function(e,i,r){let s=this;return e8(e,function(e){let n=s.events[s.events.length-1];return!e3(e)&&n&&"listItemPrefixWhitespace"===n[1].type?i(e):r(e)},"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},tY={partial:!0,tokenize:function(e,i,r){let s=this;return e8(e,function(e){let n=s.events[s.events.length-1];return n&&"listItemIndent"===n[1].type&&n[2].sliceSerialize(n[1],!0).length===s.containerState.size?i(e):r(e)},"listItemIndent",s.containerState.size+1)}},tG={name:"setextUnderline",resolveTo:function(e,i){let r,s,n,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){r=o;break}"paragraph"===e[o][1].type&&(s=o)}else"content"===e[o][1].type&&e.splice(o,1),n||"definition"!==e[o][1].type||(n=o);let a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",n?(e.splice(s,0,["enter",a,i]),e.splice(n+1,0,["exit",e[r][1],i]),e[r][1].end={...e[n][1].end}):e[r][1]=a,e.push(["exit",a,i]),e},tokenize:function(e,i,r){let s,n=this;return function(i){var a;let l,h=n.events.length;for(;h--;)if("lineEnding"!==n.events[h][1].type&&"linePrefix"!==n.events[h][1].type&&"content"!==n.events[h][1].type){l="paragraph"===n.events[h][1].type;break}return!n.parser.lazy[n.now().line]&&(n.interrupt||l)?(e.enter("setextHeadingLine"),s=i,a=i,e.enter("setextHeadingLineSequence"),function i(r){return r===s?(e.consume(r),i):(e.exit("setextHeadingLineSequence"),e3(r)?e8(e,o,"lineSuffix")(r):o(r))}(a)):r(i)};function o(s){return null===s||e2(s)?(e.exit("setextHeadingLine"),i(s)):r(s)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,i,r){let s,n=this;return function(i){var s;return e.enter("definition"),s=i,tj.call(n,e,o,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(s)};function o(i){return(s=tM(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),58===i)?(e.enter("definitionMarker"),e.consume(i),e.exit("definitionMarker"),a):r(i)}function a(i){return e5(i)?tD(e,l)(i):l(i)}function l(i){return tR(e,h,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(i)}function h(i){return e.attempt(tP,c,c)(i)}function c(i){return e3(i)?e8(e,d,"whitespace")(i):d(i)}function d(o){return null===o||e2(o)?(e.exit("definition"),n.parser.defined.push(s),i(o)):r(o)}}}},"disable",0,{null:[]},"document",0,{42:tq,43:tq,45:tq,48:tq,49:tq,50:tq,51:tq,52:tq,53:tq,54:tq,55:tq,56:tq,57:tq,62:tx},"flow",0,{35:{name:"headingAtx",resolve:function(e,i){let r,s,n=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),n-2>o&&"whitespace"===e[n][1].type&&(n-=2),"atxHeadingSequence"===e[n][1].type&&(o===n-1||n-4>o&&"whitespace"===e[n-2][1].type)&&(n-=o+1===n?2:4),n>o&&(r={type:"atxHeadingText",start:e[o][1].start,end:e[n][1].end},s={type:"chunkText",start:e[o][1].start,end:e[n][1].end,contentType:"text"},eq(e,o,n-o+1,[["enter",r,i],["enter",s,i],["exit",s,i],["exit",r,i]])),e},tokenize:function(e,i,r){let s=0;return function(n){var o;return e.enter("atxHeading"),o=n,e.enter("atxHeadingSequence"),function n(o){return 35===o&&s++<6?(e.consume(o),n):null===o||e5(o)?(e.exit("atxHeadingSequence"),function r(s){return 35===s?(e.enter("atxHeadingSequence"),function i(s){return 35===s?(e.consume(s),i):(e.exit("atxHeadingSequence"),r(s))}(s)):null===s||e2(s)?(e.exit("atxHeading"),i(s)):e3(s)?e8(e,r,"whitespace")(s):(e.enter("atxHeadingText"),function i(s){return null===s||35===s||e5(s)?(e.exit("atxHeadingText"),r(s)):(e.consume(s),i)}(s))}(o)):r(o)}(o)}}},42:tK,45:[tG,tK],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let i=e.length;for(;i--&&("enter"!==e[i][0]||"htmlFlow"!==e[i][1].type););return i>1&&"linePrefix"===e[i-2][1].type&&(e[i][1].start=e[i-2][1].start,e[i+1][1].start=e[i-2][1].start,e.splice(i-2,2)),e},tokenize:function(e,i,r){let s,n,o,a,l,h=this;return function(i){var r;return r=i,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(r),c};function c(a){return 33===a?(e.consume(a),d):47===a?(e.consume(a),n=!0,p):63===a?(e.consume(a),s=3,h.interrupt?i:P):eG(a)?(e.consume(a),o=String.fromCharCode(a),m):r(a)}function d(n){return 45===n?(e.consume(n),s=2,u):91===n?(e.consume(n),s=5,a=0,f):eG(n)?(e.consume(n),s=4,h.interrupt?i:P):r(n)}function u(s){return 45===s?(e.consume(s),h.interrupt?i:P):r(s)}function f(s){let n="CDATA[";return s===n.charCodeAt(a++)?(e.consume(s),a===n.length)?h.interrupt?i:k:f:r(s)}function p(i){return eG(i)?(e.consume(i),o=String.fromCharCode(i),m):r(i)}function m(a){if(null===a||47===a||62===a||e5(a)){let l=47===a,c=o.toLowerCase();return!l&&!n&&tA.includes(c)?(s=1,h.interrupt?i(a):k(a)):tL.includes(o.toLowerCase())?(s=6,l)?(e.consume(a),_):h.interrupt?i(a):k(a):(s=7,h.interrupt&&!h.parser.lazy[h.now().line]?r(a):n?function i(r){return e3(r)?(e.consume(r),i):w(r)}(a):g(a))}return 45===a||eX(a)?(e.consume(a),o+=String.fromCharCode(a),m):r(a)}function _(s){return 62===s?(e.consume(s),h.interrupt?i:k):r(s)}function g(i){return 47===i?(e.consume(i),w):58===i||95===i||eG(i)?(e.consume(i),v):e3(i)?(e.consume(i),g):w(i)}function v(i){return 45===i||46===i||58===i||95===i||eX(i)?(e.consume(i),v):x(i)}function x(i){return 61===i?(e.consume(i),b):e3(i)?(e.consume(i),x):g(i)}function b(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),l=i,y):e3(i)?(e.consume(i),b):function i(r){return null===r||34===r||39===r||47===r||60===r||61===r||62===r||96===r||e5(r)?x(r):(e.consume(r),i)}(i)}function y(i){return i===l?(e.consume(i),l=null,S):null===i||e2(i)?r(i):(e.consume(i),y)}function S(e){return 47===e||62===e||e3(e)?g(e):r(e)}function w(i){return 62===i?(e.consume(i),C):r(i)}function C(i){return null===i||e2(i)?k(i):e3(i)?(e.consume(i),C):r(i)}function k(i){return 45===i&&2===s?(e.consume(i),j):60===i&&1===s?(e.consume(i),T):62===i&&4===s?(e.consume(i),L):63===i&&3===s?(e.consume(i),P):93===i&&5===s?(e.consume(i),M):e2(i)&&(6===s||7===s)?(e.exit("htmlFlowData"),e.check(tB,A,E)(i)):null===i||e2(i)?(e.exit("htmlFlowData"),E(i)):(e.consume(i),k)}function E(i){return e.check(tI,N,A)(i)}function N(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),R}function R(i){return null===i||e2(i)?E(i):(e.enter("htmlFlowData"),k(i))}function j(i){return 45===i?(e.consume(i),P):k(i)}function T(i){return 47===i?(e.consume(i),o="",D):k(i)}function D(i){if(62===i){let r=o.toLowerCase();return tA.includes(r)?(e.consume(i),L):k(i)}return eG(i)&&o.length<8?(e.consume(i),o+=String.fromCharCode(i),D):k(i)}function M(i){return 93===i?(e.consume(i),P):k(i)}function P(i){return 62===i?(e.consume(i),L):45===i&&2===s?(e.consume(i),P):k(i)}function L(i){return null===i||e2(i)?(e.exit("htmlFlowData"),A(i)):(e.consume(i),L)}function A(r){return e.exit("htmlFlow"),i(r)}}},61:tG,95:tK,96:tk,126:tk},"flowInitial",0,{[-2]:tE,[-1]:tE,32:tE},"insideSpan",0,{null:[tg,th]},"string",0,{38:tw,92:tb},"text",0,{[-5]:tU,[-4]:tU,[-3]:tU,33:t$,38:tw,42:tg,60:[{name:"autolink",tokenize:function(e,i,r){let s=0;return function(i){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),n};function n(i){return eG(i)?(e.consume(i),o):64===i?r(i):l(i)}function o(i){return 43===i||45===i||46===i||eX(i)?(s=1,function i(r){return 58===r?(e.consume(r),s=0,a):(43===r||45===r||46===r||eX(r))&&s++<32?(e.consume(r),i):(s=0,l(r))}(i)):l(i)}function a(s){return 62===s?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(s),e.exit("autolinkMarker"),e.exit("autolink"),i):null===s||32===s||60===s||eQ(s)?r(s):(e.consume(s),a)}function l(i){return 64===i?(e.consume(i),h):eJ(i)?(e.consume(i),l):r(i)}function h(n){return eX(n)?function n(o){return 46===o?(e.consume(o),s=0,h):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),i):function i(o){if((45===o||eX(o))&&s++<63){let r=45===o?i:n;return e.consume(o),r}return r(o)}(o)}(n):r(n)}}},{name:"htmlText",tokenize:function(e,i,r){let s,n,o,a=this;return function(i){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(i),l};function l(i){return 33===i?(e.consume(i),h):47===i?(e.consume(i),y):63===i?(e.consume(i),x):eG(i)?(e.consume(i),w):r(i)}function h(i){return 45===i?(e.consume(i),c):91===i?(e.consume(i),n=0,p):eG(i)?(e.consume(i),v):r(i)}function c(i){return 45===i?(e.consume(i),f):r(i)}function d(i){return null===i?r(i):45===i?(e.consume(i),u):e2(i)?(o=d,D(i)):(e.consume(i),d)}function u(i){return 45===i?(e.consume(i),f):d(i)}function f(e){return 62===e?T(e):45===e?u(e):d(e)}function p(i){let s="CDATA[";return i===s.charCodeAt(n++)?(e.consume(i),n===s.length?m:p):r(i)}function m(i){return null===i?r(i):93===i?(e.consume(i),_):e2(i)?(o=m,D(i)):(e.consume(i),m)}function _(i){return 93===i?(e.consume(i),g):m(i)}function g(i){return 62===i?T(i):93===i?(e.consume(i),g):m(i)}function v(i){return null===i||62===i?T(i):e2(i)?(o=v,D(i)):(e.consume(i),v)}function x(i){return null===i?r(i):63===i?(e.consume(i),b):e2(i)?(o=x,D(i)):(e.consume(i),x)}function b(e){return 62===e?T(e):x(e)}function y(i){return eG(i)?(e.consume(i),S):r(i)}function S(i){return 45===i||eX(i)?(e.consume(i),S):function i(r){return e2(r)?(o=i,D(r)):e3(r)?(e.consume(r),i):T(r)}(i)}function w(i){return 45===i||eX(i)?(e.consume(i),w):47===i||62===i||e5(i)?C(i):r(i)}function C(i){return 47===i?(e.consume(i),T):58===i||95===i||eG(i)?(e.consume(i),k):e2(i)?(o=C,D(i)):e3(i)?(e.consume(i),C):T(i)}function k(i){return 45===i||46===i||58===i||95===i||eX(i)?(e.consume(i),k):function i(r){return 61===r?(e.consume(r),E):e2(r)?(o=i,D(r)):e3(r)?(e.consume(r),i):C(r)}(i)}function E(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),s=i,N):e2(i)?(o=E,D(i)):e3(i)?(e.consume(i),E):(e.consume(i),R)}function N(i){return i===s?(e.consume(i),s=void 0,j):null===i?r(i):e2(i)?(o=N,D(i)):(e.consume(i),N)}function R(i){return null===i||34===i||39===i||60===i||61===i||96===i?r(i):47===i||62===i||e5(i)?C(i):(e.consume(i),R)}function j(e){return 47===e||62===e||e5(e)?C(e):r(e)}function T(s){return 62===s?(e.consume(s),e.exit("htmlTextData"),e.exit("htmlText"),i):r(s)}function D(i){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),M}function M(i){return e3(i)?e8(e,P,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):P(i)}function P(i){return e.enter("htmlTextData"),o(i)}}}],91:tW,92:[{name:"hardBreakEscape",tokenize:function(e,i,r){return function(i){return e.enter("hardBreakEscape"),e.consume(i),s};function s(s){return e2(s)?(e.exit("hardBreakEscape"),i(s)):r(s)}}},tb],93:tO,95:tg,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let i,r,s=e.length-4,n=3;if(("lineEnding"===e[3][1].type||"space"===e[n][1].type)&&("lineEnding"===e[s][1].type||"space"===e[s][1].type)){for(i=n;++i<s;)if("codeTextData"===e[i][1].type){e[n][1].type="codeTextPadding",e[s][1].type="codeTextPadding",n+=2,s-=2;break}}for(i=n-1,s++;++i<=s;)void 0===r?i!==s&&"lineEnding"!==e[i][1].type&&(r=i):(i===s||"lineEnding"===e[i][1].type)&&(e[r][1].type="codeTextData",i!==r+2&&(e[r][1].end=e[i-1][1].end,e.splice(r+2,i-r-2),s-=i-r-2,i=r+2),r=void 0);return e},tokenize:function(e,i,r){let s,n,o=0;return function(i){return e.enter("codeText"),e.enter("codeTextSequence"),function i(r){return 96===r?(e.consume(r),o++,i):(e.exit("codeTextSequence"),a(r))}(i)};function a(h){return null===h?r(h):32===h?(e.enter("space"),e.consume(h),e.exit("space"),a):96===h?(n=e.enter("codeTextSequence"),s=0,function r(a){return 96===a?(e.consume(a),s++,r):s===o?(e.exit("codeTextSequence"),e.exit("codeText"),i(a)):(n.type="codeTextData",l(a))}(h)):e2(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(h))}function l(i){return null===i||32===i||96===i||e2(i)?(e.exit("codeTextData"),a(i)):(e.consume(i),l)}}}}],4127);var tX=e.i(4127);let tJ=/[\0\t\n\r]/g;function tQ(e,i){let r=Number.parseInt(e,i);return r<9||11===r||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(65535&r)==65535||(65535&r)==65534||r>1114111?"�":String.fromCodePoint(r)}let tZ=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function t0(e,i,r){if(i)return i;if(35===r.charCodeAt(0)){let e=r.charCodeAt(1),i=120===e||88===e;return tQ(r.slice(i?2:1),i?16:10)}return tS(r)||e}let t1={}.hasOwnProperty;function t2(e){return{line:e.line,column:e.column,offset:e.offset}}function t5(e,i){if(e)throw Error("Cannot close `"+e.type+"` ("+eC({start:e.start,end:e.end})+"): a different token (`"+i.type+"`, "+eC({start:i.start,end:i.end})+") is open");throw Error("Cannot close document, a token (`"+i.type+"`, "+eC({start:i.start,end:i.end})+") is still open")}function t3(e){let i=this;i.parser=function(r){var s,n;let o,a,l,h;return"object"==typeof(s={...i.data("settings"),...e,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})&&(n=s,s=void 0),(function(e){let i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(v),autolinkProtocol:c,autolinkEmail:c,atxHeading:s(m),blockQuote:s(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:s(p),codeFencedFenceInfo:n,codeFencedFenceMeta:n,codeIndented:s(p,n),codeText:s(function(){return{type:"inlineCode",value:""}},n),codeTextData:c,data:c,codeFlowValue:c,definition:s(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:n,definitionLabelString:n,definitionTitleString:n,emphasis:s(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:s(_),hardBreakTrailing:s(_),htmlFlow:s(g,n),htmlFlowData:c,htmlText:s(g,n),htmlTextData:c,image:s(function(){return{type:"image",title:null,url:"",alt:null}}),label:n,link:s(v),listItem:s(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:s(x,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:s(x),paragraph:s(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:n,resourceDestinationString:n,resourceTitleString:n,setextHeading:s(m),strong:s(function(){return{type:"strong",children:[]}}),thematicBreak:s(function(){return{type:"thematicBreak"}})},exit:{atxHeading:a(),atxHeadingSequence:function(e){let i=this.stack[this.stack.length-1];i.depth||(i.depth=this.sliceSerialize(e).length)},autolink:a(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:a(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:f,characterReferenceMarkerNumeric:f,characterReferenceValue:function(e){let i,r=this.sliceSerialize(e),s=this.data.characterReferenceType;s?(i=tQ(r,"characterReferenceMarkerNumeric"===s?10:16),this.data.characterReferenceType=void 0):i=tS(r);let n=this.stack[this.stack.length-1];n.value+=i},characterReference:function(e){this.stack.pop().position.end=t2(e.end)},codeFenced:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:a(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tM(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:a(),hardBreakEscape:a(u),hardBreakTrailing:a(u),htmlFlow:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],i=this.resume(),r=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===r.type?r.children=e.children:r.alt=i},labelText:function(e){let i=this.sliceSerialize(e),r=this.stack[this.stack.length-2];r.label=i.replace(tZ,t0),r.identifier=tM(i).toLowerCase()},lineEnding:function(e){let r=this.stack[this.stack.length-1];if(this.data.atHardBreak){r.children[r.children.length-1].position.end=t2(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(r.type)&&(c.call(this,e),d.call(this,e))},link:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tM(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:a(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:a(),thematicBreak:a()}};!function e(i,r){let s=-1;for(;++s<r.length;){let n=r[s];Array.isArray(n)?e(i,n):function(e,i){let r;for(r in i)if(t1.call(i,r))switch(r){case"canContainEols":{let s=i[r];s&&e[r].push(...s);break}case"transforms":{let s=i[r];s&&e[r].push(...s);break}case"enter":case"exit":{let s=i[r];s&&Object.assign(e[r],s)}}}(i,n)}}(i,(e||{}).mdastExtensions||[]);let r={};return function(e){let s={type:"root",children:[]},a={stack:[s],tokenStack:[],config:i,enter:o,exit:l,buffer:n,resume:h,data:r},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,i,r){let s,n,o,a,l=i-1,h=-1,c=!1;for(;++l<=r;){let i=e[l];switch(i[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===i[0]?h++:h--,a=void 0;break;case"lineEndingBlank":"enter"===i[0]&&(!s||a||h||o||(o=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!h&&"enter"===i[0]&&"listItemPrefix"===i[1].type||-1===h&&"exit"===i[0]&&("listUnordered"===i[1].type||"listOrdered"===i[1].type)){if(s){let a=l;for(n=void 0;a--;){let i=e[a];if("lineEnding"===i[1].type||"lineEndingBlank"===i[1].type){if("exit"===i[0])continue;n&&(e[n][1].type="lineEndingBlank",c=!0),i[1].type="lineEnding",n=a}else if("linePrefix"===i[1].type||"blockQuotePrefix"===i[1].type||"blockQuotePrefixWhitespace"===i[1].type||"blockQuoteMarker"===i[1].type||"listItemIndent"===i[1].type);else break}o&&(!n||o<n)&&(s._spread=!0),s.end=Object.assign({},n?e[n][1].start:i[1].end),e.splice(n||l,0,["exit",s,i[2]]),l++,r++}if("listItemPrefix"===i[1].type){let n={type:"listItem",_spread:!1,start:Object.assign({},i[1].start),end:void 0};s=n,e.splice(l,0,["enter",n,i[2]]),l++,r++,o=void 0,a=!0}}}return e[i][1]._spread=c,r}(e,c.pop(),d));for(d=-1;++d<e.length;){let r=i[e[d][0]];t1.call(r,e[d][1].type)&&r[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||t5).call(a,void 0,e[0])}for(s.position={start:t2(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:t2(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<i.transforms.length;)s=i.transforms[d](s)||s;return s};function s(e,i){return function(r){o.call(this,e(r),r),i&&i.call(this,r)}}function n(){this.stack.push({type:"fragment",children:[]})}function o(e,i,r){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([i,r||void 0]),e.position={start:t2(i.start),end:void 0}}function a(e){return function(i){e&&e.call(this,i),l.call(this,i)}}function l(e,i){let r=this.stack.pop(),s=this.tokenStack.pop();if(s)s[0].type!==e.type&&(i?i.call(this,e,s[0]):(s[1]||t5).call(this,e,s[0]));else throw Error("Cannot close `"+e.type+"` ("+eC({start:e.start,end:e.end})+"): it’s not open");r.position.end=t2(e.end)}function h(){var e;return e=this.stack.pop(),eU(e,"boolean"!=typeof eW.includeImageAlt||eW.includeImageAlt,"boolean"!=typeof eW.includeHtml||eW.includeHtml)}function c(e){let i=this.stack[this.stack.length-1].children,r=i[i.length-1];r&&"text"===r.type||((r={type:"text",value:""}).position={start:t2(e.start),end:void 0},i.push(r)),this.stack.push(r)}function d(e){let i=this.stack.pop();i.value+=this.sliceSerialize(e),i.position.end=t2(e.end)}function u(){this.data.atHardBreak=!0}function f(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function _(){return{type:"break"}}function g(){return{type:"html",value:""}}function v(){return{type:"link",title:null,url:"",children:[]}}function x(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(n)(function(e){for(;!tn(e););return e}((function(e){let i={constructs:function(e){let i={},r=-1;for(;++r<e.length;)!function(e,i){let r;for(r in i){let s,n=(eY.call(e,r)?e[r]:void 0)||(e[r]={}),o=i[r];if(o)for(s in o){eY.call(n,s)||(n[s]=[]);let e=o[s];!function(e,i){let r=-1,s=[];for(;++r<i.length;)("after"===i[r].add?e:s).push(i[r]);eq(e,0,0,s)}(n[s],Array.isArray(e)?e:e?[e]:[])}}}(i,e[r]);return i}([tX,...(e||{}).extensions||[]]),content:r(e7),defined:[],document:r(te),flow:r(tl),lazy:{},string:r(tc),text:r(td)};return i;function r(e){return function(r){return function(e,i,r){let s={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},o=[],a=[],l=[],h={attempt:m(function(e,i){_(e,i.from)}),check:m(p),consume:function(e){e2(e)?(s.line++,s.column=1,s.offset+=-3===e?2:1,g()):-1!==e&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===a[s._index].length&&(s._bufferIndex=-1,s._index++)),c.previous=e},enter:function(e,i){let r=i||{};return r.type=e,r.start=f(),c.events.push(["enter",r,c]),l.push(r),r},exit:function(e){let i=l.pop();return i.end=f(),c.events.push(["exit",i,c]),i},interrupt:m(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){n[e.line]=e.column,g()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,i){return function(e,i){let r,s=-1,n=[];for(;++s<e.length;){let o,a=e[s];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=i?" ":" ";break;case -1:if(!i&&r)continue;o=" ";break;default:o=String.fromCharCode(a)}r=-2===a,n.push(o)}return n.join("")}(u(e),i)},sliceStream:u,write:function(e){return(a=eV(a,e),function(){let e;for(;s._index<a.length;){let r=a[s._index];if("string"==typeof r)for(e=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===e&&s._bufferIndex<r.length;){var i;i=r.charCodeAt(s._bufferIndex),d=d(i)}else d=d(r)}}(),null!==a[a.length-1])?[]:(_(i,0),c.events=t_(o,c.events,c),c.events)}},d=i.tokenize.call(c,h);return i.resolveAll&&o.push(i),c;function u(e){return function(e,i){let r,s=i.start._index,n=i.start._bufferIndex,o=i.end._index,a=i.end._bufferIndex;if(s===o)r=[e[s].slice(n,a)];else{if(r=e.slice(s,o),n>-1){let e=r[0];"string"==typeof e?r[0]=e.slice(n):r.shift()}a>0&&r.push(e[o].slice(0,a))}return r}(a,e)}function f(){let{_bufferIndex:e,_index:i,line:r,column:n,offset:o}=s;return{_bufferIndex:e,_index:i,line:r,column:n,offset:o}}function p(e,i){i.restore()}function m(e,i){return function(r,n,o){var a;let d,u,p,m;return Array.isArray(r)?_(r):"tokenize"in r?_([r]):(a=r,function(e){let i=null!==e&&a[e],r=null!==e&&a.null;return _([...Array.isArray(i)?i:i?[i]:[],...Array.isArray(r)?r:r?[r]:[]])(e)});function _(e){return(d=e,u=0,0===e.length)?o:v(e[u])}function v(e){return function(r){let n,o,a,d,u;return(n=f(),o=c.previous,a=c.currentConstruct,d=c.events.length,u=Array.from(l),m={from:d,restore:function(){s=n,c.previous=o,c.currentConstruct=a,c.events.length=d,l=u,g()}},p=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(r):e.tokenize.call(i?Object.assign(Object.create(c),i):c,h,x,b)(r)}}function x(i){return e(p,m),n}function b(e){return(m.restore(),++u<d.length)?v(d[u]):o}}}function _(e,i){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&eq(c.events,i,c.events.length-i,e.resolve(c.events.slice(i),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){s.line in n&&s.column<2&&(s.column=n[s.line],s.offset+=n[s.line]-1)}}(i,e,r)}}})(n).document().write((a=1,l="",h=!0,function(e,i,r){let s,n,c,d,u,f=[];for(e=l+("string"==typeof e?e.toString():new TextDecoder(i||void 0).decode(e)),c=0,l="",h&&(65279===e.charCodeAt(0)&&c++,h=void 0);c<e.length;){if(tJ.lastIndex=c,d=(s=tJ.exec(e))&&void 0!==s.index?s.index:e.length,u=e.charCodeAt(d),!s){l=e.slice(c);break}if(10===u&&c===d&&o)f.push(-3),o=void 0;else switch(o&&(f.push(-5),o=void 0),c<d&&(f.push(e.slice(c,d)),a+=d-c),u){case 0:f.push(65533),a++;break;case 9:for(n=4*Math.ceil(a/4),f.push(-2);a++<n;)f.push(-1);break;case 10:f.push(-4),a=1;break;default:o=!0,a=1}c=d+1}return r&&(o&&f.push(-5),l&&f.push(l),f.push(null)),f})(r,s,!0))))}}let t4="object"==typeof self?self:globalThis,t6=e=>{var i;let r,s;return(i=new Map,r=(e,r)=>(i.set(r,e),e),s=n=>{if(i.has(n))return i.get(n);let[o,a]=e[n];switch(o){case 0:case -1:return r(a,n);case 1:{let e=r([],n);for(let i of a)e.push(s(i));return e}case 2:{let e=r({},n);for(let[i,r]of a)e[s(i)]=s(r);return e}case 3:return r(new Date(a),n);case 4:{let{source:e,flags:i}=a;return r(new RegExp(e,i),n)}case 5:{let e=r(new Map,n);for(let[i,r]of a)e.set(s(i),s(r));return e}case 6:{let e=r(new Set,n);for(let i of a)e.add(s(i));return e}case 7:{let{name:e,message:i}=a;return r(new t4[e](i),n)}case 8:return r(BigInt(a),n);case"BigInt":return r(Object(BigInt(a)),n);case"ArrayBuffer":return r(new Uint8Array(a).buffer,a);case"DataView":{let{buffer:e}=new Uint8Array(a);return r(new DataView(e),a)}}return r(new t4[o](a),n)})(0)},{toString:t9}={},{keys:t8}=Object,t7=e=>{let i=typeof e;if("object"!==i||!e)return[0,i];let r=t9.call(e).slice(8,-1);switch(r){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,r]}return r.includes("Array")?[1,r]:r.includes("Error")?[7,r]:[2,r]},ie=([e,i])=>0===e&&("function"===i||"symbol"===i),it=(e,{json:i,lossy:r}={})=>{var s,n,o;let a,l,h=[];return(s=!(i||r),n=!!i,o=new Map,a=(e,i)=>{let r=h.push(e)-1;return o.set(i,r),r},l=e=>{if(o.has(e))return o.get(e);let[i,r]=t7(e);switch(i){case 0:{let n=e;switch(r){case"bigint":i=8,n=e.toString();break;case"function":case"symbol":if(s)throw TypeError("unable to serialize "+r);n=null;break;case"undefined":return a([-1],e)}return a([i,n],e)}case 1:{if(r){let i=e;return"DataView"===r?i=new Uint8Array(e.buffer):"ArrayBuffer"===r&&(i=new Uint8Array(e)),a([r,[...i]],e)}let s=[],n=a([i,s],e);for(let i of e)s.push(l(i));return n}case 2:{if(r)switch(r){case"BigInt":return a([r,e.toString()],e);case"Boolean":case"Number":case"String":return a([r,e.valueOf()],e)}if(n&&"toJSON"in e)return l(e.toJSON());let o=[],h=a([i,o],e);for(let i of t8(e))(s||!ie(t7(e[i])))&&o.push([l(i),l(e[i])]);return h}case 3:return a([i,e.toISOString()],e);case 4:{let{source:r,flags:s}=e;return a([i,{source:r,flags:s}],e)}case 5:{let r=[],n=a([i,r],e);for(let[i,n]of e)(s||!(ie(t7(i))||ie(t7(n))))&&r.push([l(i),l(n)]);return n}case 6:{let r=[],n=a([i,r],e);for(let i of e)(s||!ie(t7(i)))&&r.push(l(i));return n}}let{message:h}=e;return a([i,{name:r,message:h}],e)})(e),h},ii="function"==typeof structuredClone?(e,i)=>i&&("json"in i||"lossy"in i)?t6(it(e,i)):structuredClone(e):(e,i)=>t6(it(e,i));function ir(e){let i=[],r=-1,s=0,n=0;for(;++r<e.length;){let o=e.charCodeAt(r),a="";if(37===o&&eX(e.charCodeAt(r+1))&&eX(e.charCodeAt(r+2)))n=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let i=e.charCodeAt(r+1);o<56320&&i>56319&&i<57344?(a=String.fromCharCode(o,i),n=1):a="�"}else a=String.fromCharCode(o);a&&(i.push(e.slice(s,r),encodeURIComponent(a)),s=r+n+1,a=""),n&&(r+=n,n=0)}return i.join("")+e.slice(s)}function is(e,i){let r=[{type:"text",value:"↩"}];return i>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),r}function io(e,i){return"Back to reference "+(e+1)+(i>1?"-"+i:"")}let ia=function(e){var i,r;if(null==e)return ih;if("function"==typeof e)return il(e);if("object"==typeof e){return Array.isArray(e)?function(e){let i=[],r=-1;for(;++r<e.length;)i[r]=ia(e[r]);return il(function(...e){let r=-1;for(;++r<i.length;)if(i[r].apply(this,e))return!0;return!1})}(e):(i=e,il(function(e){let r;for(r in i)if(e[r]!==i[r])return!1;return!0}))}if("string"==typeof e){return r=e,il(function(e){return e&&e.type===r})}throw Error("Expected function, string, or object as test")};function il(e){return function(i,r,s){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(i)&&e.call(this,i,"number"==typeof r?r:void 0,s||void 0))}}function ih(){return!0}let ic=[];function id(e,i,r,s){var n,o,a;let l,h,c,d,u,f;"function"==typeof i&&"function"!=typeof r?(h=void 0,c=i,l=r):(h=i,c=r,l=s),n=h,o=function(e,i){let r=i[i.length-1],s=r?r.children.indexOf(e):void 0;return c(e,s,r)},a=l,"function"==typeof n&&"function"!=typeof o?(a=o,o=n):d=n,u=ia(d),f=a?-1:1,(function e(i,r,s){let l=i&&"object"==typeof i?i:{};if("string"==typeof l.type){let e="string"==typeof l.tagName?l.tagName:"string"==typeof l.name?l.name:void 0;Object.defineProperty(h,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return h;function h(){var l;let h,c,d,p=ic;if((!n||u(i,r,s[s.length-1]||void 0))&&!1===(p=Array.isArray(l=o(i,s))?l:"number"==typeof l?[!0,l]:null==l?ic:[l])[0])return p;if("children"in i&&i.children&&i.children&&"skip"!==p[0])for(c=(a?i.children.length:-1)+f,d=s.concat(i);c>-1&&c<i.children.length;){if(!1===(h=e(i.children[c],c,d)())[0])return h;c="number"==typeof h[1]?h[1]:c+f}return p}})(e,void 0,[])()}function iu(e,i){let r=i.referenceType,s="]";if("collapsed"===r?s+="[]":"full"===r&&(s+="["+(i.label||i.identifier)+"]"),"imageReference"===i.type)return[{type:"text",value:"!["+i.alt+s}];let n=e.all(i),o=n[0];o&&"text"===o.type?o.value="["+o.value:n.unshift({type:"text",value:"["});let a=n[n.length-1];return a&&"text"===a.type?a.value+=s:n.push({type:"text",value:s}),n}function ip(e){let i=e.spread;return null==i?e.children.length>1:i}function im(e,i,r){let s=0,n=e.length;if(i){let i=e.codePointAt(s);for(;9===i||32===i;)s++,i=e.codePointAt(s)}if(r){let i=e.codePointAt(n-1);for(;9===i||32===i;)n--,i=e.codePointAt(n-1)}return n>s?e.slice(s,n):""}let i_={blockquote:function(e,i){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(i),!0)};return e.patch(i,r),e.applyData(i,r)},break:function(e,i){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(i,r),[e.applyData(i,r),{type:"text",value:"\n"}]},code:function(e,i){let r=i.value?i.value+"\n":"",s={},n=i.lang?i.lang.split(/\s+/):[];n.length>0&&(s.className=["language-"+n[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:r}]};return i.meta&&(o.data={meta:i.meta}),e.patch(i,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(i,o)]},e.patch(i,o),o},delete:function(e,i){let r={type:"element",tagName:"del",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},emphasis:function(e,i){let r={type:"element",tagName:"em",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},footnoteReference:function(e,i){let r,s="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=String(i.identifier).toUpperCase(),o=ir(n.toLowerCase()),a=e.footnoteOrder.indexOf(n),l=e.footnoteCounts.get(n);void 0===l?(l=0,e.footnoteOrder.push(n),r=e.footnoteOrder.length):r=a+1,l+=1,e.footnoteCounts.set(n,l);let h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(i,h);let c={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(i,c),e.applyData(i,c)},heading:function(e,i){let r={type:"element",tagName:"h"+i.depth,properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},html:function(e,i){if(e.options.allowDangerousHtml){let r={type:"raw",value:i.value};return e.patch(i,r),e.applyData(i,r)}},imageReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return iu(e,i);let n={src:ir(s.url||""),alt:i.alt};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"img",properties:n,children:[]};return e.patch(i,o),e.applyData(i,o)},image:function(e,i){let r={src:ir(i.url)};null!==i.alt&&void 0!==i.alt&&(r.alt=i.alt),null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(i,s),e.applyData(i,s)},inlineCode:function(e,i){let r={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};e.patch(i,r);let s={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(i,s),e.applyData(i,s)},linkReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return iu(e,i);let n={href:ir(s.url||"")};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"a",properties:n,children:e.all(i)};return e.patch(i,o),e.applyData(i,o)},link:function(e,i){let r={href:ir(i.url)};null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"a",properties:r,children:e.all(i)};return e.patch(i,s),e.applyData(i,s)},listItem:function(e,i,r){let s=e.all(i),n=r?function(e){let i=!1;if("list"===e.type){i=e.spread||!1;let r=e.children,s=-1;for(;!i&&++s<r.length;)i=ip(r[s])}return i}(r):ip(i),o={},a=[];if("boolean"==typeof i.checked){let e,r=s[0];r&&"element"===r.type&&"p"===r.tagName?e=r:(e={type:"element",tagName:"p",properties:{},children:[]},s.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<s.length;){let e=s[l];(n||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||n?a.push(e):a.push(...e.children)}let h=s[s.length-1];h&&(n||"element"!==h.type||"p"!==h.tagName)&&a.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:o,children:a};return e.patch(i,c),e.applyData(i,c)},list:function(e,i){let r={},s=e.all(i),n=-1;for("number"==typeof i.start&&1!==i.start&&(r.start=i.start);++n<s.length;){let e=s[n];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}let o={type:"element",tagName:i.ordered?"ol":"ul",properties:r,children:e.wrap(s,!0)};return e.patch(i,o),e.applyData(i,o)},paragraph:function(e,i){let r={type:"element",tagName:"p",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},root:function(e,i){let r={type:"root",children:e.wrap(e.all(i))};return e.patch(i,r),e.applyData(i,r)},strong:function(e,i){let r={type:"element",tagName:"strong",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},table:function(e,i){let r=e.all(i),s=r.shift(),n=[];if(s){let r={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(i.children[0],r),n.push(r)}if(r.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},o=eS(i.children[1]),a=ey(i.children[i.children.length-1]);o&&a&&(s.position={start:o,end:a}),n.push(s)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(n,!0)};return e.patch(i,o),e.applyData(i,o)},tableCell:function(e,i){let r={type:"element",tagName:"td",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},tableRow:function(e,i,r){let s=r?r.children:void 0,n=0===(s?s.indexOf(i):1)?"th":"td",o=r&&"table"===r.type?r.align:void 0,a=o?o.length:i.children.length,l=-1,h=[];for(;++l<a;){let r=i.children[l],s={},a=o?o[l]:void 0;a&&(s.align=a);let c={type:"element",tagName:n,properties:s,children:[]};r&&(c.children=e.all(r),e.patch(r,c),c=e.applyData(r,c)),h.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(i,c),e.applyData(i,c)},text:function(e,i){let r={type:"text",value:function(e){let i=String(e),r=/\r?\n|\r/g,s=r.exec(i),n=0,o=[];for(;s;)o.push(im(i.slice(n,s.index),n>0,!0),s[0]),n=s.index+s[0].length,s=r.exec(i);return o.push(im(i.slice(n),n>0,!1)),o.join("")}(String(i.value))};return e.patch(i,r),e.applyData(i,r)},thematicBreak:function(e,i){let r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(i,r),e.applyData(i,r)},toml:ig,yaml:ig,definition:ig,footnoteDefinition:ig};function ig(){}let iv={}.hasOwnProperty,ix={};function ib(e,i){e.position&&(i.position=function(e){let i=eS(e),r=ey(e);if(i&&r)return{start:i,end:r}}(e))}function iy(e,i){let r=i;if(e&&e.data){let i=e.data.hName,s=e.data.hChildren,n=e.data.hProperties;"string"==typeof i&&("element"===r.type?r.tagName=i:r={type:"element",tagName:i,properties:{},children:"children"in r?r.children:[r]}),"element"===r.type&&n&&Object.assign(r.properties,ii(n)),"children"in r&&r.children&&null!=s&&(r.children=s)}return r}function iS(e,i){let r=[],s=-1;for(i&&r.push({type:"text",value:"\n"});++s<e.length;)s&&r.push({type:"text",value:"\n"}),r.push(e[s]);return i&&e.length>0&&r.push({type:"text",value:"\n"}),r}function iw(e){let i=0,r=e.charCodeAt(i);for(;9===r||32===r;)i++,r=e.charCodeAt(i);return e.slice(i)}function iC(e,i){let r,s,n,o,a=(r=i||ix,s=new Map,n=new Map,o={all:function(e){let i=[];if("children"in e){let r=e.children,s=-1;for(;++s<r.length;){let n=o.one(r[s],e);if(n){if(s&&"break"===r[s-1].type&&(Array.isArray(n)||"text"!==n.type||(n.value=iw(n.value)),!Array.isArray(n)&&"element"===n.type)){let e=n.children[0];e&&"text"===e.type&&(e.value=iw(e.value))}Array.isArray(n)?i.push(...n):i.push(n)}}}return i},applyData:iy,definitionById:s,footnoteById:n,footnoteCounts:new Map,footnoteOrder:[],handlers:{...i_,...r.handlers},one:function(e,i){let r=e.type,s=o.handlers[r];if(iv.call(o.handlers,r)&&s)return s(o,e,i);if(o.options.passThrough&&o.options.passThrough.includes(r)){if("children"in e){let{children:i,...r}=e,s=ii(r);return s.children=o.all(e),s}return ii(e)}return(o.options.unknownHandler||function(e,i){let r=i.data||{},s="value"in i&&!(iv.call(r,"hProperties")||iv.call(r,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:e.all(i)};return e.patch(i,s),e.applyData(i,s)})(o,e,i)},options:r,patch:ib,wrap:iS},id(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let i="definition"===e.type?s:n,r=String(e.identifier).toUpperCase();i.has(r)||i.set(r,e)}}),o),l=a.one(e,void 0),h=function(e){let i="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||is,s=e.options.footnoteBackLabel||io,n=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],h=-1;for(;++h<e.footnoteOrder.length;){let n=e.footnoteById.get(e.footnoteOrder[h]);if(!n)continue;let o=e.all(n),a=String(n.identifier).toUpperCase(),c=ir(a.toLowerCase()),d=0,u=[],f=e.footnoteCounts.get(a);for(;void 0!==f&&++d<=f;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof r?r:r(h,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof s?s:s(h,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...u)}else o.push(...u);let m={type:"element",tagName:"li",properties:{id:i+"fn-"+c},children:e.wrap(o,!0)};e.patch(n,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...ii(a),id:"footnote-label"},children:[{type:"text",value:n}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(a),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return h&&(P("children"in c),c.children.push({type:"text",value:"\n"},h)),c}function ik(e,i){return e&&"run"in e?async function(r,s){let n=iC(r,{file:s,...i});await e.run(n,s)}:function(r,s){return iC(r,{file:s,...e||i})}}function iE(e){if(e)throw e}var iN=e.i(4100);function iR(e){if("object"!=typeof e||null===e)return!1;let i=Object.getPrototypeOf(e);return(null===i||i===Object.prototype||null===Object.getPrototypeOf(i))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let ij=function(e,i){let r;if(void 0!==i&&"string"!=typeof i)throw TypeError('"ext" argument must be a string');iP(e);let s=0,n=-1,o=e.length;if(void 0===i||0===i.length||i.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else n<0&&(r=!0,n=o+1);return n<0?"":e.slice(s,n)}if(i===e)return"";let a=-1,l=i.length-1;for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else a<0&&(r=!0,a=o+1),l>-1&&(e.codePointAt(o)===i.codePointAt(l--)?l<0&&(n=o):(l=-1,n=a));return s===n?n=a:n<0&&(n=e.length),e.slice(s,n)},iT=function(e){let i;if(iP(e),0===e.length)return".";let r=-1,s=e.length;for(;--s;)if(47===e.codePointAt(s)){if(i){r=s;break}}else i||(i=!0);return r<0?47===e.codePointAt(0)?"/":".":1===r&&47===e.codePointAt(0)?"//":e.slice(0,r)},iD=function(e){let i;iP(e);let r=e.length,s=-1,n=0,o=-1,a=0;for(;r--;){let l=e.codePointAt(r);if(47===l){if(i){n=r+1;break}continue}s<0&&(i=!0,s=r+1),46===l?o<0?o=r:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||s<0||0===a||1===a&&o===s-1&&o===n+1?"":e.slice(o,s)},iM=function(...e){var i;let r,s,n,o=-1;for(;++o<e.length;)iP(e[o]),e[o]&&(n=void 0===n?e[o]:n+"/"+e[o]);return void 0===n?".":(iP(i=n),r=47===i.codePointAt(0),0!==(s=function(e,i){let r,s,n="",o=0,a=-1,l=0,h=-1;for(;++h<=e.length;){if(h<e.length)r=e.codePointAt(h);else if(47===r)break;else r=47;if(47===r){if(a===h-1||1===l);else if(a!==h-1&&2===l){if(n.length<2||2!==o||46!==n.codePointAt(n.length-1)||46!==n.codePointAt(n.length-2)){if(n.length>2){if((s=n.lastIndexOf("/"))!==n.length-1){s<0?(n="",o=0):o=(n=n.slice(0,s)).length-1-n.lastIndexOf("/"),a=h,l=0;continue}}else if(n.length>0){n="",o=0,a=h,l=0;continue}}i&&(n=n.length>0?n+"/..":"..",o=2)}else n.length>0?n+="/"+e.slice(a+1,h):n=e.slice(a+1,h),o=h-a-1;a=h,l=0}else 46===r&&l>-1?l++:l=-1}return n}(i,!r)).length||r||(s="."),s.length>0&&47===i.codePointAt(i.length-1)&&(s+="/"),r?"/"+s:s)};function iP(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function iL(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let iA=["history","path","basename","stem","extname","dirname"];class iB{constructor(e){let i,r;i=e?iL(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in i?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<iA.length;){const e=iA[s];e in i&&void 0!==i[e]&&null!==i[e]&&(this[e]="history"===e?[...i[e]]:i[e])}for(r in i)iA.includes(r)||(this[r]=i[r])}get basename(){return"string"==typeof this.path?ij(this.path):void 0}set basename(e){iO(e,"basename"),iI(e,"basename"),this.path=iM(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?iT(this.path):void 0}set dirname(e){iF(this.basename,"dirname"),this.path=iM(e||"",this.basename)}get extname(){return"string"==typeof this.path?iD(this.path):void 0}set extname(e){if(iI(e,"extname"),iF(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=iM(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){iL(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!iL(e)){let i=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let i=e.pathname,r=-1;for(;++r<i.length;)if(37===i.codePointAt(r)&&50===i.codePointAt(r+1)){let e=i.codePointAt(r+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(i)}(e)}(e)),iO(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?ij(this.path,this.extname):void 0}set stem(e){iO(e,"stem"),iI(e,"stem"),this.path=iM(this.dirname||"",e+(this.extname||""))}fail(e,i,r){let s=this.message(e,i,r);throw s.fatal=!0,s}info(e,i,r){let s=this.message(e,i,r);return s.fatal=void 0,s}message(e,i,r){let s=new eR(e,i,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function iI(e,i){if(e&&e.includes("/"))throw Error("`"+i+"` cannot be a path: did not expect `/`")}function iO(e,i){if(!e)throw Error("`"+i+"` cannot be empty")}function iF(e,i){if(!e)throw Error("Setting `"+i+"` requires `path` to be set too")}let iz=function(e){let i=this.constructor.prototype,r=i[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,i),s},iH={}.hasOwnProperty;class i$ extends iz{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],i={run:function(...i){let r=-1,s=i.pop();if("function"!=typeof s)throw TypeError("Expected function as last argument, not "+s);!function n(o,...a){let l=e[++r],h=-1;if(o)return void s(o);for(;++h<i.length;)(null===a[h]||void 0===a[h])&&(a[h]=i[h]);i=a,l?(function(e,i){let r;return function(...i){let o,a=e.length>i.length;a&&i.push(s);try{o=e.apply(this,i)}catch(e){if(a&&r)throw e;return s(e)}a||(o&&o.then&&"function"==typeof o.then?o.then(n,s):o instanceof Error?s(o):n(o))};function s(e,...n){r||(r=!0,i(e,...n))}function n(e){s(null,e)}})(l,n)(...a):s(null,...a)}(null,...i)},use:function(r){if("function"!=typeof r)throw TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),i}};return i}()}copy(){let e=new i$,i=-1;for(;++i<this.attachers.length;){let r=this.attachers[i];e.use(...r)}return e.data((0,iN.default)(!0,{},this.namespace)),e}data(e,i){return"string"==typeof e?2==arguments.length?(iq("data",this.frozen),this.namespace[e]=i,this):iH.call(this.namespace,e)&&this.namespace[e]||void 0:e?(iq("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...i]=this.attachers[this.freezeIndex];if(!1===i[0])continue;!0===i[0]&&(i[0]=void 0);let r=e.call(this,...i);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let i=iG(e),r=this.parser||this.Parser;return iU("parse",r),r(String(i),i)}process(e,i){let r=this;return this.freeze(),iU("process",this.parser||this.Parser),iK("process",this.compiler||this.Compiler),i?s(void 0,i):new Promise(s);function s(s,n){let o=iG(e),a=r.parse(o);function l(e,r){e||!r?n(e):s?s(r):(P(i,"`done` is defined if `resolve` is not"),i(void 0,r))}r.run(a,o,function(e,i,s){var n,o;if(e||!i||!s)return l(e);let a=r.stringify(i,s);"string"==typeof(n=a)||(o=n)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?s.value=a:s.result=a,l(e,s)})}}processSync(e){let i,r=!1;return this.freeze(),iU("processSync",this.parser||this.Parser),iK("processSync",this.compiler||this.Compiler),this.process(e,function(e,s){r=!0,iE(e),i=s}),iY("processSync","process",r),P(i,"we either bailed on an error or have a tree"),i}run(e,i,r){iV(e),this.freeze();let s=this.transformers;return r||"function"!=typeof i||(r=i,i=void 0),r?n(void 0,r):new Promise(n);function n(n,o){P("function"!=typeof i,"`file` can’t be a `done` anymore, we checked");let a=iG(i);s.run(e,a,function(i,s,a){let l=s||e;i?o(i):n?n(l):(P(r,"`done` is defined if `resolve` is not"),r(void 0,l,a))})}}runSync(e,i){let r,s=!1;return this.run(e,i,function(e,i){iE(e),r=i,s=!0}),iY("runSync","run",s),P(r,"we either bailed on an error or have a tree"),r}stringify(e,i){this.freeze();let r=iG(i),s=this.compiler||this.Compiler;return iK("stringify",s),iV(e),s(e,r)}use(e,...i){let r=this.attachers,s=this.namespace;if(iq("use",this.frozen),null==e);else if("function"==typeof e)a(e,i);else if("object"==typeof e)Array.isArray(e)?o(e):n(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function n(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(s.settings=(0,iN.default)(!0,s.settings,e.settings))}function o(e){let i=-1;if(null==e);else if(Array.isArray(e))for(;++i<e.length;)!function(e){if("function"==typeof e)a(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[i,...r]=e;a(i,r)}else n(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[i]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function a(e,i){let s=-1,n=-1;for(;++s<r.length;)if(r[s][0]===e){n=s;break}if(-1===n)r.push([e,...i]);else if(i.length>0){let[s,...o]=i,a=r[n][1];iR(a)&&iR(s)&&(s=(0,iN.default)(!0,a,s)),r[n]=[e,s,...o]}}}}let iW=new i$().freeze();function iU(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `parser`")}function iK(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `compiler`")}function iq(e,i){if(i)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function iV(e){if(!iR(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function iY(e,i,r){if(!r)throw Error("`"+e+"` finished async. Use `"+i+"` instead")}function iG(e){var i;return(i=e)&&"object"==typeof i&&"message"in i&&"messages"in i?e:new iB(e)}let iX=[],iJ={allowDangerousHtml:!0},iQ=/^(https?|ircs?|mailto|xmpp)$/i,iZ=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function i0(e){var i;let r,s,n,o,a,l=(r=(i=e).rehypePlugins||iX,s=i.remarkPlugins||iX,n=i.remarkRehypeOptions?{...i.remarkRehypeOptions,...iJ}:iJ,iW().use(t3).use(s).use(ik,n).use(r)),h=(o=e.children||"",a=new iB,"string"==typeof o?a.value=o:L("Unexpected value `"+o+"` for `children` prop, expected `string`"),a);return function(e,i){let r=i.allowedElements,s=i.allowElement,n=i.components,o=i.disallowedElements,a=i.skipHtml,l=i.unwrapDisallowed,h=i.urlTransform||i1;for(let e of iZ)Object.hasOwn(i,e.from)&&L("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return r&&o&&L("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),id(e,function(e,i,n){if("raw"===e.type&&n&&"number"==typeof i)return a?n.children.splice(i,1):n.children[i]={type:"text",value:e.value},i;if("element"===e.type){let i;for(i in e$)if(Object.hasOwn(e$,i)&&Object.hasOwn(e.properties,i)){let r=e.properties[i],s=e$[i];(null===s||s.includes(e.tagName))&&(e.properties[i]=h(String(r||""),i,e))}}if("element"===e.type){let a=r?!r.includes(e.tagName):!!o&&o.includes(e.tagName);if(!a&&s&&"number"==typeof i&&(a=!s(e,i,n)),a&&n&&"number"==typeof i)return l&&e.children?n.children.splice(i,1,...e.children):n.children.splice(i,1),i}}),function(e,i){var r,s,n,o;let a;if(!i||void 0===i.Fragment)throw TypeError("Expected `Fragment` in options");let l=i.filePath||void 0;if(i.development){if("function"!=typeof i.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=l,s=i.jsxDEV,a=function(e,i,n,o){let a=Array.isArray(n.children),l=eS(e);return s(i,n,o,a,{columnNumber:l?l.column-1:void 0,fileName:r,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof i.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof i.jsxs)throw TypeError("Expected `jsxs` in production options");n=i.jsx,o=i.jsxs,a=function(e,i,r,s){let a=Array.isArray(r.children)?o:n;return s?a(i,r,s):a(i,r)}}let h={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:a,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:!1!==i.passKeys,passNode:i.passNode||!1,schema:"svg"===i.space?ex:ev,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==i.tableCellAlignToStyle},c=eA(h,e,void 0);return c&&"string"!=typeof c?c:h.create(e,h.Fragment,{children:c||void 0},void 0)}(e,{Fragment:p.Fragment,components:n,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0})}(l.runSync(l.parse(h),h),e)}function i1(e){let i=e.indexOf(":"),r=e.indexOf("?"),s=e.indexOf("#"),n=e.indexOf("/");return -1===i||-1!==n&&i>n||-1!==r&&i>r||-1!==s&&i>s||iQ.test(e.slice(0,i))?e:""}function i2({projectId:e,startInEditMode:i=!1}){let[r,s]=(0,m.useState)(""),[n,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(i),[h,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(!1),[f,_]=(0,m.useState)(null),g=(0,m.useRef)(!1);g.current=a;let v=(0,m.useRef)(i),x=(0,m.useCallback)(async()=>{try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();o(!!r.exists),g.current||s(r.content||""),v.current&&(c(r.content||""),v.current=!1),_(null)}catch(e){_(e.message)}},[e]);(0,m.useEffect)(()=>{x();let e=setInterval(x,1e4);return()=>clearInterval(e)},[x]);let b=async()=>{u(!0),_(null);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})});if(!i.ok)throw Error(`${i.status}`);s(h),l(!1)}catch(e){_(e.message)}finally{u(!1)}},y=async()=>{u(!0);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"});if(!i.ok)throw Error(`${i.status}`);await x()}catch(e){_(e.message)}finally{u(!1)}};return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0 border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",f]}),!a&&n&&(0,p.jsx)("button",{onClick:()=>{c(r),l(!0)},className:"text-[10px] text-text-muted hover:text-accent uppercase tracking-wider",children:"Edit"}),a&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("button",{onClick:b,disabled:d,className:"text-[10px] text-accent hover:text-accent-dim uppercase tracking-wider disabled:opacity-50",children:d?"Saving…":"Save"}),(0,p.jsx)("button",{onClick:()=>{l(!1),c(""),x()},disabled:d,className:"text-[10px] text-text-muted hover:text-text uppercase tracking-wider disabled:opacity-50",children:"Cancel"})]})]})]}),a&&(0,p.jsx)("div",{className:"shrink-0 px-3 py-1.5 border-b border-border bg-bg-surface text-[10px] text-text-muted leading-snug",children:"⚠️ Editing manually may conflict with the Head agent. Use the chat panel to ask Head to update the queue when possible."}),(0,p.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:!1===n?(0,p.jsxs)("div",{className:"p-3 text-[11px] text-text-muted",children:[(0,p.jsx)("p",{className:"mb-2",children:"No OVERNIGHT-QUEUE.md for this project yet."}),(0,p.jsx)("button",{onClick:y,disabled:d,className:"px-2 py-1 border border-border hover:border-accent hover:text-accent text-[11px] disabled:opacity-50",children:"Create OVERNIGHT-QUEUE.md from template"})]}):a?(0,p.jsx)("textarea",{value:h,onChange:e=>c(e.target.value),spellCheck:!1,className:"w-full h-full p-3 bg-bg text-text text-[11px] font-mono resize-none outline-none"}):(0,p.jsx)("div",{className:"p-3 text-[12px] text-text prose prose-invert prose-sm max-w-none [&_h1]:text-[14px] [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-2 [&_h2]:text-[13px] [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1.5 [&_h3]:text-[12px] [&_h3]:font-semibold [&_h3]:mt-2 [&_h3]:mb-1 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ul]:pl-4 [&_ul]:list-disc [&_ol]:my-1.5 [&_ol]:pl-4 [&_ol]:list-decimal [&_li]:my-0.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-2 [&_blockquote]:text-text-muted [&_hr]:my-3 [&_hr]:border-border [&_code]:bg-bg-surface [&_code]:px-1 [&_code]:rounded [&_code]:text-[11px] [&_strong]:text-text [&_a]:text-accent [&_a]:underline",children:(0,p.jsx)(i0,{children:r})})})]})}function i5({open:e,projectId:i,onClose:r}){return((0,m.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),e)?(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"queue-modal-title",children:(0,p.jsxs)("div",{className:"relative mx-4 w-full max-w-3xl h-[80vh] flex flex-col rounded-lg border border-white/10 bg-neutral-950 shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,p.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/10",children:[(0,p.jsx)("h2",{id:"queue-modal-title",className:"text-[12px] font-semibold text-white",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})})]}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(i2,{projectId:i,startInEditMode:!0})})]})}):null}let i3={en:{loading:"Loading batch progress…",currentBatchNone:"Current Batch: (none)",noActiveBatch:"No active batch. Ask Head to start one via the chat.",currentBatch:e=>`Current Batch: Batch ${e}`,complete:"✅ COMPLETE",allMerged:e=>`All ${e} items merged. Waiting for the next batch.`,itemsCount:e=>`(${e} items)`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Current Batch"}),"— progress tracker for the active batch. Polls GitHub to resolve each issue's status (queued → in review → approved → merged)."]})},ko:{loading:"배치 진행 상황 로딩 중...",currentBatchNone:"현재 배치: (없음)",noActiveBatch:"활성 배치가 없습니다. 채팅에서 Head에게 시작을 요청하세요.",currentBatch:e=>`현재 배치: ${e}번`,complete:"✅ 완료",allMerged:e=>`${e}개 항목 모두 병합됨. 다음 배치를 기다리는 중.`,itemsCount:e=>`(${e}개 항목)`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"현재 배치"})," - 활성 배치 진행 상황 추적기입니다. GitHub를 조회해 각 이슈 상태를 대기 → 검토 중 → 승인 → 병합 순으로 추적합니다."]})}};function i4({percent:e}){let i=Math.round(e/100*20);return(0,p.jsxs)("span",{className:"font-mono text-[11px] tabular-nums whitespace-nowrap",children:[(0,p.jsx)("span",{className:"text-accent",children:"█".repeat(i)}),(0,p.jsx)("span",{className:"text-text-muted",children:"░".repeat(20-i)})]})}function i6({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=i3[i],[s,n]=(0,m.useState)(null),o=(0,m.useCallback)(()=>{fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&n(e)}).catch(()=>{})},[e]);return((0,m.useEffect)(()=>{o();let e=setInterval(o,3e4);return()=>clearInterval(e)},[o]),s)?s.items&&0!==s.items.length?s.complete?(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.currentBatch(s.batch_number??"—")}),(0,p.jsx)("span",{className:"text-[10px] text-accent",children:r.complete})]}),(0,p.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:r.allMerged(s.items.length)})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-border/40",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.currentBatch(s.batch_number??"—")}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted",children:r.itemsCount(s.items.length)}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsx)("div",{className:"max-h-40 overflow-y-auto",children:s.items.map(e=>{let i=(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 font-mono",children:[(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0 tabular-nums",children:["#",e.issue_number]}),(0,p.jsx)(i4,{percent:e.progress}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted tabular-nums shrink-0 w-9 text-right",children:[e.progress,"%"]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.label})]});return e.url?(0,p.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block hover:bg-[#1a1a1a] transition-colors border-b border-border/30",children:i},e.issue_number):(0,p.jsx)("div",{children:i},e.issue_number)})}),s.summary&&(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border/40",children:s.summary})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsx)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.currentBatchNone})}),(0,p.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:r.noActiveBatch})]}):(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border",children:r.loading})}let i9={en:{rateLimitCritical:e=>`GitHub Rate Limit CRITICAL: 0 remaining. Resets in ${e}m.`,rateLimitLow:(e,i,r)=>`GitHub Rate Limit LOW: ${e}/${i} remaining. Resets in ${r}m.`,issues:e=>`Issues (${e})`,issuesHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Issues"})," — open issues in this repository. Agents will pick these up automatically if they are part of the overnight queue."]}),noIssues:"No open issues.",recentlyClosed:"Recently closed",noneYet:"None yet.",prs:e=>`Pull Requests (${e})`,prsHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Pull Requests"})," — active PRs in this repository. Shows review status from RE1/RE2 and CI status."]}),noPrs:"No active PRs.",recentlyMerged:"Recently merged / closed",overnightQueueHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"OVERNIGHT-QUEUE.md"})," — a list of issue numbers (one per line) for agents to process autonomously. Edit this file to add or remove tasks from the queue."]}),edit:"Edit"},ko:{rateLimitCritical:e=>`GitHub API 제한 위험: 잔여 0개. ${e}분 후 초기화됩니다.`,rateLimitLow:(e,i,r)=>`GitHub API 제한 낮음: ${e}/${i} 남음. ${r}분 후 초기화됩니다.`,issues:e=>`이슈 (${e})`,issuesHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"이슈"})," - 이 저장소의 열려 있는 이슈들입니다. 야간 큐에 포함되면 에이전트가 자동으로 작업을 시작합니다."]}),noIssues:"열린 이슈가 없습니다.",recentlyClosed:"최근 닫힌 이슈",noneYet:"아직 없습니다.",prs:e=>`풀 리퀘스트 (${e})`,prsHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"풀 리퀘스트"})," - 이 저장소의 활성화된 PR들입니다. RE1/RE2의 리뷰 상태와 CI 상태를 보여줍니다."]}),noPrs:"활성 PR이 없습니다.",recentlyMerged:"최근 머지/닫힘",overnightQueueHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"OVERNIGHT-QUEUE.md"})," - 에이전트가 자율적으로 처리할 이슈 번호 목록(한 줄에 하나씩)입니다. 이 파일을 편집하여 큐에 작업을 추가하거나 제거할 수 있습니다."]}),edit:"편집"}};function i8({color:e}){return(0,p.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${e}`})}function i7({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=i9[i],[s,n]=(0,m.useState)([]),[o,a]=(0,m.useState)([]),[l,h]=(0,m.useState)([]),[c,d]=(0,m.useState)([]),[u,f]=(0,m.useState)(!1),[_,v]=(0,m.useState)(null);(0,m.useEffect)(()=>{let i=!1;return fetch(`/api/queue?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(r=>{if(!i&&r&&!r.exists)return fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"})}).catch(()=>{}),()=>{i=!0}},[e]);let b=(0,m.useCallback)(()=>{fetch(`/api/github/issues?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&n(e)}).catch(()=>{}),fetch(`/api/github/prs?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&a(e)}).catch(()=>{}),fetch(`/api/github/closed-issues?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&h(e)}).catch(()=>{}),fetch(`/api/github/merged-prs?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&d(e)}).catch(()=>{})},[e]);return(0,m.useEffect)(()=>{let e=()=>{fetch("/api/github/rate-limit").then(e=>e.ok?e.json():null).then(e=>{e&&v(e)}).catch(()=>{})};e();let i=setInterval(e,6e4);return()=>clearInterval(i)},[]),(0,m.useEffect)(()=>{b();let e=setInterval(b,3e4);return()=>clearInterval(e)},[b]),(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[_&&(_.critical||_.low)&&(0,p.jsx)("div",{className:`px-3 py-1 text-[10px] shrink-0 ${_.critical?"bg-error/20 text-error":"bg-[#ffcc00]/20 text-[#ffcc00]"}`,children:_.critical?r.rateLimitCritical(_.resetInMinutes):r.rateLimitLow(_.remaining,_.limit,_.resetInMinutes)}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row",children:[(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col border-b lg:border-b-0 lg:border-r border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.issues(s.length)}),(0,p.jsx)(g,{children:r.issuesHelp})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===s.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:r.noIssues}),s.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i8,{color:"OPEN"===e.state?"bg-accent":"bg-error"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login})]},e.number)),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:r.recentlyClosed}),0===l.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:r.noneYet}),l.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`closed-${e.number}`))]})]}),(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.prs(o.length)}),(0,p.jsx)(g,{children:r.prsHelp})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===o.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:r.noPrs}),o.map(e=>{let i=e.reviews||[],r=e.reviewDecision||"REVIEW_REQUIRED",s={};for(let e of i){let i=(e.body||"").trim();/^(?:RE2|Reviewer2|T2b)\b/i.test(i)?s.re2=e.state:(/^(?:RE1|Reviewer1|T2a)\b/i.test(i)||/^##\s*Verdict/i.test(i))&&(s.re1=e.state)}return(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i8,{color:"APPROVED"===r?"bg-accent":"CHANGES_REQUESTED"===r?"bg-error":"bg-[#ffcc00]"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login}),["re1","re2"].map(e=>{let i=s[e];return(0,p.jsxs)("span",{className:`text-[10px] shrink-0 ${i?"APPROVED"===i?"text-accent":"CHANGES_REQUESTED"===i?"text-error":"text-[#ffcc00]":"text-text-muted"}`,children:[e,":",i?"APPROVED"===i?"ok":"CHANGES_REQUESTED"===i?"chg":"rev":"—"]},e)}),(0,p.jsx)("span",{className:`text-[10px] shrink-0 ${function(e){if(!e||0===e.length)return"text-text-muted";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"text-accent":i.some(e=>"FAILURE"===e||"ERROR"===e)?"text-error":"text-[#ffcc00]"}(e.statusCheckRollup)}`,children:function(e){if(!e||0===e.length)return"—";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"pass":i.some(e=>"FAILURE"===e||"ERROR"===e)?"fail":"run"}(e.statusCheckRollup)})]},e.number)}),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:r.recentlyMerged}),0===c.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:r.noneYet}),c.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`merged-${e.number}`))]})]})]}),(0,p.jsx)("div",{className:"shrink-0",children:(0,p.jsx)(i6,{projectId:e})}),(0,p.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5 border-t border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsx)(g,{position:"above",children:r.overnightQueueHelp})]}),(0,p.jsx)("button",{onClick:()=>f(!0),className:"px-2 py-0.5 text-[10px] text-text-muted hover:text-accent border border-border hover:border-accent transition-colors uppercase tracking-wider",children:r.edit})]}),(0,p.jsx)(i5,{open:u,projectId:e,onClose:()=>f(!1)})]})}var re=e.i(67449);let rt={en:{server:{title:"Server",stop:"Stop",confirmStop:"Confirm Stop?",restart:"Restart",resetAgents:"Reset Agents",healthGaveUp:"AC auto-restart failed 3x — manual restart required",healthRestarted:e=>`AC auto-restarted at ${e}`,stopped:"Stopped",failed:"Failed",error:"Error",acRestarted:e=>`AC restarted (PID: ${e}) — resetting agents...`,acAndAgentsRestarted:e=>`AC + ${e} agent${1!==e?"s":""} restarted`,agentResetFailed:"AC restarted — agent reset failed",resetResult:(e,i)=>`Reset — ${e} of ${i} agent${1!==i?"s":""} restarted`},system:{keepAwake:"Keep Mac Awake",keepAwakeAbout:"About Keep Mac Awake",keepAwakeHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Keep Mac Awake"})," runs macOS ",(0,p.jsx)("code",{children:"caffeinate"})," to stop the screen, disk, and system idle timers from sleeping your Mac during an overnight run. Make sure the laptop is plugged in — caffeinate blocks sleep but not battery drain."]}),autoAwakeOn:"Auto-awake ON: caffeinate starts/stops with batch lifecycle",autoAwakeOff:"Auto-awake OFF: manual Start/Stop only",awakeFor:e=>`Awake for ${e} more — keep Mac plugged in`,awakeIndefinitely:"Awake indefinitely — keep Mac plugged in",awakeDesc:"Prevents your Mac from sleeping during overnight runs.",awake:"Awake",start:"Start",on:"on",sound:"Notification Sound",soundAbout:"About Notification Sound",soundHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Notification Sound"})," plays a brief chime when an agent posts a new message (not your own sends, not system events). Sound choice picks one of the bundled chimes. Background-only mode suppresses the chime while the tab is focused — ding only when you're looking elsewhere. All prefs persist in localStorage."]}),soundDesc:"Plays a chime when an agent posts a new message.",soundLabel:"Sound",soundBgOnly:"Only when tab is in background",awakeStatusActive:"Batch active — auto-started caffeinate.",awakeStatusComplete:"Batch complete — awake paused.",awakeStatusNew:"New batch detected — auto-started caffeinate.",keepAwakeModalTitle:"Keep Awake",keepAwakeModalAbout:"About Keep Awake",keepAwakeModalHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Keep Awake"})," prevents your Mac from sleeping for the duration you set. Use this when you want agents to keep working overnight.",(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),"Under the hood, this runs macOS's ",(0,p.jsx)("code",{children:"caffeinate"})," command. While it's active your screen, disk, and system idle timers are all paused — make sure your Mac is ",(0,p.jsx)("b",{children:"plugged in"})," to avoid draining the battery."]}),makeSurePluggedIn:"Make sure Mac is plugged in",for:"for",hours:"hours",untilStopped:"Until stopped (no expiry)"}},ko:{server:{title:"서버",stop:"중지",confirmStop:"정말 중지?",restart:"재시작",resetAgents:"에이전트 초기화",healthGaveUp:"AC 자동 재시작 3회 실패 — 수동 재시작이 필요합니다",healthRestarted:e=>`AC가 ${e}에 자동 재시작되었습니다`,stopped:"중지됨",failed:"실패",error:"오류",acRestarted:e=>`AC 재시작됨 (PID: ${e}) — 에이전트 초기화 중...`,acAndAgentsRestarted:e=>`AC 및 ${e}개 에이전트 재시작됨`,agentResetFailed:"AC 재시작됨 — 에이전트 초기화 실패",resetResult:(e,i)=>`초기화 완료 — ${i}개 중 ${e}개 에이전트 재시작됨`},system:{keepAwake:"Mac 절전 방지",keepAwakeAbout:"Mac 절전 방지 정보",keepAwakeHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Mac 절전 방지"}),"는 macOS의 ",(0,p.jsx)("code",{children:"caffeinate"}),"를 실행해 야간 작업 중 Mac이 절전 상태로 들어가는 것을 막습니다. 충전기를 연결해 두세요. caffeinate는 절전은 막지만 배터리 소모를 막아주지는 않습니다."]}),autoAwakeOn:"자동 절전 방지 켬: 배치 상태에 따라 caffeinate 시작/종료",autoAwakeOff:"자동 절전 방지 끔: 수동 시작/종료만 가능",awakeFor:e=>`앞으로 ${e} 동안 절전 방지 — 전원을 연결해 두세요`,awakeIndefinitely:"무기한 절전 방지 중 — 전원을 연결해 두세요",awakeDesc:"야간 작업 중 Mac이 잠들지 않도록 합니다.",awake:"절전 방지 중",start:"시작",on:"켬",sound:"알림음",soundAbout:"알림음 정보",soundHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"알림음"}),"은 에이전트가 새 메시지를 보낼 때 짧은 알림음을 재생합니다. 내 메시지나 시스템 이벤트에는 울리지 않습니다. 사운드 선택으로 내장 알림음 중 하나를 고를 수 있고, 백그라운드 전용 모드는 탭이 포커스된 동안에는 알림음을 막습니다. 모든 설정은 localStorage에 저장됩니다."]}),soundDesc:"에이전트가 새 메시지를 보낼 때 알림음을 재생합니다.",soundLabel:"알림음",soundBgOnly:"탭이 백그라운드에 있을 때만",awakeStatusActive:"배치 실행 중 — caffeinate를 자동으로 시작했습니다.",awakeStatusComplete:"배치 완료 — 절전 방지를 일시 중단했습니다.",awakeStatusNew:"새 배치 감지 — caffeinate를 자동으로 시작했습니다.",keepAwakeModalTitle:"절전 방지",keepAwakeModalAbout:"절전 방지 정보",keepAwakeModalHelp:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"절전 방지"}),"는 설정한 시간 동안 Mac이 절전 상태로 들어가는 것을 막습니다. 에이전트가 밤새 작업하게 하려면 이 기능을 사용하세요.",(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),"내부적으로는 macOS의 ",(0,p.jsx)("code",{children:"caffeinate"})," 명령을 실행합니다. 실행 중에는 화면, 디스크, 시스템 유휴 타이머가 모두 정지됩니다. 배터리 소모를 막으려면 Mac에 ",(0,p.jsx)("b",{children:"전원을 연결"}),"해 두세요."]}),makeSurePluggedIn:"전원을 연결해 두세요",for:"시간:",hours:"시간",untilStopped:"중지할 때까지 (만료 없음)"}}};function ri({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=rt[i].server,[s,n]=(0,m.useState)(null),[o,a]=(0,m.useState)(null),[l,h]=(0,m.useState)(!1),[c,d]=(0,m.useState)(null);(0,m.useEffect)(()=>{let i=()=>{fetch(`/api/agentchattr/${encodeURIComponent(e)}/health`).then(e=>e.ok?e.json():null).then(e=>{if(!e)return void d(null);if(e.autoRestart?.gaveUp)d(r.healthGaveUp);else if(e.autoRestart?.lastRestart)if(300>Math.round((Date.now()-e.autoRestart.lastRestart)/1e3)){let i=new Date(e.autoRestart.lastRestart).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});d(r.healthRestarted(i))}else d(null);else d(null)}).catch(()=>d(null))};i();let s=setInterval(i,3e4);return()=>clearInterval(s)},[e,r]);let u=()=>{setTimeout(()=>a(null),3e3)};(0,m.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>h(!1),4e3);return()=>clearTimeout(e)},[l]);let f=async()=>{if(!l)return void h(!0);h(!1),n("stop");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/stop`,{method:"POST"}),s=await i.json();a(s.ok?r.stopped:r.failed)}catch{a(r.error)}n(null),u()},_=async()=>{n("restart");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/restart`,{method:"POST"}),s=await i.json();if(s.ok&&s.pid){a(r.acRestarted(s.pid));try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),s=await i.json();s.ok?a(r.acAndAgentsRestarted(s.restarted)):a(r.agentResetFailed)}catch{a(r.agentResetFailed)}}else a(s.error||r.failed)}catch{a(r.error)}n(null),u()},g=async()=>{n("reset");try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),s=await i.json();a(s.ok?r.resetResult(s.restarted,s.total):s.error||r.failed)}catch{a(r.error)}n(null),u()};return(0,p.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,p.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:r.title}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("button",{onClick:f,disabled:!!s,className:`px-1.5 py-0.5 text-[10px] border transition-colors disabled:opacity-50 ${l?"text-error border-error/60 bg-error/10 hover:bg-error/20":"text-text-muted border-border hover:text-error hover:border-error/40"}`,children:"stop"===s?"...":l?r.confirmStop:r.stop}),(0,p.jsx)("button",{onClick:_,disabled:!!s,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"restart"===s?"...":r.restart}),(0,p.jsx)("button",{onClick:g,disabled:!!s,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"reset"===s?"...":r.resetAgents})]}),o&&(0,p.jsx)("div",{className:"text-[10px] text-accent",children:o}),c&&!o&&(0,p.jsx)("div",{className:`text-[10px] ${c.includes("failed")||c.includes("실패")?"text-error":"text-[#ffcc00]"}`,children:c})]})}function rr(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function rs(e){let i=Math.floor(e/3600),r=Math.floor(e%3600/60);return i>0?`${i}h ${r}m`:`${r}m`}function rn({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=rt[i].system,[s,n]=(0,m.useState)(!1),[o,a]=(0,m.useState)(null),[l,h]=(0,m.useState)(""),[c,d]=(0,m.useState)(!1),[u,f]=(0,m.useState)(String(3)),[_,g]=(0,m.useState)(!1),[v,b]=(0,m.useState)(!1),[y,S]=(0,m.useState)(!1),[w,C]=(0,m.useState)(null),k=(0,m.useRef)(!1),E=(0,m.useRef)(null),N=(0,m.useRef)(!1),R=(0,m.useRef)(!1);R.current=s,k.current=y;let[j,T]=(0,m.useState)(!1),[D,M]=(0,m.useState)(!1),[P,L]=(0,m.useState)(!0),[A,B]=(0,m.useState)("soft-chime"),[I,O]=(0,m.useState)(!0);(0,m.useEffect)(()=>{L((0,re.getNotificationEnabled)()),B((0,re.getNotificationChoice)()),O((0,re.getNotificationBackgroundOnly)())},[]);let F=(0,m.useCallback)(()=>{fetch("/api/caffeinate/status").then(e=>e.ok?e.json():null).then(e=>{e&&(n(e.active),a(e.remaining),h(e.platform))}).catch(()=>{})},[]);(0,m.useEffect)(()=>{F();let e=setInterval(F,5e3);return()=>clearInterval(e)},[F]);let z=e=>{fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:e})}).then(e=>e.json()).then(i=>{i.ok&&(n(!0),a(e||null))}).catch(()=>{}),d(!1)};(0,m.useEffect)(()=>{S(!1),C(null),E.current=null,N.current=!1,fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.awake_auto&&S(!0)}).catch(()=>{})},[e]);let H=(0,m.useCallback)(async()=>{let i=!y;S(i),i||(C(null),E.current=null,N.current=!1);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.awake_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[y,e]),$=(0,m.useCallback)(()=>{let e=parseFloat(u),i=Math.round(3600*(Number.isFinite(e)?rr(e):8));fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:i})}).then(e=>e.json()).then(e=>{e.ok&&(n(!0),a(i),N.current=!1)}).catch(()=>{})},[u]),W=(0,m.useCallback)(()=>{fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{n(!1),a(null)}).catch(()=>{})},[]);(0,m.useEffect)(()=>{if(!y)return;let i=async()=>{if(k.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=E.current;if(E.current={complete:s.complete,hasItems:n},!o){!n||s.complete||R.current||($(),C(r.awakeStatusActive)),n&&s.complete&&R.current&&(W(),C(r.awakeStatusComplete));return}n&&s.complete&&!o.complete&&R.current&&(W(),C(r.awakeStatusComplete),N.current=!1),!n||s.complete||!o.complete&&o.hasItems||R.current||N.current||($(),C(r.awakeStatusNew))}catch{}};i();let s=setInterval(i,3e4);return()=>clearInterval(s)},[y,e,$,W,r]);let U=!l||"darwin"===l;return(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6 relative",children:[U&&(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:r.keepAwake}),(0,p.jsx)("button",{type:"button","aria-label":r.keepAwakeAbout,onClick:()=>T(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),(0,p.jsxs)("button",{type:"button",onClick:H,title:y?r.autoAwakeOn:r.autoAwakeOff,className:`ml-1 px-1.5 py-0.5 text-[10px] border transition-colors ${y?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",y?"●":"○"]})]}),j&&(0,p.jsx)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:r.keepAwakeHelp}),w&&(0,p.jsx)("div",{className:"text-[10px] text-accent bg-accent/5 border border-border/50 px-1.5 py-0.5 mt-0.5",children:w}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:s&&null!==o&&o>0?r.awakeFor(rs(o)):s&&null===o?r.awakeIndefinitely:r.awakeDesc}),(0,p.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:(0,p.jsxs)("button",{onClick:()=>s?void(N.current=!0,fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{n(!1),a(null)}).catch(()=>{})):d(!c),title:"Keep Mac awake (caffeinate)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${s?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[s?r.awake:r.start,s&&null!==o&&o>0&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:rs(o)}),s&&null===o&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:r.on})]})})]}),U&&(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:r.sound}),(0,p.jsx)("button",{type:"button","aria-label":r.soundAbout,onClick:()=>M(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),D&&(0,p.jsx)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:r.soundHelp}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:r.soundDesc}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:[(0,p.jsxs)("button",{type:"button",onClick:()=>{let e=!P;L(e),(0,re.setNotificationEnabled)(e)},title:P?"Notification sound on (click to mute)":"Notification sound off (click to unmute)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${P?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[P?"🔔":"🔕"," ",r.soundLabel]}),P&&(0,p.jsx)("select",{value:A,onChange:e=>(e=>{if(B(e),(0,re.setNotificationChoice)(e),P)try{let i=new Audio(`/sounds/${e}.mp3`);i.volume=.6,i.play().catch(()=>{})}catch{}})(e.target.value),title:"Notification sound",className:"bg-transparent border border-border px-1 py-0.5 text-[10px] text-text outline-none focus:border-accent cursor-pointer",children:re.NOTIFICATION_SOUND_OPTIONS.map(e=>(0,p.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))})]}),P&&(0,p.jsxs)("label",{className:"flex items-center gap-1 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:I,onChange:e=>{var i;O(i=e.target.checked),(0,re.setNotificationBackgroundOnly)(i)}}),r.soundBgOnly]})]}),c&&!s&&(0,p.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 p-2 border border-border bg-bg-surface z-20 min-w-[220px] flex flex-col gap-1.5",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.keepAwakeModalTitle}),(0,p.jsx)("button",{type:"button","aria-label":r.keepAwakeModalAbout,onClick:()=>b(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),v&&(0,p.jsx)("div",{className:"p-1.5 text-[10px] leading-snug text-text bg-bg border border-border/60 rounded",children:r.keepAwakeModalHelp}),(0,p.jsx)("p",{className:"text-[10px] text-[#ffcc00]",children:r.makeSurePluggedIn}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:r.for}),(0,p.jsx)("input",{type:"number",value:u,onChange:e=>f(e.target.value),onBlur:()=>{let e=parseFloat(u);f(String(Math.round(10*(Number.isFinite(e)?rr(e):3))/10))},disabled:_,min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-text outline-none focus:border-accent text-center disabled:opacity-40"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.hours})]}),(0,p.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:_,onChange:e=>g(e.target.checked)}),r.untilStopped]}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(_)return void z(0);let e=parseFloat(u);z(Math.round(3600*(Number.isFinite(e)?rr(e):3)))},className:"self-start px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors",children:r.start})]})]})}function ro({projectId:e}){return(0,p.jsx)("div",{className:"border-t border-border px-3 py-2",children:(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6",children:[(0,p.jsx)(ri,{projectId:e}),(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsx)(rn,{projectId:e})]})})}var ra=e.i(47167),rl=Object.defineProperty,rh=Object.getOwnPropertyDescriptor,rc=(e,i,r,s)=>{for(var n,o=s>1?void 0:s?rh(i,r):i,a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s?n(i,r,o):n(o))||o);return s&&o&&rl(i,r,o),o},rd=(e,i)=>(r,s)=>i(r,s,e),ru="Terminal input",rf="Too much output to announce, navigate to rows manually to read";function rp(e,i,r,s){var n;n=e=e.replace(/\r?\n/g,"\r"),e=r.decPrivateModes.bracketedPasteMode&&!0!==s.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,r.triggerDataEvent(e,!0),i.value=""}function rm(e,i,r){let s=r.getBoundingClientRect(),n=e.clientX-s.left-10,o=e.clientY-s.top-10;i.style.width="20px",i.style.height="20px",i.style.left=`${n}px`,i.style.top=`${o}px`,i.style.zIndex="1000",i.focus()}function r_(e,i,r,s,n){rm(e,i,r),n&&s.rightClickSelect(e),i.value=s.selectionText,i.select()}function rg(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function rv(e,i=0,r=e.length){let s="";for(let n=i;n<r;++n){let i=e[n];i>65535?(i-=65536,s+=String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):s+=String.fromCharCode(i)}return s}var rx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n=0;if(this._interim){let r=e.charCodeAt(n++);56320<=r&&r<=57343?i[s++]=(this._interim-55296)*1024+r-56320+65536:(i[s++]=this._interim,i[s++]=r),this._interim=0}for(let o=n;o<r;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return this._interim=n,s;let a=e.charCodeAt(o);56320<=a&&a<=57343?i[s++]=(n-55296)*1024+a-56320+65536:(i[s++]=n,i[s++]=a);continue}65279!==n&&(i[s++]=n)}return s}},rb=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let n=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let a=0,l;for(;(l=63&this.interim[++a])&&a<4;)o<<=6,o|=l;let h=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,d=h-a;for(;c<d;){if(c>=r)return 0;if((192&(l=e[c++]))!=128){c--,n=!0;break}this.interim[a++]=l,o<<=6,o|=63&l}n||(2===h?o<128?c--:i[s++]=o:3===h?o<2048||o>=55296&&o<=57343||65279===o||(i[s++]=o):o<65536||o>1114111||(i[s++]=o)),this.interim.fill(0)}let d=r-4,u=c;for(;u<r;){for(;u<d&&!(128&(n=e[u]))&&!(128&(o=e[u+1]))&&!(128&(a=e[u+2]))&&!(128&(l=e[u+3]));)i[s++]=n,i[s++]=o,i[s++]=a,i[s++]=l,u+=4;if((n=e[u++])<128)i[s++]=n;else if((224&n)==192){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128||(h=(31&n)<<6|63&o)<128){u--;continue}i[s++]=h}else if((240&n)==224){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(a=e[u++]))!=128){u--;continue}if((h=(15&n)<<12|(63&o)<<6|63&a)<2048||h>=55296&&h<=57343||65279===h)continue;i[s++]=h}else if((248&n)==240){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(a=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,s;if((192&(l=e[u++]))!=128){u--;continue}if((h=(7&n)<<18|(63&o)<<12|(63&a)<<6|63&l)<65536||h>1114111)continue;i[s++]=h}}return s}},ry=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rS}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let i=new e;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}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}},rS=class e{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},rw=class e extends ry{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rS,this.combinedData=""}static fromCharData(i){let r=new e;return r.setFromCharData(i),r}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?rg(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(2===e[1].length){let r=e[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rC="di$target",rk="di$dependencies",rE=new Map;function rN(e){if(rE.has(e))return rE.get(e);let i=function(e,r,s){var n,o,a;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=i,o=e,a=s,o[rC]===o?o[rk].push({id:n,index:a}):(o[rk]=[{id:n,index:a}],o[rC]=o)};return i._id=e,rE.set(e,i),i}var rR=rN("BufferService"),rj=rN("CoreMouseService"),rT=rN("CoreService"),rD=rN("CharsetService"),rM=rN("InstantiationService"),rP=rN("LogService"),rL=rN("OptionsService"),rA=rN("OscLinkService"),rB=rN("UnicodeService"),rI=rN("DecorationService"),rO=class{constructor(e,i,r){this._bufferService=e,this._optionsService=i,this._oscLinkService=r}provideLinks(e,i){let r=this._bufferService.buffer.lines.get(e-1);if(!r)return void i(void 0);let s=[],n=this._optionsService.rawOptions.linkHandler,o=new rw,a=r.getTrimmedLength(),l=-1,h=-1,c=!1;for(let i=0;i<a;i++)if(!(-1===h&&!r.hasContent(i))){if(r.loadCell(i,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===h){h=i,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else -1!==h&&(c=!0);if(c||-1!==h&&i===a-1){let r=this._oscLinkService.getLinkData(l)?.uri;if(r){let o={start:{x:h+1,y:e},end:{x:i+ +(!c&&i===a-1),y:e}},l=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(r);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||s.push({text:r,range:o,activate:(e,i)=>n?n.activate(e,i,o):function(e){if(confirm(`Do you want to navigate to ${e}?
2
6
 
3
- WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}(i),hover:(e,i)=>n?.hover?.(e,i,o),leave:(e,i)=>n?.leave?.(e,i,o)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=i,l=o.extended.urlId):(h=-1,l=-1)}}i(s)}};rA=ra([rl(0,rk),rl(1,rD),rl(2,rM)],rA);var rB=rC("CharSizeService"),rI=rC("CoreBrowserService"),rO=rC("MouseService"),rF=rC("RenderService"),rH=rC("SelectionService"),rz=rC("CharacterJoinerService"),r$=rC("ThemeService"),rW=rC("LinkProviderService"),rU=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?rY.isErrorNoTelemetry(e)?new rY(e.message+`
7
+ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}(i),hover:(e,i)=>n?.hover?.(e,i,o),leave:(e,i)=>n?.leave?.(e,i,o)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=i,l=o.extended.urlId):(h=-1,l=-1)}}i(s)}};rO=rc([rd(0,rR),rd(1,rL),rd(2,rA)],rO);var rF=rN("CharSizeService"),rz=rN("CoreBrowserService"),rH=rN("MouseService"),r$=rN("RenderService"),rW=rN("SelectionService"),rU=rN("CharacterJoinerService"),rK=rN("ThemeService"),rq=rN("LinkProviderService"),rV=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?rJ.isErrorNoTelemetry(e)?new rJ(e.message+`
4
8
 
5
9
  `+e.stack):Error(e.message+`
6
10
 
7
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(i=>{i(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function rK(e){var i;(i=e)instanceof rV||i instanceof Error&&i.name===rq&&i.message===rq||rU.onUnexpectedError(e)}var rq="Canceled",rV=class extends Error{constructor(){super(rq),this.name=this.message}},rY=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(i){if(i instanceof e)return i;let r=new e;return r.message=i.message,r.stack=i.stack,r}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},rG=class e extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function rX(e,i=0){return e[e.length-(1+i)]}(sr=ss||={}).isLessThan=function(e){return e<0},sr.isLessThanOrEqual=function(e){return e<=0},sr.isGreaterThan=function(e){return e>0},sr.isNeitherLessOrGreaterThan=function(e){return 0===e},sr.greaterThan=1,sr.lessThan=-1,sr.neitherLessOrGreaterThan=0;var rJ=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(i=>(e(i),!0))}toArray(){let e=[];return this.iterate(i=>(e.push(i),!0)),e}filter(i){return new e(e=>this.iterate(r=>!i(r)||e(r)))}map(i){return new e(e=>this.iterate(r=>e(i(r))))}some(e){let i=!1;return this.iterate(r=>!(i=e(r))),i}findFirst(e){let i;return this.iterate(r=>!e(r)||(i=r,!1)),i}findLast(e){let i;return this.iterate(r=>(e(r)&&(i=r),!0)),i}findLastMaxBy(e){let i,r=!0;return this.iterate(s=>((r||ss.isGreaterThan(e(s,i)))&&(r=!1,i=s),!0)),i}};rJ.empty=new rJ(e=>{});function rQ(e){}function rZ(e,i){}function r0(e){if(sn.is(e)){let i=[];for(let r of e)if(r)try{r.dispose()}catch(e){i.push(e)}if(1===i.length)throw i[0];if(i.length>1)throw AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function r1(e){let i={dispose:function(e,i){let r=this,s=!1,n;return function(){if(s)return n;if(s=!0,i)try{n=e.apply(r,arguments)}finally{i()}else n=e.apply(r,arguments);return n}}(()=>{rQ(i),e()})};return i}(e=>{function i(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=i;let r=Object.freeze([]);function*s(e){yield e}e.empty=function(){return r},e.single=s,e.wrap=function(e){return i(e)?e:s(e)},e.from=function(e){return e||r},e.reverse=function*(e){for(let i=e.length-1;i>=0;i--)yield e[i]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,i){let r=0;for(let s of e)if(i(s,r++))return!0;return!1},e.find=function(e,i){for(let r of e)if(i(r))return r},e.filter=function*(e,i){for(let r of e)i(r)&&(yield r)},e.map=function*(e,i){let r=0;for(let s of e)yield i(s,r++)},e.flatMap=function*(e,i){let r=0;for(let s of e)yield*i(s,r++)},e.concat=function*(...e){for(let i of e)yield*i},e.reduce=function(e,i,r){let s=r;for(let r of e)s=i(s,r);return s},e.slice=function*(e,i,r=e.length){for(i<0&&(i+=e.length),r<0?r+=e.length:r>e.length&&(r=e.length);i<r;i++)yield e[i]},e.consume=function(i,r=1/0){let s=[];if(0===r)return[s,i];let n=i[Symbol.iterator]();for(let i=0;i<r;i++){let i=n.next();if(i.done)return[s,e.empty()];s.push(i.value)}return[s,{[Symbol.iterator]:()=>n}]},e.asyncToArray=async function(e){let i=[];for await(let r of e)i.push(r);return Promise.resolve(i)}})(sn||={});var r2=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(rQ(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{r0(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return rZ(i,this),this._isDisposed?e.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(i),i}delete(e){if(e){if(e===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),rZ(e,null))}};r2.DISABLE_DISPOSED_WARNING=!1;var r5=r2,r3=class{constructor(){var e;this._store=new r5,e=this,rZ(this._store,this)}dispose(){rQ(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};r3.None=Object.freeze({dispose(){}});var r4=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&rZ(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,rQ(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&rZ(e,null),e}},r6="object"==typeof window?window:globalThis,r9=class e{constructor(i){this.element=i,this.next=e.Undefined,this.prev=e.Undefined}};r9.Undefined=new r9(void 0);var r8=class{constructor(){this._first=r9.Undefined,this._last=r9.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===r9.Undefined}clear(){let e=this._first;for(;e!==r9.Undefined;){let i=e.next;e.prev=r9.Undefined,e.next=r9.Undefined,e=i}this._first=r9.Undefined,this._last=r9.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,i){let r=new r9(e);if(this._first===r9.Undefined)this._first=r,this._last=r;else if(i){let e=this._last;this._last=r,r.prev=e,e.next=r}else{let e=this._first;this._first=r,r.next=e,e.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}shift(){if(this._first!==r9.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==r9.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==r9.Undefined&&e.next!==r9.Undefined){let i=e.prev;i.next=e.next,e.next.prev=i}else e.prev===r9.Undefined&&e.next===r9.Undefined?(this._first=r9.Undefined,this._last=r9.Undefined):e.next===r9.Undefined?(this._last=this._last.prev,this._last.next=r9.Undefined):e.prev===r9.Undefined&&(this._first=this._first.next,this._first.prev=r9.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==r9.Undefined;)yield e.element,e=e.next}},r7=globalThis.performance&&"function"==typeof globalThis.performance.now,se=class e{static create(i){return new e(i)}constructor(e){this._now=r7&&!1===e?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}};(e=>{function i(e){}function r(e){return(i,r=null,s)=>{let n=!1,o;return o=e(e=>{if(!n)return o?o.dispose():n=!0,i.call(r,e)},null,s),n&&o.dispose(),o}}function s(e,i,r){return o((r,s=null,n)=>e(e=>r.call(s,i(e)),null,n),r)}function n(e,i,r){return o((r,s=null,n)=>e(e=>i(e)&&r.call(s,e),null,n),r)}function o(e,r){let s,n={onWillAddFirstListener(){s=e(o.fire,o)},onDidRemoveLastListener(){s?.dispose()}};r||i(n);let o=new sf(n);return r?.add(o),o.event}function a(e,r,s=100,n=!1,o=!1,l,h){let c,d,u,f=0,p,_={leakWarningThreshold:l,onWillAddFirstListener(){c=e(e=>{f++,d=r(d,e),n&&!u&&(m.fire(d),d=void 0),p=()=>{let e=d;d=void 0,u=void 0,(!n||f>1)&&m.fire(e),f=0},"number"==typeof s?(clearTimeout(u),u=setTimeout(p,s)):void 0===u&&(u=0,queueMicrotask(p))})},onWillRemoveListener(){o&&f>0&&p?.()},onDidRemoveLastListener(){p=void 0,c.dispose()}};h||i(_);let m=new sf(_);return h?.add(m),m.event}e.None=()=>r3.None,e.defer=function(e,i){return a(e,()=>{},0,void 0,!0,void 0,i)},e.once=r,e.map=s,e.forEach=function(e,i,r){return o((r,s=null,n)=>e(e=>{i(e),r.call(s,e)},null,n),r)},e.filter=n,e.signal=function(e){return e},e.any=function(...e){return(i,r=null,s)=>{var n,o;return n=function(...e){let i=r1(()=>r0(e));return i}(...e.map(e=>e(e=>i.call(r,e)))),(o=s)instanceof Array?o.push(n):o&&o.add(n),n}},e.reduce=function(e,i,r,n){let o=r;return s(e,e=>o=i(o,e),n)},e.debounce=a,e.accumulate=function(i,r=0,s){return e.debounce(i,(e,i)=>e?(e.push(i),e):[i],r,void 0,!0,void 0,s)},e.latch=function(e,i=(e,i)=>e===i,r){let s=!0,o;return n(e,e=>{let r=s||!i(e,o);return s=!1,o=e,r},r)},e.split=function(i,r,s){return[e.filter(i,r,s),e.filter(i,e=>!r(e),s)]},e.buffer=function(e,i=!1,r=[],s){let n=r.slice(),o=e(e=>{n?n.push(e):l.fire(e)});s&&s.add(o);let a=()=>{n?.forEach(e=>l.fire(e)),n=null},l=new sf({onWillAddFirstListener(){o||(o=e(e=>l.fire(e)),s&&s.add(o))},onDidAddFirstListener(){n&&(i?setTimeout(a):a())},onDidRemoveLastListener(){o&&o.dispose(),o=null}});return s&&s.add(l),l.event},e.chain=function(e,i){return(r,s,n)=>{let o=i(new h);return e(function(e){let i=o.evaluate(e);i!==l&&r.call(s,i)},void 0,n)}};let l=Symbol("HaltChainable");class h{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(i=>(e(i),i)),this}filter(e){return this.steps.push(i=>e(i)?i:l),this}reduce(e,i){let r=i;return this.steps.push(i=>r=e(r,i)),this}latch(e=(e,i)=>e===i){let i=!0,r;return this.steps.push(s=>{let n=i||!e(s,r);return i=!1,r=s,n?s:l}),this}evaluate(e){for(let i of this.steps)if((e=i(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,i,r=e=>e){let s=(...e)=>n.fire(r(...e)),n=new sf({onWillAddFirstListener:()=>e.on(i,s),onDidRemoveLastListener:()=>e.removeListener(i,s)});return n.event},e.fromDOMEventEmitter=function(e,i,r=e=>e){let s=(...e)=>n.fire(r(...e)),n=new sf({onWillAddFirstListener:()=>e.addEventListener(i,s),onDidRemoveLastListener:()=>e.removeEventListener(i,s)});return n.event},e.toPromise=function(e){return new Promise(i=>r(e)(i))},e.fromPromise=function(e){let i=new sf;return e.then(e=>{i.fire(e)},()=>{i.fire(void 0)}).finally(()=>{i.dispose()}),i.event},e.forward=function(e,i){return e(e=>i.fire(e))},e.runAndSubscribe=function(e,i,r){return i(r),e(e=>i(e))};class c{constructor(e,r){this._observable=e,this._counter=0,this._hasChanged=!1;let s={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};r||i(s),this.emitter=new sf(s),r&&r.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,i){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,i){return new c(e,i).emitter.event},e.fromObservableLight=function(e){return(i,r,s)=>{let n=0,o=!1,a={beginUpdate(){n++},endUpdate(){0==--n&&(e.reportChanges(),o&&(o=!1,i.call(r)))},handlePossibleChange(){},handleChange(){o=!0}};e.addObserver(a),e.reportChanges();let l={dispose(){e.removeObserver(a)}};return s instanceof r5?s.add(l):Array.isArray(s)&&s.push(l),l}}})(so||={});var st=class e{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new se,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};st.all=new Set,st._idPool=0;var si=class e{constructor(i,r,s=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=r,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let r=this.threshold;if(r<=0||i<r)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*r;let[e,s]=this.getMostFrequentStack(),n=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${s}):`;console.warn(n),console.warn(e);let o=new sh(n,e);this._errorHandler(o)}return()=>{let i=this._stacks.get(e.value)||0;this._stacks.set(e.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[r,s]of this._stacks)(!e||i<s)&&(e=[r,s],i=s);return e}};si._idPool=1;var sr,ss,sn,so,sa,sl=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
11
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(i=>{i(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function rY(e){var i;(i=e)instanceof rX||i instanceof Error&&i.name===rG&&i.message===rG||rV.onUnexpectedError(e)}var rG="Canceled",rX=class extends Error{constructor(){super(rG),this.name=this.message}},rJ=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(i){if(i instanceof e)return i;let r=new e;return r.message=i.message,r.stack=i.stack,r}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},rQ=class e extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function rZ(e,i=0){return e[e.length-(1+i)]}(so=sa||={}).isLessThan=function(e){return e<0},so.isLessThanOrEqual=function(e){return e<=0},so.isGreaterThan=function(e){return e>0},so.isNeitherLessOrGreaterThan=function(e){return 0===e},so.greaterThan=1,so.lessThan=-1,so.neitherLessOrGreaterThan=0;var r0=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(i=>(e(i),!0))}toArray(){let e=[];return this.iterate(i=>(e.push(i),!0)),e}filter(i){return new e(e=>this.iterate(r=>!i(r)||e(r)))}map(i){return new e(e=>this.iterate(r=>e(i(r))))}some(e){let i=!1;return this.iterate(r=>!(i=e(r))),i}findFirst(e){let i;return this.iterate(r=>!e(r)||(i=r,!1)),i}findLast(e){let i;return this.iterate(r=>(e(r)&&(i=r),!0)),i}findLastMaxBy(e){let i,r=!0;return this.iterate(s=>((r||sa.isGreaterThan(e(s,i)))&&(r=!1,i=s),!0)),i}};r0.empty=new r0(e=>{});function r1(e){}function r2(e,i){}function r5(e){if(sl.is(e)){let i=[];for(let r of e)if(r)try{r.dispose()}catch(e){i.push(e)}if(1===i.length)throw i[0];if(i.length>1)throw AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function r3(e){let i={dispose:function(e,i){let r=this,s=!1,n;return function(){if(s)return n;if(s=!0,i)try{n=e.apply(r,arguments)}finally{i()}else n=e.apply(r,arguments);return n}}(()=>{r1(i),e()})};return i}(e=>{function i(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=i;let r=Object.freeze([]);function*s(e){yield e}e.empty=function(){return r},e.single=s,e.wrap=function(e){return i(e)?e:s(e)},e.from=function(e){return e||r},e.reverse=function*(e){for(let i=e.length-1;i>=0;i--)yield e[i]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,i){let r=0;for(let s of e)if(i(s,r++))return!0;return!1},e.find=function(e,i){for(let r of e)if(i(r))return r},e.filter=function*(e,i){for(let r of e)i(r)&&(yield r)},e.map=function*(e,i){let r=0;for(let s of e)yield i(s,r++)},e.flatMap=function*(e,i){let r=0;for(let s of e)yield*i(s,r++)},e.concat=function*(...e){for(let i of e)yield*i},e.reduce=function(e,i,r){let s=r;for(let r of e)s=i(s,r);return s},e.slice=function*(e,i,r=e.length){for(i<0&&(i+=e.length),r<0?r+=e.length:r>e.length&&(r=e.length);i<r;i++)yield e[i]},e.consume=function(i,r=1/0){let s=[];if(0===r)return[s,i];let n=i[Symbol.iterator]();for(let i=0;i<r;i++){let i=n.next();if(i.done)return[s,e.empty()];s.push(i.value)}return[s,{[Symbol.iterator]:()=>n}]},e.asyncToArray=async function(e){let i=[];for await(let r of e)i.push(r);return Promise.resolve(i)}})(sl||={});var r4=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(r1(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{r5(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return r2(i,this),this._isDisposed?e.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(i),i}delete(e){if(e){if(e===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),r2(e,null))}};r4.DISABLE_DISPOSED_WARNING=!1;var r6=r4,r9=class{constructor(){var e;this._store=new r6,e=this,r2(this._store,this)}dispose(){r1(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};r9.None=Object.freeze({dispose(){}});var r8=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&r2(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,r1(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&r2(e,null),e}},r7="object"==typeof window?window:globalThis,se=class e{constructor(i){this.element=i,this.next=e.Undefined,this.prev=e.Undefined}};se.Undefined=new se(void 0);var st=class{constructor(){this._first=se.Undefined,this._last=se.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===se.Undefined}clear(){let e=this._first;for(;e!==se.Undefined;){let i=e.next;e.prev=se.Undefined,e.next=se.Undefined,e=i}this._first=se.Undefined,this._last=se.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,i){let r=new se(e);if(this._first===se.Undefined)this._first=r,this._last=r;else if(i){let e=this._last;this._last=r,r.prev=e,e.next=r}else{let e=this._first;this._first=r,r.next=e,e.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}shift(){if(this._first!==se.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==se.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==se.Undefined&&e.next!==se.Undefined){let i=e.prev;i.next=e.next,e.next.prev=i}else e.prev===se.Undefined&&e.next===se.Undefined?(this._first=se.Undefined,this._last=se.Undefined):e.next===se.Undefined?(this._last=this._last.prev,this._last.next=se.Undefined):e.prev===se.Undefined&&(this._first=this._first.next,this._first.prev=se.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==se.Undefined;)yield e.element,e=e.next}},si=globalThis.performance&&"function"==typeof globalThis.performance.now,sr=class e{static create(i){return new e(i)}constructor(e){this._now=si&&!1===e?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}};(e=>{function i(e){}function r(e){return(i,r=null,s)=>{let n=!1,o;return o=e(e=>{if(!n)return o?o.dispose():n=!0,i.call(r,e)},null,s),n&&o.dispose(),o}}function s(e,i,r){return o((r,s=null,n)=>e(e=>r.call(s,i(e)),null,n),r)}function n(e,i,r){return o((r,s=null,n)=>e(e=>i(e)&&r.call(s,e),null,n),r)}function o(e,r){let s,n={onWillAddFirstListener(){s=e(o.fire,o)},onDidRemoveLastListener(){s?.dispose()}};r||i(n);let o=new s_(n);return r?.add(o),o.event}function a(e,r,s=100,n=!1,o=!1,l,h){let c,d,u,f=0,p,m={leakWarningThreshold:l,onWillAddFirstListener(){c=e(e=>{f++,d=r(d,e),n&&!u&&(_.fire(d),d=void 0),p=()=>{let e=d;d=void 0,u=void 0,(!n||f>1)&&_.fire(e),f=0},"number"==typeof s?(clearTimeout(u),u=setTimeout(p,s)):void 0===u&&(u=0,queueMicrotask(p))})},onWillRemoveListener(){o&&f>0&&p?.()},onDidRemoveLastListener(){p=void 0,c.dispose()}};h||i(m);let _=new s_(m);return h?.add(_),_.event}e.None=()=>r9.None,e.defer=function(e,i){return a(e,()=>{},0,void 0,!0,void 0,i)},e.once=r,e.map=s,e.forEach=function(e,i,r){return o((r,s=null,n)=>e(e=>{i(e),r.call(s,e)},null,n),r)},e.filter=n,e.signal=function(e){return e},e.any=function(...e){return(i,r=null,s)=>{var n,o;return n=function(...e){let i=r3(()=>r5(e));return i}(...e.map(e=>e(e=>i.call(r,e)))),(o=s)instanceof Array?o.push(n):o&&o.add(n),n}},e.reduce=function(e,i,r,n){let o=r;return s(e,e=>o=i(o,e),n)},e.debounce=a,e.accumulate=function(i,r=0,s){return e.debounce(i,(e,i)=>e?(e.push(i),e):[i],r,void 0,!0,void 0,s)},e.latch=function(e,i=(e,i)=>e===i,r){let s=!0,o;return n(e,e=>{let r=s||!i(e,o);return s=!1,o=e,r},r)},e.split=function(i,r,s){return[e.filter(i,r,s),e.filter(i,e=>!r(e),s)]},e.buffer=function(e,i=!1,r=[],s){let n=r.slice(),o=e(e=>{n?n.push(e):l.fire(e)});s&&s.add(o);let a=()=>{n?.forEach(e=>l.fire(e)),n=null},l=new s_({onWillAddFirstListener(){o||(o=e(e=>l.fire(e)),s&&s.add(o))},onDidAddFirstListener(){n&&(i?setTimeout(a):a())},onDidRemoveLastListener(){o&&o.dispose(),o=null}});return s&&s.add(l),l.event},e.chain=function(e,i){return(r,s,n)=>{let o=i(new h);return e(function(e){let i=o.evaluate(e);i!==l&&r.call(s,i)},void 0,n)}};let l=Symbol("HaltChainable");class h{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(i=>(e(i),i)),this}filter(e){return this.steps.push(i=>e(i)?i:l),this}reduce(e,i){let r=i;return this.steps.push(i=>r=e(r,i)),this}latch(e=(e,i)=>e===i){let i=!0,r;return this.steps.push(s=>{let n=i||!e(s,r);return i=!1,r=s,n?s:l}),this}evaluate(e){for(let i of this.steps)if((e=i(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,i,r=e=>e){let s=(...e)=>n.fire(r(...e)),n=new s_({onWillAddFirstListener:()=>e.on(i,s),onDidRemoveLastListener:()=>e.removeListener(i,s)});return n.event},e.fromDOMEventEmitter=function(e,i,r=e=>e){let s=(...e)=>n.fire(r(...e)),n=new s_({onWillAddFirstListener:()=>e.addEventListener(i,s),onDidRemoveLastListener:()=>e.removeEventListener(i,s)});return n.event},e.toPromise=function(e){return new Promise(i=>r(e)(i))},e.fromPromise=function(e){let i=new s_;return e.then(e=>{i.fire(e)},()=>{i.fire(void 0)}).finally(()=>{i.dispose()}),i.event},e.forward=function(e,i){return e(e=>i.fire(e))},e.runAndSubscribe=function(e,i,r){return i(r),e(e=>i(e))};class c{constructor(e,r){this._observable=e,this._counter=0,this._hasChanged=!1;let s={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};r||i(s),this.emitter=new s_(s),r&&r.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,i){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,i){return new c(e,i).emitter.event},e.fromObservableLight=function(e){return(i,r,s)=>{let n=0,o=!1,a={beginUpdate(){n++},endUpdate(){0==--n&&(e.reportChanges(),o&&(o=!1,i.call(r)))},handlePossibleChange(){},handleChange(){o=!0}};e.addObserver(a),e.reportChanges();let l={dispose(){e.removeObserver(a)}};return s instanceof r6?s.add(l):Array.isArray(s)&&s.push(l),l}}})(sh||={});var ss=class e{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new sr,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};ss.all=new Set,ss._idPool=0;var sn=class e{constructor(i,r,s=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=r,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let r=this.threshold;if(r<=0||i<r)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*r;let[e,s]=this.getMostFrequentStack(),n=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${s}):`;console.warn(n),console.warn(e);let o=new su(n,e);this._errorHandler(o)}return()=>{let i=this._stacks.get(e.value)||0;this._stacks.set(e.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[r,s]of this._stacks)(!e||i<s)&&(e=[r,s],i=s);return e}};sn._idPool=1;var so,sa,sl,sh,sc,sd=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
8
12
  `).slice(2).join(`
9
- `))}},sh=class extends Error{constructor(e,i){super(e),this.name="ListenerLeakError",this.stack=i}},sc=class extends Error{constructor(e,i){super(e),this.name="ListenerRefusalError",this.stack=i}},sd=0,su=class{constructor(e){this.value=e,this.id=sd++}},sf=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new si(e?.onListenerError??rK,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new st(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??=(e,i,r)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],r=new sc(`${e}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||rK)(r),r3.None}if(this._disposed)return r3.None;i&&(e=e.bind(i));let s=new su(e),n;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(s.stack=sl.create(),n=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof su?(this._deliveryQueue??=new sp,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=r1(()=>{sa?.unregister(o),n?.(),this._removeListener(s)});if(r instanceof r5?r.add(o):Array.isArray(r)&&r.push(o),sa){let e=Error().stack.split(`
13
+ `))}},su=class extends Error{constructor(e,i){super(e),this.name="ListenerLeakError",this.stack=i}},sf=class extends Error{constructor(e,i){super(e),this.name="ListenerRefusalError",this.stack=i}},sp=0,sm=class{constructor(e){this.value=e,this.id=sp++}},s_=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new sn(e?.onListenerError??rY,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new ss(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??=(e,i,r)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],r=new sf(`${e}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||rY)(r),r9.None}if(this._disposed)return r9.None;i&&(e=e.bind(i));let s=new sm(e),n;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(s.stack=sd.create(),n=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof sm?(this._deliveryQueue??=new sg,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=r3(()=>{sc?.unregister(o),n?.(),this._removeListener(s)});if(r instanceof r6?r.add(o):Array.isArray(r)&&r.push(o),sc){let e=Error().stack.split(`
10
14
  `).slice(2,3).join(`
11
- `).trim(),i=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);sa.register(o,i?.[2]??e,o)}return o},this._event}_removeListener(e){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 i=this._listeners,r=i.indexOf(e);if(-1===r)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--,i[r]=void 0;let s=this._deliveryQueue.current===this;if(2*this._size<=i.length){let e=0;for(let r=0;r<i.length;r++)i[r]?i[e++]=i[r]:s&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=e}}_deliver(e,i){if(!e)return;let r=this._options?.onListenerError||rK;try{e.value(i)}catch(e){r(e)}}_deliverQueue(e){let i=e.current._listeners;for(;e.i<e.end;)this._deliver(i[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof su)this._deliver(this._listeners,e);else{let i=this._deliveryQueue;i.enqueue(this,e,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},sp=class{constructor(){this.i=-1,this.end=0}enqueue(e,i,r){this.i=0,this.end=r,this.current=e,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},s_=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new sf,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new sf,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let r=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(r,e),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let r=this.getWindowId(i);this.mapWindowIdToFullScreen.set(r,e),this._onDidChangeFullscreen.fire(r)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};s_.INSTANCE=new s_,s_.INSTANCE.onDidChangeZoomLevel,s_.INSTANCE.onDidChangeFullscreen;var sm="object"==typeof navigator?navigator.userAgent:"",sg=sm.indexOf("Firefox")>=0,sv=sm.indexOf("AppleWebKit")>=0,sx=sm.indexOf("Chrome")>=0,sb=!sx&&sm.indexOf("Safari")>=0;sm.indexOf("Electron/"),sm.indexOf("Android");var sy=!1;if("function"==typeof r6.matchMedia){let e=r6.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),i=r6.matchMedia("(display-mode: fullscreen)");sy=e.matches,sS=e,"string"==typeof sS&&(sS=r6.matchMedia(sS)),sS.addEventListener("change",({matches:e})=>{sy&&i.matches||(sy=e)})}var sS,sw,sC,sk=!1,sE=!1,sN=!1,sR=!1,sj=!1,sT="en",sD=globalThis;"u">typeof sD.vscode&&"u">typeof sD.vscode.process?sC=sD.vscode.process:"u">typeof rs.default&&"string"==typeof rs.default?.versions?.node&&(sC=rs.default);var sM="string"==typeof sC?.versions?.electron&&sC?.type==="renderer";if("object"==typeof sC){sk="win32"===sC.platform,sE="darwin"===sC.platform,(sN="linux"===sC.platform)&&sC.env.SNAP&&sC.env.SNAP_REVISION,sC.env.CI||sC.env.BUILD_ARTIFACTSTAGINGDIRECTORY,sT="en";let e=sC.env.VSCODE_NLS_CONFIG;if(e)try{let i=JSON.parse(e);i.userLocale,i.osLocale,sT=i.resolvedLanguage||"en",i.languagePack?.translationsConfigFile}catch{}sR=!0}else"object"!=typeof navigator||sM?console.error("Unable to resolve platform."):(sk=(sw=navigator.userAgent).indexOf("Windows")>=0,sE=sw.indexOf("Macintosh")>=0,(sw.indexOf("Macintosh")>=0||sw.indexOf("iPad")>=0||sw.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,sN=sw.indexOf("Linux")>=0,sw?.indexOf("Mobi"),sj=!0,sT=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var sL=sk,sP=sE,sA=sN,sB=sR;sj&&"function"==typeof sD.importScripts&&sD.origin;var sI,sO=sw,sF=sT;(sG=sI||={}).value=function(){return sF},sG.isDefaultVariant=function(){return 2===sF.length?"en"===sF:sF.length>=3&&"e"===sF[0]&&"n"===sF[1]&&"-"===sF[2]},sG.isDefault=function(){return"en"===sF};var sH="function"==typeof sD.postMessage&&!sD.importScripts,sz=(()=>{if(sH){let e=[];sD.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,s=e.length;r<s;r++){let s=e[r];if(s.id===i.data.vscodeScheduleAsyncWork){e.splice(r,1),s.callback();return}}});let i=0;return r=>{let s=++i;e.push({id:s,callback:r}),sD.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})(),s$=!!(sO&&sO.indexOf("Chrome")>=0);sO&&sO.indexOf("Firefox"),!s$&&sO&&sO.indexOf("Safari"),sO&&sO.indexOf("Edg/"),sO&&sO.indexOf("Android");var sW="object"==typeof navigator?navigator:{};sB||document.queryCommandSupported&&document.queryCommandSupported("copy")||sW&&sW.clipboard&&sW.clipboard.writeText,sB||sW&&sW.clipboard&&sW.clipboard.readText,sB||sy||sW.keyboard,"ontouchstart"in r6||sW.maxTouchPoints,r6.PointerEvent&&("ontouchstart"in r6||navigator.maxTouchPoints);var sU=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,i){this._keyCodeToStr[e]=i,this._strToKeyCode[i.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},sK=new sU,sq=new sU,sV=new sU,sY=Array(230);(sX=sJ||={}).toString=function(e){return sK.keyCodeToStr(e)},sX.fromString=function(e){return sK.strToKeyCode(e)},sX.toUserSettingsUS=function(e){return sq.keyCodeToStr(e)},sX.toUserSettingsGeneral=function(e){return sV.keyCodeToStr(e)},sX.fromUserSettings=function(e){return sq.strToKeyCode(e)||sV.strToKeyCode(e)},sX.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return sK.keyCodeToStr(e)};var sG,sX,sJ,sQ,sZ=class e{constructor(e,i,r,s,n){this.ctrlKey=e,this.shiftKey=i,this.altKey=r,this.metaKey=s,this.keyCode=n}equals(i){return i instanceof e&&this.ctrlKey===i.ctrlKey&&this.shiftKey===i.shiftKey&&this.altKey===i.altKey&&this.metaKey===i.metaKey&&this.keyCode===i.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",r=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${e}${i}${r}${s}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new s0([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},s0=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let i=0,r=this.chords.length;i<r;i++)0!==i&&(e+=";"),e+=this.chords[i].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let i=0;i<this.chords.length;i++)if(!this.chords[i].equals(e.chords[i]))return!1;return!0}},s1=sP?256:2048,s2=sP?2048:256,s5=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return sJ.fromString(i)}let i=e.keyCode;if(3===i)return 7;if(sg)switch(i){case 59:return 85;case 60:if(sA)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(sP)return 57}else if(sv&&(sP&&93===i||!sP&&92===i))return 57;return sY[i]||0}(e),this.code=e.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(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let i=0;return this.ctrlKey&&(i|=s1),this.altKey&&(i|=512),this.shiftKey&&(i|=1024),this.metaKey&&(i|=s2),i|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new sZ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},s3=new WeakMap,s4=class{static getSameOriginWindowChain(e){let i=s3.get(e);if(!i){i=[],s3.set(e,i);let r=e,s;do(s=function(e){if(!e.parent||e.parent===e)return null;try{let i=e.location,r=e.parent.location;if("null"!==i.origin&&"null"!==r.origin&&i.origin!==r.origin)return null}catch{return null}return e.parent}(r))?i.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):i.push({window:new WeakRef(r),iframeElement:null}),r=s;while(r)}return i.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,i){if(!i||e===i)return{top:0,left:0};let r=0,s=0;for(let n of this.getSameOriginWindowChain(e)){let e=n.window.deref();if(r+=e?.scrollY??0,s+=e?.scrollX??0,e===i||!n.iframeElement)break;let o=n.iframeElement.getBoundingClientRect();r+=o.top,s+=o.left}return{top:r,left:s}}},s6=class{constructor(e,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=0===i.button,this.middleButton=1===i.button,this.rightButton=2===i.button,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,"dblclick"===i.type&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,"number"==typeof i.pageX?(this.posx=i.pageX,this.posy=i.pageY):(this.posx=i.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=i.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let r=s4.getPositionOfChildWindowRelativeToAncestorWindow(e,i.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},s9=class{constructor(e,i=0,r=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=i;let s=!1;if(sx){let e=navigator.userAgent.match(/Chrome\/(\d+)/);s=(e?parseInt(e[1]):123)<=122}if(e){let i=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?s?this.deltaY=e.wheelDeltaY/(120*i):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?sg&&!sP?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?sb&&sL?this.deltaX=-(e.wheelDeltaX/120):s?this.deltaX=e.wheelDeltaX/(120*i):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?sg&&!sP?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},s8=Object.freeze(function(e,i){let r=setTimeout(e.bind(i),0);return{dispose(){clearTimeout(r)}}});(nQ=sQ||={}).isCancellationToken=function(e){return e===nQ.None||e===nQ.Cancelled||e instanceof s7||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},nQ.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:so.None}),nQ.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:s8});var s7=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?s8:(this._emitter||(this._emitter=new sf),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var ne=class{constructor(e,i){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof i&&this.setIfNotSet(e,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,i){if(this._isDisposed)throw new rG("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},i)}setIfNotSet(e,i){if(this._isDisposed)throw new rG("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},i))}},nt=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,i,r=globalThis){if(this.isDisposed)throw new rG("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=r.setInterval(()=>{e()},i);this.disposable=r1(()=>{r.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(nZ=n0||={}).settled=async function(e){let i,r=await Promise.all(e.map(e=>e.then(e=>e,e=>{i||(i=e)})));if("u">typeof i)throw i;return r},nZ.withAsyncBody=function(e){return new Promise(async(i,r)=>{try{await e(i,r)}catch(e){r(e)}})};var ni=class e{static fromArray(i){return new e(e=>{e.emitMany(i)})}static fromPromise(i){return new e(async e=>{e.emitMany(await i)})}static fromPromises(i){return new e(async e=>{await Promise.all(i.map(async i=>e.emitOne(await i)))})}static merge(i){return new e(async e=>{await Promise.all(i.map(async i=>{for await(let r of i)e.emitOne(r)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new sf,queueMicrotask(async()=>{let i={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(i)),this.resolve()}catch(e){this.reject(e)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await so.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,r){return new e(async e=>{for await(let s of i)e.emitOne(r(s))})}map(i){return e.map(this,i)}static filter(i,r){return new e(async e=>{for await(let s of i)r(s)&&e.emitOne(s)})}filter(i){return e.filter(this,i)}static coalesce(i){return e.filter(i,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let i=[];for await(let r of e)i.push(r);return i}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};ni.EMPTY=ni.fromArray([]);function nr(e,i){return(i<<5)-i+e|0}function ns(e,i){i=nr(149417,i);for(let r=0,s=e.length;r<s;r++)i=nr(e.charCodeAt(r),i);return i}new DataView(new ArrayBuffer(320));var{registerWindow:nn,getWindow:no,getDocument:na,getWindows:nl,getWindowsCount:nh,getWindowId:nc,getWindowById:nd,hasWindow:nu,onDidRegisterWindow:nf,onWillUnregisterWindow:np,onDidUnregisterWindow:n_}=(i=new Map,r={window:r6,disposables:new r5},i.set(r6.vscodeWindowId,r),s=new sf,n=new sf,o=new sf,{onDidRegisterWindow:s.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:n.event,registerWindow(e){if(i.has(e.vscodeWindowId))return r3.None;let r=new r5,a={window:e,disposables:r.add(new r5)};return i.set(e.vscodeWindowId,a),r.add(r1(()=>{i.delete(e.vscodeWindowId),n.fire(e)})),r.add(ng(e,nS.BEFORE_UNLOAD,()=>{o.fire(e)})),s.fire(a),r},getWindows:()=>i.values(),getWindowsCount:()=>i.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>i.has(e),getWindowById:function(e,s){return("number"==typeof e?i.get(e):void 0)??(s?r:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:r6,getDocument:e=>no(e).document}),nm=class{constructor(e,i,r,s){this._node=e,this._type=i,this._handler=r,this._options=s||!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 ng(e,i,r,s){return new nm(e,i,r,s)}var nv=function(e,i,r,s){var n;let o=r;return"click"===i||"mousedown"===i||"contextmenu"===i?(n=no(e),o=function(e){return r(new s6(n,e))}):("keydown"===i||"keypress"===i||"keyup"===i)&&(o=function(e){return r(new s5(e))}),ng(e,i,o,s)},nx=class extends nt{constructor(e){super(),this.defaultTarget=e&&no(e)}cancelAndSet(e,i,r){return super.cancelAndSet(e,i,r??this.defaultTarget)}},nb=class{constructor(e,i=0){this._runner=e,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){rK(e)}}static sort(e,i){return i.priority-e.priority}};a=new Map,l=new Map,h=new Map,c=new Map,n1=(e,i,r=0)=>{let s=nc(e),n=new nb(i,r),o=a.get(s);return o||(o=[],a.set(s,o)),o.push(n),h.get(s)||(h.set(s,!0),e.requestAnimationFrame(()=>(e=>{h.set(e,!1);let i=a.get(e)??[];for(l.set(e,i),a.set(e,[]),c.set(e,!0);i.length>0;)i.sort(nb.sort),i.shift().execute();c.set(e,!1)})(s))),n};var ny=class e{constructor(e,i){this.width=e,this.height=i}with(i=this.width,r=this.height){return i!==this.width||r!==this.height?new e(i,r):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(i){return i instanceof e?i:new e(i.width,i.height)}static equals(e,i){return e===i||!!e&&!!i&&e.width===i.width&&e.height===i.height}};ny.None=new ny(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,i,r){let s=this.mutationObservers.get(e);s||(s=new Map,this.mutationObservers.set(e,s));let n=function e(i,r){switch(typeof i){case"object":var s,n,o,a;return null===i?nr(349,r):Array.isArray(i)?(s=i,n=nr(104579,n=r),s.reduce((i,r)=>e(r,i),n)):(o=i,a=nr(181387,a=r),Object.keys(o).sort().reduce((i,r)=>(i=ns(r,i),e(o[r],i)),a));case"string":return ns(i,r);case"boolean":return nr(i?433:863,r);case"number":return nr(i,r);case"undefined":return nr(937,r);default:return nr(617,r)}}(r,0),o=s.get(n);if(o)o.users+=1;else{let a=new sf,l=new MutationObserver(e=>a.fire(e));l.observe(e,r);let h=o={users:1,observer:l,onDidMutate:a.event};i.add(r1(()=>{h.users-=1,0===h.users&&(a.dispose(),l.disconnect(),s?.delete(n),s?.size===0&&this.mutationObservers.delete(e))})),s.set(n,o)}return o.onDidMutate}};var nS={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"},nw=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let i=nC(e);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let i=nC(e);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(e){let i=nC(e);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(e){let i=nC(e);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(e){let i=nC(e);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(e){let i=nC(e);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(e){let i=nC(e);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(e){let i=nC(e);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let i=nC(e);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let i=nC(e);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let i=nC(e);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let i=nC(e);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let i=nC(e);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let i=nC(e);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,i){this.domNode.classList.toggle(e,i),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,i){this.domNode.setAttribute(e,i)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function nC(e){return"number"==typeof e?`${e}px`:e}function nk(e){return new nw(e)}var nE=class{constructor(){this._hooks=new r5,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,i,r,s,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=n;let o=e;try{e.setPointerCapture(i),this._hooks.add(r1(()=>{try{e.releasePointerCapture(i)}catch{}}))}catch{o=no(e)}this._hooks.add(ng(o,nS.POINTER_MOVE,e=>{e.buttons!==r?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(ng(o,nS.POINTER_UP,e=>this.stopMonitoring(!0)))}};(d=n2||={}).Tap="-xterm-gesturetap",d.Change="-xterm-gesturechange",d.Start="-xterm-gesturestart",d.End="-xterm-gesturesend",d.Contextmenu="-xterm-gesturecontextmenu";var nN=class e extends r3{constructor(){super(),this.dispatched=!1,this.targets=new r8,this.ignoreTargets=new r8,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(so.runAndSubscribe(nf,({window:e,disposables:i})=>{i.add(ng(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),i.add(ng(e.document,"touchend",i=>this.onTouchEnd(e,i))),i.add(ng(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:r6,disposables:this._store}))}static addTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),r1(e.INSTANCE.targets.push(i))):r3.None}static ignoreTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),r1(e.INSTANCE.ignoreTargets.push(i))):r3.None}static isTouchDevice(){return"ontouchstart"in r6||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,s=e.targetTouches.length;r<s;r++){let s=e.targetTouches.item(r);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:i,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[i],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let n=this.newGestureEvent(n2.Start,s.target);n.pageX=s.pageX,n.pageY=s.pageY,this.dispatchEvent(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(i,r){let s=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=r.changedTouches.length;o<a;o++){let a=r.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-rX(l.rollingPageX))&&30>Math.abs(l.initialPageY-rX(l.rollingPageY))){let e=this.newGestureEvent(n2.Tap,l.initialTarget);e.pageX=rX(l.rollingPageX),e.pageY=rX(l.rollingPageY),this.dispatchEvent(e)}else if(h>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-rX(l.rollingPageX))&&30>Math.abs(l.initialPageY-rX(l.rollingPageY))){let e=this.newGestureEvent(n2.Contextmenu,l.initialTarget);e.pageX=rX(l.rollingPageX),e.pageY=rX(l.rollingPageY),this.dispatchEvent(e)}else if(1===n){let e=rX(l.rollingPageX),r=rX(l.rollingPageY),n=rX(l.rollingTimestamps)-l.rollingTimestamps[0],o=e-l.rollingPageX[0],a=r-l.rollingPageY[0],h=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(i,h,s,Math.abs(o)/n,o>0?1:-1,e,Math.abs(a)/n,a>0?1:-1,r)}this.dispatchEvent(this.newGestureEvent(n2.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let r=document.createEvent("CustomEvent");return r.initEvent(e,!1,!0),r.initialTarget=i,r.tapCount=0,r}dispatchEvent(i){if(i.type===n2.Tap){let r=new Date().getTime(),s=0;s=r-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=r,i.tapCount=s}else(i.type===n2.Change||i.type===n2.Contextmenu)&&(this._lastSetTapCountTime=0);if(i.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(i.initialTarget))return;let e=[];for(let r of this.targets)if(r.contains(i.initialTarget)){let s=0,n=i.initialTarget;for(;n&&n!==r;)s++,n=n.parentElement;e.push([s,r])}for(let[r,s]of(e.sort((e,i)=>e[0]-i[0]),e))s.dispatchEvent(i),this.dispatched=!0}}inertia(i,r,s,n,o,a,l,h,c){this.handle=n1(i,()=>{let d=Date.now(),u=d-s,f=0,p=0,_=!0;n+=e.SCROLL_FRICTION*u,l+=e.SCROLL_FRICTION*u,n>0&&(_=!1,f=o*n*u),l>0&&(_=!1,p=h*l*u);let m=this.newGestureEvent(n2.Change);m.translationX=f,m.translationY=p,r.forEach(e=>e.dispatchEvent(m)),_||this.inertia(i,r,d,n,o,a+f,l,h,c+p)})}onTouchMove(e){let i=Date.now();for(let r=0,s=e.changedTouches.length;r<s;r++){let s=e.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let n=this.activeTouches[s.identifier],o=this.newGestureEvent(n2.Change,n.initialTarget);o.translationX=s.pageX-rX(n.rollingPageX),o.translationY=s.pageY-rX(n.rollingPageY),o.pageX=s.pageX,o.pageY=s.pageY,this.dispatchEvent(o),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(s.pageX),n.rollingPageY.push(s.pageY),n.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};nN.SCROLL_FRICTION=-.005,nN.HOLD_DELAY=700,nN.CLEAR_TAP_COUNT_TIME=400,ra([function(e,i,r){let s=null,n=null;if("function"==typeof r.value?(s="value",0!==(n=r.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof r.get&&(s="get",n=r.get),!n)throw Error("not supported");let o=`$memoize$${i}`;r[s]=function(...e){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,e)}),this[o]}}],nN,"isTouchDevice",1);var nR=class extends r3{onclick(e,i){this._register(ng(e,nS.CLICK,r=>i(new s6(no(e),r))))}onmousedown(e,i){this._register(ng(e,nS.MOUSE_DOWN,r=>i(new s6(no(e),r))))}onmouseover(e,i){this._register(ng(e,nS.MOUSE_OVER,r=>i(new s6(no(e),r))))}onmouseleave(e,i){this._register(ng(e,nS.MOUSE_LEAVE,r=>i(new s6(no(e),r))))}onkeydown(e,i){this._register(ng(e,nS.KEY_DOWN,e=>i(new s5(e))))}onkeyup(e,i){this._register(ng(e,nS.KEY_UP,e=>i(new s5(e))))}oninput(e,i){this._register(ng(e,nS.INPUT,i))}onblur(e,i){this._register(ng(e,nS.BLUR,i))}onfocus(e,i){this._register(ng(e,nS.FOCUS,i))}onchange(e,i){this._register(ng(e,nS.CHANGE,i))}ignoreGesture(e){return nN.ignoreTarget(e)}},nj=class extends nR{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new nE),this._register(nv(this.bgDomNode,nS.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(nv(this.domNode,nS.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new nx),this._pointerdownScheduleRepeatTimer=this._register(new ne)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,no(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(i,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},nT=class e{constructor(e,i,r,s,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i|=0,r|=0,s|=0,n|=0,o|=0,a|=0),this.rawScrollLeft=s,this.rawScrollTop=a,i<0&&(i=0),s+i>r&&(s=r-i),s<0&&(s=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=r,this.scrollLeft=s,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(i,r){return new e(this._forceIntegerValues,"u">typeof i.width?i.width:this.width,"u">typeof i.scrollWidth?i.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,"u">typeof i.height?i.height:this.height,"u">typeof i.scrollHeight?i.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(i){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof i.scrollLeft?i.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof i.scrollTop?i.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let r=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:s,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},nD=class extends r3{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new sf),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new nT(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,i){let r=this._state.withScrollDimensions(e,i);this._setState(r,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let i=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(i,!1)}setScrollPositionSmooth(e,i){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let r;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;r=i?new nP(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=nP.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),i=this._state.withScrollPosition(e);if(this._setState(i,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,i){let r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,i)))}},nM=class{constructor(e,i,r){this.scrollLeft=e,this.scrollTop=i,this.isDone=r}};function nL(e,i){let r=i-e;return function(i){return e+r*(1-Math.pow(1-i,3))}}var nP=class e{constructor(e,i,r,s){this.from=e,this.to=i,this.duration=s,this.startTime=r,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(e,i,r){if(Math.abs(e-i)>2.5*r){var s,n;let o,a;return e<i?(o=e+.75*r,a=i-.75*r):(o=e-.75*r,a=i+.75*r),s=nL(e,o),n=nL(a,i),function(e){return e<.33?s(e/.33):n((e-.33)/(1-.33))}}return nL(e,i)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let i=(e-this.startTime)/this.duration;return i<1?new nM(this.scrollLeft(i),this.scrollTop(i),!1):new nM(this.to.scrollLeft,this.to.scrollTop,!0)}combine(i,r,s){return e.start(i,r,s)}static start(i,r,s){return s+=10,new e(i,r,Date.now()-10,s)}},nA=class extends r3{constructor(e,i,r){super(),this._visibility=e,this._visibleClassName=i,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new ne)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){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(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},nB=class extends nR{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nA(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new nE),this._shouldRender=!0,this.domNode=nk(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(ng(this.domNode.domNode,nS.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let i=this._register(new nj(e));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(e,i,r,s){this.slider=nk(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(i),"number"==typeof r&&this.slider.setWidth(r),"number"==typeof s&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ng(this.slider.domNode,nS.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let i=this.domNode.domNode.getClientRects()[0].top,r=i+this._scrollbarState.getSliderPosition(),s=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);r<=n&&n<=s?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let i,r;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)i=e.offsetX,r=e.offsetY;else{var s;let n,o,a=(n=(s=this.domNode.domNode).getBoundingClientRect(),o=no(s),{left:n.left+o.scrollX,top:n.top+o.scrollY,width:n.width,height:n.height});i=e.pageX-a.left,r=e.pageY-a.top}let n=this._pointerDownRelativePosition(i,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let n=Math.abs(this._sliderOrthogonalPointerPosition(e)-r);if(sL&&n>140)return void this._setDesiredScrollPositionNow(s.getScrollPosition());let o=this._sliderPointerPosition(e)-i;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let i={};this.writeScrollPosition(i,e),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},nI=class e{constructor(e,i,r,s,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i&&(this._visibleSize=i,this._refreshComputedValues(),!0)}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i&&(this._scrollSize=i,this._refreshComputedValues(),!0)}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i&&(this._scrollPosition=i,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,r,s,n){let o=Math.max(0,r-e),a=Math.max(0,o-2*i),l=s>0&&s>r;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(r*a/s))),c=(a-h)/(s-r);return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(n*c)}}_refreshComputedValues(){let i=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=i.computedAvailableSize,this._computedIsNeeded=i.computedIsNeeded,this._computedSliderSize=i.computedSliderSize,this._computedSliderRatio=i.computedSliderRatio,this._computedSliderPosition=i.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(e){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,r=this._scrollPosition;return i<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},nO=class extends nB{constructor(e,i,r){let s=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:r,scrollbarState:new nI(i.horizontalHasArrows?i.arrowSize:0,2===i.horizontal?0:i.horizontalScrollbarSize,2===i.vertical?0:i.verticalScrollbarSize,s.width,s.scrollWidth,n.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(e,i){this.slider.setWidth(e),this.slider.setLeft(i)}_renderDomNode(e,i){this.domNode.setWidth(e),this.domNode.setHeight(i),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,i){e.scrollLeft=i}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},nF=class extends nB{constructor(e,i,r){let s=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:r,scrollbarState:new nI(i.verticalHasArrows?i.arrowSize:0,2===i.vertical?0:i.verticalScrollbarSize,0,s.height,s.scrollHeight,n.scrollTop),visibility:i.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:i.scrollByPage}),i.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((i.verticalScrollbarSize-i.verticalSliderSize)/2),i.verticalSliderSize,void 0)}_updateSlider(e,i){this.slider.setHeight(e),this.slider.setTop(i)}_renderDomNode(e,i){this.domNode.setWidth(i),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return i}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,i){e.scrollTop=i}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},nH=class{constructor(e,i,r){this.timestamp=e,this.deltaX=i,this.deltaY=r,this.score=0}},nz=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,i=0,r=1,s=this._rear;for(;;){let n=s===this._front?e:Math.pow(2,-r);if(e-=n,i+=this._memory[s].score*n,s===this._front)break;s=(this._capacity+s-1)%this._capacity,r++}return i<=.5}acceptStandardWheelEvent(e){if(sx){var i;let r=(i=no(e.browserEvent),s_.INSTANCE.getZoomFactor(i));this.accept(Date.now(),e.deltaX*r,e.deltaY*r)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,i,r){let s=null,n=new nH(e,i,r);-1===this._front&&-1===this._rear?(this._memory[0]=n,this._front=0,this._rear=0):(s=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]=n),n.score=this._computeScore(n,s)}_computeScore(e,i){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let r=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(r+=.25),i){let s=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(s,o),1),h=Math.max(Math.min(n,a),1),c=Math.max(n,a);Math.max(s,o)%l==0&&c%h==0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};nz.INSTANCE=new nz;var n$=class extends nR{constructor(e,i,r){super(),this._onScroll=this._register(new sf),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new sf),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let i={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return i.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:i.horizontalScrollbarSize,i.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:i.verticalScrollbarSize,sP&&(i.className+=" mac"),i}(i),this._scrollable=r,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let s={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new nF(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new nO(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=nk(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=nk(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=nk(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,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new ne),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=r0(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,sP&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new s9(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=r0(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new s9(e))};this._mouseWheelToDispose.push(ng(this._listenOnDomNode,nS.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let i=nz.INSTANCE;i.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let s=e.deltaY*this._options.mouseWheelScrollSensitivity,n=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+s===0?n=s=0:Math.abs(s)>=Math.abs(n)?n=0:s=0),this._options.flipAxes&&([s,n]=[n,s]);let o=!sP&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=s,s=0),e.browserEvent&&e.browserEvent.altKey&&(n*=this._options.fastScrollSensitivity,s*=this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(s){let e=50*s,i=a.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,i)}if(n){let e=50*n,i=a.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,i)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),r=!0)}let s=r;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),i=e.scrollTop>0,r=e.scrollLeft>0,s=r?" left":"",n=i?" top":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${r||i?" top-left-corner":""}${n}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){this._mouseIsOver||this._isDragging||(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){this._mouseIsOver||this._isDragging||this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},nW=class extends n${constructor(e,i,r){super(e,i,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},nU=class extends r3{constructor(e,i,r,s,n,o,a,l){super(),this._bufferService=r,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new sf),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new nD({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>n1(s.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new nW(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(so.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(r1(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(r1(()=>this._styleElement.remove())),this._register(so.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
12
- `)})),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(e=>this._handleScroll(e)))}scrollLines(e){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,i){i&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:e*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(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=i-this._bufferService.buffer.ydisp;0!==r&&(this._latestYDisp=i,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};nU=ra([rl(2,rk),rl(3,rI),rl(4,rE),rl(5,r$),rl(6,rD),rl(7,rF)],nU);var nK=class extends r3{constructor(e,i,r,s,n){super(),this._screenElement=e,this._bufferService=i,this._coreBrowserService=r,this._decorationService=s,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(r1(()=>{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 e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let r=e.options.x??0;return r&&r>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(e,i),i}_refreshStyle(e){let i=e.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${i*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,i=e.element){if(!i)return;let r=e.options.x??0;"right"===(e.options.anchor||"left")?i.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":i.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};nK=ra([rl(1,rk),rl(2,rI),rl(3,rP),rl(4,rF)],nK);var nq=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let i of this._zones)if(i.color===e.options.overviewRulerOptions.color&&i.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,e.marker.line))return;if(this._lineAdjacentToZone(i,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(i,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,i){return i>=e.startBufferLine&&i<=e.endBufferLine}_lineAdjacentToZone(e,i,r){return i>=e.startBufferLine-this._linePadding[r||"full"]&&i<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,i){e.startBufferLine=Math.min(e.startBufferLine,i),e.endBufferLine=Math.max(e.endBufferLine,i)}},nV={full:0,left:0,center:0,right:0},nY={full:0,left:0,center:0,right:0},nG={full:0,left:0,center:0,right:0},nX=class extends r3{constructor(e,i,r,s,n,o,a,l){super(),this._viewportElement=e,this._screenElement=i,this._bufferService=r,this._decorationService=s,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new nq,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(r1(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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 e=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);nY.full=this._canvas.width,nY.left=e,nY.center=i,nY.right=e,this._refreshDrawHeightConstants(),nG.full=1,nG.left=1,nG.center=1+nY.left,nG.right=1+nY.left+nY.center}_refreshDrawHeightConstants(){nV.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);nV.left=e,nV.center=e,nV.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nV.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nV.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nV.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nV.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 e 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(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let i of e)"full"!==i.position&&this._renderColorZone(i);for(let i of e)"full"===i.position&&this._renderColorZone(i);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(nG[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-nV[e.position||"full"]/2),nY[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+nV[e.position||"full"]))}_queueRefresh(e,i){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};nX=ra([rl(2,rk),rl(3,rP),rl(4,rF),rl(5,rD),rl(6,r$),rl(7,rI)],nX),(u=n5||={}).NUL="\0",u.SOH="\x01",u.STX="\x02",u.ETX="\x03",u.EOT="\x04",u.ENQ="\x05",u.ACK="\x06",u.BEL="\x07",u.BS="\b",u.HT=" ",u.LF=`
13
- `,u.VT="\v",u.FF="\f",u.CR="\r",u.SO="\x0e",u.SI="\x0f",u.DLE="\x10",u.DC1="\x11",u.DC2="\x12",u.DC3="\x13",u.DC4="\x14",u.NAK="\x15",u.SYN="\x16",u.ETB="\x17",u.CAN="\x18",u.EM="\x19",u.SUB="\x1a",u.ESC="\x1b",u.FS="\x1c",u.GS="\x1d",u.RS="\x1e",u.US="\x1f",u.SP=" ",u.DEL="",(f=n3||={}).PAD="€",f.HOP="",f.BPH="‚",f.NBH="ƒ",f.IND="„",f.NEL="…",f.SSA="†",f.ESA="‡",f.HTS="ˆ",f.HTJ="‰",f.VTS="Š",f.PLD="‹",f.PLU="Œ",f.RI="",f.SS2="Ž",f.SS3="",f.DCS="",f.PU1="‘",f.PU2="’",f.STS="“",f.CCH="”",f.MW="•",f.SPA="–",f.EPA="—",f.SOS="˜",f.SGCI="™",f.SCI="š",f.CSI="›",f.ST="œ",f.OSC="",f.PM="ž",f.APC="Ÿ",(n4||={}).ST=`${n5.ESC}\\`;var nJ=class{constructor(e,i,r,s,n,o){this._textarea=e,this._compositionView=i,this._bufferService=r,this._optionsService=s,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let i;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(i=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let i=this._textarea.value,r=i.replace(e,"");this._dataAlreadySent=r,i.length>e.length?this._coreService.triggerDataEvent(r,!0):i.length<e.length?this._coreService.triggerDataEvent(`${n5.DEL}`,!0):i.length===e.length&&i!==e&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};nJ=ra([rl(2,rk),rl(3,rD),rl(4,rN),rl(5,rF)],nJ);var nQ,nZ,n0,n1,n2,n5,n3,n4,n6,n9=0,n8=0,n7=0,oe=0,ot={css:"#00000000",rgba:0};(aH=n6||={}).toCss=function(e,i,r,s){return void 0!==s?`#${oh(e)}${oh(i)}${oh(r)}${oh(s)}`:`#${oh(e)}${oh(i)}${oh(r)}`},aH.toRgba=function(e,i,r,s=255){return(e<<24|i<<16|r<<8|s)>>>0},aH.toColor=function(e,i,r,s){return{css:aH.toCss(e,i,r,s),rgba:aH.toRgba(e,i,r,s)}};var oi=az||={};function or(e,i){return oe=Math.round(255*i),[n9,n8,n7]=aU.toChannels(e.rgba),{css:n6.toCss(n9,n8,n7,oe),rgba:n6.toRgba(n9,n8,n7,oe)}}oi.blend=function(e,i){if(1==(oe=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let r=i.rgba>>24&255,s=i.rgba>>16&255,n=i.rgba>>8&255,o=e.rgba>>24&255,a=e.rgba>>16&255,l=e.rgba>>8&255;return n9=o+Math.round((r-o)*oe),n8=a+Math.round((s-a)*oe),n7=l+Math.round((n-l)*oe),{css:n6.toCss(n9,n8,n7),rgba:n6.toRgba(n9,n8,n7)}},oi.isOpaque=function(e){return(255&e.rgba)==255},oi.ensureContrastRatio=function(e,i,r){let s=aU.ensureContrastRatio(e.rgba,i.rgba,r);if(s)return n6.toColor(s>>24&255,s>>16&255,s>>8&255)},oi.opaque=function(e){let i=(255|e.rgba)>>>0;return[n9,n8,n7]=aU.toChannels(i),{css:n6.toCss(n9,n8,n7),rgba:i}},oi.opacity=or,oi.multiplyOpacity=function(e,i){return oe=255&e.rgba,or(e,oe*i/255)},oi.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let i,r;try{let e=document.createElement("canvas");e.width=1,e.height=1;let s=e.getContext("2d",{willReadFrequently:!0});s&&((i=s).globalCompositeOperation="copy",r=i.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return n9=parseInt(e.slice(1,2).repeat(2),16),n8=parseInt(e.slice(2,3).repeat(2),16),n7=parseInt(e.slice(3,4).repeat(2),16),n6.toColor(n9,n8,n7);case 5:return n9=parseInt(e.slice(1,2).repeat(2),16),n8=parseInt(e.slice(2,3).repeat(2),16),n7=parseInt(e.slice(3,4).repeat(2),16),oe=parseInt(e.slice(4,5).repeat(2),16),n6.toColor(n9,n8,n7,oe);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let s=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return n9=parseInt(s[1]),n8=parseInt(s[2]),n7=parseInt(s[3]),oe=Math.round((void 0===s[5]?1:parseFloat(s[5]))*255),n6.toColor(n9,n8,n7,oe);if(!i||!r||(i.fillStyle=r,i.fillStyle=e,"string"!=typeof i.fillStyle)||(i.fillRect(0,0,1,1),[n9,n8,n7,oe]=i.getImageData(0,0,1,1).data,255!==oe))throw Error("css.toColor: Unsupported css format");return{rgba:n6.toRgba(n9,n8,n7,oe),css:e}}})(a$||={});var os=aW||={};function on(e,i,r){let s=e/255,n=i/255,o=r/255;return .2126*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}os.relativeLuminance=function(e){return on(e>>16&255,e>>8&255,255&e)},os.relativeLuminance2=on;var oo=aU||={};function oa(e,i,r){let s=e>>24&255,n=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,h=i>>8&255,c=oc(aW.relativeLuminance2(a,l,h),aW.relativeLuminance2(s,n,o));for(;c<r&&(a>0||l>0||h>0);)a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h-=Math.max(0,Math.ceil(.1*h)),c=oc(aW.relativeLuminance2(a,l,h),aW.relativeLuminance2(s,n,o));return(a<<24|l<<16|h<<8|255)>>>0}function ol(e,i,r){let s=e>>24&255,n=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,h=i>>8&255,c=oc(aW.relativeLuminance2(a,l,h),aW.relativeLuminance2(s,n,o));for(;c<r&&(a<255||l<255||h<255);)a=Math.min(255,a+Math.ceil((255-a)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),h=Math.min(255,h+Math.ceil((255-h)*.1)),c=oc(aW.relativeLuminance2(a,l,h),aW.relativeLuminance2(s,n,o));return(a<<24|l<<16|h<<8|255)>>>0}function oh(e){let i=e.toString(16);return i.length<2?"0"+i:i}function oc(e,i){return e<i?(i+.05)/(e+.05):(e+.05)/(i+.05)}oo.blend=function(e,i){if(1==(oe=(255&i)/255))return i;let r=e>>24&255,s=e>>16&255,n=e>>8&255;return n9=r+Math.round(((i>>24&255)-r)*oe),n8=s+Math.round(((i>>16&255)-s)*oe),n7=n+Math.round(((i>>8&255)-n)*oe),n6.toRgba(n9,n8,n7)},oo.ensureContrastRatio=function(e,i,r){let s=aW.relativeLuminance(e>>8),n=aW.relativeLuminance(i>>8);if(oc(s,n)<r){if(n<s){let n=oa(e,i,r),o=oc(s,aW.relativeLuminance(n>>8));if(o<r){let a=ol(e,i,r);return o>oc(s,aW.relativeLuminance(a>>8))?n:a}return n}let o=ol(e,i,r),a=oc(s,aW.relativeLuminance(o>>8));if(a<r){let n=oa(e,i,r);return a>oc(s,aW.relativeLuminance(n>>8))?o:n}return o}},oo.reduceLuminance=oa,oo.increaseLuminance=ol,oo.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var od=class extends rv{constructor(e,i,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=i,this._width=r}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ou=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rb}register(e){let i={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(i),i.id}deregister(e){for(let i=0;i<this._characterJoiners.length;i++)if(this._characterJoiners[i].id===e)return this._characterJoiners.splice(i,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let i=this._bufferService.buffer.lines.get(e);if(!i||0===i.length)return[];let r=[],s=i.translateToString(!0),n=0,o=0,a=0,l=i.getFg(0),h=i.getBg(0);for(let e=0;e<i.getTrimmedLength();e++)if(i.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==h){if(e-n>1){let e=this._getJoinedRanges(s,a,o,i,n);for(let i=0;i<e.length;i++)r.push(e[i])}n=e,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||1}if(this._bufferService.cols-n>1){let e=this._getJoinedRanges(s,a,o,i,n);for(let i=0;i<e.length;i++)r.push(e[i])}return r}_getJoinedRanges(e,i,r,s,n){let o=e.substring(i,r),a=[];try{a=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let i=this._characterJoiners[e].handler(o);for(let e=0;e<i.length;e++)ou._mergeRanges(a,i[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,s,n),a}_stringRangesToCellRanges(e,i,r){let s=0,n=!1,o=0,a=e[0];if(a){for(let l=r;l<this._bufferService.cols;l++){let r=i.getWidth(l),h=i.getString(l).length||1;if(0!==r){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,!(a=e[++s]))break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,i){let r=!1;for(let s=0;s<e.length;s++){let n=e[s];if(r){if(i[1]<=n[0])return e[s-1][1]=i[1],e;if(i[1]<=n[1])return e[s-1][1]=Math.max(i[1],n[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(i[1]<=n[0])return e.splice(s,0,i),e;if(i[1]<=n[1])return n[0]=Math.min(i[0],n[0]),e;i[0]<n[1]&&(n[0]=Math.min(i[0],n[0]),r=!0);continue}}return r?e[e.length-1][1]=i[1]:e.push(i),e}};function of(){return{width:0,height:0}}ou=ra([rl(0,rk)],ou);var op=class{constructor(e,i,r,s,n,o,a){this._document=e,this._characterJoinerService=i,this._optionsService=r,this._coreBrowserService=s,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new rb,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,i,r){this._selectionStart=e,this._selectionEnd=i,this._columnSelectMode=r}createRow(e,i,r,s,n,o,a,l,h,c,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(i),p=this._themeService.colors,_=e.getNoBgTrimmedLength();r&&_<o+1&&(_=o+1);let m,g=0,v="",x=0,b=0,y=0,S=0,w=!1,C=0,k=!1,E=0,N=0,R=[],j=-1!==c&&-1!==d;for(let T=0;T<_;T++){let _;e.loadCell(T,this._workCell);let D=this._workCell.getWidth();if(0===D)continue;let M=!1,L=T>=N,P=T,A=this._workCell;if(f.length>0&&T===f[0][0]&&L){let s=f.shift(),n=this._isCellInSelection(s[0],i);for(x=s[0]+1;x<s[1];x++)L&&=n===this._isCellInSelection(x,i);(L&&=!r||o<s[0]||o>=s[1])?(M=!0,A=new od(this._workCell,e.translateToString(!0,s[0],s[1]),s[1]-s[0]),P=s[1]-1,D=A.getWidth()):N=s[1]}let B=this._isCellInSelection(T,i),I=r&&T===o,O=j&&T>=c&&T<=d,F=!1;this._decorationService.forEachDecorationAtCell(T,i,void 0,e=>{F=!0});let H=A.getChars()||" ";if(" "===H&&(A.isUnderline()||A.isOverline())&&(H=" "),E=D*l-h.get(H,A.isBold(),A.isItalic()),m)if(g&&(B&&k||!B&&!k&&A.bg===b)&&(B&&k&&p.selectionForeground||A.fg===y)&&A.extended.ext===S&&O===w&&E===C&&!I&&!M&&!F&&L){A.isInvisible()?v+=" ":v+=H,g++;continue}else g&&(m.textContent=v),m=this._document.createElement("span"),g=0,v="";else m=this._document.createElement("span");if(b=A.bg,y=A.fg,S=A.extended.ext,w=O,C=E,k=B,M&&o>=T&&o<=P&&(o=T),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(R.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&R.push("xterm-cursor-blink"),R.push("bar"===s?"xterm-cursor-bar":"underline"===s?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":R.push("xterm-cursor-outline");break;case"block":R.push("xterm-cursor-block");break;case"bar":R.push("xterm-cursor-bar");break;case"underline":R.push("xterm-cursor-underline")}}if(A.isBold()&&R.push("xterm-bold"),A.isItalic()&&R.push("xterm-italic"),A.isDim()&&R.push("xterm-dim"),v=A.isInvisible()?" ":A.getChars()||" ",A.isUnderline()&&(R.push(`xterm-underline-${A.extended.underlineStyle}`)," "===v&&(v=" "),!A.isUnderlineColorDefault()))if(A.isUnderlineColorRGB())m.style.textDecorationColor=`rgb(${rv.toColorRGB(A.getUnderlineColor()).join(",")})`;else{let e=A.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&A.isBold()&&e<8&&(e+=8),m.style.textDecorationColor=p.ansi[e].css}A.isOverline()&&(R.push("xterm-overline")," "===v&&(v=" ")),A.isStrikethrough()&&R.push("xterm-strikethrough"),O&&(m.style.textDecoration="underline");let z=A.getFgColor(),$=A.getFgColorMode(),W=A.getBgColor(),U=A.getBgColorMode(),K=!!A.isInverse();if(K){let e=z;z=W,W=e;let i=$;$=U,U=i}let q,V,Y=!1;switch(this._decorationService.forEachDecorationAtCell(T,i,void 0,e=>{"top"!==e.options.layer&&Y||(e.backgroundColorRGB&&(U=0x3000000,W=e.backgroundColorRGB.rgba>>8&0xffffff,q=e.backgroundColorRGB),e.foregroundColorRGB&&($=0x3000000,z=e.foregroundColorRGB.rgba>>8&0xffffff,V=e.foregroundColorRGB),Y="top"===e.options.layer)}),!Y&&B&&(W=(q=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,U=0x3000000,Y=!0,p.selectionForeground&&($=0x3000000,z=p.selectionForeground.rgba>>8&0xffffff,V=p.selectionForeground)),Y&&R.push("xterm-decoration-top"),U){case 0x1000000:case 0x2000000:_=p.ansi[W],R.push(`xterm-bg-${W}`);break;case 0x3000000:_=n6.toColor(W>>16,W>>8&255,255&W),this._addStyle(m,`background-color:#${o_((W>>>0).toString(16),"0",6)}`);break;default:K?(_=p.foreground,R.push("xterm-bg-257")):_=p.background}switch(q||A.isDim()&&(q=az.multiplyOpacity(_,.5)),$){case 0x1000000:case 0x2000000:A.isBold()&&z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(z+=8),this._applyMinimumContrast(m,_,p.ansi[z],A,q,void 0)||R.push(`xterm-fg-${z}`);break;case 0x3000000:let G=n6.toColor(z>>16&255,z>>8&255,255&z);this._applyMinimumContrast(m,_,G,A,q,V)||this._addStyle(m,`color:#${o_(z.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(m,_,p.foreground,A,q,V)||K&&R.push("xterm-fg-257")}R.length&&(m.className=R.join(" "),R.length=0),I||M||F||!L?m.textContent=v:g++,E!==this.defaultSpacing&&(m.style.letterSpacing=`${E}px`),u.push(m),T=P}return m&&g&&(m.textContent=v),u}_applyMinimumContrast(e,i,r,s,n,o){var a,l,h;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=a=s.getCode())&&l<=57558||9472<=(h=a)&&h<=9631)return!1;let c=this._getContrastCache(s),d;if(n||o||(d=c.getColor(i.rgba,r.rgba)),void 0===d){let e=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=az.ensureContrastRatio(n||i,o||r,e),c.setColor((n||i).rgba,(o||r).rgba,d??null)}return!!d&&(this._addStyle(e,`color:${d.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,i){e.setAttribute("style",`${e.getAttribute("style")||""}${i};`)}_isCellInSelection(e,i){let r=this._selectionStart,s=this._selectionEnd;return!!r&&!!s&&(this._columnSelectMode?r[0]<=s[0]?e>=r[0]&&i>=r[1]&&e<s[0]&&i<=s[1]:e<r[0]&&i>=r[1]&&e>=s[0]&&i<=s[1]:i>r[1]&&i<s[1]||r[1]===s[1]&&i===r[1]&&e>=r[0]&&e<s[0]||r[1]<s[1]&&i===s[1]&&e<s[0]||r[1]<s[1]&&i===r[1]&&e>=r[0])}};function o_(e,i,r){for(;e.length<r;)e=i+e;return e}op=ra([rl(1,rz),rl(2,rD),rl(3,rI),rl(4,rN),rl(5,rP),rl(6,r$)],op);var om=class{constructor(e,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let r=e.createElement("span");r.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[r,s,n,o],this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(o),i.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,i,r,s){e===this._font&&i===this._fontSize&&r===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=i,this._weight=r,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,i,r){let s=0;if(!i&&!r&&1===e.length&&(s=e.charCodeAt(0))<256){if(-9999!==this._flat[s])return this._flat[s];let i=this._measure(e,0);return i>0&&(this._flat[s]=i),i}let n=e;i&&(n+="B"),r&&(n+="I");let o=this._holey.get(n);if(void 0===o){let s=0;i&&(s|=1),r&&(s|=2),(o=this._measure(e,s))>0&&this._holey.set(n,o)}return o}_measure(e,i){let r=this._measureElements[i];return r.textContent=e.repeat(32),r.offsetWidth/32}},og=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,i,r,s=!1){if(this.selectionStart=i,this.selectionEnd=r,!i||!r||i[0]===r[0]&&i[1]===r[1])return void this.clear();let n=e.buffers.active.ydisp,o=i[1]-n,a=r[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);l>=e.rows||h<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=i[0],this.endCol=r[0])}isCellSelected(e,i,r){return!!this.hasSelection&&(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?i>=this.startCol&&r>=this.viewportCappedStartRow&&i<this.endCol&&r<=this.viewportCappedEndRow:i<this.startCol&&r>=this.viewportCappedStartRow&&i>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&i>=this.startCol&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&i>=this.startCol)}},ov="xterm-dom-renderer-owner-",ox="xterm-rows",ob="xterm-fg-",oy="xterm-bg-",oS="xterm-focus",ow="xterm-selection",oC=1,ok=class extends r3{constructor(e,i,r,s,n,o,a,l,h,c,d,u,f,p){super(),this._terminal=e,this._document=i,this._element=r,this._screenElement=s,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=p,this._terminalClass=oC++,this._rowElements=[],this._selectionRenderModel=new og,this.onRequestRedraw=this._register(new sf).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ox),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(ow),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:of(),cell:of()},device:{canvas:of(),cell:of(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(op,document),this._element.classList.add(ov+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(r1(()=>{this._element.classList.remove(ov+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new om(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;for(let i of(this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows,this._rowElements))i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let i=`${this._terminalSelector} .${ox} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=i,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let i=`${this._terminalSelector} .${ox} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;i+=`${this._terminalSelector} .${ox} .xterm-dim { color: ${az.multiplyOpacity(e.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 r=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;for(let[o,a]of(i+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}@keyframes ${s} { 50% { box-shadow: none; }}@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${ox}.${oS} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ox}.${oS} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ox}.${oS} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${ox} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ox} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ox} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ox} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ox} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${ow} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ow} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ow} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))i+=`${this._terminalSelector} .${ob}${o} { color: ${a.css}; }${this._terminalSelector} .${ob}${o}.xterm-dim { color: ${az.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${oy}${o} { background-color: ${a.css}; }`;i+=`${this._terminalSelector} .${ob}257 { color: ${az.opaque(e.background).css}; }${this._terminalSelector} .${ob}257.xterm-dim { color: ${az.multiplyOpacity(az.opaque(e.background),.5).css}; }${this._terminalSelector} .${oy}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=i}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,i){for(let e=this._rowElements.length;e<=i;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,i){this._refreshRowElements(e,i),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(oS),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(oS),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,i,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,i,r),this.renderRows(0,this._bufferService.rows-1),!e||!i||(this._selectionRenderModel.update(this._terminal,e,i,r),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(r){let r=e[0]>i[0];l.appendChild(this._createSelectionElement(o,r?i[0]:e[0],r?e[0]:i[0],a-o+1))}else{let r=s===o?e[0]:0,h=o===n?i[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(o,r,h)),l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,a-o-1)),o!==a){let e=n===a?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,i,r,s=1){let n=this._document.createElement("div"),o=i*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(r-i);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${s*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,i){let r=this._bufferService.buffer,s=r.ybase+r.y,n=Math.min(r.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=i;h++){let e=h+r.ydisp,i=this._rowElements[h],c=r.lines.get(e);if(!i||!c)break;i.replaceChildren(...this._rowFactory.createRow(c,e,e===s,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${ov}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,i,r,s,n,o){r<0&&(e=0),s<0&&(i=0);let a=this._bufferService.rows-1;r=Math.max(Math.min(r,a),0),s=Math.max(Math.min(s,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=r;a<=s;++a){let p=a+l.ydisp,_=this._rowElements[a],m=l.lines.get(p);if(!_||!m)break;_.replaceChildren(...this._rowFactory.createRow(m,p,p===h,u,f,c,d,this.dimensions.css.cell.width,this._widthCache,o?a===r?e:0:-1,o?(a===s?i:n)-1:-1))}}};ok=ra([rl(7,rj),rl(8,rB),rl(9,rD),rl(10,rk),rl(11,rN),rl(12,rI),rl(13,r$)],ok);var oE=class extends r3{constructor(e,i,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new sf),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new oj(this._optionsService))}catch{this._measureStrategy=this._register(new oR(e,i,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};oE=ra([rl(2,rD)],oE);var oN=class extends r3{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,i){void 0!==e&&e>0&&void 0!==i&&i>0&&(this._result.width=e,this._result.height=i)}},oR=class extends oN{constructor(e,i,r){super(),this._document=e,this._parentElement=i,this._optionsService=r,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}},oj=class extends oN{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let i=this._ctx.measureText("W");if(!("width"in i&&"fontBoundingBoxAscent"in i&&"fontBoundingBoxDescent"in i))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},oT=class extends r3{constructor(e,i,r){super(),this._textarea=e,this._window=i,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new oD(this._window)),this._onDprChange=this._register(new sf),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new sf),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(so.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ng(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ng(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},oD=class extends r3{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new r4),this._onDprChange=this._register(new sf),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(r1(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ng(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)}},oM=class extends r3{constructor(){super(),this.linkProviders=[],this._register(r1(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let i=this.linkProviders.indexOf(e);-1!==i&&this.linkProviders.splice(i,1)}}}};function oL(e,i,r){let s=r.getBoundingClientRect(),n=e.getComputedStyle(r),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[i.clientX-s.left-o,i.clientY-s.top-a]}var oP=class{constructor(e,i){this._renderService=e,this._charSizeService=i}getCoords(e,i,r,s,n){return function(e,i,r,s,n,o,a,l,h){if(!o)return;let c=oL(e,i,r);return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),s+ +!!h),c[1]=Math.min(Math.max(c[1],1),n),c}(window,e,i,r,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,i){let r=oL(window,e,i);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};oP=ra([rl(0,rF),rl(1,rB)],oP);var oA=class{constructor(e,i){this._renderCallback=e,this._coreBrowserService=i,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,i,r){this._rowCount=r,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i,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 e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},oB={},oI={getSafariVersion:()=>oK,isChromeOS:()=>oJ,isFirefox:()=>o$,isIpad:()=>oV,isIphone:()=>oY,isLegacyEdge:()=>oW,isLinux:()=>oX,isMac:()=>oq,isNode:()=>oF,isSafari:()=>oU,isWindows:()=>oG};for(var oO in oI)rn(oB,oO,{get:oI[oO],enumerable:!0});var oF="u">typeof rs.default&&"title"in rs.default,oH=oF?"node":navigator.userAgent,oz=oF?"node":navigator.platform,o$=oH.includes("Firefox"),oW=oH.includes("Edge"),oU=/^((?!chrome|android).)*safari/i.test(oH);function oK(){if(!oU)return 0;let e=oH.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var oq=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(oz),oV="iPad"===oz,oY="iPhone"===oz,oG=["Windows","Win16","Win32","WinCE"].includes(oz),oX=oz.indexOf("Linux")>=0,oJ=/\bCrOS\b/.test(oH),oQ=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let i=0,r=0,s=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,1.5*(r=Math.max(i=Math.max(1,performance.now()-i),r))>(n=e.timeRemaining())){s-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-i))}ms`),this._start();return}s=n}this.clear()}},oZ=class extends oQ{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let i=performance.now()+e;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},o0=class extends oQ{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},o1=!oF&&"requestIdleCallback"in window?o0:oZ,o2=class{constructor(){this._queue=new o1}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},o5=class extends r3{constructor(e,i,r,s,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=s,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new r4),this._pausedResizeTask=new o2,this._observerDisposable=this._register(new r4),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 sf),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new sf),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new sf),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new sf),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new oA((e,i)=>this._renderRows(e,i),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new o3(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(r1(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,i)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,i){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});r.observe(i),this._observerDisposable.value=r1(()=>r.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,i,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),i=Math.max(i,s.end)),r||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,i,this._rowCount)}_renderRows(e,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);e=Math.min(e,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(e,i),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:i}),this._onRender.fire({start:e,end:i}),this._isNextRenderRedrawOnly=!0}}resize(e,i){this._rowCount=i,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){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(e,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,i)):this._renderer.value.handleResize(e,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,i,r){this._selectionState.start=e,this._selectionState.end=i,this._selectionState.columnSelectMode=r,this._renderer.value?.handleSelectionChanged(e,i,r)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};o5=ra([rl(2,rD),rl(3,rB),rl(4,rN),rl(5,rP),rl(6,rk),rl(7,rI),rl(8,r$)],o5);var o3=class{constructor(e,i,r){this._coreBrowserService=e,this._coreService=i,this._onTimeout=r,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,i){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,i)):(this._start=e,this._end=i,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 e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function o4(e,i,r,s){return o7(Math.abs(e-o6(e,r)-(i-o6(i,r)))-function(e,i,r){let s=0,n=e-o6(e,r),o=i-o6(i,r);for(let a=0;a<Math.abs(n-o);a++){let o="A"===function(e,i){return e>i?"A":"B"}(e,i)?-1:1;r.buffer.lines.get(n+o*a)?.isWrapped&&s++}return s}(e,i,r),o8(e>i?"A":"B",s))}function o6(e,i){let r=0,s=i.buffer.lines.get(e),n=s?.isWrapped;for(;n&&e>=0&&e<i.rows;)r++,s=i.buffer.lines.get(--e),n=s?.isWrapped;return r}function o9(e,i,r,s,n,o){let a=e,l=i,h="";for(;(a!==r||l!==s)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),e=a=o.cols-1,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function o8(e,i){return n5.ESC+(i?"O":"[")+e}function o7(e,i){e=Math.floor(e);let r="";for(let s=0;s<e;s++)r+=i;return r}var ae=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,i=this.selectionEnd;return!!e&&!!i&&(e[1]>i[1]||e[1]===i[1]&&e[0]>i[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function at(e,i){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return i*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var ai=RegExp(" ","g"),ar=class extends r3{constructor(e,i,r,s,n,o,a,l,h){super(),this._element=e,this._screenElement=i,this._linkifier=r,this._bufferService=s,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rb,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new sf),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new sf),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new sf),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new sf),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new ae(this._bufferService),this._activeSelectionMode=0,this._register(r1(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1])}get selectionText(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!e||!i)return"";let r=this._bufferService.buffer,s=[];if(3===this._activeSelectionMode){if(e[0]===i[0])return"";let n=e[0]<i[0]?e[0]:i[0],o=e[0]<i[0]?i[0]:e[0];for(let a=e[1];a<=i[1];a++){let e=r.translateBufferLineToString(a,!0,n,o);s.push(e)}}else{let n=e[1]===i[1]?i[0]:void 0;s.push(r.translateBufferLineToString(e[1],!0,e[0],n));for(let n=e[1]+1;n<=i[1]-1;n++){let e=r.lines.get(n),i=r.translateBufferLineToString(n,!0);e?.isWrapped?s[s.length-1]+=i:s.push(i)}if(e[1]!==i[1]){let e=r.lines.get(i[1]),n=r.translateBufferLineToString(i[1],!0,0,i[0]);e&&e.isWrapped?s[s.length-1]+=n:s.push(n)}}return s.map(e=>e.replace(ai," ")).join(oG?`\r
15
+ `).trim(),i=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);sc.register(o,i?.[2]??e,o)}return o},this._event}_removeListener(e){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 i=this._listeners,r=i.indexOf(e);if(-1===r)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--,i[r]=void 0;let s=this._deliveryQueue.current===this;if(2*this._size<=i.length){let e=0;for(let r=0;r<i.length;r++)i[r]?i[e++]=i[r]:s&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=e}}_deliver(e,i){if(!e)return;let r=this._options?.onListenerError||rY;try{e.value(i)}catch(e){r(e)}}_deliverQueue(e){let i=e.current._listeners;for(;e.i<e.end;)this._deliver(i[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof sm)this._deliver(this._listeners,e);else{let i=this._deliveryQueue;i.enqueue(this,e,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},sg=class{constructor(){this.i=-1,this.end=0}enqueue(e,i,r){this.i=0,this.end=r,this.current=e,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},sv=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new s_,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new s_,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let r=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(r,e),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let r=this.getWindowId(i);this.mapWindowIdToFullScreen.set(r,e),this._onDidChangeFullscreen.fire(r)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};sv.INSTANCE=new sv,sv.INSTANCE.onDidChangeZoomLevel,sv.INSTANCE.onDidChangeFullscreen;var sx="object"==typeof navigator?navigator.userAgent:"",sb=sx.indexOf("Firefox")>=0,sy=sx.indexOf("AppleWebKit")>=0,sS=sx.indexOf("Chrome")>=0,sw=!sS&&sx.indexOf("Safari")>=0;sx.indexOf("Electron/"),sx.indexOf("Android");var sC=!1;if("function"==typeof r7.matchMedia){let e=r7.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),i=r7.matchMedia("(display-mode: fullscreen)");sC=e.matches,sk=e,"string"==typeof sk&&(sk=r7.matchMedia(sk)),sk.addEventListener("change",({matches:e})=>{sC&&i.matches||(sC=e)})}var sk,sE,sN,sR=!1,sj=!1,sT=!1,sD=!1,sM=!1,sP="en",sL=globalThis;"u">typeof sL.vscode&&"u">typeof sL.vscode.process?sN=sL.vscode.process:"u">typeof ra.default&&"string"==typeof ra.default?.versions?.node&&(sN=ra.default);var sA="string"==typeof sN?.versions?.electron&&sN?.type==="renderer";if("object"==typeof sN){sR="win32"===sN.platform,sj="darwin"===sN.platform,(sT="linux"===sN.platform)&&sN.env.SNAP&&sN.env.SNAP_REVISION,sN.env.CI||sN.env.BUILD_ARTIFACTSTAGINGDIRECTORY,sP="en";let e=sN.env.VSCODE_NLS_CONFIG;if(e)try{let i=JSON.parse(e);i.userLocale,i.osLocale,sP=i.resolvedLanguage||"en",i.languagePack?.translationsConfigFile}catch{}sD=!0}else"object"!=typeof navigator||sA?console.error("Unable to resolve platform."):(sR=(sE=navigator.userAgent).indexOf("Windows")>=0,sj=sE.indexOf("Macintosh")>=0,(sE.indexOf("Macintosh")>=0||sE.indexOf("iPad")>=0||sE.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,sT=sE.indexOf("Linux")>=0,sE?.indexOf("Mobi"),sM=!0,sP=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var sB=sR,sI=sj,sO=sT,sF=sD;sM&&"function"==typeof sL.importScripts&&sL.origin;var sz,sH=sE,s$=sP;(sQ=sz||={}).value=function(){return s$},sQ.isDefaultVariant=function(){return 2===s$.length?"en"===s$:s$.length>=3&&"e"===s$[0]&&"n"===s$[1]&&"-"===s$[2]},sQ.isDefault=function(){return"en"===s$};var sW="function"==typeof sL.postMessage&&!sL.importScripts,sU=(()=>{if(sW){let e=[];sL.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,s=e.length;r<s;r++){let s=e[r];if(s.id===i.data.vscodeScheduleAsyncWork){e.splice(r,1),s.callback();return}}});let i=0;return r=>{let s=++i;e.push({id:s,callback:r}),sL.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})(),sK=!!(sH&&sH.indexOf("Chrome")>=0);sH&&sH.indexOf("Firefox"),!sK&&sH&&sH.indexOf("Safari"),sH&&sH.indexOf("Edg/"),sH&&sH.indexOf("Android");var sq="object"==typeof navigator?navigator:{};sF||document.queryCommandSupported&&document.queryCommandSupported("copy")||sq&&sq.clipboard&&sq.clipboard.writeText,sF||sq&&sq.clipboard&&sq.clipboard.readText,sF||sC||sq.keyboard,"ontouchstart"in r7||sq.maxTouchPoints,r7.PointerEvent&&("ontouchstart"in r7||navigator.maxTouchPoints);var sV=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,i){this._keyCodeToStr[e]=i,this._strToKeyCode[i.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},sY=new sV,sG=new sV,sX=new sV,sJ=Array(230);(sZ=s0||={}).toString=function(e){return sY.keyCodeToStr(e)},sZ.fromString=function(e){return sY.strToKeyCode(e)},sZ.toUserSettingsUS=function(e){return sG.keyCodeToStr(e)},sZ.toUserSettingsGeneral=function(e){return sX.keyCodeToStr(e)},sZ.fromUserSettings=function(e){return sG.strToKeyCode(e)||sX.strToKeyCode(e)},sZ.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return sY.keyCodeToStr(e)};var sQ,sZ,s0,s1,s2=class e{constructor(e,i,r,s,n){this.ctrlKey=e,this.shiftKey=i,this.altKey=r,this.metaKey=s,this.keyCode=n}equals(i){return i instanceof e&&this.ctrlKey===i.ctrlKey&&this.shiftKey===i.shiftKey&&this.altKey===i.altKey&&this.metaKey===i.metaKey&&this.keyCode===i.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",r=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${e}${i}${r}${s}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new s5([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},s5=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let i=0,r=this.chords.length;i<r;i++)0!==i&&(e+=";"),e+=this.chords[i].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let i=0;i<this.chords.length;i++)if(!this.chords[i].equals(e.chords[i]))return!1;return!0}},s3=sI?256:2048,s4=sI?2048:256,s6=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return s0.fromString(i)}let i=e.keyCode;if(3===i)return 7;if(sb)switch(i){case 59:return 85;case 60:if(sO)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(sI)return 57}else if(sy&&(sI&&93===i||!sI&&92===i))return 57;return sJ[i]||0}(e),this.code=e.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(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let i=0;return this.ctrlKey&&(i|=s3),this.altKey&&(i|=512),this.shiftKey&&(i|=1024),this.metaKey&&(i|=s4),i|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new s2(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},s9=new WeakMap,s8=class{static getSameOriginWindowChain(e){let i=s9.get(e);if(!i){i=[],s9.set(e,i);let r=e,s;do(s=function(e){if(!e.parent||e.parent===e)return null;try{let i=e.location,r=e.parent.location;if("null"!==i.origin&&"null"!==r.origin&&i.origin!==r.origin)return null}catch{return null}return e.parent}(r))?i.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):i.push({window:new WeakRef(r),iframeElement:null}),r=s;while(r)}return i.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,i){if(!i||e===i)return{top:0,left:0};let r=0,s=0;for(let n of this.getSameOriginWindowChain(e)){let e=n.window.deref();if(r+=e?.scrollY??0,s+=e?.scrollX??0,e===i||!n.iframeElement)break;let o=n.iframeElement.getBoundingClientRect();r+=o.top,s+=o.left}return{top:r,left:s}}},s7=class{constructor(e,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=0===i.button,this.middleButton=1===i.button,this.rightButton=2===i.button,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,"dblclick"===i.type&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,"number"==typeof i.pageX?(this.posx=i.pageX,this.posy=i.pageY):(this.posx=i.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=i.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let r=s8.getPositionOfChildWindowRelativeToAncestorWindow(e,i.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ne=class{constructor(e,i=0,r=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=i;let s=!1;if(sS){let e=navigator.userAgent.match(/Chrome\/(\d+)/);s=(e?parseInt(e[1]):123)<=122}if(e){let i=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?s?this.deltaY=e.wheelDeltaY/(120*i):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?sb&&!sI?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?sw&&sB?this.deltaX=-(e.wheelDeltaX/120):s?this.deltaX=e.wheelDeltaX/(120*i):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?sb&&!sI?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},nt=Object.freeze(function(e,i){let r=setTimeout(e.bind(i),0);return{dispose(){clearTimeout(r)}}});(n1=s1||={}).isCancellationToken=function(e){return e===n1.None||e===n1.Cancelled||e instanceof ni||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},n1.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:sh.None}),n1.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:nt});var ni=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?nt:(this._emitter||(this._emitter=new s_),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var nr=class{constructor(e,i){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof i&&this.setIfNotSet(e,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,i){if(this._isDisposed)throw new rQ("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},i)}setIfNotSet(e,i){if(this._isDisposed)throw new rQ("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},i))}},ns=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,i,r=globalThis){if(this.isDisposed)throw new rQ("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=r.setInterval(()=>{e()},i);this.disposable=r3(()=>{r.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(n2=n5||={}).settled=async function(e){let i,r=await Promise.all(e.map(e=>e.then(e=>e,e=>{i||(i=e)})));if("u">typeof i)throw i;return r},n2.withAsyncBody=function(e){return new Promise(async(i,r)=>{try{await e(i,r)}catch(e){r(e)}})};var nn=class e{static fromArray(i){return new e(e=>{e.emitMany(i)})}static fromPromise(i){return new e(async e=>{e.emitMany(await i)})}static fromPromises(i){return new e(async e=>{await Promise.all(i.map(async i=>e.emitOne(await i)))})}static merge(i){return new e(async e=>{await Promise.all(i.map(async i=>{for await(let r of i)e.emitOne(r)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new s_,queueMicrotask(async()=>{let i={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(i)),this.resolve()}catch(e){this.reject(e)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await sh.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,r){return new e(async e=>{for await(let s of i)e.emitOne(r(s))})}map(i){return e.map(this,i)}static filter(i,r){return new e(async e=>{for await(let s of i)r(s)&&e.emitOne(s)})}filter(i){return e.filter(this,i)}static coalesce(i){return e.filter(i,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let i=[];for await(let r of e)i.push(r);return i}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};nn.EMPTY=nn.fromArray([]);function no(e,i){return(i<<5)-i+e|0}function na(e,i){i=no(149417,i);for(let r=0,s=e.length;r<s;r++)i=no(e.charCodeAt(r),i);return i}new DataView(new ArrayBuffer(320));var{registerWindow:nl,getWindow:nh,getDocument:nc,getWindows:nd,getWindowsCount:nu,getWindowId:nf,getWindowById:np,hasWindow:nm,onDidRegisterWindow:n_,onWillUnregisterWindow:ng,onDidUnregisterWindow:nv}=(i=new Map,r={window:r7,disposables:new r6},i.set(r7.vscodeWindowId,r),s=new s_,n=new s_,o=new s_,{onDidRegisterWindow:s.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:n.event,registerWindow(e){if(i.has(e.vscodeWindowId))return r9.None;let r=new r6,a={window:e,disposables:r.add(new r6)};return i.set(e.vscodeWindowId,a),r.add(r3(()=>{i.delete(e.vscodeWindowId),n.fire(e)})),r.add(nb(e,nk.BEFORE_UNLOAD,()=>{o.fire(e)})),s.fire(a),r},getWindows:()=>i.values(),getWindowsCount:()=>i.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>i.has(e),getWindowById:function(e,s){return("number"==typeof e?i.get(e):void 0)??(s?r:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:r7,getDocument:e=>nh(e).document}),nx=class{constructor(e,i,r,s){this._node=e,this._type=i,this._handler=r,this._options=s||!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 nb(e,i,r,s){return new nx(e,i,r,s)}var ny=function(e,i,r,s){var n;let o=r;return"click"===i||"mousedown"===i||"contextmenu"===i?(n=nh(e),o=function(e){return r(new s7(n,e))}):("keydown"===i||"keypress"===i||"keyup"===i)&&(o=function(e){return r(new s6(e))}),nb(e,i,o,s)},nS=class extends ns{constructor(e){super(),this.defaultTarget=e&&nh(e)}cancelAndSet(e,i,r){return super.cancelAndSet(e,i,r??this.defaultTarget)}},nw=class{constructor(e,i=0){this._runner=e,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){rY(e)}}static sort(e,i){return i.priority-e.priority}};a=new Map,l=new Map,h=new Map,c=new Map,n3=(e,i,r=0)=>{let s=nf(e),n=new nw(i,r),o=a.get(s);return o||(o=[],a.set(s,o)),o.push(n),h.get(s)||(h.set(s,!0),e.requestAnimationFrame(()=>(e=>{h.set(e,!1);let i=a.get(e)??[];for(l.set(e,i),a.set(e,[]),c.set(e,!0);i.length>0;)i.sort(nw.sort),i.shift().execute();c.set(e,!1)})(s))),n};var nC=class e{constructor(e,i){this.width=e,this.height=i}with(i=this.width,r=this.height){return i!==this.width||r!==this.height?new e(i,r):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(i){return i instanceof e?i:new e(i.width,i.height)}static equals(e,i){return e===i||!!e&&!!i&&e.width===i.width&&e.height===i.height}};nC.None=new nC(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,i,r){let s=this.mutationObservers.get(e);s||(s=new Map,this.mutationObservers.set(e,s));let n=function e(i,r){switch(typeof i){case"object":var s,n,o,a;return null===i?no(349,r):Array.isArray(i)?(s=i,n=no(104579,n=r),s.reduce((i,r)=>e(r,i),n)):(o=i,a=no(181387,a=r),Object.keys(o).sort().reduce((i,r)=>(i=na(r,i),e(o[r],i)),a));case"string":return na(i,r);case"boolean":return no(i?433:863,r);case"number":return no(i,r);case"undefined":return no(937,r);default:return no(617,r)}}(r,0),o=s.get(n);if(o)o.users+=1;else{let a=new s_,l=new MutationObserver(e=>a.fire(e));l.observe(e,r);let h=o={users:1,observer:l,onDidMutate:a.event};i.add(r3(()=>{h.users-=1,0===h.users&&(a.dispose(),l.disconnect(),s?.delete(n),s?.size===0&&this.mutationObservers.delete(e))})),s.set(n,o)}return o.onDidMutate}};var nk={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"},nE=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let i=nN(e);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let i=nN(e);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(e){let i=nN(e);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(e){let i=nN(e);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(e){let i=nN(e);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(e){let i=nN(e);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(e){let i=nN(e);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(e){let i=nN(e);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let i=nN(e);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let i=nN(e);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let i=nN(e);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let i=nN(e);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let i=nN(e);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let i=nN(e);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,i){this.domNode.classList.toggle(e,i),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,i){this.domNode.setAttribute(e,i)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function nN(e){return"number"==typeof e?`${e}px`:e}function nR(e){return new nE(e)}var nj=class{constructor(){this._hooks=new r6,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,i,r,s,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=n;let o=e;try{e.setPointerCapture(i),this._hooks.add(r3(()=>{try{e.releasePointerCapture(i)}catch{}}))}catch{o=nh(e)}this._hooks.add(nb(o,nk.POINTER_MOVE,e=>{e.buttons!==r?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(nb(o,nk.POINTER_UP,e=>this.stopMonitoring(!0)))}};(d=n4||={}).Tap="-xterm-gesturetap",d.Change="-xterm-gesturechange",d.Start="-xterm-gesturestart",d.End="-xterm-gesturesend",d.Contextmenu="-xterm-gesturecontextmenu";var nT=class e extends r9{constructor(){super(),this.dispatched=!1,this.targets=new st,this.ignoreTargets=new st,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(sh.runAndSubscribe(n_,({window:e,disposables:i})=>{i.add(nb(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),i.add(nb(e.document,"touchend",i=>this.onTouchEnd(e,i))),i.add(nb(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:r7,disposables:this._store}))}static addTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),r3(e.INSTANCE.targets.push(i))):r9.None}static ignoreTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),r3(e.INSTANCE.ignoreTargets.push(i))):r9.None}static isTouchDevice(){return"ontouchstart"in r7||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,s=e.targetTouches.length;r<s;r++){let s=e.targetTouches.item(r);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:i,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[i],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let n=this.newGestureEvent(n4.Start,s.target);n.pageX=s.pageX,n.pageY=s.pageY,this.dispatchEvent(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(i,r){let s=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=r.changedTouches.length;o<a;o++){let a=r.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-rZ(l.rollingPageX))&&30>Math.abs(l.initialPageY-rZ(l.rollingPageY))){let e=this.newGestureEvent(n4.Tap,l.initialTarget);e.pageX=rZ(l.rollingPageX),e.pageY=rZ(l.rollingPageY),this.dispatchEvent(e)}else if(h>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-rZ(l.rollingPageX))&&30>Math.abs(l.initialPageY-rZ(l.rollingPageY))){let e=this.newGestureEvent(n4.Contextmenu,l.initialTarget);e.pageX=rZ(l.rollingPageX),e.pageY=rZ(l.rollingPageY),this.dispatchEvent(e)}else if(1===n){let e=rZ(l.rollingPageX),r=rZ(l.rollingPageY),n=rZ(l.rollingTimestamps)-l.rollingTimestamps[0],o=e-l.rollingPageX[0],a=r-l.rollingPageY[0],h=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(i,h,s,Math.abs(o)/n,o>0?1:-1,e,Math.abs(a)/n,a>0?1:-1,r)}this.dispatchEvent(this.newGestureEvent(n4.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let r=document.createEvent("CustomEvent");return r.initEvent(e,!1,!0),r.initialTarget=i,r.tapCount=0,r}dispatchEvent(i){if(i.type===n4.Tap){let r=new Date().getTime(),s=0;s=r-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=r,i.tapCount=s}else(i.type===n4.Change||i.type===n4.Contextmenu)&&(this._lastSetTapCountTime=0);if(i.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(i.initialTarget))return;let e=[];for(let r of this.targets)if(r.contains(i.initialTarget)){let s=0,n=i.initialTarget;for(;n&&n!==r;)s++,n=n.parentElement;e.push([s,r])}for(let[r,s]of(e.sort((e,i)=>e[0]-i[0]),e))s.dispatchEvent(i),this.dispatched=!0}}inertia(i,r,s,n,o,a,l,h,c){this.handle=n3(i,()=>{let d=Date.now(),u=d-s,f=0,p=0,m=!0;n+=e.SCROLL_FRICTION*u,l+=e.SCROLL_FRICTION*u,n>0&&(m=!1,f=o*n*u),l>0&&(m=!1,p=h*l*u);let _=this.newGestureEvent(n4.Change);_.translationX=f,_.translationY=p,r.forEach(e=>e.dispatchEvent(_)),m||this.inertia(i,r,d,n,o,a+f,l,h,c+p)})}onTouchMove(e){let i=Date.now();for(let r=0,s=e.changedTouches.length;r<s;r++){let s=e.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let n=this.activeTouches[s.identifier],o=this.newGestureEvent(n4.Change,n.initialTarget);o.translationX=s.pageX-rZ(n.rollingPageX),o.translationY=s.pageY-rZ(n.rollingPageY),o.pageX=s.pageX,o.pageY=s.pageY,this.dispatchEvent(o),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(s.pageX),n.rollingPageY.push(s.pageY),n.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};nT.SCROLL_FRICTION=-.005,nT.HOLD_DELAY=700,nT.CLEAR_TAP_COUNT_TIME=400,rc([function(e,i,r){let s=null,n=null;if("function"==typeof r.value?(s="value",0!==(n=r.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof r.get&&(s="get",n=r.get),!n)throw Error("not supported");let o=`$memoize$${i}`;r[s]=function(...e){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,e)}),this[o]}}],nT,"isTouchDevice",1);var nD=class extends r9{onclick(e,i){this._register(nb(e,nk.CLICK,r=>i(new s7(nh(e),r))))}onmousedown(e,i){this._register(nb(e,nk.MOUSE_DOWN,r=>i(new s7(nh(e),r))))}onmouseover(e,i){this._register(nb(e,nk.MOUSE_OVER,r=>i(new s7(nh(e),r))))}onmouseleave(e,i){this._register(nb(e,nk.MOUSE_LEAVE,r=>i(new s7(nh(e),r))))}onkeydown(e,i){this._register(nb(e,nk.KEY_DOWN,e=>i(new s6(e))))}onkeyup(e,i){this._register(nb(e,nk.KEY_UP,e=>i(new s6(e))))}oninput(e,i){this._register(nb(e,nk.INPUT,i))}onblur(e,i){this._register(nb(e,nk.BLUR,i))}onfocus(e,i){this._register(nb(e,nk.FOCUS,i))}onchange(e,i){this._register(nb(e,nk.CHANGE,i))}ignoreGesture(e){return nT.ignoreTarget(e)}},nM=class extends nD{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new nj),this._register(ny(this.bgDomNode,nk.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(ny(this.domNode,nk.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new nS),this._pointerdownScheduleRepeatTimer=this._register(new nr)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,nh(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(i,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},nP=class e{constructor(e,i,r,s,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i|=0,r|=0,s|=0,n|=0,o|=0,a|=0),this.rawScrollLeft=s,this.rawScrollTop=a,i<0&&(i=0),s+i>r&&(s=r-i),s<0&&(s=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=r,this.scrollLeft=s,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(i,r){return new e(this._forceIntegerValues,"u">typeof i.width?i.width:this.width,"u">typeof i.scrollWidth?i.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,"u">typeof i.height?i.height:this.height,"u">typeof i.scrollHeight?i.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(i){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof i.scrollLeft?i.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof i.scrollTop?i.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let r=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:s,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},nL=class extends r9{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new s_),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new nP(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,i){let r=this._state.withScrollDimensions(e,i);this._setState(r,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let i=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(i,!1)}setScrollPositionSmooth(e,i){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let r;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;r=i?new nI(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=nI.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),i=this._state.withScrollPosition(e);if(this._setState(i,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,i){let r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,i)))}},nA=class{constructor(e,i,r){this.scrollLeft=e,this.scrollTop=i,this.isDone=r}};function nB(e,i){let r=i-e;return function(i){return e+r*(1-Math.pow(1-i,3))}}var nI=class e{constructor(e,i,r,s){this.from=e,this.to=i,this.duration=s,this.startTime=r,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(e,i,r){if(Math.abs(e-i)>2.5*r){var s,n;let o,a;return e<i?(o=e+.75*r,a=i-.75*r):(o=e-.75*r,a=i+.75*r),s=nB(e,o),n=nB(a,i),function(e){return e<.33?s(e/.33):n((e-.33)/(1-.33))}}return nB(e,i)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let i=(e-this.startTime)/this.duration;return i<1?new nA(this.scrollLeft(i),this.scrollTop(i),!1):new nA(this.to.scrollLeft,this.to.scrollTop,!0)}combine(i,r,s){return e.start(i,r,s)}static start(i,r,s){return s+=10,new e(i,r,Date.now()-10,s)}},nO=class extends r9{constructor(e,i,r){super(),this._visibility=e,this._visibleClassName=i,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new nr)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){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(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},nF=class extends nD{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nO(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new nj),this._shouldRender=!0,this.domNode=nR(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(nb(this.domNode.domNode,nk.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let i=this._register(new nM(e));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(e,i,r,s){this.slider=nR(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(i),"number"==typeof r&&this.slider.setWidth(r),"number"==typeof s&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(nb(this.slider.domNode,nk.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let i=this.domNode.domNode.getClientRects()[0].top,r=i+this._scrollbarState.getSliderPosition(),s=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);r<=n&&n<=s?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let i,r;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)i=e.offsetX,r=e.offsetY;else{var s;let n,o,a=(n=(s=this.domNode.domNode).getBoundingClientRect(),o=nh(s),{left:n.left+o.scrollX,top:n.top+o.scrollY,width:n.width,height:n.height});i=e.pageX-a.left,r=e.pageY-a.top}let n=this._pointerDownRelativePosition(i,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let n=Math.abs(this._sliderOrthogonalPointerPosition(e)-r);if(sB&&n>140)return void this._setDesiredScrollPositionNow(s.getScrollPosition());let o=this._sliderPointerPosition(e)-i;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let i={};this.writeScrollPosition(i,e),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},nz=class e{constructor(e,i,r,s,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i&&(this._visibleSize=i,this._refreshComputedValues(),!0)}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i&&(this._scrollSize=i,this._refreshComputedValues(),!0)}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i&&(this._scrollPosition=i,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,r,s,n){let o=Math.max(0,r-e),a=Math.max(0,o-2*i),l=s>0&&s>r;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(r*a/s))),c=(a-h)/(s-r);return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(n*c)}}_refreshComputedValues(){let i=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=i.computedAvailableSize,this._computedIsNeeded=i.computedIsNeeded,this._computedSliderSize=i.computedSliderSize,this._computedSliderRatio=i.computedSliderRatio,this._computedSliderPosition=i.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(e){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,r=this._scrollPosition;return i<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},nH=class extends nF{constructor(e,i,r){let s=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:r,scrollbarState:new nz(i.horizontalHasArrows?i.arrowSize:0,2===i.horizontal?0:i.horizontalScrollbarSize,2===i.vertical?0:i.verticalScrollbarSize,s.width,s.scrollWidth,n.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(e,i){this.slider.setWidth(e),this.slider.setLeft(i)}_renderDomNode(e,i){this.domNode.setWidth(e),this.domNode.setHeight(i),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,i){e.scrollLeft=i}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},n$=class extends nF{constructor(e,i,r){let s=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:r,scrollbarState:new nz(i.verticalHasArrows?i.arrowSize:0,2===i.vertical?0:i.verticalScrollbarSize,0,s.height,s.scrollHeight,n.scrollTop),visibility:i.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:i.scrollByPage}),i.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((i.verticalScrollbarSize-i.verticalSliderSize)/2),i.verticalSliderSize,void 0)}_updateSlider(e,i){this.slider.setHeight(e),this.slider.setTop(i)}_renderDomNode(e,i){this.domNode.setWidth(i),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return i}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,i){e.scrollTop=i}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},nW=class{constructor(e,i,r){this.timestamp=e,this.deltaX=i,this.deltaY=r,this.score=0}},nU=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,i=0,r=1,s=this._rear;for(;;){let n=s===this._front?e:Math.pow(2,-r);if(e-=n,i+=this._memory[s].score*n,s===this._front)break;s=(this._capacity+s-1)%this._capacity,r++}return i<=.5}acceptStandardWheelEvent(e){if(sS){var i;let r=(i=nh(e.browserEvent),sv.INSTANCE.getZoomFactor(i));this.accept(Date.now(),e.deltaX*r,e.deltaY*r)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,i,r){let s=null,n=new nW(e,i,r);-1===this._front&&-1===this._rear?(this._memory[0]=n,this._front=0,this._rear=0):(s=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]=n),n.score=this._computeScore(n,s)}_computeScore(e,i){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let r=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(r+=.25),i){let s=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(s,o),1),h=Math.max(Math.min(n,a),1),c=Math.max(n,a);Math.max(s,o)%l==0&&c%h==0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};nU.INSTANCE=new nU;var nK=class extends nD{constructor(e,i,r){super(),this._onScroll=this._register(new s_),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new s_),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let i={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return i.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:i.horizontalScrollbarSize,i.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:i.verticalScrollbarSize,sI&&(i.className+=" mac"),i}(i),this._scrollable=r,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let s={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new n$(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new nH(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=nR(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=nR(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=nR(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,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new nr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=r5(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,sI&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new ne(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=r5(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new ne(e))};this._mouseWheelToDispose.push(nb(this._listenOnDomNode,nk.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let i=nU.INSTANCE;i.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let s=e.deltaY*this._options.mouseWheelScrollSensitivity,n=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+s===0?n=s=0:Math.abs(s)>=Math.abs(n)?n=0:s=0),this._options.flipAxes&&([s,n]=[n,s]);let o=!sI&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=s,s=0),e.browserEvent&&e.browserEvent.altKey&&(n*=this._options.fastScrollSensitivity,s*=this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(s){let e=50*s,i=a.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,i)}if(n){let e=50*n,i=a.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,i)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),r=!0)}let s=r;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),i=e.scrollTop>0,r=e.scrollLeft>0,s=r?" left":"",n=i?" top":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${r||i?" top-left-corner":""}${n}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){this._mouseIsOver||this._isDragging||(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){this._mouseIsOver||this._isDragging||this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},nq=class extends nK{constructor(e,i,r){super(e,i,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},nV=class extends r9{constructor(e,i,r,s,n,o,a,l){super(),this._bufferService=r,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new s_),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new nL({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>n3(s.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new nq(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(sh.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(r3(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(r3(()=>this._styleElement.remove())),this._register(sh.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
16
+ `)})),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(e=>this._handleScroll(e)))}scrollLines(e){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,i){i&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:e*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(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=i-this._bufferService.buffer.ydisp;0!==r&&(this._latestYDisp=i,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};nV=rc([rd(2,rR),rd(3,rz),rd(4,rj),rd(5,rK),rd(6,rL),rd(7,r$)],nV);var nY=class extends r9{constructor(e,i,r,s,n){super(),this._screenElement=e,this._bufferService=i,this._coreBrowserService=r,this._decorationService=s,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(r3(()=>{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 e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let r=e.options.x??0;return r&&r>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(e,i),i}_refreshStyle(e){let i=e.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${i*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,i=e.element){if(!i)return;let r=e.options.x??0;"right"===(e.options.anchor||"left")?i.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":i.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};nY=rc([rd(1,rR),rd(2,rz),rd(3,rI),rd(4,r$)],nY);var nG=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let i of this._zones)if(i.color===e.options.overviewRulerOptions.color&&i.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,e.marker.line))return;if(this._lineAdjacentToZone(i,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(i,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,i){return i>=e.startBufferLine&&i<=e.endBufferLine}_lineAdjacentToZone(e,i,r){return i>=e.startBufferLine-this._linePadding[r||"full"]&&i<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,i){e.startBufferLine=Math.min(e.startBufferLine,i),e.endBufferLine=Math.max(e.endBufferLine,i)}},nX={full:0,left:0,center:0,right:0},nJ={full:0,left:0,center:0,right:0},nQ={full:0,left:0,center:0,right:0},nZ=class extends r9{constructor(e,i,r,s,n,o,a,l){super(),this._viewportElement=e,this._screenElement=i,this._bufferService=r,this._decorationService=s,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new nG,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(r3(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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 e=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);nJ.full=this._canvas.width,nJ.left=e,nJ.center=i,nJ.right=e,this._refreshDrawHeightConstants(),nQ.full=1,nQ.left=1,nQ.center=1+nJ.left,nQ.right=1+nJ.left+nJ.center}_refreshDrawHeightConstants(){nX.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);nX.left=e,nX.center=e,nX.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nX.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nX.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nX.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nX.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 e 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(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let i of e)"full"!==i.position&&this._renderColorZone(i);for(let i of e)"full"===i.position&&this._renderColorZone(i);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(nQ[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-nX[e.position||"full"]/2),nJ[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+nX[e.position||"full"]))}_queueRefresh(e,i){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};nZ=rc([rd(2,rR),rd(3,rI),rd(4,r$),rd(5,rL),rd(6,rK),rd(7,rz)],nZ),(u=n6||={}).NUL="\0",u.SOH="\x01",u.STX="\x02",u.ETX="\x03",u.EOT="\x04",u.ENQ="\x05",u.ACK="\x06",u.BEL="\x07",u.BS="\b",u.HT=" ",u.LF=`
17
+ `,u.VT="\v",u.FF="\f",u.CR="\r",u.SO="\x0e",u.SI="\x0f",u.DLE="\x10",u.DC1="\x11",u.DC2="\x12",u.DC3="\x13",u.DC4="\x14",u.NAK="\x15",u.SYN="\x16",u.ETB="\x17",u.CAN="\x18",u.EM="\x19",u.SUB="\x1a",u.ESC="\x1b",u.FS="\x1c",u.GS="\x1d",u.RS="\x1e",u.US="\x1f",u.SP=" ",u.DEL="",(f=n9||={}).PAD="€",f.HOP="",f.BPH="‚",f.NBH="ƒ",f.IND="„",f.NEL="…",f.SSA="†",f.ESA="‡",f.HTS="ˆ",f.HTJ="‰",f.VTS="Š",f.PLD="‹",f.PLU="Œ",f.RI="",f.SS2="Ž",f.SS3="",f.DCS="",f.PU1="‘",f.PU2="’",f.STS="“",f.CCH="”",f.MW="•",f.SPA="–",f.EPA="—",f.SOS="˜",f.SGCI="™",f.SCI="š",f.CSI="›",f.ST="œ",f.OSC="",f.PM="ž",f.APC="Ÿ",(n8||={}).ST=`${n6.ESC}\\`;var n0=class{constructor(e,i,r,s,n,o){this._textarea=e,this._compositionView=i,this._bufferService=r,this._optionsService=s,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let i;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(i=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let i=this._textarea.value,r=i.replace(e,"");this._dataAlreadySent=r,i.length>e.length?this._coreService.triggerDataEvent(r,!0):i.length<e.length?this._coreService.triggerDataEvent(`${n6.DEL}`,!0):i.length===e.length&&i!==e&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};n0=rc([rd(2,rR),rd(3,rL),rd(4,rT),rd(5,r$)],n0);var n1,n2,n5,n3,n4,n6,n9,n8,n7,oe=0,ot=0,oi=0,or=0,os={css:"#00000000",rgba:0};(aW=n7||={}).toCss=function(e,i,r,s){return void 0!==s?`#${ou(e)}${ou(i)}${ou(r)}${ou(s)}`:`#${ou(e)}${ou(i)}${ou(r)}`},aW.toRgba=function(e,i,r,s=255){return(e<<24|i<<16|r<<8|s)>>>0},aW.toColor=function(e,i,r,s){return{css:aW.toCss(e,i,r,s),rgba:aW.toRgba(e,i,r,s)}};var on=aU||={};function oo(e,i){return or=Math.round(255*i),[oe,ot,oi]=aV.toChannels(e.rgba),{css:n7.toCss(oe,ot,oi,or),rgba:n7.toRgba(oe,ot,oi,or)}}on.blend=function(e,i){if(1==(or=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let r=i.rgba>>24&255,s=i.rgba>>16&255,n=i.rgba>>8&255,o=e.rgba>>24&255,a=e.rgba>>16&255,l=e.rgba>>8&255;return oe=o+Math.round((r-o)*or),ot=a+Math.round((s-a)*or),oi=l+Math.round((n-l)*or),{css:n7.toCss(oe,ot,oi),rgba:n7.toRgba(oe,ot,oi)}},on.isOpaque=function(e){return(255&e.rgba)==255},on.ensureContrastRatio=function(e,i,r){let s=aV.ensureContrastRatio(e.rgba,i.rgba,r);if(s)return n7.toColor(s>>24&255,s>>16&255,s>>8&255)},on.opaque=function(e){let i=(255|e.rgba)>>>0;return[oe,ot,oi]=aV.toChannels(i),{css:n7.toCss(oe,ot,oi),rgba:i}},on.opacity=oo,on.multiplyOpacity=function(e,i){return or=255&e.rgba,oo(e,or*i/255)},on.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let i,r;try{let e=document.createElement("canvas");e.width=1,e.height=1;let s=e.getContext("2d",{willReadFrequently:!0});s&&((i=s).globalCompositeOperation="copy",r=i.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return oe=parseInt(e.slice(1,2).repeat(2),16),ot=parseInt(e.slice(2,3).repeat(2),16),oi=parseInt(e.slice(3,4).repeat(2),16),n7.toColor(oe,ot,oi);case 5:return oe=parseInt(e.slice(1,2).repeat(2),16),ot=parseInt(e.slice(2,3).repeat(2),16),oi=parseInt(e.slice(3,4).repeat(2),16),or=parseInt(e.slice(4,5).repeat(2),16),n7.toColor(oe,ot,oi,or);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let s=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return oe=parseInt(s[1]),ot=parseInt(s[2]),oi=parseInt(s[3]),or=Math.round((void 0===s[5]?1:parseFloat(s[5]))*255),n7.toColor(oe,ot,oi,or);if(!i||!r||(i.fillStyle=r,i.fillStyle=e,"string"!=typeof i.fillStyle)||(i.fillRect(0,0,1,1),[oe,ot,oi,or]=i.getImageData(0,0,1,1).data,255!==or))throw Error("css.toColor: Unsupported css format");return{rgba:n7.toRgba(oe,ot,oi,or),css:e}}})(aK||={});var oa=aq||={};function ol(e,i,r){let s=e/255,n=i/255,o=r/255;return .2126*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}oa.relativeLuminance=function(e){return ol(e>>16&255,e>>8&255,255&e)},oa.relativeLuminance2=ol;var oh=aV||={};function oc(e,i,r){let s=e>>24&255,n=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,h=i>>8&255,c=of(aq.relativeLuminance2(a,l,h),aq.relativeLuminance2(s,n,o));for(;c<r&&(a>0||l>0||h>0);)a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h-=Math.max(0,Math.ceil(.1*h)),c=of(aq.relativeLuminance2(a,l,h),aq.relativeLuminance2(s,n,o));return(a<<24|l<<16|h<<8|255)>>>0}function od(e,i,r){let s=e>>24&255,n=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,h=i>>8&255,c=of(aq.relativeLuminance2(a,l,h),aq.relativeLuminance2(s,n,o));for(;c<r&&(a<255||l<255||h<255);)a=Math.min(255,a+Math.ceil((255-a)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),h=Math.min(255,h+Math.ceil((255-h)*.1)),c=of(aq.relativeLuminance2(a,l,h),aq.relativeLuminance2(s,n,o));return(a<<24|l<<16|h<<8|255)>>>0}function ou(e){let i=e.toString(16);return i.length<2?"0"+i:i}function of(e,i){return e<i?(i+.05)/(e+.05):(e+.05)/(i+.05)}oh.blend=function(e,i){if(1==(or=(255&i)/255))return i;let r=e>>24&255,s=e>>16&255,n=e>>8&255;return oe=r+Math.round(((i>>24&255)-r)*or),ot=s+Math.round(((i>>16&255)-s)*or),oi=n+Math.round(((i>>8&255)-n)*or),n7.toRgba(oe,ot,oi)},oh.ensureContrastRatio=function(e,i,r){let s=aq.relativeLuminance(e>>8),n=aq.relativeLuminance(i>>8);if(of(s,n)<r){if(n<s){let n=oc(e,i,r),o=of(s,aq.relativeLuminance(n>>8));if(o<r){let a=od(e,i,r);return o>of(s,aq.relativeLuminance(a>>8))?n:a}return n}let o=od(e,i,r),a=of(s,aq.relativeLuminance(o>>8));if(a<r){let n=oc(e,i,r);return a>of(s,aq.relativeLuminance(n>>8))?o:n}return o}},oh.reduceLuminance=oc,oh.increaseLuminance=od,oh.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var op=class extends ry{constructor(e,i,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=i,this._width=r}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},om=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rw}register(e){let i={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(i),i.id}deregister(e){for(let i=0;i<this._characterJoiners.length;i++)if(this._characterJoiners[i].id===e)return this._characterJoiners.splice(i,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let i=this._bufferService.buffer.lines.get(e);if(!i||0===i.length)return[];let r=[],s=i.translateToString(!0),n=0,o=0,a=0,l=i.getFg(0),h=i.getBg(0);for(let e=0;e<i.getTrimmedLength();e++)if(i.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==h){if(e-n>1){let e=this._getJoinedRanges(s,a,o,i,n);for(let i=0;i<e.length;i++)r.push(e[i])}n=e,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||1}if(this._bufferService.cols-n>1){let e=this._getJoinedRanges(s,a,o,i,n);for(let i=0;i<e.length;i++)r.push(e[i])}return r}_getJoinedRanges(e,i,r,s,n){let o=e.substring(i,r),a=[];try{a=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let i=this._characterJoiners[e].handler(o);for(let e=0;e<i.length;e++)om._mergeRanges(a,i[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,s,n),a}_stringRangesToCellRanges(e,i,r){let s=0,n=!1,o=0,a=e[0];if(a){for(let l=r;l<this._bufferService.cols;l++){let r=i.getWidth(l),h=i.getString(l).length||1;if(0!==r){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,!(a=e[++s]))break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,i){let r=!1;for(let s=0;s<e.length;s++){let n=e[s];if(r){if(i[1]<=n[0])return e[s-1][1]=i[1],e;if(i[1]<=n[1])return e[s-1][1]=Math.max(i[1],n[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(i[1]<=n[0])return e.splice(s,0,i),e;if(i[1]<=n[1])return n[0]=Math.min(i[0],n[0]),e;i[0]<n[1]&&(n[0]=Math.min(i[0],n[0]),r=!0);continue}}return r?e[e.length-1][1]=i[1]:e.push(i),e}};function o_(){return{width:0,height:0}}om=rc([rd(0,rR)],om);var og=class{constructor(e,i,r,s,n,o,a){this._document=e,this._characterJoinerService=i,this._optionsService=r,this._coreBrowserService=s,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new rw,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,i,r){this._selectionStart=e,this._selectionEnd=i,this._columnSelectMode=r}createRow(e,i,r,s,n,o,a,l,h,c,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(i),p=this._themeService.colors,m=e.getNoBgTrimmedLength();r&&m<o+1&&(m=o+1);let _,g=0,v="",x=0,b=0,y=0,S=0,w=!1,C=0,k=!1,E=0,N=0,R=[],j=-1!==c&&-1!==d;for(let T=0;T<m;T++){let m;e.loadCell(T,this._workCell);let D=this._workCell.getWidth();if(0===D)continue;let M=!1,P=T>=N,L=T,A=this._workCell;if(f.length>0&&T===f[0][0]&&P){let s=f.shift(),n=this._isCellInSelection(s[0],i);for(x=s[0]+1;x<s[1];x++)P&&=n===this._isCellInSelection(x,i);(P&&=!r||o<s[0]||o>=s[1])?(M=!0,A=new op(this._workCell,e.translateToString(!0,s[0],s[1]),s[1]-s[0]),L=s[1]-1,D=A.getWidth()):N=s[1]}let B=this._isCellInSelection(T,i),I=r&&T===o,O=j&&T>=c&&T<=d,F=!1;this._decorationService.forEachDecorationAtCell(T,i,void 0,e=>{F=!0});let z=A.getChars()||" ";if(" "===z&&(A.isUnderline()||A.isOverline())&&(z=" "),E=D*l-h.get(z,A.isBold(),A.isItalic()),_)if(g&&(B&&k||!B&&!k&&A.bg===b)&&(B&&k&&p.selectionForeground||A.fg===y)&&A.extended.ext===S&&O===w&&E===C&&!I&&!M&&!F&&P){A.isInvisible()?v+=" ":v+=z,g++;continue}else g&&(_.textContent=v),_=this._document.createElement("span"),g=0,v="";else _=this._document.createElement("span");if(b=A.bg,y=A.fg,S=A.extended.ext,w=O,C=E,k=B,M&&o>=T&&o<=L&&(o=T),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(R.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&R.push("xterm-cursor-blink"),R.push("bar"===s?"xterm-cursor-bar":"underline"===s?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":R.push("xterm-cursor-outline");break;case"block":R.push("xterm-cursor-block");break;case"bar":R.push("xterm-cursor-bar");break;case"underline":R.push("xterm-cursor-underline")}}if(A.isBold()&&R.push("xterm-bold"),A.isItalic()&&R.push("xterm-italic"),A.isDim()&&R.push("xterm-dim"),v=A.isInvisible()?" ":A.getChars()||" ",A.isUnderline()&&(R.push(`xterm-underline-${A.extended.underlineStyle}`)," "===v&&(v=" "),!A.isUnderlineColorDefault()))if(A.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${ry.toColorRGB(A.getUnderlineColor()).join(",")})`;else{let e=A.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&A.isBold()&&e<8&&(e+=8),_.style.textDecorationColor=p.ansi[e].css}A.isOverline()&&(R.push("xterm-overline")," "===v&&(v=" ")),A.isStrikethrough()&&R.push("xterm-strikethrough"),O&&(_.style.textDecoration="underline");let H=A.getFgColor(),$=A.getFgColorMode(),W=A.getBgColor(),U=A.getBgColorMode(),K=!!A.isInverse();if(K){let e=H;H=W,W=e;let i=$;$=U,U=i}let q,V,Y=!1;switch(this._decorationService.forEachDecorationAtCell(T,i,void 0,e=>{"top"!==e.options.layer&&Y||(e.backgroundColorRGB&&(U=0x3000000,W=e.backgroundColorRGB.rgba>>8&0xffffff,q=e.backgroundColorRGB),e.foregroundColorRGB&&($=0x3000000,H=e.foregroundColorRGB.rgba>>8&0xffffff,V=e.foregroundColorRGB),Y="top"===e.options.layer)}),!Y&&B&&(W=(q=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,U=0x3000000,Y=!0,p.selectionForeground&&($=0x3000000,H=p.selectionForeground.rgba>>8&0xffffff,V=p.selectionForeground)),Y&&R.push("xterm-decoration-top"),U){case 0x1000000:case 0x2000000:m=p.ansi[W],R.push(`xterm-bg-${W}`);break;case 0x3000000:m=n7.toColor(W>>16,W>>8&255,255&W),this._addStyle(_,`background-color:#${ov((W>>>0).toString(16),"0",6)}`);break;default:K?(m=p.foreground,R.push("xterm-bg-257")):m=p.background}switch(q||A.isDim()&&(q=aU.multiplyOpacity(m,.5)),$){case 0x1000000:case 0x2000000:A.isBold()&&H<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(H+=8),this._applyMinimumContrast(_,m,p.ansi[H],A,q,void 0)||R.push(`xterm-fg-${H}`);break;case 0x3000000:let G=n7.toColor(H>>16&255,H>>8&255,255&H);this._applyMinimumContrast(_,m,G,A,q,V)||this._addStyle(_,`color:#${ov(H.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(_,m,p.foreground,A,q,V)||K&&R.push("xterm-fg-257")}R.length&&(_.className=R.join(" "),R.length=0),I||M||F||!P?_.textContent=v:g++,E!==this.defaultSpacing&&(_.style.letterSpacing=`${E}px`),u.push(_),T=L}return _&&g&&(_.textContent=v),u}_applyMinimumContrast(e,i,r,s,n,o){var a,l,h;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=a=s.getCode())&&l<=57558||9472<=(h=a)&&h<=9631)return!1;let c=this._getContrastCache(s),d;if(n||o||(d=c.getColor(i.rgba,r.rgba)),void 0===d){let e=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=aU.ensureContrastRatio(n||i,o||r,e),c.setColor((n||i).rgba,(o||r).rgba,d??null)}return!!d&&(this._addStyle(e,`color:${d.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,i){e.setAttribute("style",`${e.getAttribute("style")||""}${i};`)}_isCellInSelection(e,i){let r=this._selectionStart,s=this._selectionEnd;return!!r&&!!s&&(this._columnSelectMode?r[0]<=s[0]?e>=r[0]&&i>=r[1]&&e<s[0]&&i<=s[1]:e<r[0]&&i>=r[1]&&e>=s[0]&&i<=s[1]:i>r[1]&&i<s[1]||r[1]===s[1]&&i===r[1]&&e>=r[0]&&e<s[0]||r[1]<s[1]&&i===s[1]&&e<s[0]||r[1]<s[1]&&i===r[1]&&e>=r[0])}};function ov(e,i,r){for(;e.length<r;)e=i+e;return e}og=rc([rd(1,rU),rd(2,rL),rd(3,rz),rd(4,rT),rd(5,rI),rd(6,rK)],og);var ox=class{constructor(e,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let r=e.createElement("span");r.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[r,s,n,o],this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(o),i.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,i,r,s){e===this._font&&i===this._fontSize&&r===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=i,this._weight=r,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,i,r){let s=0;if(!i&&!r&&1===e.length&&(s=e.charCodeAt(0))<256){if(-9999!==this._flat[s])return this._flat[s];let i=this._measure(e,0);return i>0&&(this._flat[s]=i),i}let n=e;i&&(n+="B"),r&&(n+="I");let o=this._holey.get(n);if(void 0===o){let s=0;i&&(s|=1),r&&(s|=2),(o=this._measure(e,s))>0&&this._holey.set(n,o)}return o}_measure(e,i){let r=this._measureElements[i];return r.textContent=e.repeat(32),r.offsetWidth/32}},ob=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,i,r,s=!1){if(this.selectionStart=i,this.selectionEnd=r,!i||!r||i[0]===r[0]&&i[1]===r[1])return void this.clear();let n=e.buffers.active.ydisp,o=i[1]-n,a=r[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);l>=e.rows||h<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=i[0],this.endCol=r[0])}isCellSelected(e,i,r){return!!this.hasSelection&&(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?i>=this.startCol&&r>=this.viewportCappedStartRow&&i<this.endCol&&r<=this.viewportCappedEndRow:i<this.startCol&&r>=this.viewportCappedStartRow&&i>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&i>=this.startCol&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&i>=this.startCol)}},oy="xterm-dom-renderer-owner-",oS="xterm-rows",ow="xterm-fg-",oC="xterm-bg-",ok="xterm-focus",oE="xterm-selection",oN=1,oR=class extends r9{constructor(e,i,r,s,n,o,a,l,h,c,d,u,f,p){super(),this._terminal=e,this._document=i,this._element=r,this._screenElement=s,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=p,this._terminalClass=oN++,this._rowElements=[],this._selectionRenderModel=new ob,this.onRequestRedraw=this._register(new s_).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(oS),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(oE),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:o_(),cell:o_()},device:{canvas:o_(),cell:o_(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(og,document),this._element.classList.add(oy+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(r3(()=>{this._element.classList.remove(oy+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ox(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;for(let i of(this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows,this._rowElements))i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let i=`${this._terminalSelector} .${oS} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=i,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let i=`${this._terminalSelector} .${oS} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;i+=`${this._terminalSelector} .${oS} .xterm-dim { color: ${aU.multiplyOpacity(e.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 r=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;for(let[o,a]of(i+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}@keyframes ${s} { 50% { box-shadow: none; }}@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${oS}.${ok} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${oS}.${ok} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${oS}.${ok} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${oS} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${oS} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${oS} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${oS} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${oS} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${oE} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${oE} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${oE} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))i+=`${this._terminalSelector} .${ow}${o} { color: ${a.css}; }${this._terminalSelector} .${ow}${o}.xterm-dim { color: ${aU.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${oC}${o} { background-color: ${a.css}; }`;i+=`${this._terminalSelector} .${ow}257 { color: ${aU.opaque(e.background).css}; }${this._terminalSelector} .${ow}257.xterm-dim { color: ${aU.multiplyOpacity(aU.opaque(e.background),.5).css}; }${this._terminalSelector} .${oC}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=i}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,i){for(let e=this._rowElements.length;e<=i;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,i){this._refreshRowElements(e,i),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(ok),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ok),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,i,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,i,r),this.renderRows(0,this._bufferService.rows-1),!e||!i||(this._selectionRenderModel.update(this._terminal,e,i,r),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(r){let r=e[0]>i[0];l.appendChild(this._createSelectionElement(o,r?i[0]:e[0],r?e[0]:i[0],a-o+1))}else{let r=s===o?e[0]:0,h=o===n?i[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(o,r,h)),l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,a-o-1)),o!==a){let e=n===a?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,i,r,s=1){let n=this._document.createElement("div"),o=i*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(r-i);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${s*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,i){let r=this._bufferService.buffer,s=r.ybase+r.y,n=Math.min(r.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=i;h++){let e=h+r.ydisp,i=this._rowElements[h],c=r.lines.get(e);if(!i||!c)break;i.replaceChildren(...this._rowFactory.createRow(c,e,e===s,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${oy}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,i,r,s,n,o){r<0&&(e=0),s<0&&(i=0);let a=this._bufferService.rows-1;r=Math.max(Math.min(r,a),0),s=Math.max(Math.min(s,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=r;a<=s;++a){let p=a+l.ydisp,m=this._rowElements[a],_=l.lines.get(p);if(!m||!_)break;m.replaceChildren(...this._rowFactory.createRow(_,p,p===h,u,f,c,d,this.dimensions.css.cell.width,this._widthCache,o?a===r?e:0:-1,o?(a===s?i:n)-1:-1))}}};oR=rc([rd(7,rM),rd(8,rF),rd(9,rL),rd(10,rR),rd(11,rT),rd(12,rz),rd(13,rK)],oR);var oj=class extends r9{constructor(e,i,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new s_),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new oM(this._optionsService))}catch{this._measureStrategy=this._register(new oD(e,i,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};oj=rc([rd(2,rL)],oj);var oT=class extends r9{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,i){void 0!==e&&e>0&&void 0!==i&&i>0&&(this._result.width=e,this._result.height=i)}},oD=class extends oT{constructor(e,i,r){super(),this._document=e,this._parentElement=i,this._optionsService=r,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}},oM=class extends oT{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let i=this._ctx.measureText("W");if(!("width"in i&&"fontBoundingBoxAscent"in i&&"fontBoundingBoxDescent"in i))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},oP=class extends r9{constructor(e,i,r){super(),this._textarea=e,this._window=i,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new oL(this._window)),this._onDprChange=this._register(new s_),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new s_),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(sh.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(nb(this._textarea,"focus",()=>this._isFocused=!0)),this._register(nb(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},oL=class extends r9{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new r8),this._onDprChange=this._register(new s_),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(r3(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=nb(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)}},oA=class extends r9{constructor(){super(),this.linkProviders=[],this._register(r3(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let i=this.linkProviders.indexOf(e);-1!==i&&this.linkProviders.splice(i,1)}}}};function oB(e,i,r){let s=r.getBoundingClientRect(),n=e.getComputedStyle(r),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[i.clientX-s.left-o,i.clientY-s.top-a]}var oI=class{constructor(e,i){this._renderService=e,this._charSizeService=i}getCoords(e,i,r,s,n){return function(e,i,r,s,n,o,a,l,h){if(!o)return;let c=oB(e,i,r);return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),s+ +!!h),c[1]=Math.min(Math.max(c[1],1),n),c}(window,e,i,r,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,i){let r=oB(window,e,i);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};oI=rc([rd(0,r$),rd(1,rF)],oI);var oO=class{constructor(e,i){this._renderCallback=e,this._coreBrowserService=i,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,i,r){this._rowCount=r,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i,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 e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},oF={},oz={getSafariVersion:()=>oY,isChromeOS:()=>o0,isFirefox:()=>oK,isIpad:()=>oX,isIphone:()=>oJ,isLegacyEdge:()=>oq,isLinux:()=>oZ,isMac:()=>oG,isNode:()=>o$,isSafari:()=>oV,isWindows:()=>oQ};for(var oH in oz)rl(oF,oH,{get:oz[oH],enumerable:!0});var o$="u">typeof ra.default&&"title"in ra.default,oW=o$?"node":navigator.userAgent,oU=o$?"node":navigator.platform,oK=oW.includes("Firefox"),oq=oW.includes("Edge"),oV=/^((?!chrome|android).)*safari/i.test(oW);function oY(){if(!oV)return 0;let e=oW.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var oG=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(oU),oX="iPad"===oU,oJ="iPhone"===oU,oQ=["Windows","Win16","Win32","WinCE"].includes(oU),oZ=oU.indexOf("Linux")>=0,o0=/\bCrOS\b/.test(oW),o1=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let i=0,r=0,s=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,1.5*(r=Math.max(i=Math.max(1,performance.now()-i),r))>(n=e.timeRemaining())){s-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-i))}ms`),this._start();return}s=n}this.clear()}},o2=class extends o1{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let i=performance.now()+e;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},o5=class extends o1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},o3=!o$&&"requestIdleCallback"in window?o5:o2,o4=class{constructor(){this._queue=new o3}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},o6=class extends r9{constructor(e,i,r,s,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=s,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new r8),this._pausedResizeTask=new o4,this._observerDisposable=this._register(new r8),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 s_),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new s_),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new s_),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new s_),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new oO((e,i)=>this._renderRows(e,i),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new o9(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(r3(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,i)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,i){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});r.observe(i),this._observerDisposable.value=r3(()=>r.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,i,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),i=Math.max(i,s.end)),r||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,i,this._rowCount)}_renderRows(e,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);e=Math.min(e,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(e,i),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:i}),this._onRender.fire({start:e,end:i}),this._isNextRenderRedrawOnly=!0}}resize(e,i){this._rowCount=i,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){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(e,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,i)):this._renderer.value.handleResize(e,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,i,r){this._selectionState.start=e,this._selectionState.end=i,this._selectionState.columnSelectMode=r,this._renderer.value?.handleSelectionChanged(e,i,r)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};o6=rc([rd(2,rL),rd(3,rF),rd(4,rT),rd(5,rI),rd(6,rR),rd(7,rz),rd(8,rK)],o6);var o9=class{constructor(e,i,r){this._coreBrowserService=e,this._coreService=i,this._onTimeout=r,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,i){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,i)):(this._start=e,this._end=i,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 e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function o8(e,i,r,s){return ai(Math.abs(e-o7(e,r)-(i-o7(i,r)))-function(e,i,r){let s=0,n=e-o7(e,r),o=i-o7(i,r);for(let a=0;a<Math.abs(n-o);a++){let o="A"===function(e,i){return e>i?"A":"B"}(e,i)?-1:1;r.buffer.lines.get(n+o*a)?.isWrapped&&s++}return s}(e,i,r),at(e>i?"A":"B",s))}function o7(e,i){let r=0,s=i.buffer.lines.get(e),n=s?.isWrapped;for(;n&&e>=0&&e<i.rows;)r++,s=i.buffer.lines.get(--e),n=s?.isWrapped;return r}function ae(e,i,r,s,n,o){let a=e,l=i,h="";for(;(a!==r||l!==s)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),e=a=o.cols-1,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function at(e,i){return n6.ESC+(i?"O":"[")+e}function ai(e,i){e=Math.floor(e);let r="";for(let s=0;s<e;s++)r+=i;return r}var ar=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,i=this.selectionEnd;return!!e&&!!i&&(e[1]>i[1]||e[1]===i[1]&&e[0]>i[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function as(e,i){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return i*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var an=RegExp(" ","g"),ao=class extends r9{constructor(e,i,r,s,n,o,a,l,h){super(),this._element=e,this._screenElement=i,this._linkifier=r,this._bufferService=s,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rw,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new s_),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new s_),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new s_),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new s_),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new ar(this._bufferService),this._activeSelectionMode=0,this._register(r3(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1])}get selectionText(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!e||!i)return"";let r=this._bufferService.buffer,s=[];if(3===this._activeSelectionMode){if(e[0]===i[0])return"";let n=e[0]<i[0]?e[0]:i[0],o=e[0]<i[0]?i[0]:e[0];for(let a=e[1];a<=i[1];a++){let e=r.translateBufferLineToString(a,!0,n,o);s.push(e)}}else{let n=e[1]===i[1]?i[0]:void 0;s.push(r.translateBufferLineToString(e[1],!0,e[0],n));for(let n=e[1]+1;n<=i[1]-1;n++){let e=r.lines.get(n),i=r.translateBufferLineToString(n,!0);e?.isWrapped?s[s.length-1]+=i:s.push(i)}if(e[1]!==i[1]){let e=r.lines.get(i[1]),n=r.translateBufferLineToString(i[1],!0,0,i[0]);e&&e.isWrapped?s[s.length-1]+=n:s.push(n)}}return s.map(e=>e.replace(an," ")).join(oQ?`\r
14
18
  `:`
15
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),oX&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(e){let i=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!!r&&!!s&&!!i&&this._areCoordsInSelection(i,r,s)}isCellInSelection(e,i){let r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!!r&&!!s&&this._areCoordsInSelection([e,i],r,s)}_areCoordsInSelection(e,i,r){return e[1]>i[1]&&e[1]<r[1]||i[1]===r[1]&&e[1]===i[1]&&e[0]>=i[0]&&e[0]<r[0]||i[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||i[1]<r[1]&&e[1]===i[1]&&e[0]>=i[0]}_selectWordAtCursor(e,i){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=at(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return!!s&&(this._selectWordAt(s,i),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,i){this._model.clearSelection(),e=Math.max(e,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let i=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(e){let i=oL(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return i>=0&&i<=r?0:(i>r&&(i-=r),(i=Math.min(Math.max(i,-50),50)/50)/Math.abs(i)+Math.round(14*i))}shouldForceSelection(e){return oq?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&0===i.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let i=this._getMouseBufferCoords(e);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(e){return e.altKey&&!(oq&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let i=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!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(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let e=r.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}i&&i[0]===this._model.selectionEnd[0]&&i[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let i=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&void 0!==i[0]&&void 0!==i[1]){let e=function(e,i,r,s){var n,o,a,l,h,c,d,u,f,p,_,m,g,v,x,b;let y,S=r.buffer.x,w=r.buffer.y;if(!r.buffer.hasScrollback){let b,y,C;return n=S,(0===o4(o=w,i,a=r,l=s).length?"":o7(o9(n,o,n,o-o6(o,a),!1,a).length,o8("D",l)))+o4(w,i,r,s)+(h=S,c=w,d=e,b=o4(c,u=i,f=r,p=s).length>0?u-o6(u,f):c,C=(_=h,m=c,y=o4(g=d,v=u,x=f,p).length>0?v-o6(v,x):m,_<g&&y<=v||_>=g&&y<v?"C":"D"),o7(o9(h,b,d,u,"C"===C,f).length,o8(C,p)))}if(w===i)return y=S>e?"D":"C",o7(Math.abs(S-e),o8(y,s));y=w>i?"D":"C";let C=Math.abs(w-i);return o7((b=w>i?e:S,r.cols-b+(C-1)*r.cols+1+((w>i?S:e)-1)),o8(y,s))}(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,r=!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,i,r);return}!e||!i||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&i[0]===this._oldSelectionEnd[0]&&i[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,i,r)}_fireOnSelectionChange(e,i,r){this._oldSelectionStart=e,this._oldSelectionEnd=i,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,i){let r=i;for(let s=0;i>=s;s++){let n=e.loadCell(s,this._workCell).getChars().length;0===this._workCell.getWidth()?r--:n>1&&i!==s&&(r+=n-1)}return r}setSelection(e,i,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,i],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,i,r=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,d=0,u=0,f=0,p=0;if(" "===a.charAt(l)){for(;l>0&&" "===a.charAt(l-1);)l--;for(;h<a.length&&" "===a.charAt(h+1);)h++}else{let i=e[0],r=e[0];0===o.getWidth(i)&&(d++,i--),2===o.getWidth(r)&&(u++,r++);let s=o.getString(r).length;for(s>1&&(p+=s-1,h+=s-1);i>0&&l>0&&!this._isCharWordSeparator(o.loadCell(i-1,this._workCell));){o.loadCell(i-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(d++,i--):e>1&&(f+=e-1,l-=e-1),l--,i--}for(;r<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(r+1,this._workCell));){o.loadCell(r+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,r++):e>1&&(p+=e-1,h+=e-1),h++,r++}}h++;let _=l+c-d+f,m=Math.min(this._bufferService.cols,h-l+d+u-f-p);if(!(!i&&""===a.slice(l,h).trim())){if(r&&0===_&&32!==o.getCodePoint(0)){let i=n.lines.get(e[1]-1);if(i&&o.isWrapped&&32!==i.getCodePoint(this._bufferService.cols-1)){let i=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(i){let e=this._bufferService.cols-i.start;_-=e,m+=e}}}if(s&&_+m===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){let i=n.lines.get(e[1]+1);if(i?.isWrapped&&32!==i.getCodePoint(0)){let i=this._getWordAt([0,e[1]+1],!1,!1,!0);i&&(m+=i.length)}}return{start:_,length:m}}}_selectWordAt(e,i){let r=this._getWordAt(e,i);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let i=this._getWordAt(e,!0);if(i){let r=e[1];for(;i.start<0;)i.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;i.start+i.length>this._bufferService.cols;)i.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?i.start:i.start+i.length,r]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let i=this._bufferService.buffer.getWrappedRangeForLine(e),r={start:{x:0,y:i.first},end:{x:this._bufferService.cols-1,y:i.last}};this._model.selectionStart=[0,i.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=at(r,this._bufferService.cols)}};ar=ra([rl(3,rk),rl(4,rN),rl(5,rO),rl(6,rD),rl(7,rF),rl(8,rI)],ar);var as=class{constructor(){this._data={}}set(e,i,r){this._data[e]||(this._data[e]={}),this._data[e][i]=r}get(e,i){return this._data[e]?this._data[e][i]:void 0}clear(){this._data={}}},an=class{constructor(){this._color=new as,this._css=new as}setCss(e,i,r){this._css.set(e,i,r)}getCss(e,i){return this._css.get(e,i)}setColor(e,i,r){this._color.set(e,i,r)}getColor(e,i){return this._color.get(e,i)}clear(){this._color.clear(),this._css.clear()}},ao=Object.freeze((()=>{let e=[a$.toColor("#2e3436"),a$.toColor("#cc0000"),a$.toColor("#4e9a06"),a$.toColor("#c4a000"),a$.toColor("#3465a4"),a$.toColor("#75507b"),a$.toColor("#06989a"),a$.toColor("#d3d7cf"),a$.toColor("#555753"),a$.toColor("#ef2929"),a$.toColor("#8ae234"),a$.toColor("#fce94f"),a$.toColor("#729fcf"),a$.toColor("#ad7fa8"),a$.toColor("#34e2e2"),a$.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let r=0;r<216;r++){let s=i[r/36%6|0],n=i[r/6%6|0],o=i[r%6];e.push({css:n6.toCss(s,n,o),rgba:n6.toRgba(s,n,o)})}for(let i=0;i<24;i++){let r=8+10*i;e.push({css:n6.toCss(r,r,r),rgba:n6.toRgba(r,r,r)})}return e})()),aa=a$.toColor("#ffffff"),al=a$.toColor("#000000"),ah=a$.toColor("#ffffff"),ac={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},ad=class extends r3{constructor(e){super(),this._optionsService=e,this._contrastCache=new an,this._halfContrastCache=new an,this._onChangeColors=this._register(new sf),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:aa,background:al,cursor:ah,cursorAccent:al,selectionForeground:void 0,selectionBackgroundTransparent:ac,selectionBackgroundOpaque:az.blend(al,ac),selectionInactiveBackgroundTransparent:ac,selectionInactiveBackgroundOpaque:az.blend(al,ac),scrollbarSliderBackground:az.opacity(aa,.2),scrollbarSliderHoverBackground:az.opacity(aa,.4),scrollbarSliderActiveBackground:az.opacity(aa,.5),overviewRulerBorder:aa,ansi:ao.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let i=this._colors;if(i.foreground=au(e.foreground,aa),i.background=au(e.background,al),i.cursor=az.blend(i.background,au(e.cursor,ah)),i.cursorAccent=az.blend(i.background,au(e.cursorAccent,al)),i.selectionBackgroundTransparent=au(e.selectionBackground,ac),i.selectionBackgroundOpaque=az.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=au(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=az.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?au(e.selectionForeground,ot):void 0,i.selectionForeground===ot&&(i.selectionForeground=void 0),az.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=az.opacity(i.selectionBackgroundTransparent,.3)),az.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=az.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=au(e.scrollbarSliderBackground,az.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=au(e.scrollbarSliderHoverBackground,az.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=au(e.scrollbarSliderActiveBackground,az.opacity(i.foreground,.5)),i.overviewRulerBorder=au(e.overviewRulerBorder,aa),i.ansi=ao.slice(),i.ansi[0]=au(e.black,ao[0]),i.ansi[1]=au(e.red,ao[1]),i.ansi[2]=au(e.green,ao[2]),i.ansi[3]=au(e.yellow,ao[3]),i.ansi[4]=au(e.blue,ao[4]),i.ansi[5]=au(e.magenta,ao[5]),i.ansi[6]=au(e.cyan,ao[6]),i.ansi[7]=au(e.white,ao[7]),i.ansi[8]=au(e.brightBlack,ao[8]),i.ansi[9]=au(e.brightRed,ao[9]),i.ansi[10]=au(e.brightGreen,ao[10]),i.ansi[11]=au(e.brightYellow,ao[11]),i.ansi[12]=au(e.brightBlue,ao[12]),i.ansi[13]=au(e.brightMagenta,ao[13]),i.ansi[14]=au(e.brightCyan,ao[14]),i.ansi[15]=au(e.brightWhite,ao[15]),e.extendedAnsi){let r=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<r;s++)i.ansi[s+16]=au(e.extendedAnsi[s],ao[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0===e){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function au(e,i){if(void 0!==e)try{return a$.toColor(e)}catch{}return i}ad=ra([rl(0,rD)],ad);var af=class{constructor(...e){for(let[i,r]of(this._entries=new Map,e))this.set(i,r)}set(e,i){let r=this._entries.get(e);return this._entries.set(e,i),r}forEach(e){for(let[i,r]of this._entries.entries())e(i,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ap=class{constructor(){this._services=new af,this._services.set(rj,this)}setService(e,i){this._services.set(e,i)}getService(e){return this._services.get(e)}createInstance(e,...i){let r=(e[rS]||[]).sort((e,i)=>e.index-i.index),s=[];for(let i of r){let r=this._services.get(i.id);if(!r)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${i.id._id}.`);s.push(r)}let n=r.length>0?r[0].index:i.length;if(i.length!==n)throw Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${i.length} static arguments`);return new e(...i,...s)}},a_={trace:0,debug:1,info:2,warn:3,error:4,off:5},am=class extends r3{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=a_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let i=0;i<e.length;i++)"function"==typeof e[i]&&(e[i]=e[i]())}_log(e,i,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...r)}trace(e,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,i)}debug(e,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,i)}info(e,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,i)}warn(e,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,i)}error(e,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,i)}};am=ra([rl(0,rD)],am);var ag=class extends r3{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new sf),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new sf),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new sf),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let i=Array(e);for(let r=0;r<Math.min(e,this.length);r++)i[r]=this._array[this._getCyclicIndex(r)];this._array=i,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let i=this._length;i<e;i++)this._array[i]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,i){this._array[this._getCyclicIndex(e)]=i}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,i,...r){if(i){for(let r=e;r<this._length-i;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+i)];this._length-=i,this.onDeleteEmitter.fire({index:e,amount:i})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+r.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<r.length;i++)this._array[this._getCyclicIndex(e+i)]=r[i];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let e=this._length+r.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,i,r){if(!(i<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+r<0)throw Error("Cannot shift elements in list beyond index 0");if(r>0){for(let s=i-1;s>=0;s--)this.set(e+s+r,this.get(e+s));let s=e+i+r-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<i;s++)this.set(e+s+r,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},av=Object.freeze(new rv),ax=0,ab=class e{constructor(e,i,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let s=i||rb.fromCharData([0,"",1,0]);for(let i=0;i<e;++i)this.setCell(i,s);this.length=e}get(e){let i=this._data[3*e+0],r=2097151&i;return[this._data[3*e+1],2097152&i?this._combined[e]:r?rp(r):"",i>>22,2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):r]}set(e,i){this._data[3*e+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[3*e+0]=2097152|e|i[2]<<22):this._data[3*e+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&i}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e]:2097151&i?rp(2097151&i):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,i){return ax=3*e,i.content=this._data[ax+0],i.fg=this._data[ax+1],i.bg=this._data[ax+2],2097152&i.content&&(i.combinedData=this._combined[e]),0x10000000&i.bg&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){2097152&i.content&&(this._combined[e]=i.combinedData),0x10000000&i.bg&&(this._extendedAttrs[e]=i.extended),this._data[3*e+0]=i.content,this._data[3*e+1]=i.fg,this._data[3*e+2]=i.bg}setCellFromCodepoint(e,i,r,s){0x10000000&s.bg&&(this._extendedAttrs[e]=s.extended),this._data[3*e+0]=i|r<<22,this._data[3*e+1]=s.fg,this._data[3*e+2]=s.bg}addCodepointToCell(e,i,r){let s=this._data[3*e+0];2097152&s?this._combined[e]+=rp(i):2097151&s?(this._combined[e]=rp(2097151&s)+rp(i),s&=-2097152,s|=2097152):s=4194304|i,r&&(s&=-0xc00001,s|=r<<22),this._data[3*e+0]=s}insertCells(e,i,r){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),i<this.length-e){let s=new rb;for(let r=this.length-e-i-1;r>=0;--r)this.setCell(e+i+r,this.loadCell(e+r,s));for(let s=0;s<i;++s)this.setCell(e+s,r)}else for(let i=e;i<this.length;++i)this.setCell(i,r);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(e,i,r){if(e%=this.length,i<this.length-e){let s=new rb;for(let r=0;r<this.length-e-i;++r)this.setCell(e+r,this.loadCell(e+i+r,s));for(let e=this.length-i;e<this.length;++e)this.setCell(e,r)}else for(let i=e;i<this.length;++i)this.setCell(i,r);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,r)}replaceCells(e,i,r,s=!1){if(s){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),i<this.length&&2===this.getWidth(i-1)&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,r);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,r),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),i<this.length&&2===this.getWidth(i-1)&&this.setCellFromCodepoint(i,0,1,r);e<i&&e<this.length;)this.setCell(e++,r)}resize(e,i){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let r=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*r)this._data=new Uint32Array(this._data.buffer,0,r);else{let e=new Uint32Array(r);e.set(this._data),this._data=e}for(let r=this.length;r<e;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,r);let i=Object.keys(this._combined);for(let r=0;r<i.length;r++){let s=parseInt(i[r],10);s>=e&&delete this._combined[s]}let s=Object.keys(this._extendedAttrs);for(let i=0;i<s.length;i++){let r=parseInt(s[i],10);r>=e&&delete this._extendedAttrs[r]}}return this.length=e,4*r*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){for(let i in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[i]=e._combined[i];for(let i in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let i=new e(0);for(let e in i._data=new Uint32Array(this._data),i.length=this.length,this._combined)i._combined[e]=this._combined[e];for(let e in this._extendedAttrs)i._extendedAttrs[e]=this._extendedAttrs[e];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,i,r,s,n){let o=e._data;if(n)for(let n=s-1;n>=0;n--){for(let e=0;e<3;e++)this._data[(r+n)*3+e]=o[(i+n)*3+e];0x10000000&o[(i+n)*3+2]&&(this._extendedAttrs[r+n]=e._extendedAttrs[i+n])}else for(let n=0;n<s;n++){for(let e=0;e<3;e++)this._data[(r+n)*3+e]=o[(i+n)*3+e];0x10000000&o[(i+n)*3+2]&&(this._extendedAttrs[r+n]=e._extendedAttrs[i+n])}let a=Object.keys(e._combined);for(let s=0;s<a.length;s++){let n=parseInt(a[s],10);n>=i&&(this._combined[n-i+r]=e._combined[n])}}translateToString(e,i,r,s){i=i??0,r=r??this.length,e&&(r=Math.min(r,this.getTrimmedLength())),s&&(s.length=0);let n="";for(;i<r;){let e=this._data[3*i+0],r=2097151&e,o=2097152&e?this._combined[i]:r?rp(r):" ";if(n+=o,s)for(let e=0;e<o.length;++e)s.push(i);i+=e>>22||1}return s&&s.push(i),n}};function ay(e,i,r){if(i===e.length-1)return e[i].getTrimmedLength();let s=!e[i].hasContent(r-1)&&1===e[i].getWidth(r-1),n=2===e[i+1].getWidth(0);return s&&n?r-1:r}var aS=class e{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new sf),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),r0(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};aS._nextId=1;var aw={},aC=aw.B;aw[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:"≥","{":"π","|":"≠","}":"£","~":"·"},aw.A={"#":"£"},aw.B=void 0,aw[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},aw.C=aw[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},aw.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},aw.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},aw.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},aw.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},aw.E=aw[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},aw.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},aw.H=aw[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},aw["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ak=class{constructor(e,i,r){this._hasScrollback=e,this._optionsService=i,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=av.clone(),this.savedCharset=aC,this.markers=[],this._nullCell=rb.fromCharData([0,"",1,0]),this._whitespaceCell=rb.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new o1,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ag(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rx),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rx),this._whitespaceCell}getBlankLine(e,i){return new ab(this._bufferService.cols,this.getNullCell(e),i)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let i=e+this._optionsService.rawOptions.scrollback;return i>0xffffffff?0xffffffff:i}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=av);let i=this._rows;for(;i--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ag(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,i){let r=this.getNullCell(av),s=0,n=this._getCorrectBufferLength(i);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let i=0;i<this.lines.length;i++)s+=+this.lines.get(i).resize(e,r);let o=0;if(this._rows<i)for(let s=this._rows;s<i;s++)this.lines.length<i+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new ab(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ab(e,r)));else for(let e=this._rows;e>i;e--)this.lines.length>i+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let e=this.lines.length-n;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,i-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=i-1,this._isReflowEnabled&&(this._reflow(e,i),this._cols>e))for(let i=0;i<this.lines.length;i++)s+=+this.lines.get(i).resize(e,r);this._cols=e,this._rows=i,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let i=0;for(;this._memoryCleanupPosition<this.lines.length;)if((i+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,i){this._cols!==e&&(e>this._cols?this._reflowLarger(e,i):this._reflowSmaller(e,i))}_reflowLarger(e,i){let r=this._optionsService.rawOptions.reflowCursorLine,s=function(e,i,r,s,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let d=[e.get(l)];for(;h<e.length&&c.isWrapped;)d.push(c),c=e.get(++h);if(!o&&s>=l&&s<h){l+=d.length-1;continue}let u=0,f=ay(d,0,i),p=1,_=0;for(;p<d.length;){let e=ay(d,p,i),s=Math.min(e-_,r-f);d[u].copyCellsFrom(d[p],_,f,s,!1),(f+=s)===r&&(u++,f=0),(_+=s)===e&&(p++,_=0),0===f&&0!==u&&2===d[u-1].getWidth(r-1)&&(d[u].copyCellsFrom(d[u-1],r-1,f++,1,!1),d[u-1].setCell(r-1,n))}d[u].replaceCells(f,r,n);let m=0;for(let e=d.length-1;e>0&&(e>u||0===d[e].getTrimmedLength());e--)m++;m>0&&(a.push(l+d.length-m),a.push(m)),l+=d.length-1}return a}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(av),r);if(s.length>0){let r=function(e,i){let r=[],s=0,n=i[0],o=0;for(let a=0;a<e.length;a++)if(n===a){let r=i[++s];e.onDeleteEmitter.fire({index:a-o,amount:r}),a+=r-1,o+=r,n=i[++s]}else r.push(a);return{layout:r,countRemoved:o}}(this.lines,s);(function(e,i){let r=[];for(let s=0;s<i.length;s++)r.push(e.get(i[s]));for(let i=0;i<r.length;i++)e.set(i,r[i]);e.length=i.length})(this.lines,r.layout),this._reflowLargerAdjustViewport(e,i,r.countRemoved)}}_reflowLargerAdjustViewport(e,i,r){let s=this.getNullCell(av),n=r;for(;n-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new ab(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,i){let r=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(av),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!r){let e=this.ybase+this.y;if(e>=a&&e<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=function(e,i,r){let s=[],n=e.map((r,s)=>ay(e,s,i)).reduce((e,i)=>e+i),o=0,a=0,l=0;for(;l<n;){if(n-l<r){s.push(n-l);break}o+=r;let h=ay(e,a,i);o>h&&(o-=h,a++);let c=2===e[a].getWidth(o-1);c&&o--;let d=c?r-1:r;s.push(d),l+=d}return s}(h,this._cols,e),u=d.length-h.length,f;f=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let p=[];for(let e=0;e<u;e++){let e=this.getBlankLine(av,!0);p.push(e)}p.length>0&&(n.push({start:a+h.length+o,newLines:p}),o+=p.length),h.push(...p);let _=d.length-1,m=d[_];0===m&&(m=d[--_]);let g=h.length-u-1,v=c;for(;g>=0;){let e=Math.min(v,m);if(void 0===h[_])break;h[_].copyCellsFrom(h[g],v-e,m-e,e,!0),0==(m-=e)&&(m=d[--_]),0==(v-=e)&&(v=ay(h,Math.max(--g,0),this._cols))}for(let i=0;i<h.length;i++)d[i]<e&&h[i].setCell(d[i],s);let x=u-f;for(;x-- >0;)0===this.ybase?this.y<i-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-i&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+i-1)}if(n.length>0){let e=[],i=[];for(let e=0;e<this.lines.length;e++)i.push(this.lines.get(e));let r=this.lines.length,s=r-1,a=0,l=n[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let h=0;for(let c=Math.min(this.lines.maxLength-1,r+o-1);c>=0;c--)if(l&&l.start>s+h){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(c--,l.newLines[e]);c++,e.push({index:s+1,amount:l.newLines.length}),h+=l.newLines.length,l=n[++a]}else this.lines.set(c,i[s--]);let c=0;for(let i=e.length-1;i>=0;i--)e[i].index+=c,this.lines.onInsertEmitter.fire(e[i]),c+=e[i].amount;let d=Math.max(0,r+o-this.lines.maxLength);d>0&&this.lines.onTrimEmitter.fire(d)}}translateBufferLineToString(e,i,r=0,s){let n=this.lines.get(e);return n?n.translateToString(i,r,s):""}getWrappedRangeForLine(e){let i=e,r=e;for(;i>0&&this.lines.get(i).isWrapped;)i--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:i,last:r}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let i=0;i<this.markers.length;i++)this.markers[i].line===e&&(this.markers[i].dispose(),this.markers.splice(i--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let i=new aS(e);return this.markers.push(i),i.register(this.lines.onTrim(e=>{i.line-=e,i.line<0&&i.dispose()})),i.register(this.lines.onInsert(e=>{i.line>=e.index&&(i.line+=e.amount)})),i.register(this.lines.onDelete(e=>{i.line>=e.index&&i.line<e.index+e.amount&&i.dispose(),i.line>e.index&&(i.line-=e.amount)})),i.register(i.onDispose(()=>this._removeMarker(i))),i}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},aE=class extends r3{constructor(e,i){super(),this._optionsService=e,this._bufferService=i,this._onBufferActivate=this._register(new sf),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 ak(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ak(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,i){this._normal.resize(e,i),this._alt.resize(e,i),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},aN=class extends r3{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new sf),this.onResize=this._onResize.event,this._onScroll=this._register(new sf),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new aE(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,i){let r=this.cols!==e,s=this.rows!==i;this.cols=e,this.rows=i,this.buffers.resize(e,i),this._onResize.fire({cols:e,rows:i,colsChanged:r,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,i=!1){let r=this.buffer,s;(s=this._cachedBlankLine)&&s.length===this.cols&&s.getFg(0)===e.fg&&s.getBg(0)===e.bg||(s=r.getBlankLine(e,i),this._cachedBlankLine=s),s.isWrapped=i;let n=r.ybase+r.scrollTop,o=r.ybase+r.scrollBottom;if(0===r.scrollTop){let e=r.lines.isFull;o===r.lines.length-1?e?r.lines.recycle().copyFrom(s):r.lines.push(s.clone()):r.lines.splice(o+1,0,s.clone()),e?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let e=o-n+1;r.lines.shiftElements(n+1,e-1,-1),r.lines.set(o,s.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,i){let r=this.buffer;if(e<0){if(0===r.ydisp)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let s=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),s!==r.ydisp&&(i||this._onScroll.fire(r.ydisp))}};aN=ra([rl(0,rD)],aN);var aR={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:oq,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},aj=["normal","bold","100","200","300","400","500","600","700","800","900"],aT=class extends r3{constructor(e){super(),this._onOptionChange=this._register(new sf),this.onOptionChange=this._onOptionChange.event;let i={...aR};for(let r in e)if(r in i)try{let s=e[r];i[r]=this._sanitizeAndValidateOption(r,s)}catch(e){console.error(e)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(r1(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,i){return this.onOptionChange(r=>{r===e&&i(this.rawOptions[e])})}onMultipleOptionChange(e,i){return this.onOptionChange(r=>{-1!==e.indexOf(r)&&i()})}_setupOptions(){let e=e=>{if(!(e in aR))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},i=(e,i)=>{if(!(e in aR))throw Error(`No option with key "${e}"`);i=this._sanitizeAndValidateOption(e,i),this.rawOptions[e]!==i&&(this.rawOptions[e]=i,this._onOptionChange.fire(e))};for(let r in this.rawOptions){let s={get:e.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this.options,r,s)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":var r;if(i||(i=aR[e]),"block"!==(r=i)&&"underline"!==r&&"bar"!==r)throw Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=aR[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=aj.includes(i)?i:aR[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}};function aD(e,i=5){if("object"!=typeof e)return e;let r=Array.isArray(e)?[]:{};for(let s in e)r[s]=i<=1?e[s]:e[s]&&aD(e[s],i-1);return r}var aM=Object.freeze({insertMode:!1}),aL=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),aP=class extends r3{constructor(e,i,r){super(),this._bufferService=e,this._logService=i,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new sf),this.onData=this._onData.event,this._onUserInput=this._register(new sf),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new sf),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new sf),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=aD(aM),this.decPrivateModes=aD(aL)}reset(){this.modes=aD(aM),this.decPrivateModes=aD(aL)}triggerDataEvent(e,i=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;i&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),i&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};aP=ra([rl(0,rk),rl(1,rT),rl(2,rD)],aP);var aA={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function aB(e,i){let r=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(r|=64,r|=e.action):(r|=3&e.button,4&e.button&&(r|=64),8&e.button&&(r|=128),32===e.action?r|=32:0!==e.action||i||(r|=3)),r}var aI=String.fromCharCode,aO={DEFAULT:e=>{let i=[aB(e,!1)+32,e.col+32,e.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`\x1b[M${aI(i[0])}${aI(i[1])}${aI(i[2])}`},SGR:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${aB(e,!0)};${e.col};${e.row}${i}`},SGR_PIXELS:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${aB(e,!0)};${e.x};${e.y}${i}`}},aF=class extends r3{constructor(e,i,r){for(let s of(super(),this._bufferService=e,this._coreService=i,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new sf),this.onProtocolChange=this._onProtocolChange.event,Object.keys(aA)))this.addProtocol(s,aA[s]);for(let e of Object.keys(aO))this.addEncoding(e,aO[e]);this.reset()}addProtocol(e,i){this._protocols[e]=i}addEncoding(e,i){this._encodings[e]=i}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,i,r){if(0===e.deltaY||e.shiftKey||void 0===i||void 0===r)return 0;let s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=i/r+0,50>Math.abs(e.deltaY)&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,i){return i.altKey||i.ctrlKey||i.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let i=this._encodings[this._activeEncoding](e);return i&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(i):this._coreService.triggerDataEvent(i,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,i,r){if(r){if(e.x!==i.x||e.y!==i.y)return!1}else if(e.col!==i.col||e.row!==i.row)return!1;return e.button===i.button&&e.action===i.action&&e.ctrl===i.ctrl&&e.alt===i.alt&&e.shift===i.shift}};aF=ra([rl(0,rk),rl(1,rN),rl(2,rD)],aF);var aH,az,a$,aW,aU,aK,aq=[[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]],aV=[[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]],aY=class{constructor(){if(this.version="6",!aK){(aK=new Uint8Array(65536)).fill(1),aK[0]=0,aK.fill(0,1,32),aK.fill(0,127,160),aK.fill(2,4352,4448),aK[9001]=2,aK[9002]=2,aK.fill(2,11904,42192),aK[12351]=1,aK.fill(2,44032,55204),aK.fill(2,63744,64256),aK.fill(2,65040,65050),aK.fill(2,65072,65136),aK.fill(2,65280,65377),aK.fill(2,65504,65511);for(let e=0;e<aq.length;++e)aK.fill(0,aq[e][0],aq[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?aK[e]:!function(e,i){let r=0,s=i.length-1,n;if(e<i[0][0]||e>i[s][1])return!1;for(;s>=r;)if(e>i[n=r+s>>1][1])r=n+1;else{if(!(e<i[n][0]))return!0;s=n-1}return!1}(e,aV)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,i){let r=this.wcwidth(e),s=0===r&&0!==i;if(s){let e=aG.extractWidth(i);0===e?s=!1:e>r&&(r=e)}return aG.createPropertyValue(0,r,s)}},aG=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new sf,this.onChange=this._onChange.event;let e=new aY;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,r=!1){return(0xffffff&e)<<3|(3&i)<<1|!!r}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(i){let r=0,s=0,n=i.length;for(let o=0;o<n;++o){let a=i.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return r+this.wcwidth(a);let e=i.charCodeAt(o);56320<=e&&e<=57343?a=(a-55296)*1024+e-56320+65536:r+=this.wcwidth(e)}let l=this.charProperties(a,s),h=e.extractWidth(l);e.extractShouldJoin(l)&&(h-=e.extractWidth(s)),r+=h,s=l}return r}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},aX=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,i){this._charsets[e]=i,this.glevel===e&&(this.charset=i)}};function aJ(e){let i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&i&&(r.isWrapped=0!==i[3]&&32!==i[3])}var aQ=class e{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(i){let r=new e;if(!i.length)return r;for(let e=+!!Array.isArray(i[0]);e<i.length;++e){let s=i[e];if(Array.isArray(s))for(let e=0;e<s.length;++e)r.addSubParam(s[e]);else r.addParam(s)}return r}clone(){let i=new e(this.maxLength,this.maxSubParamsLength);return i.params.set(this.params),i.length=this.length,i._subParams.set(this._subParams),i._subParamsLength=this._subParamsLength,i._subParamsIdx.set(this._subParamsIdx),i._rejectDigits=this._rejectDigits,i._rejectSubDigits=this._rejectSubDigits,i._digitIsSub=this._digitIsSub,i}toArray(){let e=[];for(let i=0;i<this.length;++i){e.push(this.params[i]);let r=this._subParamsIdx[i]>>8,s=255&this._subParamsIdx[i];s-r>0&&e.push(Array.prototype.slice.call(this._subParams,r,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>0x7fffffff?0x7fffffff:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,r=255&this._subParamsIdx[e];return r-i>0?this._subParams.subarray(i,r):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let r=this._subParamsIdx[i]>>8,s=255&this._subParamsIdx[i];s-r>0&&(e[i]=this._subParams.slice(r,s))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,s=r[i-1];r[i-1]=~s?Math.min(10*s+e,0x7fffffff):e}},aZ=[],a0=class{constructor(){this._state=0,this._active=aZ,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=aZ}reset(){if(2===this._state)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=aZ,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||aZ,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,i,r){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,i,r);else this._handlerFb(this._id,"PUT",r_(e,i,r))}start(){this.reset(),this._state=1}put(e,i,r){if(3!==this._state){if(1===this._state)for(;i<r;){let r=e[i++];if(59===r){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+r-48}2===this._state&&r-i>0&&this._put(e,i,r)}}end(e,i=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let r=!1,s=this._active.length-1,n=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;s>=0&&!0!==(r=this._active[s].end(e));s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if((r=this._active[s].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}else this._handlerFb(this._id,"END",e);this._active=aZ,this._id=-1,this._state=0}}},a1=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,i,r){this._hitLimit||(this._data+=r_(e,i,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data))instanceof Promise)return i.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,i}},a2=[],a5=class{constructor(){this._handlers=Object.create(null),this._active=a2,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a2}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=a2,this._ident=0}hook(e,i){if(this.reset(),this._ident=e,this._active=this._handlers[e]||a2,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(i);else this._handlerFb(this._ident,"HOOK",i)}put(e,i,r){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,i,r);else this._handlerFb(this._ident,"PUT",r_(e,i,r))}unhook(e,i=!0){if(this._active.length){let r=!1,s=this._active.length-1,n=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;s>=0&&!0!==(r=this._active[s].unhook(e));s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if((r=this._active[s].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}else this._handlerFb(this._ident,"UNHOOK",e);this._active=a2,this._ident=0}},a3=new aQ;a3.addParam(0);var a4=class{constructor(e){this._handler=e,this._data="",this._params=a3,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():a3,this._data="",this._hitLimit=!1}put(e,i,r){this._hitLimit||(this._data+=r_(e,i,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data,this._params))instanceof Promise)return i.then(e=>(this._params=a3,this._data="",this._hitLimit=!1,e));return this._params=a3,this._data="",this._hitLimit=!1,i}},a6=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,i){this.table.fill(e<<4|i)}add(e,i,r,s){this.table[i<<8|e]=r<<4|s}addMany(e,i,r,s){for(let n=0;n<e.length;n++)this.table[i<<8|e[n]]=r<<4|s}},a9=function(){let e=new a6(4095),i=Array.apply(null,Array(256)).map((e,i)=>i),r=(e,r)=>i.slice(e,r),s=r(32,127),n=r(0,24);n.push(25),n.push.apply(n,r(28,32));let o=r(0,14),a;for(a in e.setDefault(1,0),e.addMany(s,0,2,0),o)e.addMany([24,26,153,154],a,3,0),e.addMany(r(128,144),a,3,0),e.addMany(r(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),a8=class extends r3{constructor(e=a9){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new aQ,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,i,r)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,i)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(r1(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new a0),this._dcsParser=this._register(new a5),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,i=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((r=e.prefix.charCodeAt(0))&&60>r||r>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let s=e.intermediates.charCodeAt(i);if(32>s||s>47)throw Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=s}}if(1!==e.final.length)throw Error("final must be a single byte");let s=e.final.charCodeAt(0);if(i[0]>s||s>i[1])throw Error(`final must be in range ${i[0]} .. ${i[1]}`);return r<<=8,r|=s}identToString(e){let i=[];for(;e;)i.push(String.fromCharCode(255&e)),e>>=8;return i.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,i){let r=this._identifier(e,[48,126]);void 0===this._escHandlers[r]&&(this._escHandlers[r]=[]);let s=this._escHandlers[r];return s.push(i),{dispose:()=>{let e=s.indexOf(i);-1!==e&&s.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,i){this._executeHandlers[e.charCodeAt(0)]=i}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,i){let r=this._identifier(e);void 0===this._csiHandlers[r]&&(this._csiHandlers[r]=[]);let s=this._csiHandlers[r];return s.push(i),{dispose:()=>{let e=s.indexOf(i);-1!==e&&s.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,i){return this._dcsParser.registerHandler(this._identifier(e),i)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,i){return this._oscParser.registerHandler(e,i)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,i,r,s,n){this._parseStack.state=e,this._parseStack.handlers=i,this._parseStack.handlerPos=r,this._parseStack.transition=s,this._parseStack.chunkPos=n}parse(e,i,r){let s=0,n=0,o=0,a;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===r||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let i=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===r&&n>-1){for(;n>=0&&!0!==(a=i[n](this._params));n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 4:if(!1===r&&n>-1){for(;n>=0&&!0!==(a=i[n]());n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(24!==s&&26!==s,r))return a;27===s&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],a=this._oscParser.end(24!==s&&26!==s,r))return a;27===s&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let r=o;r<i;++r){switch(s=e[r],(n=this._transitions.table[this.currentState<<8|(s<160?s:160)])>>4){case 2:for(let n=r+1;;++n)if(n>=i||(s=e[n])<32||s>126&&s<160||++n>=i||(s=e[n])<32||s>126&&s<160||++n>=i||(s=e[n])<32||s>126&&s<160||++n>=i||(s=e[n])<32||s>126&&s<160){this._printHandler(e,r,n),r=n-1;break}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:r,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|s],l=o?o.length-1:-1;for(;l>=0&&!0!==(a=o[l](this._params));l--)if(a instanceof Promise)return this._preserveStack(3,o,l,n,r),a;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++r<i&&(s=e[r])>47&&s<60)r--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let h=this._escHandlers[this._collect<<8|s],c=h?h.length-1:-1;for(;c>=0&&!0!==(a=h[c]());c--)if(a instanceof Promise)return this._preserveStack(4,h,c,n,r),a;c<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let n=r+1;;++n)if(n>=i||24===(s=e[n])||26===s||27===s||s>127&&s<160){this._dcsParser.put(e,r,n),r=n-1;break}break;case 14:if(a=this._dcsParser.unhook(24!==s&&26!==s))return this._preserveStack(6,[],0,n,r),a;27===s&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let n=r+1;;n++)if(n>=i||(s=e[n])<32||s>127&&s<160){this._oscParser.put(e,r,n),r=n-1;break}break;case 6:if(a=this._oscParser.end(24!==s&&26!==s))return this._preserveStack(5,[],0,n,r),a;27===s&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},a7=/^([\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})$/,le=/^[\da-f]+$/;function lt(e){if(!e)return;let i=e.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let e=a7.exec(i);if(e){let i=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/i*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/i*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/i*255)]}}else if(0===i.indexOf("#")&&(i=i.slice(1),le.exec(i)&&[3,6,9,12].includes(i.length))){let e=i.length/3,r=[0,0,0];for(let s=0;s<3;++s){let n=parseInt(i.slice(e*s,e*s+e),16);r[s]=1===e?n<<4:2===e?n:3===e?n>>4:n>>8}return r}}function li(e,i){let r=e.toString(16),s=r.length<2?"0"+r:r;switch(i){case 4:return r[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}var lr={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function ls(e,i){if(e>24)return i.setWinLines||!1;switch(e){case 1:return!!i.restoreWin;case 2:return!!i.minimizeWin;case 3:return!!i.setWinPosition;case 4:return!!i.setWinSizePixels;case 5:return!!i.raiseWin;case 6:return!!i.lowerWin;case 7:return!!i.refreshWin;case 8:return!!i.setWinSizeChars;case 9:return!!i.maximizeWin;case 10:return!!i.fullscreenWin;case 11:return!!i.getWinState;case 13:return!!i.getWinPosition;case 14:return!!i.getWinSizePixels;case 15:return!!i.getScreenSizePixels;case 16:return!!i.getCellSizePixels;case 18:return!!i.getWinSizeChars;case 19:return!!i.getScreenSizeChars;case 20:return!!i.getIconTitle;case 21:return!!i.getWinTitle;case 22:return!!i.pushTitle;case 23:return!!i.popTitle;case 24:return!!i.setWinLines}return!1}var ln=0,lo=class extends r3{constructor(e,i,r,s,n,o,a,l,h=new a8){for(let c in super(),this._bufferService=e,this._charsetService=i,this._coreService=r,this._logService=s,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rm,this._utf8Decoder=new rg,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=av.clone(),this._eraseAttrDataInternal=av.clone(),this._onRequestBell=this._register(new sf),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new sf),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new sf),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new sf),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new sf),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new sf),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new sf),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new sf),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new sf),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new sf),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new sf),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new sf),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new sf),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 la(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,i)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:i.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,i,r)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:i,data:r})}),this._parser.setDcsHandlerFallback((e,i,r)=>{"HOOK"===i&&(r=r.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:i,payload:r})}),this._parser.setPrintHandler((e,i,r)=>this.print(e,i,r)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(n5.BEL,()=>this.bell()),this._parser.setExecuteHandler(n5.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(n5.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(n5.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(n5.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(n5.BS,()=>this.backspace()),this._parser.setExecuteHandler(n5.HT,()=>this.tab()),this._parser.setExecuteHandler(n5.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(n5.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(n3.IND,()=>this.index()),this._parser.setExecuteHandler(n3.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(n3.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new a1(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new a1(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new a1(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new a1(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new a1(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new a1(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new a1(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new a1(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new a1(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new a1(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new a1(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new a1(e=>this.restoreCursorColor(e))),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()),aw)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new a4((e,i)=>this.requestStatusString(e,i)))}getAttrData(){return this._curAttrData}_preserveStack(e,i,r,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=i,this._parseStack.decodedLength=r,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,i){let r,s=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,i))return this._logSlowResolvingAsync(r),r;s=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(o=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),a||this._dirtyRowTracker.clearRange(),e.length>131072)for(let i=o;i<e.length;i+=131072){let o=i+131072<e.length?i+131072:e.length,a="string"==typeof e?this._stringDecoder.decode(e.substring(i,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(i,o),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,a))return this._preserveStack(s,n,a,i),this._logSlowResolvingAsync(r),r}else if(!a){let i="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,i))return this._preserveStack(s,n,i,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==s||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,i,r){let s,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-i>0&&2===u.getWidth(this._activeBuffer.x-1)&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let p=i;p<r;++p){if((s=e[p])<127&&o){let e=o[String.fromCharCode(s)];e&&(s=e.charCodeAt(0))}let i=this._unicodeService.charProperties(s,f);n=aG.extractWidth(i);let r=aG.extractShouldJoin(i),_=r?aG.extractWidth(f):0;if(f=i,a&&this._onA11yChar.fire(rp(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-_>l){if(h){let e=u,i=this._activeBuffer.x-_;for(this._activeBuffer.x=_,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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),_>0&&u instanceof ab&&u.copyCellsFrom(e,i,0,_,!1);i<l;)e.setCellFromCodepoint(i++,0,1,d)}else if(this._activeBuffer.x=l-1,2===n)continue}if(r&&this._activeBuffer.x){let e=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-e,s,n);for(let e=n-_;--e>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,n-_,this._activeBuffer.getNullCell(d)),2===u.getWidth(l-1)&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,s,n,d),n>0)for(;--n;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&r-i>0&&0===u.getWidth(this._activeBuffer.x)&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,i){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,i):this._parser.registerCsiHandler(e,e=>!ls(e.params[0],this._optionsService.rawOptions.windowOptions)||i(e))}registerDcsHandler(e,i){return this._parser.registerDcsHandler(e,new a4(i))}registerEscHandler(e,i){return this._parser.registerEscHandler(e,i)}registerOscHandler(e,i){return this._parser.registerOscHandler(e,new a1(i))}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 e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,i){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+i):(this._activeBuffer.x=e,this._activeBuffer.y=i),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,i){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+i)}cursorUp(e){let i=this._activeBuffer.y-this._activeBuffer.scrollTop;return i>=0?this._moveCursor(0,-Math.min(i,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let i=this._activeBuffer.scrollBottom-this._activeBuffer.y;return i>=0?this._moveCursor(0,Math.min(i,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let i=e.params[0];return 0===i?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===i&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let i=e.params[0];return 1===i&&(this._curAttrData.bg|=0x20000000),(2===i||0===i)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,i,r,s=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(i,r,this._activeBuffer.getNullCell(this._eraseAttrData()),n),s&&(o.isWrapped=!1)}_resetBufferLine(e,i=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),i),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,i=!1){let r;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);r<this._bufferService.rows;r++)this._resetBufferLine(r,i);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,i),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,i);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,i);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0))}return!0}eraseInLine(e,i=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,i);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,i)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;i--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;i--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let i=e.params[0]||1;for(;i--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let i=e.params[0]||1;for(;i--;)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(av));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.deleteCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.insertCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.insertCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.deleteCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let i=this._parser.precedingJoinState;if(!i)return!0;let r=e.params[0]||1,s=aG.extractWidth(i),n=this._activeBuffer.x-s,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*r),l=0;for(let e=0;e<o.length;){let i=o.codePointAt(e)||0;a[l++]=i,e+=i>65535?2:1}let h=l;for(let e=1;e<r;++e)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(n5.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(n5.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(n5.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(n5.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(n5.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,aC),this._charsetService.setgCharset(1,aC),this._charsetService.setgCharset(2,aC),this._charsetService.setgCharset(3,aC);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(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){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===e.params[i]&&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(e,i){let r,s,n,o;(s=r||={})[s.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",s[s.SET=1]="SET",s[s.RESET=2]="RESET",s[s.PERMANENTLY_SET=3]="PERMANENTLY_SET",s[s.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let a=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:h}=this._coreMouseService,c=this._coreService,{buffers:d,cols:u}=this._bufferService,{active:f,alt:p}=d,_=this._optionsService.rawOptions,m=e=>e?1:2,g=e.params[0];return n=g,o=i?2===g?4:4===g?m(c.modes.insertMode):12===g?3:20===g?m(_.convertEol):0:1===g?m(a.applicationCursorKeys):3===g?_.windowOptions.setWinLines?80===u?2:+(132===u):0:6===g?m(a.origin):7===g?m(a.wraparound):8===g?3:9===g?m("X10"===l):12===g?m(_.cursorBlink):25===g?m(!c.isCursorHidden):45===g?m(a.reverseWraparound):66===g?m(a.applicationKeypad):67===g?4:1e3===g?m("VT200"===l):1002===g?m("DRAG"===l):1003===g?m("ANY"===l):1004===g?m(a.sendFocus):1005===g?4:1006===g?m("SGR"===h):1015===g?4:1016===g?m("SGR_PIXELS"===h):1048===g?1:47===g||1047===g||1049===g?m(f===p):2004===g?m(a.bracketedPasteMode):2026===g?m(a.synchronizedOutput):0,c.triggerDataEvent(`${n5.ESC}[${i?"":"?"}${n};${o}$y`),!0}_updateAttrColor(e,i,r,s,n){return 2===i?(e|=0x3000000,e&=-0x1000000,e|=rv.fromColorRGB([r,s,n])):5===i&&(e&=-0x3000100,e|=0x2000000|255&r),e}_extractColor(e,i,r){let s=[0,0,-1,0,0,0],n=0,o=0;do{if(s[o+n]=e.params[i+o],e.hasSubParams(i+o)){let r=e.getSubParams(i+o),a=0;do 5===s[1]&&(n=1),s[o+a+1+n]=r[a];while(++a<r.length&&a+o+1+n<s.length)break}if(5===s[1]&&o+n>=2||2===s[1]&&o+n>=5)break;s[1]&&(n=1)}while(++o+i<e.length&&o+n<s.length)for(let e=2;e<s.length;++e)-1===s[e]&&(s[e]=0);switch(s[0]){case 38:r.fg=this._updateAttrColor(r.fg,s[1],s[3],s[4],s[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,s[1],s[3],s[4],s[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,s[1],s[3],s[4],s[5])}return o}_processUnderline(e,i){i.extended=i.extended.clone(),(!~e||e>5)&&(e=1),i.extended.underlineStyle=e,i.fg|=0x10000000,0===e&&(i.fg&=-0x10000001),i.updateExtended()}_processSGR0(e){e.fg=av.fg,e.bg=av.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let i=e.length,r,s=this._curAttrData;for(let n=0;n<i;n++)(r=e.params[n])>=30&&r<=37?(s.fg&=-0x3000100,s.fg|=0x1000000|r-30):r>=40&&r<=47?(s.bg&=-0x3000100,s.bg|=0x1000000|r-40):r>=90&&r<=97?(s.fg&=-0x3000100,s.fg|=0x1000000|r-90|8):r>=100&&r<=107?(s.bg&=-0x3000100,s.bg|=0x1000000|r-100|8):0===r?this._processSGR0(s):1===r?s.fg|=0x8000000:3===r?s.bg|=0x4000000:4===r?(s.fg|=0x10000000,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,s)):5===r?s.fg|=0x20000000:7===r?s.fg|=0x4000000:8===r?s.fg|=0x40000000:9===r?s.fg|=0x80000000:2===r?s.bg|=0x8000000:21===r?this._processUnderline(2,s):22===r?(s.fg&=-0x8000001,s.bg&=-0x8000001):23===r?s.bg&=-0x4000001:24===r?(s.fg&=-0x10000001,this._processUnderline(0,s)):25===r?s.fg&=-0x20000001:27===r?s.fg&=-0x4000001:28===r?s.fg&=-0x40000001:29===r?s.fg&=0x7fffffff:39===r?(s.fg&=-0x4000000,s.fg|=0xffffff&av.fg):49===r?(s.bg&=-0x4000000,s.bg|=0xffffff&av.bg):38===r||48===r||58===r?n+=this._extractColor(e,n,s):53===r?s.bg|=0x40000000:55===r?s.bg&=-0x40000001:59===r?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):100===r?(s.fg&=-0x4000000,s.fg|=0xffffff&av.fg,s.bg&=-0x4000000,s.bg|=0xffffff&av.bg):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${n5.ESC}[0n`);break;case 6:let i=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n5.ESC}[${i};${r}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n5.ESC}[?${e};${i}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=av.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let i=0===e.length?1:e.params[0];if(0===i)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(i){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=i%2==1}return!0}setScrollRegion(e){let i=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||0===r)&&(r=this._bufferService.rows),r>i&&(this._activeBuffer.scrollTop=i-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ls(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let i=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==i&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${n5.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===i||2===i)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===i||1===i)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===i||2===i)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===i||1===i)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let i=[],r=e.split(";");for(;r.length>1;){let e=r.shift(),s=r.shift();if(/^\d+$/.exec(e)){let r=parseInt(e);if(ll(r))if("?"===s)i.push({type:0,index:r});else{let e=lt(s);e&&i.push({type:1,index:r,color:e})}}}return i.length&&this._onColor.fire(i),!0}setHyperlink(e){let i=e.indexOf(";");if(-1===i)return!0;let r=e.slice(0,i).trim(),s=e.slice(i+1);return s?this._createHyperlink(r,s):!r.trim()&&this._finishHyperlink()}_createHyperlink(e,i){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),s,n=r.findIndex(e=>e.startsWith("id="));return -1!==n&&(s=r[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:i}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,i){let r=e.split(";");for(let e=0;e<r.length&&!(i>=this._specialColors.length);++e,++i)if("?"===r[e])this._onColor.fire([{type:0,index:this._specialColors[i]}]);else{let s=lt(r[e]);s&&this._onColor.fire([{type:1,index:this._specialColors[i],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let i=[],r=e.split(";");for(let e=0;e<r.length;++e)if(/^\d+$/.exec(r[e])){let s=parseInt(r[e]);ll(s)&&i.push({type:2,index:s})}return i.length&&this._onColor.fire(i),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,aC),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(lr[e[0]],aw[e[1]]||aC),!0}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=av.clone(),this._eraseAttrDataInternal=av.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new rb;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let i=0;i<this._bufferService.rows;++i){let r=this._activeBuffer.ybase+this._activeBuffer.y+i,s=this._activeBuffer.lines.get(r);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,i){let r=e=>(this._coreService.triggerDataEvent(`${n5.ESC}${e}${n5.ESC}\\`),!0),s=this._bufferService.buffer,n=this._optionsService.rawOptions;return r('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[n.cursorStyle]-!!n.cursorBlink} q`:"P0$r")}markRangeDirty(e,i){this._dirtyRowTracker.markRangeDirty(e,i)}},la=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,i){e>i&&(ln=e,e=i,i=ln),e<this.start&&(this.start=e),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function ll(e){return 0<=e&&e<256}la=ra([rl(0,rk)],la);var lh=class extends r3{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new sf),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,i){let r;if(void 0!==i&&this._syncCalls>i){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;r=this._writeBuffer.shift();){this._action(r);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,i){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+=e.length,this._writeBuffer.push(e),this._callbacks.push(i),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i)}_innerWrite(e=0,i=!0){let r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],s=this._action(e,i);if(s){let e=e=>performance.now()-r>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(r,e);s.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-r>=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()}},lc=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let i=this._bufferService.buffer;if(void 0===e.id){let r=i.addMarker(i.ybase+i.y),s={data:e,id:this._nextId++,lines:[r]};return r.onDispose(()=>this._removeMarkerFromLink(s,r)),this._dataByLinkId.set(s.id,s),s.id}let r=this._getEntryIdKey(e),s=this._entriesWithId.get(r);if(s)return this.addLineToLink(s.id,i.ybase+i.y),s.id;let n=i.addMarker(i.ybase+i.y),o={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,i){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(e=>e.line!==i)){let e=this._bufferService.buffer.addMarker(i);r.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(r,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,i){let r=e.lines.indexOf(i);-1!==r&&(e.lines.splice(r,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};lc=ra([rl(0,rk)],lc);var ld=!1,lu=class extends r3{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new r4),this._onBinary=this._register(new sf),this.onBinary=this._onBinary.event,this._onData=this._register(new sf),this.onData=this._onData.event,this._onLineFeed=this._register(new sf),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new sf),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new sf),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new sf),this._instantiationService=new ap,this.optionsService=this._register(new aT(e)),this._instantiationService.setService(rD,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(aN)),this._instantiationService.setService(rk,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(am)),this._instantiationService.setService(rT,this._logService),this.coreService=this._register(this._instantiationService.createInstance(aP)),this._instantiationService.setService(rN,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(aF)),this._instantiationService.setService(rE,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(aG)),this._instantiationService.setService(rL,this.unicodeService),this._charsetService=this._instantiationService.createInstance(aX),this._instantiationService.setService(rR,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(lc),this._instantiationService.setService(rM,this._oscLinkService),this._inputHandler=this._register(new lo(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(so.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(so.forward(this._bufferService.onResize,this._onResize)),this._register(so.forward(this.coreService.onData,this._onData)),this._register(so.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 lh((e,i)=>this._inputHandler.parse(e,i))),this._register(so.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new sf),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let i in e)this.optionsService.options[i]=e[i]}write(e,i){this._writeBuffer.write(e,i)}writeSync(e,i){this._logService.logLevel<=3&&!ld&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ld=!0),this._writeBuffer.writeSync(e,i)}input(e,i=!0){this.coreService.triggerDataEvent(e,i)}resize(e,i){isNaN(e)||isNaN(i)||(e=Math.max(e,2),i=Math.max(i,1),this._bufferService.resize(e,i))}scroll(e,i=!1){this._bufferService.scroll(e,i)}scrollLines(e,i){this._bufferService.scrollLines(e,i)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}registerEscHandler(e,i){return this._inputHandler.registerEscHandler(e,i)}registerDcsHandler(e,i){return this._inputHandler.registerDcsHandler(e,i)}registerCsiHandler(e,i){return this._inputHandler.registerCsiHandler(e,i)}registerOscHandler(e,i){return this._inputHandler.registerOscHandler(e,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,i=this.optionsService.rawOptions.windowsPty;i&&void 0!==i.buildNumber&&void 0!==i.buildNumber?e="conpty"===i.backend&&i.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(aJ.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(aJ(this._bufferService),!1))),this._windowsWrappingHeuristics.value=r1(()=>{for(let i of e)i.dispose()})}}},lf={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:["'",'"']},lp=0,l_=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new o1,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new o1,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,i)=>this._getKey(e)-this._getKey(i)),i=0,r=0,s=Array(this._array.length+this._insertedValues.length);for(let n=0;n<s.length;n++)r>=this._array.length||this._getKey(e[i])<=this._getKey(this._array[r])?(s[n]=e[i],i++):s[n]=this._array[r++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let i=this._getKey(e);if(void 0===i||-1===(lp=this._search(i))||this._getKey(this._array[lp])!==i)return!1;do if(this._array[lp]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(lp),!0;while(++lp<this._array.length&&this._getKey(this._array[lp])===i)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,i)=>e-i),i=0,r=Array(this._array.length-e.length),s=0;for(let n=0;n<this._array.length;n++)e[i]===n?i++:r[s++]=this._array[n];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((lp=this._search(e))<0||lp>=this._array.length)&&this._getKey(this._array[lp])===e)do yield this._array[lp];while(++lp<this._array.length&&this._getKey(this._array[lp])===e)}forEachByKey(e,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((lp=this._search(e))<0||lp>=this._array.length)&&this._getKey(this._array[lp])===e)do i(this._array[lp]);while(++lp<this._array.length&&this._getKey(this._array[lp])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let i=0,r=this._array.length-1;for(;r>=i;){let s=i+r>>1,n=this._getKey(this._array[s]);if(n>e)r=s-1;else if(n<e)i=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return i}},lm=0,lg=0,lv=class extends r3{constructor(){super(),this._decorations=new l_(e=>e?.marker.line),this._onDecorationRegistered=this._register(new sf),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new sf),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(r1(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let i=new lx(e);if(i){let e=i.marker.onDispose(()=>i.dispose()),r=i.onDispose(()=>{r.dispose(),i&&(this._decorations.delete(i)&&this._onDecorationRemoved.fire(i),e.dispose())});this._decorations.insert(i),this._onDecorationRegistered.fire(i)}return i}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,i,r){let s=0,n=0;for(let o of this._decorations.getKeyIterator(i))n=(s=o.options.x??0)+(o.options.width??1),e>=s&&e<n&&(!r||(o.options.layer??"bottom")===r)&&(yield o)}forEachDecorationAtCell(e,i,r,s){this._decorations.forEachByKey(i,i=>{lg=(lm=i.options.x??0)+(i.options.width??1),e>=lm&&e<lg&&(!r||(i.options.layer??"bottom")===r)&&s(i)})}},lx=class extends r5{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new sf),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new sf),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=a$.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=a$.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},lb=class{constructor(e,i=1e3){this._renderCallback=e,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,i,r){this._rowCount=r,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=s-this._lastRefreshMs,i=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},i)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i)}},ly=class extends r3{constructor(e,i,r,s){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new lb(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(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
16
- `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ng(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(r1(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let i=0;i<e;i++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
17
- `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=rc)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,i){this._liveRegionDebouncer.refresh(e,i,this._terminal.rows)}_renderRows(e,i){let r=this._terminal.buffer,s=r.lines.length.toString();for(let n=e;n<=i;n++){let e=r.lines.get(r.ydisp+n),i=[],o=e?.translateToString(!0,void 0,void 0,i)||"",a=(r.ydisp+n+1).toString(),l=this._rowElements[n];l&&(0===o.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=o,this._rowColumns.set(l,i)),l.setAttribute("aria-posinset",a),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,i){let r,s,n=e.target,o=this._rowElements[0===i?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===i?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===i?(r=n,s=this._rowElements.pop(),this._rowContainer.removeChild(s)):(r=this._rowElements.shift(),s=n,this._rowContainer.removeChild(r)),r.removeEventListener("focus",this._topBoundaryFocusListener),s.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((i.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===r.node&&i.offset>r.offset)&&([i,r]=[r,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let s=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let n=({node:e,offset:i})=>{let r=e instanceof Text?e.parentNode:e,s=parseInt(r?.getAttribute("aria-posinset"),10)-1;if(isNaN(s))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(r);if(!n)return console.warn("columns is null. Race condition?"),null;let o=i<n.length?n[i]:n.slice(-1)[0]+1;return o>=this._terminal.cols&&(++s,o=0),{row:s,column:o}},o=n(i),a=n(r);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let i=e.getBoundingClientRect().width,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let s=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/i})`}};ly=ra([rl(1,rj),rl(2,rI),rl(3,rF)],ly);var lS=class extends r3{constructor(e,i,r,s,n){super(),this._element=e,this._mouseService=i,this._renderService=r,this._bufferService=s,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new sf),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new sf),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(r1(()=>{r0(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(ng(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ng(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ng(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ng(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let r=e.composedPath();for(let e=0;e<r.length;e++){let i=r[e];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}this._lastBufferCell&&i.x===this._lastBufferCell.x&&i.y===this._lastBufferCell.y||(this._handleHover(i),this._lastBufferCell=i)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,i){this._activeProviderReplies&&i||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,n]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):n.provideLinks(e.y,i=>{if(this._isMouseOut)return;let n=i?.map(e=>({link:e}));this._activeProviderReplies?.set(s,n),r=this._checkLinkProviderResult(s,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,i){let r=new Set;for(let s=0;s<i.size;s++){let n=i.get(s);if(n)for(let i=0;i<n.length;i++){let s=n[i],o=s.link.range.start.y<e?0:s.link.range.start.x,a=s.link.range.end.y>e?this._bufferService.cols:s.link.range.end.x;for(let e=o;e<=a;e++){if(r.has(e)){n.splice(i--,1);break}r.add(e)}}}}_checkLinkProviderResult(e,i,r){if(!this._activeProviderReplies)return r;let s=this._activeProviderReplies.get(e),n=!1;for(let i=0;i<e;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(n=!0);if(!n&&s){let e=s.find(e=>this._linkAtPosition(e.link,i));e&&(r=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let e=0;e<this._activeProviderReplies.size;e++){let s=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,i));if(s){r=!0,this._handleNewLink(s);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var i,r;if(!this._currentLink)return;let s=this._positionFromMouseEvent(e,this._element,this._mouseService);s&&this._mouseDownLink&&(i=this._mouseDownLink.link,r=this._currentLink.link,i.text===r.text&&i.range.start.x===r.range.start.x&&i.range.start.y===r.range.start.y&&i.range.end.x===r.range.end.x&&i.range.end.y===r.range.end.y)&&this._linkAtPosition(this._currentLink.link,s)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,i){this._currentLink&&this._lastMouseEvent&&(!e||!i||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,r0(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(e.link,i)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let i=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,i,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(r,i.text)}_fireUnderlineEvent(e,i){let r=e.range,s=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-s-1,r.end.x,r.end.y-s-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,i,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(r,i.text)}_linkAtPosition(e,i){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,n=i.y*this._bufferService.cols+i.x;return r<=n&&n<=s}_positionFromMouseEvent(e,i,r){let s=r.getCoords(e,i,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,i,r,s,n){return{x1:e,y1:i,x2:r,y2:s,cols:this._bufferService.cols,fg:n}}};lS=ra([rl(1,rO),rl(2,rF),rl(3,rk),rl(4,rW)],lS);var lw=class extends lu{constructor(e={}){super(e),this._linkifier=this._register(new r4),this.browser=oB,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new r4),this._onCursorMove=this._register(new sf),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new sf),this.onKey=this._onKey.event,this._onRender=this._register(new sf),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new sf),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new sf),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new sf),this.onBell=this._onBell.event,this._onFocus=this._register(new sf),this._onBlur=this._register(new sf),this._onA11yCharEmitter=this._register(new sf),this._onA11yTabEmitter=this._register(new sf),this._onWillOpen=this._register(new sf),this._setup(),this._decorationService=this._instantiationService.createInstance(lv),this._instantiationService.setService(rP,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(oM),this._instantiationService.setService(rW,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(rA)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(so.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(so.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(so.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(so.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(r1(()=>{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(e){if(this._themeService)for(let i of e){let e,r="";switch(i.index){case 256:e="foreground",r="10";break;case 257:e="background",r="11";break;case 258:e="cursor",r="12";break;default:e="ansi",r="4;"+i.index}switch(i.type){case 0:let s=az.toColorRGB("ansi"===e?this._themeService.colors.ansi[i.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${n5.ESC}]${r};${function(e,i=16){let[r,s,n]=e;return`rgb:${li(r,i)}/${li(s,i)}/${li(n,i)}`}(s)}${n4.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[i.index]=n6.toColor(...i.color));else{let r=e;this._themeService.modifyColors(e=>e[r]=n6.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ly,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(n5.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(n5.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,i=this.buffer.lines.get(e);if(!i)return;let r=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,n=i.getWidth(r),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ng(this.element,"copy",e=>{var i;this.hasSelection()&&(i=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault())}));let e=e=>{var i,r,s;return i=this.textarea,r=this.coreService,s=this.optionsService,void(e.stopPropagation(),e.clipboardData&&rd(e.clipboardData.getData("text/plain"),i,r,s))};this._register(ng(this.textarea,"paste",e)),this._register(ng(this.element,"paste",e)),o$?this._register(ng(this.element,"mousedown",e=>{2===e.button&&rf(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ng(this.element,"contextmenu",e=>{rf(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),oX&&this._register(ng(this.element,"auxclick",e=>{1===e.button&&ru(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ng(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ng(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ng(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ng(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ng(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ng(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ng(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ng(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",rh),oJ||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(oT,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(rI,this._coreBrowserService),this._register(ng(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(ng(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(oE,this._document,this._helperContainer),this._instantiationService.setService(rB,this._charSizeService),this._themeService=this._instantiationService.createInstance(ad),this._instantiationService.setService(r$,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ou),this._instantiationService.setService(rz,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(o5,this.rows,this.screenElement)),this._instantiationService.setService(rF,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(nJ,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(oP),this._instantiationService.setService(rO,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(lS,this.screenElement));this.element.appendChild(i);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(nU,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ar,this.element,this.screenElement,s)),this._instantiationService.setService(rH,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(so.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(nK,this.screenElement)),this._register(ng(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),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(ly,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nX,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nX,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ok,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function r(i){let r,s,n=e._mouseService.getMouseReportCoords(i,e.screenElement);if(!n)return!1;switch(i.overrideType||i.type){case"mousemove":s=32,void 0===i.buttons?(r=3,void 0!==i.button&&(r=i.button<3?i.button:3)):r=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":s=0,r=i.button<3?i.button:3;break;case"mousedown":s=1,r=i.button<3?i.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(i))return!1;let o=i.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;s=o<0?0:1,r=4;break;default:return!1}return void 0!==s&&void 0!==r&&!(r>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:s,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(r(e),e.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(e)),o=e=>(r(e),this.cancel(e,!0)),a=e=>{e.buttons&&r(e)},l=e=>{e.buttons||r(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),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&e?s.mousemove||(i.addEventListener("mousemove",l),s.mousemove=l):(i.removeEventListener("mousemove",s.mousemove),s.mousemove=null),16&e?s.wheel||(i.addEventListener("wheel",o,{passive:!1}),s.wheel=o):(i.removeEventListener("wheel",s.wheel),s.wheel=null),2&e?s.mouseup||(s.mouseup=n):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),4&e?s.mousedrag||(s.mousedrag=a):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ng(i,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return r(e),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(e)})),this._register(ng(i,"wheel",i=>{if(!s.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback){if(0===i.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(i,!0);let r=n5.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(r,!0),this.cancel(i,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(e){rd(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,i,r){this._selectionService.setSelection(e,i,r)}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(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;i||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let r=function(e,i,r,s){let n={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?i?n.key=n5.ESC+"OA":n.key=n5.ESC+"[A":"UIKeyInputLeftArrow"===e.key?i?n.key=n5.ESC+"OD":n.key=n5.ESC+"[D":"UIKeyInputRightArrow"===e.key?i?n.key=n5.ESC+"OC":n.key=n5.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(i?n.key=n5.ESC+"OB":n.key=n5.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":n5.DEL,e.altKey&&(n.key=n5.ESC+n.key);break;case 9:if(e.shiftKey){n.key=n5.ESC+"[Z";break}n.key=n5.HT,n.cancel=!0;break;case 13:n.key=e.altKey?n5.ESC+n5.CR:n5.CR,n.cancel=!0;break;case 27:n.key=n5.ESC,e.altKey&&(n.key=n5.ESC+n5.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=n5.ESC+"[1;"+(o+1)+"D":i?n.key=n5.ESC+"OD":n.key=n5.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=n5.ESC+"[1;"+(o+1)+"C":i?n.key=n5.ESC+"OC":n.key=n5.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=n5.ESC+"[1;"+(o+1)+"A":i?n.key=n5.ESC+"OA":n.key=n5.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=n5.ESC+"[1;"+(o+1)+"B":i?n.key=n5.ESC+"OB":n.key=n5.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=n5.ESC+"[2~");break;case 46:o?n.key=n5.ESC+"[3;"+(o+1)+"~":n.key=n5.ESC+"[3~";break;case 36:o?n.key=n5.ESC+"[1;"+(o+1)+"H":i?n.key=n5.ESC+"OH":n.key=n5.ESC+"[H";break;case 35:o?n.key=n5.ESC+"[1;"+(o+1)+"F":i?n.key=n5.ESC+"OF":n.key=n5.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=n5.ESC+"[5;"+(o+1)+"~":n.key=n5.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=n5.ESC+"[6;"+(o+1)+"~":n.key=n5.ESC+"[6~";break;case 112:o?n.key=n5.ESC+"[1;"+(o+1)+"P":n.key=n5.ESC+"OP";break;case 113:o?n.key=n5.ESC+"[1;"+(o+1)+"Q":n.key=n5.ESC+"OQ";break;case 114:o?n.key=n5.ESC+"[1;"+(o+1)+"R":n.key=n5.ESC+"OR";break;case 115:o?n.key=n5.ESC+"[1;"+(o+1)+"S":n.key=n5.ESC+"OS";break;case 116:o?n.key=n5.ESC+"[15;"+(o+1)+"~":n.key=n5.ESC+"[15~";break;case 117:o?n.key=n5.ESC+"[17;"+(o+1)+"~":n.key=n5.ESC+"[17~";break;case 118:o?n.key=n5.ESC+"[18;"+(o+1)+"~":n.key=n5.ESC+"[18~";break;case 119:o?n.key=n5.ESC+"[19;"+(o+1)+"~":n.key=n5.ESC+"[19~";break;case 120:o?n.key=n5.ESC+"[20;"+(o+1)+"~":n.key=n5.ESC+"[20~";break;case 121:o?n.key=n5.ESC+"[21;"+(o+1)+"~":n.key=n5.ESC+"[21~";break;case 122:o?n.key=n5.ESC+"[23;"+(o+1)+"~":n.key=n5.ESC+"[23~";break;case 123:o?n.key=n5.ESC+"[24;"+(o+1)+"~":n.key=n5.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!r||s)&&e.altKey&&!e.metaKey){let i=lf[e.keyCode]?.[+!!e.shiftKey];if(i)n.key=n5.ESC+i;else if(e.keyCode>=65&&e.keyCode<=90){let i=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(i=i.toUpperCase()),n.key=n5.ESC+i}else if(32===e.keyCode)n.key=n5.ESC+(e.ctrlKey?n5.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let i=e.code.slice(3,4);e.shiftKey||(i=i.toLowerCase()),n.key=n5.ESC+i,n.cancel=!0}}else!r||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=n5.US),"@"===e.key&&(n.key=n5.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=n5.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=n5.DEL:219===e.keyCode?n.key=n5.ESC:220===e.keyCode?n.key=n5.FS:221===e.keyCode&&(n.key=n5.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===r.type||2===r.type){let i=this.rows-1;return this.scrollLines(2===r.type?-i:i),this.cancel(e,!0)}return 1===r.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((r.key===n5.ETX||r.key===n5.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,i){let r=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?r:r&&(!i.keyCode||i.keyCode>47)}_keyUp(e){var i;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(i=e).keyCode||17===i.keyCode||18===i.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(null===e.which||void 0===e.which)i=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;i=e.which}return!!i&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(av));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 e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(n5.ESC+"[I"):this.coreService.triggerDataEvent(n5.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${n5.ESC}[4;${r};${i}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${n5.ESC}[6;${n};${s}t`)}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}},lC=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let r={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(r),i.dispose=()=>this._wrappedAddonDispose(r),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){i=r;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},lk=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new rb)}translateToString(e,i,r){return this._line.translateToString(e,i,r)}},lE=class{constructor(e,i){this._buffer=e,this.type=i}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let i=this._buffer.lines.get(e);if(i)return new lk(i)}getNullCell(){return new rb}},lN=class extends r3{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new sf),this.onBufferChange=this._onBufferChange.event,this._normal=new lE(this._core.buffers.normal,"normal"),this._alternate=new lE(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)}},lR=class{constructor(e){this._core=e}registerCsiHandler(e,i){return this._core.registerCsiHandler(e,e=>i(e.toArray()))}addCsiHandler(e,i){return this.registerCsiHandler(e,i)}registerDcsHandler(e,i){return this._core.registerDcsHandler(e,(e,r)=>i(e,r.toArray()))}addDcsHandler(e,i){return this.registerDcsHandler(e,i)}registerEscHandler(e,i){return this._core.registerEscHandler(e,i)}addEscHandler(e,i){return this.registerEscHandler(e,i)}registerOscHandler(e,i){return this._core.registerOscHandler(e,i)}addOscHandler(e,i){return this.registerOscHandler(e,i)}},lj=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},lT=["cols","rows"],lD=0,lM=class extends r3{constructor(e){super(),this._core=this._register(new lw(e)),this._addonManager=this._register(new lC),this._publicOptions={...this._core.options};let i=e=>this._core.options[e],r=(e,i)=>{this._checkReadonlyOptions(e),this._core.options[e]=i};for(let e in this._core.options){let s={get:i.bind(this,e),set:r.bind(this,e)};Object.defineProperty(this._publicOptions,e,s)}}_checkReadonlyOptions(e){if(lT.includes(e))throw Error(`Option "${e}" 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 lR(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new lj(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 lN(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let i in e)this._publicOptions[i]=e[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,i=!0){this._core.input(e,i)}resize(e,i){this._verifyIntegers(e,i),this._core.resize(e,i)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,i,r){this._verifyIntegers(e,i,r),this._core.select(e,i,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,i){this._verifyIntegers(e,i),this._core.selectLines(e,i)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,i){this._core.write(e,i)}writeln(e,i){this._core.write(e),this._core.write(`\r
18
- `,i)}paste(e){this._core.paste(e)}refresh(e,i){this._verifyIntegers(e,i),this._core.refresh(e,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return rh},set promptLabel(t){rh=t},get tooMuchOutput(){return rc},set tooMuchOutput(t){rc=t}}}_verifyIntegers(...e){for(lD of e)if(lD===1/0||isNaN(lD)||lD%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(lD of e)if(lD&&(lD===1/0||isNaN(lD)||lD%1!=0||lD<0))throw Error("This API only accepts positive integers")}},lL=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(r.getPropertyValue("height")),n=Math.max(0,parseInt(r.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom;return{cols:Math.max(2,Math.floor((n-(a.right+a.left)-i)/e.css.cell.width)),rows:Math.max(1,Math.floor((s-l)/e.css.cell.height))}}};function lP({projectId:e,agentId:i,wsUrl:r,onActivity:s}){let n=(0,_.useRef)(null),o=(0,_.useRef)(null),a=(0,_.useRef)(null),l=(0,_.useRef)(null),h=(0,_.useRef)(s);(0,_.useEffect)(()=>{h.current=s},[s]);let c=(0,_.useCallback)(()=>{if(a.current&&o.current&&n.current)try{a.current.fit();let e=l.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:"resize",cols:o.current.cols,rows:o.current.rows}))}catch{}},[]);return(0,_.useEffect)(()=>{if(!n.current)return;let s=new lM({scrollback:1e3,fontSize:11,fontFamily:'"Geist Mono", "JetBrains Mono", "Fira Code", "Cascadia Code", monospace',lineHeight:1.2,letterSpacing:.5,cursorBlink:!1,cursorStyle:"block",theme:{background:"#0a0a0a",foreground:"#e0e0e0",cursor:"#00ff88",cursorAccent:"#0a0a0a",selectionBackground:"#00ff8844",black:"#0a0a0a",red:"#ff4444",green:"#00ff88",yellow:"#ffcc00",blue:"#4488ff",magenta:"#cc44ff",cyan:"#44ccff",white:"#e0e0e0",brightBlack:"#737373",brightRed:"#ff6666",brightGreen:"#00ff88",brightYellow:"#ffdd44",brightBlue:"#66aaff",brightMagenta:"#dd66ff",brightCyan:"#66ddff",brightWhite:"#ffffff"},allowTransparency:!1,drawBoldTextInBrightColors:!0}),d=new lL;s.loadAddon(d),s.open(n.current),o.current=s,a.current=d,requestAnimationFrame(()=>c());let u=new ResizeObserver(()=>c());u.observe(n.current),s.onData(e=>{let i=l.current;i&&i.readyState===WebSocket.OPEN&&i.send(e)});let f=!1,p=null,_=async()=>{if(p)return p;if(r)return p=r;let e="https:"===window.location.protocol?"wss:":"ws:";try{let i=await fetch("/api/config");if(i.ok){let r=(await i.json()).port||8400,s=parseInt(window.location.port,10);p=s&&s!==r?`${e}//${window.location.hostname}:${r}`:`${e}//${window.location.host}`}else p=`${e}//${window.location.host}`}catch{p=`${e}//${window.location.host}`}return p},m=async()=>{try{let r=await fetch("/api/sessions");if(!r.ok)return!1;let s=await r.json();return Array.isArray(s)&&s.some(r=>r&&r.projectId===e&&r.agentId===i)}catch{return!1}},g=0,v=null,x=async()=>{let r=await _();if(f)return;let n=new WebSocket(`${r}/ws/terminal?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i)}`);l.current=n,n.onopen=()=>{g=0,v&&clearInterval(v);let e=0;v=setInterval(()=>{c(),++e>=4&&(clearInterval(v),v=null)},500),n.send(JSON.stringify({type:"resize",cols:s.cols,rows:s.rows})),n.send(JSON.stringify({type:"replay"}))},n.onmessage=e=>{s.write(e.data);let i=h.current;i&&i()},n.onclose=async e=>{if(v&&(clearInterval(v),v=null),!f){if(g<5){let e=Date.now(),i=!1;for(;Date.now()-e<2e3;){if(await new Promise(e=>setTimeout(e,200)),f)return;if(await m()){i=!0;break}}if(f)return;if(i){g+=1,s.reset(),s.write(`\x1b[38;2;115;115;115m[reattached to new session]\x1b[0m\r
19
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),oZ&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(e){let i=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!!r&&!!s&&!!i&&this._areCoordsInSelection(i,r,s)}isCellInSelection(e,i){let r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!!r&&!!s&&this._areCoordsInSelection([e,i],r,s)}_areCoordsInSelection(e,i,r){return e[1]>i[1]&&e[1]<r[1]||i[1]===r[1]&&e[1]===i[1]&&e[0]>=i[0]&&e[0]<r[0]||i[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||i[1]<r[1]&&e[1]===i[1]&&e[0]>=i[0]}_selectWordAtCursor(e,i){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=as(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return!!s&&(this._selectWordAt(s,i),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,i){this._model.clearSelection(),e=Math.max(e,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let i=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(e){let i=oB(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return i>=0&&i<=r?0:(i>r&&(i-=r),(i=Math.min(Math.max(i,-50),50)/50)/Math.abs(i)+Math.round(14*i))}shouldForceSelection(e){return oG?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&0===i.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let i=this._getMouseBufferCoords(e);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(e){return e.altKey&&!(oG&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let i=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!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(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let e=r.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}i&&i[0]===this._model.selectionEnd[0]&&i[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let i=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&void 0!==i[0]&&void 0!==i[1]){let e=function(e,i,r,s){var n,o,a,l,h,c,d,u,f,p,m,_,g,v,x,b;let y,S=r.buffer.x,w=r.buffer.y;if(!r.buffer.hasScrollback){let b,y,C;return n=S,(0===o8(o=w,i,a=r,l=s).length?"":ai(ae(n,o,n,o-o7(o,a),!1,a).length,at("D",l)))+o8(w,i,r,s)+(h=S,c=w,d=e,b=o8(c,u=i,f=r,p=s).length>0?u-o7(u,f):c,C=(m=h,_=c,y=o8(g=d,v=u,x=f,p).length>0?v-o7(v,x):_,m<g&&y<=v||m>=g&&y<v?"C":"D"),ai(ae(h,b,d,u,"C"===C,f).length,at(C,p)))}if(w===i)return y=S>e?"D":"C",ai(Math.abs(S-e),at(y,s));y=w>i?"D":"C";let C=Math.abs(w-i);return ai((b=w>i?e:S,r.cols-b+(C-1)*r.cols+1+((w>i?S:e)-1)),at(y,s))}(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,r=!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,i,r);return}!e||!i||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&i[0]===this._oldSelectionEnd[0]&&i[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,i,r)}_fireOnSelectionChange(e,i,r){this._oldSelectionStart=e,this._oldSelectionEnd=i,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,i){let r=i;for(let s=0;i>=s;s++){let n=e.loadCell(s,this._workCell).getChars().length;0===this._workCell.getWidth()?r--:n>1&&i!==s&&(r+=n-1)}return r}setSelection(e,i,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,i],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,i,r=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,d=0,u=0,f=0,p=0;if(" "===a.charAt(l)){for(;l>0&&" "===a.charAt(l-1);)l--;for(;h<a.length&&" "===a.charAt(h+1);)h++}else{let i=e[0],r=e[0];0===o.getWidth(i)&&(d++,i--),2===o.getWidth(r)&&(u++,r++);let s=o.getString(r).length;for(s>1&&(p+=s-1,h+=s-1);i>0&&l>0&&!this._isCharWordSeparator(o.loadCell(i-1,this._workCell));){o.loadCell(i-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(d++,i--):e>1&&(f+=e-1,l-=e-1),l--,i--}for(;r<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(r+1,this._workCell));){o.loadCell(r+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,r++):e>1&&(p+=e-1,h+=e-1),h++,r++}}h++;let m=l+c-d+f,_=Math.min(this._bufferService.cols,h-l+d+u-f-p);if(!(!i&&""===a.slice(l,h).trim())){if(r&&0===m&&32!==o.getCodePoint(0)){let i=n.lines.get(e[1]-1);if(i&&o.isWrapped&&32!==i.getCodePoint(this._bufferService.cols-1)){let i=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(i){let e=this._bufferService.cols-i.start;m-=e,_+=e}}}if(s&&m+_===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){let i=n.lines.get(e[1]+1);if(i?.isWrapped&&32!==i.getCodePoint(0)){let i=this._getWordAt([0,e[1]+1],!1,!1,!0);i&&(_+=i.length)}}return{start:m,length:_}}}_selectWordAt(e,i){let r=this._getWordAt(e,i);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let i=this._getWordAt(e,!0);if(i){let r=e[1];for(;i.start<0;)i.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;i.start+i.length>this._bufferService.cols;)i.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?i.start:i.start+i.length,r]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let i=this._bufferService.buffer.getWrappedRangeForLine(e),r={start:{x:0,y:i.first},end:{x:this._bufferService.cols-1,y:i.last}};this._model.selectionStart=[0,i.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=as(r,this._bufferService.cols)}};ao=rc([rd(3,rR),rd(4,rT),rd(5,rH),rd(6,rL),rd(7,r$),rd(8,rz)],ao);var aa=class{constructor(){this._data={}}set(e,i,r){this._data[e]||(this._data[e]={}),this._data[e][i]=r}get(e,i){return this._data[e]?this._data[e][i]:void 0}clear(){this._data={}}},al=class{constructor(){this._color=new aa,this._css=new aa}setCss(e,i,r){this._css.set(e,i,r)}getCss(e,i){return this._css.get(e,i)}setColor(e,i,r){this._color.set(e,i,r)}getColor(e,i){return this._color.get(e,i)}clear(){this._color.clear(),this._css.clear()}},ah=Object.freeze((()=>{let e=[aK.toColor("#2e3436"),aK.toColor("#cc0000"),aK.toColor("#4e9a06"),aK.toColor("#c4a000"),aK.toColor("#3465a4"),aK.toColor("#75507b"),aK.toColor("#06989a"),aK.toColor("#d3d7cf"),aK.toColor("#555753"),aK.toColor("#ef2929"),aK.toColor("#8ae234"),aK.toColor("#fce94f"),aK.toColor("#729fcf"),aK.toColor("#ad7fa8"),aK.toColor("#34e2e2"),aK.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let r=0;r<216;r++){let s=i[r/36%6|0],n=i[r/6%6|0],o=i[r%6];e.push({css:n7.toCss(s,n,o),rgba:n7.toRgba(s,n,o)})}for(let i=0;i<24;i++){let r=8+10*i;e.push({css:n7.toCss(r,r,r),rgba:n7.toRgba(r,r,r)})}return e})()),ac=aK.toColor("#ffffff"),ad=aK.toColor("#000000"),au=aK.toColor("#ffffff"),af={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},ap=class extends r9{constructor(e){super(),this._optionsService=e,this._contrastCache=new al,this._halfContrastCache=new al,this._onChangeColors=this._register(new s_),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ac,background:ad,cursor:au,cursorAccent:ad,selectionForeground:void 0,selectionBackgroundTransparent:af,selectionBackgroundOpaque:aU.blend(ad,af),selectionInactiveBackgroundTransparent:af,selectionInactiveBackgroundOpaque:aU.blend(ad,af),scrollbarSliderBackground:aU.opacity(ac,.2),scrollbarSliderHoverBackground:aU.opacity(ac,.4),scrollbarSliderActiveBackground:aU.opacity(ac,.5),overviewRulerBorder:ac,ansi:ah.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let i=this._colors;if(i.foreground=am(e.foreground,ac),i.background=am(e.background,ad),i.cursor=aU.blend(i.background,am(e.cursor,au)),i.cursorAccent=aU.blend(i.background,am(e.cursorAccent,ad)),i.selectionBackgroundTransparent=am(e.selectionBackground,af),i.selectionBackgroundOpaque=aU.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=am(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=aU.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?am(e.selectionForeground,os):void 0,i.selectionForeground===os&&(i.selectionForeground=void 0),aU.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=aU.opacity(i.selectionBackgroundTransparent,.3)),aU.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=aU.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=am(e.scrollbarSliderBackground,aU.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=am(e.scrollbarSliderHoverBackground,aU.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=am(e.scrollbarSliderActiveBackground,aU.opacity(i.foreground,.5)),i.overviewRulerBorder=am(e.overviewRulerBorder,ac),i.ansi=ah.slice(),i.ansi[0]=am(e.black,ah[0]),i.ansi[1]=am(e.red,ah[1]),i.ansi[2]=am(e.green,ah[2]),i.ansi[3]=am(e.yellow,ah[3]),i.ansi[4]=am(e.blue,ah[4]),i.ansi[5]=am(e.magenta,ah[5]),i.ansi[6]=am(e.cyan,ah[6]),i.ansi[7]=am(e.white,ah[7]),i.ansi[8]=am(e.brightBlack,ah[8]),i.ansi[9]=am(e.brightRed,ah[9]),i.ansi[10]=am(e.brightGreen,ah[10]),i.ansi[11]=am(e.brightYellow,ah[11]),i.ansi[12]=am(e.brightBlue,ah[12]),i.ansi[13]=am(e.brightMagenta,ah[13]),i.ansi[14]=am(e.brightCyan,ah[14]),i.ansi[15]=am(e.brightWhite,ah[15]),e.extendedAnsi){let r=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<r;s++)i.ansi[s+16]=am(e.extendedAnsi[s],ah[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0===e){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function am(e,i){if(void 0!==e)try{return aK.toColor(e)}catch{}return i}ap=rc([rd(0,rL)],ap);var a_=class{constructor(...e){for(let[i,r]of(this._entries=new Map,e))this.set(i,r)}set(e,i){let r=this._entries.get(e);return this._entries.set(e,i),r}forEach(e){for(let[i,r]of this._entries.entries())e(i,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ag=class{constructor(){this._services=new a_,this._services.set(rM,this)}setService(e,i){this._services.set(e,i)}getService(e){return this._services.get(e)}createInstance(e,...i){let r=(e[rk]||[]).sort((e,i)=>e.index-i.index),s=[];for(let i of r){let r=this._services.get(i.id);if(!r)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${i.id._id}.`);s.push(r)}let n=r.length>0?r[0].index:i.length;if(i.length!==n)throw Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${i.length} static arguments`);return new e(...i,...s)}},av={trace:0,debug:1,info:2,warn:3,error:4,off:5},ax=class extends r9{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=av[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let i=0;i<e.length;i++)"function"==typeof e[i]&&(e[i]=e[i]())}_log(e,i,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...r)}trace(e,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,i)}debug(e,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,i)}info(e,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,i)}warn(e,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,i)}error(e,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,i)}};ax=rc([rd(0,rL)],ax);var ab=class extends r9{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new s_),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new s_),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new s_),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let i=Array(e);for(let r=0;r<Math.min(e,this.length);r++)i[r]=this._array[this._getCyclicIndex(r)];this._array=i,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let i=this._length;i<e;i++)this._array[i]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,i){this._array[this._getCyclicIndex(e)]=i}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,i,...r){if(i){for(let r=e;r<this._length-i;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+i)];this._length-=i,this.onDeleteEmitter.fire({index:e,amount:i})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+r.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<r.length;i++)this._array[this._getCyclicIndex(e+i)]=r[i];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let e=this._length+r.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,i,r){if(!(i<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+r<0)throw Error("Cannot shift elements in list beyond index 0");if(r>0){for(let s=i-1;s>=0;s--)this.set(e+s+r,this.get(e+s));let s=e+i+r-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<i;s++)this.set(e+s+r,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ay=Object.freeze(new ry),aS=0,aw=class e{constructor(e,i,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let s=i||rw.fromCharData([0,"",1,0]);for(let i=0;i<e;++i)this.setCell(i,s);this.length=e}get(e){let i=this._data[3*e+0],r=2097151&i;return[this._data[3*e+1],2097152&i?this._combined[e]:r?rg(r):"",i>>22,2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):r]}set(e,i){this._data[3*e+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[3*e+0]=2097152|e|i[2]<<22):this._data[3*e+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&i}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e]:2097151&i?rg(2097151&i):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,i){return aS=3*e,i.content=this._data[aS+0],i.fg=this._data[aS+1],i.bg=this._data[aS+2],2097152&i.content&&(i.combinedData=this._combined[e]),0x10000000&i.bg&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){2097152&i.content&&(this._combined[e]=i.combinedData),0x10000000&i.bg&&(this._extendedAttrs[e]=i.extended),this._data[3*e+0]=i.content,this._data[3*e+1]=i.fg,this._data[3*e+2]=i.bg}setCellFromCodepoint(e,i,r,s){0x10000000&s.bg&&(this._extendedAttrs[e]=s.extended),this._data[3*e+0]=i|r<<22,this._data[3*e+1]=s.fg,this._data[3*e+2]=s.bg}addCodepointToCell(e,i,r){let s=this._data[3*e+0];2097152&s?this._combined[e]+=rg(i):2097151&s?(this._combined[e]=rg(2097151&s)+rg(i),s&=-2097152,s|=2097152):s=4194304|i,r&&(s&=-0xc00001,s|=r<<22),this._data[3*e+0]=s}insertCells(e,i,r){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),i<this.length-e){let s=new rw;for(let r=this.length-e-i-1;r>=0;--r)this.setCell(e+i+r,this.loadCell(e+r,s));for(let s=0;s<i;++s)this.setCell(e+s,r)}else for(let i=e;i<this.length;++i)this.setCell(i,r);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(e,i,r){if(e%=this.length,i<this.length-e){let s=new rw;for(let r=0;r<this.length-e-i;++r)this.setCell(e+r,this.loadCell(e+i+r,s));for(let e=this.length-i;e<this.length;++e)this.setCell(e,r)}else for(let i=e;i<this.length;++i)this.setCell(i,r);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,r)}replaceCells(e,i,r,s=!1){if(s){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),i<this.length&&2===this.getWidth(i-1)&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,r);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,r),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,r),i<this.length&&2===this.getWidth(i-1)&&this.setCellFromCodepoint(i,0,1,r);e<i&&e<this.length;)this.setCell(e++,r)}resize(e,i){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let r=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*r)this._data=new Uint32Array(this._data.buffer,0,r);else{let e=new Uint32Array(r);e.set(this._data),this._data=e}for(let r=this.length;r<e;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,r);let i=Object.keys(this._combined);for(let r=0;r<i.length;r++){let s=parseInt(i[r],10);s>=e&&delete this._combined[s]}let s=Object.keys(this._extendedAttrs);for(let i=0;i<s.length;i++){let r=parseInt(s[i],10);r>=e&&delete this._extendedAttrs[r]}}return this.length=e,4*r*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){for(let i in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[i]=e._combined[i];for(let i in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let i=new e(0);for(let e in i._data=new Uint32Array(this._data),i.length=this.length,this._combined)i._combined[e]=this._combined[e];for(let e in this._extendedAttrs)i._extendedAttrs[e]=this._extendedAttrs[e];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,i,r,s,n){let o=e._data;if(n)for(let n=s-1;n>=0;n--){for(let e=0;e<3;e++)this._data[(r+n)*3+e]=o[(i+n)*3+e];0x10000000&o[(i+n)*3+2]&&(this._extendedAttrs[r+n]=e._extendedAttrs[i+n])}else for(let n=0;n<s;n++){for(let e=0;e<3;e++)this._data[(r+n)*3+e]=o[(i+n)*3+e];0x10000000&o[(i+n)*3+2]&&(this._extendedAttrs[r+n]=e._extendedAttrs[i+n])}let a=Object.keys(e._combined);for(let s=0;s<a.length;s++){let n=parseInt(a[s],10);n>=i&&(this._combined[n-i+r]=e._combined[n])}}translateToString(e,i,r,s){i=i??0,r=r??this.length,e&&(r=Math.min(r,this.getTrimmedLength())),s&&(s.length=0);let n="";for(;i<r;){let e=this._data[3*i+0],r=2097151&e,o=2097152&e?this._combined[i]:r?rg(r):" ";if(n+=o,s)for(let e=0;e<o.length;++e)s.push(i);i+=e>>22||1}return s&&s.push(i),n}};function aC(e,i,r){if(i===e.length-1)return e[i].getTrimmedLength();let s=!e[i].hasContent(r-1)&&1===e[i].getWidth(r-1),n=2===e[i+1].getWidth(0);return s&&n?r-1:r}var ak=class e{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new s_),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),r5(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};ak._nextId=1;var aE={},aN=aE.B;aE[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:"≥","{":"π","|":"≠","}":"£","~":"·"},aE.A={"#":"£"},aE.B=void 0,aE[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},aE.C=aE[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},aE.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},aE.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},aE.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},aE.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},aE.E=aE[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},aE.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},aE.H=aE[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},aE["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var aR=class{constructor(e,i,r){this._hasScrollback=e,this._optionsService=i,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ay.clone(),this.savedCharset=aN,this.markers=[],this._nullCell=rw.fromCharData([0,"",1,0]),this._whitespaceCell=rw.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new o3,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ab(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rS),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rS),this._whitespaceCell}getBlankLine(e,i){return new aw(this._bufferService.cols,this.getNullCell(e),i)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let i=e+this._optionsService.rawOptions.scrollback;return i>0xffffffff?0xffffffff:i}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=ay);let i=this._rows;for(;i--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ab(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,i){let r=this.getNullCell(ay),s=0,n=this._getCorrectBufferLength(i);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let i=0;i<this.lines.length;i++)s+=+this.lines.get(i).resize(e,r);let o=0;if(this._rows<i)for(let s=this._rows;s<i;s++)this.lines.length<i+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new aw(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new aw(e,r)));else for(let e=this._rows;e>i;e--)this.lines.length>i+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let e=this.lines.length-n;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,i-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=i-1,this._isReflowEnabled&&(this._reflow(e,i),this._cols>e))for(let i=0;i<this.lines.length;i++)s+=+this.lines.get(i).resize(e,r);this._cols=e,this._rows=i,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let i=0;for(;this._memoryCleanupPosition<this.lines.length;)if((i+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,i){this._cols!==e&&(e>this._cols?this._reflowLarger(e,i):this._reflowSmaller(e,i))}_reflowLarger(e,i){let r=this._optionsService.rawOptions.reflowCursorLine,s=function(e,i,r,s,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let d=[e.get(l)];for(;h<e.length&&c.isWrapped;)d.push(c),c=e.get(++h);if(!o&&s>=l&&s<h){l+=d.length-1;continue}let u=0,f=aC(d,0,i),p=1,m=0;for(;p<d.length;){let e=aC(d,p,i),s=Math.min(e-m,r-f);d[u].copyCellsFrom(d[p],m,f,s,!1),(f+=s)===r&&(u++,f=0),(m+=s)===e&&(p++,m=0),0===f&&0!==u&&2===d[u-1].getWidth(r-1)&&(d[u].copyCellsFrom(d[u-1],r-1,f++,1,!1),d[u-1].setCell(r-1,n))}d[u].replaceCells(f,r,n);let _=0;for(let e=d.length-1;e>0&&(e>u||0===d[e].getTrimmedLength());e--)_++;_>0&&(a.push(l+d.length-_),a.push(_)),l+=d.length-1}return a}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ay),r);if(s.length>0){let r=function(e,i){let r=[],s=0,n=i[0],o=0;for(let a=0;a<e.length;a++)if(n===a){let r=i[++s];e.onDeleteEmitter.fire({index:a-o,amount:r}),a+=r-1,o+=r,n=i[++s]}else r.push(a);return{layout:r,countRemoved:o}}(this.lines,s);(function(e,i){let r=[];for(let s=0;s<i.length;s++)r.push(e.get(i[s]));for(let i=0;i<r.length;i++)e.set(i,r[i]);e.length=i.length})(this.lines,r.layout),this._reflowLargerAdjustViewport(e,i,r.countRemoved)}}_reflowLargerAdjustViewport(e,i,r){let s=this.getNullCell(ay),n=r;for(;n-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new aw(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,i){let r=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(ay),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!r){let e=this.ybase+this.y;if(e>=a&&e<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=function(e,i,r){let s=[],n=e.map((r,s)=>aC(e,s,i)).reduce((e,i)=>e+i),o=0,a=0,l=0;for(;l<n;){if(n-l<r){s.push(n-l);break}o+=r;let h=aC(e,a,i);o>h&&(o-=h,a++);let c=2===e[a].getWidth(o-1);c&&o--;let d=c?r-1:r;s.push(d),l+=d}return s}(h,this._cols,e),u=d.length-h.length,f;f=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let p=[];for(let e=0;e<u;e++){let e=this.getBlankLine(ay,!0);p.push(e)}p.length>0&&(n.push({start:a+h.length+o,newLines:p}),o+=p.length),h.push(...p);let m=d.length-1,_=d[m];0===_&&(_=d[--m]);let g=h.length-u-1,v=c;for(;g>=0;){let e=Math.min(v,_);if(void 0===h[m])break;h[m].copyCellsFrom(h[g],v-e,_-e,e,!0),0==(_-=e)&&(_=d[--m]),0==(v-=e)&&(v=aC(h,Math.max(--g,0),this._cols))}for(let i=0;i<h.length;i++)d[i]<e&&h[i].setCell(d[i],s);let x=u-f;for(;x-- >0;)0===this.ybase?this.y<i-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-i&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+i-1)}if(n.length>0){let e=[],i=[];for(let e=0;e<this.lines.length;e++)i.push(this.lines.get(e));let r=this.lines.length,s=r-1,a=0,l=n[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let h=0;for(let c=Math.min(this.lines.maxLength-1,r+o-1);c>=0;c--)if(l&&l.start>s+h){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(c--,l.newLines[e]);c++,e.push({index:s+1,amount:l.newLines.length}),h+=l.newLines.length,l=n[++a]}else this.lines.set(c,i[s--]);let c=0;for(let i=e.length-1;i>=0;i--)e[i].index+=c,this.lines.onInsertEmitter.fire(e[i]),c+=e[i].amount;let d=Math.max(0,r+o-this.lines.maxLength);d>0&&this.lines.onTrimEmitter.fire(d)}}translateBufferLineToString(e,i,r=0,s){let n=this.lines.get(e);return n?n.translateToString(i,r,s):""}getWrappedRangeForLine(e){let i=e,r=e;for(;i>0&&this.lines.get(i).isWrapped;)i--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:i,last:r}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let i=0;i<this.markers.length;i++)this.markers[i].line===e&&(this.markers[i].dispose(),this.markers.splice(i--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let i=new ak(e);return this.markers.push(i),i.register(this.lines.onTrim(e=>{i.line-=e,i.line<0&&i.dispose()})),i.register(this.lines.onInsert(e=>{i.line>=e.index&&(i.line+=e.amount)})),i.register(this.lines.onDelete(e=>{i.line>=e.index&&i.line<e.index+e.amount&&i.dispose(),i.line>e.index&&(i.line-=e.amount)})),i.register(i.onDispose(()=>this._removeMarker(i))),i}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},aj=class extends r9{constructor(e,i){super(),this._optionsService=e,this._bufferService=i,this._onBufferActivate=this._register(new s_),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 aR(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new aR(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,i){this._normal.resize(e,i),this._alt.resize(e,i),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},aT=class extends r9{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new s_),this.onResize=this._onResize.event,this._onScroll=this._register(new s_),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new aj(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,i){let r=this.cols!==e,s=this.rows!==i;this.cols=e,this.rows=i,this.buffers.resize(e,i),this._onResize.fire({cols:e,rows:i,colsChanged:r,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,i=!1){let r=this.buffer,s;(s=this._cachedBlankLine)&&s.length===this.cols&&s.getFg(0)===e.fg&&s.getBg(0)===e.bg||(s=r.getBlankLine(e,i),this._cachedBlankLine=s),s.isWrapped=i;let n=r.ybase+r.scrollTop,o=r.ybase+r.scrollBottom;if(0===r.scrollTop){let e=r.lines.isFull;o===r.lines.length-1?e?r.lines.recycle().copyFrom(s):r.lines.push(s.clone()):r.lines.splice(o+1,0,s.clone()),e?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let e=o-n+1;r.lines.shiftElements(n+1,e-1,-1),r.lines.set(o,s.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,i){let r=this.buffer;if(e<0){if(0===r.ydisp)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let s=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),s!==r.ydisp&&(i||this._onScroll.fire(r.ydisp))}};aT=rc([rd(0,rL)],aT);var aD={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:oG,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},aM=["normal","bold","100","200","300","400","500","600","700","800","900"],aP=class extends r9{constructor(e){super(),this._onOptionChange=this._register(new s_),this.onOptionChange=this._onOptionChange.event;let i={...aD};for(let r in e)if(r in i)try{let s=e[r];i[r]=this._sanitizeAndValidateOption(r,s)}catch(e){console.error(e)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(r3(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,i){return this.onOptionChange(r=>{r===e&&i(this.rawOptions[e])})}onMultipleOptionChange(e,i){return this.onOptionChange(r=>{-1!==e.indexOf(r)&&i()})}_setupOptions(){let e=e=>{if(!(e in aD))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},i=(e,i)=>{if(!(e in aD))throw Error(`No option with key "${e}"`);i=this._sanitizeAndValidateOption(e,i),this.rawOptions[e]!==i&&(this.rawOptions[e]=i,this._onOptionChange.fire(e))};for(let r in this.rawOptions){let s={get:e.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this.options,r,s)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":var r;if(i||(i=aD[e]),"block"!==(r=i)&&"underline"!==r&&"bar"!==r)throw Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=aD[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=aM.includes(i)?i:aD[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}};function aL(e,i=5){if("object"!=typeof e)return e;let r=Array.isArray(e)?[]:{};for(let s in e)r[s]=i<=1?e[s]:e[s]&&aL(e[s],i-1);return r}var aA=Object.freeze({insertMode:!1}),aB=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),aI=class extends r9{constructor(e,i,r){super(),this._bufferService=e,this._logService=i,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new s_),this.onData=this._onData.event,this._onUserInput=this._register(new s_),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new s_),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new s_),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=aL(aA),this.decPrivateModes=aL(aB)}reset(){this.modes=aL(aA),this.decPrivateModes=aL(aB)}triggerDataEvent(e,i=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;i&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),i&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};aI=rc([rd(0,rR),rd(1,rP),rd(2,rL)],aI);var aO={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function aF(e,i){let r=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(r|=64,r|=e.action):(r|=3&e.button,4&e.button&&(r|=64),8&e.button&&(r|=128),32===e.action?r|=32:0!==e.action||i||(r|=3)),r}var az=String.fromCharCode,aH={DEFAULT:e=>{let i=[aF(e,!1)+32,e.col+32,e.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`\x1b[M${az(i[0])}${az(i[1])}${az(i[2])}`},SGR:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${aF(e,!0)};${e.col};${e.row}${i}`},SGR_PIXELS:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${aF(e,!0)};${e.x};${e.y}${i}`}},a$=class extends r9{constructor(e,i,r){for(let s of(super(),this._bufferService=e,this._coreService=i,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new s_),this.onProtocolChange=this._onProtocolChange.event,Object.keys(aO)))this.addProtocol(s,aO[s]);for(let e of Object.keys(aH))this.addEncoding(e,aH[e]);this.reset()}addProtocol(e,i){this._protocols[e]=i}addEncoding(e,i){this._encodings[e]=i}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,i,r){if(0===e.deltaY||e.shiftKey||void 0===i||void 0===r)return 0;let s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=i/r+0,50>Math.abs(e.deltaY)&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,i){return i.altKey||i.ctrlKey||i.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let i=this._encodings[this._activeEncoding](e);return i&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(i):this._coreService.triggerDataEvent(i,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,i,r){if(r){if(e.x!==i.x||e.y!==i.y)return!1}else if(e.col!==i.col||e.row!==i.row)return!1;return e.button===i.button&&e.action===i.action&&e.ctrl===i.ctrl&&e.alt===i.alt&&e.shift===i.shift}};a$=rc([rd(0,rR),rd(1,rT),rd(2,rL)],a$);var aW,aU,aK,aq,aV,aY,aG=[[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]],aX=[[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]],aJ=class{constructor(){if(this.version="6",!aY){(aY=new Uint8Array(65536)).fill(1),aY[0]=0,aY.fill(0,1,32),aY.fill(0,127,160),aY.fill(2,4352,4448),aY[9001]=2,aY[9002]=2,aY.fill(2,11904,42192),aY[12351]=1,aY.fill(2,44032,55204),aY.fill(2,63744,64256),aY.fill(2,65040,65050),aY.fill(2,65072,65136),aY.fill(2,65280,65377),aY.fill(2,65504,65511);for(let e=0;e<aG.length;++e)aY.fill(0,aG[e][0],aG[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?aY[e]:!function(e,i){let r=0,s=i.length-1,n;if(e<i[0][0]||e>i[s][1])return!1;for(;s>=r;)if(e>i[n=r+s>>1][1])r=n+1;else{if(!(e<i[n][0]))return!0;s=n-1}return!1}(e,aX)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,i){let r=this.wcwidth(e),s=0===r&&0!==i;if(s){let e=aQ.extractWidth(i);0===e?s=!1:e>r&&(r=e)}return aQ.createPropertyValue(0,r,s)}},aQ=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new s_,this.onChange=this._onChange.event;let e=new aJ;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,r=!1){return(0xffffff&e)<<3|(3&i)<<1|!!r}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(i){let r=0,s=0,n=i.length;for(let o=0;o<n;++o){let a=i.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return r+this.wcwidth(a);let e=i.charCodeAt(o);56320<=e&&e<=57343?a=(a-55296)*1024+e-56320+65536:r+=this.wcwidth(e)}let l=this.charProperties(a,s),h=e.extractWidth(l);e.extractShouldJoin(l)&&(h-=e.extractWidth(s)),r+=h,s=l}return r}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},aZ=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,i){this._charsets[e]=i,this.glevel===e&&(this.charset=i)}};function a0(e){let i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&i&&(r.isWrapped=0!==i[3]&&32!==i[3])}var a1=class e{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(i){let r=new e;if(!i.length)return r;for(let e=+!!Array.isArray(i[0]);e<i.length;++e){let s=i[e];if(Array.isArray(s))for(let e=0;e<s.length;++e)r.addSubParam(s[e]);else r.addParam(s)}return r}clone(){let i=new e(this.maxLength,this.maxSubParamsLength);return i.params.set(this.params),i.length=this.length,i._subParams.set(this._subParams),i._subParamsLength=this._subParamsLength,i._subParamsIdx.set(this._subParamsIdx),i._rejectDigits=this._rejectDigits,i._rejectSubDigits=this._rejectSubDigits,i._digitIsSub=this._digitIsSub,i}toArray(){let e=[];for(let i=0;i<this.length;++i){e.push(this.params[i]);let r=this._subParamsIdx[i]>>8,s=255&this._subParamsIdx[i];s-r>0&&e.push(Array.prototype.slice.call(this._subParams,r,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>0x7fffffff?0x7fffffff:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,r=255&this._subParamsIdx[e];return r-i>0?this._subParams.subarray(i,r):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let r=this._subParamsIdx[i]>>8,s=255&this._subParamsIdx[i];s-r>0&&(e[i]=this._subParams.slice(r,s))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,s=r[i-1];r[i-1]=~s?Math.min(10*s+e,0x7fffffff):e}},a2=[],a5=class{constructor(){this._state=0,this._active=a2,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a2}reset(){if(2===this._state)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=a2,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a2,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,i,r){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,i,r);else this._handlerFb(this._id,"PUT",rv(e,i,r))}start(){this.reset(),this._state=1}put(e,i,r){if(3!==this._state){if(1===this._state)for(;i<r;){let r=e[i++];if(59===r){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+r-48}2===this._state&&r-i>0&&this._put(e,i,r)}}end(e,i=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let r=!1,s=this._active.length-1,n=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;s>=0&&!0!==(r=this._active[s].end(e));s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if((r=this._active[s].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}else this._handlerFb(this._id,"END",e);this._active=a2,this._id=-1,this._state=0}}},a3=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,i,r){this._hitLimit||(this._data+=rv(e,i,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data))instanceof Promise)return i.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,i}},a4=[],a6=class{constructor(){this._handlers=Object.create(null),this._active=a4,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a4}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=a4,this._ident=0}hook(e,i){if(this.reset(),this._ident=e,this._active=this._handlers[e]||a4,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(i);else this._handlerFb(this._ident,"HOOK",i)}put(e,i,r){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,i,r);else this._handlerFb(this._ident,"PUT",rv(e,i,r))}unhook(e,i=!0){if(this._active.length){let r=!1,s=this._active.length-1,n=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;s>=0&&!0!==(r=this._active[s].unhook(e));s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if((r=this._active[s].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}else this._handlerFb(this._ident,"UNHOOK",e);this._active=a4,this._ident=0}},a9=new a1;a9.addParam(0);var a8=class{constructor(e){this._handler=e,this._data="",this._params=a9,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():a9,this._data="",this._hitLimit=!1}put(e,i,r){this._hitLimit||(this._data+=rv(e,i,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data,this._params))instanceof Promise)return i.then(e=>(this._params=a9,this._data="",this._hitLimit=!1,e));return this._params=a9,this._data="",this._hitLimit=!1,i}},a7=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,i){this.table.fill(e<<4|i)}add(e,i,r,s){this.table[i<<8|e]=r<<4|s}addMany(e,i,r,s){for(let n=0;n<e.length;n++)this.table[i<<8|e[n]]=r<<4|s}},le=function(){let e=new a7(4095),i=Array.apply(null,Array(256)).map((e,i)=>i),r=(e,r)=>i.slice(e,r),s=r(32,127),n=r(0,24);n.push(25),n.push.apply(n,r(28,32));let o=r(0,14),a;for(a in e.setDefault(1,0),e.addMany(s,0,2,0),o)e.addMany([24,26,153,154],a,3,0),e.addMany(r(128,144),a,3,0),e.addMany(r(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),lt=class extends r9{constructor(e=le){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new a1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,i,r)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,i)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(r3(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new a5),this._dcsParser=this._register(new a6),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,i=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((r=e.prefix.charCodeAt(0))&&60>r||r>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let s=e.intermediates.charCodeAt(i);if(32>s||s>47)throw Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=s}}if(1!==e.final.length)throw Error("final must be a single byte");let s=e.final.charCodeAt(0);if(i[0]>s||s>i[1])throw Error(`final must be in range ${i[0]} .. ${i[1]}`);return r<<=8,r|=s}identToString(e){let i=[];for(;e;)i.push(String.fromCharCode(255&e)),e>>=8;return i.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,i){let r=this._identifier(e,[48,126]);void 0===this._escHandlers[r]&&(this._escHandlers[r]=[]);let s=this._escHandlers[r];return s.push(i),{dispose:()=>{let e=s.indexOf(i);-1!==e&&s.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,i){this._executeHandlers[e.charCodeAt(0)]=i}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,i){let r=this._identifier(e);void 0===this._csiHandlers[r]&&(this._csiHandlers[r]=[]);let s=this._csiHandlers[r];return s.push(i),{dispose:()=>{let e=s.indexOf(i);-1!==e&&s.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,i){return this._dcsParser.registerHandler(this._identifier(e),i)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,i){return this._oscParser.registerHandler(e,i)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,i,r,s,n){this._parseStack.state=e,this._parseStack.handlers=i,this._parseStack.handlerPos=r,this._parseStack.transition=s,this._parseStack.chunkPos=n}parse(e,i,r){let s=0,n=0,o=0,a;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===r||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let i=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===r&&n>-1){for(;n>=0&&!0!==(a=i[n](this._params));n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 4:if(!1===r&&n>-1){for(;n>=0&&!0!==(a=i[n]());n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(24!==s&&26!==s,r))return a;27===s&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],a=this._oscParser.end(24!==s&&26!==s,r))return a;27===s&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let r=o;r<i;++r){switch(s=e[r],(n=this._transitions.table[this.currentState<<8|(s<160?s:160)])>>4){case 2:for(let n=r+1;;++n)if(n>=i||(s=e[n])<32||s>126&&s<160||++n>=i||(s=e[n])<32||s>126&&s<160||++n>=i||(s=e[n])<32||s>126&&s<160||++n>=i||(s=e[n])<32||s>126&&s<160){this._printHandler(e,r,n),r=n-1;break}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:r,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|s],l=o?o.length-1:-1;for(;l>=0&&!0!==(a=o[l](this._params));l--)if(a instanceof Promise)return this._preserveStack(3,o,l,n,r),a;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++r<i&&(s=e[r])>47&&s<60)r--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let h=this._escHandlers[this._collect<<8|s],c=h?h.length-1:-1;for(;c>=0&&!0!==(a=h[c]());c--)if(a instanceof Promise)return this._preserveStack(4,h,c,n,r),a;c<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let n=r+1;;++n)if(n>=i||24===(s=e[n])||26===s||27===s||s>127&&s<160){this._dcsParser.put(e,r,n),r=n-1;break}break;case 14:if(a=this._dcsParser.unhook(24!==s&&26!==s))return this._preserveStack(6,[],0,n,r),a;27===s&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let n=r+1;;n++)if(n>=i||(s=e[n])<32||s>127&&s<160){this._oscParser.put(e,r,n),r=n-1;break}break;case 6:if(a=this._oscParser.end(24!==s&&26!==s))return this._preserveStack(5,[],0,n,r),a;27===s&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},li=/^([\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})$/,lr=/^[\da-f]+$/;function ls(e){if(!e)return;let i=e.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let e=li.exec(i);if(e){let i=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/i*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/i*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/i*255)]}}else if(0===i.indexOf("#")&&(i=i.slice(1),lr.exec(i)&&[3,6,9,12].includes(i.length))){let e=i.length/3,r=[0,0,0];for(let s=0;s<3;++s){let n=parseInt(i.slice(e*s,e*s+e),16);r[s]=1===e?n<<4:2===e?n:3===e?n>>4:n>>8}return r}}function ln(e,i){let r=e.toString(16),s=r.length<2?"0"+r:r;switch(i){case 4:return r[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}var lo={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function la(e,i){if(e>24)return i.setWinLines||!1;switch(e){case 1:return!!i.restoreWin;case 2:return!!i.minimizeWin;case 3:return!!i.setWinPosition;case 4:return!!i.setWinSizePixels;case 5:return!!i.raiseWin;case 6:return!!i.lowerWin;case 7:return!!i.refreshWin;case 8:return!!i.setWinSizeChars;case 9:return!!i.maximizeWin;case 10:return!!i.fullscreenWin;case 11:return!!i.getWinState;case 13:return!!i.getWinPosition;case 14:return!!i.getWinSizePixels;case 15:return!!i.getScreenSizePixels;case 16:return!!i.getCellSizePixels;case 18:return!!i.getWinSizeChars;case 19:return!!i.getScreenSizeChars;case 20:return!!i.getIconTitle;case 21:return!!i.getWinTitle;case 22:return!!i.pushTitle;case 23:return!!i.popTitle;case 24:return!!i.setWinLines}return!1}var ll=0,lh=class extends r9{constructor(e,i,r,s,n,o,a,l,h=new lt){for(let c in super(),this._bufferService=e,this._charsetService=i,this._coreService=r,this._logService=s,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rx,this._utf8Decoder=new rb,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ay.clone(),this._eraseAttrDataInternal=ay.clone(),this._onRequestBell=this._register(new s_),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new s_),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new s_),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new s_),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new s_),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new s_),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new s_),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new s_),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new s_),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new s_),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new s_),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new s_),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new s_),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 lc(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,i)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:i.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,i,r)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:i,data:r})}),this._parser.setDcsHandlerFallback((e,i,r)=>{"HOOK"===i&&(r=r.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:i,payload:r})}),this._parser.setPrintHandler((e,i,r)=>this.print(e,i,r)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(n6.BEL,()=>this.bell()),this._parser.setExecuteHandler(n6.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(n6.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(n6.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(n6.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(n6.BS,()=>this.backspace()),this._parser.setExecuteHandler(n6.HT,()=>this.tab()),this._parser.setExecuteHandler(n6.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(n6.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(n9.IND,()=>this.index()),this._parser.setExecuteHandler(n9.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(n9.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new a3(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new a3(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new a3(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new a3(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new a3(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new a3(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new a3(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new a3(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new a3(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new a3(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new a3(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new a3(e=>this.restoreCursorColor(e))),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()),aE)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new a8((e,i)=>this.requestStatusString(e,i)))}getAttrData(){return this._curAttrData}_preserveStack(e,i,r,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=i,this._parseStack.decodedLength=r,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,i){let r,s=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,i))return this._logSlowResolvingAsync(r),r;s=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(o=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),a||this._dirtyRowTracker.clearRange(),e.length>131072)for(let i=o;i<e.length;i+=131072){let o=i+131072<e.length?i+131072:e.length,a="string"==typeof e?this._stringDecoder.decode(e.substring(i,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(i,o),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,a))return this._preserveStack(s,n,a,i),this._logSlowResolvingAsync(r),r}else if(!a){let i="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,i))return this._preserveStack(s,n,i,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==s||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,i,r){let s,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-i>0&&2===u.getWidth(this._activeBuffer.x-1)&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let p=i;p<r;++p){if((s=e[p])<127&&o){let e=o[String.fromCharCode(s)];e&&(s=e.charCodeAt(0))}let i=this._unicodeService.charProperties(s,f);n=aQ.extractWidth(i);let r=aQ.extractShouldJoin(i),m=r?aQ.extractWidth(f):0;if(f=i,a&&this._onA11yChar.fire(rg(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-m>l){if(h){let e=u,i=this._activeBuffer.x-m;for(this._activeBuffer.x=m,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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&u instanceof aw&&u.copyCellsFrom(e,i,0,m,!1);i<l;)e.setCellFromCodepoint(i++,0,1,d)}else if(this._activeBuffer.x=l-1,2===n)continue}if(r&&this._activeBuffer.x){let e=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-e,s,n);for(let e=n-m;--e>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,n-m,this._activeBuffer.getNullCell(d)),2===u.getWidth(l-1)&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,s,n,d),n>0)for(;--n;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&r-i>0&&0===u.getWidth(this._activeBuffer.x)&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,i){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,i):this._parser.registerCsiHandler(e,e=>!la(e.params[0],this._optionsService.rawOptions.windowOptions)||i(e))}registerDcsHandler(e,i){return this._parser.registerDcsHandler(e,new a8(i))}registerEscHandler(e,i){return this._parser.registerEscHandler(e,i)}registerOscHandler(e,i){return this._parser.registerOscHandler(e,new a3(i))}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 e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,i){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+i):(this._activeBuffer.x=e,this._activeBuffer.y=i),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,i){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+i)}cursorUp(e){let i=this._activeBuffer.y-this._activeBuffer.scrollTop;return i>=0?this._moveCursor(0,-Math.min(i,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let i=this._activeBuffer.scrollBottom-this._activeBuffer.y;return i>=0?this._moveCursor(0,Math.min(i,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let i=e.params[0];return 0===i?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===i&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let i=e.params[0];return 1===i&&(this._curAttrData.bg|=0x20000000),(2===i||0===i)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,i,r,s=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(i,r,this._activeBuffer.getNullCell(this._eraseAttrData()),n),s&&(o.isWrapped=!1)}_resetBufferLine(e,i=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),i),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,i=!1){let r;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);r<this._bufferService.rows;r++)this._resetBufferLine(r,i);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,i),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,i);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,i);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0))}return!0}eraseInLine(e,i=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,i);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,i)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;i--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;i--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let i=e.params[0]||1;for(;i--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let i=e.params[0]||1;for(;i--;)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(ay));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.deleteCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.insertCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.insertCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.deleteCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let i=this._parser.precedingJoinState;if(!i)return!0;let r=e.params[0]||1,s=aQ.extractWidth(i),n=this._activeBuffer.x-s,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*r),l=0;for(let e=0;e<o.length;){let i=o.codePointAt(e)||0;a[l++]=i,e+=i>65535?2:1}let h=l;for(let e=1;e<r;++e)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(n6.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(n6.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(n6.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(n6.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(n6.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,aN),this._charsetService.setgCharset(1,aN),this._charsetService.setgCharset(2,aN),this._charsetService.setgCharset(3,aN);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(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){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===e.params[i]&&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(e,i){let r,s,n,o;(s=r||={})[s.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",s[s.SET=1]="SET",s[s.RESET=2]="RESET",s[s.PERMANENTLY_SET=3]="PERMANENTLY_SET",s[s.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let a=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:h}=this._coreMouseService,c=this._coreService,{buffers:d,cols:u}=this._bufferService,{active:f,alt:p}=d,m=this._optionsService.rawOptions,_=e=>e?1:2,g=e.params[0];return n=g,o=i?2===g?4:4===g?_(c.modes.insertMode):12===g?3:20===g?_(m.convertEol):0:1===g?_(a.applicationCursorKeys):3===g?m.windowOptions.setWinLines?80===u?2:+(132===u):0:6===g?_(a.origin):7===g?_(a.wraparound):8===g?3:9===g?_("X10"===l):12===g?_(m.cursorBlink):25===g?_(!c.isCursorHidden):45===g?_(a.reverseWraparound):66===g?_(a.applicationKeypad):67===g?4:1e3===g?_("VT200"===l):1002===g?_("DRAG"===l):1003===g?_("ANY"===l):1004===g?_(a.sendFocus):1005===g?4:1006===g?_("SGR"===h):1015===g?4:1016===g?_("SGR_PIXELS"===h):1048===g?1:47===g||1047===g||1049===g?_(f===p):2004===g?_(a.bracketedPasteMode):2026===g?_(a.synchronizedOutput):0,c.triggerDataEvent(`${n6.ESC}[${i?"":"?"}${n};${o}$y`),!0}_updateAttrColor(e,i,r,s,n){return 2===i?(e|=0x3000000,e&=-0x1000000,e|=ry.fromColorRGB([r,s,n])):5===i&&(e&=-0x3000100,e|=0x2000000|255&r),e}_extractColor(e,i,r){let s=[0,0,-1,0,0,0],n=0,o=0;do{if(s[o+n]=e.params[i+o],e.hasSubParams(i+o)){let r=e.getSubParams(i+o),a=0;do 5===s[1]&&(n=1),s[o+a+1+n]=r[a];while(++a<r.length&&a+o+1+n<s.length)break}if(5===s[1]&&o+n>=2||2===s[1]&&o+n>=5)break;s[1]&&(n=1)}while(++o+i<e.length&&o+n<s.length)for(let e=2;e<s.length;++e)-1===s[e]&&(s[e]=0);switch(s[0]){case 38:r.fg=this._updateAttrColor(r.fg,s[1],s[3],s[4],s[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,s[1],s[3],s[4],s[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,s[1],s[3],s[4],s[5])}return o}_processUnderline(e,i){i.extended=i.extended.clone(),(!~e||e>5)&&(e=1),i.extended.underlineStyle=e,i.fg|=0x10000000,0===e&&(i.fg&=-0x10000001),i.updateExtended()}_processSGR0(e){e.fg=ay.fg,e.bg=ay.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let i=e.length,r,s=this._curAttrData;for(let n=0;n<i;n++)(r=e.params[n])>=30&&r<=37?(s.fg&=-0x3000100,s.fg|=0x1000000|r-30):r>=40&&r<=47?(s.bg&=-0x3000100,s.bg|=0x1000000|r-40):r>=90&&r<=97?(s.fg&=-0x3000100,s.fg|=0x1000000|r-90|8):r>=100&&r<=107?(s.bg&=-0x3000100,s.bg|=0x1000000|r-100|8):0===r?this._processSGR0(s):1===r?s.fg|=0x8000000:3===r?s.bg|=0x4000000:4===r?(s.fg|=0x10000000,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,s)):5===r?s.fg|=0x20000000:7===r?s.fg|=0x4000000:8===r?s.fg|=0x40000000:9===r?s.fg|=0x80000000:2===r?s.bg|=0x8000000:21===r?this._processUnderline(2,s):22===r?(s.fg&=-0x8000001,s.bg&=-0x8000001):23===r?s.bg&=-0x4000001:24===r?(s.fg&=-0x10000001,this._processUnderline(0,s)):25===r?s.fg&=-0x20000001:27===r?s.fg&=-0x4000001:28===r?s.fg&=-0x40000001:29===r?s.fg&=0x7fffffff:39===r?(s.fg&=-0x4000000,s.fg|=0xffffff&ay.fg):49===r?(s.bg&=-0x4000000,s.bg|=0xffffff&ay.bg):38===r||48===r||58===r?n+=this._extractColor(e,n,s):53===r?s.bg|=0x40000000:55===r?s.bg&=-0x40000001:59===r?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):100===r?(s.fg&=-0x4000000,s.fg|=0xffffff&ay.fg,s.bg&=-0x4000000,s.bg|=0xffffff&ay.bg):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${n6.ESC}[0n`);break;case 6:let i=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n6.ESC}[${i};${r}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n6.ESC}[?${e};${i}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ay.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let i=0===e.length?1:e.params[0];if(0===i)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(i){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=i%2==1}return!0}setScrollRegion(e){let i=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||0===r)&&(r=this._bufferService.rows),r>i&&(this._activeBuffer.scrollTop=i-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!la(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let i=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==i&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${n6.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===i||2===i)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===i||1===i)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===i||2===i)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===i||1===i)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let i=[],r=e.split(";");for(;r.length>1;){let e=r.shift(),s=r.shift();if(/^\d+$/.exec(e)){let r=parseInt(e);if(ld(r))if("?"===s)i.push({type:0,index:r});else{let e=ls(s);e&&i.push({type:1,index:r,color:e})}}}return i.length&&this._onColor.fire(i),!0}setHyperlink(e){let i=e.indexOf(";");if(-1===i)return!0;let r=e.slice(0,i).trim(),s=e.slice(i+1);return s?this._createHyperlink(r,s):!r.trim()&&this._finishHyperlink()}_createHyperlink(e,i){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),s,n=r.findIndex(e=>e.startsWith("id="));return -1!==n&&(s=r[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:i}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,i){let r=e.split(";");for(let e=0;e<r.length&&!(i>=this._specialColors.length);++e,++i)if("?"===r[e])this._onColor.fire([{type:0,index:this._specialColors[i]}]);else{let s=ls(r[e]);s&&this._onColor.fire([{type:1,index:this._specialColors[i],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let i=[],r=e.split(";");for(let e=0;e<r.length;++e)if(/^\d+$/.exec(r[e])){let s=parseInt(r[e]);ld(s)&&i.push({type:2,index:s})}return i.length&&this._onColor.fire(i),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,aN),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(lo[e[0]],aE[e[1]]||aN),!0}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ay.clone(),this._eraseAttrDataInternal=ay.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new rw;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let i=0;i<this._bufferService.rows;++i){let r=this._activeBuffer.ybase+this._activeBuffer.y+i,s=this._activeBuffer.lines.get(r);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,i){let r=e=>(this._coreService.triggerDataEvent(`${n6.ESC}${e}${n6.ESC}\\`),!0),s=this._bufferService.buffer,n=this._optionsService.rawOptions;return r('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[n.cursorStyle]-!!n.cursorBlink} q`:"P0$r")}markRangeDirty(e,i){this._dirtyRowTracker.markRangeDirty(e,i)}},lc=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,i){e>i&&(ll=e,e=i,i=ll),e<this.start&&(this.start=e),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function ld(e){return 0<=e&&e<256}lc=rc([rd(0,rR)],lc);var lu=class extends r9{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new s_),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,i){let r;if(void 0!==i&&this._syncCalls>i){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;r=this._writeBuffer.shift();){this._action(r);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,i){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+=e.length,this._writeBuffer.push(e),this._callbacks.push(i),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i)}_innerWrite(e=0,i=!0){let r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],s=this._action(e,i);if(s){let e=e=>performance.now()-r>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(r,e);s.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-r>=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()}},lf=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let i=this._bufferService.buffer;if(void 0===e.id){let r=i.addMarker(i.ybase+i.y),s={data:e,id:this._nextId++,lines:[r]};return r.onDispose(()=>this._removeMarkerFromLink(s,r)),this._dataByLinkId.set(s.id,s),s.id}let r=this._getEntryIdKey(e),s=this._entriesWithId.get(r);if(s)return this.addLineToLink(s.id,i.ybase+i.y),s.id;let n=i.addMarker(i.ybase+i.y),o={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,i){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(e=>e.line!==i)){let e=this._bufferService.buffer.addMarker(i);r.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(r,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,i){let r=e.lines.indexOf(i);-1!==r&&(e.lines.splice(r,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};lf=rc([rd(0,rR)],lf);var lp=!1,lm=class extends r9{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new r8),this._onBinary=this._register(new s_),this.onBinary=this._onBinary.event,this._onData=this._register(new s_),this.onData=this._onData.event,this._onLineFeed=this._register(new s_),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new s_),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new s_),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new s_),this._instantiationService=new ag,this.optionsService=this._register(new aP(e)),this._instantiationService.setService(rL,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(aT)),this._instantiationService.setService(rR,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ax)),this._instantiationService.setService(rP,this._logService),this.coreService=this._register(this._instantiationService.createInstance(aI)),this._instantiationService.setService(rT,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(a$)),this._instantiationService.setService(rj,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(aQ)),this._instantiationService.setService(rB,this.unicodeService),this._charsetService=this._instantiationService.createInstance(aZ),this._instantiationService.setService(rD,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(lf),this._instantiationService.setService(rA,this._oscLinkService),this._inputHandler=this._register(new lh(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(sh.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(sh.forward(this._bufferService.onResize,this._onResize)),this._register(sh.forward(this.coreService.onData,this._onData)),this._register(sh.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 lu((e,i)=>this._inputHandler.parse(e,i))),this._register(sh.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new s_),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let i in e)this.optionsService.options[i]=e[i]}write(e,i){this._writeBuffer.write(e,i)}writeSync(e,i){this._logService.logLevel<=3&&!lp&&(this._logService.warn("writeSync is unreliable and will be removed soon."),lp=!0),this._writeBuffer.writeSync(e,i)}input(e,i=!0){this.coreService.triggerDataEvent(e,i)}resize(e,i){isNaN(e)||isNaN(i)||(e=Math.max(e,2),i=Math.max(i,1),this._bufferService.resize(e,i))}scroll(e,i=!1){this._bufferService.scroll(e,i)}scrollLines(e,i){this._bufferService.scrollLines(e,i)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}registerEscHandler(e,i){return this._inputHandler.registerEscHandler(e,i)}registerDcsHandler(e,i){return this._inputHandler.registerDcsHandler(e,i)}registerCsiHandler(e,i){return this._inputHandler.registerCsiHandler(e,i)}registerOscHandler(e,i){return this._inputHandler.registerOscHandler(e,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,i=this.optionsService.rawOptions.windowsPty;i&&void 0!==i.buildNumber&&void 0!==i.buildNumber?e="conpty"===i.backend&&i.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(a0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(a0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=r3(()=>{for(let i of e)i.dispose()})}}},l_={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:["'",'"']},lg=0,lv=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new o3,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new o3,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,i)=>this._getKey(e)-this._getKey(i)),i=0,r=0,s=Array(this._array.length+this._insertedValues.length);for(let n=0;n<s.length;n++)r>=this._array.length||this._getKey(e[i])<=this._getKey(this._array[r])?(s[n]=e[i],i++):s[n]=this._array[r++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let i=this._getKey(e);if(void 0===i||-1===(lg=this._search(i))||this._getKey(this._array[lg])!==i)return!1;do if(this._array[lg]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(lg),!0;while(++lg<this._array.length&&this._getKey(this._array[lg])===i)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,i)=>e-i),i=0,r=Array(this._array.length-e.length),s=0;for(let n=0;n<this._array.length;n++)e[i]===n?i++:r[s++]=this._array[n];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((lg=this._search(e))<0||lg>=this._array.length)&&this._getKey(this._array[lg])===e)do yield this._array[lg];while(++lg<this._array.length&&this._getKey(this._array[lg])===e)}forEachByKey(e,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((lg=this._search(e))<0||lg>=this._array.length)&&this._getKey(this._array[lg])===e)do i(this._array[lg]);while(++lg<this._array.length&&this._getKey(this._array[lg])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let i=0,r=this._array.length-1;for(;r>=i;){let s=i+r>>1,n=this._getKey(this._array[s]);if(n>e)r=s-1;else if(n<e)i=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return i}},lx=0,lb=0,ly=class extends r9{constructor(){super(),this._decorations=new lv(e=>e?.marker.line),this._onDecorationRegistered=this._register(new s_),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new s_),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(r3(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let i=new lS(e);if(i){let e=i.marker.onDispose(()=>i.dispose()),r=i.onDispose(()=>{r.dispose(),i&&(this._decorations.delete(i)&&this._onDecorationRemoved.fire(i),e.dispose())});this._decorations.insert(i),this._onDecorationRegistered.fire(i)}return i}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,i,r){let s=0,n=0;for(let o of this._decorations.getKeyIterator(i))n=(s=o.options.x??0)+(o.options.width??1),e>=s&&e<n&&(!r||(o.options.layer??"bottom")===r)&&(yield o)}forEachDecorationAtCell(e,i,r,s){this._decorations.forEachByKey(i,i=>{lb=(lx=i.options.x??0)+(i.options.width??1),e>=lx&&e<lb&&(!r||(i.options.layer??"bottom")===r)&&s(i)})}},lS=class extends r6{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new s_),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new s_),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=aK.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=aK.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},lw=class{constructor(e,i=1e3){this._renderCallback=e,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,i,r){this._rowCount=r,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=s-this._lastRefreshMs,i=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},i)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i)}},lC=class extends r9{constructor(e,i,r,s){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new lw(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(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
20
+ `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(nb(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(r3(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let i=0;i<e;i++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
21
+ `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=rf)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,i){this._liveRegionDebouncer.refresh(e,i,this._terminal.rows)}_renderRows(e,i){let r=this._terminal.buffer,s=r.lines.length.toString();for(let n=e;n<=i;n++){let e=r.lines.get(r.ydisp+n),i=[],o=e?.translateToString(!0,void 0,void 0,i)||"",a=(r.ydisp+n+1).toString(),l=this._rowElements[n];l&&(0===o.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=o,this._rowColumns.set(l,i)),l.setAttribute("aria-posinset",a),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,i){let r,s,n=e.target,o=this._rowElements[0===i?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===i?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===i?(r=n,s=this._rowElements.pop(),this._rowContainer.removeChild(s)):(r=this._rowElements.shift(),s=n,this._rowContainer.removeChild(r)),r.removeEventListener("focus",this._topBoundaryFocusListener),s.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((i.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===r.node&&i.offset>r.offset)&&([i,r]=[r,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let s=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let n=({node:e,offset:i})=>{let r=e instanceof Text?e.parentNode:e,s=parseInt(r?.getAttribute("aria-posinset"),10)-1;if(isNaN(s))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(r);if(!n)return console.warn("columns is null. Race condition?"),null;let o=i<n.length?n[i]:n.slice(-1)[0]+1;return o>=this._terminal.cols&&(++s,o=0),{row:s,column:o}},o=n(i),a=n(r);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let i=e.getBoundingClientRect().width,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let s=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/i})`}};lC=rc([rd(1,rM),rd(2,rz),rd(3,r$)],lC);var lk=class extends r9{constructor(e,i,r,s,n){super(),this._element=e,this._mouseService=i,this._renderService=r,this._bufferService=s,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new s_),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new s_),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(r3(()=>{r5(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(nb(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(nb(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(nb(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(nb(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let r=e.composedPath();for(let e=0;e<r.length;e++){let i=r[e];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}this._lastBufferCell&&i.x===this._lastBufferCell.x&&i.y===this._lastBufferCell.y||(this._handleHover(i),this._lastBufferCell=i)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,i){this._activeProviderReplies&&i||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,n]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):n.provideLinks(e.y,i=>{if(this._isMouseOut)return;let n=i?.map(e=>({link:e}));this._activeProviderReplies?.set(s,n),r=this._checkLinkProviderResult(s,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,i){let r=new Set;for(let s=0;s<i.size;s++){let n=i.get(s);if(n)for(let i=0;i<n.length;i++){let s=n[i],o=s.link.range.start.y<e?0:s.link.range.start.x,a=s.link.range.end.y>e?this._bufferService.cols:s.link.range.end.x;for(let e=o;e<=a;e++){if(r.has(e)){n.splice(i--,1);break}r.add(e)}}}}_checkLinkProviderResult(e,i,r){if(!this._activeProviderReplies)return r;let s=this._activeProviderReplies.get(e),n=!1;for(let i=0;i<e;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(n=!0);if(!n&&s){let e=s.find(e=>this._linkAtPosition(e.link,i));e&&(r=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let e=0;e<this._activeProviderReplies.size;e++){let s=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,i));if(s){r=!0,this._handleNewLink(s);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var i,r;if(!this._currentLink)return;let s=this._positionFromMouseEvent(e,this._element,this._mouseService);s&&this._mouseDownLink&&(i=this._mouseDownLink.link,r=this._currentLink.link,i.text===r.text&&i.range.start.x===r.range.start.x&&i.range.start.y===r.range.start.y&&i.range.end.x===r.range.end.x&&i.range.end.y===r.range.end.y)&&this._linkAtPosition(this._currentLink.link,s)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,i){this._currentLink&&this._lastMouseEvent&&(!e||!i||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,r5(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(e.link,i)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let i=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,i,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(r,i.text)}_fireUnderlineEvent(e,i){let r=e.range,s=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-s-1,r.end.x,r.end.y-s-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,i,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(r,i.text)}_linkAtPosition(e,i){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,n=i.y*this._bufferService.cols+i.x;return r<=n&&n<=s}_positionFromMouseEvent(e,i,r){let s=r.getCoords(e,i,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,i,r,s,n){return{x1:e,y1:i,x2:r,y2:s,cols:this._bufferService.cols,fg:n}}};lk=rc([rd(1,rH),rd(2,r$),rd(3,rR),rd(4,rq)],lk);var lE=class extends lm{constructor(e={}){super(e),this._linkifier=this._register(new r8),this.browser=oF,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new r8),this._onCursorMove=this._register(new s_),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new s_),this.onKey=this._onKey.event,this._onRender=this._register(new s_),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new s_),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new s_),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new s_),this.onBell=this._onBell.event,this._onFocus=this._register(new s_),this._onBlur=this._register(new s_),this._onA11yCharEmitter=this._register(new s_),this._onA11yTabEmitter=this._register(new s_),this._onWillOpen=this._register(new s_),this._setup(),this._decorationService=this._instantiationService.createInstance(ly),this._instantiationService.setService(rI,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(oA),this._instantiationService.setService(rq,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(rO)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(sh.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(sh.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(sh.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(sh.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(r3(()=>{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(e){if(this._themeService)for(let i of e){let e,r="";switch(i.index){case 256:e="foreground",r="10";break;case 257:e="background",r="11";break;case 258:e="cursor",r="12";break;default:e="ansi",r="4;"+i.index}switch(i.type){case 0:let s=aU.toColorRGB("ansi"===e?this._themeService.colors.ansi[i.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${n6.ESC}]${r};${function(e,i=16){let[r,s,n]=e;return`rgb:${ln(r,i)}/${ln(s,i)}/${ln(n,i)}`}(s)}${n8.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[i.index]=n7.toColor(...i.color));else{let r=e;this._themeService.modifyColors(e=>e[r]=n7.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(lC,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(n6.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(n6.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,i=this.buffer.lines.get(e);if(!i)return;let r=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,n=i.getWidth(r),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(nb(this.element,"copy",e=>{var i;this.hasSelection()&&(i=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault())}));let e=e=>{var i,r,s;return i=this.textarea,r=this.coreService,s=this.optionsService,void(e.stopPropagation(),e.clipboardData&&rp(e.clipboardData.getData("text/plain"),i,r,s))};this._register(nb(this.textarea,"paste",e)),this._register(nb(this.element,"paste",e)),oK?this._register(nb(this.element,"mousedown",e=>{2===e.button&&r_(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(nb(this.element,"contextmenu",e=>{r_(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),oZ&&this._register(nb(this.element,"auxclick",e=>{1===e.button&&rm(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(nb(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(nb(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(nb(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(nb(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(nb(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(nb(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(nb(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(nb(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ru),o0||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(oP,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(rz,this._coreBrowserService),this._register(nb(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(nb(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(oj,this._document,this._helperContainer),this._instantiationService.setService(rF,this._charSizeService),this._themeService=this._instantiationService.createInstance(ap),this._instantiationService.setService(rK,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(om),this._instantiationService.setService(rU,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(o6,this.rows,this.screenElement)),this._instantiationService.setService(r$,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(n0,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(oI),this._instantiationService.setService(rH,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(lk,this.screenElement));this.element.appendChild(i);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(nV,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ao,this.element,this.screenElement,s)),this._instantiationService.setService(rW,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(sh.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(nY,this.screenElement)),this._register(nb(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),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(lC,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nZ,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(nZ,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(oR,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function r(i){let r,s,n=e._mouseService.getMouseReportCoords(i,e.screenElement);if(!n)return!1;switch(i.overrideType||i.type){case"mousemove":s=32,void 0===i.buttons?(r=3,void 0!==i.button&&(r=i.button<3?i.button:3)):r=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":s=0,r=i.button<3?i.button:3;break;case"mousedown":s=1,r=i.button<3?i.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(i))return!1;let o=i.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;s=o<0?0:1,r=4;break;default:return!1}return void 0!==s&&void 0!==r&&!(r>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:s,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(r(e),e.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(e)),o=e=>(r(e),this.cancel(e,!0)),a=e=>{e.buttons&&r(e)},l=e=>{e.buttons||r(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),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&e?s.mousemove||(i.addEventListener("mousemove",l),s.mousemove=l):(i.removeEventListener("mousemove",s.mousemove),s.mousemove=null),16&e?s.wheel||(i.addEventListener("wheel",o,{passive:!1}),s.wheel=o):(i.removeEventListener("wheel",s.wheel),s.wheel=null),2&e?s.mouseup||(s.mouseup=n):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),4&e?s.mousedrag||(s.mousedrag=a):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(nb(i,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return r(e),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(e)})),this._register(nb(i,"wheel",i=>{if(!s.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback){if(0===i.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(i,!0);let r=n6.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(r,!0),this.cancel(i,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(e){rp(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,i,r){this._selectionService.setSelection(e,i,r)}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(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;i||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let r=function(e,i,r,s){let n={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?i?n.key=n6.ESC+"OA":n.key=n6.ESC+"[A":"UIKeyInputLeftArrow"===e.key?i?n.key=n6.ESC+"OD":n.key=n6.ESC+"[D":"UIKeyInputRightArrow"===e.key?i?n.key=n6.ESC+"OC":n.key=n6.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(i?n.key=n6.ESC+"OB":n.key=n6.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":n6.DEL,e.altKey&&(n.key=n6.ESC+n.key);break;case 9:if(e.shiftKey){n.key=n6.ESC+"[Z";break}n.key=n6.HT,n.cancel=!0;break;case 13:n.key=e.altKey?n6.ESC+n6.CR:n6.CR,n.cancel=!0;break;case 27:n.key=n6.ESC,e.altKey&&(n.key=n6.ESC+n6.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=n6.ESC+"[1;"+(o+1)+"D":i?n.key=n6.ESC+"OD":n.key=n6.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=n6.ESC+"[1;"+(o+1)+"C":i?n.key=n6.ESC+"OC":n.key=n6.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=n6.ESC+"[1;"+(o+1)+"A":i?n.key=n6.ESC+"OA":n.key=n6.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=n6.ESC+"[1;"+(o+1)+"B":i?n.key=n6.ESC+"OB":n.key=n6.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=n6.ESC+"[2~");break;case 46:o?n.key=n6.ESC+"[3;"+(o+1)+"~":n.key=n6.ESC+"[3~";break;case 36:o?n.key=n6.ESC+"[1;"+(o+1)+"H":i?n.key=n6.ESC+"OH":n.key=n6.ESC+"[H";break;case 35:o?n.key=n6.ESC+"[1;"+(o+1)+"F":i?n.key=n6.ESC+"OF":n.key=n6.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=n6.ESC+"[5;"+(o+1)+"~":n.key=n6.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=n6.ESC+"[6;"+(o+1)+"~":n.key=n6.ESC+"[6~";break;case 112:o?n.key=n6.ESC+"[1;"+(o+1)+"P":n.key=n6.ESC+"OP";break;case 113:o?n.key=n6.ESC+"[1;"+(o+1)+"Q":n.key=n6.ESC+"OQ";break;case 114:o?n.key=n6.ESC+"[1;"+(o+1)+"R":n.key=n6.ESC+"OR";break;case 115:o?n.key=n6.ESC+"[1;"+(o+1)+"S":n.key=n6.ESC+"OS";break;case 116:o?n.key=n6.ESC+"[15;"+(o+1)+"~":n.key=n6.ESC+"[15~";break;case 117:o?n.key=n6.ESC+"[17;"+(o+1)+"~":n.key=n6.ESC+"[17~";break;case 118:o?n.key=n6.ESC+"[18;"+(o+1)+"~":n.key=n6.ESC+"[18~";break;case 119:o?n.key=n6.ESC+"[19;"+(o+1)+"~":n.key=n6.ESC+"[19~";break;case 120:o?n.key=n6.ESC+"[20;"+(o+1)+"~":n.key=n6.ESC+"[20~";break;case 121:o?n.key=n6.ESC+"[21;"+(o+1)+"~":n.key=n6.ESC+"[21~";break;case 122:o?n.key=n6.ESC+"[23;"+(o+1)+"~":n.key=n6.ESC+"[23~";break;case 123:o?n.key=n6.ESC+"[24;"+(o+1)+"~":n.key=n6.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!r||s)&&e.altKey&&!e.metaKey){let i=l_[e.keyCode]?.[+!!e.shiftKey];if(i)n.key=n6.ESC+i;else if(e.keyCode>=65&&e.keyCode<=90){let i=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(i=i.toUpperCase()),n.key=n6.ESC+i}else if(32===e.keyCode)n.key=n6.ESC+(e.ctrlKey?n6.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let i=e.code.slice(3,4);e.shiftKey||(i=i.toLowerCase()),n.key=n6.ESC+i,n.cancel=!0}}else!r||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=n6.US),"@"===e.key&&(n.key=n6.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=n6.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=n6.DEL:219===e.keyCode?n.key=n6.ESC:220===e.keyCode?n.key=n6.FS:221===e.keyCode&&(n.key=n6.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===r.type||2===r.type){let i=this.rows-1;return this.scrollLines(2===r.type?-i:i),this.cancel(e,!0)}return 1===r.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((r.key===n6.ETX||r.key===n6.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,i){let r=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?r:r&&(!i.keyCode||i.keyCode>47)}_keyUp(e){var i;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(i=e).keyCode||17===i.keyCode||18===i.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(null===e.which||void 0===e.which)i=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;i=e.which}return!!i&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(ay));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 e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(n6.ESC+"[I"):this.coreService.triggerDataEvent(n6.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${n6.ESC}[4;${r};${i}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${n6.ESC}[6;${n};${s}t`)}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}},lN=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let r={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(r),i.dispose=()=>this._wrappedAddonDispose(r),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){i=r;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},lR=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new rw)}translateToString(e,i,r){return this._line.translateToString(e,i,r)}},lj=class{constructor(e,i){this._buffer=e,this.type=i}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let i=this._buffer.lines.get(e);if(i)return new lR(i)}getNullCell(){return new rw}},lT=class extends r9{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new s_),this.onBufferChange=this._onBufferChange.event,this._normal=new lj(this._core.buffers.normal,"normal"),this._alternate=new lj(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)}},lD=class{constructor(e){this._core=e}registerCsiHandler(e,i){return this._core.registerCsiHandler(e,e=>i(e.toArray()))}addCsiHandler(e,i){return this.registerCsiHandler(e,i)}registerDcsHandler(e,i){return this._core.registerDcsHandler(e,(e,r)=>i(e,r.toArray()))}addDcsHandler(e,i){return this.registerDcsHandler(e,i)}registerEscHandler(e,i){return this._core.registerEscHandler(e,i)}addEscHandler(e,i){return this.registerEscHandler(e,i)}registerOscHandler(e,i){return this._core.registerOscHandler(e,i)}addOscHandler(e,i){return this.registerOscHandler(e,i)}},lM=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},lP=["cols","rows"],lL=0,lA=class extends r9{constructor(e){super(),this._core=this._register(new lE(e)),this._addonManager=this._register(new lN),this._publicOptions={...this._core.options};let i=e=>this._core.options[e],r=(e,i)=>{this._checkReadonlyOptions(e),this._core.options[e]=i};for(let e in this._core.options){let s={get:i.bind(this,e),set:r.bind(this,e)};Object.defineProperty(this._publicOptions,e,s)}}_checkReadonlyOptions(e){if(lP.includes(e))throw Error(`Option "${e}" 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 lD(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new lM(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 lT(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let i in e)this._publicOptions[i]=e[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,i=!0){this._core.input(e,i)}resize(e,i){this._verifyIntegers(e,i),this._core.resize(e,i)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,i,r){this._verifyIntegers(e,i,r),this._core.select(e,i,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,i){this._verifyIntegers(e,i),this._core.selectLines(e,i)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,i){this._core.write(e,i)}writeln(e,i){this._core.write(e),this._core.write(`\r
22
+ `,i)}paste(e){this._core.paste(e)}refresh(e,i){this._verifyIntegers(e,i),this._core.refresh(e,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return ru},set promptLabel(t){ru=t},get tooMuchOutput(){return rf},set tooMuchOutput(t){rf=t}}}_verifyIntegers(...e){for(lL of e)if(lL===1/0||isNaN(lL)||lL%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(lL of e)if(lL&&(lL===1/0||isNaN(lL)||lL%1!=0||lL<0))throw Error("This API only accepts positive integers")}},lB=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(r.getPropertyValue("height")),n=Math.max(0,parseInt(r.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom;return{cols:Math.max(2,Math.floor((n-(a.right+a.left)-i)/e.css.cell.width)),rows:Math.max(1,Math.floor((s-l)/e.css.cell.height))}}};function lI({projectId:e,agentId:i,wsUrl:r,onActivity:s}){let n=(0,m.useRef)(null),o=(0,m.useRef)(null),a=(0,m.useRef)(null),l=(0,m.useRef)(null),h=(0,m.useRef)(s);(0,m.useEffect)(()=>{h.current=s},[s]);let c=(0,m.useCallback)(()=>{if(a.current&&o.current&&n.current)try{a.current.fit();let e=l.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:"resize",cols:o.current.cols,rows:o.current.rows}))}catch{}},[]);return(0,m.useEffect)(()=>{if(!n.current)return;let s=new lA({scrollback:1e3,fontSize:11,fontFamily:'"Geist Mono", "JetBrains Mono", "Fira Code", "Cascadia Code", monospace',lineHeight:1.2,letterSpacing:.5,cursorBlink:!1,cursorStyle:"block",theme:{background:"#0a0a0a",foreground:"#e0e0e0",cursor:"#00ff88",cursorAccent:"#0a0a0a",selectionBackground:"#00ff8844",black:"#0a0a0a",red:"#ff4444",green:"#00ff88",yellow:"#ffcc00",blue:"#4488ff",magenta:"#cc44ff",cyan:"#44ccff",white:"#e0e0e0",brightBlack:"#737373",brightRed:"#ff6666",brightGreen:"#00ff88",brightYellow:"#ffdd44",brightBlue:"#66aaff",brightMagenta:"#dd66ff",brightCyan:"#66ddff",brightWhite:"#ffffff"},allowTransparency:!1,drawBoldTextInBrightColors:!0}),d=new lB;s.loadAddon(d),s.open(n.current),o.current=s,a.current=d,requestAnimationFrame(()=>c());let u=new ResizeObserver(()=>c());u.observe(n.current),s.onData(e=>{let i=l.current;i&&i.readyState===WebSocket.OPEN&&i.send(e)});let f=!1,p=null,m=async()=>{if(p)return p;if(r)return p=r;let e="https:"===window.location.protocol?"wss:":"ws:";try{let i=await fetch("/api/config");if(i.ok){let r=(await i.json()).port||8400,s=parseInt(window.location.port,10);p=s&&s!==r?`${e}//${window.location.hostname}:${r}`:`${e}//${window.location.host}`}else p=`${e}//${window.location.host}`}catch{p=`${e}//${window.location.host}`}return p},_=async()=>{try{let r=await fetch("/api/sessions");if(!r.ok)return!1;let s=await r.json();return Array.isArray(s)&&s.some(r=>r&&r.projectId===e&&r.agentId===i)}catch{return!1}},g=0,v=null,x=async()=>{let r=await m();if(f)return;let n=new WebSocket(`${r}/ws/terminal?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i)}`);l.current=n,n.onopen=()=>{g=0,v&&clearInterval(v);let e=0;v=setInterval(()=>{c(),++e>=4&&(clearInterval(v),v=null)},500),n.send(JSON.stringify({type:"resize",cols:s.cols,rows:s.rows})),n.send(JSON.stringify({type:"replay"}))},n.onmessage=e=>{s.write(e.data);let i=h.current;i&&i()},n.onclose=async e=>{if(v&&(clearInterval(v),v=null),!f){if(g<5){let e=Date.now(),i=!1;for(;Date.now()-e<2e3;){if(await new Promise(e=>setTimeout(e,200)),f)return;if(await _()){i=!0;break}}if(f)return;if(i){g+=1,s.reset(),s.write(`\x1b[38;2;115;115;115m[reattached to new session]\x1b[0m\r
19
23
  `),x();return}}s.write(`\r
20
24
  \x1b[38;2;115;115;115m[session closed: ${e.reason||e.code}]\x1b[0m\r
21
- `)}}};return x(),()=>{f=!0,v&&clearInterval(v),u.disconnect(),l.current?.close(),s.dispose(),o.current=null,a.current=null,l.current=null}},[e,i,r,c]),(0,p.jsx)("div",{ref:n,className:"w-full h-full"})}let lA=[{id:"re1",label:"RE1"},{id:"re2",label:"RE2"},{id:"dev",label:"Dev"}],lB=["border-r border-b border-border","border-b border-border","col-span-2"],lI=["border-r border-b border-border","border-b border-border","border-r border-border",""];function lO({projectId:e,agents:i=lA,agentStates:r={},onStatusChange:s}){let[n,o]=(0,_.useState)(null),a=i.length>=4?lI:lB,l=(0,_.useRef)({}),[h,c]=(0,_.useState)(0),d=(0,_.useCallback)(e=>{l.current[e]=Date.now()},[]),u=(0,_.useRef)({}),f=(0,_.useCallback)((i,r)=>{fetch("/api/activity/log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e,agent:i,type:r,timestamp:Date.now()})}).catch(()=>{})},[e]);(0,_.useEffect)(()=>{let e=setInterval(()=>{for(let e of(c(e=>e+1),i)){let i=l.current[e.id],r=void 0!==i&&Date.now()-i<5e3,s=!!u.current[e.id];r&&!s?(u.current[e.id]=!0,f(e.id,"start")):!r&&s&&(u.current[e.id]=!1,f(e.id,"end"))}},500);return()=>clearInterval(e)},[i,f]);let m=e=>{let i=l.current[e];return void 0!==i&&Date.now()-i<5e3};return(0,p.jsx)("div",{className:"w-full h-full relative grid grid-rows-2 grid-cols-2",children:i.map((i,l)=>{let h=n===i.id,c=null!==n&&!h;return(0,p.jsxs)("div",{className:`flex flex-col ${h?"absolute inset-0 z-10 bg-bg":`${a[l]||""}`}`,style:c?{visibility:"hidden",overflow:"hidden"}:void 0,children:[(0,p.jsxs)("div",{className:`flex items-center justify-between px-3 shrink-0 border-b border-border ${h?"h-7":"h-6"}`,children:[(0,p.jsxs)("div",{className:`flex items-center gap-1.5 ${!h?"cursor-pointer":""}`,onClick:h?void 0:()=>o(i.id),children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:["running"===r[i.id]&&m(i.id)&&(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:`relative w-1.5 h-1.5 rounded-full ${"running"===r[i.id]?"bg-accent":"error"===r[i.id]?"bg-error":"bg-text-muted"}`})]}),(0,p.jsx)("span",{className:`text-[11px] uppercase tracking-wider ${"running"===r[i.id]&&m(i.id)?"text-accent animate-name-shimmer":"text-text-muted"}`,children:i.label})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1",children:["running"!==r[i.id]&&(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i.id)}&action=start`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&s&&s(i.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Start",children:"▶"}),"running"===r[i.id]&&(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i.id)}&action=stop`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&s&&s(i.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-error transition-colors px-0.5",title:"Stop",children:"■"}),(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i.id)}&action=restart`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&s&&s(i.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Restart",children:"↻"}),"running"===r[i.id]&&(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents/${encodeURIComponent(e)}/${encodeURIComponent(i.id)}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"/compact\n"})}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Compact — frees context/memory when agent is stuck",children:"/c"}),h&&(0,p.jsx)("button",{onClick:()=>o(null),className:"text-[11px] text-text-muted hover:text-text transition-colors ml-1",children:"esc"})]})]}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(lP,{projectId:e,agentId:i.id,onActivity:()=>d(i.id)})})]},i.id)})})}let lF={en:{title:"Agent Terminals",aboutLabel:"About agent terminals",tooltip:(0,p.jsxs)(p.Fragment,{children:["These show what each agent is doing in their CLI session. ",(0,p.jsx)("b",{children:"Do not type here directly"}),"— use the AgentChattr chat above instead. Agents won't see messages typed in their terminals."]})},ko:{title:"에이전트 터미널",aboutLabel:"에이전트 터미널 설명",tooltip:(0,p.jsxs)(p.Fragment,{children:["각 에이전트가 CLI 세션에서 무엇을 하고 있는지 보여주는 읽기 전용 터미널입니다. ",(0,p.jsx)("b",{children:"여기에 직접 입력하지 마세요."})," 위의 AgentChattr 채팅을 사용해야 에이전트가 메시지를 볼 수 있습니다."]})}},lH=[{id:"head",label:"Head"},{id:"dev",label:"Dev"},{id:"re1",label:"RE1"},{id:"re2",label:"RE2"}];function lz({projectId:e,agentStates:i,onStatusChange:r}){let{locale:s}=(0,x.useLocale)(),n=lF[s],[o,a]=(0,_.useState)(!1);return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,p.jsx)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:n.title}),(0,p.jsxs)("div",{className:"relative inline-flex items-center",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,p.jsx)("button",{type:"button","aria-label":n.aboutLabel,className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),o&&(0,p.jsx)("div",{role:"tooltip",className:"ko-help absolute top-5 left-0 z-20 w-72 max-w-[min(18rem,calc(100vw-2rem))] p-2 text-[11px] leading-snug text-text bg-bg-surface border border-border shadow-lg",children:n.tooltip})]})]})}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(lO,{projectId:e,agents:lH,agentStates:i,onStatusChange:r})})]})}let l$={en:{label:(e,i)=>`Scheduled Trigger${e?i?" (auto)":" (running)":""}`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Scheduled Trigger"})," sends a periodic message to all agents on a timer. Use this to keep the autonomous workflow running overnight. First message fires after the configured interval, not immediately."]}),autoTriggerOn:"Auto-trigger ON — trigger follows batch lifecycle",autoTriggerOff:"Auto-trigger OFF — manual start/stop only",auto:"Auto ",message:"Message",sendEvery:"Send every",minFor:"min for",hours:"hours",starting:"Starting…",startTrigger:"Start Trigger",sending:"Sending:",running:"Running",next:"Next: ",stopsIn:"Stops in: ",untilStopped:"(until stopped)",stopping:"Stopping…",stopTrigger:"Stop Trigger",autoStopStatus:"Batch complete — trigger paused. Waiting for next batch."},ko:{label:(e,i)=>`예약 트리거${e?i?" (자동)":" (실행 중)":""}`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"예약 트리거"})," - 타이머에 따라 모든 에이전트에게 주기적으로 메시지를 보냅니다. 야간 자율 워크플로우를 계속 돌릴 때 사용하세요. 첫 메시지는 즉시가 아니라 설정한 간격 후에 전송됩니다."]}),autoTriggerOn:"자동 트리거 ON - 배치 생명주기에 따라 트리거가 동작합니다",autoTriggerOff:"자동 트리거 OFF - 수동 시작/중지만 가능합니다",auto:"자동 ",message:"메시지",sendEvery:"전송 간격: ",minFor:"분 마다, ",hours:"시간 동안",starting:"시작 중…",startTrigger:"트리거 시작",sending:"전송 중:",running:"실행 중",next:"다음 전송: ",stopsIn:"종료까지: ",untilStopped:"(중지할 때까지)",stopping:"중지 중…",stopTrigger:"트리거 중지",autoStopStatus:"배치 완료 — 트리거 일시 중지. 다음 배치를 기다리는 중."}};function lW(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function lU(e){return!Number.isFinite(e)||e<=0?String(3):(Math.round(e/60*10)/10).toString()}function lK(e){if(e<=0)return"0m 0s";let i=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),s=Math.floor(e%6e4/1e3);return i>0?`${i}h ${r}m`:`${r}m ${s}s`}function lq({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l$[i],[s,n]=(0,_.useState)(null),[o,a]=(0,_.useState)(""),[l,h]=(0,_.useState)(15),[c,d]=(0,_.useState)("15"),[u,f]=(0,_.useState)(180),[m,v]=(0,_.useState)(()=>lU(180)),[b,y]=(0,_.useState)(!1),[S,w]=(0,_.useState)(!1),C=(0,_.useRef)(""),k=(0,_.useRef)(!1),E=(0,_.useRef)(!1);(0,_.useEffect)(()=>{C.current=o},[o]),(0,_.useEffect)(()=>{k.current=b},[b]),(0,_.useEffect)(()=>{E.current=S},[S]);let[N,R]=(0,_.useState)(!1),[j,T]=(0,_.useState)(null),[D,M]=(0,_.useState)(""),[L,P]=(0,_.useState)(""),A=(0,_.useMemo)(()=>{let i;return i=`~/.quadwork/${e}/OVERNIGHT-QUEUE.md`,`@head @dev @re1 @re2 — Queue check.
25
+ `)}}};return x(),()=>{f=!0,v&&clearInterval(v),u.disconnect(),l.current?.close(),s.dispose(),o.current=null,a.current=null,l.current=null}},[e,i,r,c]),(0,p.jsx)("div",{ref:n,className:"w-full h-full"})}let lO=[{id:"re1",label:"RE1"},{id:"re2",label:"RE2"},{id:"dev",label:"Dev"}],lF=["border-r border-b border-border","border-b border-border","col-span-2"],lz=["border-r border-b border-border","border-b border-border","border-r border-border",""];function lH({projectId:e,agents:i=lO,agentStates:r={},onStatusChange:s}){let[n,o]=(0,m.useState)(null),a=i.length>=4?lz:lF,l=(0,m.useRef)({}),[h,c]=(0,m.useState)(0),d=(0,m.useCallback)(e=>{l.current[e]=Date.now()},[]),u=(0,m.useRef)({}),f=(0,m.useCallback)((i,r)=>{fetch("/api/activity/log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e,agent:i,type:r,timestamp:Date.now()})}).catch(()=>{})},[e]);(0,m.useEffect)(()=>{let e=setInterval(()=>{for(let e of(c(e=>e+1),i)){let i=l.current[e.id],r=void 0!==i&&Date.now()-i<5e3,s=!!u.current[e.id];r&&!s?(u.current[e.id]=!0,f(e.id,"start")):!r&&s&&(u.current[e.id]=!1,f(e.id,"end"))}},500);return()=>clearInterval(e)},[i,f]);let _=e=>{let i=l.current[e];return void 0!==i&&Date.now()-i<5e3};return(0,p.jsx)("div",{className:"w-full h-full relative grid grid-rows-2 grid-cols-2",children:i.map((i,l)=>{let h=n===i.id,c=null!==n&&!h;return(0,p.jsxs)("div",{className:`flex flex-col ${h?"absolute inset-0 z-10 bg-bg":`${a[l]||""}`}`,style:c?{visibility:"hidden",overflow:"hidden"}:void 0,children:[(0,p.jsxs)("div",{className:`flex items-center justify-between px-3 shrink-0 border-b border-border ${h?"h-7":"h-6"}`,children:[(0,p.jsxs)("div",{className:`flex items-center gap-1.5 ${!h?"cursor-pointer":""}`,onClick:h?void 0:()=>o(i.id),children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:["running"===r[i.id]&&_(i.id)&&(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:`relative w-1.5 h-1.5 rounded-full ${"running"===r[i.id]?"bg-accent":"error"===r[i.id]?"bg-error":"bg-text-muted"}`})]}),(0,p.jsx)("span",{className:`text-[11px] uppercase tracking-wider ${"running"===r[i.id]&&_(i.id)?"text-accent animate-name-shimmer":"text-text-muted"}`,children:i.label})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1",children:["running"!==r[i.id]&&(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i.id)}&action=start`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&s&&s(i.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Start",children:"▶"}),"running"===r[i.id]&&(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i.id)}&action=stop`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&s&&s(i.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-error transition-colors px-0.5",title:"Stop",children:"■"}),(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(i.id)}&action=restart`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&s&&s(i.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Restart",children:"↻"}),"running"===r[i.id]&&(0,p.jsx)("button",{onClick:()=>{fetch(`/api/agents/${encodeURIComponent(e)}/${encodeURIComponent(i.id)}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"/compact\n"})}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Compact — frees context/memory when agent is stuck",children:"/c"}),h&&(0,p.jsx)("button",{onClick:()=>o(null),className:"text-[11px] text-text-muted hover:text-text transition-colors ml-1",children:"esc"})]})]}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(lI,{projectId:e,agentId:i.id,onActivity:()=>d(i.id)})})]},i.id)})})}let l$={en:{title:"Agent Terminals",aboutLabel:"About agent terminals",tooltip:(0,p.jsxs)(p.Fragment,{children:["These show what each agent is doing in their CLI session. ",(0,p.jsx)("b",{children:"Do not type here directly"}),"— use the AgentChattr chat above instead. Agents won't see messages typed in their terminals."]})},ko:{title:"에이전트 터미널",aboutLabel:"에이전트 터미널 설명",tooltip:(0,p.jsxs)(p.Fragment,{children:["각 에이전트가 CLI 세션에서 무엇을 하고 있는지 보여주는 읽기 전용 터미널입니다. ",(0,p.jsx)("b",{children:"여기에 직접 입력하지 마세요."})," 위의 AgentChattr 채팅을 사용해야 에이전트가 메시지를 볼 수 있습니다."]})}},lW=[{id:"head",label:"Head"},{id:"dev",label:"Dev"},{id:"re1",label:"RE1"},{id:"re2",label:"RE2"}];function lU({projectId:e,agentStates:i,onStatusChange:r}){let{locale:s}=(0,x.useLocale)(),n=l$[s],[o,a]=(0,m.useState)(!1);return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,p.jsx)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:n.title}),(0,p.jsxs)("div",{className:"relative inline-flex items-center",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,p.jsx)("button",{type:"button","aria-label":n.aboutLabel,className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),o&&(0,p.jsx)("div",{role:"tooltip",className:"ko-help absolute top-5 left-0 z-20 w-72 max-w-[min(18rem,calc(100vw-2rem))] p-2 text-[11px] leading-snug text-text bg-bg-surface border border-border shadow-lg",children:n.tooltip})]})]})}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(lH,{projectId:e,agents:lW,agentStates:i,onStatusChange:r})})]})}let lK={en:{label:(e,i)=>`Scheduled Trigger${e?i?" (auto)":" (running)":""}`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Scheduled Trigger"})," sends a periodic message to all agents on a timer. Use this to keep the autonomous workflow running overnight. First message fires after the configured interval, not immediately."]}),autoTriggerOn:"Auto-trigger ON — trigger follows batch lifecycle",autoTriggerOff:"Auto-trigger OFF — manual start/stop only",auto:"Auto ",message:"Message",sendEvery:"Send every",minFor:"min for",hours:"hours",starting:"Starting…",startTrigger:"Start Trigger",sending:"Sending:",running:"Running",next:"Next: ",stopsIn:"Stops in: ",untilStopped:"(until stopped)",stopping:"Stopping…",stopTrigger:"Stop Trigger",autoStopStatus:"Batch complete — trigger paused. Waiting for next batch."},ko:{label:(e,i)=>`예약 트리거${e?i?" (자동)":" (실행 중)":""}`,tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"예약 트리거"})," - 타이머에 따라 모든 에이전트에게 주기적으로 메시지를 보냅니다. 야간 자율 워크플로우를 계속 돌릴 때 사용하세요. 첫 메시지는 즉시가 아니라 설정한 간격 후에 전송됩니다."]}),autoTriggerOn:"자동 트리거 ON - 배치 생명주기에 따라 트리거가 동작합니다",autoTriggerOff:"자동 트리거 OFF - 수동 시작/중지만 가능합니다",auto:"자동 ",message:"메시지",sendEvery:"전송 간격: ",minFor:"분 마다, ",hours:"시간 동안",starting:"시작 중…",startTrigger:"트리거 시작",sending:"전송 중:",running:"실행 중",next:"다음 전송: ",stopsIn:"종료까지: ",untilStopped:"(중지할 때까지)",stopping:"중지 중…",stopTrigger:"트리거 중지",autoStopStatus:"배치 완료 — 트리거 일시 중지. 다음 배치를 기다리는 중."}};function lq(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function lV(e){return!Number.isFinite(e)||e<=0?String(3):(Math.round(e/60*10)/10).toString()}function lY(e){if(e<=0)return"0m 0s";let i=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),s=Math.floor(e%6e4/1e3);return i>0?`${i}h ${r}m`:`${r}m ${s}s`}function lG({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=lK[i],[s,n]=(0,m.useState)(null),[o,a]=(0,m.useState)(""),[l,h]=(0,m.useState)(15),[c,d]=(0,m.useState)("15"),[u,f]=(0,m.useState)(180),[_,v]=(0,m.useState)(()=>lV(180)),[b,y]=(0,m.useState)(!1),[S,w]=(0,m.useState)(!1),C=(0,m.useRef)(""),k=(0,m.useRef)(!1),E=(0,m.useRef)(!1);(0,m.useEffect)(()=>{C.current=o},[o]),(0,m.useEffect)(()=>{k.current=b},[b]),(0,m.useEffect)(()=>{E.current=S},[S]);let[N,R]=(0,m.useState)(!1),[j,T]=(0,m.useState)(null),[D,M]=(0,m.useState)(""),[P,L]=(0,m.useState)(""),A=(0,m.useMemo)(()=>{let i;return i=`~/.quadwork/${e}/OVERNIGHT-QUEUE.md`,`@head @dev @re1 @re2 — Queue check.
22
26
  @head: Merge any PR with both approvals, assign next from ${i}.
23
27
  @dev: Work on assigned ticket or address review feedback.
24
28
  @re1 & @re2: Review open PRs. If @dev pushed fixes, re-review. Post verdict on PR AND notify @dev here.
25
- ALL: Communicate via this chat by tagging agents. Your terminal is NOT visible.`},[e]),[B,I]=(0,_.useState)(!1),[O,F]=(0,_.useState)(!1),[H,z]=(0,_.useState)(null),$=(0,_.useRef)(null),W=(0,_.useRef)(!1);(0,_.useEffect)(()=>{W.current=!1,$.current=null,I(!1),F(!1),z(null)},[e]),(0,_.useEffect)(()=>{W.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.trigger_auto&&I(!0),W.current=!0}).catch(()=>{})},[e]);let U=(0,_.useCallback)(async()=>{try{let i=await fetch("/api/triggers");if(!i.ok)throw Error(`${i.status}`);let r=(await i.json())[e]||null;if(n(r),r){if(r.message&&!C.current&&(a(r.message),C.current=r.message),!k.current)if(r.enabled&&r.interval){let e=Math.max(1,Math.round(r.interval/6e4));h(e),d(String(e))}else"number"==typeof r.intervalMin&&r.intervalMin>0&&(h(r.intervalMin),d(String(r.intervalMin)));!E.current&&"number"==typeof r.durationMin&&r.durationMin>=0&&(f(r.durationMin),v(lU(r.durationMin)))}T(null)}catch(e){T(e.message)}},[e]);(0,_.useEffect)(()=>{o||a(A)},[A,o]),(0,_.useEffect)(()=>{U();let e=window.setInterval(U,5e3);return()=>window.clearInterval(e)},[U]),(0,_.useEffect)(()=>{if(!s?.enabled){M(""),P("");return}let e=()=>{if(s.nextAt&&M(lK(Math.max(0,s.nextAt-Date.now()))),s.expiresAt){let e=Math.max(0,s.expiresAt-Date.now());P(lK(e)),e<=0&&U()}else P("")};e();let i=window.setInterval(e,1e3);return()=>window.clearInterval(i)},[s?.enabled,s?.nextAt,s?.expiresAt,U]);let K=async()=>{R(!0),T(null);let i=parseFloat(m),r=Math.round(60*(Number.isFinite(i)?lW(i):3));r!==u&&(f(r),v(lU(r)));let s=parseInt(c,10),n=Number.isFinite(s)?Math.max(1,Math.min(1440,s)):15;n!==l&&(h(n),d(String(n)));try{let i=await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:n,duration:r,message:o})});if(!i.ok)throw Error(`${i.status}`);y(!1),w(!1),await U()}catch(e){T(e.message)}finally{R(!1)}},q=async()=>{R(!0),T(null);try{let i=await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"});if(!i.ok)throw Error(`${i.status}`);F(!1),n({...s||{interval:0,lastSent:null,nextAt:null,expiresAt:null,message:o,intervalMin:l,durationMin:u},enabled:!1}),await U()}catch(e){T(e.message)}finally{R(!1)}},V=(0,_.useCallback)(async()=>{let i=!B;I(i),i||(z(null),$.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.trigger_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[B,e]),Y=(0,_.useRef)(B),G=(0,_.useRef)(s);(0,_.useEffect)(()=>{Y.current=B},[B]),(0,_.useEffect)(()=>{G.current=s},[s]);let X=(0,_.useCallback)(async()=>{if(Y.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=$.current;if($.current={complete:s.complete,hasItems:n},!o){if(n&&!s.complete&&!G.current?.enabled){F(!0),z(null);let i=parseFloat(m),r=Number.isFinite(i)?lW(i):3,s=Math.round(60*r),n=parseInt(c,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:C.current||A})}),await U()}n&&s.complete&&G.current?.enabled&&(await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),F(!1),z(r.autoStopStatus),await U());return}if(n&&s.complete&&!o.complete&&G.current?.enabled){await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),F(!1),z(r.autoStopStatus),await U();return}if(n&&!s.complete&&(o.complete||!o.hasItems)&&!G.current?.enabled){F(!0),z(null);let i=parseFloat(m),r=Number.isFinite(i)?lW(i):3,s=Math.round(60*r),n=parseInt(c,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:C.current||A})}),await U()}}catch{}},[e,m,c,A,U,r.autoStopStatus]);(0,_.useEffect)(()=>{if(!B)return;X();let e=window.setInterval(X,3e4);return()=>window.clearInterval(e)},[B,X]);let J=!!s?.enabled;return(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.label(J,O)}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[j&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",j]}),(0,p.jsxs)("button",{type:"button",onClick:V,title:B?r.autoTriggerOn:r.autoTriggerOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${B?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[r.auto,B?"●":"○"]})]})]}),H&&(0,p.jsx)("div",{className:"px-3 py-1 text-[10px] text-accent bg-accent/5 border-b border-border/50",children:H}),J?(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:r.sending}),(0,p.jsx)("pre",{className:"text-[11px] font-mono whitespace-pre-wrap text-text bg-bg-surface border border-border p-2 max-h-28 overflow-auto",children:(s?.message||o).slice(0,400)}),(0,p.jsxs)("div",{className:"flex items-center gap-3 flex-wrap text-[11px]",children:[(0,p.jsxs)("span",{className:"flex items-center gap-1",children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:r.running})]}),(0,p.jsxs)("span",{className:"tabular-nums text-text",children:[r.next,D]}),L&&(0,p.jsxs)("span",{className:"tabular-nums text-text-muted",children:[r.stopsIn,L]}),!s?.expiresAt&&(0,p.jsx)("span",{className:"text-text-muted",children:r.untilStopped})]}),(0,p.jsx)("button",{onClick:q,disabled:N,className:"self-start px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:N?r.stopping:r.stopTrigger})]}):(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("label",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.message}),(0,p.jsx)("textarea",{value:o,onChange:e=>a(e.target.value),rows:6,spellCheck:!1,className:"w-full bg-bg text-text text-[11px] font-mono p-2 border border-border outline-none focus:border-accent resize-y"}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-[11px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:r.sendEvery}),(0,p.jsx)("input",{type:"number",value:c,onChange:e=>{d(e.target.value),y(!0)},onBlur:()=>{let e=parseInt(c,10),i=Number.isFinite(e)?Math.max(1,Math.min(1440,e)):15;h(i),d(String(i))},min:1,max:1440,className:"w-12 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.minFor}),(0,p.jsx)("input",{type:"number",value:m,onChange:e=>{v(e.target.value),w(!0)},onBlur:()=>{let e=parseFloat(m),i=Math.round(60*(Number.isFinite(e)?lW(e):3));f(i),v(lU(i))},min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.hours})]}),(0,p.jsx)("button",{onClick:K,disabled:N||!o.trim(),className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:N?r.starting:r.startTrigger})]})]})}function lV({open:e,initialChatId:i="",onClose:r,onSave:s}){let[n,o]=(0,_.useState)(""),[a,l]=(0,_.useState)(i),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(null),[f,m]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{e&&l(i)},[e,i]),(0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),a.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"telegram-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"telegram-setup-title",className:"text-base font-semibold text-white",children:"Set up your Telegram Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Telegram chat, so you can read and reply on your phone."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Telegram bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for ",(0,p.jsx)("b",{children:"@BotFather"}),"."]}),(0,p.jsxs)("li",{children:["Send ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"/newbot"})," and follow the prompts."]}),(0,p.jsxs)("li",{children:["Choose a name and username (must end in ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),")."]}),(0,p.jsxs)("li",{children:["BotFather replies with a ",(0,p.jsx)("b",{children:"bot token"})," that looks like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"123456:ABC-DEF1234ghIkl…"}),". Copy it."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Get your chat ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for your new bot by its exact ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"@username"}),"."]}),(0,p.jsxs)("li",{children:["Tap ",(0,p.jsx)("b",{children:"Start"})," and send any message (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"hello"}),")."," ",(0,p.jsxs)("span",{className:"text-neutral-400",children:["You must send at least one message first — ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," returns ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:'{"ok":true,"result":[]}'})," until Telegram has an inbound message on record."]})]}),(0,p.jsxs)("li",{children:["Open this URL in your browser (replace ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"YOUR_TOKEN"}),"):",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://api.telegram.org/botYOUR_TOKEN/getUpdates"})]}),(0,p.jsxs)("li",{children:["Look for ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:'"chat":{"id":<NUMBER>'})," in the JSON. That number is your ",(0,p.jsx)("b",{children:"chat id"}),". Group chat ids are negative (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"-1001234567890"}),") — paste the full value ",(0,p.jsx)("b",{children:"including the minus sign"}),"."]})]}),(0,p.jsx)("p",{className:"mt-1 text-neutral-400",children:"Or use one of these terminal one-liners:"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["With ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (cleanest):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"curl -s \"https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates\" | jq '.result[-1].message.chat.id'"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["Without ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (pure grep):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates" | grep -o \'"chat":{"id":-\\?[0-9]*\' | tail -1'}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["The first message from a brand-new bot sometimes doesn't propagate to ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," instantly. If ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"result"})," is empty, send 2-3 more messages and retry."]}),(0,p.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"mt-2 text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Still empty? Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Webhook conflict."})," Something else may be consuming updates. Check and delete any active webhook:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getWebhookInfo" curl -s "https://api.telegram.org/bot<TOKEN>/deleteWebhook"'})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Stale bridge process."}),"A leftover bridge from a previous install will hold the update queue. Two consumers can't share one bot:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"ps aux | grep telegram_bridge | grep -v grep"}),"Kill any PIDs that show up before retrying the curl."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Token / bot mismatch."})," A token that doesn't match the bot you're messaging silently returns empty results. Confirm the token's ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"username"})," matches the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"@username"}),"you're chatting with:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getMe"'})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"123456:ABC-DEF…",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Chat id",(0,p.jsx)("input",{type:"text",value:a,onChange:e=>l(e.target.value),placeholder:"123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!a.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]})]})]})})}let lY={en:{title:"Telegram Bridge",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Telegram Bridge"})," forwards AgentChattr messages to a Telegram bot so you can monitor from your phone. Bidirectional — replies from Telegram appear in chat."]}),autoOn:"Auto ON — bridge follows batch lifecycle",autoOff:"Auto OFF — manual start/stop only",notConfigured:"Not configured",setUp:"Set up Telegram Bridge",running:"Running",stopped:"Stopped",stop:"Stop",stopping:"Stopping…",start:"Start",starting:"Starting…",howToSetUp:"How to set up",editCredentials:"Edit credentials",dismiss:"dismiss",batchActive:"Batch active — auto-starting bridge.",batchComplete:"Batch complete — bridge paused. Waiting for next batch.",newBatch:"New batch detected — auto-starting bridge."},ko:{title:"텔레그램 브릿지",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"텔레그램 브릿지"})," - AgentChattr 메시지를 텔레그램 봇으로 전달해서 휴대폰에서 모니터링할 수 있게 합니다. 양방향이며 텔레그램에서 보낸 답장도 채팅에 나타납니다."]}),autoOn:"자동 모드 켬 — 브릿지가 배치 주기를 따릅니다",autoOff:"자동 모드 끔 — 수동 시작/중지만 가능",notConfigured:"설정되지 않음",setUp:"텔레그램 브릿지 설정",running:"실행 중",stopped:"중지됨",stop:"중지",stopping:"중지 중…",start:"시작",starting:"시작 중…",howToSetUp:"설정 방법",editCredentials:"인증 정보 수정",dismiss:"닫기",batchActive:"배치 실행 중 — 브릿지를 자동 시작합니다.",batchComplete:"배치 완료 — 브릿지를 일시 중단했습니다. 다음 배치를 기다리는 중.",newBatch:"새 배치 감지 — 브릿지를 자동 시작합니다."}};async function lG(e,i){let r=await fetch(`/api/telegram?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function lX({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=lY[i],[s,n]=(0,_.useState)(null),[o,a]=(0,_.useState)(!1),[l,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(null),[u,f]=(0,_.useState)(!1),[m,v]=(0,_.useState)(null),[b,y]=(0,_.useState)(!1),[S,w]=(0,_.useState)(null),C=(0,_.useRef)(b),k=(0,_.useRef)(!1);(0,_.useEffect)(()=>{C.current=b},[b]);let E=(0,_.useRef)(!1);(0,_.useEffect)(()=>{E.current=!1,y(!1),w(null)},[e]),(0,_.useEffect)(()=>{E.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.telegram_auto&&y(!0),E.current=!0}).catch(()=>{})},[e]);let N=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/telegram?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();n(r),d(null)}catch(e){d(e.message)}},[e]);(0,_.useEffect)(()=>{N();let e=window.setInterval(N,5e3);return()=>window.clearInterval(e)},[N]);let R=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?v(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.tg]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):v(null)},j=async()=>{a(!0),h(null);try{if(s&&!s.bridge_installed){let e=await lG("install",{});R(e)}await lG("start",{project_id:e}),await N()}catch(e){h(e.message)}finally{a(!1)}},T=async()=>{a(!0),h(null);try{await lG("stop",{project_id:e}),await N()}catch(e){h(e.message)}finally{a(!1)}},D=async(i,r)=>{await lG("save-config",{project_id:e,bot_token:i,chat_id:r});try{if(s&&!s.bridge_installed){let e=await lG("install",{});R(e)}await lG("start",{project_id:e})}catch(e){h(e.message)}await N()},M=(0,_.useCallback)(async()=>{let i=!b;y(i),i||(w(null),L.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.telegram_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[b,e]),L=(0,_.useRef)(null),P=(0,_.useCallback)(async()=>{if(C.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=L.current;if(L.current={complete:s.complete,hasItems:n},!o){!n||s.complete||k.current||(w(r.batchActive),await lG("start",{project_id:e}).catch(()=>{}),await N()),n&&s.complete&&k.current&&(w(r.batchComplete),h(null),await lG("stop",{project_id:e}).catch(()=>{}),await N());return}if(n&&s.complete&&!o.complete&&k.current){w(r.batchComplete),h(null),await lG("stop",{project_id:e}).catch(()=>{}),await N();return}!n||s.complete||!o.complete&&o.hasItems||k.current||(w(r.newBatch),await lG("start",{project_id:e}).catch(()=>{}),await N())}catch{}},[e,N,r]);(0,_.useEffect)(()=>{if(!b)return;P();let e=window.setInterval(P,3e4);return()=>window.clearInterval(e)},[b,P]);let A=!!s?.configured,B=!!s?.running;(0,_.useEffect)(()=>{k.current=B},[B]);let I=!B&&!!S,O=l||c||!B&&!I&&s?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[A&&(0,p.jsxs)("button",{type:"button",onClick:M,title:b?r.autoOn:r.autoOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${b?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",b?"●":"○"]}),O&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[A?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[B?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:r.running})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.stopped})]}),s?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: @",s.bot_username]}),s?.chat_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Chat: ",s.chat_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[B?(0,p.jsx)("button",{onClick:T,disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:o?r.stopping:r.stop}):(0,p.jsx)("button",{onClick:j,disabled:o,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:o?r.starting:r.start}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.howToSetUp}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.editCredentials})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:r.notConfigured})]}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:r.setUp})]}),m&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[m,(0,p.jsx)("button",{type:"button",onClick:()=>v(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]}),S&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-accent",children:S}),O&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[O,l&&(0,p.jsx)("button",{type:"button",onClick:()=>h(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]})]})]}),(0,p.jsx)(lV,{open:u,initialChatId:s?.chat_id||"",onClose:()=>f(!1),onSave:D})]})}function lJ({open:e,initialChannelId:i="",onClose:r,onSave:s}){let[n,o]=(0,_.useState)(""),[a,l]=(0,_.useState)(i),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(null),[f,m]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{e&&l(i)},[e,i]),(0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),a.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"discord-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"discord-setup-title",className:"text-base font-semibold text-white",children:"Set up your Discord Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Discord channel, so you can read and reply from Discord."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Discord Application + Bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Discord Developer Portal"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"New Application"}),' → name it (e.g. "QuadWork") → ',(0,p.jsx)("b",{children:"Create"}),"."]}),(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"Bot"})," tab in the left sidebar."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Reset Token"})," → copy the bot token. Save it somewhere safe."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Enable MESSAGE_CONTENT intent (critical)"}),(0,p.jsxs)("div",{className:"mt-1.5 rounded border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,p.jsxs)("div",{className:"flex items-start gap-2",children:[(0,p.jsx)("span",{className:"text-amber-400 text-[16px] leading-none shrink-0",children:"⚠"}),(0,p.jsxs)("div",{className:"text-[12px] text-amber-200/90 leading-relaxed",children:[(0,p.jsx)("b",{className:"text-amber-300",children:"This step is required."}),"Without it, the bot connects successfully but receives empty message content — no error, no warning, just silent empty messages. This is the #1 cause of Discord bot setup issues."]})]}),(0,p.jsxs)("ol",{className:"mt-2 pl-6 list-decimal space-y-0.5 text-neutral-300 text-[12px]",children:[(0,p.jsxs)("li",{children:["On the same ",(0,p.jsx)("b",{children:"Bot"})," tab, scroll down to ",(0,p.jsx)("b",{children:"Privileged Gateway Intents"}),"."]}),(0,p.jsxs)("li",{children:["Toggle ",(0,p.jsx)("b",{children:"ON"}),": ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"MESSAGE CONTENT INTENT"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Save Changes"}),"."]})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Invite the bot to your server"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"OAuth2"})," tab → ",(0,p.jsx)("b",{children:"URL Generator"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Scopes"}),", check ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Bot Permissions"}),", check:",(0,p.jsxs)("ul",{className:"mt-0.5 pl-4 list-disc text-neutral-400",children:[(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Send Messages"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Read Message History"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"View Channels"})})]})]}),(0,p.jsxs)("li",{children:["Copy the generated URL at the bottom. It will look like:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&permissions=66560&scope=bot"})]}),(0,p.jsxs)("li",{children:["Open it in your browser → select your Discord server → ",(0,p.jsx)("b",{children:"Authorize"}),"."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 4 — Get your channel ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["In Discord, go to ",(0,p.jsx)("b",{children:"User Settings"})," → ",(0,p.jsx)("b",{children:"Advanced"})," → enable ",(0,p.jsx)("b",{children:"Developer Mode"}),"."]}),(0,p.jsxs)("li",{children:["Right-click the channel you want to bridge → ",(0,p.jsx)("b",{children:"Copy Channel ID"}),"."]})]}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["Channel IDs are large numbers like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"1234567890123456789"}),"."]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 5 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"MTIzNDU2Nzg5MDEyMzQ1Njc4OQ...",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Channel ID",(0,p.jsx)("input",{type:"text",value:a,onChange:e=>l(e.target.value),placeholder:"1234567890123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!a.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot connects but messages are empty."})," ","MESSAGE_CONTENT intent is not enabled. Go back to Step 2 — toggle it on in the Developer Portal under Bot → Privileged Gateway Intents, then restart the bridge."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot can't see the channel."})," ","The bot wasn't invited to the server (Step 3) or it lacks the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"View Channels"}),"permission for that specific channel. Check your server's role permissions."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:'"Disallowed intents" error in logs.'})," ","MESSAGE_CONTENT intent is not toggled in the Developer Portal. This is different from not requesting it in code — the portal toggle is the gatekeeper."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Rate limited."})," ","Normal for high-traffic channels. ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"discord.py"})," handles backoff automatically. If persistent, increase the AC poll interval in the bridge config."]})]})]})]})]})})}let lQ={en:{title:"Discord Bridge",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Discord Bridge"})," forwards AgentChattr messages to a Discord channel so you can monitor from Discord. Bidirectional — replies from Discord appear in chat."]}),autoOn:"Auto ON — bridge follows batch lifecycle",autoOff:"Auto OFF — manual start/stop only",notConfigured:"Not configured",setUp:"Set up Discord Bridge",running:"Running",stopped:"Stopped",stop:"Stop",stopping:"Stopping…",start:"Start",starting:"Starting…",howToSetUp:"How to set up",editCredentials:"Edit credentials",dismiss:"dismiss",batchActive:"Batch active — auto-starting bridge.",batchComplete:"Batch complete — bridge paused. Waiting for next batch.",newBatch:"New batch detected — auto-starting bridge."},ko:{title:"디스코드 브릿지",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"디스코드 브릿지"})," - AgentChattr 메시지를 디스코드 채널로 전달해서 디스코드에서 모니터링할 수 있게 합니다. 양방향이며 디스코드에서 보낸 답장도 채팅에 나타납니다."]}),autoOn:"자동 모드 켬 — 브릿지가 배치 주기를 따릅니다",autoOff:"자동 모드 끔 — 수동 시작/중지만 가능",notConfigured:"설정되지 않음",setUp:"디스코드 브릿지 설정",running:"실행 중",stopped:"중지됨",stop:"중지",stopping:"중지 중…",start:"시작",starting:"시작 중…",howToSetUp:"설정 방법",editCredentials:"인증 정보 수정",dismiss:"닫기",batchActive:"배치 실행 중 — 브릿지를 자동 시작합니다.",batchComplete:"배치 완료 — 브릿지를 일시 중단했습니다. 다음 배치를 기다리는 중.",newBatch:"새 배치 감지 — 브릿지를 자동 시작합니다."}};async function lZ(e,i){let r=await fetch(`/api/discord?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function l0({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=lQ[i],[s,n]=(0,_.useState)(null),[o,a]=(0,_.useState)(!1),[l,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(null),[u,f]=(0,_.useState)(!1),[m,v]=(0,_.useState)(null),[b,y]=(0,_.useState)(!1),[S,w]=(0,_.useState)(null),C=(0,_.useRef)(null),k=(0,_.useRef)(b),E=(0,_.useRef)(!1);(0,_.useEffect)(()=>{k.current=b},[b]);let N=(0,_.useRef)(!1);(0,_.useEffect)(()=>{N.current=!1,C.current=null,y(!1),w(null)},[e]),(0,_.useEffect)(()=>{N.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.discord_auto&&y(!0),N.current=!0}).catch(()=>{})},[e]);let R=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/discord?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();n(r),d(null)}catch(e){d(e.message)}},[e]);(0,_.useEffect)(()=>{R();let e=window.setInterval(R,5e3);return()=>window.clearInterval(e)},[R]);let j=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?v(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.dc]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):v(null)},T=async()=>{a(!0),h(null);try{if(s&&!s.bridge_installed){let e=await lZ("install",{});j(e)}await lZ("start",{project_id:e}),await R()}catch(e){h(e.message)}finally{a(!1)}},D=async()=>{a(!0),h(null);try{await lZ("stop",{project_id:e}),await R()}catch(e){h(e.message)}finally{a(!1)}},M=async(i,r)=>{await lZ("save-config",{project_id:e,bot_token:i,channel_id:r});try{if(s&&!s.bridge_installed){let e=await lZ("install",{});j(e)}await lZ("start",{project_id:e})}catch(e){h(e.message)}await R()},L=(0,_.useCallback)(async()=>{let i=!b;y(i),i||(w(null),C.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.discord_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[b,e]),P=(0,_.useCallback)(async()=>{if(k.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=C.current;if(C.current={complete:s.complete,hasItems:n},!o){!n||s.complete||E.current||(w(r.batchActive),await lZ("start",{project_id:e}).catch(()=>{}),await R()),n&&s.complete&&E.current&&(w(r.batchComplete),h(null),await lZ("stop",{project_id:e}).catch(()=>{}),await R());return}if(n&&s.complete&&!o.complete&&E.current){w(r.batchComplete),h(null),await lZ("stop",{project_id:e}).catch(()=>{}),await R();return}!n||s.complete||!o.complete&&o.hasItems||E.current||(w(r.newBatch),await lZ("start",{project_id:e}).catch(()=>{}),await R())}catch{}},[e,R,r]);(0,_.useEffect)(()=>{if(!b)return;P();let e=window.setInterval(P,3e4);return()=>window.clearInterval(e)},[b,P]);let A=!!s?.configured,B=!!s?.running;(0,_.useEffect)(()=>{E.current=B},[B]);let I=!B&&!!S,O=l||c||!B&&!I&&s?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[A&&(0,p.jsxs)("button",{type:"button",onClick:L,title:b?r.autoOn:r.autoOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${b?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",b?"●":"○"]}),O&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[A?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[B?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:r.running})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.stopped})]}),s?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: ",s.bot_username]}),s?.channel_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Channel: ",s.channel_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[B?(0,p.jsx)("button",{onClick:D,disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:o?r.stopping:r.stop}):(0,p.jsx)("button",{onClick:T,disabled:o,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:o?r.starting:r.start}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.howToSetUp}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.editCredentials})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:r.notConfigured})]}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:r.setUp})]}),m&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[m,(0,p.jsx)("button",{type:"button",onClick:()=>v(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]}),S&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-accent",children:S}),O&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[O,l&&(0,p.jsx)("button",{type:"button",onClick:()=>h(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]})]})]}),(0,p.jsx)(lJ,{open:u,initialChannelId:s?.channel_id||"",onClose:()=>f(!1),onSave:M})]})}let l1={en:{title:"Loop Guard",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Loop Guard"})," pauses agent-to-agent message chains after this many hops with no human reply. Higher values let agents work longer overnight; lower values add safety against runaway loops. AgentChattr accepts ",(0,p.jsx)("b",{children:"4–50"}),"; QuadWork defaults to ",(0,p.jsx)("b",{children:"30"})," (about 5–6 full PR cycles). Posting any chat message yourself resets the counter immediately."]}),pauseAfter:"Pause after",hops:"hops",apply:"Apply",applying:"…",applyTitle:"Apply (writes config.toml + live-pushes to AgentChattr)",errorInteger:"Must be an integer between 4 and 50.",liveUpdateFailed:"Saved to config.toml — live update failed; takes effect on next AC restart.",autoContinue:"Auto-continue after pause",wait:"— wait",secondsBefore:"s before /continue"},ko:{title:"루프 가드",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"루프 가드"})," - 사람의 응답 없이 에이전트끼리 메시지를 주고받는 횟수가 이 값에 도달하면 체인을 멈춥니다. 값을 높이면 야간 작업을 더 길게 돌릴 수 있고, 낮추면 runaway loop에 대한 안전성이 높아집니다. AgentChattr 허용 범위는 ",(0,p.jsx)("b",{children:"4-50"}),"이며 QuadWork 기본값은 ",(0,p.jsx)("b",{children:"30"}),"입니다. 직접 채팅을 한 번 보내면 카운터는 즉시 초기화됩니다."]}),pauseAfter:"다음 횟수 후 일시정지:",hops:"홉",apply:"적용",applying:"…",applyTitle:"적용 (config.toml에 저장하고 AgentChattr에 실시간 반영)",errorInteger:"4에서 50 사이의 정수여야 합니다.",liveUpdateFailed:"config.toml에 저장되었습니다. 실시간 업데이트는 실패하여 다음 AC 재시작 때 적용됩니다.",autoContinue:"일시정지 후 자동 재개",wait:"—",secondsBefore:"초 대기 후 /continue"}};function l2({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l1[i],[s,n]=(0,_.useState)(30),[o,a]=(0,_.useState)("30"),[l,h]=(0,_.useState)(!1),[c,d]=(0,_.useState)(null),[u,f]=(0,_.useState)(null),[m,v]=(0,_.useState)(!1),[b,y]=(0,_.useState)(30),[S,w]=(0,_.useState)("30"),[C,k]=(0,_.useState)(!1);(0,_.useEffect)(()=>{fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&"number"==typeof e.value&&(n(e.value),a(String(e.value)))}).catch(()=>{}),fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);if(!r)return;v(!!r.auto_continue_loop_guard);let s=Number.isFinite(r.auto_continue_delay_sec)?r.auto_continue_delay_sec:30;y(s),w(String(s))}).catch(()=>{})},[e]);let E=async(i,r)=>{k(!0);try{let s=await fetch("/api/config");if(!s.ok)throw Error(`GET /api/config ${s.status}`);let n=await s.json();if(!n||!Array.isArray(n.projects))throw Error("config shape");let o=n.projects.findIndex(i=>i.id===e);if(o<0)throw Error(`project ${e} not found`);n.projects[o]={...n.projects[o],auto_continue_loop_guard:i,auto_continue_delay_sec:r};let a=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw Error(`PUT /api/config ${a.status}`)}finally{k(!1)}};return(0,p.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,p.jsx)("span",{className:"uppercase tracking-wider text-text-muted",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-text-muted",children:r.pauseAfter}),(0,p.jsx)("input",{type:"number",min:4,max:50,value:o,onChange:e=>a(e.target.value),disabled:l,className:"w-12 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.hops}),(0,p.jsx)("button",{type:"button",onClick:()=>{let i=parseInt(o,10);!Number.isInteger(i)||i<4||i>50?d(r.errorInteger):(h(!0),d(null),fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:i})}).then(async e=>{if(!e.ok){let i=await e.text().catch(()=>"");throw Error(`${e.status}: ${i.slice(0,120)}`)}return e.json()}).then(e=>{n(e.value),f(e.live)}).catch(e=>d(e.message||String(e))).finally(()=>h(!1)))},disabled:l||o===String(s),className:"ml-auto px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:r.applyTitle,children:l?r.applying:r.apply})]}),c&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:c}),!1===u&&!c&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:r.liveUpdateFailed}),(0,p.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:m,disabled:C,onChange:e=>{let i=e.target.checked;v(i),E(i,b).catch(()=>{v(!i)})}}),r.autoContinue,(0,p.jsx)("span",{className:"text-text-muted",children:r.wait}),(0,p.jsx)("input",{type:"number",min:5,max:300,value:S,disabled:C||!m,onChange:e=>w(e.target.value),onBlur:()=>{let e=parseInt(S,10),i=Number.isFinite(e)?Math.max(5,Math.min(300,e)):30;y(i),w(String(i)),i!==b&&E(m,i).catch(()=>{})},className:"w-10 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent disabled:opacity-40 text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.secondsBefore})]})]})}let l5={en:{title:"Project History",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Project History"})," — export or import the full AgentChattr chat history for this project. Useful for backup, migration, or resuming after a fresh install."]}),export:e=>`Export ${e} chat`,import:"Import history…",importing:"Importing…",autoRestore:"Auto-restore newest snapshot after AC restart",autoSnapshots:"Auto-snapshots (before restart)",restore:"Restore",restoreConfirm:e=>`Restore snapshot ${e}? This will replay every message through AgentChattr (tagged by the original sender) and may duplicate history already in the chat. Continue?`,importMismatchConfirm:(e,i)=>`This export is from project '${e}' but you're importing into '${i}'. Continue anyway?`,importReservedConfirm:e=>`This export contains messages attributed to reserved agent/system identities (${e}). Importing will replay them as those agents — only do this for a legitimate disaster-recovery restore. Continue?`,importDuplicateConfirm:e=>`${e}
29
+ ALL: Communicate via this chat by tagging agents. Your terminal is NOT visible.`},[e]),[B,I]=(0,m.useState)(!1),[O,F]=(0,m.useState)(!1),[z,H]=(0,m.useState)(null),$=(0,m.useRef)(null),W=(0,m.useRef)(!1);(0,m.useEffect)(()=>{W.current=!1,$.current=null,I(!1),F(!1),H(null)},[e]),(0,m.useEffect)(()=>{W.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.trigger_auto&&I(!0),W.current=!0}).catch(()=>{})},[e]);let U=(0,m.useCallback)(async()=>{try{let i=await fetch("/api/triggers");if(!i.ok)throw Error(`${i.status}`);let r=(await i.json())[e]||null;if(n(r),r){if(r.message&&!C.current&&(a(r.message),C.current=r.message),!k.current)if(r.enabled&&r.interval){let e=Math.max(1,Math.round(r.interval/6e4));h(e),d(String(e))}else"number"==typeof r.intervalMin&&r.intervalMin>0&&(h(r.intervalMin),d(String(r.intervalMin)));!E.current&&"number"==typeof r.durationMin&&r.durationMin>=0&&(f(r.durationMin),v(lV(r.durationMin)))}T(null)}catch(e){T(e.message)}},[e]);(0,m.useEffect)(()=>{o||a(A)},[A,o]),(0,m.useEffect)(()=>{U();let e=window.setInterval(U,5e3);return()=>window.clearInterval(e)},[U]),(0,m.useEffect)(()=>{if(!s?.enabled){M(""),L("");return}let e=()=>{if(s.nextAt&&M(lY(Math.max(0,s.nextAt-Date.now()))),s.expiresAt){let e=Math.max(0,s.expiresAt-Date.now());L(lY(e)),e<=0&&U()}else L("")};e();let i=window.setInterval(e,1e3);return()=>window.clearInterval(i)},[s?.enabled,s?.nextAt,s?.expiresAt,U]);let K=async()=>{R(!0),T(null);let i=parseFloat(_),r=Math.round(60*(Number.isFinite(i)?lq(i):3));r!==u&&(f(r),v(lV(r)));let s=parseInt(c,10),n=Number.isFinite(s)?Math.max(1,Math.min(1440,s)):15;n!==l&&(h(n),d(String(n)));try{let i=await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:n,duration:r,message:o})});if(!i.ok)throw Error(`${i.status}`);y(!1),w(!1),await U()}catch(e){T(e.message)}finally{R(!1)}},q=async()=>{R(!0),T(null);try{let i=await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"});if(!i.ok)throw Error(`${i.status}`);F(!1),n({...s||{interval:0,lastSent:null,nextAt:null,expiresAt:null,message:o,intervalMin:l,durationMin:u},enabled:!1}),await U()}catch(e){T(e.message)}finally{R(!1)}},V=(0,m.useCallback)(async()=>{let i=!B;I(i),i||(H(null),$.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.trigger_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[B,e]),Y=(0,m.useRef)(B),G=(0,m.useRef)(s);(0,m.useEffect)(()=>{Y.current=B},[B]),(0,m.useEffect)(()=>{G.current=s},[s]);let X=(0,m.useCallback)(async()=>{if(Y.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=$.current;if($.current={complete:s.complete,hasItems:n},!o){if(n&&!s.complete&&!G.current?.enabled){F(!0),H(null);let i=parseFloat(_),r=Number.isFinite(i)?lq(i):3,s=Math.round(60*r),n=parseInt(c,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:C.current||A})}),await U()}n&&s.complete&&G.current?.enabled&&(await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),F(!1),H(r.autoStopStatus),await U());return}if(n&&s.complete&&!o.complete&&G.current?.enabled){await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),F(!1),H(r.autoStopStatus),await U();return}if(n&&!s.complete&&(o.complete||!o.hasItems)&&!G.current?.enabled){F(!0),H(null);let i=parseFloat(_),r=Number.isFinite(i)?lq(i):3,s=Math.round(60*r),n=parseInt(c,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:C.current||A})}),await U()}}catch{}},[e,_,c,A,U,r.autoStopStatus]);(0,m.useEffect)(()=>{if(!B)return;X();let e=window.setInterval(X,3e4);return()=>window.clearInterval(e)},[B,X]);let J=!!s?.enabled;return(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.label(J,O)}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[j&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",j]}),(0,p.jsxs)("button",{type:"button",onClick:V,title:B?r.autoTriggerOn:r.autoTriggerOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${B?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[r.auto,B?"●":"○"]})]})]}),z&&(0,p.jsx)("div",{className:"px-3 py-1 text-[10px] text-accent bg-accent/5 border-b border-border/50",children:z}),J?(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:r.sending}),(0,p.jsx)("pre",{className:"text-[11px] font-mono whitespace-pre-wrap text-text bg-bg-surface border border-border p-2 max-h-28 overflow-auto",children:(s?.message||o).slice(0,400)}),(0,p.jsxs)("div",{className:"flex items-center gap-3 flex-wrap text-[11px]",children:[(0,p.jsxs)("span",{className:"flex items-center gap-1",children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:r.running})]}),(0,p.jsxs)("span",{className:"tabular-nums text-text",children:[r.next,D]}),P&&(0,p.jsxs)("span",{className:"tabular-nums text-text-muted",children:[r.stopsIn,P]}),!s?.expiresAt&&(0,p.jsx)("span",{className:"text-text-muted",children:r.untilStopped})]}),(0,p.jsx)("button",{onClick:q,disabled:N,className:"self-start px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:N?r.stopping:r.stopTrigger})]}):(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("label",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:r.message}),(0,p.jsx)("textarea",{value:o,onChange:e=>a(e.target.value),rows:6,spellCheck:!1,className:"w-full bg-bg text-text text-[11px] font-mono p-2 border border-border outline-none focus:border-accent resize-y"}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-[11px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:r.sendEvery}),(0,p.jsx)("input",{type:"number",value:c,onChange:e=>{d(e.target.value),y(!0)},onBlur:()=>{let e=parseInt(c,10),i=Number.isFinite(e)?Math.max(1,Math.min(1440,e)):15;h(i),d(String(i))},min:1,max:1440,className:"w-12 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.minFor}),(0,p.jsx)("input",{type:"number",value:_,onChange:e=>{v(e.target.value),w(!0)},onBlur:()=>{let e=parseFloat(_),i=Math.round(60*(Number.isFinite(e)?lq(e):3));f(i),v(lV(i))},min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.hours})]}),(0,p.jsx)("button",{onClick:K,disabled:N||!o.trim(),className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:N?r.starting:r.startTrigger})]})]})}function lX({open:e,initialChatId:i="",onClose:r,onSave:s}){let[n,o]=(0,m.useState)(""),[a,l]=(0,m.useState)(i),[h,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(null),[f,_]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{e&&l(i)},[e,i]),(0,m.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),a.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"telegram-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"telegram-setup-title",className:"text-base font-semibold text-white",children:"Set up your Telegram Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Telegram chat, so you can read and reply on your phone."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Telegram bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for ",(0,p.jsx)("b",{children:"@BotFather"}),"."]}),(0,p.jsxs)("li",{children:["Send ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"/newbot"})," and follow the prompts."]}),(0,p.jsxs)("li",{children:["Choose a name and username (must end in ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),")."]}),(0,p.jsxs)("li",{children:["BotFather replies with a ",(0,p.jsx)("b",{children:"bot token"})," that looks like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"123456:ABC-DEF1234ghIkl…"}),". Copy it."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Get your chat ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for your new bot by its exact ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"@username"}),"."]}),(0,p.jsxs)("li",{children:["Tap ",(0,p.jsx)("b",{children:"Start"})," and send any message (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"hello"}),")."," ",(0,p.jsxs)("span",{className:"text-neutral-400",children:["You must send at least one message first — ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," returns ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:'{"ok":true,"result":[]}'})," until Telegram has an inbound message on record."]})]}),(0,p.jsxs)("li",{children:["Open this URL in your browser (replace ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"YOUR_TOKEN"}),"):",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://api.telegram.org/botYOUR_TOKEN/getUpdates"})]}),(0,p.jsxs)("li",{children:["Look for ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:'"chat":{"id":<NUMBER>'})," in the JSON. That number is your ",(0,p.jsx)("b",{children:"chat id"}),". Group chat ids are negative (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"-1001234567890"}),") — paste the full value ",(0,p.jsx)("b",{children:"including the minus sign"}),"."]})]}),(0,p.jsx)("p",{className:"mt-1 text-neutral-400",children:"Or use one of these terminal one-liners:"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["With ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (cleanest):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"curl -s \"https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates\" | jq '.result[-1].message.chat.id'"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["Without ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (pure grep):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates" | grep -o \'"chat":{"id":-\\?[0-9]*\' | tail -1'}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["The first message from a brand-new bot sometimes doesn't propagate to ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," instantly. If ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"result"})," is empty, send 2-3 more messages and retry."]}),(0,p.jsx)("button",{type:"button",onClick:()=>_(e=>!e),className:"mt-2 text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Still empty? Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Webhook conflict."})," Something else may be consuming updates. Check and delete any active webhook:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getWebhookInfo" curl -s "https://api.telegram.org/bot<TOKEN>/deleteWebhook"'})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Stale bridge process."}),"A leftover bridge from a previous install will hold the update queue. Two consumers can't share one bot:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"ps aux | grep telegram_bridge | grep -v grep"}),"Kill any PIDs that show up before retrying the curl."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Token / bot mismatch."})," A token that doesn't match the bot you're messaging silently returns empty results. Confirm the token's ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"username"})," matches the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"@username"}),"you're chatting with:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getMe"'})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"123456:ABC-DEF…",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Chat id",(0,p.jsx)("input",{type:"text",value:a,onChange:e=>l(e.target.value),placeholder:"123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!a.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]})]})]})})}let lJ={en:{title:"Telegram Bridge",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Telegram Bridge"})," forwards AgentChattr messages to a Telegram bot so you can monitor from your phone. Bidirectional — replies from Telegram appear in chat."]}),autoOn:"Auto ON — bridge follows batch lifecycle",autoOff:"Auto OFF — manual start/stop only",notConfigured:"Not configured",setUp:"Set up Telegram Bridge",running:"Running",stopped:"Stopped",stop:"Stop",stopping:"Stopping…",start:"Start",starting:"Starting…",howToSetUp:"How to set up",editCredentials:"Edit credentials",dismiss:"dismiss",batchActive:"Batch active — auto-starting bridge.",batchComplete:"Batch complete — bridge paused. Waiting for next batch.",newBatch:"New batch detected — auto-starting bridge."},ko:{title:"텔레그램 브릿지",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"텔레그램 브릿지"})," - AgentChattr 메시지를 텔레그램 봇으로 전달해서 휴대폰에서 모니터링할 수 있게 합니다. 양방향이며 텔레그램에서 보낸 답장도 채팅에 나타납니다."]}),autoOn:"자동 모드 켬 — 브릿지가 배치 주기를 따릅니다",autoOff:"자동 모드 끔 — 수동 시작/중지만 가능",notConfigured:"설정되지 않음",setUp:"텔레그램 브릿지 설정",running:"실행 중",stopped:"중지됨",stop:"중지",stopping:"중지 중…",start:"시작",starting:"시작 중…",howToSetUp:"설정 방법",editCredentials:"인증 정보 수정",dismiss:"닫기",batchActive:"배치 실행 중 — 브릿지를 자동 시작합니다.",batchComplete:"배치 완료 — 브릿지를 일시 중단했습니다. 다음 배치를 기다리는 중.",newBatch:"새 배치 감지 — 브릿지를 자동 시작합니다."}};async function lQ(e,i){let r=await fetch(`/api/telegram?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function lZ({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=lJ[i],[s,n]=(0,m.useState)(null),[o,a]=(0,m.useState)(!1),[l,h]=(0,m.useState)(null),[c,d]=(0,m.useState)(null),[u,f]=(0,m.useState)(!1),[_,v]=(0,m.useState)(null),[b,y]=(0,m.useState)(!1),[S,w]=(0,m.useState)(null),C=(0,m.useRef)(b),k=(0,m.useRef)(!1);(0,m.useEffect)(()=>{C.current=b},[b]);let E=(0,m.useRef)(!1);(0,m.useEffect)(()=>{E.current=!1,y(!1),w(null)},[e]),(0,m.useEffect)(()=>{E.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.telegram_auto&&y(!0),E.current=!0}).catch(()=>{})},[e]);let N=(0,m.useCallback)(async()=>{try{let i=await fetch(`/api/telegram?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();n(r),d(null)}catch(e){d(e.message)}},[e]);(0,m.useEffect)(()=>{N();let e=window.setInterval(N,5e3);return()=>window.clearInterval(e)},[N]);let R=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?v(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.tg]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):v(null)},j=async()=>{a(!0),h(null);try{if(s&&!s.bridge_installed){let e=await lQ("install",{});R(e)}await lQ("start",{project_id:e}),await N()}catch(e){h(e.message)}finally{a(!1)}},T=async()=>{a(!0),h(null);try{await lQ("stop",{project_id:e}),await N()}catch(e){h(e.message)}finally{a(!1)}},D=async(i,r)=>{await lQ("save-config",{project_id:e,bot_token:i,chat_id:r});try{if(s&&!s.bridge_installed){let e=await lQ("install",{});R(e)}await lQ("start",{project_id:e})}catch(e){h(e.message)}await N()},M=(0,m.useCallback)(async()=>{let i=!b;y(i),i||(w(null),P.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.telegram_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[b,e]),P=(0,m.useRef)(null),L=(0,m.useCallback)(async()=>{if(C.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=P.current;if(P.current={complete:s.complete,hasItems:n},!o){!n||s.complete||k.current||(w(r.batchActive),await lQ("start",{project_id:e}).catch(()=>{}),await N()),n&&s.complete&&k.current&&(w(r.batchComplete),h(null),await lQ("stop",{project_id:e}).catch(()=>{}),await N());return}if(n&&s.complete&&!o.complete&&k.current){w(r.batchComplete),h(null),await lQ("stop",{project_id:e}).catch(()=>{}),await N();return}!n||s.complete||!o.complete&&o.hasItems||k.current||(w(r.newBatch),await lQ("start",{project_id:e}).catch(()=>{}),await N())}catch{}},[e,N,r]);(0,m.useEffect)(()=>{if(!b)return;L();let e=window.setInterval(L,3e4);return()=>window.clearInterval(e)},[b,L]);let A=!!s?.configured,B=!!s?.running;(0,m.useEffect)(()=>{k.current=B},[B]);let I=!B&&!!S,O=l||c||!B&&!I&&s?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[A&&(0,p.jsxs)("button",{type:"button",onClick:M,title:b?r.autoOn:r.autoOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${b?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",b?"●":"○"]}),O&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[A?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[B?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:r.running})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.stopped})]}),s?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: @",s.bot_username]}),s?.chat_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Chat: ",s.chat_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[B?(0,p.jsx)("button",{onClick:T,disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:o?r.stopping:r.stop}):(0,p.jsx)("button",{onClick:j,disabled:o,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:o?r.starting:r.start}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.howToSetUp}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.editCredentials})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:r.notConfigured})]}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:r.setUp})]}),_&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[_,(0,p.jsx)("button",{type:"button",onClick:()=>v(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]}),S&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-accent",children:S}),O&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[O,l&&(0,p.jsx)("button",{type:"button",onClick:()=>h(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]})]})]}),(0,p.jsx)(lX,{open:u,initialChatId:s?.chat_id||"",onClose:()=>f(!1),onSave:D})]})}function l0({open:e,initialChannelId:i="",onClose:r,onSave:s}){let[n,o]=(0,m.useState)(""),[a,l]=(0,m.useState)(i),[h,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(null),[f,_]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{e&&l(i)},[e,i]),(0,m.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),a.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"discord-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"discord-setup-title",className:"text-base font-semibold text-white",children:"Set up your Discord Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Discord channel, so you can read and reply from Discord."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Discord Application + Bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Discord Developer Portal"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"New Application"}),' → name it (e.g. "QuadWork") → ',(0,p.jsx)("b",{children:"Create"}),"."]}),(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"Bot"})," tab in the left sidebar."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Reset Token"})," → copy the bot token. Save it somewhere safe."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Enable MESSAGE_CONTENT intent (critical)"}),(0,p.jsxs)("div",{className:"mt-1.5 rounded border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,p.jsxs)("div",{className:"flex items-start gap-2",children:[(0,p.jsx)("span",{className:"text-amber-400 text-[16px] leading-none shrink-0",children:"⚠"}),(0,p.jsxs)("div",{className:"text-[12px] text-amber-200/90 leading-relaxed",children:[(0,p.jsx)("b",{className:"text-amber-300",children:"This step is required."}),"Without it, the bot connects successfully but receives empty message content — no error, no warning, just silent empty messages. This is the #1 cause of Discord bot setup issues."]})]}),(0,p.jsxs)("ol",{className:"mt-2 pl-6 list-decimal space-y-0.5 text-neutral-300 text-[12px]",children:[(0,p.jsxs)("li",{children:["On the same ",(0,p.jsx)("b",{children:"Bot"})," tab, scroll down to ",(0,p.jsx)("b",{children:"Privileged Gateway Intents"}),"."]}),(0,p.jsxs)("li",{children:["Toggle ",(0,p.jsx)("b",{children:"ON"}),": ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"MESSAGE CONTENT INTENT"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Save Changes"}),"."]})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Invite the bot to your server"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"OAuth2"})," tab → ",(0,p.jsx)("b",{children:"URL Generator"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Scopes"}),", check ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Bot Permissions"}),", check:",(0,p.jsxs)("ul",{className:"mt-0.5 pl-4 list-disc text-neutral-400",children:[(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Send Messages"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Read Message History"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"View Channels"})})]})]}),(0,p.jsxs)("li",{children:["Copy the generated URL at the bottom. It will look like:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&permissions=66560&scope=bot"})]}),(0,p.jsxs)("li",{children:["Open it in your browser → select your Discord server → ",(0,p.jsx)("b",{children:"Authorize"}),"."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 4 — Get your channel ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["In Discord, go to ",(0,p.jsx)("b",{children:"User Settings"})," → ",(0,p.jsx)("b",{children:"Advanced"})," → enable ",(0,p.jsx)("b",{children:"Developer Mode"}),"."]}),(0,p.jsxs)("li",{children:["Right-click the channel you want to bridge → ",(0,p.jsx)("b",{children:"Copy Channel ID"}),"."]})]}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["Channel IDs are large numbers like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"1234567890123456789"}),"."]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 5 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"MTIzNDU2Nzg5MDEyMzQ1Njc4OQ...",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Channel ID",(0,p.jsx)("input",{type:"text",value:a,onChange:e=>l(e.target.value),placeholder:"1234567890123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!a.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("button",{type:"button",onClick:()=>_(e=>!e),className:"text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot connects but messages are empty."})," ","MESSAGE_CONTENT intent is not enabled. Go back to Step 2 — toggle it on in the Developer Portal under Bot → Privileged Gateway Intents, then restart the bridge."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot can't see the channel."})," ","The bot wasn't invited to the server (Step 3) or it lacks the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"View Channels"}),"permission for that specific channel. Check your server's role permissions."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:'"Disallowed intents" error in logs.'})," ","MESSAGE_CONTENT intent is not toggled in the Developer Portal. This is different from not requesting it in code — the portal toggle is the gatekeeper."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Rate limited."})," ","Normal for high-traffic channels. ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"discord.py"})," handles backoff automatically. If persistent, increase the AC poll interval in the bridge config."]})]})]})]})]})})}let l1={en:{title:"Discord Bridge",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Discord Bridge"})," forwards AgentChattr messages to a Discord channel so you can monitor from Discord. Bidirectional — replies from Discord appear in chat."]}),autoOn:"Auto ON — bridge follows batch lifecycle",autoOff:"Auto OFF — manual start/stop only",notConfigured:"Not configured",setUp:"Set up Discord Bridge",running:"Running",stopped:"Stopped",stop:"Stop",stopping:"Stopping…",start:"Start",starting:"Starting…",howToSetUp:"How to set up",editCredentials:"Edit credentials",dismiss:"dismiss",batchActive:"Batch active — auto-starting bridge.",batchComplete:"Batch complete — bridge paused. Waiting for next batch.",newBatch:"New batch detected — auto-starting bridge."},ko:{title:"디스코드 브릿지",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"디스코드 브릿지"})," - AgentChattr 메시지를 디스코드 채널로 전달해서 디스코드에서 모니터링할 수 있게 합니다. 양방향이며 디스코드에서 보낸 답장도 채팅에 나타납니다."]}),autoOn:"자동 모드 켬 — 브릿지가 배치 주기를 따릅니다",autoOff:"자동 모드 끔 — 수동 시작/중지만 가능",notConfigured:"설정되지 않음",setUp:"디스코드 브릿지 설정",running:"실행 중",stopped:"중지됨",stop:"중지",stopping:"중지 중…",start:"시작",starting:"시작 중…",howToSetUp:"설정 방법",editCredentials:"인증 정보 수정",dismiss:"닫기",batchActive:"배치 실행 중 — 브릿지를 자동 시작합니다.",batchComplete:"배치 완료 — 브릿지를 일시 중단했습니다. 다음 배치를 기다리는 중.",newBatch:"새 배치 감지 — 브릿지를 자동 시작합니다."}};async function l2(e,i){let r=await fetch(`/api/discord?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function l5({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l1[i],[s,n]=(0,m.useState)(null),[o,a]=(0,m.useState)(!1),[l,h]=(0,m.useState)(null),[c,d]=(0,m.useState)(null),[u,f]=(0,m.useState)(!1),[_,v]=(0,m.useState)(null),[b,y]=(0,m.useState)(!1),[S,w]=(0,m.useState)(null),C=(0,m.useRef)(null),k=(0,m.useRef)(b),E=(0,m.useRef)(!1);(0,m.useEffect)(()=>{k.current=b},[b]);let N=(0,m.useRef)(!1);(0,m.useEffect)(()=>{N.current=!1,C.current=null,y(!1),w(null)},[e]),(0,m.useEffect)(()=>{N.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.discord_auto&&y(!0),N.current=!0}).catch(()=>{})},[e]);let R=(0,m.useCallback)(async()=>{try{let i=await fetch(`/api/discord?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();n(r),d(null)}catch(e){d(e.message)}},[e]);(0,m.useEffect)(()=>{R();let e=window.setInterval(R,5e3);return()=>window.clearInterval(e)},[R]);let j=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?v(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.dc]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):v(null)},T=async()=>{a(!0),h(null);try{if(s&&!s.bridge_installed){let e=await l2("install",{});j(e)}await l2("start",{project_id:e}),await R()}catch(e){h(e.message)}finally{a(!1)}},D=async()=>{a(!0),h(null);try{await l2("stop",{project_id:e}),await R()}catch(e){h(e.message)}finally{a(!1)}},M=async(i,r)=>{await l2("save-config",{project_id:e,bot_token:i,channel_id:r});try{if(s&&!s.bridge_installed){let e=await l2("install",{});j(e)}await l2("start",{project_id:e})}catch(e){h(e.message)}await R()},P=(0,m.useCallback)(async()=>{let i=!b;y(i),i||(w(null),C.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.discord_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[b,e]),L=(0,m.useCallback)(async()=>{if(k.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let s=await i.json(),n=s.items.length>0,o=C.current;if(C.current={complete:s.complete,hasItems:n},!o){!n||s.complete||E.current||(w(r.batchActive),await l2("start",{project_id:e}).catch(()=>{}),await R()),n&&s.complete&&E.current&&(w(r.batchComplete),h(null),await l2("stop",{project_id:e}).catch(()=>{}),await R());return}if(n&&s.complete&&!o.complete&&E.current){w(r.batchComplete),h(null),await l2("stop",{project_id:e}).catch(()=>{}),await R();return}!n||s.complete||!o.complete&&o.hasItems||E.current||(w(r.newBatch),await l2("start",{project_id:e}).catch(()=>{}),await R())}catch{}},[e,R,r]);(0,m.useEffect)(()=>{if(!b)return;L();let e=window.setInterval(L,3e4);return()=>window.clearInterval(e)},[b,L]);let A=!!s?.configured,B=!!s?.running;(0,m.useEffect)(()=>{E.current=B},[B]);let I=!B&&!!S,O=l||c||!B&&!I&&s?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[A&&(0,p.jsxs)("button",{type:"button",onClick:P,title:b?r.autoOn:r.autoOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${b?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",b?"●":"○"]}),O&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[A?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[B?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:r.running})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.stopped})]}),s?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: ",s.bot_username]}),s?.channel_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Channel: ",s.channel_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[B?(0,p.jsx)("button",{onClick:D,disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:o?r.stopping:r.stop}):(0,p.jsx)("button",{onClick:T,disabled:o,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:o?r.starting:r.start}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.howToSetUp}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:r.editCredentials})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:r.notConfigured})]}),(0,p.jsx)("button",{onClick:()=>f(!0),disabled:o,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:r.setUp})]}),_&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[_,(0,p.jsx)("button",{type:"button",onClick:()=>v(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]}),S&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-accent",children:S}),O&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[O,l&&(0,p.jsx)("button",{type:"button",onClick:()=>h(null),className:"block mt-1 text-text-muted hover:text-text underline",children:r.dismiss})]})]})]}),(0,p.jsx)(l0,{open:u,initialChannelId:s?.channel_id||"",onClose:()=>f(!1),onSave:M})]})}let l3={en:{title:"Loop Guard",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Loop Guard"})," pauses agent-to-agent message chains after this many hops with no human reply. Higher values let agents work longer overnight; lower values add safety against runaway loops. AgentChattr accepts ",(0,p.jsx)("b",{children:"4–50"}),"; QuadWork defaults to ",(0,p.jsx)("b",{children:"30"})," (about 5–6 full PR cycles). Posting any chat message yourself resets the counter immediately."]}),pauseAfter:"Pause after",hops:"hops",apply:"Apply",applying:"…",applyTitle:"Apply (writes config.toml + live-pushes to AgentChattr)",errorInteger:"Must be an integer between 4 and 50.",liveUpdateFailed:"Saved to config.toml — live update failed; takes effect on next AC restart.",autoContinue:"Auto-continue after pause",wait:"— wait",secondsBefore:"s before /continue"},ko:{title:"루프 가드",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"루프 가드"})," - 사람의 응답 없이 에이전트끼리 메시지를 주고받는 횟수가 이 값에 도달하면 체인을 멈춥니다. 값을 높이면 야간 작업을 더 길게 돌릴 수 있고, 낮추면 runaway loop에 대한 안전성이 높아집니다. AgentChattr 허용 범위는 ",(0,p.jsx)("b",{children:"4-50"}),"이며 QuadWork 기본값은 ",(0,p.jsx)("b",{children:"30"}),"입니다. 직접 채팅을 한 번 보내면 카운터는 즉시 초기화됩니다."]}),pauseAfter:"다음 횟수 후 일시정지:",hops:"홉",apply:"적용",applying:"…",applyTitle:"적용 (config.toml에 저장하고 AgentChattr에 실시간 반영)",errorInteger:"4에서 50 사이의 정수여야 합니다.",liveUpdateFailed:"config.toml에 저장되었습니다. 실시간 업데이트는 실패하여 다음 AC 재시작 때 적용됩니다.",autoContinue:"일시정지 후 자동 재개",wait:"—",secondsBefore:"초 대기 후 /continue"}};function l4({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l3[i],[s,n]=(0,m.useState)(30),[o,a]=(0,m.useState)("30"),[l,h]=(0,m.useState)(!1),[c,d]=(0,m.useState)(null),[u,f]=(0,m.useState)(null),[_,v]=(0,m.useState)(!1),[b,y]=(0,m.useState)(30),[S,w]=(0,m.useState)("30"),[C,k]=(0,m.useState)(!1);(0,m.useEffect)(()=>{fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&"number"==typeof e.value&&(n(e.value),a(String(e.value)))}).catch(()=>{}),fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);if(!r)return;v(!!r.auto_continue_loop_guard);let s=Number.isFinite(r.auto_continue_delay_sec)?r.auto_continue_delay_sec:30;y(s),w(String(s))}).catch(()=>{})},[e]);let E=async(i,r)=>{k(!0);try{let s=await fetch("/api/config");if(!s.ok)throw Error(`GET /api/config ${s.status}`);let n=await s.json();if(!n||!Array.isArray(n.projects))throw Error("config shape");let o=n.projects.findIndex(i=>i.id===e);if(o<0)throw Error(`project ${e} not found`);n.projects[o]={...n.projects[o],auto_continue_loop_guard:i,auto_continue_delay_sec:r};let a=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw Error(`PUT /api/config ${a.status}`)}finally{k(!1)}};return(0,p.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,p.jsx)("span",{className:"uppercase tracking-wider text-text-muted",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-text-muted",children:r.pauseAfter}),(0,p.jsx)("input",{type:"number",min:4,max:50,value:o,onChange:e=>a(e.target.value),disabled:l,className:"w-12 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.hops}),(0,p.jsx)("button",{type:"button",onClick:()=>{let i=parseInt(o,10);!Number.isInteger(i)||i<4||i>50?d(r.errorInteger):(h(!0),d(null),fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:i})}).then(async e=>{if(!e.ok){let i=await e.text().catch(()=>"");throw Error(`${e.status}: ${i.slice(0,120)}`)}return e.json()}).then(e=>{n(e.value),f(e.live)}).catch(e=>d(e.message||String(e))).finally(()=>h(!1)))},disabled:l||o===String(s),className:"ml-auto px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:r.applyTitle,children:l?r.applying:r.apply})]}),c&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:c}),!1===u&&!c&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:r.liveUpdateFailed}),(0,p.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:_,disabled:C,onChange:e=>{let i=e.target.checked;v(i),E(i,b).catch(()=>{v(!i)})}}),r.autoContinue,(0,p.jsx)("span",{className:"text-text-muted",children:r.wait}),(0,p.jsx)("input",{type:"number",min:5,max:300,value:S,disabled:C||!_,onChange:e=>w(e.target.value),onBlur:()=>{let e=parseInt(S,10),i=Number.isFinite(e)?Math.max(5,Math.min(300,e)):30;y(i),w(String(i)),i!==b&&E(_,i).catch(()=>{})},className:"w-10 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent disabled:opacity-40 text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:r.secondsBefore})]})]})}let l6={en:{title:"Project History",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Project History"})," — export or import the full AgentChattr chat history for this project. Useful for backup, migration, or resuming after a fresh install."]}),export:e=>`Export ${e} chat`,import:"Import history…",importing:"Importing…",autoRestore:"Auto-restore newest snapshot after AC restart",autoSnapshots:"Auto-snapshots (before restart)",restore:"Restore",restoreConfirm:e=>`Restore snapshot ${e}? This will replay every message through AgentChattr (tagged by the original sender) and may duplicate history already in the chat. Continue?`,importMismatchConfirm:(e,i)=>`This export is from project '${e}' but you're importing into '${i}'. Continue anyway?`,importReservedConfirm:e=>`This export contains messages attributed to reserved agent/system identities (${e}). Importing will replay them as those agents — only do this for a legitimate disaster-recovery restore. Continue?`,importDuplicateConfirm:e=>`${e}
26
30
 
27
31
  This file looks like it was already imported. Re-import will duplicate every message. Continue anyway?`,importStatus:(e,i,r,s)=>(0,p.jsxs)(p.Fragment,{children:["Imported ",e," / ",i,r>0&&` \xb7 skipped ${r}`,s>0&&` \xb7 ${s} errors`]})},ko:{title:"프로젝트 히스토리",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"프로젝트 히스토리"})," - 이 프로젝트의 전체 AgentChattr 채팅 기록을 내보내거나 가져옵니다. 백업, 마이그레이션, 재설치 후 복구에 유용합니다."]}),export:e=>`${e} 채팅 내보내기`,import:"히스토리 가져오기…",importing:"가져오는 중…",autoRestore:"AC 재시작 후 최신 스냅샷 자동 복구",autoSnapshots:"자동 스냅샷 (재시작 전)",restore:"복구",restoreConfirm:e=>`스냅샷 ${e}을(를) 복구할까요? 모든 메시지가 AgentChattr를 통해 재생되며(원본 발신자 표시), 채팅에 이미 있는 내용이 중복될 수 있습니다. 계속하시겠습니까?`,importMismatchConfirm:(e,i)=>`이 내보내기 파일은 '${e}' 프로젝트에서 생성되었지만, 현재 '${i}' 프로젝트로 가져오려 합니다. 계속하시겠습니까?`,importReservedConfirm:e=>`이 파일에는 예약된 에이전트/시스템 식별자(${e})가 발신자로 표시된 메시지가 포함되어 있습니다. 가져오기를 진행하면 해당 에이전트가 말하는 것처럼 메시지가 재생됩니다. 재난 복구 상황에서만 사용하세요. 계속하시겠습니까?`,importDuplicateConfirm:e=>`${e}
28
32
 
29
- 이 파일은 이미 가져온 것 같습니다. 다시 가져오면 모든 메시지가 중복됩니다. 계속하시겠습니까?`,importStatus:(e,i,r,s)=>(0,p.jsxs)(p.Fragment,{children:["가져옴: ",e," / ",i,r>0&&` \xb7 건너뜀 ${r}`,s>0&&` \xb7 오류 ${s}`]})}};function l3({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l5[i],s=(0,_.useRef)(null),[n,o]=(0,_.useState)(null),[a,l]=(0,_.useState)(null),[h,c]=(0,_.useState)(null),[d,u]=(0,_.useState)([]),[f,m]=(0,_.useState)(!1),[v,b]=(0,_.useState)(!1);(0,_.useEffect)(()=>{fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);r&&m(!!r.auto_restore_after_restart)}).catch(()=>{})},[e]);let y=async i=>{b(!0);try{let r=await fetch("/api/config");if(!r.ok)throw Error(`GET /api/config ${r.status}`);let s=await r.json(),n=s.projects?.findIndex(i=>i.id===e)??-1;if(n<0)throw Error("project not found");s.projects[n]={...s.projects[n],auto_restore_after_restart:i};let o=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw Error(`PUT /api/config ${o.status}`)}finally{b(!1)}},S=()=>{fetch(`/api/project-history/snapshots?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&Array.isArray(e.snapshots)&&u(e.snapshots)}).catch(()=>{})};(0,_.useEffect)(()=>{S();let e=setInterval(S,15e3);return()=>clearInterval(e)},[e]);let w=async i=>{if(window.confirm(r.restoreConfirm(i))){o("restore"),l(null),c(null);try{let r=await fetch(`/api/project-history/restore?project=${encodeURIComponent(e)}&name=${encodeURIComponent(i)}`,{method:"POST"}),s=await r.json().catch(()=>null);if(!r.ok)throw Error(s&&s.error||`HTTP ${r.status}`);s&&"number"==typeof s.imported&&c(s)}catch(e){l(e.message||String(e))}finally{o(null),S()}}},C=async()=>{o("export"),l(null),c(null);try{let i=await fetch(`/api/project-history?project=${encodeURIComponent(e)}`);if(!i.ok){let e=await i.text().catch(()=>"");throw Error(`HTTP ${i.status}: ${e.slice(0,200)}`)}let r=await i.blob(),s=URL.createObjectURL(r),n=document.createElement("a"),o=new Date().toISOString().slice(0,10);n.href=s,n.download=`${e}-history-${o}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}catch(e){l(e.message||String(e))}finally{o(null)}},k=async i=>{let n;if(i.size>0xa00000)return void l(`File too large (${i.size} bytes; limit 10485760)`);o("import"),l(null),c(null);try{let e=await i.text();n=JSON.parse(e)}catch(e){o(null),l(`Invalid JSON: ${e.message||String(e)}`);return}if(!n||"object"!=typeof n||!Array.isArray(n.messages)){o(null),l("File missing 'messages' array");return}let a=!1;if(n.project_id&&n.project_id!==e){if(!window.confirm(r.importMismatchConfirm(n.project_id,e)))return void o(null);a=!0}let h=new Set(["head","dev","reviewer1","reviewer2","re1","re2","t1","t2a","t2b","t3","system"]),d=!1,u=new Set;for(let e of n.messages)if(e&&"object"==typeof e){let i=e.sender;if("string"==typeof i&&h.has(i.toLowerCase())&&(u.add(i),u.size>=5))break}if(u.size>0){if(!window.confirm(r.importReservedConfirm([...u].join(", "))))return void o(null);d=!0}let f=!1,p=i=>fetch(`/api/project-history?project=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,allow_project_mismatch:a,allow_agent_senders:d,allow_duplicate:f,...i})});try{let e=await p({}),i=await e.json().catch(()=>null);if(409===e.status&&i&&"string"==typeof i.error&&/already imported/i.test(i.error)){if(!window.confirm(r.importDuplicateConfirm(i.error)))return void o(null);f=!0,e=await p({allow_duplicate:!0}),i=await e.json().catch(()=>null)}if(!e.ok)throw Error(i&&i.error||`HTTP ${e.status}`);c(i)}catch(e){l(e.message||String(e))}finally{o(null),s.current&&(s.current.value="")}};return(0,p.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted uppercase tracking-wider mb-1.5",children:[r.title,(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("button",{type:"button",onClick:C,disabled:null!==n,className:"px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Download a JSON snapshot of this project's chat history",children:"export"===n?"…":r.export(e)}),(0,p.jsx)("button",{type:"button",onClick:()=>{l(null),c(null),s.current?.click()},disabled:null!==n,className:"px-2 py-0.5 text-[10px] text-text-muted border border-border rounded hover:text-text hover:border-accent transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Restore a previously exported chat history (JSON)",children:"import"===n?r.importing:r.import}),(0,p.jsx)("input",{ref:s,type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let i=e.target.files&&e.target.files[0];i&&k(i)}})]}),a&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:a}),h&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:r.importStatus(h.imported,h.total,h.skipped,h.errors.length)}),(0,p.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:f,disabled:v,onChange:e=>{let i=e.target.checked;m(i),y(i).catch(()=>m(!i))}}),r.autoRestore]}),d.length>0&&(0,p.jsxs)("div",{className:"mt-2 border-t border-border/50 pt-1.5",children:[(0,p.jsx)("div",{className:"text-[9px] text-text-muted uppercase tracking-wider mb-0.5",children:r.autoSnapshots}),d.map(e=>{let i=new Date(e.mtime).toLocaleString();return(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] py-0.5",children:[(0,p.jsx)("span",{className:"text-text-muted tabular-nums flex-1 truncate",title:e.name,children:i}),(0,p.jsxs)("span",{className:"text-text-muted tabular-nums shrink-0",children:[Math.round(e.size/1024),"KB"]}),(0,p.jsx)("button",{type:"button",onClick:()=>w(e.name),disabled:null!==n,className:"px-1.5 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:`Restore ${e.name}`,children:"restore"===n?"…":r.restore})]},e.name)})]})]})}let l4={en:{title:"Agent Models",loading:"Loading…",noAgents:"No agents configured.",restartRequired:"restart required",restartRequiredTooltip:"Config changed — running session is still on the old model/effort. Click Restart to apply.",default:"(default)",custom:"(custom)",restart:"Restart",restartTooltip:"Restart this agent to pick up the new model / reasoning setting",help:(0,p.jsxs)(p.Fragment,{children:["Codex reasoning effort defaults to ",(0,p.jsx)("code",{className:"text-text",children:"medium"})," for new projects. Blank model falls back to the CLI default. Click Restart to apply changes to a live session."]}),summary:(e,i)=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"text-text",children:e}),(0,p.jsxs)("span",{children:[": ",i]})]}),configure:"Configure →",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Agent Models"})," — configure which LLM model and reasoning effort each agent uses. Changes require an agent restart to take effect."]})},ko:{title:"에이전트 모델",loading:"로딩 중…",noAgents:"설정된 에이전트가 없습니다.",restartRequired:"재시작 필요",restartRequiredTooltip:"설정이 변경되었습니다. 실행 중인 세션에는 이전 설정이 적용되어 있습니다. 재시작을 클릭하여 적용하세요.",default:"(기본값)",custom:"(사용자 정의)",restart:"재시작",restartTooltip:"에이전트를 재시작하여 새로운 모델/추론 설정을 적용합니다",help:(0,p.jsxs)(p.Fragment,{children:["Codex 추론 수준은 새 프로젝트의 경우 ",(0,p.jsx)("code",{className:"text-text",children:"medium"}),"으로 기본 설정됩니다. 모델을 비워두면 CLI 기본값이 사용됩니다. 변경 사항을 적용하려면 재시작을 클릭하세요."]}),summary:(e,i)=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"text-text",children:e}),(0,p.jsxs)("span",{children:[": ",i]})]}),configure:"설정 →",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"에이전트 모델"})," - 각 에이전트가 어떤 LLM 모델과 추론 수준을 사용할지 설정합니다. 변경 사항은 에이전트를 재시작해야 적용됩니다."]})}},l6=["minimal","low","medium","high"],l9={codex:[{value:"",label:"(CLI default)"},{value:"gpt-5.4",label:"gpt-5.4"},{value:"gpt-5",label:"gpt-5"},{value:"gpt-4o",label:"gpt-4o"}],claude:[{value:"",label:"(CLI default)"},{value:"claude-opus-4-7",label:"claude-opus-4-7"},{value:"claude-opus-4-6",label:"claude-opus-4-6"},{value:"claude-sonnet-4-6",label:"claude-sonnet-4-6"},{value:"claude-haiku-4-5-20251001",label:"claude-haiku-4-5"}]};function l8(e){return l9[e]||[{value:"",label:"(CLI default)"}]}function l7({projectId:e,onClose:i}){let{locale:r}=(0,x.useLocale)(),s=l4[r],[n,o]=(0,_.useState)(null),[a,l]=(0,_.useState)(null),[h,c]=(0,_.useState)(null),[d,u]=(0,_.useState)(new Set),f=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/project/${encodeURIComponent(e)}/agent-models`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();o(r.agents||[]),l(null)}catch(e){l(e.message)}},[e]);(0,_.useEffect)(()=>{f()},[f]),(0,_.useEffect)(()=>{let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]);let m=async(i,r)=>{c(i),l(null);try{let s=await fetch(`/api/project/${encodeURIComponent(e)}/agent-models/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await s.json();if(!s.ok||!1===n.ok)throw Error(n.error||`${s.status}`);u(e=>{let r=new Set(e);return r.add(i),r}),await f()}catch(e){l(e.message)}finally{c(null)}},g=async i=>{c(i),l(null);try{let r=await fetch(`/api/agents/${encodeURIComponent(e)}/${encodeURIComponent(i)}/restart`,{method:"POST"}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);u(e=>{let r=new Set(e);return r.delete(i),r})}catch(e){l(e.message)}finally{c(null)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:i,role:"dialog","aria-modal":"true","aria-labelledby":"agent-models-title",children:(0,p.jsxs)("div",{className:"relative mx-4 w-full max-w-[520px] max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:i,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,p.jsx)("h2",{id:"agent-models-title",className:"text-base font-semibold text-white",children:s.title}),a&&(0,p.jsxs)("span",{className:"text-[10px] text-error max-w-[60%] truncate ml-2",title:a,children:["err: ",a]})]}),(0,p.jsxs)("div",{className:"flex flex-col gap-1.5",children:[!n&&(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:s.loading}),n&&0===n.length&&(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:s.noAgents}),n&&n.map(e=>(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("span",{className:"text-[11px] text-text font-semibold w-16 shrink-0",children:e.agent_id}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted w-12 shrink-0",children:e.backend}),d.has(e.agent_id)&&(0,p.jsx)("span",{className:"text-[9px] text-[#ffcc00] border border-[#ffcc00]/40 px-1 py-[1px] shrink-0",title:s.restartRequiredTooltip,children:s.restartRequired}),(0,p.jsxs)("select",{value:e.model,disabled:h===e.agent_id,onChange:i=>m(e.agent_id,{model:i.target.value}),className:"flex-1 min-w-[140px] bg-transparent border border-border px-1 py-0.5 text-[11px] font-mono text-text outline-none focus:border-accent cursor-pointer disabled:opacity-50",children:[l8(e.backend).map(e=>(0,p.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value)),e.model&&!l8(e.backend).some(i=>i.value===e.model)&&(0,p.jsxs)("option",{value:e.model,className:"bg-bg-surface",children:[e.model," ",s.custom]})]}),e.reasoning_supported?(0,p.jsxs)("select",{value:e.reasoning_effort||"",disabled:h===e.agent_id,onChange:i=>m(e.agent_id,{reasoning_effort:i.target.value}),className:"bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent cursor-pointer disabled:opacity-50",children:[(0,p.jsx)("option",{value:"",className:"bg-bg-surface",children:s.default}),l6.map(e=>(0,p.jsx)("option",{value:e,className:"bg-bg-surface",children:e},e))]}):(0,p.jsx)("span",{className:"text-[10px] text-text-muted w-16 text-center",children:"—"}),(0,p.jsx)("button",{type:"button",onClick:()=>g(e.agent_id),disabled:h===e.agent_id,title:s.restartTooltip,className:"shrink-0 px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 disabled:opacity-50 transition-colors",children:h===e.agent_id?"…":s.restart})]},e.agent_id)),(0,p.jsx)("p",{className:"mt-2 text-[10px] text-text-muted leading-snug",children:s.help})]})]})})}function he({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l4[i],[s,n]=(0,_.useState)(!1),[o,a]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let i=!1;return fetch(`/api/project/${encodeURIComponent(e)}/agent-models`).then(e=>e.ok?e.json():null).then(e=>{i||!e||a((e.agents||[]).map(e=>({id:e.agent_id,backend:e.backend})))}).catch(()=>{}),()=>{i=!0}},[e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsx)("button",{type:"button",onClick:()=>n(!0),className:"px-2 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors",children:r.configure})]}),o&&o.length>0&&(0,p.jsx)("div",{className:"px-3 py-1 text-[10px] text-text-muted truncate",title:o.map(e=>`${e.id}: ${e.backend}`).join(" · "),children:o.map((e,i)=>(0,p.jsxs)("span",{children:[i>0&&(0,p.jsx)("span",{className:"text-text-muted/60",children:" · "}),r.summary(e.id,e.backend)]},e.id))})]}),s&&(0,p.jsx)(l7,{projectId:e,onClose:()=>n(!1)})]})}let ht={en:{label:"Operator Features",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Operator Features"})," — tools for running autonomous overnight batches. Includes the Scheduled Trigger, Telegram Bridge, Discord Bridge, Loop Guard, Project History, and Agent Models."]})},ko:{label:"운영자 기능",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"운영자 기능"})," - 야간 자율 배치를 운영할 때 쓰는 도구 모음입니다. Scheduled Trigger, Telegram Bridge, Discord Bridge, Loop Guard, Project History, Agent Models가 포함됩니다."]})}};function hi({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=ht[i];return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,p.jsx)(m,{label:r.label,tooltip:(0,p.jsx)(g,{children:r.tooltip})}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row gap-2 p-2 overflow-auto lg:overflow-hidden",children:[(0,p.jsx)("div",{className:"lg:flex-1 lg:min-w-[280px] lg:min-h-0",children:(0,p.jsx)(lq,{projectId:e})}),(0,p.jsx)("div",{className:"hidden lg:block w-px self-stretch bg-border"}),(0,p.jsxs)("div",{className:"lg:flex-1 lg:min-h-0 lg:overflow-y-auto flex flex-col gap-2",children:[(0,p.jsx)(he,{projectId:e}),(0,p.jsx)(lX,{projectId:e}),(0,p.jsx)(l0,{projectId:e}),(0,p.jsx)(l2,{projectId:e}),(0,p.jsx)(l3,{projectId:e})]})]})]})}let hr={en:{filterAgentsTitle:"Showing agent messages only — click to show all",filterAllTitle:"Showing all messages — click to hide system/status noise",filterOn:"Filter system log: on",filterOff:"Filter system log: off",chatLabel:"AgentChattr — primary chat",chatTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Primary Chat"})," — live chat between you and the 4 AI agents. Messages you type here trigger agent actions. Use @mentions to address specific agents."]}),githubLabel:"GitHub",githubTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"GitHub"}),"— open issues and pull requests on this project's repo. Click any item to open it on GitHub. The batch progress panel tracks the active batch's lifecycle from queued to merged."]})},ko:{filterAgentsTitle:"에이전트 메시지만 표시 중 - 클릭하면 전체를 표시합니다",filterAllTitle:"전체 메시지 표시 중 - 클릭하면 시스템/상태 로그를 숨깁니다",filterOn:"시스템 로그 필터: 켜짐",filterOff:"시스템 로그 필터: 꺼짐",chatLabel:"AgentChattr — 메인 채팅",chatTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"메인 채팅"})," - 당신과 4개의 AI 에이전트가 실시간으로 대화하는 공간입니다. 여기 입력한 메시지가 에이전트 동작을 시작시킵니다. 특정 에이전트를 부를 때는 @멘션을 사용하세요."]}),githubLabel:"GitHub",githubTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"GitHub"})," - 이 프로젝트 저장소의 열린 이슈와 PR을 보여줍니다. 항목을 클릭하면 GitHub에서 바로 열립니다. 아래 배치 진행 패널은 현재 배치가 대기에서 병합까지 어떻게 진행되는지 추적합니다."]})}};e.s(["default",0,function({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=hr[i],s=(0,_.useRef)(null),[n,o]=(0,_.useState)(.5),[a,l]=(0,_.useState)(.5),h=(0,_.useRef)(null),[c,d]=(0,_.useState)({}),[u,f]=(0,_.useState)(!1),v=(0,_.useRef)(!1);(0,_.useEffect)(()=>{v.current=!1,f(!1)},[e]),(0,_.useEffect)(()=>{v.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.bridge_filter_agents_only&&f(!0),v.current=!0}).catch(()=>{})},[e]);let b=(0,_.useCallback)(()=>{f(i=>{let r=!i;return fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let s=(i.projects||[]).find(i=>i.id===e);if(s)return s.bridge_filter_agents_only=r,fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}).catch(()=>{}),r})},[e]),y=(0,_.useMemo)(()=>(0,p.jsx)("button",{type:"button",onClick:b,title:u?r.filterAgentsTitle:r.filterAllTitle,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${u?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:u?r.filterOn:r.filterOff}),[u,r,b]);(0,_.useEffect)(()=>{let i=()=>{fetch("/api/agents").then(e=>e.ok?e.json():{}).then(i=>{let r={};for(let[s,n]of Object.entries(i))s.startsWith(`${e}/`)&&(r[s.split("/")[1]]=n.state);d(r)}).catch(()=>{})};i();let r=setInterval(i,5e3);return()=>clearInterval(r)},[e]);let S=(0,_.useCallback)((e,i)=>Math.min((i-4-150)/i,Math.max(150/i,e)),[]);(0,_.useEffect)(()=>{let e=e=>{if(!h.current||!s.current)return;let i=s.current.getBoundingClientRect();"col"===h.current?o(S((e.clientX-i.left)/i.width,i.width)):l(S((e.clientY-i.top)/i.height,i.height))},i=()=>{h.current=null,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",i),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",i)}},[S]);let w=e=>{h.current=e,document.body.style.cursor="col"===e?"col-resize":"row-resize",document.body.style.userSelect="none"},C=`${100*n}% 4px 1fr`,k=`${100*a}% 4px 1fr`;return(0,p.jsxs)("div",{ref:s,className:"w-full h-full",children:[(0,p.jsx)("style",{children:`
33
+ 이 파일은 이미 가져온 것 같습니다. 다시 가져오면 모든 메시지가 중복됩니다. 계속하시겠습니까?`,importStatus:(e,i,r,s)=>(0,p.jsxs)(p.Fragment,{children:["가져옴: ",e," / ",i,r>0&&` \xb7 건너뜀 ${r}`,s>0&&` \xb7 오류 ${s}`]})}};function l9({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l6[i],s=(0,m.useRef)(null),[n,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(null),[h,c]=(0,m.useState)(null),[d,u]=(0,m.useState)([]),[f,_]=(0,m.useState)(!1),[v,b]=(0,m.useState)(!1);(0,m.useEffect)(()=>{fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);r&&_(!!r.auto_restore_after_restart)}).catch(()=>{})},[e]);let y=async i=>{b(!0);try{let r=await fetch("/api/config");if(!r.ok)throw Error(`GET /api/config ${r.status}`);let s=await r.json(),n=s.projects?.findIndex(i=>i.id===e)??-1;if(n<0)throw Error("project not found");s.projects[n]={...s.projects[n],auto_restore_after_restart:i};let o=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw Error(`PUT /api/config ${o.status}`)}finally{b(!1)}},S=()=>{fetch(`/api/project-history/snapshots?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&Array.isArray(e.snapshots)&&u(e.snapshots)}).catch(()=>{})};(0,m.useEffect)(()=>{S();let e=setInterval(S,15e3);return()=>clearInterval(e)},[e]);let w=async i=>{if(window.confirm(r.restoreConfirm(i))){o("restore"),l(null),c(null);try{let r=await fetch(`/api/project-history/restore?project=${encodeURIComponent(e)}&name=${encodeURIComponent(i)}`,{method:"POST"}),s=await r.json().catch(()=>null);if(!r.ok)throw Error(s&&s.error||`HTTP ${r.status}`);s&&"number"==typeof s.imported&&c(s)}catch(e){l(e.message||String(e))}finally{o(null),S()}}},C=async()=>{o("export"),l(null),c(null);try{let i=await fetch(`/api/project-history?project=${encodeURIComponent(e)}`);if(!i.ok){let e=await i.text().catch(()=>"");throw Error(`HTTP ${i.status}: ${e.slice(0,200)}`)}let r=await i.blob(),s=URL.createObjectURL(r),n=document.createElement("a"),o=new Date().toISOString().slice(0,10);n.href=s,n.download=`${e}-history-${o}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}catch(e){l(e.message||String(e))}finally{o(null)}},k=async i=>{let n;if(i.size>0xa00000)return void l(`File too large (${i.size} bytes; limit 10485760)`);o("import"),l(null),c(null);try{let e=await i.text();n=JSON.parse(e)}catch(e){o(null),l(`Invalid JSON: ${e.message||String(e)}`);return}if(!n||"object"!=typeof n||!Array.isArray(n.messages)){o(null),l("File missing 'messages' array");return}let a=!1;if(n.project_id&&n.project_id!==e){if(!window.confirm(r.importMismatchConfirm(n.project_id,e)))return void o(null);a=!0}let h=new Set(["head","dev","reviewer1","reviewer2","re1","re2","t1","t2a","t2b","t3","system"]),d=!1,u=new Set;for(let e of n.messages)if(e&&"object"==typeof e){let i=e.sender;if("string"==typeof i&&h.has(i.toLowerCase())&&(u.add(i),u.size>=5))break}if(u.size>0){if(!window.confirm(r.importReservedConfirm([...u].join(", "))))return void o(null);d=!0}let f=!1,p=i=>fetch(`/api/project-history?project=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,allow_project_mismatch:a,allow_agent_senders:d,allow_duplicate:f,...i})});try{let e=await p({}),i=await e.json().catch(()=>null);if(409===e.status&&i&&"string"==typeof i.error&&/already imported/i.test(i.error)){if(!window.confirm(r.importDuplicateConfirm(i.error)))return void o(null);f=!0,e=await p({allow_duplicate:!0}),i=await e.json().catch(()=>null)}if(!e.ok)throw Error(i&&i.error||`HTTP ${e.status}`);c(i)}catch(e){l(e.message||String(e))}finally{o(null),s.current&&(s.current.value="")}};return(0,p.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted uppercase tracking-wider mb-1.5",children:[r.title,(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("button",{type:"button",onClick:C,disabled:null!==n,className:"px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Download a JSON snapshot of this project's chat history",children:"export"===n?"…":r.export(e)}),(0,p.jsx)("button",{type:"button",onClick:()=>{l(null),c(null),s.current?.click()},disabled:null!==n,className:"px-2 py-0.5 text-[10px] text-text-muted border border-border rounded hover:text-text hover:border-accent transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Restore a previously exported chat history (JSON)",children:"import"===n?r.importing:r.import}),(0,p.jsx)("input",{ref:s,type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let i=e.target.files&&e.target.files[0];i&&k(i)}})]}),a&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:a}),h&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:r.importStatus(h.imported,h.total,h.skipped,h.errors.length)}),(0,p.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:f,disabled:v,onChange:e=>{let i=e.target.checked;_(i),y(i).catch(()=>_(!i))}}),r.autoRestore]}),d.length>0&&(0,p.jsxs)("div",{className:"mt-2 border-t border-border/50 pt-1.5",children:[(0,p.jsx)("div",{className:"text-[9px] text-text-muted uppercase tracking-wider mb-0.5",children:r.autoSnapshots}),d.map(e=>{let i=new Date(e.mtime).toLocaleString();return(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] py-0.5",children:[(0,p.jsx)("span",{className:"text-text-muted tabular-nums flex-1 truncate",title:e.name,children:i}),(0,p.jsxs)("span",{className:"text-text-muted tabular-nums shrink-0",children:[Math.round(e.size/1024),"KB"]}),(0,p.jsx)("button",{type:"button",onClick:()=>w(e.name),disabled:null!==n,className:"px-1.5 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:`Restore ${e.name}`,children:"restore"===n?"…":r.restore})]},e.name)})]})]})}let l8={en:{title:"Agent Models",loading:"Loading…",noAgents:"No agents configured.",restartRequired:"restart required",restartRequiredTooltip:"Config changed — running session is still on the old model/effort. Click Restart to apply.",default:"(default)",custom:"(custom)",restart:"Restart",restartTooltip:"Restart this agent to pick up the new model / reasoning setting",help:(0,p.jsxs)(p.Fragment,{children:["Codex reasoning effort defaults to ",(0,p.jsx)("code",{className:"text-text",children:"medium"})," for new projects. Blank model falls back to the CLI default. Click Restart to apply changes to a live session."]}),summary:(e,i)=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"text-text",children:e}),(0,p.jsxs)("span",{children:[": ",i]})]}),configure:"Configure →",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Agent Models"})," — configure which LLM model and reasoning effort each agent uses. Changes require an agent restart to take effect."]})},ko:{title:"에이전트 모델",loading:"로딩 중…",noAgents:"설정된 에이전트가 없습니다.",restartRequired:"재시작 필요",restartRequiredTooltip:"설정이 변경되었습니다. 실행 중인 세션에는 이전 설정이 적용되어 있습니다. 재시작을 클릭하여 적용하세요.",default:"(기본값)",custom:"(사용자 정의)",restart:"재시작",restartTooltip:"에이전트를 재시작하여 새로운 모델/추론 설정을 적용합니다",help:(0,p.jsxs)(p.Fragment,{children:["Codex 추론 수준은 새 프로젝트의 경우 ",(0,p.jsx)("code",{className:"text-text",children:"medium"}),"으로 기본 설정됩니다. 모델을 비워두면 CLI 기본값이 사용됩니다. 변경 사항을 적용하려면 재시작을 클릭하세요."]}),summary:(e,i)=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"text-text",children:e}),(0,p.jsxs)("span",{children:[": ",i]})]}),configure:"설정 →",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"에이전트 모델"})," - 각 에이전트가 어떤 LLM 모델과 추론 수준을 사용할지 설정합니다. 변경 사항은 에이전트를 재시작해야 적용됩니다."]})}},l7=["minimal","low","medium","high"],he={codex:[{value:"",label:"(CLI default)"},{value:"gpt-5.4",label:"gpt-5.4"},{value:"gpt-5",label:"gpt-5"},{value:"gpt-4o",label:"gpt-4o"}],claude:[{value:"",label:"(CLI default)"},{value:"claude-opus-4-7",label:"claude-opus-4-7"},{value:"claude-opus-4-6",label:"claude-opus-4-6"},{value:"claude-sonnet-4-6",label:"claude-sonnet-4-6"},{value:"claude-haiku-4-5-20251001",label:"claude-haiku-4-5"}]};function ht(e){return he[e]||[{value:"",label:"(CLI default)"}]}function hi({projectId:e,onClose:i}){let{locale:r}=(0,x.useLocale)(),s=l8[r],[n,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(null),[h,c]=(0,m.useState)(null),[d,u]=(0,m.useState)(new Set),f=(0,m.useCallback)(async()=>{try{let i=await fetch(`/api/project/${encodeURIComponent(e)}/agent-models`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();o(r.agents||[]),l(null)}catch(e){l(e.message)}},[e]);(0,m.useEffect)(()=>{f()},[f]),(0,m.useEffect)(()=>{let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]);let _=async(i,r)=>{c(i),l(null);try{let s=await fetch(`/api/project/${encodeURIComponent(e)}/agent-models/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await s.json();if(!s.ok||!1===n.ok)throw Error(n.error||`${s.status}`);u(e=>{let r=new Set(e);return r.add(i),r}),await f()}catch(e){l(e.message)}finally{c(null)}},g=async i=>{c(i),l(null);try{let r=await fetch(`/api/agents/${encodeURIComponent(e)}/${encodeURIComponent(i)}/restart`,{method:"POST"}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);u(e=>{let r=new Set(e);return r.delete(i),r})}catch(e){l(e.message)}finally{c(null)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:i,role:"dialog","aria-modal":"true","aria-labelledby":"agent-models-title",children:(0,p.jsxs)("div",{className:"relative mx-4 w-full max-w-[520px] max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:i,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,p.jsx)("h2",{id:"agent-models-title",className:"text-base font-semibold text-white",children:s.title}),a&&(0,p.jsxs)("span",{className:"text-[10px] text-error max-w-[60%] truncate ml-2",title:a,children:["err: ",a]})]}),(0,p.jsxs)("div",{className:"flex flex-col gap-1.5",children:[!n&&(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:s.loading}),n&&0===n.length&&(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:s.noAgents}),n&&n.map(e=>(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("span",{className:"text-[11px] text-text font-semibold w-16 shrink-0",children:e.agent_id}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted w-12 shrink-0",children:e.backend}),d.has(e.agent_id)&&(0,p.jsx)("span",{className:"text-[9px] text-[#ffcc00] border border-[#ffcc00]/40 px-1 py-[1px] shrink-0",title:s.restartRequiredTooltip,children:s.restartRequired}),(0,p.jsxs)("select",{value:e.model,disabled:h===e.agent_id,onChange:i=>_(e.agent_id,{model:i.target.value}),className:"flex-1 min-w-[140px] bg-transparent border border-border px-1 py-0.5 text-[11px] font-mono text-text outline-none focus:border-accent cursor-pointer disabled:opacity-50",children:[ht(e.backend).map(e=>(0,p.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value)),e.model&&!ht(e.backend).some(i=>i.value===e.model)&&(0,p.jsxs)("option",{value:e.model,className:"bg-bg-surface",children:[e.model," ",s.custom]})]}),e.reasoning_supported?(0,p.jsxs)("select",{value:e.reasoning_effort||"",disabled:h===e.agent_id,onChange:i=>_(e.agent_id,{reasoning_effort:i.target.value}),className:"bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent cursor-pointer disabled:opacity-50",children:[(0,p.jsx)("option",{value:"",className:"bg-bg-surface",children:s.default}),l7.map(e=>(0,p.jsx)("option",{value:e,className:"bg-bg-surface",children:e},e))]}):(0,p.jsx)("span",{className:"text-[10px] text-text-muted w-16 text-center",children:"—"}),(0,p.jsx)("button",{type:"button",onClick:()=>g(e.agent_id),disabled:h===e.agent_id,title:s.restartTooltip,className:"shrink-0 px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 disabled:opacity-50 transition-colors",children:h===e.agent_id?"…":s.restart})]},e.agent_id)),(0,p.jsx)("p",{className:"mt-2 text-[10px] text-text-muted leading-snug",children:s.help})]})]})})}function hr({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=l8[i],[s,n]=(0,m.useState)(!1),[o,a]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let i=!1;return fetch(`/api/project/${encodeURIComponent(e)}/agent-models`).then(e=>e.ok?e.json():null).then(e=>{i||!e||a((e.agents||[]).map(e=>({id:e.agent_id,backend:e.backend})))}).catch(()=>{}),()=>{i=!0}},[e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:r.title}),(0,p.jsx)(g,{children:r.tooltip})]}),(0,p.jsx)("button",{type:"button",onClick:()=>n(!0),className:"px-2 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors",children:r.configure})]}),o&&o.length>0&&(0,p.jsx)("div",{className:"px-3 py-1 text-[10px] text-text-muted truncate",title:o.map(e=>`${e.id}: ${e.backend}`).join(" · "),children:o.map((e,i)=>(0,p.jsxs)("span",{children:[i>0&&(0,p.jsx)("span",{className:"text-text-muted/60",children:" · "}),r.summary(e.id,e.backend)]},e.id))})]}),s&&(0,p.jsx)(hi,{projectId:e,onClose:()=>n(!1)})]})}let hs={en:{label:"Operator Features",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Operator Features"})," — tools for running autonomous overnight batches. Includes the Scheduled Trigger, Telegram Bridge, Discord Bridge, Loop Guard, Project History, and Agent Models."]})},ko:{label:"운영자 기능",tooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"운영자 기능"})," - 야간 자율 배치를 운영할 때 쓰는 도구 모음입니다. Scheduled Trigger, Telegram Bridge, Discord Bridge, Loop Guard, Project History, Agent Models가 포함됩니다."]})}};function hn({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=hs[i];return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,p.jsx)(_,{label:r.label,tooltip:(0,p.jsx)(g,{children:r.tooltip})}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row gap-2 p-2 overflow-auto lg:overflow-hidden",children:[(0,p.jsx)("div",{className:"lg:flex-1 lg:min-w-[280px] lg:min-h-0",children:(0,p.jsx)(lG,{projectId:e})}),(0,p.jsx)("div",{className:"hidden lg:block w-px self-stretch bg-border"}),(0,p.jsxs)("div",{className:"lg:flex-1 lg:min-h-0 lg:overflow-y-auto flex flex-col gap-2",children:[(0,p.jsx)(hr,{projectId:e}),(0,p.jsx)(lZ,{projectId:e}),(0,p.jsx)(l5,{projectId:e}),(0,p.jsx)(l4,{projectId:e}),(0,p.jsx)(l9,{projectId:e})]})]})]})}let ho={en:{filterAgentsTitle:"Showing agent messages only — click to show all",filterAllTitle:"Showing all messages — click to hide system/status noise",filterOn:"Filter system log: on",filterOff:"Filter system log: off",chatLabel:"AgentChattr — primary chat",chatTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"Primary Chat"})," — live chat between you and the 4 AI agents. Messages you type here trigger agent actions. Use @mentions to address specific agents."]}),githubLabel:"GitHub",githubTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"GitHub"}),"— open issues and pull requests on this project's repo. Click any item to open it on GitHub. The batch progress panel tracks the active batch's lifecycle from queued to merged."]})},ko:{filterAgentsTitle:"에이전트 메시지만 표시 중 - 클릭하면 전체를 표시합니다",filterAllTitle:"전체 메시지 표시 중 - 클릭하면 시스템/상태 로그를 숨깁니다",filterOn:"시스템 로그 필터: 켜짐",filterOff:"시스템 로그 필터: 꺼짐",chatLabel:"AgentChattr — 메인 채팅",chatTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"메인 채팅"})," - 당신과 4개의 AI 에이전트가 실시간으로 대화하는 공간입니다. 여기 입력한 메시지가 에이전트 동작을 시작시킵니다. 특정 에이전트를 부를 때는 @멘션을 사용하세요."]}),githubLabel:"GitHub",githubTooltip:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("b",{children:"GitHub"})," - 이 프로젝트 저장소의 열린 이슈와 PR을 보여줍니다. 항목을 클릭하면 GitHub에서 바로 열립니다. 아래 배치 진행 패널은 현재 배치가 대기에서 병합까지 어떻게 진행되는지 추적합니다."]})}};e.s(["default",0,function({projectId:e}){let{locale:i}=(0,x.useLocale)(),r=ho[i],s=(0,m.useRef)(null),[n,o]=(0,m.useState)(.5),[a,l]=(0,m.useState)(.5),h=(0,m.useRef)(null),[c,d]=(0,m.useState)({}),[u,f]=(0,m.useState)(!1),v=(0,m.useRef)(!1);(0,m.useEffect)(()=>{v.current=!1,f(!1)},[e]),(0,m.useEffect)(()=>{v.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.bridge_filter_agents_only&&f(!0),v.current=!0}).catch(()=>{})},[e]);let b=(0,m.useCallback)(()=>{f(i=>{let r=!i;return fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let s=(i.projects||[]).find(i=>i.id===e);if(s)return s.bridge_filter_agents_only=r,fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}).catch(()=>{}),r})},[e]),y=(0,m.useMemo)(()=>(0,p.jsx)("button",{type:"button",onClick:b,title:u?r.filterAgentsTitle:r.filterAllTitle,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${u?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:u?r.filterOn:r.filterOff}),[u,r,b]);(0,m.useEffect)(()=>{let i=()=>{fetch("/api/agents").then(e=>e.ok?e.json():{}).then(i=>{let r={};for(let[s,n]of Object.entries(i))s.startsWith(`${e}/`)&&(r[s.split("/")[1]]=n.state);d(r)}).catch(()=>{})};i();let r=setInterval(i,5e3);return()=>clearInterval(r)},[e]);let S=(0,m.useCallback)((e,i)=>Math.min((i-4-150)/i,Math.max(150/i,e)),[]);(0,m.useEffect)(()=>{let e=e=>{if(!h.current||!s.current)return;let i=s.current.getBoundingClientRect();"col"===h.current?o(S((e.clientX-i.left)/i.width,i.width)):l(S((e.clientY-i.top)/i.height,i.height))},i=()=>{h.current=null,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",i),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",i)}},[S]);let w=e=>{h.current=e,document.body.style.cursor="col"===e?"col-resize":"row-resize",document.body.style.userSelect="none"},C=`${100*n}% 4px 1fr`,k=`${100*a}% 4px 1fr`;return(0,p.jsxs)("div",{ref:s,className:"w-full h-full",children:[(0,p.jsx)("style",{children:`
30
34
  @media (min-width: 1024px) {
31
35
  .qw-dashboard {
32
36
  display: grid !important;
@@ -35,4 +39,4 @@ This file looks like it was already imported. Re-import will duplicate every mes
35
39
  overflow: hidden !important;
36
40
  }
37
41
  }
38
- `}),(0,p.jsxs)("div",{className:"qw-dashboard flex flex-col w-full h-full overflow-y-auto",children:[(0,p.jsxs)("div",{className:"flex flex-col overflow-hidden border-2 border-accent min-h-[60vh] lg:min-h-0",children:[(0,p.jsx)(m,{label:r.chatLabel,tooltip:(0,p.jsx)(g,{children:r.chatTooltip}),children:y}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(R,{projectId:e,filterSystem:u})}),(0,p.jsx)(rr,{projectId:e})]}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("col")}),(0,p.jsx)("div",{className:"hidden lg:flex flex-col overflow-hidden",children:(0,p.jsx)(lz,{projectId:e,agentStates:c,onStatusChange:(e,i)=>{d(r=>({...r,[e]:i}))}})}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("row")}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-move",onMouseDown:()=>w("col")}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("row")}),(0,p.jsxs)("div",{className:"flex flex-col overflow-hidden border-t border-border lg:border-t-0",children:[(0,p.jsx)(m,{label:r.githubLabel,tooltip:(0,p.jsx)(g,{children:r.githubTooltip})}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(i6,{projectId:e})})]}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("col")}),(0,p.jsx)("div",{className:"border-t border-border lg:border-t-0 flex flex-col overflow-hidden",children:(0,p.jsx)(hi,{projectId:e})})]})]})}],55601)},73766,e=>{e.n(e.i(55601))}]);
42
+ `}),(0,p.jsxs)("div",{className:"qw-dashboard flex flex-col w-full h-full overflow-y-auto",children:[(0,p.jsxs)("div",{className:"flex flex-col overflow-hidden border-2 border-accent h-[60vh] shrink-0 lg:h-auto lg:shrink lg:min-h-0",children:[(0,p.jsx)(_,{label:r.chatLabel,tooltip:(0,p.jsx)(g,{children:r.chatTooltip}),children:y}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(D,{projectId:e,filterSystem:u})}),(0,p.jsx)(ro,{projectId:e})]}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("col")}),(0,p.jsx)("div",{className:"hidden lg:flex flex-col overflow-hidden",children:(0,p.jsx)(lU,{projectId:e,agentStates:c,onStatusChange:(e,i)=>{d(r=>({...r,[e]:i}))}})}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("row")}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-move",onMouseDown:()=>w("col")}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("row")}),(0,p.jsxs)("div",{className:"flex flex-col overflow-hidden border-t border-border lg:border-t-0 min-h-[40vh] shrink-0 lg:min-h-0 lg:shrink",children:[(0,p.jsx)(_,{label:r.githubLabel,tooltip:(0,p.jsx)(g,{children:r.githubTooltip})}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(i7,{projectId:e})})]}),(0,p.jsx)("div",{className:"hidden lg:block bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>w("col")}),(0,p.jsx)("div",{className:"border-t border-border lg:border-t-0 flex flex-col overflow-hidden",children:(0,p.jsx)(hn,{projectId:e})})]})]})}],55601)},73766,e=>{e.n(e.i(55601))}]);