/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/InstanceDetail-BO2CcF4D.js
import{O as Zi,j as m,R as Fe,d as B,aq as ho,r as Z,u as lo,E as ts,e as ss,ar as uo,as as pi,ap as yt,T as ht,t as ye,l as Oe,f as Qe,at as mi,ae as _o,g as qe,i as Ne,q as Ee,p as tt,au as er,av as wt,C as Pt,aw as fo,ax as po,ay as gi,az as vi,aA as mo,Y as go,aB as Rs,aC as vo,aD as tr,U as fe,am as Dt,aE as sr,ao as ir,L as Ks,aF as Lt,aG as rr,n as jt,H as Gs,aH as nr,v as st,aj as ot,al as So,aI as bo,F as Ys,aJ as Co,aK as or,G as ar,aL as Eo,A as cr,c as is,V as ge,Q as Si,P as bi,k as yo,aM as wo,aN as zs,D as xo,aO as Io,b as hr,aP as Ao,y as Po,aQ as Do,J as Lo}from"./index-B3cgCbnJ.js";import{i as Mo}from"./instanceOptions-D4bz_1Ev.js";import{g as Ci,u as Ro,a as To,I as ko,b as Ei,c as yi,d as Ue,i as rs,e as lr,C as Bo,D as Oo,f as No}from"./DeleteInstanceBtn-CRUFJ69a.js";import{M as Uo}from"./Meter-v0AAwaqr.js";import{N as jo,D as Fo}from"./NetworkListTable-Rl5yNR8Z.js";import{a as xt,b as Ho,c as ur,d as Ko,f as Go,e as Yo,g as dr,h as zo,m as Wo,i as $o,r as Vo}from"./instances-D13BkiL4.js";import{S as _r}from"./SnapshotForm-D7tEadHd.js";import{t as qo,a as Xo,b as Qo,g as fr,i as Jo,c as Zo}from"./snapshots-Bt9cFkFc.js";import{u as Ye}from"./projects-9DerJg4m.js";import{C as pr}from"./ClusterMemberSelector-iA98KA1k.js";import{u as mr,a as ea}from"./useInstances-BbVYlT_m.js";import{I as ta}from"./ItemName-B_MTAAB6.js";import{S as sa}from"./SelectableMainTable-CTM3_-pn.js";import{B as ia}from"./BulkDeleteButton-CR5M7boY.js";import{u as ra}from"./useBulkDetails-Bdf_X4A0.js";import{S as na}from"./SelectedTableNotification-BBOESV7i.js";import{h as gr,i as at,j as Ht,I as vr,r as oa,E as aa,R as ca,a as ha,M as la,B as ua,C as da,Y as _a,k as fa}from"./FormMenuItem-BwEOqt61.js";import{u as pa}from"./useSortTableData-DogFPcVj.js";import{C as ma}from"./CustomIsoModal-BSq8u8wj.js";import{y as ga,Y as St,I as va,M as Es,D as Sa,N as ba,G as Ca,P as Ea,O as ya,R as wa,S as xa,a as Ia,b as Aa,B as Pa,C as Da,c as La,o as Ma}from"./YamlSwitch-Bng19N-X.js";import{D as Ra,N as Ta,G as ka,P as Ba,O as Oa}from"./ProxyDeviceForm-DVEGshLd.js";import{F as Na}from"./FormFooterLayout-ChlQYZN0.js";import{Y as Ua}from"./YamlNotification-C209eie-.js";import{F as ja}from"./FormSubmitBtn-CI9Q_IyH.js";import{R as Fa}from"./RenameHeader-7HM7rJrm.js";import{F as ys,B as Ha}from"./FormLink-B3Ky5UhN.js";import{S as Ka}from"./StoragePoolSelectTable-BX9Dyx5x.js";import{S as Ga}from"./StoragePoolSelector-_Ij9bIB_.js";import{T as Ya}from"./TabLinks-BN40EEc5.js";import"./ExpandableList-DwC4iUKg.js";import"./useNetworks-DC9cTd9P.js";import"./networks-DBYE4DQa.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-BmFqLvbw.js";import"./scroll-BEbDVMxI.js";import"./ConfigFieldDescription-C9KDhW5s.js";import"./UploadCustomIso-KkVf5SOT.js";import"./ProgressBar-DyR68PLu.js";import"./storage-volumes-BlpH9Ab1.js";import"./useVolumes-BGHjBnNk.js";import"./images-CA6qXE8n.js";import"./DiskSizeSelector-CIkNkBL4.js";import"./StorageVolumeForm-0OnQ0JYw.js";import"./NetworkSelector-DygdY6TH.js";import"./useNetworkAcls-n0o7vmIP.js";import"./network-acls-BrbgJ988.js";import"./StoragePoolSize-34u3KM6q.js";import"./StoragePoolClusterMember-C_lGzG9t.js";const za=({instance:t,onFailure:e})=>{const{data:s=[],error:c,isLoading:v}=Zi(t.project);c&&e("Loading profiles failed",c);const I=[{content:"Name",sortKey:"name",className:"u-text--muted"},{content:"Description",sortKey:"description",className:"u-text--muted"}],y=t.profiles.map(n=>{const a=s.find(_=>_.name===n),u=(a==null?void 0:a.description)??"";return{key:n,columns:[{content:m.jsx(Fe,{type:"profile",value:n,to:a?`/ui/project/${encodeURIComponent(t.project)}/profile/${encodeURIComponent(n)}`:""}),role:"rowheader","aria-label":"Name"},{content:u,role:"cell",title:`Description ${u}`,"aria-label":"Description"}],sortData:{name:n.toLowerCase(),description:u.toLowerCase()}}});return v?m.jsx(B.Spinner,{className:"u-loader",text:"Loading profiles..."}):m.jsx(B.MainTable,{headers:I,rows:y,sortable:!0})},Wa=({instance:t})=>{const{getMetricHistory:e}=ho(),s=e(),[c,v]=Z.useState(15);Z.useEffect(()=>{const n=setInterval(()=>{v(a=>a-1)},1e3);return()=>{clearInterval(n)}},[]);const y=(()=>{if(s.length===0)return null;const n=s.length-1,a=Ci(s[n],t);if(!a)return null;let u=null;for(let o=s.length-2;o>=0&&(u=Ci(s[o],t),(u==null?void 0:u.cpuSecondsTotal)==a.cpuSecondsTotal);o--);if(!u)return null;const _=()=>{const o=a.cpuSecondsTotal-a.cpuSecondsIdle,r=u.cpuSecondsTotal-u.cpuSecondsIdle;return o-r},l=()=>{if(a.coreCount>0)return a.coreCount;const o=t.expanded_config["limits.cpu"];if(o){const r=parseInt(o);return r>0?r:1}return 1},f=_(),g=l(),b=(a.time-u.time)*g,d=100*f/b;return d<0?null:Math.min(d,100)})();return y===null?m.jsxs("div",{className:"u-text--muted p-text--small",children:["loading",c>0?`, ${c} seconds remaining to first CPU snapshot`:" takes longer than expected"]},c>0?c:"long"):m.jsx("div",{children:m.jsx(Uo,{percentage:y,text:`${Math.round(y*100)/100}%`})})},$a=({instance:t,onFailure:e})=>{var _;const{isRestricted:s}=lo(),[c,v]=Z.useState(!1),{data:I=[],error:y,isLoading:n}=Ro(t.location);y&&e("Loading metrics failed",y);const a=To(I,t);if(s)return m.jsx("div",{className:"u-text--muted",children:"Details are not available for restricted users"});const u=a.otherFilesystems.length>0;return m.jsx(m.Fragment,{children:n?m.jsx(B.Spinner,{className:"u-loader",text:"Loading metrics..."}):m.jsx("table",{children:m.jsxs("tbody",{children:[m.jsxs("tr",{className:"metric-row",children:[m.jsx("th",{className:"u-text--muted",children:"Memory"}),m.jsx("td",{children:a.memory?m.jsx(ko,{memory:a.memory}):"-"})]}),m.jsxs("tr",{className:"metric-row",children:[m.jsx("th",{className:"u-text--muted",children:"Root filesystem"}),m.jsx("td",{children:a.rootFilesystem?m.jsx(Ei,{filesystem:a.rootFilesystem}):"-"})]}),c&&a.otherFilesystems.map(l=>m.jsxs("tr",{className:"metric-row",children:[m.jsx("th",{className:"u-text--muted",children:l.device}),m.jsx("td",{children:m.jsx(Ei,{filesystem:l})})]},l.device)),u&&m.jsxs("tr",{className:"metric-row",children:[m.jsx("th",{}),m.jsx("td",{children:m.jsx(B.Button,{appearance:"link",className:"u-no-margin--bottom",onClick:()=>{v(!c)},children:c?"Hide other filesystems":"Show other filesystems"})})]}),m.jsxs("tr",{className:"metric-row",children:[m.jsx("th",{className:"u-text--muted",children:"CPU"}),m.jsx("td",{children:a.memory?m.jsx(Wa,{instance:t}):"-"},(_=a.memory)==null?void 0:_.free)]})]})})})},Va=({instance:t})=>{var y;const e=B.useNotify(),s=ts(),c=(n,a)=>{e.failure(n,a)},v=()=>{ht("instance-overview-tab")};Z.useEffect(v,[(y=e.notification)==null?void 0:y.message]),B.useListener(window,v,"resize",!0);const I=!t.state||t.state.pid===0?"-":t.state.pid;return m.jsxs("div",{className:"instance-overview-tab",children:[m.jsx(ss,{}),m.jsxs(B.Row,{className:"general",children:[m.jsx(B.Col,{size:3,children:m.jsx("h2",{className:"p-heading--5",children:"General"})}),m.jsx(B.Col,{size:7,children:m.jsx("table",{children:m.jsxs("tbody",{children:[m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"Base image"}),m.jsx("td",{children:uo(t)})]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"Description"}),m.jsx("td",{children:t.description?t.description:"-"})]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"Type"}),m.jsx("td",{children:Mo.filter(n=>n.value===t.type)[0].label})]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"IPv4"}),m.jsx("td",{children:m.jsx(yi,{instance:t,family:"inet"})},pi(t,"inet").length)]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"IPv6"}),m.jsx("td",{children:m.jsx(yi,{instance:t,family:"inet6"})},pi(t,"inet6").length)]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"Architecture"}),m.jsx("td",{children:t.architecture})]}),s&&m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"Cluster member"}),m.jsx("td",{children:t.location?m.jsx(Fe,{type:"cluster-member",value:t.location,to:`/ui/cluster/member/${encodeURIComponent(t.location)}`}):"-"})]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"PID"}),m.jsx("td",{children:I})]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"Date created"}),m.jsx("td",{children:yt(t.created_at)})]}),m.jsxs("tr",{children:[m.jsx("th",{className:"u-text--muted",children:"Last used"}),m.jsx("td",{children:yt(t.last_used_at)})]})]})})})]}),m.jsxs(B.Row,{className:"usage",children:[m.jsx(B.Col,{size:3,children:m.jsx("h2",{className:"p-heading--5",children:"Usage"})}),m.jsx(B.Col,{size:7,children:m.jsx($a,{instance:t,onFailure:c})})]}),m.jsxs(B.Row,{className:"networks",children:[m.jsx(B.Col,{size:3,children:m.jsx("h2",{className:"p-heading--5",children:"Networks"})}),m.jsx(B.Col,{size:7,children:m.jsx(jo,{devices:t.expanded_devices,instance:t,onFailure:c})})]}),m.jsxs(B.Row,{className:"networks",children:[m.jsx(B.Col,{size:3,children:m.jsx("h2",{className:"p-heading--5",children:"Devices"})}),m.jsx(B.Col,{size:7,children:m.jsx(Fo,{configBaseURL:`/ui/project/${encodeURIComponent(t.project)}/instance/${encodeURIComponent(t.name)}/configuration`,devices:t.expanded_devices})})]}),m.jsxs(B.Row,{className:"profiles",children:[m.jsx(B.Col,{size:3,children:m.jsx("h2",{className:"p-heading--5",children:"Profiles"})}),m.jsx(B.Col,{size:7,children:m.jsx(za,{instance:t,onFailure:c})})]})]})};var ws={exports:{}},wi;function qa(){return wi||(wi=1,function(t,e){(function(s,c){t.exports=c()})(self,()=>(()=>{var s={};return(()=>{var c=s;Object.defineProperty(c,"__esModule",{value:!0}),c.FitAddon=void 0,c.FitAddon=class{activate(v){this._terminal=v}dispose(){}fit(){const v=this.proposeDimensions();if(!v||!this._terminal||isNaN(v.cols)||isNaN(v.rows))return;const I=this._terminal._core;this._terminal.rows===v.rows&&this._terminal.cols===v.cols||(I._renderService.clear(),this._terminal.resize(v.cols,v.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const v=this._terminal._core,I=v._renderService.dimensions;if(I.css.cell.width===0||I.css.cell.height===0)return;const y=this._terminal.options.scrollback===0?0:v.viewport.scrollBarWidth,n=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(n.getPropertyValue("height")),u=Math.max(0,parseInt(n.getPropertyValue("width"))),_=window.getComputedStyle(this._terminal.element),l=a-(parseInt(_.getPropertyValue("padding-top"))+parseInt(_.getPropertyValue("padding-bottom"))),f=u-(parseInt(_.getPropertyValue("padding-right"))+parseInt(_.getPropertyValue("padding-left")))-y;return{cols:Math.max(2,Math.floor(f/I.css.cell.width)),rows:Math.max(1,Math.floor(l/I.css.cell.height))}}}})(),s})())}(ws)),ws.exports}var Sr=qa();const Xa=({payload:t,close:e,reconnect:s,instance:c})=>{const v=ye(),[I,y]=Z.useState(null),n=Oe(),a=Z.useRef(null),u=Qe().shape({command:qe().required("This field is required"),environment:_o().of(Qe().shape({key:qe(),value:qe()})),user:mi(),group:mi()}),_=Ne({initialValues:t,validationSchema:u,onSubmit:s}),l=()=>{const o=[..._.values.environment];o.push({key:"",value:""}),_.setFieldValue("environment",o)},f=o=>{const r=[..._.values.environment];r.splice(o,1),_.setFieldValue("environment",r)},g=()=>{c.config={...c.config,[Er]:JSON.stringify(_.values)},xt(c,c.project).then(o=>{v.set(o.metadata.id,()=>{y(B.success("Saved terminal connection defaults for this instance.","Saved successfully"))},r=>{y(B.failure("Failed to save terminal connection defaults.",new Error(r)))},()=>{n.invalidateQueries({queryKey:[Ee.instances,c.name,c.project]})})}).catch(o=>{y(B.failure("Failed to save terminal connection defaults.",o))})},b=o=>{o.key==="Escape"&&e()},d=()=>{ht("content-wrapper","p-modal__footer",64,"max-height")};return B.useListener(window,d,"resize",!0),Z.useEffect(d,[]),Z.useEffect(()=>{var o;(o=a.current)==null||o.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),window.dispatchEvent(new Event("resize"))},[_.values.environment]),m.jsxs(B.Modal,{close:e,title:"Reconnect terminal",buttonRow:m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button","aria-label":"cancel reconnect",onClick:e,children:"Cancel"}),m.jsx(B.Button,{className:"u-no-margin--bottom",type:"button",title:"Save as default for this instance",onClick:g,children:"Save as default"}),m.jsx(B.ActionButton,{className:"u-no-margin--bottom",appearance:"positive","aria-label":"submit reconnect",onClick:()=>void _.submitForm(),children:"Reconnect"})]}),onKeyDown:b,children:[I&&m.jsx(B.Notification,{severity:I.type,title:I.title,onDismiss:()=>{y(null)},className:"margin-right",children:I.message}),m.jsxs(B.Form,{onSubmit:_.handleSubmit,children:[m.jsx(B.Input,{type:"submit",hidden:!0,value:"Hidden input"}),m.jsxs("div",{className:"content-wrapper",children:[m.jsx(B.Input,{id:"command",name:"command",label:"Command",labelClassName:"u-no-margin--bottom",type:"text",required:!0,onBlur:_.handleBlur,onChange:_.handleChange,error:_.touched.command?_.errors.command:null,value:_.values.command}),m.jsx(B.Input,{id:"user",name:"user",label:"User ID",labelClassName:"u-no-margin--bottom",type:"number",onBlur:_.handleBlur,onChange:_.handleChange,value:_.values.user}),m.jsx(B.Input,{id:"group",name:"group",label:"Group ID",labelClassName:"u-no-margin--bottom",type:"number",onBlur:_.handleBlur,onChange:_.handleChange,value:_.values.group}),m.jsx("p",{className:"u-no-margin--bottom p-form__label",children:"Environment variables"}),_.values.environment.map((o,r)=>m.jsxs("div",{className:"env-variables",children:[m.jsx(B.Input,{type:"text",placeholder:"Key",labelClassName:"u-off-screen",label:`Key of variable ${r}`,id:`environment.${r}.key`,name:`environment.${r}.key`,onBlur:_.handleBlur,onChange:_.handleChange,value:_.values.environment[r].key}),m.jsx(B.Input,{type:"text",placeholder:"Value",labelClassName:"u-off-screen",label:`Value of variable ${r}`,id:`environment.${r}.value`,name:`environment.${r}.value`,onBlur:_.handleBlur,onChange:_.handleChange,value:_.values.environment[r].value}),m.jsx(B.Button,{"aria-label":`remove variable ${r}`,onClick:()=>{f(r)},type:"button",hasIcon:!0,children:m.jsx(B.Icon,{name:"delete"})})]},r)),m.jsx("div",{ref:a,children:m.jsx(B.Button,{"aria-label":"add variable",onClick:l,type:"button",children:m.jsx("span",{children:"Add variable"})})})]})]})]})},Qa=({payload:t,reconnect:e,instance:s})=>{const[c,v]=Z.useState(!1),I=()=>{v(!1)},y=()=>{v(!0)},n=a=>{I(),e(a)};return m.jsxs(m.Fragment,{children:[c&&m.jsx(Xa,{close:I,reconnect:n,instance:s,payload:t}),m.jsxs(B.Button,{className:"u-no-margin--bottom",hasIcon:!0,onClick:y,children:[m.jsx(B.Icon,{name:"connected"}),m.jsx("span",{children:"Reconnect"})]})]})};var xs={exports:{}},xi;function Ja(){return xi||(xi=1,function(t,e){(function(s,c){t.exports=c()})(globalThis,()=>(()=>{var s={4567:function(y,n,a){var u=this&&this.__decorate||function(i,h,p,E){var C,w=arguments.length,S=w<3?h:E===null?E=Object.getOwnPropertyDescriptor(h,p):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(i,h,p,E);else for(var x=i.length-1;x>=0;x--)(C=i[x])&&(S=(w<3?C(S):w>3?C(h,p,S):C(h,p))||S);return w>3&&S&&Object.defineProperty(h,p,S),S},_=this&&this.__param||function(i,h){return function(p,E){h(p,E,i)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const l=a(9042),f=a(9924),g=a(844),b=a(4725),d=a(2585),o=a(3656);let r=n.AccessibilityManager=class extends g.Disposable{constructor(i,h,p,E){super(),this._terminal=i,this._coreBrowserService=p,this._renderService=E,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new f.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(C=>this._handleResize(C.rows))),this.register(this._terminal.onRender(C=>this._refreshRows(C.start,C.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(C=>this._handleChar(C))),this.register(this._terminal.onLineFeed(()=>this._handleChar(` `))),this.register(this._terminal.onA11yTab(C=>this._handleTab(C))),this.register(this._terminal.onKey(C=>this._handleKey(C.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this.register((0,o.addDisposableDomListener)(document,"selectionchange",()=>this._handleSelectionChange())),this.register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,g.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(i){for(let h=0;h<i;h++)this._handleChar(" ")}_handleChar(i){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==i&&(this._charsToAnnounce+=i):this._charsToAnnounce+=i,i===` `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=l.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(i){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(i)||this._charsToConsume.push(i)}_refreshRows(i,h){this._liveRegionDebouncer.refresh(i,h,this._terminal.rows)}_renderRows(i,h){const p=this._terminal.buffer,E=p.lines.length.toString();for(let C=i;C<=h;C++){const w=p.lines.get(p.ydisp+C),S=[],x=(w==null?void 0:w.translateToString(!0,void 0,void 0,S))||"",M=(p.ydisp+C+1).toString(),k=this._rowElements[C];k&&(x.length===0?(k.innerText=" ",this._rowColumns.set(k,[0,1])):(k.textContent=x,this._rowColumns.set(k,S)),k.setAttribute("aria-posinset",M),k.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(i,h){const p=i.target,E=this._rowElements[h===0?1:this._rowElements.length-2];if(p.getAttribute("aria-posinset")===(h===0?"1":`${this._terminal.buffer.lines.length}`)||i.relatedTarget!==E)return;let C,w;if(h===0?(C=p,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(C=this._rowElements.shift(),w=p,this._rowContainer.removeChild(C)),C.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),h===0){const S=this._createAccessibilityTreeNode();this._rowElements.unshift(S),this._rowContainer.insertAdjacentElement("afterbegin",S)}else{const S=this._createAccessibilityTreeNode();this._rowElements.push(S),this._rowContainer.appendChild(S)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(h===0?-1:1),this._rowElements[h===0?1:this._rowElements.length-2].focus(),i.preventDefault(),i.stopImmediatePropagation()}_handleSelectionChange(){var x;if(this._rowElements.length===0)return;const i=document.getSelection();if(!i)return;if(i.isCollapsed)return void(this._rowContainer.contains(i.anchorNode)&&this._terminal.clearSelection());if(!i.anchorNode||!i.focusNode)return void console.error("anchorNode and/or focusNode are null");let h={node:i.anchorNode,offset:i.anchorOffset},p={node:i.focusNode,offset:i.focusOffset};if((h.node.compareDocumentPosition(p.node)&Node.DOCUMENT_POSITION_PRECEDING||h.node===p.node&&h.offset>p.offset)&&([h,p]=[p,h]),h.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(h={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(h.node))return;const E=this._rowElements.slice(-1)[0];if(p.node.compareDocumentPosition(E)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(p={node:E,offset:((x=E.textContent)==null?void 0:x.length)??0}),!this._rowContainer.contains(p.node))return;const C=({node:M,offset:k})=>{const N=M instanceof Text?M.parentNode:M;let L=parseInt(N==null?void 0:N.getAttribute("aria-posinset"),10)-1;if(isNaN(L))return console.warn("row is invalid. Race condition?"),null;const F=this._rowColumns.get(N);if(!F)return console.warn("columns is null. Race condition?"),null;let G=k<F.length?F[k]:F.slice(-1)[0]+1;return G>=this._terminal.cols&&(++L,G=0),{row:L,column:G}},w=C(h),S=C(p);if(w&&S){if(w.row>S.row||w.row===S.row&&w.column>=S.column)throw new Error("invalid range");this._terminal.select(w.column,w.row,(S.row-w.row)*this._terminal.cols-w.column+S.column)}}_handleResize(i){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let h=this._rowContainer.children.length;h<this._terminal.rows;h++)this._rowElements[h]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[h]);for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const i=this._coreBrowserService.mainDocument.createElement("div");return i.setAttribute("role","listitem"),i.tabIndex=-1,this._refreshRowDimensions(i),i}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let i=0;i<this._terminal.rows;i++)this._refreshRowDimensions(this._rowElements[i])}}_refreshRowDimensions(i){i.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=r=u([_(1,d.IInstantiationService),_(2,b.ICoreBrowserService),_(3,b.IRenderService)],r)},3614:(y,n)=>{function a(f){return f.replace(/\r?\n/g,"\r")}function u(f,g){return g?"\x1B[200~"+f+"\x1B[201~":f}function _(f,g,b,d){f=u(f=a(f),b.decPrivateModes.bracketedPasteMode&&d.rawOptions.ignoreBracketedPasteMode!==!0),b.triggerDataEvent(f,!0),g.value=""}function l(f,g,b){const d=b.getBoundingClientRect(),o=f.clientX-d.left-10,r=f.clientY-d.top-10;g.style.width="20px",g.style.height="20px",g.style.left=`${o}px`,g.style.top=`${r}px`,g.style.zIndex="1000",g.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=a,n.bracketTextForPaste=u,n.copyHandler=function(f,g){f.clipboardData&&f.clipboardData.setData("text/plain",g.selectionText),f.preventDefault()},n.handlePasteEvent=function(f,g,b,d){f.stopPropagation(),f.clipboardData&&_(f.clipboardData.getData("text/plain"),g,b,d)},n.paste=_,n.moveTextAreaUnderMouseCursor=l,n.rightClickHandler=function(f,g,b,d,o){l(f,g,b),o&&d.rightClickSelect(f),g.value=d.selectionText,g.select()}},7239:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const u=a(1505);n.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(_,l,f){this._css.set(_,l,f)}getCss(_,l){return this._css.get(_,l)}setColor(_,l,f){this._color.set(_,l,f)}getColor(_,l){return this._color.get(_,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(a,u,_,l){a.addEventListener(u,_,l);let f=!1;return{dispose:()=>{f||(f=!0,a.removeEventListener(u,_,l))}}}},3551:function(y,n,a){var u=this&&this.__decorate||function(r,i,h,p){var E,C=arguments.length,w=C<3?i:p===null?p=Object.getOwnPropertyDescriptor(i,h):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(r,i,h,p);else for(var S=r.length-1;S>=0;S--)(E=r[S])&&(w=(C<3?E(w):C>3?E(i,h,w):E(i,h))||w);return C>3&&w&&Object.defineProperty(i,h,w),w},_=this&&this.__param||function(r,i){return function(h,p){i(h,p,r)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier=void 0;const l=a(3656),f=a(8460),g=a(844),b=a(2585),d=a(4725);let o=n.Linkifier=class extends g.Disposable{get currentLink(){return this._currentLink}constructor(r,i,h,p,E){super(),this._element=r,this._mouseService=i,this._renderService=h,this._bufferService=p,this._linkProviderService=E,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new f.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new f.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,g.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,g.toDisposable)(()=>{var C;this._lastMouseEvent=void 0,(C=this._activeProviderReplies)==null||C.clear()})),this.register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this.register((0,l.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,l.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(r){this._lastMouseEvent=r;const i=this._positionFromMouseEvent(r,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;const h=r.composedPath();for(let p=0;p<h.length;p++){const E=h[p];if(E.classList.contains("xterm"))break;if(E.classList.contains("xterm-hover"))return}this._lastBufferCell&&i.x===this._lastBufferCell.x&&i.y===this._lastBufferCell.y||(this._handleHover(i),this._lastBufferCell=i)}_handleHover(r){if(this._activeLine!==r.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(r,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,r)||(this._clearCurrentLink(),this._askForLink(r,!0))}_askForLink(r,i){var p,E;this._activeProviderReplies&&i||((p=this._activeProviderReplies)==null||p.forEach(C=>{C==null||C.forEach(w=>{w.link.dispose&&w.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=r.y);let h=!1;for(const[C,w]of this._linkProviderService.linkProviders.entries())i?(E=this._activeProviderReplies)!=null&&E.get(C)&&(h=this._checkLinkProviderResult(C,r,h)):w.provideLinks(r.y,S=>{var M,k;if(this._isMouseOut)return;const x=S==null?void 0:S.map(N=>({link:N}));(M=this._activeProviderReplies)==null||M.set(C,x),h=this._checkLinkProviderResult(C,r,h),((k=this._activeProviderReplies)==null?void 0:k.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(r.y,this._activeProviderReplies)})}_removeIntersectingLinks(r,i){const h=new Set;for(let p=0;p<i.size;p++){const E=i.get(p);if(E)for(let C=0;C<E.length;C++){const w=E[C],S=w.link.range.start.y<r?0:w.link.range.start.x,x=w.link.range.end.y>r?this._bufferService.cols:w.link.range.end.x;for(let M=S;M<=x;M++){if(h.has(M)){E.splice(C--,1);break}h.add(M)}}}}_checkLinkProviderResult(r,i,h){var C;if(!this._activeProviderReplies)return h;const p=this._activeProviderReplies.get(r);let E=!1;for(let w=0;w<r;w++)this._activeProviderReplies.has(w)&&!this._activeProviderReplies.get(w)||(E=!0);if(!E&&p){const w=p.find(S=>this._linkAtPosition(S.link,i));w&&(h=!0,this._handleNewLink(w))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!h)for(let w=0;w<this._activeProviderReplies.size;w++){const S=(C=this._activeProviderReplies.get(w))==null?void 0:C.find(x=>this._linkAtPosition(x.link,i));if(S){h=!0,this._handleNewLink(S);break}}return h}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(r){if(!this._currentLink)return;const i=this._positionFromMouseEvent(r,this._element,this._mouseService);i&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,i)&&this._currentLink.link.activate(r,this._currentLink.link.text)}_clearCurrentLink(r,i){this._currentLink&&this._lastMouseEvent&&(!r||!i||this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,g.disposeArray)(this._linkCacheDisposables))}_handleNewLink(r){if(!this._lastMouseEvent)return;const i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(r.link,i)&&(this._currentLink=r,this._currentLink.state={decorations:{underline:r.link.decorations===void 0||r.link.decorations.underline,pointerCursor:r.link.decorations===void 0||r.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,r.link,this._lastMouseEvent),r.link.decorations={},Object.defineProperties(r.link.decorations,{pointerCursor:{get:()=>{var h,p;return(p=(h=this._currentLink)==null?void 0:h.state)==null?void 0:p.decorations.pointerCursor},set:h=>{var p;(p=this._currentLink)!=null&&p.state&&this._currentLink.state.decorations.pointerCursor!==h&&(this._currentLink.state.decorations.pointerCursor=h,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",h))}},underline:{get:()=>{var h,p;return(p=(h=this._currentLink)==null?void 0:h.state)==null?void 0:p.decorations.underline},set:h=>{var p,E,C;(p=this._currentLink)!=null&&p.state&&((C=(E=this._currentLink)==null?void 0:E.state)==null?void 0:C.decorations.underline)!==h&&(this._currentLink.state.decorations.underline=h,this._currentLink.state.isHovered&&this._fireUnderlineEvent(r.link,h))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(h=>{if(!this._currentLink)return;const p=h.start===0?0:h.start+1+this._bufferService.buffer.ydisp,E=this._bufferService.buffer.ydisp+1+h.end;if(this._currentLink.link.range.start.y>=p&&this._currentLink.link.range.end.y<=E&&(this._clearCurrentLink(p,E),this._lastMouseEvent)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}})))}_linkHover(r,i,h){var p;(p=this._currentLink)!=null&&p.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&r.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(h,i.text)}_fireUnderlineEvent(r,i){const h=r.range,p=this._bufferService.buffer.ydisp,E=this._createLinkUnderlineEvent(h.start.x-1,h.start.y-p-1,h.end.x,h.end.y-p-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(E)}_linkLeave(r,i,h){var p;(p=this._currentLink)!=null&&p.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&r.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(h,i.text)}_linkAtPosition(r,i){const h=r.range.start.y*this._bufferService.cols+r.range.start.x,p=r.range.end.y*this._bufferService.cols+r.range.end.x,E=i.y*this._bufferService.cols+i.x;return h<=E&&E<=p}_positionFromMouseEvent(r,i,h){const p=h.getCoords(r,i,this._bufferService.cols,this._bufferService.rows);if(p)return{x:p[0],y:p[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(r,i,h,p,E){return{x1:r,y1:i,x2:h,y2:p,cols:this._bufferService.cols,fg:E}}};n.Linkifier=o=u([_(1,d.IMouseService),_(2,d.IRenderService),_(3,b.IBufferService),_(4,d.ILinkProviderService)],o)},9042:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(y,n,a){var u=this&&this.__decorate||function(d,o,r,i){var h,p=arguments.length,E=p<3?o:i===null?i=Object.getOwnPropertyDescriptor(o,r):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,o,r,i);else for(var C=d.length-1;C>=0;C--)(h=d[C])&&(E=(p<3?h(E):p>3?h(o,r,E):h(o,r))||E);return p>3&&E&&Object.defineProperty(o,r,E),E},_=this&&this.__param||function(d,o){return function(r,i){o(r,i,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const l=a(511),f=a(2585);let g=n.OscLinkProvider=class{constructor(d,o,r){this._bufferService=d,this._optionsService=o,this._oscLinkService=r}provideLinks(d,o){var x;const r=this._bufferService.buffer.lines.get(d-1);if(!r)return void o(void 0);const i=[],h=this._optionsService.rawOptions.linkHandler,p=new l.CellData,E=r.getTrimmedLength();let C=-1,w=-1,S=!1;for(let M=0;M<E;M++)if(w!==-1||r.hasContent(M)){if(r.loadCell(M,p),p.hasExtendedAttrs()&&p.extended.urlId){if(w===-1){w=M,C=p.extended.urlId;continue}S=p.extended.urlId!==C}else w!==-1&&(S=!0);if(S||w!==-1&&M===E-1){const k=(x=this._oscLinkService.getLinkData(C))==null?void 0:x.uri;if(k){const N={start:{x:w+1,y:d},end:{x:M+(S||M!==E-1?0:1),y:d}};let L=!1;if(!(h!=null&&h.allowNonHttpProtocols))try{const F=new URL(k);["http:","https:"].includes(F.protocol)||(L=!0)}catch{L=!0}L||i.push({text:k,range:N,activate:(F,G)=>h?h.activate(F,G,N):b(0,G),hover:(F,G)=>{var $;return($=h==null?void 0:h.hover)==null?void 0:$.call(h,F,G,N)},leave:(F,G)=>{var $;return($=h==null?void 0:h.leave)==null?void 0:$.call(h,F,G,N)}})}S=!1,p.hasExtendedAttrs()&&p.extended.urlId?(w=M,C=p.extended.urlId):(w=-1,C=-1)}}o(i)}};function b(d,o){if(confirm(`Do you want to navigate to ${o}? WARNING: This link could potentially be dangerous`)){const r=window.open();if(r){try{r.opener=null}catch{}r.location.href=o}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=g=u([_(0,f.IBufferService),_(1,f.IOptionsService),_(2,f.IOscLinkService)],g)},6193:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(a,u){this._renderCallback=a,this._coreBrowserService=u,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(a){return this._refreshCallbacks.push(a),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(a,u,_){this._rowCount=_,a=a!==void 0?a:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,a):a,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const a=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,u),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const a of this._refreshCallbacks)a(0);this._refreshCallbacks=[]}}},3236:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const u=a(3614),_=a(3656),l=a(3551),f=a(9042),g=a(3730),b=a(1680),d=a(3107),o=a(5744),r=a(2950),i=a(1296),h=a(428),p=a(4269),E=a(5114),C=a(8934),w=a(3230),S=a(9312),x=a(4725),M=a(6731),k=a(8055),N=a(8969),L=a(8460),F=a(844),G=a(6114),$=a(8437),Q=a(2584),V=a(7399),A=a(5941),D=a(9074),T=a(2585),O=a(5435),Y=a(4567),q=a(779);class se extends N.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(U={}){super(U),this.browser=G,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new L.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new L.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new L.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new L.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new L.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new L.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new L.EventEmitter),this._onBlur=this.register(new L.EventEmitter),this._onA11yCharEmitter=this.register(new L.EventEmitter),this._onA11yTabEmitter=this.register(new L.EventEmitter),this._onWillOpen=this.register(new L.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(D.DecorationService),this._instantiationService.setService(T.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(q.LinkProviderService),this._instantiationService.setService(x.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(g.OscLinkProvider)),this.register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this.register(this._inputHandler.onRequestRefreshRows((P,W)=>this.refresh(P,W))),this.register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this.register(this._inputHandler.onRequestReset(()=>this.reset())),this.register(this._inputHandler.onRequestWindowsOptionsReport(P=>this._reportWindowsOptions(P))),this.register(this._inputHandler.onColor(P=>this._handleColorEvent(P))),this.register((0,L.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,L.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,L.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,L.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize(P=>this._afterResize(P.cols,P.rows))),this.register((0,F.toDisposable)(()=>{var P,W;this._customKeyEventHandler=void 0,(W=(P=this.element)==null?void 0:P.parentNode)==null||W.removeChild(this.element)}))}_handleColorEvent(U){if(this._themeService)for(const P of U){let W,H="";switch(P.index){case 256:W="foreground",H="10";break;case 257:W="background",H="11";break;case 258:W="cursor",H="12";break;default:W="ansi",H="4;"+P.index}switch(P.type){case 0:const J=k.color.toColorRGB(W==="ansi"?this._themeService.colors.ansi[P.index]:this._themeService.colors[W]);this.coreService.triggerDataEvent(`${Q.C0.ESC}]${H};${(0,A.toRgbString)(J)}${Q.C1_ESCAPED.ST}`);break;case 1:if(W==="ansi")this._themeService.modifyColors(X=>X.ansi[P.index]=k.channels.toColor(...P.color));else{const X=W;this._themeService.modifyColors(ne=>ne[X]=k.channels.toColor(...P.color))}break;case 2:this._themeService.restoreColor(P.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(U){U?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(U){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var U;return(U=this.textarea)==null?void 0:U.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const U=this.buffer.ybase+this.buffer.y,P=this.buffer.lines.get(U);if(!P)return;const W=Math.min(this.buffer.x,this.cols-1),H=this._renderService.dimensions.css.cell.height,J=P.getWidth(W),X=this._renderService.dimensions.css.cell.width*J,ne=this.buffer.y*this._renderService.dimensions.css.cell.height,ue=W*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ue+"px",this.textarea.style.top=ne+"px",this.textarea.style.width=X+"px",this.textarea.style.height=H+"px",this.textarea.style.lineHeight=H+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,_.addDisposableDomListener)(this.element,"copy",P=>{this.hasSelection()&&(0,u.copyHandler)(P,this._selectionService)}));const U=P=>(0,u.handlePasteEvent)(P,this.textarea,this.coreService,this.optionsService);this.register((0,_.addDisposableDomListener)(this.textarea,"paste",U)),this.register((0,_.addDisposableDomListener)(this.element,"paste",U)),G.isFirefox?this.register((0,_.addDisposableDomListener)(this.element,"mousedown",P=>{P.button===2&&(0,u.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,_.addDisposableDomListener)(this.element,"contextmenu",P=>{(0,u.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),G.isLinux&&this.register((0,_.addDisposableDomListener)(this.element,"auxclick",P=>{P.button===1&&(0,u.moveTextAreaUnderMouseCursor)(P,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,_.addDisposableDomListener)(this.textarea,"keyup",U=>this._keyUp(U),!0)),this.register((0,_.addDisposableDomListener)(this.textarea,"keydown",U=>this._keyDown(U),!0)),this.register((0,_.addDisposableDomListener)(this.textarea,"keypress",U=>this._keyPress(U),!0)),this.register((0,_.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,_.addDisposableDomListener)(this.textarea,"compositionupdate",U=>this._compositionHelper.compositionupdate(U))),this.register((0,_.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,_.addDisposableDomListener)(this.textarea,"input",U=>this._inputEvent(U),!0)),this.register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(U){var W;if(!U)throw new Error("Terminal requires a parent element.");if(U.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((W=this.element)==null?void 0:W.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=U.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"),U.appendChild(this.element);const P=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),P.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,_.addDisposableDomListener)(this.screenElement,"mousemove",H=>this.updateCursorStyle(H))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),P.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",f.promptLabel),G.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(E.CoreBrowserService,this.textarea,U.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(x.ICoreBrowserService,this._coreBrowserService),this.register((0,_.addDisposableDomListener)(this.textarea,"focus",H=>this._handleTextAreaFocus(H))),this.register((0,_.addDisposableDomListener)(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(x.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(M.ThemeService),this._instantiationService.setService(x.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(p.CharacterJoinerService),this._instantiationService.setService(x.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(w.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(x.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(H=>this._onRender.fire(H))),this.onResize(H=>this._renderService.resize(H.cols,H.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(r.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(C.MouseService),this._instantiationService.setService(x.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(l.Linkifier,this.screenElement)),this.element.appendChild(P);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(b.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines(H=>this.scrollLines(H.amount,H.suppressScrollEvent,1)),this.register(this._inputHandler.onRequestSyncScrollBar(()=>this.viewport.syncScrollArea())),this.register(this.viewport),this.register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this.register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this.register(this.onBlur(()=>this._renderService.handleBlur())),this.register(this.onFocus(()=>this._renderService.handleFocus())),this.register(this._renderService.onDimensionsChange(()=>this.viewport.syncScrollArea())),this._selectionService=this.register(this._instantiationService.createInstance(S.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(x.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(H=>this.scrollLines(H.amount,H.suppressScrollEvent))),this.register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this.register(this._selectionService.onRequestRedraw(H=>this._renderService.handleSelectionChanged(H.start,H.end,H.columnSelectMode))),this.register(this._selectionService.onLinuxMouseSelection(H=>{this.textarea.value=H,this.textarea.focus(),this.textarea.select()})),this.register(this._onScroll.event(H=>{this.viewport.syncScrollArea(),this._selectionService.refresh()})),this.register((0,_.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.register(this._instantiationService.createInstance(d.BufferDecorationRenderer,this.screenElement)),this.register((0,_.addDisposableDomListener)(this.element,"mousedown",H=>this._selectionService.handleMouseDown(H))),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(Y.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",H=>this._handleScreenReaderModeOptionChange(H))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",H=>{!this._overviewRulerRenderer&&H&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.OverviewRulerRenderer,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(i.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const U=this,P=this.element;function W(X){const ne=U._mouseService.getMouseReportCoords(X,U.screenElement);if(!ne)return!1;let ue,de;switch(X.overrideType||X.type){case"mousemove":de=32,X.buttons===void 0?(ue=3,X.button!==void 0&&(ue=X.button<3?X.button:3)):ue=1&X.buttons?0:4&X.buttons?1:2&X.buttons?2:3;break;case"mouseup":de=0,ue=X.button<3?X.button:3;break;case"mousedown":de=1,ue=X.button<3?X.button:3;break;case"wheel":if(U._customWheelEventHandler&&U._customWheelEventHandler(X)===!1||U.viewport.getLinesScrolled(X)===0)return!1;de=X.deltaY<0?0:1,ue=4;break;default:return!1}return!(de===void 0||ue===void 0||ue>4)&&U.coreMouseService.triggerMouseEvent({col:ne.col,row:ne.row,x:ne.x,y:ne.y,button:ue,action:de,ctrl:X.ctrlKey,alt:X.altKey,shift:X.shiftKey})}const H={mouseup:null,wheel:null,mousedrag:null,mousemove:null},J={mouseup:X=>(W(X),X.buttons||(this._document.removeEventListener("mouseup",H.mouseup),H.mousedrag&&this._document.removeEventListener("mousemove",H.mousedrag)),this.cancel(X)),wheel:X=>(W(X),this.cancel(X,!0)),mousedrag:X=>{X.buttons&&W(X)},mousemove:X=>{X.buttons||W(X)}};this.register(this.coreMouseService.onProtocolChange(X=>{X?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(X)),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&X?H.mousemove||(P.addEventListener("mousemove",J.mousemove),H.mousemove=J.mousemove):(P.removeEventListener("mousemove",H.mousemove),H.mousemove=null),16&X?H.wheel||(P.addEventListener("wheel",J.wheel,{passive:!1}),H.wheel=J.wheel):(P.removeEventListener("wheel",H.wheel),H.wheel=null),2&X?H.mouseup||(H.mouseup=J.mouseup):(this._document.removeEventListener("mouseup",H.mouseup),H.mouseup=null),4&X?H.mousedrag||(H.mousedrag=J.mousedrag):(this._document.removeEventListener("mousemove",H.mousedrag),H.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,_.addDisposableDomListener)(P,"mousedown",X=>{if(X.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(X))return W(X),H.mouseup&&this._document.addEventListener("mouseup",H.mouseup),H.mousedrag&&this._document.addEventListener("mousemove",H.mousedrag),this.cancel(X)})),this.register((0,_.addDisposableDomListener)(P,"wheel",X=>{if(!H.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(X)===!1)return!1;if(!this.buffer.hasScrollback){const ne=this.viewport.getLinesScrolled(X);if(ne===0)return;const ue=Q.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(X.deltaY<0?"A":"B");let de="";for(let Ie=0;Ie<Math.abs(ne);Ie++)de+=ue;return this.coreService.triggerDataEvent(de,!0),this.cancel(X,!0)}return this.viewport.handleWheel(X)?this.cancel(X):void 0}},{passive:!1})),this.register((0,_.addDisposableDomListener)(P,"touchstart",X=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(X),this.cancel(X)},{passive:!0})),this.register((0,_.addDisposableDomListener)(P,"touchmove",X=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(X)?void 0:this.cancel(X)},{passive:!1}))}refresh(U,P){var W;(W=this._renderService)==null||W.refreshRows(U,P)}updateCursorStyle(U){var P;(P=this._selectionService)!=null&&P.shouldColumnSelect(U)?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(U,P,W=0){var H;W===1?(super.scrollLines(U,P,W),this.refresh(0,this.rows-1)):(H=this.viewport)==null||H.scrollLines(U)}paste(U){(0,u.paste)(U,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(U){this._customKeyEventHandler=U}attachCustomWheelEventHandler(U){this._customWheelEventHandler=U}registerLinkProvider(U){return this._linkProviderService.registerLinkProvider(U)}registerCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const P=this._characterJoinerService.register(U);return this.refresh(0,this.rows-1),P}deregisterCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(U)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(U){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+U)}registerDecoration(U){return this._decorationService.registerDecoration(U)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(U,P,W){this._selectionService.setSelection(U,P,W)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var U;(U=this._selectionService)==null||U.clearSelection()}selectAll(){var U;(U=this._selectionService)==null||U.selectAll()}selectLines(U,P){var W;(W=this._selectionService)==null||W.selectLines(U,P)}_keyDown(U){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;const P=this.browser.isMac&&this.options.macOptionIsMeta&&U.altKey;if(!P&&!this._compositionHelper.keydown(U))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;P||U.key!=="Dead"&&U.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const W=(0,V.evaluateKeyboardEvent)(U,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(U),W.type===3||W.type===2){const H=this.rows-1;return this.scrollLines(W.type===2?-H:H),this.cancel(U,!0)}return W.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,U)||(W.cancel&&this.cancel(U,!0),!W.key||!!(U.key&&!U.ctrlKey&&!U.altKey&&!U.metaKey&&U.key.length===1&&U.key.charCodeAt(0)>=65&&U.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(W.key!==Q.C0.ETX&&W.key!==Q.C0.CR||(this.textarea.value=""),this._onKey.fire({key:W.key,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(W.key,!0),!this.optionsService.rawOptions.screenReaderMode||U.altKey||U.ctrlKey?this.cancel(U,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(U,P){const W=U.isMac&&!this.options.macOptionIsMeta&&P.altKey&&!P.ctrlKey&&!P.metaKey||U.isWindows&&P.altKey&&P.ctrlKey&&!P.metaKey||U.isWindows&&P.getModifierState("AltGraph");return P.type==="keypress"?W:W&&(!P.keyCode||P.keyCode>47)}_keyUp(U){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1||(function(P){return P.keyCode===16||P.keyCode===17||P.keyCode===18}(U)||this.focus(),this.updateCursorStyle(U),this._keyPressHandled=!1)}_keyPress(U){let P;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;if(this.cancel(U),U.charCode)P=U.charCode;else if(U.which===null||U.which===void 0)P=U.keyCode;else{if(U.which===0||U.charCode===0)return!1;P=U.which}return!(!P||(U.altKey||U.ctrlKey||U.metaKey)&&!this._isThirdLevelShift(this.browser,U)||(P=String.fromCharCode(P),this._onKey.fire({key:P,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(P,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(U){if(U.data&&U.inputType==="insertText"&&(!U.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const P=U.data;return this.coreService.triggerDataEvent(P,!0),this.cancel(U),!0}return!1}resize(U,P){U!==this.cols||P!==this.rows?super.resize(U,P):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(U,P){var W,H;(W=this._charSizeService)==null||W.measure(),(H=this.viewport)==null||H.syncScrollArea(!0)}clear(){var U;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let P=1;P<this.rows;P++)this.buffer.lines.push(this.buffer.getBlankLine($.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(U=this.viewport)==null||U.reset(),this.refresh(0,this.rows-1)}}reset(){var P,W;this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),(P=this._selectionService)==null||P.reset(),this._decorationService.reset(),(W=this.viewport)==null||W.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){var U;(U=this._renderService)==null||U.clearTextureAtlas()}_reportFocus(){var U;(U=this.element)!=null&&U.classList.contains("focus")?this.coreService.triggerDataEvent(Q.C0.ESC+"[I"):this.coreService.triggerDataEvent(Q.C0.ESC+"[O")}_reportWindowsOptions(U){if(this._renderService)switch(U){case O.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const P=this._renderService.dimensions.css.canvas.width.toFixed(0),W=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[4;${W};${P}t`);break;case O.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const H=this._renderService.dimensions.css.cell.width.toFixed(0),J=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[6;${J};${H}t`)}}cancel(U,P){if(this.options.cancelEvents||P)return U.preventDefault(),U.stopPropagation(),!1}}n.Terminal=se},9924:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(a,u=1e3){this._renderCallback=a,this._debounceThresholdMS=u,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(a,u,_){this._rowCount=_,a=a!==void 0?a:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,a):a,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u;const l=Date.now();if(l-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=l,this._innerRefresh();else if(!this._additionalRefreshRequested){const f=l-this._lastRefreshMs,g=this._debounceThresholdMS-f;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},g)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const a=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,u)}}},1680:function(y,n,a){var u=this&&this.__decorate||function(r,i,h,p){var E,C=arguments.length,w=C<3?i:p===null?p=Object.getOwnPropertyDescriptor(i,h):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(r,i,h,p);else for(var S=r.length-1;S>=0;S--)(E=r[S])&&(w=(C<3?E(w):C>3?E(i,h,w):E(i,h))||w);return C>3&&w&&Object.defineProperty(i,h,w),w},_=this&&this.__param||function(r,i){return function(h,p){i(h,p,r)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const l=a(3656),f=a(4725),g=a(8460),b=a(844),d=a(2585);let o=n.Viewport=class extends b.Disposable{constructor(r,i,h,p,E,C,w,S){super(),this._viewportElement=r,this._scrollArea=i,this._bufferService=h,this._optionsService=p,this._charSizeService=E,this._renderService=C,this._coreBrowserService=w,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new g.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,l.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(x=>this._activeBuffer=x.activeBuffer)),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange(x=>this._renderDimensions=x)),this._handleThemeChange(S.colors),this.register(S.onChangeColors(x=>this._handleThemeChange(x))),this.register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.syncScrollArea())),setTimeout(()=>this.syncScrollArea())}_handleThemeChange(r){this._viewportElement.style.backgroundColor=r.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame(()=>this.syncScrollArea())}_refresh(r){if(r)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const i=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==i&&(this._lastRecordedBufferHeight=i,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const r=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==r&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=r),this._refreshAnimationFrame=null}syncScrollArea(r=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(r);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(r)}_handleScroll(r){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const i=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:i,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const r=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(r*(this._smoothScrollState.target-this._smoothScrollState.origin)),r<1?this._coreBrowserService.window.requestAnimationFrame(()=>this._smoothScroll()):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(r,i){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(i<0&&this._viewportElement.scrollTop!==0||i>0&&h<this._lastRecordedBufferHeight)||(r.cancelable&&r.preventDefault(),!1)}handleWheel(r){const i=this._getPixelsScrolled(r);return i!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+i:this._smoothScrollState.target+=i,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=i,this._bubbleScroll(r,i))}scrollLines(r){if(r!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const i=r*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+i,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:r,suppressScrollEvent:!1})}_getPixelsScrolled(r){if(r.deltaY===0||r.shiftKey)return 0;let i=this._applyScrollModifier(r.deltaY,r);return r.deltaMode===WheelEvent.DOM_DELTA_LINE?i*=this._currentRowHeight:r.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._currentRowHeight*this._bufferService.rows),i}getBufferElements(r,i){var S;let h,p="";const E=[],C=i??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let x=r;x<C;x++){const M=w.get(x);if(!M)continue;const k=(S=w.get(x+1))==null?void 0:S.isWrapped;if(p+=M.translateToString(!k),!k||x===w.length-1){const N=document.createElement("div");N.textContent=p,E.push(N),p.length>0&&(h=N),p=""}}return{bufferElements:E,cursorElement:h}}getLinesScrolled(r){if(r.deltaY===0||r.shiftKey)return 0;let i=this._applyScrollModifier(r.deltaY,r);return r.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=this._currentRowHeight+0,this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):r.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(r,i){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&i.altKey||h==="ctrl"&&i.ctrlKey||h==="shift"&&i.shiftKey?r*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:r*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(r){this._lastTouchY=r.touches[0].pageY}handleTouchMove(r){const i=this._lastTouchY-r.touches[0].pageY;return this._lastTouchY=r.touches[0].pageY,i!==0&&(this._viewportElement.scrollTop+=i,this._bubbleScroll(r,i))}};n.Viewport=o=u([_(2,d.IBufferService),_(3,d.IOptionsService),_(4,f.ICharSizeService),_(5,f.IRenderService),_(6,f.ICoreBrowserService),_(7,f.IThemeService)],o)},3107:function(y,n,a){var u=this&&this.__decorate||function(d,o,r,i){var h,p=arguments.length,E=p<3?o:i===null?i=Object.getOwnPropertyDescriptor(o,r):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,o,r,i);else for(var C=d.length-1;C>=0;C--)(h=d[C])&&(E=(p<3?h(E):p>3?h(o,r,E):h(o,r))||E);return p>3&&E&&Object.defineProperty(o,r,E),E},_=this&&this.__param||function(d,o){return function(r,i){o(r,i,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const l=a(4725),f=a(844),g=a(2585);let b=n.BufferDecorationRenderer=class extends f.Disposable{constructor(d,o,r,i,h){super(),this._screenElement=d,this._bufferService=o,this._coreBrowserService=r,this._decorationService=i,this._renderService=h,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(p=>this._removeDecoration(p))),this.register((0,f.toDisposable)(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(const d of this._decorationService.decorations)this._renderDecoration(d);this._dimensionsChanged=!1}_renderDecoration(d){this._refreshStyle(d),this._dimensionsChanged&&this._refreshXPosition(d)}_createElement(d){var i;const o=this._coreBrowserService.mainDocument.createElement("div");o.classList.add("xterm-decoration"),o.classList.toggle("xterm-decoration-top-layer",((i=d==null?void 0:d.options)==null?void 0:i.layer)==="top"),o.style.width=`${Math.round((d.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,o.style.height=(d.options.height||1)*this._renderService.dimensions.css.cell.height+"px",o.style.top=(d.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",o.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const r=d.options.x??0;return r&&r>this._bufferService.cols&&(o.style.display="none"),this._refreshXPosition(d,o),o}_refreshStyle(d){const o=d.marker.line-this._bufferService.buffers.active.ydisp;if(o<0||o>=this._bufferService.rows)d.element&&(d.element.style.display="none",d.onRenderEmitter.fire(d.element));else{let r=this._decorationElements.get(d);r||(r=this._createElement(d),d.element=r,this._decorationElements.set(d,r),this._container.appendChild(r),d.onDispose(()=>{this._decorationElements.delete(d),r.remove()})),r.style.top=o*this._renderService.dimensions.css.cell.height+"px",r.style.display=this._altBufferIsActive?"none":"block",d.onRenderEmitter.fire(r)}}_refreshXPosition(d,o=d.element){if(!o)return;const r=d.options.x??0;(d.options.anchor||"left")==="right"?o.style.right=r?r*this._renderService.dimensions.css.cell.width+"px":"":o.style.left=r?r*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(d){var o;(o=this._decorationElements.get(d))==null||o.remove(),this._decorationElements.delete(d),d.dispose()}};n.BufferDecorationRenderer=b=u([_(1,g.IBufferService),_(2,l.ICoreBrowserService),_(3,g.IDecorationService),_(4,l.IRenderService)],b)},5871:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(a){if(a.options.overviewRulerOptions){for(const u of this._zones)if(u.color===a.options.overviewRulerOptions.color&&u.position===a.options.overviewRulerOptions.position){if(this._lineIntersectsZone(u,a.marker.line))return;if(this._lineAdjacentToZone(u,a.marker.line,a.options.overviewRulerOptions.position))return void this._addLineToZone(u,a.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=a.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=a.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=a.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=a.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:a.options.overviewRulerOptions.color,position:a.options.overviewRulerOptions.position,startBufferLine:a.marker.line,endBufferLine:a.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(a){this._linePadding=a}_lineIntersectsZone(a,u){return u>=a.startBufferLine&&u<=a.endBufferLine}_lineAdjacentToZone(a,u,_){return u>=a.startBufferLine-this._linePadding[_||"full"]&&u<=a.endBufferLine+this._linePadding[_||"full"]}_addLineToZone(a,u){a.startBufferLine=Math.min(a.startBufferLine,u),a.endBufferLine=Math.max(a.endBufferLine,u)}}},5744:function(y,n,a){var u=this&&this.__decorate||function(h,p,E,C){var w,S=arguments.length,x=S<3?p:C===null?C=Object.getOwnPropertyDescriptor(p,E):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,p,E,C);else for(var M=h.length-1;M>=0;M--)(w=h[M])&&(x=(S<3?w(x):S>3?w(p,E,x):w(p,E))||x);return S>3&&x&&Object.defineProperty(p,E,x),x},_=this&&this.__param||function(h,p){return function(E,C){p(E,C,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const l=a(5871),f=a(4725),g=a(844),b=a(2585),d={full:0,left:0,center:0,right:0},o={full:0,left:0,center:0,right:0},r={full:0,left:0,center:0,right:0};let i=n.OverviewRulerRenderer=class extends g.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(h,p,E,C,w,S,x){var k;super(),this._viewportElement=h,this._screenElement=p,this._bufferService=E,this._decorationService=C,this._renderService=w,this._optionsService=S,this._coreBrowserService=x,this._colorZoneStore=new l.ColorZoneStore,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(),(k=this._viewportElement.parentElement)==null||k.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,g.toDisposable)(()=>{var N;(N=this._canvas)==null||N.remove()}))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this.register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0)))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this.register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this.register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())}))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",()=>this._queueRefresh(!0))),this.register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._queueRefresh(!0)}_refreshDrawConstants(){const h=Math.floor(this._canvas.width/3),p=Math.ceil(this._canvas.width/3);o.full=this._canvas.width,o.left=h,o.center=p,o.right=h,this._refreshDrawHeightConstants(),r.full=0,r.left=0,r.center=o.left,r.right=o.left+o.center}_refreshDrawHeightConstants(){d.full=Math.round(2*this._coreBrowserService.dpr);const h=this._canvas.height/this._bufferService.buffer.lines.length,p=Math.round(Math.max(Math.min(h,12),6)*this._coreBrowserService.dpr);d.left=p,d.center=p,d.right=p}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*d.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*d.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*d.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*d.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const p of this._decorationService.decorations)this._colorZoneStore.addDecoration(p);this._ctx.lineWidth=1;const h=this._colorZoneStore.zones;for(const p of h)p.position!=="full"&&this._renderColorZone(p);for(const p of h)p.position==="full"&&this._renderColorZone(p);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(h){this._ctx.fillStyle=h.color,this._ctx.fillRect(r[h.position||"full"],Math.round((this._canvas.height-1)*(h.startBufferLine/this._bufferService.buffers.active.lines.length)-d[h.position||"full"]/2),o[h.position||"full"],Math.round((this._canvas.height-1)*((h.endBufferLine-h.startBufferLine)/this._bufferService.buffers.active.lines.length)+d[h.position||"full"]))}_queueRefresh(h,p){this._shouldUpdateDimensions=h||this._shouldUpdateDimensions,this._shouldUpdateAnchor=p||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};n.OverviewRulerRenderer=i=u([_(2,b.IBufferService),_(3,b.IDecorationService),_(4,f.IRenderService),_(5,b.IOptionsService),_(6,f.ICoreBrowserService)],i)},2950:function(y,n,a){var u=this&&this.__decorate||function(d,o,r,i){var h,p=arguments.length,E=p<3?o:i===null?i=Object.getOwnPropertyDescriptor(o,r):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,o,r,i);else for(var C=d.length-1;C>=0;C--)(h=d[C])&&(E=(p<3?h(E):p>3?h(o,r,E):h(o,r))||E);return p>3&&E&&Object.defineProperty(o,r,E),E},_=this&&this.__param||function(d,o){return function(r,i){o(r,i,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const l=a(4725),f=a(2585),g=a(2584);let b=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(d,o,r,i,h,p){this._textarea=d,this._compositionView=o,this._bufferService=r,this._optionsService=i,this._coreService=h,this._renderService=p,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(d){this._compositionView.textContent=d.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(d){if(this._isComposing||this._isSendingComposition){if(d.keyCode===229||d.keyCode===16||d.keyCode===17||d.keyCode===18)return!1;this._finalizeComposition(!1)}return d.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(d){if(this._compositionView.classList.remove("active"),this._isComposing=!1,d){const o={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let r;this._isSendingComposition=!1,o.start+=this._dataAlreadySent.length,r=this._isComposing?this._textarea.value.substring(o.start,o.end):this._textarea.value.substring(o.start),r.length>0&&this._coreService.triggerDataEvent(r,!0)}},0)}else{this._isSendingComposition=!1;const o=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(o,!0)}}_handleAnyTextareaChanges(){const d=this._textarea.value;setTimeout(()=>{if(!this._isComposing){const o=this._textarea.value,r=o.replace(d,"");this._dataAlreadySent=r,o.length>d.length?this._coreService.triggerDataEvent(r,!0):o.length<d.length?this._coreService.triggerDataEvent(`${g.C0.DEL}`,!0):o.length===d.length&&o!==d&&this._coreService.triggerDataEvent(o,!0)}},0)}updateCompositionElements(d){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const o=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=o*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const p=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(p.width,1)+"px",this._textarea.style.height=Math.max(p.height,1)+"px",this._textarea.style.lineHeight=p.height+"px"}d||setTimeout(()=>this.updateCompositionElements(!0),0)}}};n.CompositionHelper=b=u([_(2,f.IBufferService),_(3,f.IOptionsService),_(4,f.ICoreService),_(5,l.IRenderService)],b)},9806:(y,n)=>{function a(u,_,l){const f=l.getBoundingClientRect(),g=u.getComputedStyle(l),b=parseInt(g.getPropertyValue("padding-left")),d=parseInt(g.getPropertyValue("padding-top"));return[_.clientX-f.left-b,_.clientY-f.top-d]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=a,n.getCoords=function(u,_,l,f,g,b,d,o,r){if(!b)return;const i=a(u,_,l);return i?(i[0]=Math.ceil((i[0]+(r?d/2:0))/d),i[1]=Math.ceil(i[1]/o),i[0]=Math.min(Math.max(i[0],1),f+(r?1:0)),i[1]=Math.min(Math.max(i[1],1),g),i):void 0}},9504:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const u=a(2584);function _(o,r,i,h){const p=o-l(o,i),E=r-l(r,i),C=Math.abs(p-E)-function(w,S,x){let M=0;const k=w-l(w,x),N=S-l(S,x);for(let L=0;L<Math.abs(k-N);L++){const F=f(w,S)==="A"?-1:1,G=x.buffer.lines.get(k+F*L);G!=null&&G.isWrapped&&M++}return M}(o,r,i);return d(C,b(f(o,r),h))}function l(o,r){let i=0,h=r.buffer.lines.get(o),p=h==null?void 0:h.isWrapped;for(;p&&o>=0&&o<r.rows;)i++,h=r.buffer.lines.get(--o),p=h==null?void 0:h.isWrapped;return i}function f(o,r){return o>r?"A":"B"}function g(o,r,i,h,p,E){let C=o,w=r,S="";for(;C!==i||w!==h;)C+=p?1:-1,p&&C>E.cols-1?(S+=E.buffer.translateBufferLineToString(w,!1,o,C),C=0,o=0,w++):!p&&C<0&&(S+=E.buffer.translateBufferLineToString(w,!1,0,o+1),C=E.cols-1,o=C,w--);return S+E.buffer.translateBufferLineToString(w,!1,o,C)}function b(o,r){const i=r?"O":"[";return u.C0.ESC+i+o}function d(o,r){o=Math.floor(o);let i="";for(let h=0;h<o;h++)i+=r;return i}n.moveToCellSequence=function(o,r,i,h){const p=i.buffer.x,E=i.buffer.y;if(!i.buffer.hasScrollback)return function(S,x,M,k,N,L){return _(x,k,N,L).length===0?"":d(g(S,x,S,x-l(x,N),!1,N).length,b("D",L))}(p,E,0,r,i,h)+_(E,r,i,h)+function(S,x,M,k,N,L){let F;F=_(x,k,N,L).length>0?k-l(k,N):x;const G=k,$=function(Q,V,A,D,T,O){let Y;return Y=_(A,D,T,O).length>0?D-l(D,T):V,Q<A&&Y<=D||Q>=A&&Y<D?"C":"D"}(S,x,M,k,N,L);return d(g(S,F,M,G,$==="C",N).length,b($,L))}(p,E,o,r,i,h);let C;if(E===r)return C=p>o?"D":"C",d(Math.abs(p-o),b(C,h));C=E>r?"D":"C";const w=Math.abs(E-r);return d(function(S,x){return x.cols-S}(E>r?o:p,i)+(w-1)*i.cols+1+((E>r?p:o)-1),b(C,h))}},1296:function(y,n,a){var u=this&&this.__decorate||function(L,F,G,$){var Q,V=arguments.length,A=V<3?F:$===null?$=Object.getOwnPropertyDescriptor(F,G):$;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(L,F,G,$);else for(var D=L.length-1;D>=0;D--)(Q=L[D])&&(A=(V<3?Q(A):V>3?Q(F,G,A):Q(F,G))||A);return V>3&&A&&Object.defineProperty(F,G,A),A},_=this&&this.__param||function(L,F){return function(G,$){F(G,$,L)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const l=a(3787),f=a(2550),g=a(2223),b=a(6171),d=a(6052),o=a(4725),r=a(8055),i=a(8460),h=a(844),p=a(2585),E="xterm-dom-renderer-owner-",C="xterm-rows",w="xterm-fg-",S="xterm-bg-",x="xterm-focus",M="xterm-selection";let k=1,N=n.DomRenderer=class extends h.Disposable{constructor(L,F,G,$,Q,V,A,D,T,O,Y,q,se){super(),this._terminal=L,this._document=F,this._element=G,this._screenElement=$,this._viewportElement=Q,this._helperContainer=V,this._linkifier2=A,this._charSizeService=T,this._optionsService=O,this._bufferService=Y,this._coreBrowserService=q,this._themeService=se,this._terminalClass=k++,this._rowElements=[],this._selectionRenderModel=(0,d.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new i.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(M),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,b.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._themeService.onChangeColors(te=>this._injectCss(te))),this._injectCss(this._themeService.colors),this._rowFactory=D.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(E+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(te=>this._handleLinkHover(te))),this.register(this._linkifier2.onHideLinkUnderline(te=>this._handleLinkLeave(te))),this.register((0,h.toDisposable)(()=>{this._element.classList.remove(E+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new f.WidthCache(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(){const L=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*L,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*L),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/L),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/L),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const G of this._rowElements)G.style.width=`${this.dimensions.css.canvas.width}px`,G.style.height=`${this.dimensions.css.cell.height}px`,G.style.lineHeight=`${this.dimensions.css.cell.height}px`,G.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const F=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=F,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(L){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let F=`${this._terminalSelector} .${C} { color: ${L.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;F+=`${this._terminalSelector} .${C} .xterm-dim { color: ${r.color.multiplyOpacity(L.foreground,.5).css};}`,F+=`${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;}`;const G=`blink_underline_${this._terminalClass}`,$=`blink_bar_${this._terminalClass}`,Q=`blink_block_${this._terminalClass}`;F+=`@keyframes ${G} { 50% { border-bottom-style: hidden; }}`,F+=`@keyframes ${$} { 50% { box-shadow: none; }}`,F+=`@keyframes ${Q} { 0% { background-color: ${L.cursor.css}; color: ${L.cursorAccent.css}; } 50% { background-color: inherit; color: ${L.cursor.css}; }}`,F+=`${this._terminalSelector} .${C}.${x} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${G} 1s step-end infinite;}${this._terminalSelector} .${C}.${x} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${$} 1s step-end infinite;}${this._terminalSelector} .${C}.${x} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Q} 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${L.cursor.css}; color: ${L.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${L.cursor.css} !important; color: ${L.cursorAccent.css} !important;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${L.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${L.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${L.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,F+=`${this._terminalSelector} .${M} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${M} div { position: absolute; background-color: ${L.selectionBackgroundOpaque.css};}${this._terminalSelector} .${M} div { position: absolute; background-color: ${L.selectionInactiveBackgroundOpaque.css};}`;for(const[V,A]of L.ansi.entries())F+=`${this._terminalSelector} .${w}${V} { color: ${A.css}; }${this._terminalSelector} .${w}${V}.xterm-dim { color: ${r.color.multiplyOpacity(A,.5).css}; }${this._terminalSelector} .${S}${V} { background-color: ${A.css}; }`;F+=`${this._terminalSelector} .${w}${g.INVERTED_DEFAULT_COLOR} { color: ${r.color.opaque(L.background).css}; }${this._terminalSelector} .${w}${g.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${r.color.multiplyOpacity(r.color.opaque(L.background),.5).css}; }${this._terminalSelector} .${S}${g.INVERTED_DEFAULT_COLOR} { background-color: ${L.foreground.css}; }`,this._themeStyleElement.textContent=F}_setDefaultSpacing(){const L=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${L}px`,this._rowFactory.defaultSpacing=L}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(L,F){for(let G=this._rowElements.length;G<=F;G++){const $=this._document.createElement("div");this._rowContainer.appendChild($),this._rowElements.push($)}for(;this._rowElements.length>F;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(L,F){this._refreshRowElements(L,F),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(x),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(x),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(L,F,G){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(L,F,G),this.renderRows(0,this._bufferService.rows-1),!L||!F)return;this._selectionRenderModel.update(this._terminal,L,F,G);const $=this._selectionRenderModel.viewportStartRow,Q=this._selectionRenderModel.viewportEndRow,V=this._selectionRenderModel.viewportCappedStartRow,A=this._selectionRenderModel.viewportCappedEndRow;if(V>=this._bufferService.rows||A<0)return;const D=this._document.createDocumentFragment();if(G){const T=L[0]>F[0];D.appendChild(this._createSelectionElement(V,T?F[0]:L[0],T?L[0]:F[0],A-V+1))}else{const T=$===V?L[0]:0,O=V===Q?F[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(V,T,O));const Y=A-V-1;if(D.appendChild(this._createSelectionElement(V+1,0,this._bufferService.cols,Y)),V!==A){const q=Q===A?F[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(A,0,q))}}this._selectionContainer.appendChild(D)}_createSelectionElement(L,F,G,$=1){const Q=this._document.createElement("div"),V=F*this.dimensions.css.cell.width;let A=this.dimensions.css.cell.width*(G-F);return V+A>this.dimensions.css.canvas.width&&(A=this.dimensions.css.canvas.width-V),Q.style.height=$*this.dimensions.css.cell.height+"px",Q.style.top=L*this.dimensions.css.cell.height+"px",Q.style.left=`${V}px`,Q.style.width=`${A}px`,Q}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const L of this._rowElements)L.replaceChildren()}renderRows(L,F){const G=this._bufferService.buffer,$=G.ybase+G.y,Q=Math.min(G.x,this._bufferService.cols-1),V=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,D=this._optionsService.rawOptions.cursorInactiveStyle;for(let T=L;T<=F;T++){const O=T+G.ydisp,Y=this._rowElements[T],q=G.lines.get(O);if(!Y||!q)break;Y.replaceChildren(...this._rowFactory.createRow(q,O,O===$,A,D,Q,V,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${E}${this._terminalClass}`}_handleLinkHover(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!0)}_handleLinkLeave(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!1)}_setCellUnderline(L,F,G,$,Q,V){G<0&&(L=0),$<0&&(F=0);const A=this._bufferService.rows-1;G=Math.max(Math.min(G,A),0),$=Math.max(Math.min($,A),0),Q=Math.min(Q,this._bufferService.cols);const D=this._bufferService.buffer,T=D.ybase+D.y,O=Math.min(D.x,Q-1),Y=this._optionsService.rawOptions.cursorBlink,q=this._optionsService.rawOptions.cursorStyle,se=this._optionsService.rawOptions.cursorInactiveStyle;for(let te=G;te<=$;++te){const U=te+D.ydisp,P=this._rowElements[te],W=D.lines.get(U);if(!P||!W)break;P.replaceChildren(...this._rowFactory.createRow(W,U,U===T,q,se,O,Y,this.dimensions.css.cell.width,this._widthCache,V?te===G?L:0:-1,V?(te===$?F:Q)-1:-1))}}};n.DomRenderer=N=u([_(7,p.IInstantiationService),_(8,o.ICharSizeService),_(9,p.IOptionsService),_(10,p.IBufferService),_(11,o.ICoreBrowserService),_(12,o.IThemeService)],N)},3787:function(y,n,a){var u=this&&this.__decorate||function(C,w,S,x){var M,k=arguments.length,N=k<3?w:x===null?x=Object.getOwnPropertyDescriptor(w,S):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,w,S,x);else for(var L=C.length-1;L>=0;L--)(M=C[L])&&(N=(k<3?M(N):k>3?M(w,S,N):M(w,S))||N);return k>3&&N&&Object.defineProperty(w,S,N),N},_=this&&this.__param||function(C,w){return function(S,x){w(S,x,C)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const l=a(2223),f=a(643),g=a(511),b=a(2585),d=a(8055),o=a(4725),r=a(4269),i=a(6171),h=a(3734);let p=n.DomRendererRowFactory=class{constructor(C,w,S,x,M,k,N){this._document=C,this._characterJoinerService=w,this._optionsService=S,this._coreBrowserService=x,this._coreService=M,this._decorationService=k,this._themeService=N,this._workCell=new g.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(C,w,S){this._selectionStart=C,this._selectionEnd=w,this._columnSelectMode=S}createRow(C,w,S,x,M,k,N,L,F,G,$){const Q=[],V=this._characterJoinerService.getJoinedCharacters(w),A=this._themeService.colors;let D,T=C.getNoBgTrimmedLength();S&&T<k+1&&(T=k+1);let O=0,Y="",q=0,se=0,te=0,U=!1,P=0,W=!1,H=0;const J=[],X=G!==-1&&$!==-1;for(let ne=0;ne<T;ne++){C.loadCell(ne,this._workCell);let ue=this._workCell.getWidth();if(ue===0)continue;let de=!1,Ie=ne,re=this._workCell;if(V.length>0&&ne===V[0][0]){de=!0;const he=V.shift();re=new r.JoinedCellData(this._workCell,C.translateToString(!0,he[0],he[1]),he[1]-he[0]),Ie=he[1]-1,ue=re.getWidth()}const pt=this._isCellInSelection(ne,w),vs=S&&ne===k,Ss=X&&ne>=G&&ne<=$;let bs=!1;this._decorationService.forEachDecorationAtCell(ne,w,void 0,he=>{bs=!0});let Tt=re.getChars()||f.WHITESPACE_CELL_CHAR;if(Tt===" "&&(re.isUnderline()||re.isOverline())&&(Tt=" "),H=ue*L-F.get(Tt,re.isBold(),re.isItalic()),D){if(O&&(pt&&W||!pt&&!W&&re.bg===q)&&(pt&&W&&A.selectionForeground||re.fg===se)&&re.extended.ext===te&&Ss===U&&H===P&&!vs&&!de&&!bs){re.isInvisible()?Y+=f.WHITESPACE_CELL_CHAR:Y+=Tt,O++;continue}O&&(D.textContent=Y),D=this._document.createElement("span"),O=0,Y=""}else D=this._document.createElement("span");if(q=re.bg,se=re.fg,te=re.extended.ext,U=Ss,P=H,W=pt,de&&k>=ne&&k<=Ie&&(k=ne),!this._coreService.isCursorHidden&&vs&&this._coreService.isCursorInitialized){if(J.push("xterm-cursor"),this._coreBrowserService.isFocused)N&&J.push("xterm-cursor-blink"),J.push(x==="bar"?"xterm-cursor-bar":x==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(M)switch(M){case"outline":J.push("xterm-cursor-outline");break;case"block":J.push("xterm-cursor-block");break;case"bar":J.push("xterm-cursor-bar");break;case"underline":J.push("xterm-cursor-underline")}}if(re.isBold()&&J.push("xterm-bold"),re.isItalic()&&J.push("xterm-italic"),re.isDim()&&J.push("xterm-dim"),Y=re.isInvisible()?f.WHITESPACE_CELL_CHAR:re.getChars()||f.WHITESPACE_CELL_CHAR,re.isUnderline()&&(J.push(`xterm-underline-${re.extended.underlineStyle}`),Y===" "&&(Y=" "),!re.isUnderlineColorDefault()))if(re.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(re.getUnderlineColor()).join(",")})`;else{let he=re.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&re.isBold()&&he<8&&(he+=8),D.style.textDecorationColor=A.ansi[he].css}re.isOverline()&&(J.push("xterm-overline"),Y===" "&&(Y=" ")),re.isStrikethrough()&&J.push("xterm-strikethrough"),Ss&&(D.style.textDecoration="underline");let Pe=re.getFgColor(),mt=re.getFgColorMode(),je=re.getBgColor(),gt=re.getBgColorMode();const Cs=!!re.isInverse();if(Cs){const he=Pe;Pe=je,je=he;const co=mt;mt=gt,gt=co}let We,kt,$e,vt=!1;switch(this._decorationService.forEachDecorationAtCell(ne,w,void 0,he=>{he.options.layer!=="top"&&vt||(he.backgroundColorRGB&&(gt=50331648,je=he.backgroundColorRGB.rgba>>8&16777215,We=he.backgroundColorRGB),he.foregroundColorRGB&&(mt=50331648,Pe=he.foregroundColorRGB.rgba>>8&16777215,kt=he.foregroundColorRGB),vt=he.options.layer==="top")}),!vt&&pt&&(We=this._coreBrowserService.isFocused?A.selectionBackgroundOpaque:A.selectionInactiveBackgroundOpaque,je=We.rgba>>8&16777215,gt=50331648,vt=!0,A.selectionForeground&&(mt=50331648,Pe=A.selectionForeground.rgba>>8&16777215,kt=A.selectionForeground)),vt&&J.push("xterm-decoration-top"),gt){case 16777216:case 33554432:$e=A.ansi[je],J.push(`xterm-bg-${je}`);break;case 50331648:$e=d.channels.toColor(je>>16,je>>8&255,255&je),this._addStyle(D,`background-color:#${E((je>>>0).toString(16),"0",6)}`);break;default:Cs?($e=A.foreground,J.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):$e=A.background}switch(We||re.isDim()&&(We=d.color.multiplyOpacity($e,.5)),mt){case 16777216:case 33554432:re.isBold()&&Pe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Pe+=8),this._applyMinimumContrast(D,$e,A.ansi[Pe],re,We,void 0)||J.push(`xterm-fg-${Pe}`);break;case 50331648:const he=d.channels.toColor(Pe>>16&255,Pe>>8&255,255&Pe);this._applyMinimumContrast(D,$e,he,re,We,kt)||this._addStyle(D,`color:#${E(Pe.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,$e,A.foreground,re,We,kt)||Cs&&J.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}J.length&&(D.className=J.join(" "),J.length=0),vs||de||bs?D.textContent=Y:O++,H!==this.defaultSpacing&&(D.style.letterSpacing=`${H}px`),Q.push(D),ne=Ie}return D&&O&&(D.textContent=Y),Q}_applyMinimumContrast(C,w,S,x,M,k){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,i.treatGlyphAsBackgroundColor)(x.getCode()))return!1;const N=this._getContrastCache(x);let L;if(M||k||(L=N.getColor(w.rgba,S.rgba)),L===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(x.isDim()?2:1);L=d.color.ensureContrastRatio(M||w,k||S,F),N.setColor((M||w).rgba,(k||S).rgba,L??null)}return!!L&&(this._addStyle(C,`color:${L.css}`),!0)}_getContrastCache(C){return C.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(C,w){C.setAttribute("style",`${C.getAttribute("style")||""}${w};`)}_isCellInSelection(C,w){const S=this._selectionStart,x=this._selectionEnd;return!(!S||!x)&&(this._columnSelectMode?S[0]<=x[0]?C>=S[0]&&w>=S[1]&&C<x[0]&&w<=x[1]:C<S[0]&&w>=S[1]&&C>=x[0]&&w<=x[1]:w>S[1]&&w<x[1]||S[1]===x[1]&&w===S[1]&&C>=S[0]&&C<x[0]||S[1]<x[1]&&w===x[1]&&C<x[0]||S[1]<x[1]&&w===S[1]&&C>=S[0])}};function E(C,w,S){for(;C.length<S;)C=w+C;return C}n.DomRendererRowFactory=p=u([_(1,o.ICharacterJoinerService),_(2,b.IOptionsService),_(3,o.ICoreBrowserService),_(4,b.ICoreService),_(5,b.IDecorationService),_(6,o.IThemeService)],p)},2550:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(a,u){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=a.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const _=a.createElement("span");_.classList.add("xterm-char-measure-element");const l=a.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold";const f=a.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontStyle="italic";const g=a.createElement("span");g.classList.add("xterm-char-measure-element"),g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[_,l,f,g],this._container.appendChild(_),this._container.appendChild(l),this._container.appendChild(f),this._container.appendChild(g),u.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(a,u,_,l){a===this._font&&u===this._fontSize&&_===this._weight&&l===this._weightBold||(this._font=a,this._fontSize=u,this._weight=_,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${_}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${_}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(a,u,_){let l=0;if(!u&&!_&&a.length===1&&(l=a.charCodeAt(0))<256){if(this._flat[l]!==-9999)return this._flat[l];const b=this._measure(a,0);return b>0&&(this._flat[l]=b),b}let f=a;u&&(f+="B"),_&&(f+="I");let g=this._holey.get(f);if(g===void 0){let b=0;u&&(b|=1),_&&(b|=2),g=this._measure(a,b),g>0&&this._holey.set(f,g)}return g}_measure(a,u){const _=this._measureElements[u];return _.textContent=a.repeat(32),_.offsetWidth/32}}},2223:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const u=a(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=u.isFirefox||u.isLegacyEdge?"bottom":"ideographic"},6171:(y,n)=>{function a(_){return 57508<=_&&_<=57558}function u(_){return _>=128512&&_<=128591||_>=127744&&_<=128511||_>=128640&&_<=128767||_>=9728&&_<=9983||_>=9984&&_<=10175||_>=65024&&_<=65039||_>=129280&&_<=129535||_>=127462&&_<=127487}Object.defineProperty(n,"__esModule",{value:!0}),n.computeNextVariantOffset=n.createRenderDimensions=n.treatGlyphAsBackgroundColor=n.allowRescaling=n.isEmoji=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(_){if(!_)throw new Error("value must not be falsy");return _},n.isPowerlineGlyph=a,n.isRestrictedPowerlineGlyph=function(_){return 57520<=_&&_<=57527},n.isEmoji=u,n.allowRescaling=function(_,l,f,g){return l===1&&f>Math.ceil(1.5*g)&&_!==void 0&&_>255&&!u(_)&&!a(_)&&!function(b){return 57344<=b&&b<=63743}(_)},n.treatGlyphAsBackgroundColor=function(_){return a(_)||function(l){return 9472<=l&&l<=9631}(_)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},n.computeNextVariantOffset=function(_,l,f=0){return(_-(2*Math.round(l)-f))%(2*Math.round(l))}},6052:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createSelectionRenderModel=void 0;class a{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(_,l,f,g=!1){if(this.selectionStart=l,this.selectionEnd=f,!l||!f||l[0]===f[0]&&l[1]===f[1])return void this.clear();const b=_.buffers.active.ydisp,d=l[1]-b,o=f[1]-b,r=Math.max(d,0),i=Math.min(o,_.rows-1);r>=_.rows||i<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=g,this.viewportStartRow=d,this.viewportEndRow=o,this.viewportCappedStartRow=r,this.viewportCappedEndRow=i,this.startCol=l[0],this.endCol=f[0])}isCellSelected(_,l,f){return!!this.hasSelection&&(f-=_.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?l>=this.startCol&&f>=this.viewportCappedStartRow&&l<this.endCol&&f<=this.viewportCappedEndRow:l<this.startCol&&f>=this.viewportCappedStartRow&&l>=this.endCol&&f<=this.viewportCappedEndRow:f>this.viewportStartRow&&f<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&f===this.viewportStartRow&&l>=this.startCol&&l<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportEndRow&&l<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportStartRow&&l>=this.startCol)}}n.createSelectionRenderModel=function(){return new a}},456:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(a){this._bufferService=a,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?a%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)-1]:[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[a,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[Math.max(a,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const a=this.selectionStart,u=this.selectionEnd;return!(!a||!u)&&(a[1]>u[1]||a[1]===u[1]&&a[0]>u[0])}handleTrim(a){return this.selectionStart&&(this.selectionStart[1]-=a),this.selectionEnd&&(this.selectionEnd[1]-=a),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(y,n,a){var u=this&&this.__decorate||function(i,h,p,E){var C,w=arguments.length,S=w<3?h:E===null?E=Object.getOwnPropertyDescriptor(h,p):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(i,h,p,E);else for(var x=i.length-1;x>=0;x--)(C=i[x])&&(S=(w<3?C(S):w>3?C(h,p,S):C(h,p))||S);return w>3&&S&&Object.defineProperty(h,p,S),S},_=this&&this.__param||function(i,h){return function(p,E){h(p,E,i)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const l=a(2585),f=a(8460),g=a(844);let b=n.CharSizeService=class extends g.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(i,h,p){super(),this._optionsService=p,this.width=0,this.height=0,this._onCharSizeChange=this.register(new f.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new r(this._optionsService))}catch{this._measureStrategy=this.register(new o(i,h,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}measure(){const i=this._measureStrategy.measure();i.width===this.width&&i.height===this.height||(this.width=i.width,this.height=i.height,this._onCharSizeChange.fire())}};n.CharSizeService=b=u([_(2,l.IOptionsService)],b);class d extends g.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(h,p){h!==void 0&&h>0&&p!==void 0&&p>0&&(this._result.width=h,this._result.height=p)}}class o extends d{constructor(h,p,E){super(),this._document=h,this._parentElement=p,this._optionsService=E,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}}class r extends d{constructor(h){super(),this._optionsService=h,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const p=this._ctx.measureText("W");if(!("width"in p&&"fontBoundingBoxAscent"in p&&"fontBoundingBoxDescent"in p))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const h=this._ctx.measureText("W");return this._validateAndSet(h.width,h.fontBoundingBoxAscent+h.fontBoundingBoxDescent),this._result}}},4269:function(y,n,a){var u=this&&this.__decorate||function(r,i,h,p){var E,C=arguments.length,w=C<3?i:p===null?p=Object.getOwnPropertyDescriptor(i,h):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(r,i,h,p);else for(var S=r.length-1;S>=0;S--)(E=r[S])&&(w=(C<3?E(w):C>3?E(i,h,w):E(i,h))||w);return C>3&&w&&Object.defineProperty(i,h,w),w},_=this&&this.__param||function(r,i){return function(h,p){i(h,p,r)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const l=a(3734),f=a(643),g=a(511),b=a(2585);class d extends l.AttributeData{constructor(i,h,p){super(),this.content=0,this.combinedData="",this.fg=i.fg,this.bg=i.bg,this.combinedData=h,this._width=p}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(i){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=d;let o=n.CharacterJoinerService=class br{constructor(i){this._bufferService=i,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new g.CellData}register(i){const h={id:this._nextCharacterJoinerId++,handler:i};return this._characterJoiners.push(h),h.id}deregister(i){for(let h=0;h<this._characterJoiners.length;h++)if(this._characterJoiners[h].id===i)return this._characterJoiners.splice(h,1),!0;return!1}getJoinedCharacters(i){if(this._characterJoiners.length===0)return[];const h=this._bufferService.buffer.lines.get(i);if(!h||h.length===0)return[];const p=[],E=h.translateToString(!0);let C=0,w=0,S=0,x=h.getFg(0),M=h.getBg(0);for(let k=0;k<h.getTrimmedLength();k++)if(h.loadCell(k,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==x||this._workCell.bg!==M){if(k-C>1){const N=this._getJoinedRanges(E,S,w,h,C);for(let L=0;L<N.length;L++)p.push(N[L])}C=k,S=w,x=this._workCell.fg,M=this._workCell.bg}w+=this._workCell.getChars().length||f.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-C>1){const k=this._getJoinedRanges(E,S,w,h,C);for(let N=0;N<k.length;N++)p.push(k[N])}return p}_getJoinedRanges(i,h,p,E,C){const w=i.substring(h,p);let S=[];try{S=this._characterJoiners[0].handler(w)}catch(x){console.error(x)}for(let x=1;x<this._characterJoiners.length;x++)try{const M=this._characterJoiners[x].handler(w);for(let k=0;k<M.length;k++)br._mergeRanges(S,M[k])}catch(M){console.error(M)}return this._stringRangesToCellRanges(S,E,C),S}_stringRangesToCellRanges(i,h,p){let E=0,C=!1,w=0,S=i[E];if(S){for(let x=p;x<this._bufferService.cols;x++){const M=h.getWidth(x),k=h.getString(x).length||f.WHITESPACE_CELL_CHAR.length;if(M!==0){if(!C&&S[0]<=w&&(S[0]=x,C=!0),S[1]<=w){if(S[1]=x,S=i[++E],!S)break;S[0]<=w?(S[0]=x,C=!0):C=!1}w+=k}}S&&(S[1]=this._bufferService.cols)}}static _mergeRanges(i,h){let p=!1;for(let E=0;E<i.length;E++){const C=i[E];if(p){if(h[1]<=C[0])return i[E-1][1]=h[1],i;if(h[1]<=C[1])return i[E-1][1]=Math.max(h[1],C[1]),i.splice(E,1),i;i.splice(E,1),E--}else{if(h[1]<=C[0])return i.splice(E,0,h),i;if(h[1]<=C[1])return C[0]=Math.min(h[0],C[0]),i;h[0]<C[1]&&(C[0]=Math.min(h[0],C[0]),p=!0)}}return p?i[i.length-1][1]=h[1]:i.push(h),i}};n.CharacterJoinerService=o=u([_(0,b.IBufferService)],o)},5114:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0;const u=a(844),_=a(8460),l=a(3656);class f extends u.Disposable{constructor(d,o,r){super(),this._textarea=d,this._window=o,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new g(this._window),this._onDprChange=this.register(new _.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new _.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this.register((0,_.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",()=>this._isFocused=!0),this._textarea.addEventListener("blur",()=>this._isFocused=!1)}get window(){return this._window}set window(d){this._window!==d&&(this._window=d,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}}n.CoreBrowserService=f;class g extends u.Disposable{constructor(d){super(),this._parentWindow=d,this._windowResizeListener=this.register(new u.MutableDisposable),this._onDprChange=this.register(new _.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,u.toDisposable)(()=>this.clearListener()))}setWindow(d){this._parentWindow=d,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,l.addDisposableDomListener)(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var d;this._outerListener&&((d=this._resolutionMediaMatchList)==null||d.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)}}},779:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LinkProviderService=void 0;const u=a(844);class _ extends u.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,u.toDisposable)(()=>this.linkProviders.length=0))}registerLinkProvider(f){return this.linkProviders.push(f),{dispose:()=>{const g=this.linkProviders.indexOf(f);g!==-1&&this.linkProviders.splice(g,1)}}}}n.LinkProviderService=_},8934:function(y,n,a){var u=this&&this.__decorate||function(b,d,o,r){var i,h=arguments.length,p=h<3?d:r===null?r=Object.getOwnPropertyDescriptor(d,o):r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(b,d,o,r);else for(var E=b.length-1;E>=0;E--)(i=b[E])&&(p=(h<3?i(p):h>3?i(d,o,p):i(d,o))||p);return h>3&&p&&Object.defineProperty(d,o,p),p},_=this&&this.__param||function(b,d){return function(o,r){d(o,r,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const l=a(4725),f=a(9806);let g=n.MouseService=class{constructor(b,d){this._renderService=b,this._charSizeService=d}getCoords(b,d,o,r,i){return(0,f.getCoords)(window,b,d,o,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(b,d){const o=(0,f.getCoordsRelativeToElement)(window,b,d);if(this._charSizeService.hasValidSize)return o[0]=Math.min(Math.max(o[0],0),this._renderService.dimensions.css.canvas.width-1),o[1]=Math.min(Math.max(o[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(o[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(o[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(o[0]),y:Math.floor(o[1])}}};n.MouseService=g=u([_(0,l.IRenderService),_(1,l.ICharSizeService)],g)},3230:function(y,n,a){var u=this&&this.__decorate||function(i,h,p,E){var C,w=arguments.length,S=w<3?h:E===null?E=Object.getOwnPropertyDescriptor(h,p):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(i,h,p,E);else for(var x=i.length-1;x>=0;x--)(C=i[x])&&(S=(w<3?C(S):w>3?C(h,p,S):C(h,p))||S);return w>3&&S&&Object.defineProperty(h,p,S),S},_=this&&this.__param||function(i,h){return function(p,E){h(p,E,i)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const l=a(6193),f=a(4725),g=a(8460),b=a(844),d=a(7226),o=a(2585);let r=n.RenderService=class extends b.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(i,h,p,E,C,w,S,x){super(),this._rowCount=i,this._charSizeService=E,this._renderer=this.register(new b.MutableDisposable),this._pausedResizeTask=new d.DebouncedIdleTask,this._observerDisposable=this.register(new b.MutableDisposable),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 g.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new g.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new g.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new g.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new l.RenderDebouncer((M,k)=>this._renderRows(M,k),S),this.register(this._renderDebouncer),this.register(S.onDprChange(()=>this.handleDevicePixelRatioChange())),this.register(w.onResize(()=>this._fullRefresh())),this.register(w.buffers.onBufferActivate(()=>{var M;return(M=this._renderer.value)==null?void 0:M.clear()})),this.register(p.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this.register(C.onDecorationRegistered(()=>this._fullRefresh())),this.register(C.onDecorationRemoved(()=>this._fullRefresh())),this.register(p.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(w.cols,w.rows),this._fullRefresh()})),this.register(p.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(w.buffer.y,w.buffer.y,!0))),this.register(x.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(S.window,h),this.register(S.onWindowChange(M=>this._registerIntersectionObserver(M,h)))}_registerIntersectionObserver(i,h){if("IntersectionObserver"in i){const p=new i.IntersectionObserver(E=>this._handleIntersectionChange(E[E.length-1]),{threshold:0});p.observe(h),this._observerDisposable.value=(0,b.toDisposable)(()=>p.disconnect())}}_handleIntersectionChange(i){this._isPaused=i.isIntersecting===void 0?i.intersectionRatio===0:!i.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(i,h,p=!1){this._isPaused?this._needsFullRefresh=!0:(p||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(i,h,this._rowCount))}_renderRows(i,h){this._renderer.value&&(i=Math.min(i,this._rowCount-1),h=Math.min(h,this._rowCount-1),this._renderer.value.renderRows(i,h),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:i,end:h}),this._onRender.fire({start:i,end:h}),this._isNextRenderRedrawOnly=!0)}resize(i,h){this._rowCount=h,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(i){this._renderer.value=i,this._renderer.value&&(this._renderer.value.onRequestRedraw(h=>this.refreshRows(h.start,h.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(i){return this._renderDebouncer.addRefreshCallback(i)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var i,h;this._renderer.value&&((h=(i=this._renderer.value).clearTextureAtlas)==null||h.call(i),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(i,h){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var p;return(p=this._renderer.value)==null?void 0:p.handleResize(i,h)}):this._renderer.value.handleResize(i,h),this._fullRefresh())}handleCharSizeChanged(){var i;(i=this._renderer.value)==null||i.handleCharSizeChanged()}handleBlur(){var i;(i=this._renderer.value)==null||i.handleBlur()}handleFocus(){var i;(i=this._renderer.value)==null||i.handleFocus()}handleSelectionChanged(i,h,p){var E;this._selectionState.start=i,this._selectionState.end=h,this._selectionState.columnSelectMode=p,(E=this._renderer.value)==null||E.handleSelectionChanged(i,h,p)}handleCursorMove(){var i;(i=this._renderer.value)==null||i.handleCursorMove()}clear(){var i;(i=this._renderer.value)==null||i.clear()}};n.RenderService=r=u([_(2,o.IOptionsService),_(3,f.ICharSizeService),_(4,o.IDecorationService),_(5,o.IBufferService),_(6,f.ICoreBrowserService),_(7,f.IThemeService)],r)},9312:function(y,n,a){var u=this&&this.__decorate||function(S,x,M,k){var N,L=arguments.length,F=L<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,M):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(S,x,M,k);else for(var G=S.length-1;G>=0;G--)(N=S[G])&&(F=(L<3?N(F):L>3?N(x,M,F):N(x,M))||F);return L>3&&F&&Object.defineProperty(x,M,F),F},_=this&&this.__param||function(S,x){return function(M,k){x(M,k,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const l=a(9806),f=a(9504),g=a(456),b=a(4725),d=a(8460),o=a(844),r=a(6114),i=a(4841),h=a(511),p=a(2585),E=" ",C=new RegExp(E,"g");let w=n.SelectionService=class extends o.Disposable{constructor(S,x,M,k,N,L,F,G,$){super(),this._element=S,this._screenElement=x,this._linkifier=M,this._bufferService=k,this._coreService=N,this._mouseService=L,this._optionsService=F,this._renderService=G,this._coreBrowserService=$,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new h.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new d.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new d.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new d.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new d.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=Q=>this._handleMouseMove(Q),this._mouseUpListener=Q=>this._handleMouseUp(Q),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(Q=>this._handleTrim(Q)),this.register(this._bufferService.buffers.onBufferActivate(Q=>this._handleBufferActivate(Q))),this.enable(),this._model=new g.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,o.toDisposable)(()=>{this._removeMouseDownListeners()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const S=this._model.finalSelectionStart,x=this._model.finalSelectionEnd;return!(!S||!x||S[0]===x[0]&&S[1]===x[1])}get selectionText(){const S=this._model.finalSelectionStart,x=this._model.finalSelectionEnd;if(!S||!x)return"";const M=this._bufferService.buffer,k=[];if(this._activeSelectionMode===3){if(S[0]===x[0])return"";const N=S[0]<x[0]?S[0]:x[0],L=S[0]<x[0]?x[0]:S[0];for(let F=S[1];F<=x[1];F++){const G=M.translateBufferLineToString(F,!0,N,L);k.push(G)}}else{const N=S[1]===x[1]?x[0]:void 0;k.push(M.translateBufferLineToString(S[1],!0,S[0],N));for(let L=S[1]+1;L<=x[1]-1;L++){const F=M.lines.get(L),G=M.translateBufferLineToString(L,!0);F!=null&&F.isWrapped?k[k.length-1]+=G:k.push(G)}if(S[1]!==x[1]){const L=M.lines.get(x[1]),F=M.translateBufferLineToString(x[1],!0,0,x[0]);L&&L.isWrapped?k[k.length-1]+=F:k.push(F)}}return k.map(N=>N.replace(C," ")).join(r.isWindows?`\r `:` `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(S){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),r.isLinux&&S&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(S){const x=this._getMouseBufferCoords(S),M=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!!(M&&k&&x)&&this._areCoordsInSelection(x,M,k)}isCellInSelection(S,x){const M=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!(!M||!k)&&this._areCoordsInSelection([S,x],M,k)}_areCoordsInSelection(S,x,M){return S[1]>x[1]&&S[1]<M[1]||x[1]===M[1]&&S[1]===x[1]&&S[0]>=x[0]&&S[0]<M[0]||x[1]<M[1]&&S[1]===M[1]&&S[0]<M[0]||x[1]<M[1]&&S[1]===x[1]&&S[0]>=x[0]}_selectWordAtCursor(S,x){var N,L;const M=(L=(N=this._linkifier.currentLink)==null?void 0:N.link)==null?void 0:L.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,i.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const k=this._getMouseBufferCoords(S);return!!k&&(this._selectWordAt(k,x),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(S,x){this._model.clearSelection(),S=Math.max(S,0),x=Math.min(x,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,S],this._model.selectionEnd=[this._bufferService.cols,x],this.refresh(),this._onSelectionChange.fire()}_handleTrim(S){this._model.handleTrim(S)&&this.refresh()}_getMouseBufferCoords(S){const x=this._mouseService.getCoords(S,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(x)return x[0]--,x[1]--,x[1]+=this._bufferService.buffer.ydisp,x}_getMouseEventScrollAmount(S){let x=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,S,this._screenElement)[1];const M=this._renderService.dimensions.css.canvas.height;return x>=0&&x<=M?0:(x>M&&(x-=M),x=Math.min(Math.max(x,-50),50),x/=50,x/Math.abs(x)+Math.round(14*x))}shouldForceSelection(S){return r.isMac?S.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:S.shiftKey}handleMouseDown(S){if(this._mouseDownTimeStamp=S.timeStamp,(S.button!==2||!this.hasSelection)&&S.button===0){if(!this._enabled){if(!this.shouldForceSelection(S))return;S.stopPropagation()}S.preventDefault(),this._dragScrollAmount=0,this._enabled&&S.shiftKey?this._handleIncrementalClick(S):S.detail===1?this._handleSingleClick(S):S.detail===2?this._handleDoubleClick(S):S.detail===3&&this._handleTripleClick(S),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(S){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(S))}_handleSingleClick(S){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(S)?3:0,this._model.selectionStart=this._getMouseBufferCoords(S),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const x=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);x&&x.length!==this._model.selectionStart[0]&&x.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(S){this._selectWordAtCursor(S,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(S){const x=this._getMouseBufferCoords(S);x&&(this._activeSelectionMode=2,this._selectLineAt(x[1]))}shouldColumnSelect(S){return S.altKey&&!(r.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(S){if(S.stopImmediatePropagation(),!this._model.selectionStart)return;const x=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(S),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(S),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const M=this._bufferService.buffer;if(this._model.selectionEnd[1]<M.lines.length){const k=M.lines.get(this._model.selectionEnd[1]);k&&k.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}x&&x[0]===this._model.selectionEnd[0]&&x[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const S=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(S.ydisp+this._bufferService.rows,S.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=S.ydisp),this.refresh()}}_handleMouseUp(S){const x=S.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&x<500&&S.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const M=this._mouseService.getCoords(S,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(M&&M[0]!==void 0&&M[1]!==void 0){const k=(0,f.moveToCellSequence)(M[0]-1,M[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(k,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const S=this._model.finalSelectionStart,x=this._model.finalSelectionEnd,M=!(!S||!x||S[0]===x[0]&&S[1]===x[1]);M?S&&x&&(this._oldSelectionStart&&this._oldSelectionEnd&&S[0]===this._oldSelectionStart[0]&&S[1]===this._oldSelectionStart[1]&&x[0]===this._oldSelectionEnd[0]&&x[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(S,x,M)):this._oldHasSelection&&this._fireOnSelectionChange(S,x,M)}_fireOnSelectionChange(S,x,M){this._oldSelectionStart=S,this._oldSelectionEnd=x,this._oldHasSelection=M,this._onSelectionChange.fire()}_handleBufferActivate(S){this.clearSelection(),this._trimListener.dispose(),this._trimListener=S.activeBuffer.lines.onTrim(x=>this._handleTrim(x))}_convertViewportColToCharacterIndex(S,x){let M=x;for(let k=0;x>=k;k++){const N=S.loadCell(k,this._workCell).getChars().length;this._workCell.getWidth()===0?M--:N>1&&x!==k&&(M+=N-1)}return M}setSelection(S,x,M){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[S,x],this._model.selectionStartLength=M,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(S){this._isClickInSelection(S)||(this._selectWordAtCursor(S,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(S,x,M=!0,k=!0){if(S[0]>=this._bufferService.cols)return;const N=this._bufferService.buffer,L=N.lines.get(S[1]);if(!L)return;const F=N.translateBufferLineToString(S[1],!1);let G=this._convertViewportColToCharacterIndex(L,S[0]),$=G;const Q=S[0]-G;let V=0,A=0,D=0,T=0;if(F.charAt(G)===" "){for(;G>0&&F.charAt(G-1)===" ";)G--;for(;$<F.length&&F.charAt($+1)===" ";)$++}else{let q=S[0],se=S[0];L.getWidth(q)===0&&(V++,q--),L.getWidth(se)===2&&(A++,se++);const te=L.getString(se).length;for(te>1&&(T+=te-1,$+=te-1);q>0&&G>0&&!this._isCharWordSeparator(L.loadCell(q-1,this._workCell));){L.loadCell(q-1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===0?(V++,q--):U>1&&(D+=U-1,G-=U-1),G--,q--}for(;se<L.length&&$+1<F.length&&!this._isCharWordSeparator(L.loadCell(se+1,this._workCell));){L.loadCell(se+1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===2?(A++,se++):U>1&&(T+=U-1,$+=U-1),$++,se++}}$++;let O=G+Q-V+D,Y=Math.min(this._bufferService.cols,$-G+V+A-D-T);if(x||F.slice(G,$).trim()!==""){if(M&&O===0&&L.getCodePoint(0)!==32){const q=N.lines.get(S[1]-1);if(q&&L.isWrapped&&q.getCodePoint(this._bufferService.cols-1)!==32){const se=this._getWordAt([this._bufferService.cols-1,S[1]-1],!1,!0,!1);if(se){const te=this._bufferService.cols-se.start;O-=te,Y+=te}}}if(k&&O+Y===this._bufferService.cols&&L.getCodePoint(this._bufferService.cols-1)!==32){const q=N.lines.get(S[1]+1);if(q!=null&&q.isWrapped&&q.getCodePoint(0)!==32){const se=this._getWordAt([0,S[1]+1],!1,!1,!0);se&&(Y+=se.length)}}return{start:O,length:Y}}}_selectWordAt(S,x){const M=this._getWordAt(S,x);if(M){for(;M.start<0;)M.start+=this._bufferService.cols,S[1]--;this._model.selectionStart=[M.start,S[1]],this._model.selectionStartLength=M.length}}_selectToWordAt(S){const x=this._getWordAt(S,!0);if(x){let M=S[1];for(;x.start<0;)x.start+=this._bufferService.cols,M--;if(!this._model.areSelectionValuesReversed())for(;x.start+x.length>this._bufferService.cols;)x.length-=this._bufferService.cols,M++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?x.start:x.start+x.length,M]}}_isCharWordSeparator(S){return S.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(S.getChars())>=0}_selectLineAt(S){const x=this._bufferService.buffer.getWrappedRangeForLine(S),M={start:{x:0,y:x.first},end:{x:this._bufferService.cols-1,y:x.last}};this._model.selectionStart=[0,x.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,i.getRangeLength)(M,this._bufferService.cols)}};n.SelectionService=w=u([_(3,p.IBufferService),_(4,p.ICoreService),_(5,b.IMouseService),_(6,p.IOptionsService),_(7,b.IRenderService),_(8,b.ICoreBrowserService)],w)},4725:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ILinkProviderService=n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const u=a(8343);n.ICharSizeService=(0,u.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,u.createDecorator)("CoreBrowserService"),n.IMouseService=(0,u.createDecorator)("MouseService"),n.IRenderService=(0,u.createDecorator)("RenderService"),n.ISelectionService=(0,u.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,u.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,u.createDecorator)("ThemeService"),n.ILinkProviderService=(0,u.createDecorator)("LinkProviderService")},6731:function(y,n,a){var u=this&&this.__decorate||function(w,S,x,M){var k,N=arguments.length,L=N<3?S:M===null?M=Object.getOwnPropertyDescriptor(S,x):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(w,S,x,M);else for(var F=w.length-1;F>=0;F--)(k=w[F])&&(L=(N<3?k(L):N>3?k(S,x,L):k(S,x))||L);return N>3&&L&&Object.defineProperty(S,x,L),L},_=this&&this.__param||function(w,S){return function(x,M){S(x,M,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const l=a(7239),f=a(8055),g=a(8460),b=a(844),d=a(2585),o=f.css.toColor("#ffffff"),r=f.css.toColor("#000000"),i=f.css.toColor("#ffffff"),h=f.css.toColor("#000000"),p={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const w=[f.css.toColor("#2e3436"),f.css.toColor("#cc0000"),f.css.toColor("#4e9a06"),f.css.toColor("#c4a000"),f.css.toColor("#3465a4"),f.css.toColor("#75507b"),f.css.toColor("#06989a"),f.css.toColor("#d3d7cf"),f.css.toColor("#555753"),f.css.toColor("#ef2929"),f.css.toColor("#8ae234"),f.css.toColor("#fce94f"),f.css.toColor("#729fcf"),f.css.toColor("#ad7fa8"),f.css.toColor("#34e2e2"),f.css.toColor("#eeeeec")],S=[0,95,135,175,215,255];for(let x=0;x<216;x++){const M=S[x/36%6|0],k=S[x/6%6|0],N=S[x%6];w.push({css:f.channels.toCss(M,k,N),rgba:f.channels.toRgba(M,k,N)})}for(let x=0;x<24;x++){const M=8+10*x;w.push({css:f.channels.toCss(M,M,M),rgba:f.channels.toRgba(M,M,M)})}return w})());let E=n.ThemeService=class extends b.Disposable{get colors(){return this._colors}constructor(w){super(),this._optionsService=w,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new g.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:o,background:r,cursor:i,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:p,selectionBackgroundOpaque:f.color.blend(r,p),selectionInactiveBackgroundTransparent:p,selectionInactiveBackgroundOpaque:f.color.blend(r,p),ansi:n.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this.register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}_setTheme(w={}){const S=this._colors;if(S.foreground=C(w.foreground,o),S.background=C(w.background,r),S.cursor=C(w.cursor,i),S.cursorAccent=C(w.cursorAccent,h),S.selectionBackgroundTransparent=C(w.selectionBackground,p),S.selectionBackgroundOpaque=f.color.blend(S.background,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundTransparent=C(w.selectionInactiveBackground,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundOpaque=f.color.blend(S.background,S.selectionInactiveBackgroundTransparent),S.selectionForeground=w.selectionForeground?C(w.selectionForeground,f.NULL_COLOR):void 0,S.selectionForeground===f.NULL_COLOR&&(S.selectionForeground=void 0),f.color.isOpaque(S.selectionBackgroundTransparent)&&(S.selectionBackgroundTransparent=f.color.opacity(S.selectionBackgroundTransparent,.3)),f.color.isOpaque(S.selectionInactiveBackgroundTransparent)&&(S.selectionInactiveBackgroundTransparent=f.color.opacity(S.selectionInactiveBackgroundTransparent,.3)),S.ansi=n.DEFAULT_ANSI_COLORS.slice(),S.ansi[0]=C(w.black,n.DEFAULT_ANSI_COLORS[0]),S.ansi[1]=C(w.red,n.DEFAULT_ANSI_COLORS[1]),S.ansi[2]=C(w.green,n.DEFAULT_ANSI_COLORS[2]),S.ansi[3]=C(w.yellow,n.DEFAULT_ANSI_COLORS[3]),S.ansi[4]=C(w.blue,n.DEFAULT_ANSI_COLORS[4]),S.ansi[5]=C(w.magenta,n.DEFAULT_ANSI_COLORS[5]),S.ansi[6]=C(w.cyan,n.DEFAULT_ANSI_COLORS[6]),S.ansi[7]=C(w.white,n.DEFAULT_ANSI_COLORS[7]),S.ansi[8]=C(w.brightBlack,n.DEFAULT_ANSI_COLORS[8]),S.ansi[9]=C(w.brightRed,n.DEFAULT_ANSI_COLORS[9]),S.ansi[10]=C(w.brightGreen,n.DEFAULT_ANSI_COLORS[10]),S.ansi[11]=C(w.brightYellow,n.DEFAULT_ANSI_COLORS[11]),S.ansi[12]=C(w.brightBlue,n.DEFAULT_ANSI_COLORS[12]),S.ansi[13]=C(w.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),S.ansi[14]=C(w.brightCyan,n.DEFAULT_ANSI_COLORS[14]),S.ansi[15]=C(w.brightWhite,n.DEFAULT_ANSI_COLORS[15]),w.extendedAnsi){const x=Math.min(S.ansi.length-16,w.extendedAnsi.length);for(let M=0;M<x;M++)S.ansi[M+16]=C(w.extendedAnsi[M],n.DEFAULT_ANSI_COLORS[M+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(w){this._restoreColor(w),this._onChangeColors.fire(this.colors)}_restoreColor(w){if(w!==void 0)switch(w){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[w]=this._restoreColors.ansi[w]}else for(let S=0;S<this._restoreColors.ansi.length;++S)this._colors.ansi[S]=this._restoreColors.ansi[S]}modifyColors(w){w(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 C(w,S){if(w!==void 0)try{return f.css.toColor(w)}catch{}return S}n.ThemeService=E=u([_(0,d.IOptionsService)],E)},6349:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const u=a(8460),_=a(844);class l extends _.Disposable{constructor(g){super(),this._maxLength=g,this.onDeleteEmitter=this.register(new u.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new u.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new u.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(g){if(this._maxLength===g)return;const b=new Array(g);for(let d=0;d<Math.min(g,this.length);d++)b[d]=this._array[this._getCyclicIndex(d)];this._array=b,this._maxLength=g,this._startIndex=0}get length(){return this._length}set length(g){if(g>this._length)for(let b=this._length;b<g;b++)this._array[b]=void 0;this._length=g}get(g){return this._array[this._getCyclicIndex(g)]}set(g,b){this._array[this._getCyclicIndex(g)]=b}push(g){this._array[this._getCyclicIndex(this._length)]=g,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(g,b,...d){if(b){for(let o=g;o<this._length-b;o++)this._array[this._getCyclicIndex(o)]=this._array[this._getCyclicIndex(o+b)];this._length-=b,this.onDeleteEmitter.fire({index:g,amount:b})}for(let o=this._length-1;o>=g;o--)this._array[this._getCyclicIndex(o+d.length)]=this._array[this._getCyclicIndex(o)];for(let o=0;o<d.length;o++)this._array[this._getCyclicIndex(g+o)]=d[o];if(d.length&&this.onInsertEmitter.fire({index:g,amount:d.length}),this._length+d.length>this._maxLength){const o=this._length+d.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=d.length}trimStart(g){g>this._length&&(g=this._length),this._startIndex+=g,this._length-=g,this.onTrimEmitter.fire(g)}shiftElements(g,b,d){if(!(b<=0)){if(g<0||g>=this._length)throw new Error("start argument out of range");if(g+d<0)throw new Error("Cannot shift elements in list beyond index 0");if(d>0){for(let r=b-1;r>=0;r--)this.set(g+r+d,this.get(g+r));const o=g+b+d-this._length;if(o>0)for(this._length+=o;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let o=0;o<b;o++)this.set(g+o+d,this.get(g+o))}}_getCyclicIndex(g){return(this._startIndex+g)%this._maxLength}}n.CircularList=l},1439:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function a(u,_=5){if(typeof u!="object")return u;const l=Array.isArray(u)?[]:{};for(const f in u)l[f]=_<=1?u[f]:u[f]&&a(u[f],_-1);return l}},8055:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;let a=0,u=0,_=0,l=0;var f,g,b,d,o;function r(h){const p=h.toString(16);return p.length<2?"0"+p:p}function i(h,p){return h<p?(p+.05)/(h+.05):(h+.05)/(p+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},function(h){h.toCss=function(p,E,C,w){return w!==void 0?`#${r(p)}${r(E)}${r(C)}${r(w)}`:`#${r(p)}${r(E)}${r(C)}`},h.toRgba=function(p,E,C,w=255){return(p<<24|E<<16|C<<8|w)>>>0},h.toColor=function(p,E,C,w){return{css:h.toCss(p,E,C,w),rgba:h.toRgba(p,E,C,w)}}}(f||(n.channels=f={})),function(h){function p(E,C){return l=Math.round(255*C),[a,u,_]=o.toChannels(E.rgba),{css:f.toCss(a,u,_,l),rgba:f.toRgba(a,u,_,l)}}h.blend=function(E,C){if(l=(255&C.rgba)/255,l===1)return{css:C.css,rgba:C.rgba};const w=C.rgba>>24&255,S=C.rgba>>16&255,x=C.rgba>>8&255,M=E.rgba>>24&255,k=E.rgba>>16&255,N=E.rgba>>8&255;return a=M+Math.round((w-M)*l),u=k+Math.round((S-k)*l),_=N+Math.round((x-N)*l),{css:f.toCss(a,u,_),rgba:f.toRgba(a,u,_)}},h.isOpaque=function(E){return(255&E.rgba)==255},h.ensureContrastRatio=function(E,C,w){const S=o.ensureContrastRatio(E.rgba,C.rgba,w);if(S)return f.toColor(S>>24&255,S>>16&255,S>>8&255)},h.opaque=function(E){const C=(255|E.rgba)>>>0;return[a,u,_]=o.toChannels(C),{css:f.toCss(a,u,_),rgba:C}},h.opacity=p,h.multiplyOpacity=function(E,C){return l=255&E.rgba,p(E,l*C/255)},h.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}}(g||(n.color=g={})),function(h){let p,E;try{const C=document.createElement("canvas");C.width=1,C.height=1;const w=C.getContext("2d",{willReadFrequently:!0});w&&(p=w,p.globalCompositeOperation="copy",E=p.createLinearGradient(0,0,1,1))}catch{}h.toColor=function(C){if(C.match(/#[\da-f]{3,8}/i))switch(C.length){case 4:return a=parseInt(C.slice(1,2).repeat(2),16),u=parseInt(C.slice(2,3).repeat(2),16),_=parseInt(C.slice(3,4).repeat(2),16),f.toColor(a,u,_);case 5:return a=parseInt(C.slice(1,2).repeat(2),16),u=parseInt(C.slice(2,3).repeat(2),16),_=parseInt(C.slice(3,4).repeat(2),16),l=parseInt(C.slice(4,5).repeat(2),16),f.toColor(a,u,_,l);case 7:return{css:C,rgba:(parseInt(C.slice(1),16)<<8|255)>>>0};case 9:return{css:C,rgba:parseInt(C.slice(1),16)>>>0}}const w=C.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(w)return a=parseInt(w[1]),u=parseInt(w[2]),_=parseInt(w[3]),l=Math.round(255*(w[5]===void 0?1:parseFloat(w[5]))),f.toColor(a,u,_,l);if(!p||!E)throw new Error("css.toColor: Unsupported css format");if(p.fillStyle=E,p.fillStyle=C,typeof p.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(p.fillRect(0,0,1,1),[a,u,_,l]=p.getImageData(0,0,1,1).data,l!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:f.toRgba(a,u,_,l),css:C}}}(b||(n.css=b={})),function(h){function p(E,C,w){const S=E/255,x=C/255,M=w/255;return .2126*(S<=.03928?S/12.92:Math.pow((S+.055)/1.055,2.4))+.7152*(x<=.03928?x/12.92:Math.pow((x+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}h.relativeLuminance=function(E){return p(E>>16&255,E>>8&255,255&E)},h.relativeLuminance2=p}(d||(n.rgb=d={})),function(h){function p(C,w,S){const x=C>>24&255,M=C>>16&255,k=C>>8&255;let N=w>>24&255,L=w>>16&255,F=w>>8&255,G=i(d.relativeLuminance2(N,L,F),d.relativeLuminance2(x,M,k));for(;G<S&&(N>0||L>0||F>0);)N-=Math.max(0,Math.ceil(.1*N)),L-=Math.max(0,Math.ceil(.1*L)),F-=Math.max(0,Math.ceil(.1*F)),G=i(d.relativeLuminance2(N,L,F),d.relativeLuminance2(x,M,k));return(N<<24|L<<16|F<<8|255)>>>0}function E(C,w,S){const x=C>>24&255,M=C>>16&255,k=C>>8&255;let N=w>>24&255,L=w>>16&255,F=w>>8&255,G=i(d.relativeLuminance2(N,L,F),d.relativeLuminance2(x,M,k));for(;G<S&&(N<255||L<255||F<255);)N=Math.min(255,N+Math.ceil(.1*(255-N))),L=Math.min(255,L+Math.ceil(.1*(255-L))),F=Math.min(255,F+Math.ceil(.1*(255-F))),G=i(d.relativeLuminance2(N,L,F),d.relativeLuminance2(x,M,k));return(N<<24|L<<16|F<<8|255)>>>0}h.blend=function(C,w){if(l=(255&w)/255,l===1)return w;const S=w>>24&255,x=w>>16&255,M=w>>8&255,k=C>>24&255,N=C>>16&255,L=C>>8&255;return a=k+Math.round((S-k)*l),u=N+Math.round((x-N)*l),_=L+Math.round((M-L)*l),f.toRgba(a,u,_)},h.ensureContrastRatio=function(C,w,S){const x=d.relativeLuminance(C>>8),M=d.relativeLuminance(w>>8);if(i(x,M)<S){if(M<x){const L=p(C,w,S),F=i(x,d.relativeLuminance(L>>8));if(F<S){const G=E(C,w,S);return F>i(x,d.relativeLuminance(G>>8))?L:G}return L}const k=E(C,w,S),N=i(x,d.relativeLuminance(k>>8));if(N<S){const L=p(C,w,S);return N>i(x,d.relativeLuminance(L>>8))?k:L}return k}},h.reduceLuminance=p,h.increaseLuminance=E,h.toChannels=function(C){return[C>>24&255,C>>16&255,C>>8&255,255&C]}}(o||(n.rgba=o={})),n.toPaddedHex=r,n.contrastRatio=i},8969:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const u=a(844),_=a(2585),l=a(4348),f=a(7866),g=a(744),b=a(7302),d=a(6975),o=a(8460),r=a(1753),i=a(1480),h=a(7994),p=a(9282),E=a(5435),C=a(5981),w=a(2660);let S=!1;class x extends u.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new o.EventEmitter),this._onScroll.event(k=>{var N;(N=this._onScrollApi)==null||N.fire(k.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(k){for(const N in k)this.optionsService.options[N]=k[N]}constructor(k){super(),this._windowsWrappingHeuristics=this.register(new u.MutableDisposable),this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new o.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new o.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new o.EventEmitter),this._instantiationService=new l.InstantiationService,this.optionsService=this.register(new b.OptionsService(k)),this._instantiationService.setService(_.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(g.BufferService)),this._instantiationService.setService(_.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(f.LogService)),this._instantiationService.setService(_.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(d.CoreService)),this._instantiationService.setService(_.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(r.CoreMouseService)),this._instantiationService.setService(_.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(i.UnicodeService)),this._instantiationService.setService(_.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(_.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(w.OscLinkService),this._instantiationService.setService(_.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new E.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,o.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,o.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,o.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,o.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom())),this.register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this.register(this._bufferService.onScroll(N=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this.register(this._inputHandler.onScroll(N=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this.register(new C.WriteBuffer((N,L)=>this._inputHandler.parse(N,L))),this.register((0,o.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(k,N){this._writeBuffer.write(k,N)}writeSync(k,N){this._logService.logLevel<=_.LogLevelEnum.WARN&&!S&&(this._logService.warn("writeSync is unreliable and will be removed soon."),S=!0),this._writeBuffer.writeSync(k,N)}input(k,N=!0){this.coreService.triggerDataEvent(k,N)}resize(k,N){isNaN(k)||isNaN(N)||(k=Math.max(k,g.MINIMUM_COLS),N=Math.max(N,g.MINIMUM_ROWS),this._bufferService.resize(k,N))}scroll(k,N=!1){this._bufferService.scroll(k,N)}scrollLines(k,N,L){this._bufferService.scrollLines(k,N,L)}scrollPages(k){this.scrollLines(k*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(k){const N=k-this._bufferService.buffer.ydisp;N!==0&&this.scrollLines(N)}registerEscHandler(k,N){return this._inputHandler.registerEscHandler(k,N)}registerDcsHandler(k,N){return this._inputHandler.registerDcsHandler(k,N)}registerCsiHandler(k,N){return this._inputHandler.registerCsiHandler(k,N)}registerOscHandler(k,N){return this._inputHandler.registerOscHandler(k,N)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let k=!1;const N=this.optionsService.rawOptions.windowsPty;N&&N.buildNumber!==void 0&&N.buildNumber!==void 0?k=N.backend==="conpty"&&N.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(k=!0),k?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const k=[];k.push(this.onLineFeed(p.updateWindowsModeWrappedState.bind(null,this._bufferService))),k.push(this.registerCsiHandler({final:"H"},()=>((0,p.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,u.toDisposable)(()=>{for(const N of k)N.dispose()})}}}n.CoreTerminal=x},8460:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.runAndSubscribe=n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=a=>(this._listeners.push(a),{dispose:()=>{if(!this._disposed){for(let u=0;u<this._listeners.length;u++)if(this._listeners[u]===a)return void this._listeners.splice(u,1)}}})),this._event}fire(a,u){const _=[];for(let l=0;l<this._listeners.length;l++)_.push(this._listeners[l]);for(let l=0;l<_.length;l++)_[l].call(void 0,a,u)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(a,u){return a(_=>u.fire(_))},n.runAndSubscribe=function(a,u){return u(void 0),a(_=>u(_))}},5435:function(y,n,a){var u=this&&this.__decorate||function(V,A,D,T){var O,Y=arguments.length,q=Y<3?A:T===null?T=Object.getOwnPropertyDescriptor(A,D):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate(V,A,D,T);else for(var se=V.length-1;se>=0;se--)(O=V[se])&&(q=(Y<3?O(q):Y>3?O(A,D,q):O(A,D))||q);return Y>3&&q&&Object.defineProperty(A,D,q),q},_=this&&this.__param||function(V,A){return function(D,T){A(D,T,V)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const l=a(2584),f=a(7116),g=a(2015),b=a(844),d=a(482),o=a(8437),r=a(8460),i=a(643),h=a(511),p=a(3734),E=a(2585),C=a(1480),w=a(6242),S=a(6351),x=a(5941),M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},k=131072;function N(V,A){if(V>24)return A.setWinLines||!1;switch(V){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var L;(function(V){V[V.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",V[V.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(L||(n.WindowsOptionsReportType=L={}));let F=0;class G extends b.Disposable{getAttrData(){return this._curAttrData}constructor(A,D,T,O,Y,q,se,te,U=new g.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=D,this._coreService=T,this._logService=O,this._optionsService=Y,this._oscLinkService=q,this._coreMouseService=se,this._unicodeService=te,this._parser=U,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new d.StringToUtf32,this._utf8Decoder=new d.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new r.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new r.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new r.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new r.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new r.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new r.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new r.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new r.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new r.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new r.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new r.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new r.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new r.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new $(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(P=>this._activeBuffer=P.activeBuffer)),this._parser.setCsiHandlerFallback((P,W)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(P),params:W.toArray()})}),this._parser.setEscHandlerFallback(P=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(P)})}),this._parser.setExecuteHandlerFallback(P=>{this._logService.debug("Unknown EXECUTE code: ",{code:P})}),this._parser.setOscHandlerFallback((P,W,H)=>{this._logService.debug("Unknown OSC code: ",{identifier:P,action:W,data:H})}),this._parser.setDcsHandlerFallback((P,W,H)=>{W==="HOOK"&&(H=H.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(P),action:W,payload:H})}),this._parser.setPrintHandler((P,W,H)=>this.print(P,W,H)),this._parser.registerCsiHandler({final:"@"},P=>this.insertChars(P)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},P=>this.scrollLeft(P)),this._parser.registerCsiHandler({final:"A"},P=>this.cursorUp(P)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},P=>this.scrollRight(P)),this._parser.registerCsiHandler({final:"B"},P=>this.cursorDown(P)),this._parser.registerCsiHandler({final:"C"},P=>this.cursorForward(P)),this._parser.registerCsiHandler({final:"D"},P=>this.cursorBackward(P)),this._parser.registerCsiHandler({final:"E"},P=>this.cursorNextLine(P)),this._parser.registerCsiHandler({final:"F"},P=>this.cursorPrecedingLine(P)),this._parser.registerCsiHandler({final:"G"},P=>this.cursorCharAbsolute(P)),this._parser.registerCsiHandler({final:"H"},P=>this.cursorPosition(P)),this._parser.registerCsiHandler({final:"I"},P=>this.cursorForwardTab(P)),this._parser.registerCsiHandler({final:"J"},P=>this.eraseInDisplay(P,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},P=>this.eraseInDisplay(P,!0)),this._parser.registerCsiHandler({final:"K"},P=>this.eraseInLine(P,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},P=>this.eraseInLine(P,!0)),this._parser.registerCsiHandler({final:"L"},P=>this.insertLines(P)),this._parser.registerCsiHandler({final:"M"},P=>this.deleteLines(P)),this._parser.registerCsiHandler({final:"P"},P=>this.deleteChars(P)),this._parser.registerCsiHandler({final:"S"},P=>this.scrollUp(P)),this._parser.registerCsiHandler({final:"T"},P=>this.scrollDown(P)),this._parser.registerCsiHandler({final:"X"},P=>this.eraseChars(P)),this._parser.registerCsiHandler({final:"Z"},P=>this.cursorBackwardTab(P)),this._parser.registerCsiHandler({final:"`"},P=>this.charPosAbsolute(P)),this._parser.registerCsiHandler({final:"a"},P=>this.hPositionRelative(P)),this._parser.registerCsiHandler({final:"b"},P=>this.repeatPrecedingCharacter(P)),this._parser.registerCsiHandler({final:"c"},P=>this.sendDeviceAttributesPrimary(P)),this._parser.registerCsiHandler({prefix:">",final:"c"},P=>this.sendDeviceAttributesSecondary(P)),this._parser.registerCsiHandler({final:"d"},P=>this.linePosAbsolute(P)),this._parser.registerCsiHandler({final:"e"},P=>this.vPositionRelative(P)),this._parser.registerCsiHandler({final:"f"},P=>this.hVPosition(P)),this._parser.registerCsiHandler({final:"g"},P=>this.tabClear(P)),this._parser.registerCsiHandler({final:"h"},P=>this.setMode(P)),this._parser.registerCsiHandler({prefix:"?",final:"h"},P=>this.setModePrivate(P)),this._parser.registerCsiHandler({final:"l"},P=>this.resetMode(P)),this._parser.registerCsiHandler({prefix:"?",final:"l"},P=>this.resetModePrivate(P)),this._parser.registerCsiHandler({final:"m"},P=>this.charAttributes(P)),this._parser.registerCsiHandler({final:"n"},P=>this.deviceStatus(P)),this._parser.registerCsiHandler({prefix:"?",final:"n"},P=>this.deviceStatusPrivate(P)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},P=>this.softReset(P)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},P=>this.setCursorStyle(P)),this._parser.registerCsiHandler({final:"r"},P=>this.setScrollRegion(P)),this._parser.registerCsiHandler({final:"s"},P=>this.saveCursor(P)),this._parser.registerCsiHandler({final:"t"},P=>this.windowOptions(P)),this._parser.registerCsiHandler({final:"u"},P=>this.restoreCursor(P)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},P=>this.insertColumns(P)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},P=>this.deleteColumns(P)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},P=>this.selectProtected(P)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},P=>this.requestMode(P,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},P=>this.requestMode(P,!1)),this._parser.setExecuteHandler(l.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(l.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(l.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(l.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(l.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(l.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(l.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(l.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(l.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(l.C1.IND,()=>this.index()),this._parser.setExecuteHandler(l.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(l.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new w.OscHandler(P=>(this.setTitle(P),this.setIconName(P),!0))),this._parser.registerOscHandler(1,new w.OscHandler(P=>this.setIconName(P))),this._parser.registerOscHandler(2,new w.OscHandler(P=>this.setTitle(P))),this._parser.registerOscHandler(4,new w.OscHandler(P=>this.setOrReportIndexedColor(P))),this._parser.registerOscHandler(8,new w.OscHandler(P=>this.setHyperlink(P))),this._parser.registerOscHandler(10,new w.OscHandler(P=>this.setOrReportFgColor(P))),this._parser.registerOscHandler(11,new w.OscHandler(P=>this.setOrReportBgColor(P))),this._parser.registerOscHandler(12,new w.OscHandler(P=>this.setOrReportCursorColor(P))),this._parser.registerOscHandler(104,new w.OscHandler(P=>this.restoreIndexedColor(P))),this._parser.registerOscHandler(110,new w.OscHandler(P=>this.restoreFgColor(P))),this._parser.registerOscHandler(111,new w.OscHandler(P=>this.restoreBgColor(P))),this._parser.registerOscHandler(112,new w.OscHandler(P=>this.restoreCursorColor(P))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(const P in f.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:P},()=>this.selectCharset("("+P)),this._parser.registerEscHandler({intermediates:")",final:P},()=>this.selectCharset(")"+P)),this._parser.registerEscHandler({intermediates:"*",final:P},()=>this.selectCharset("*"+P)),this._parser.registerEscHandler({intermediates:"+",final:P},()=>this.selectCharset("+"+P)),this._parser.registerEscHandler({intermediates:"-",final:P},()=>this.selectCharset("-"+P)),this._parser.registerEscHandler({intermediates:".",final:P},()=>this.selectCharset("."+P)),this._parser.registerEscHandler({intermediates:"/",final:P},()=>this.selectCharset("/"+P));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(P=>(this._logService.error("Parsing error: ",P),P)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new S.DcsHandler((P,W)=>this.requestStatusString(P,W)))}_preserveStack(A,D,T,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=D,this._parseStack.decodedLength=T,this._parseStack.position=O}_logSlowResolvingAsync(A){this._logService.logLevel<=E.LogLevelEnum.WARN&&Promise.race([A,new Promise((D,T)=>setTimeout(()=>T("#SLOW_TIMEOUT"),5e3))]).catch(D=>{if(D!=="#SLOW_TIMEOUT")throw D;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,D){let T,O=this._activeBuffer.x,Y=this._activeBuffer.y,q=0;const se=this._parseStack.paused;if(se){if(T=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,D))return this._logSlowResolvingAsync(T),T;O=this._parseStack.cursorStartX,Y=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>k&&(q=this._parseStack.position+k)}if(this._logService.logLevel<=E.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,P=>String.fromCharCode(P)).join("")}"`),typeof A=="string"?A.split("").map(P=>P.charCodeAt(0)):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<k&&(this._parseBuffer=new Uint32Array(Math.min(A.length,k))),se||this._dirtyRowTracker.clearRange(),A.length>k)for(let P=q;P<A.length;P+=k){const W=P+k<A.length?P+k:A.length,H=typeof A=="string"?this._stringDecoder.decode(A.substring(P,W),this._parseBuffer):this._utf8Decoder.decode(A.subarray(P,W),this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,H))return this._preserveStack(O,Y,H,P),this._logSlowResolvingAsync(T),T}else if(!se){const P=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,P))return this._preserveStack(O,Y,P,0),this._logSlowResolvingAsync(T),T}this._activeBuffer.x===O&&this._activeBuffer.y===Y||this._onCursorMove.fire();const te=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),U=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);U<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(U,this._bufferService.rows-1),Math.min(te,this._bufferService.rows-1))}print(A,D,T){let O,Y;const q=this._charsetService.charset,se=this._optionsService.rawOptions.screenReaderMode,te=this._bufferService.cols,U=this._coreService.decPrivateModes.wraparound,P=this._coreService.modes.insertMode,W=this._curAttrData;let H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&T-D>0&&H.getWidth(this._activeBuffer.x-1)===2&&H.setCellFromCodepoint(this._activeBuffer.x-1,0,1,W);let J=this._parser.precedingJoinState;for(let X=D;X<T;++X){if(O=A[X],O<127&&q){const Ie=q[String.fromCharCode(O)];Ie&&(O=Ie.charCodeAt(0))}const ne=this._unicodeService.charProperties(O,J);Y=C.UnicodeService.extractWidth(ne);const ue=C.UnicodeService.extractShouldJoin(ne),de=ue?C.UnicodeService.extractWidth(J):0;if(J=ne,se&&this._onA11yChar.fire((0,d.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+Y-de>te){if(U){const Ie=H;let re=this._activeBuffer.x-de;for(this._activeBuffer.x=de,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),H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),de>0&&H instanceof o.BufferLine&&H.copyCellsFrom(Ie,re,0,de,!1);re<te;)Ie.setCellFromCodepoint(re++,0,1,W)}else if(this._activeBuffer.x=te-1,Y===2)continue}if(ue&&this._activeBuffer.x){const Ie=H.getWidth(this._activeBuffer.x-1)?1:2;H.addCodepointToCell(this._activeBuffer.x-Ie,O,Y);for(let re=Y-de;--re>=0;)H.setCellFromCodepoint(this._activeBuffer.x++,0,0,W)}else if(P&&(H.insertCells(this._activeBuffer.x,Y-de,this._activeBuffer.getNullCell(W)),H.getWidth(te-1)===2&&H.setCellFromCodepoint(te-1,i.NULL_CELL_CODE,i.NULL_CELL_WIDTH,W)),H.setCellFromCodepoint(this._activeBuffer.x++,O,Y,W),Y>0)for(;--Y;)H.setCellFromCodepoint(this._activeBuffer.x++,0,0,W)}this._parser.precedingJoinState=J,this._activeBuffer.x<te&&T-D>0&&H.getWidth(this._activeBuffer.x)===0&&!H.hasContent(this._activeBuffer.x)&&H.setCellFromCodepoint(this._activeBuffer.x,0,1,W),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,D){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,D):this._parser.registerCsiHandler(A,T=>!N(T.params[0],this._optionsService.rawOptions.windowOptions)||D(T))}registerDcsHandler(A,D){return this._parser.registerDcsHandler(A,new S.DcsHandler(D))}registerEscHandler(A,D){return this._parser.registerEscHandler(A,D)}registerOscHandler(A,D){return this._parser.registerOscHandler(A,new w.OscHandler(D))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);D.hasWidth(this._activeBuffer.x)&&!D.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,D){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+D):(this._activeBuffer.x=A,this._activeBuffer.y=D),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,D){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+D)}cursorUp(A){const D=this._activeBuffer.y-this._activeBuffer.scrollTop;return D>=0?this._moveCursor(0,-Math.min(D,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const D=this._activeBuffer.scrollBottom-this._activeBuffer.y;return D>=0?this._moveCursor(0,Math.min(D,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const D=A.params[0];return D===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:D===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=A.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=A.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const D=A.params[0];return D===1&&(this._curAttrData.bg|=536870912),D!==2&&D!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,D,T,O=!1,Y=!1){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);q.replaceCells(D,T,this._activeBuffer.getNullCell(this._eraseAttrData()),Y),O&&(q.isWrapped=!1)}_resetBufferLine(A,D=!1){const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);T&&(T.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),D),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),T.isWrapped=!1)}eraseInDisplay(A,D=!1){let T;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(T=this._activeBuffer.y,this._dirtyRowTracker.markDirty(T),this._eraseInBufferLine(T++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,D);T<this._bufferService.rows;T++)this._resetBufferLine(T,D);this._dirtyRowTracker.markDirty(T);break;case 1:for(T=this._activeBuffer.y,this._dirtyRowTracker.markDirty(T),this._eraseInBufferLine(T,0,this._activeBuffer.x+1,!0,D),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(T+1).isWrapped=!1);T--;)this._resetBufferLine(T,D);this._dirtyRowTracker.markDirty(0);break;case 2:for(T=this._bufferService.rows,this._dirtyRowTracker.markDirty(T-1);T--;)this._resetBufferLine(T,D);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(A,D=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,D);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,D);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,D)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let D=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,Y=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;D--;)this._activeBuffer.lines.splice(Y-1,1),this._activeBuffer.lines.splice(T,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let D=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;D--;)this._activeBuffer.lines.splice(T,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let D=A.params[0]||1;for(;D--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let D=A.params[0]||1;for(;D--;)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(o.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.deleteCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData())),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.insertCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData())),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.insertCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData())),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.deleteCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData())),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){const D=this._parser.precedingJoinState;if(!D)return!0;const T=A.params[0]||1,O=C.UnicodeService.extractWidth(D),Y=this._activeBuffer.x-O,q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(Y),se=new Uint32Array(q.length*T);let te=0;for(let P=0;P<q.length;){const W=q.codePointAt(P)||0;se[te++]=W,P+=W>65535?2:1}let U=te;for(let P=1;P<T;++P)se.copyWithin(U,0,te),U+=te;return this.print(se,0,U),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(l.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(l.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(l.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(l.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let D=0;D<A.length;D++)switch(A.params[D]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let D=0;D<A.length;D++)switch(A.params[D]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),this._charsetService.setgCharset(1,f.DEFAULT_CHARSET),this._charsetService.setgCharset(2,f.DEFAULT_CHARSET),this._charsetService.setgCharset(3,f.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let D=0;D<A.length;D++)switch(A.params[D]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let D=0;D<A.length;D++)switch(A.params[D]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[D]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,D){const T=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:Y}=this._coreMouseService,q=this._coreService,{buffers:se,cols:te}=this._bufferService,{active:U,alt:P}=se,W=this._optionsService.rawOptions,H=ue=>ue?1:2,J=A.params[0];return X=J,ne=D?J===2?4:J===4?H(q.modes.insertMode):J===12?3:J===20?H(W.convertEol):0:J===1?H(T.applicationCursorKeys):J===3?W.windowOptions.setWinLines?te===80?2:te===132?1:0:0:J===6?H(T.origin):J===7?H(T.wraparound):J===8?3:J===9?H(O==="X10"):J===12?H(W.cursorBlink):J===25?H(!q.isCursorHidden):J===45?H(T.reverseWraparound):J===66?H(T.applicationKeypad):J===67?4:J===1e3?H(O==="VT200"):J===1002?H(O==="DRAG"):J===1003?H(O==="ANY"):J===1004?H(T.sendFocus):J===1005?4:J===1006?H(Y==="SGR"):J===1015?4:J===1016?H(Y==="SGR_PIXELS"):J===1048?1:J===47||J===1047||J===1049?H(U===P):J===2004?H(T.bracketedPasteMode):0,q.triggerDataEvent(`${l.C0.ESC}[${D?"":"?"}${X};${ne}$y`),!0;var X,ne}_updateAttrColor(A,D,T,O,Y){return D===2?(A|=50331648,A&=-16777216,A|=p.AttributeData.fromColorRGB([T,O,Y])):D===5&&(A&=-50331904,A|=33554432|255&T),A}_extractColor(A,D,T){const O=[0,0,-1,0,0,0];let Y=0,q=0;do{if(O[q+Y]=A.params[D+q],A.hasSubParams(D+q)){const se=A.getSubParams(D+q);let te=0;do O[1]===5&&(Y=1),O[q+te+1+Y]=se[te];while(++te<se.length&&te+q+1+Y<O.length);break}if(O[1]===5&&q+Y>=2||O[1]===2&&q+Y>=5)break;O[1]&&(Y=1)}while(++q+D<A.length&&q+Y<O.length);for(let se=2;se<O.length;++se)O[se]===-1&&(O[se]=0);switch(O[0]){case 38:T.fg=this._updateAttrColor(T.fg,O[1],O[3],O[4],O[5]);break;case 48:T.bg=this._updateAttrColor(T.bg,O[1],O[3],O[4],O[5]);break;case 58:T.extended=T.extended.clone(),T.extended.underlineColor=this._updateAttrColor(T.extended.underlineColor,O[1],O[3],O[4],O[5])}return q}_processUnderline(A,D){D.extended=D.extended.clone(),(!~A||A>5)&&(A=1),D.extended.underlineStyle=A,D.fg|=268435456,A===0&&(D.fg&=-268435457),D.updateExtended()}_processSGR0(A){A.fg=o.DEFAULT_ATTR_DATA.fg,A.bg=o.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const D=A.length;let T;const O=this._curAttrData;for(let Y=0;Y<D;Y++)T=A.params[Y],T>=30&&T<=37?(O.fg&=-50331904,O.fg|=16777216|T-30):T>=40&&T<=47?(O.bg&=-50331904,O.bg|=16777216|T-40):T>=90&&T<=97?(O.fg&=-50331904,O.fg|=16777224|T-90):T>=100&&T<=107?(O.bg&=-50331904,O.bg|=16777224|T-100):T===0?this._processSGR0(O):T===1?O.fg|=134217728:T===3?O.bg|=67108864:T===4?(O.fg|=268435456,this._processUnderline(A.hasSubParams(Y)?A.getSubParams(Y)[0]:1,O)):T===5?O.fg|=536870912:T===7?O.fg|=67108864:T===8?O.fg|=1073741824:T===9?O.fg|=2147483648:T===2?O.bg|=134217728:T===21?this._processUnderline(2,O):T===22?(O.fg&=-134217729,O.bg&=-134217729):T===23?O.bg&=-67108865:T===24?(O.fg&=-268435457,this._processUnderline(0,O)):T===25?O.fg&=-536870913:T===27?O.fg&=-67108865:T===28?O.fg&=-1073741825:T===29?O.fg&=2147483647:T===39?(O.fg&=-67108864,O.fg|=16777215&o.DEFAULT_ATTR_DATA.fg):T===49?(O.bg&=-67108864,O.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):T===38||T===48||T===58?Y+=this._extractColor(A,Y,O):T===53?O.bg|=1073741824:T===55?O.bg&=-1073741825:T===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):T===100?(O.fg&=-67108864,O.fg|=16777215&o.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",T);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const D=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${D};${T}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const D=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${D};${T}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const D=A.params[0]||1;switch(D){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const T=D%2==1;return this._optionsService.options.cursorBlink=T,!0}setScrollRegion(A){const D=A.params[0]||1;let T;return(A.length<2||(T=A.params[1])>this._bufferService.rows||T===0)&&(T=this._bufferService.rows),T>D&&(this._activeBuffer.scrollTop=D-1,this._activeBuffer.scrollBottom=T-1,this._setCursor(0,0)),!0}windowOptions(A){if(!N(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const D=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:D!==2&&this._onRequestWindowsOptionsReport.fire(L.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(L.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${l.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:D!==0&&D!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),D!==0&&D!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:D!==0&&D!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),D!==0&&D!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const D=[],T=A.split(";");for(;T.length>1;){const O=T.shift(),Y=T.shift();if(/^\d+$/.exec(O)){const q=parseInt(O);if(Q(q))if(Y==="?")D.push({type:0,index:q});else{const se=(0,x.parseColor)(Y);se&&D.push({type:1,index:q,color:se})}}}return D.length&&this._onColor.fire(D),!0}setHyperlink(A){const D=A.split(";");return!(D.length<2)&&(D[1]?this._createHyperlink(D[0],D[1]):!D[0]&&this._finishHyperlink())}_createHyperlink(A,D){this._getCurrentLinkId()&&this._finishHyperlink();const T=A.split(":");let O;const Y=T.findIndex(q=>q.startsWith("id="));return Y!==-1&&(O=T[Y].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:D}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,D){const T=A.split(";");for(let O=0;O<T.length&&!(D>=this._specialColors.length);++O,++D)if(T[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[D]}]);else{const Y=(0,x.parseColor)(T[O]);Y&&this._onColor.fire([{type:1,index:this._specialColors[D],color:Y}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const D=[],T=A.split(";");for(let O=0;O<T.length;++O)if(/^\d+$/.exec(T[O])){const Y=parseInt(T[O]);Q(Y)&&D.push({type:2,index:Y})}return D.length&&this._onColor.fire(D),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(M[A[0]],f.CHARSETS[A[1]]||f.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new h.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let D=0;D<this._bufferService.rows;++D){const T=this._activeBuffer.ybase+this._activeBuffer.y+D,O=this._activeBuffer.lines.get(T);O&&(O.fill(A),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,D){const T=this._bufferService.buffer,O=this._optionsService.rawOptions;return(Y=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${Y}${l.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${T.scrollTop+1};${T.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,D){this._dirtyRowTracker.markRangeDirty(A,D)}}n.InputHandler=G;let $=class{constructor(V){this._bufferService=V,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(V){V<this.start?this.start=V:V>this.end&&(this.end=V)}markRangeDirty(V,A){V>A&&(F=V,V=A,A=F),V<this.start&&(this.start=V),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Q(V){return 0<=V&&V<256}$=u([_(0,E.IBufferService)],$)},844:(y,n)=>{function a(u){for(const _ of u)_.dispose();u.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const u of this._disposables)u.dispose();this._disposables.length=0}register(u){return this._disposables.push(u),u}unregister(u){const _=this._disposables.indexOf(u);_!==-1&&this._disposables.splice(_,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(u){var _;this._isDisposed||u===this._value||((_=this._value)==null||_.dispose(),this._value=u)}clear(){this.value=void 0}dispose(){var u;this._isDisposed=!0,(u=this._value)==null||u.dispose(),this._value=void 0}},n.toDisposable=function(u){return{dispose:u}},n.disposeArray=a,n.getDisposeArrayDisposable=function(u){return{dispose:()=>a(u)}}},1505:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class a{constructor(){this._data={}}set(_,l,f){this._data[_]||(this._data[_]={}),this._data[_][l]=f}get(_,l){return this._data[_]?this._data[_][l]:void 0}clear(){this._data={}}}n.TwoKeyMap=a,n.FourKeyMap=class{constructor(){this._data=new a}set(u,_,l,f,g){this._data.get(u,_)||this._data.set(u,_,new a),this._data.get(u,_).set(l,f,g)}get(u,_,l,f){var g;return(g=this._data.get(u,_))==null?void 0:g.get(l,f)}clear(){this._data.clear()}}},6114:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof process<"u"&&"title"in process;const a=n.isNode?"node":navigator.userAgent,u=n.isNode?"node":navigator.platform;n.isFirefox=a.includes("Firefox"),n.isLegacyEdge=a.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(a),n.getSafariVersion=function(){if(!n.isSafari)return 0;const _=a.match(/Version\/(\d+)/);return _===null||_.length<2?0:parseInt(_[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(u),n.isIpad=u==="iPad",n.isIphone=u==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(u),n.isLinux=u.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(a)},6106:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let a=0;n.SortedList=class{constructor(u){this._getKey=u,this._array=[]}clear(){this._array.length=0}insert(u){this._array.length!==0?(a=this._search(this._getKey(u)),this._array.splice(a,0,u)):this._array.push(u)}delete(u){if(this._array.length===0)return!1;const _=this._getKey(u);if(_===void 0||(a=this._search(_),a===-1)||this._getKey(this._array[a])!==_)return!1;do if(this._array[a]===u)return this._array.splice(a,1),!0;while(++a<this._array.length&&this._getKey(this._array[a])===_);return!1}*getKeyIterator(u){if(this._array.length!==0&&(a=this._search(u),!(a<0||a>=this._array.length)&&this._getKey(this._array[a])===u))do yield this._array[a];while(++a<this._array.length&&this._getKey(this._array[a])===u)}forEachByKey(u,_){if(this._array.length!==0&&(a=this._search(u),!(a<0||a>=this._array.length)&&this._getKey(this._array[a])===u))do _(this._array[a]);while(++a<this._array.length&&this._getKey(this._array[a])===u)}values(){return[...this._array].values()}_search(u){let _=0,l=this._array.length-1;for(;l>=_;){let f=_+l>>1;const g=this._getKey(this._array[f]);if(g>u)l=f-1;else{if(!(g<u)){for(;f>0&&this._getKey(this._array[f-1])===u;)f--;return f}_=f+1}}return _}}},7226:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const u=a(6114);class _{constructor(){this._tasks=[],this._i=0}enqueue(g){this._tasks.push(g),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(g){this._idleCallback=void 0;let b=0,d=0,o=g.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(b=Date.now(),this._tasks[this._i]()||this._i++,b=Math.max(1,Date.now()-b),d=Math.max(b,d),r=g.timeRemaining(),1.5*d>r)return o-b<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(o-b))}ms`),void this._start();o=r}this.clear()}}class l extends _{_requestCallback(g){return setTimeout(()=>g(this._createDeadline(16)))}_cancelCallback(g){clearTimeout(g)}_createDeadline(g){const b=Date.now()+g;return{timeRemaining:()=>Math.max(0,b-Date.now())}}}n.PriorityTaskQueue=l,n.IdleTaskQueue=!u.isNode&&"requestIdleCallback"in window?class extends _{_requestCallback(f){return requestIdleCallback(f)}_cancelCallback(f){cancelIdleCallback(f)}}:l,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(f){this._queue.clear(),this._queue.enqueue(f)}flush(){this._queue.flush()}}},9282:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const u=a(643);n.updateWindowsModeWrappedState=function(_){const l=_.buffer.lines.get(_.buffer.ybase+_.buffer.y-1),f=l==null?void 0:l.get(_.cols-1),g=_.buffer.lines.get(_.buffer.ybase+_.buffer.y);g&&f&&(g.isWrapped=f[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&f[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)}},3734:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class a{constructor(){this.fg=0,this.bg=0,this.extended=new u}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){const l=new a;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}n.AttributeData=a;class u{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}get underlineVariantOffset(){const l=(3758096384&this._ext)>>29;return l<0?4294967288^l:l}set underlineVariantOffset(l){this._ext&=536870911,this._ext|=l<<29&3758096384}constructor(l=0,f=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=f}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=u},9092:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const u=a(6349),_=a(7226),l=a(3734),f=a(8437),g=a(4634),b=a(511),d=a(643),o=a(4863),r=a(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(i,h,p){this._hasScrollback=i,this._optionsService=h,this._bufferService=p,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=f.DEFAULT_ATTR_DATA.clone(),this.savedCharset=r.DEFAULT_CHARSET,this.markers=[],this._nullCell=b.CellData.fromCharData([0,d.NULL_CELL_CHAR,d.NULL_CELL_WIDTH,d.NULL_CELL_CODE]),this._whitespaceCell=b.CellData.fromCharData([0,d.WHITESPACE_CELL_CHAR,d.WHITESPACE_CELL_WIDTH,d.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new _.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(i){return i?(this._nullCell.fg=i.fg,this._nullCell.bg=i.bg,this._nullCell.extended=i.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new l.ExtendedAttrs),this._nullCell}getWhitespaceCell(i){return i?(this._whitespaceCell.fg=i.fg,this._whitespaceCell.bg=i.bg,this._whitespaceCell.extended=i.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new l.ExtendedAttrs),this._whitespaceCell}getBlankLine(i,h){return new f.BufferLine(this._bufferService.cols,this.getNullCell(i),h)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const i=this.ybase+this.y-this.ydisp;return i>=0&&i<this._rows}_getCorrectBufferLength(i){if(!this._hasScrollback)return i;const h=i+this._optionsService.rawOptions.scrollback;return h>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:h}fillViewportRows(i){if(this.lines.length===0){i===void 0&&(i=f.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(i))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(i,h){const p=this.getNullCell(f.DEFAULT_ATTR_DATA);let E=0;const C=this._getCorrectBufferLength(h);if(C>this.lines.maxLength&&(this.lines.maxLength=C),this.lines.length>0){if(this._cols<i)for(let S=0;S<this.lines.length;S++)E+=+this.lines.get(S).resize(i,p);let w=0;if(this._rows<h)for(let S=this._rows;S<h;S++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new f.BufferLine(i,p)):this.ybase>0&&this.lines.length<=this.ybase+this.y+w+1?(this.ybase--,w++,this.ydisp>0&&this.ydisp--):this.lines.push(new f.BufferLine(i,p)));else for(let S=this._rows;S>h;S--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(C<this.lines.maxLength){const S=this.lines.length-C;S>0&&(this.lines.trimStart(S),this.ybase=Math.max(this.ybase-S,0),this.ydisp=Math.max(this.ydisp-S,0),this.savedY=Math.max(this.savedY-S,0)),this.lines.maxLength=C}this.x=Math.min(this.x,i-1),this.y=Math.min(this.y,h-1),w&&(this.y+=w),this.savedX=Math.min(this.savedX,i-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(i,h),this._cols>i))for(let w=0;w<this.lines.length;w++)E+=+this.lines.get(w).resize(i,p);this._cols=i,this._rows=h,this._memoryCleanupQueue.clear(),E>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let i=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,i=!1);let h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>100)return!0;return i}get _isReflowEnabled(){const i=this._optionsService.rawOptions.windowsPty;return i&&i.buildNumber?this._hasScrollback&&i.backend==="conpty"&&i.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(i,h){this._cols!==i&&(i>this._cols?this._reflowLarger(i,h):this._reflowSmaller(i,h))}_reflowLarger(i,h){const p=(0,g.reflowLargerGetLinesToRemove)(this.lines,this._cols,i,this.ybase+this.y,this.getNullCell(f.DEFAULT_ATTR_DATA));if(p.length>0){const E=(0,g.reflowLargerCreateNewLayout)(this.lines,p);(0,g.reflowLargerApplyNewLayout)(this.lines,E.layout),this._reflowLargerAdjustViewport(i,h,E.countRemoved)}}_reflowLargerAdjustViewport(i,h,p){const E=this.getNullCell(f.DEFAULT_ATTR_DATA);let C=p;for(;C-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new f.BufferLine(i,E))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-p,0)}_reflowSmaller(i,h){const p=this.getNullCell(f.DEFAULT_ATTR_DATA),E=[];let C=0;for(let w=this.lines.length-1;w>=0;w--){let S=this.lines.get(w);if(!S||!S.isWrapped&&S.getTrimmedLength()<=i)continue;const x=[S];for(;S.isWrapped&&w>0;)S=this.lines.get(--w),x.unshift(S);const M=this.ybase+this.y;if(M>=w&&M<w+x.length)continue;const k=x[x.length-1].getTrimmedLength(),N=(0,g.reflowSmallerGetNewLineLengths)(x,this._cols,i),L=N.length-x.length;let F;F=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+L):Math.max(0,this.lines.length-this.lines.maxLength+L);const G=[];for(let T=0;T<L;T++){const O=this.getBlankLine(f.DEFAULT_ATTR_DATA,!0);G.push(O)}G.length>0&&(E.push({start:w+x.length+C,newLines:G}),C+=G.length),x.push(...G);let $=N.length-1,Q=N[$];Q===0&&($--,Q=N[$]);let V=x.length-L-1,A=k;for(;V>=0;){const T=Math.min(A,Q);if(x[$]===void 0)break;if(x[$].copyCellsFrom(x[V],A-T,Q-T,T,!0),Q-=T,Q===0&&($--,Q=N[$]),A-=T,A===0){V--;const O=Math.max(V,0);A=(0,g.getWrappedLineTrimmedLength)(x,O,this._cols)}}for(let T=0;T<x.length;T++)N[T]<i&&x[T].setCell(N[T],p);let D=L-F;for(;D-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+C)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+L,this.ybase+h-1)}if(E.length>0){const w=[],S=[];for(let $=0;$<this.lines.length;$++)S.push(this.lines.get($));const x=this.lines.length;let M=x-1,k=0,N=E[k];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+C);let L=0;for(let $=Math.min(this.lines.maxLength-1,x+C-1);$>=0;$--)if(N&&N.start>M+L){for(let Q=N.newLines.length-1;Q>=0;Q--)this.lines.set($--,N.newLines[Q]);$++,w.push({index:M+1,amount:N.newLines.length}),L+=N.newLines.length,N=E[++k]}else this.lines.set($,S[M--]);let F=0;for(let $=w.length-1;$>=0;$--)w[$].index+=F,this.lines.onInsertEmitter.fire(w[$]),F+=w[$].amount;const G=Math.max(0,x+C-this.lines.maxLength);G>0&&this.lines.onTrimEmitter.fire(G)}}translateBufferLineToString(i,h,p=0,E){const C=this.lines.get(i);return C?C.translateToString(h,p,E):""}getWrappedRangeForLine(i){let h=i,p=i;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;p+1<this.lines.length&&this.lines.get(p+1).isWrapped;)p++;return{first:h,last:p}}setupTabStops(i){for(i!=null?this.tabs[i]||(i=this.prevStop(i)):(this.tabs={},i=0);i<this._cols;i+=this._optionsService.rawOptions.tabStopWidth)this.tabs[i]=!0}prevStop(i){for(i==null&&(i=this.x);!this.tabs[--i]&&i>0;);return i>=this._cols?this._cols-1:i<0?0:i}nextStop(i){for(i==null&&(i=this.x);!this.tabs[++i]&&i<this._cols;);return i>=this._cols?this._cols-1:i<0?0:i}clearMarkers(i){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].line===i&&(this.markers[h].dispose(),this.markers.splice(h--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let i=0;i<this.markers.length;i++)this.markers[i].dispose(),this.markers.splice(i--,1);this._isClearing=!1}addMarker(i){const h=new o.Marker(i);return this.markers.push(h),h.register(this.lines.onTrim(p=>{h.line-=p,h.line<0&&h.dispose()})),h.register(this.lines.onInsert(p=>{h.line>=p.index&&(h.line+=p.amount)})),h.register(this.lines.onDelete(p=>{h.line>=p.index&&h.line<p.index+p.amount&&h.dispose(),h.line>p.index&&(h.line-=p.amount)})),h.register(h.onDispose(()=>this._removeMarker(h))),h}_removeMarker(i){this._isClearing||this.markers.splice(this.markers.indexOf(i),1)}}},8437:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const u=a(3734),_=a(511),l=a(643),f=a(482);n.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let g=0;class b{constructor(o,r,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*o);const h=r||_.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let p=0;p<o;++p)this.setCell(p,h);this.length=o}get(o){const r=this._data[3*o+0],i=2097151&r;return[this._data[3*o+1],2097152&r?this._combined[o]:i?(0,f.stringFromCodePoint)(i):"",r>>22,2097152&r?this._combined[o].charCodeAt(this._combined[o].length-1):i]}set(o,r){this._data[3*o+1]=r[l.CHAR_DATA_ATTR_INDEX],r[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[o]=r[1],this._data[3*o+0]=2097152|o|r[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*o+0]=r[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|r[l.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(o){return this._data[3*o+0]>>22}hasWidth(o){return 12582912&this._data[3*o+0]}getFg(o){return this._data[3*o+1]}getBg(o){return this._data[3*o+2]}hasContent(o){return 4194303&this._data[3*o+0]}getCodePoint(o){const r=this._data[3*o+0];return 2097152&r?this._combined[o].charCodeAt(this._combined[o].length-1):2097151&r}isCombined(o){return 2097152&this._data[3*o+0]}getString(o){const r=this._data[3*o+0];return 2097152&r?this._combined[o]:2097151&r?(0,f.stringFromCodePoint)(2097151&r):""}isProtected(o){return 536870912&this._data[3*o+2]}loadCell(o,r){return g=3*o,r.content=this._data[g+0],r.fg=this._data[g+1],r.bg=this._data[g+2],2097152&r.content&&(r.combinedData=this._combined[o]),268435456&r.bg&&(r.extended=this._extendedAttrs[o]),r}setCell(o,r){2097152&r.content&&(this._combined[o]=r.combinedData),268435456&r.bg&&(this._extendedAttrs[o]=r.extended),this._data[3*o+0]=r.content,this._data[3*o+1]=r.fg,this._data[3*o+2]=r.bg}setCellFromCodepoint(o,r,i,h){268435456&h.bg&&(this._extendedAttrs[o]=h.extended),this._data[3*o+0]=r|i<<22,this._data[3*o+1]=h.fg,this._data[3*o+2]=h.bg}addCodepointToCell(o,r,i){let h=this._data[3*o+0];2097152&h?this._combined[o]+=(0,f.stringFromCodePoint)(r):2097151&h?(this._combined[o]=(0,f.stringFromCodePoint)(2097151&h)+(0,f.stringFromCodePoint)(r),h&=-2097152,h|=2097152):h=r|4194304,i&&(h&=-12582913,h|=i<<22),this._data[3*o+0]=h}insertCells(o,r,i){if((o%=this.length)&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,i),r<this.length-o){const h=new _.CellData;for(let p=this.length-o-r-1;p>=0;--p)this.setCell(o+r+p,this.loadCell(o+p,h));for(let p=0;p<r;++p)this.setCell(o+p,i)}else for(let h=o;h<this.length;++h)this.setCell(h,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(o,r,i){if(o%=this.length,r<this.length-o){const h=new _.CellData;for(let p=0;p<this.length-o-r;++p)this.setCell(o+p,this.loadCell(o+r+p,h));for(let p=this.length-r;p<this.length;++p)this.setCell(p,i)}else for(let h=o;h<this.length;++h)this.setCell(h,i);o&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,i),this.getWidth(o)!==0||this.hasContent(o)||this.setCellFromCodepoint(o,0,1,i)}replaceCells(o,r,i,h=!1){if(h)for(o&&this.getWidth(o-1)===2&&!this.isProtected(o-1)&&this.setCellFromCodepoint(o-1,0,1,i),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,i);o<r&&o<this.length;)this.isProtected(o)||this.setCell(o,i),o++;else for(o&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,i),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,i);o<r&&o<this.length;)this.setCell(o++,i)}resize(o,r){if(o===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const i=3*o;if(o>this.length){if(this._data.buffer.byteLength>=4*i)this._data=new Uint32Array(this._data.buffer,0,i);else{const h=new Uint32Array(i);h.set(this._data),this._data=h}for(let h=this.length;h<o;++h)this.setCell(h,r)}else{this._data=this._data.subarray(0,i);const h=Object.keys(this._combined);for(let E=0;E<h.length;E++){const C=parseInt(h[E],10);C>=o&&delete this._combined[C]}const p=Object.keys(this._extendedAttrs);for(let E=0;E<p.length;E++){const C=parseInt(p[E],10);C>=o&&delete this._extendedAttrs[C]}}return this.length=o,4*i*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const o=new Uint32Array(this._data.length);return o.set(this._data),this._data=o,1}return 0}fill(o,r=!1){if(r)for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,o);else{this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,o)}}copyFrom(o){this.length!==o.length?this._data=new Uint32Array(o._data):this._data.set(o._data),this.length=o.length,this._combined={};for(const r in o._combined)this._combined[r]=o._combined[r];this._extendedAttrs={};for(const r in o._extendedAttrs)this._extendedAttrs[r]=o._extendedAttrs[r];this.isWrapped=o.isWrapped}clone(){const o=new b(0);o._data=new Uint32Array(this._data),o.length=this.length;for(const r in this._combined)o._combined[r]=this._combined[r];for(const r in this._extendedAttrs)o._extendedAttrs[r]=this._extendedAttrs[r];return o.isWrapped=this.isWrapped,o}getTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0])return o+(this._data[3*o+0]>>22);return 0}getNoBgTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0]||50331648&this._data[3*o+2])return o+(this._data[3*o+0]>>22);return 0}copyCellsFrom(o,r,i,h,p){const E=o._data;if(p)for(let w=h-1;w>=0;w--){for(let S=0;S<3;S++)this._data[3*(i+w)+S]=E[3*(r+w)+S];268435456&E[3*(r+w)+2]&&(this._extendedAttrs[i+w]=o._extendedAttrs[r+w])}else for(let w=0;w<h;w++){for(let S=0;S<3;S++)this._data[3*(i+w)+S]=E[3*(r+w)+S];268435456&E[3*(r+w)+2]&&(this._extendedAttrs[i+w]=o._extendedAttrs[r+w])}const C=Object.keys(o._combined);for(let w=0;w<C.length;w++){const S=parseInt(C[w],10);S>=r&&(this._combined[S-r+i]=o._combined[S])}}translateToString(o,r,i,h){r=r??0,i=i??this.length,o&&(i=Math.min(i,this.getTrimmedLength())),h&&(h.length=0);let p="";for(;r<i;){const E=this._data[3*r+0],C=2097151&E,w=2097152&E?this._combined[r]:C?(0,f.stringFromCodePoint)(C):l.WHITESPACE_CELL_CHAR;if(p+=w,h)for(let S=0;S<w.length;++S)h.push(r);r+=E>>22||1}return h&&h.push(r),p}}n.BufferLine=b},4841:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(a,u){if(a.start.y>a.end.y)throw new Error(`Buffer range end (${a.end.x}, ${a.end.y}) cannot be before start (${a.start.x}, ${a.start.y})`);return u*(a.end.y-a.start.y)+(a.end.x-a.start.x+1)}},4634:(y,n)=>{function a(u,_,l){if(_===u.length-1)return u[_].getTrimmedLength();const f=!u[_].hasContent(l-1)&&u[_].getWidth(l-1)===1,g=u[_+1].getWidth(0)===2;return f&&g?l-1:l}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(u,_,l,f,g){const b=[];for(let d=0;d<u.length-1;d++){let o=d,r=u.get(++o);if(!r.isWrapped)continue;const i=[u.get(d)];for(;o<u.length&&r.isWrapped;)i.push(r),r=u.get(++o);if(f>=d&&f<o){d+=i.length-1;continue}let h=0,p=a(i,h,_),E=1,C=0;for(;E<i.length;){const S=a(i,E,_),x=S-C,M=l-p,k=Math.min(x,M);i[h].copyCellsFrom(i[E],C,p,k,!1),p+=k,p===l&&(h++,p=0),C+=k,C===S&&(E++,C=0),p===0&&h!==0&&i[h-1].getWidth(l-1)===2&&(i[h].copyCellsFrom(i[h-1],l-1,p++,1,!1),i[h-1].setCell(l-1,g))}i[h].replaceCells(p,l,g);let w=0;for(let S=i.length-1;S>0&&(S>h||i[S].getTrimmedLength()===0);S--)w++;w>0&&(b.push(d+i.length-w),b.push(w)),d+=i.length-1}return b},n.reflowLargerCreateNewLayout=function(u,_){const l=[];let f=0,g=_[f],b=0;for(let d=0;d<u.length;d++)if(g===d){const o=_[++f];u.onDeleteEmitter.fire({index:d-b,amount:o}),d+=o-1,b+=o,g=_[++f]}else l.push(d);return{layout:l,countRemoved:b}},n.reflowLargerApplyNewLayout=function(u,_){const l=[];for(let f=0;f<_.length;f++)l.push(u.get(_[f]));for(let f=0;f<l.length;f++)u.set(f,l[f]);u.length=_.length},n.reflowSmallerGetNewLineLengths=function(u,_,l){const f=[],g=u.map((r,i)=>a(u,i,_)).reduce((r,i)=>r+i);let b=0,d=0,o=0;for(;o<g;){if(g-o<l){f.push(g-o);break}b+=l;const r=a(u,d,_);b>r&&(b-=r,d++);const i=u[d].getWidth(b-1)===2;i&&b--;const h=i?l-1:l;f.push(h),o+=h}return f},n.getWrappedLineTrimmedLength=a},5295:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const u=a(8460),_=a(844),l=a(9092);class f extends _.Disposable{constructor(b,d){super(),this._optionsService=b,this._bufferService=d,this._onBufferActivate=this.register(new u.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(b){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(b),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(b,d){this._normal.resize(b,d),this._alt.resize(b,d),this.setupTabStops(b)}setupTabStops(b){this._normal.setupTabStops(b),this._alt.setupTabStops(b)}}n.BufferSet=f},511:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const u=a(482),_=a(643),l=a(3734);class f extends l.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new l.ExtendedAttrs,this.combinedData=""}static fromCharData(b){const d=new f;return d.setFromCharData(b),d}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,u.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(b){this.fg=b[_.CHAR_DATA_ATTR_INDEX],this.bg=0;let d=!1;if(b[_.CHAR_DATA_CHAR_INDEX].length>2)d=!0;else if(b[_.CHAR_DATA_CHAR_INDEX].length===2){const o=b[_.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=o&&o<=56319){const r=b[_.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(o-55296)+r-56320+65536|b[_.CHAR_DATA_WIDTH_INDEX]<<22:d=!0}else d=!0}else this.content=b[_.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|b[_.CHAR_DATA_WIDTH_INDEX]<<22;d&&(this.combinedData=b[_.CHAR_DATA_CHAR_INDEX],this.content=2097152|b[_.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=f},643:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const u=a(8460),_=a(844);class l{get id(){return this._id}constructor(g){this.line=g,this.isDisposed=!1,this._disposables=[],this._id=l._nextId++,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,_.disposeArray)(this._disposables),this._disposables.length=0)}register(g){return this._disposables.push(g),g}}n.Marker=l,l._nextId=1},7116:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(y,n)=>{var a,u,_;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,function(l){l.NUL="\0",l.SOH="",l.STX="",l.ETX="",l.EOT="",l.ENQ="",l.ACK="",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=` `,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="",l.SI="",l.DLE="",l.DC1="",l.DC2="",l.DC3="",l.DC4="",l.NAK="",l.SYN="",l.ETB="",l.CAN="",l.EM="",l.SUB="",l.ESC="\x1B",l.FS="",l.GS="",l.RS="",l.US="",l.SP=" ",l.DEL=""}(a||(n.C0=a={})),function(l){l.PAD="",l.HOP="",l.BPH="",l.NBH="",l.IND="",l.NEL=" ",l.SSA="",l.ESA="",l.HTS="",l.HTJ="",l.VTS="",l.PLD="",l.PLU="",l.RI="",l.SS2="",l.SS3="",l.DCS="",l.PU1="",l.PU2="",l.STS="",l.CCH="",l.MW="",l.SPA="",l.EPA="",l.SOS="",l.SGCI="",l.SCI="",l.CSI="",l.ST="",l.OSC="",l.PM="",l.APC=""}(u||(n.C1=u={})),function(l){l.ST=`${a.ESC}\\`}(_||(n.C1_ESCAPED=_={}))},7399:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const u=a(2584),_={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};n.evaluateKeyboardEvent=function(l,f,g,b){const d={type:0,cancel:!1,key:void 0},o=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?d.key=f?u.C0.ESC+"OA":u.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?d.key=f?u.C0.ESC+"OD":u.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?d.key=f?u.C0.ESC+"OC":u.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(d.key=f?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:d.key=l.ctrlKey?"\b":u.C0.DEL,l.altKey&&(d.key=u.C0.ESC+d.key);break;case 9:if(l.shiftKey){d.key=u.C0.ESC+"[Z";break}d.key=u.C0.HT,d.cancel=!0;break;case 13:d.key=l.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,d.cancel=!0;break;case 27:d.key=u.C0.ESC,l.altKey&&(d.key=u.C0.ESC+u.C0.ESC),d.cancel=!0;break;case 37:if(l.metaKey)break;o?(d.key=u.C0.ESC+"[1;"+(o+1)+"D",d.key===u.C0.ESC+"[1;3D"&&(d.key=u.C0.ESC+(g?"b":"[1;5D"))):d.key=f?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(l.metaKey)break;o?(d.key=u.C0.ESC+"[1;"+(o+1)+"C",d.key===u.C0.ESC+"[1;3C"&&(d.key=u.C0.ESC+(g?"f":"[1;5C"))):d.key=f?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(l.metaKey)break;o?(d.key=u.C0.ESC+"[1;"+(o+1)+"A",g||d.key!==u.C0.ESC+"[1;3A"||(d.key=u.C0.ESC+"[1;5A")):d.key=f?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(l.metaKey)break;o?(d.key=u.C0.ESC+"[1;"+(o+1)+"B",g||d.key!==u.C0.ESC+"[1;3B"||(d.key=u.C0.ESC+"[1;5B")):d.key=f?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(d.key=u.C0.ESC+"[2~");break;case 46:d.key=o?u.C0.ESC+"[3;"+(o+1)+"~":u.C0.ESC+"[3~";break;case 36:d.key=o?u.C0.ESC+"[1;"+(o+1)+"H":f?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:d.key=o?u.C0.ESC+"[1;"+(o+1)+"F":f?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:l.shiftKey?d.type=2:l.ctrlKey?d.key=u.C0.ESC+"[5;"+(o+1)+"~":d.key=u.C0.ESC+"[5~";break;case 34:l.shiftKey?d.type=3:l.ctrlKey?d.key=u.C0.ESC+"[6;"+(o+1)+"~":d.key=u.C0.ESC+"[6~";break;case 112:d.key=o?u.C0.ESC+"[1;"+(o+1)+"P":u.C0.ESC+"OP";break;case 113:d.key=o?u.C0.ESC+"[1;"+(o+1)+"Q":u.C0.ESC+"OQ";break;case 114:d.key=o?u.C0.ESC+"[1;"+(o+1)+"R":u.C0.ESC+"OR";break;case 115:d.key=o?u.C0.ESC+"[1;"+(o+1)+"S":u.C0.ESC+"OS";break;case 116:d.key=o?u.C0.ESC+"[15;"+(o+1)+"~":u.C0.ESC+"[15~";break;case 117:d.key=o?u.C0.ESC+"[17;"+(o+1)+"~":u.C0.ESC+"[17~";break;case 118:d.key=o?u.C0.ESC+"[18;"+(o+1)+"~":u.C0.ESC+"[18~";break;case 119:d.key=o?u.C0.ESC+"[19;"+(o+1)+"~":u.C0.ESC+"[19~";break;case 120:d.key=o?u.C0.ESC+"[20;"+(o+1)+"~":u.C0.ESC+"[20~";break;case 121:d.key=o?u.C0.ESC+"[21;"+(o+1)+"~":u.C0.ESC+"[21~";break;case 122:d.key=o?u.C0.ESC+"[23;"+(o+1)+"~":u.C0.ESC+"[23~";break;case 123:d.key=o?u.C0.ESC+"[24;"+(o+1)+"~":u.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(g&&!b||!l.altKey||l.metaKey)!g||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?d.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(d.key=u.C0.US),l.key==="@"&&(d.key=u.C0.NUL)):l.keyCode===65&&(d.type=1);else{const r=_[l.keyCode],i=r==null?void 0:r[l.shiftKey?1:0];if(i)d.key=u.C0.ESC+i;else if(l.keyCode>=65&&l.keyCode<=90){const h=l.ctrlKey?l.keyCode-64:l.keyCode+32;let p=String.fromCharCode(h);l.shiftKey&&(p=p.toUpperCase()),d.key=u.C0.ESC+p}else if(l.keyCode===32)d.key=u.C0.ESC+(l.ctrlKey?u.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let h=l.code.slice(3,4);l.shiftKey||(h=h.toLowerCase()),d.key=u.C0.ESC+h,d.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?d.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?d.key=u.C0.NUL:l.keyCode>=51&&l.keyCode<=55?d.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?d.key=u.C0.DEL:l.keyCode===219?d.key=u.C0.ESC:l.keyCode===220?d.key=u.C0.FS:l.keyCode===221&&(d.key=u.C0.GS)}return d}},482:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(a){return a>65535?(a-=65536,String.fromCharCode(55296+(a>>10))+String.fromCharCode(a%1024+56320)):String.fromCharCode(a)},n.utf32ToString=function(a,u=0,_=a.length){let l="";for(let f=u;f<_;++f){let g=a[f];g>65535?(g-=65536,l+=String.fromCharCode(55296+(g>>10))+String.fromCharCode(g%1024+56320)):l+=String.fromCharCode(g)}return l},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(a,u){const _=a.length;if(!_)return 0;let l=0,f=0;if(this._interim){const g=a.charCodeAt(f++);56320<=g&&g<=57343?u[l++]=1024*(this._interim-55296)+g-56320+65536:(u[l++]=this._interim,u[l++]=g),this._interim=0}for(let g=f;g<_;++g){const b=a.charCodeAt(g);if(55296<=b&&b<=56319){if(++g>=_)return this._interim=b,l;const d=a.charCodeAt(g);56320<=d&&d<=57343?u[l++]=1024*(b-55296)+d-56320+65536:(u[l++]=b,u[l++]=d)}else b!==65279&&(u[l++]=b)}return l}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(a,u){const _=a.length;if(!_)return 0;let l,f,g,b,d=0,o=0,r=0;if(this.interim[0]){let p=!1,E=this.interim[0];E&=(224&E)==192?31:(240&E)==224?15:7;let C,w=0;for(;(C=63&this.interim[++w])&&w<4;)E<<=6,E|=C;const S=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,x=S-w;for(;r<x;){if(r>=_)return 0;if(C=a[r++],(192&C)!=128){r--,p=!0;break}this.interim[w++]=C,E<<=6,E|=63&C}p||(S===2?E<128?r--:u[d++]=E:S===3?E<2048||E>=55296&&E<=57343||E===65279||(u[d++]=E):E<65536||E>1114111||(u[d++]=E)),this.interim.fill(0)}const i=_-4;let h=r;for(;h<_;){for(;!(!(h<i)||128&(l=a[h])||128&(f=a[h+1])||128&(g=a[h+2])||128&(b=a[h+3]));)u[d++]=l,u[d++]=f,u[d++]=g,u[d++]=b,h+=4;if(l=a[h++],l<128)u[d++]=l;else if((224&l)==192){if(h>=_)return this.interim[0]=l,d;if(f=a[h++],(192&f)!=128){h--;continue}if(o=(31&l)<<6|63&f,o<128){h--;continue}u[d++]=o}else if((240&l)==224){if(h>=_)return this.interim[0]=l,d;if(f=a[h++],(192&f)!=128){h--;continue}if(h>=_)return this.interim[0]=l,this.interim[1]=f,d;if(g=a[h++],(192&g)!=128){h--;continue}if(o=(15&l)<<12|(63&f)<<6|63&g,o<2048||o>=55296&&o<=57343||o===65279)continue;u[d++]=o}else if((248&l)==240){if(h>=_)return this.interim[0]=l,d;if(f=a[h++],(192&f)!=128){h--;continue}if(h>=_)return this.interim[0]=l,this.interim[1]=f,d;if(g=a[h++],(192&g)!=128){h--;continue}if(h>=_)return this.interim[0]=l,this.interim[1]=f,this.interim[2]=g,d;if(b=a[h++],(192&b)!=128){h--;continue}if(o=(7&l)<<18|(63&f)<<12|(63&g)<<6|63&b,o<65536||o>1114111)continue;u[d++]=o}}return d}}},225:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const u=a(1480),_=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;n.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let g=0;g<_.length;++g)f.fill(0,_[g][0],_[g][1]+1)}}wcwidth(g){return g<32?0:g<127?1:g<65536?f[g]:function(b,d){let o,r=0,i=d.length-1;if(b<d[0][0]||b>d[i][1])return!1;for(;i>=r;)if(o=r+i>>1,b>d[o][1])r=o+1;else{if(!(b<d[o][0]))return!0;i=o-1}return!1}(g,l)?0:g>=131072&&g<=196605||g>=196608&&g<=262141?2:1}charProperties(g,b){let d=this.wcwidth(g),o=d===0&&b!==0;if(o){const r=u.UnicodeService.extractWidth(b);r===0?o=!1:r>d&&(d=r)}return u.UnicodeService.createPropertyValue(0,d,o)}}},5981:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const u=a(8460),_=a(844);class l extends _.Disposable{constructor(g){super(),this._action=g,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(g,b){if(b!==void 0&&this._syncCalls>b)return void(this._syncCalls=0);if(this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let d;for(this._isSyncWriting=!0;d=this._writeBuffer.shift();){this._action(d);const o=this._callbacks.shift();o&&o()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(g,b){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(b),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(b)}_innerWrite(g=0,b=!0){const d=g||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const o=this._writeBuffer[this._bufferOffset],r=this._action(o,b);if(r){const h=p=>Date.now()-d>=12?setTimeout(()=>this._innerWrite(0,p)):this._innerWrite(d,p);return void r.catch(p=>(queueMicrotask(()=>{throw p}),Promise.resolve(!1))).then(h)}const i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=o.length,Date.now()-d>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}n.WriteBuffer=l},5941:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const a=/^([\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})$/,u=/^[\da-f]+$/;function _(l,f){const g=l.toString(16),b=g.length<2?"0"+g:g;switch(f){case 4:return g[0];case 8:return b;case 12:return(b+b).slice(0,3);default:return b+b}}n.parseColor=function(l){if(!l)return;let f=l.toLowerCase();if(f.indexOf("rgb:")===0){f=f.slice(4);const g=a.exec(f);if(g){const b=g[1]?15:g[4]?255:g[7]?4095:65535;return[Math.round(parseInt(g[1]||g[4]||g[7]||g[10],16)/b*255),Math.round(parseInt(g[2]||g[5]||g[8]||g[11],16)/b*255),Math.round(parseInt(g[3]||g[6]||g[9]||g[12],16)/b*255)]}}else if(f.indexOf("#")===0&&(f=f.slice(1),u.exec(f)&&[3,6,9,12].includes(f.length))){const g=f.length/3,b=[0,0,0];for(let d=0;d<3;++d){const o=parseInt(f.slice(g*d,g*d+g),16);b[d]=g===1?o<<4:g===2?o:g===3?o>>4:o>>8}return b}},n.toRgbString=function(l,f=16){const[g,b,d]=l;return`rgb:${_(g,f)}/${_(b,f)}/${_(d,f)}`}},5770:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const u=a(482),_=a(8742),l=a(5770),f=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=f,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}registerHandler(b,d){this._handlers[b]===void 0&&(this._handlers[b]=[]);const o=this._handlers[b];return o.push(d),{dispose:()=>{const r=o.indexOf(d);r!==-1&&o.splice(r,1)}}}clearHandler(b){this._handlers[b]&&delete this._handlers[b]}setHandlerFallback(b){this._handlerFb=b}reset(){if(this._active.length)for(let b=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;b>=0;--b)this._active[b].unhook(!1);this._stack.paused=!1,this._active=f,this._ident=0}hook(b,d){if(this.reset(),this._ident=b,this._active=this._handlers[b]||f,this._active.length)for(let o=this._active.length-1;o>=0;o--)this._active[o].hook(d);else this._handlerFb(this._ident,"HOOK",d)}put(b,d,o){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(b,d,o);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(b,d,o))}unhook(b,d=!0){if(this._active.length){let o=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,o=d,i=this._stack.fallThrough,this._stack.paused=!1),!i&&o===!1){for(;r>=0&&(o=this._active[r].unhook(b),o!==!0);r--)if(o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,o;r--}for(;r>=0;r--)if(o=this._active[r].unhook(!1),o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,o}else this._handlerFb(this._ident,"UNHOOK",b);this._active=f,this._ident=0}};const g=new _.Params;g.addParam(0),n.DcsHandler=class{constructor(b){this._handler=b,this._data="",this._params=g,this._hitLimit=!1}hook(b){this._params=b.length>1||b.params[0]?b.clone():g,this._data="",this._hitLimit=!1}put(b,d,o){this._hitLimit||(this._data+=(0,u.utf32ToString)(b,d,o),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(b){let d=!1;if(this._hitLimit)d=!1;else if(b&&(d=this._handler(this._data,this._params),d instanceof Promise))return d.then(o=>(this._params=g,this._data="",this._hitLimit=!1,o));return this._params=g,this._data="",this._hitLimit=!1,d}}},2015:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const u=a(844),_=a(8742),l=a(6242),f=a(6351);class g{constructor(r){this.table=new Uint8Array(r)}setDefault(r,i){this.table.fill(r<<4|i)}add(r,i,h,p){this.table[i<<8|r]=h<<4|p}addMany(r,i,h,p){for(let E=0;E<r.length;E++)this.table[i<<8|r[E]]=h<<4|p}}n.TransitionTable=g;const b=160;n.VT500_TRANSITION_TABLE=function(){const o=new g(4095),r=Array.apply(null,Array(256)).map((w,S)=>S),i=(w,S)=>r.slice(w,S),h=i(32,127),p=i(0,24);p.push(25),p.push.apply(p,i(28,32));const E=i(0,14);let C;for(C in o.setDefault(1,0),o.addMany(h,0,2,0),E)o.addMany([24,26,153,154],C,3,0),o.addMany(i(128,144),C,3,0),o.addMany(i(144,152),C,3,0),o.add(156,C,0,0),o.add(27,C,11,1),o.add(157,C,4,8),o.addMany([152,158,159],C,0,7),o.add(155,C,11,3),o.add(144,C,11,9);return o.addMany(p,0,3,0),o.addMany(p,1,3,1),o.add(127,1,0,1),o.addMany(p,8,0,8),o.addMany(p,3,3,3),o.add(127,3,0,3),o.addMany(p,4,3,4),o.add(127,4,0,4),o.addMany(p,6,3,6),o.addMany(p,5,3,5),o.add(127,5,0,5),o.addMany(p,2,3,2),o.add(127,2,0,2),o.add(93,1,4,8),o.addMany(h,8,5,8),o.add(127,8,5,8),o.addMany([156,27,24,26,7],8,6,0),o.addMany(i(28,32),8,0,8),o.addMany([88,94,95],1,0,7),o.addMany(h,7,0,7),o.addMany(p,7,0,7),o.add(156,7,0,0),o.add(127,7,0,7),o.add(91,1,11,3),o.addMany(i(64,127),3,7,0),o.addMany(i(48,60),3,8,4),o.addMany([60,61,62,63],3,9,4),o.addMany(i(48,60),4,8,4),o.addMany(i(64,127),4,7,0),o.addMany([60,61,62,63],4,0,6),o.addMany(i(32,64),6,0,6),o.add(127,6,0,6),o.addMany(i(64,127),6,0,0),o.addMany(i(32,48),3,9,5),o.addMany(i(32,48),5,9,5),o.addMany(i(48,64),5,0,6),o.addMany(i(64,127),5,7,0),o.addMany(i(32,48),4,9,5),o.addMany(i(32,48),1,9,2),o.addMany(i(32,48),2,9,2),o.addMany(i(48,127),2,10,0),o.addMany(i(48,80),1,10,0),o.addMany(i(81,88),1,10,0),o.addMany([89,90,92],1,10,0),o.addMany(i(96,127),1,10,0),o.add(80,1,11,9),o.addMany(p,9,0,9),o.add(127,9,0,9),o.addMany(i(28,32),9,0,9),o.addMany(i(32,48),9,9,12),o.addMany(i(48,60),9,8,10),o.addMany([60,61,62,63],9,9,10),o.addMany(p,11,0,11),o.addMany(i(32,128),11,0,11),o.addMany(i(28,32),11,0,11),o.addMany(p,10,0,10),o.add(127,10,0,10),o.addMany(i(28,32),10,0,10),o.addMany(i(48,60),10,8,10),o.addMany([60,61,62,63],10,0,11),o.addMany(i(32,48),10,9,12),o.addMany(p,12,0,12),o.add(127,12,0,12),o.addMany(i(28,32),12,0,12),o.addMany(i(32,48),12,9,12),o.addMany(i(48,64),12,0,11),o.addMany(i(64,127),12,12,13),o.addMany(i(64,127),10,12,13),o.addMany(i(64,127),9,12,13),o.addMany(p,13,13,13),o.addMany(h,13,13,13),o.add(127,13,0,13),o.addMany([27,156,24,26],13,14,0),o.add(b,0,2,0),o.add(b,8,5,8),o.add(b,6,0,6),o.add(b,11,0,11),o.add(b,13,13,13),o}();class d extends u.Disposable{constructor(r=n.VT500_TRANSITION_TABLE){super(),this._transitions=r,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new _.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(i,h,p)=>{},this._executeHandlerFb=i=>{},this._csiHandlerFb=(i,h)=>{},this._escHandlerFb=i=>{},this._errorHandlerFb=i=>i,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,u.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this.register(new l.OscParser),this._dcsParser=this.register(new f.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(r,i=[64,126]){let h=0;if(r.prefix){if(r.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=r.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(r.intermediates){if(r.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let E=0;E<r.intermediates.length;++E){const C=r.intermediates.charCodeAt(E);if(32>C||C>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=C}}if(r.final.length!==1)throw new Error("final must be a single byte");const p=r.final.charCodeAt(0);if(i[0]>p||p>i[1])throw new Error(`final must be in range ${i[0]} .. ${i[1]}`);return h<<=8,h|=p,h}identToString(r){const i=[];for(;r;)i.push(String.fromCharCode(255&r)),r>>=8;return i.reverse().join("")}setPrintHandler(r){this._printHandler=r}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(r,i){const h=this._identifier(r,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const p=this._escHandlers[h];return p.push(i),{dispose:()=>{const E=p.indexOf(i);E!==-1&&p.splice(E,1)}}}clearEscHandler(r){this._escHandlers[this._identifier(r,[48,126])]&&delete this._escHandlers[this._identifier(r,[48,126])]}setEscHandlerFallback(r){this._escHandlerFb=r}setExecuteHandler(r,i){this._executeHandlers[r.charCodeAt(0)]=i}clearExecuteHandler(r){this._executeHandlers[r.charCodeAt(0)]&&delete this._executeHandlers[r.charCodeAt(0)]}setExecuteHandlerFallback(r){this._executeHandlerFb=r}registerCsiHandler(r,i){const h=this._identifier(r);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const p=this._csiHandlers[h];return p.push(i),{dispose:()=>{const E=p.indexOf(i);E!==-1&&p.splice(E,1)}}}clearCsiHandler(r){this._csiHandlers[this._identifier(r)]&&delete this._csiHandlers[this._identifier(r)]}setCsiHandlerFallback(r){this._csiHandlerFb=r}registerDcsHandler(r,i){return this._dcsParser.registerHandler(this._identifier(r),i)}clearDcsHandler(r){this._dcsParser.clearHandler(this._identifier(r))}setDcsHandlerFallback(r){this._dcsParser.setHandlerFallback(r)}registerOscHandler(r,i){return this._oscParser.registerHandler(r,i)}clearOscHandler(r){this._oscParser.clearHandler(r)}setOscHandlerFallback(r){this._oscParser.setHandlerFallback(r)}setErrorHandler(r){this._errorHandler=r}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(r,i,h,p,E){this._parseStack.state=r,this._parseStack.handlers=i,this._parseStack.handlerPos=h,this._parseStack.transition=p,this._parseStack.chunkPos=E}parse(r,i,h){let p,E=0,C=0,w=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,w=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const S=this._parseStack.handlers;let x=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&x>-1){for(;x>=0&&(p=S[x](this._params),p!==!0);x--)if(p instanceof Promise)return this._parseStack.handlerPos=x,p}this._parseStack.handlers=[];break;case 4:if(h===!1&&x>-1){for(;x>=0&&(p=S[x](),p!==!0);x--)if(p instanceof Promise)return this._parseStack.handlerPos=x,p}this._parseStack.handlers=[];break;case 6:if(E=r[this._parseStack.chunkPos],p=this._dcsParser.unhook(E!==24&&E!==26,h),p)return p;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(E=r[this._parseStack.chunkPos],p=this._oscParser.end(E!==24&&E!==26,h),p)return p;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,w=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let S=w;S<i;++S){switch(E=r[S],C=this._transitions.table[this.currentState<<8|(E<160?E:b)],C>>4){case 2:for(let L=S+1;;++L){if(L>=i||(E=r[L])<32||E>126&&E<b){this._printHandler(r,S,L),S=L-1;break}if(++L>=i||(E=r[L])<32||E>126&&E<b){this._printHandler(r,S,L),S=L-1;break}if(++L>=i||(E=r[L])<32||E>126&&E<b){this._printHandler(r,S,L),S=L-1;break}if(++L>=i||(E=r[L])<32||E>126&&E<b){this._printHandler(r,S,L),S=L-1;break}}break;case 3:this._executeHandlers[E]?this._executeHandlers[E]():this._executeHandlerFb(E),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:S,code:E,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const x=this._csiHandlers[this._collect<<8|E];let M=x?x.length-1:-1;for(;M>=0&&(p=x[M](this._params),p!==!0);M--)if(p instanceof Promise)return this._preserveStack(3,x,M,C,S),p;M<0&&this._csiHandlerFb(this._collect<<8|E,this._params),this.precedingJoinState=0;break;case 8:do switch(E){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(E-48)}while(++S<i&&(E=r[S])>47&&E<60);S--;break;case 9:this._collect<<=8,this._collect|=E;break;case 10:const k=this._escHandlers[this._collect<<8|E];let N=k?k.length-1:-1;for(;N>=0&&(p=k[N](),p!==!0);N--)if(p instanceof Promise)return this._preserveStack(4,k,N,C,S),p;N<0&&this._escHandlerFb(this._collect<<8|E),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|E,this._params);break;case 13:for(let L=S+1;;++L)if(L>=i||(E=r[L])===24||E===26||E===27||E>127&&E<b){this._dcsParser.put(r,S,L),S=L-1;break}break;case 14:if(p=this._dcsParser.unhook(E!==24&&E!==26),p)return this._preserveStack(6,[],0,C,S),p;E===27&&(C|=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 L=S+1;;L++)if(L>=i||(E=r[L])<32||E>127&&E<b){this._oscParser.put(r,S,L),S=L-1;break}break;case 6:if(p=this._oscParser.end(E!==24&&E!==26),p)return this._preserveStack(5,[],0,C,S),p;E===27&&(C|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&C}}}n.EscapeSequenceParser=d},6242:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const u=a(5770),_=a(482),l=[];n.OscParser=class{constructor(){this._state=0,this._active=l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(f,g){this._handlers[f]===void 0&&(this._handlers[f]=[]);const b=this._handlers[f];return b.push(g),{dispose:()=>{const d=b.indexOf(g);d!==-1&&b.splice(d,1)}}}clearHandler(f){this._handlers[f]&&delete this._handlers[f]}setHandlerFallback(f){this._handlerFb=f}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=l}reset(){if(this._state===2)for(let f=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;f>=0;--f)this._active[f].end(!1);this._stack.paused=!1,this._active=l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||l,this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].start();else this._handlerFb(this._id,"START")}_put(f,g,b){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(f,g,b);else this._handlerFb(this._id,"PUT",(0,_.utf32ToString)(f,g,b))}start(){this.reset(),this._state=1}put(f,g,b){if(this._state!==3){if(this._state===1)for(;g<b;){const d=f[g++];if(d===59){this._state=2,this._start();break}if(d<48||57<d)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+d-48}this._state===2&&b-g>0&&this._put(f,g,b)}}end(f,g=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let b=!1,d=this._active.length-1,o=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,b=g,o=this._stack.fallThrough,this._stack.paused=!1),!o&&b===!1){for(;d>=0&&(b=this._active[d].end(f),b!==!0);d--)if(b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,b;d--}for(;d>=0;d--)if(b=this._active[d].end(!1),b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,b}else this._handlerFb(this._id,"END",f);this._active=l,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(f){this._handler=f,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(f,g,b){this._hitLimit||(this._data+=(0,_.utf32ToString)(f,g,b),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(f){let g=!1;if(this._hitLimit)g=!1;else if(f&&(g=this._handler(this._data),g instanceof Promise))return g.then(b=>(this._data="",this._hitLimit=!1,b));return this._data="",this._hitLimit=!1,g}}},8742:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const a=2147483647;class u{static fromArray(l){const f=new u;if(!l.length)return f;for(let g=Array.isArray(l[0])?1:0;g<l.length;++g){const b=l[g];if(Array.isArray(b))for(let d=0;d<b.length;++d)f.addSubParam(b[d]);else f.addParam(b)}return f}constructor(l=32,f=32){if(this.maxLength=l,this.maxSubParamsLength=f,f>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(f),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const l=new u(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){const l=[];for(let f=0;f<this.length;++f){l.push(this.params[f]);const g=this._subParamsIdx[f]>>8,b=255&this._subParamsIdx[f];b-g>0&&l.push(Array.prototype.slice.call(this._subParams,g,b))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>a?a:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>a?a:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const f=this._subParamsIdx[l]>>8,g=255&this._subParamsIdx[l];return g-f>0?this._subParams.subarray(f,g):null}getSubParamsAll(){const l={};for(let f=0;f<this.length;++f){const g=this._subParamsIdx[f]>>8,b=255&this._subParamsIdx[f];b-g>0&&(l[f]=this._subParams.slice(g,b))}return l}addDigit(l){let f;if(this._rejectDigits||!(f=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const g=this._digitIsSub?this._subParams:this.params,b=g[f-1];g[f-1]=~b?Math.min(10*b+l,a):l}}n.Params=u},5741:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let a=this._addons.length-1;a>=0;a--)this._addons[a].instance.dispose()}loadAddon(a,u){const _={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(_),u.dispose=()=>this._wrappedAddonDispose(_),u.activate(a)}_wrappedAddonDispose(a){if(a.isDisposed)return;let u=-1;for(let _=0;_<this._addons.length;_++)if(this._addons[_]===a){u=_;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");a.isDisposed=!0,a.dispose.apply(a.instance),this._addons.splice(u,1)}}},8771:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const u=a(3785),_=a(511);n.BufferApiView=class{constructor(l,f){this._buffer=l,this.type=f}init(l){return this._buffer=l,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(l){const f=this._buffer.lines.get(l);if(f)return new u.BufferLineApiView(f)}getNullCell(){return new _.CellData}}},3785:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const u=a(511);n.BufferLineApiView=class{constructor(_){this._line=_}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(_,l){if(!(_<0||_>=this._line.length))return l?(this._line.loadCell(_,l),l):this._line.loadCell(_,new u.CellData)}translateToString(_,l,f){return this._line.translateToString(_,l,f)}}},8285:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const u=a(8771),_=a(8460),l=a(844);class f extends l.Disposable{constructor(b){super(),this._core=b,this._onBufferChange=this.register(new _.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}n.BufferNamespaceApi=f},7975:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(a){this._core=a}registerCsiHandler(a,u){return this._core.registerCsiHandler(a,_=>u(_.toArray()))}addCsiHandler(a,u){return this.registerCsiHandler(a,u)}registerDcsHandler(a,u){return this._core.registerDcsHandler(a,(_,l)=>u(_,l.toArray()))}addDcsHandler(a,u){return this.registerDcsHandler(a,u)}registerEscHandler(a,u){return this._core.registerEscHandler(a,u)}addEscHandler(a,u){return this.registerEscHandler(a,u)}registerOscHandler(a,u){return this._core.registerOscHandler(a,u)}addOscHandler(a,u){return this.registerOscHandler(a,u)}}},7090:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(a){this._core=a}register(a){this._core.unicodeService.register(a)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(a){this._core.unicodeService.activeVersion=a}}},744:function(y,n,a){var u=this&&this.__decorate||function(o,r,i,h){var p,E=arguments.length,C=E<3?r:h===null?h=Object.getOwnPropertyDescriptor(r,i):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(o,r,i,h);else for(var w=o.length-1;w>=0;w--)(p=o[w])&&(C=(E<3?p(C):E>3?p(r,i,C):p(r,i))||C);return E>3&&C&&Object.defineProperty(r,i,C),C},_=this&&this.__param||function(o,r){return function(i,h){r(i,h,o)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const l=a(8460),f=a(844),g=a(5295),b=a(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let d=n.BufferService=class extends f.Disposable{get buffer(){return this.buffers.active}constructor(o){super(),this.isUserScrolling=!1,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new l.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(o.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(o.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new g.BufferSet(o,this))}resize(o,r){this.cols=o,this.rows=r,this.buffers.resize(o,r),this._onResize.fire({cols:o,rows:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(o,r=!1){const i=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===o.fg&&h.getBg(0)===o.bg||(h=i.getBlankLine(o,r),this._cachedBlankLine=h),h.isWrapped=r;const p=i.ybase+i.scrollTop,E=i.ybase+i.scrollBottom;if(i.scrollTop===0){const C=i.lines.isFull;E===i.lines.length-1?C?i.lines.recycle().copyFrom(h):i.lines.push(h.clone()):i.lines.splice(E+1,0,h.clone()),C?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{const C=E-p+1;i.lines.shiftElements(p+1,C-1,-1),i.lines.set(E,h.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(o,r,i){const h=this.buffer;if(o<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else o+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const p=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+o,h.ybase),0),p!==h.ydisp&&(r||this._onScroll.fire(h.ydisp))}};n.BufferService=d=u([_(0,b.IOptionsService)],d)},7994:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(a){this.glevel=a,this.charset=this._charsets[a]}setgCharset(a,u){this._charsets[a]=u,this.glevel===a&&(this.charset=u)}}},1753:function(y,n,a){var u=this&&this.__decorate||function(h,p,E,C){var w,S=arguments.length,x=S<3?p:C===null?C=Object.getOwnPropertyDescriptor(p,E):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,p,E,C);else for(var M=h.length-1;M>=0;M--)(w=h[M])&&(x=(S<3?w(x):S>3?w(p,E,x):w(p,E))||x);return S>3&&x&&Object.defineProperty(p,E,x),x},_=this&&this.__param||function(h,p){return function(E,C){p(E,C,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const l=a(2585),f=a(8460),g=a(844),b={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function d(h,p){let E=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(E|=64,E|=h.action):(E|=3&h.button,4&h.button&&(E|=64),8&h.button&&(E|=128),h.action===32?E|=32:h.action!==0||p||(E|=3)),E}const o=String.fromCharCode,r={DEFAULT:h=>{const p=[d(h,!1)+32,h.col+32,h.row+32];return p[0]>255||p[1]>255||p[2]>255?"":`\x1B[M${o(p[0])}${o(p[1])}${o(p[2])}`},SGR:h=>{const p=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${d(h,!0)};${h.col};${h.row}${p}`},SGR_PIXELS:h=>{const p=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${d(h,!0)};${h.x};${h.y}${p}`}};let i=n.CoreMouseService=class extends g.Disposable{constructor(h,p){super(),this._bufferService=h,this._coreService=p,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new f.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const E of Object.keys(b))this.addProtocol(E,b[E]);for(const E of Object.keys(r))this.addEncoding(E,r[E]);this.reset()}addProtocol(h,p){this._protocols[h]=p}addEncoding(h,p){this._encodings[h]=p}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const p=this._encodings[this._activeEncoding](h);return p&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(p):this._coreService.triggerDataEvent(p,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,p,E){if(E){if(h.x!==p.x||h.y!==p.y)return!1}else if(h.col!==p.col||h.row!==p.row)return!1;return h.button===p.button&&h.action===p.action&&h.ctrl===p.ctrl&&h.alt===p.alt&&h.shift===p.shift}};n.CoreMouseService=i=u([_(0,l.IBufferService),_(1,l.ICoreService)],i)},6975:function(y,n,a){var u=this&&this.__decorate||function(i,h,p,E){var C,w=arguments.length,S=w<3?h:E===null?E=Object.getOwnPropertyDescriptor(h,p):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(i,h,p,E);else for(var x=i.length-1;x>=0;x--)(C=i[x])&&(S=(w<3?C(S):w>3?C(h,p,S):C(h,p))||S);return w>3&&S&&Object.defineProperty(h,p,S),S},_=this&&this.__param||function(i,h){return function(p,E){h(p,E,i)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const l=a(1439),f=a(8460),g=a(844),b=a(2585),d=Object.freeze({insertMode:!1}),o=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let r=n.CoreService=class extends g.Disposable{constructor(i,h,p){super(),this._bufferService=i,this._logService=h,this._optionsService=p,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new f.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new f.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new f.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new f.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,l.clone)(d),this.decPrivateModes=(0,l.clone)(o)}reset(){this.modes=(0,l.clone)(d),this.decPrivateModes=(0,l.clone)(o)}triggerDataEvent(i,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const p=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&p.ybase!==p.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${i}"`,()=>i.split("").map(E=>E.charCodeAt(0))),this._onData.fire(i)}triggerBinaryEvent(i){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${i}"`,()=>i.split("").map(h=>h.charCodeAt(0))),this._onBinary.fire(i))}};n.CoreService=r=u([_(0,b.IBufferService),_(1,b.ILogService),_(2,b.IOptionsService)],r)},9074:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const u=a(8055),_=a(8460),l=a(844),f=a(6106);let g=0,b=0;class d extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new f.SortedList(i=>i==null?void 0:i.marker.line),this._onDecorationRegistered=this.register(new _.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new _.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)(()=>this.reset()))}registerDecoration(i){if(i.marker.isDisposed)return;const h=new o(i);if(h){const p=h.marker.onDispose(()=>h.dispose());h.onDispose(()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),p.dispose())}),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const i of this._decorations.values())i.dispose();this._decorations.clear()}*getDecorationsAtCell(i,h,p){let E=0,C=0;for(const w of this._decorations.getKeyIterator(h))E=w.options.x??0,C=E+(w.options.width??1),i>=E&&i<C&&(!p||(w.options.layer??"bottom")===p)&&(yield w)}forEachDecorationAtCell(i,h,p,E){this._decorations.forEachByKey(h,C=>{g=C.options.x??0,b=g+(C.options.width??1),i>=g&&i<b&&(!p||(C.options.layer??"bottom")===p)&&E(C)})}}n.DecorationService=d;class o extends l.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=u.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=u.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(i){super(),this.options=i,this.onRenderEmitter=this.register(new _.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new _.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=i.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const u=a(2585),_=a(8343);class l{constructor(...g){this._entries=new Map;for(const[b,d]of g)this.set(b,d)}set(g,b){const d=this._entries.get(g);return this._entries.set(g,b),d}forEach(g){for(const[b,d]of this._entries.entries())g(b,d)}has(g){return this._entries.has(g)}get(g){return this._entries.get(g)}}n.ServiceCollection=l,n.InstantiationService=class{constructor(){this._services=new l,this._services.set(u.IInstantiationService,this)}setService(f,g){this._services.set(f,g)}getService(f){return this._services.get(f)}createInstance(f,...g){const b=(0,_.getServiceDependencies)(f).sort((r,i)=>r.index-i.index),d=[];for(const r of b){const i=this._services.get(r.id);if(!i)throw new Error(`[createInstance] ${f.name} depends on UNKNOWN service ${r.id}.`);d.push(i)}const o=b.length>0?b[0].index:g.length;if(g.length!==o)throw new Error(`[createInstance] First service dependency of ${f.name} at position ${o+1} conflicts with ${g.length} static arguments`);return new f(...g,...d)}}},7866:function(y,n,a){var u=this&&this.__decorate||function(o,r,i,h){var p,E=arguments.length,C=E<3?r:h===null?h=Object.getOwnPropertyDescriptor(r,i):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(o,r,i,h);else for(var w=o.length-1;w>=0;w--)(p=o[w])&&(C=(E<3?p(C):E>3?p(r,i,C):p(r,i))||C);return E>3&&C&&Object.defineProperty(r,i,C),C},_=this&&this.__param||function(o,r){return function(i,h){r(i,h,o)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const l=a(844),f=a(2585),g={trace:f.LogLevelEnum.TRACE,debug:f.LogLevelEnum.DEBUG,info:f.LogLevelEnum.INFO,warn:f.LogLevelEnum.WARN,error:f.LogLevelEnum.ERROR,off:f.LogLevelEnum.OFF};let b,d=n.LogService=class extends l.Disposable{get logLevel(){return this._logLevel}constructor(o){super(),this._optionsService=o,this._logLevel=f.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),b=this}_updateLogLevel(){this._logLevel=g[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(o){for(let r=0;r<o.length;r++)typeof o[r]=="function"&&(o[r]=o[r]())}_log(o,r,i){this._evalLazyOptionalParams(i),o.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+r,...i)}trace(o,...r){var i;this._logLevel<=f.LogLevelEnum.TRACE&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,o,r)}debug(o,...r){var i;this._logLevel<=f.LogLevelEnum.DEBUG&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,o,r)}info(o,...r){var i;this._logLevel<=f.LogLevelEnum.INFO&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,o,r)}warn(o,...r){var i;this._logLevel<=f.LogLevelEnum.WARN&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,o,r)}error(o,...r){var i;this._logLevel<=f.LogLevelEnum.ERROR&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,o,r)}};n.LogService=d=u([_(0,f.IOptionsService)],d),n.setTraceLogger=function(o){b=o},n.traceCall=function(o,r,i){if(typeof i.value!="function")throw new Error("not supported");const h=i.value;i.value=function(...p){if(b.logLevel!==f.LogLevelEnum.TRACE)return h.apply(this,p);b.trace(`GlyphRenderer#${h.name}(${p.map(C=>JSON.stringify(C)).join(", ")})`);const E=h.apply(this,p);return b.trace(`GlyphRenderer#${h.name} return`,E),E}}},7302:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const u=a(8460),_=a(844),l=a(6114);n.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:l.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const f=["normal","bold","100","200","300","400","500","600","700","800","900"];class g extends _.Disposable{constructor(d){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const o={...n.DEFAULT_OPTIONS};for(const r in d)if(r in o)try{const i=d[r];o[r]=this._sanitizeAndValidateOption(r,i)}catch(i){console.error(i)}this.rawOptions=o,this.options={...o},this._setupOptions(),this.register((0,_.toDisposable)(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(d,o){return this.onOptionChange(r=>{r===d&&o(this.rawOptions[d])})}onMultipleOptionChange(d,o){return this.onOptionChange(r=>{d.indexOf(r)!==-1&&o()})}_setupOptions(){const d=r=>{if(!(r in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},o=(r,i)=>{if(!(r in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${r}"`);i=this._sanitizeAndValidateOption(r,i),this.rawOptions[r]!==i&&(this.rawOptions[r]=i,this._onOptionChange.fire(r))};for(const r in this.rawOptions){const i={get:d.bind(this,r),set:o.bind(this,r)};Object.defineProperty(this.options,r,i)}}_sanitizeAndValidateOption(d,o){switch(d){case"cursorStyle":if(o||(o=n.DEFAULT_OPTIONS[d]),!function(r){return r==="block"||r==="underline"||r==="bar"}(o))throw new Error(`"${o}" is not a valid value for ${d}`);break;case"wordSeparator":o||(o=n.DEFAULT_OPTIONS[d]);break;case"fontWeight":case"fontWeightBold":if(typeof o=="number"&&1<=o&&o<=1e3)break;o=f.includes(o)?o:n.DEFAULT_OPTIONS[d];break;case"cursorWidth":o=Math.floor(o);case"lineHeight":case"tabStopWidth":if(o<1)throw new Error(`${d} cannot be less than 1, value: ${o}`);break;case"minimumContrastRatio":o=Math.max(1,Math.min(21,Math.round(10*o)/10));break;case"scrollback":if((o=Math.min(o,4294967295))<0)throw new Error(`${d} cannot be less than 0, value: ${o}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(o<=0)throw new Error(`${d} cannot be less than or equal to 0, value: ${o}`);break;case"rows":case"cols":if(!o&&o!==0)throw new Error(`${d} must be numeric, value: ${o}`);break;case"windowsPty":o=o??{}}return o}}n.OptionsService=g},2660:function(y,n,a){var u=this&&this.__decorate||function(g,b,d,o){var r,i=arguments.length,h=i<3?b:o===null?o=Object.getOwnPropertyDescriptor(b,d):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(g,b,d,o);else for(var p=g.length-1;p>=0;p--)(r=g[p])&&(h=(i<3?r(h):i>3?r(b,d,h):r(b,d))||h);return i>3&&h&&Object.defineProperty(b,d,h),h},_=this&&this.__param||function(g,b){return function(d,o){b(d,o,g)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const l=a(2585);let f=n.OscLinkService=class{constructor(g){this._bufferService=g,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(g){const b=this._bufferService.buffer;if(g.id===void 0){const p=b.addMarker(b.ybase+b.y),E={data:g,id:this._nextId++,lines:[p]};return p.onDispose(()=>this._removeMarkerFromLink(E,p)),this._dataByLinkId.set(E.id,E),E.id}const d=g,o=this._getEntryIdKey(d),r=this._entriesWithId.get(o);if(r)return this.addLineToLink(r.id,b.ybase+b.y),r.id;const i=b.addMarker(b.ybase+b.y),h={id:this._nextId++,key:this._getEntryIdKey(d),data:d,lines:[i]};return i.onDispose(()=>this._removeMarkerFromLink(h,i)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(g,b){const d=this._dataByLinkId.get(g);if(d&&d.lines.every(o=>o.line!==b)){const o=this._bufferService.buffer.addMarker(b);d.lines.push(o),o.onDispose(()=>this._removeMarkerFromLink(d,o))}}getLinkData(g){var b;return(b=this._dataByLinkId.get(g))==null?void 0:b.data}_getEntryIdKey(g){return`${g.id};;${g.uri}`}_removeMarkerFromLink(g,b){const d=g.lines.indexOf(b);d!==-1&&(g.lines.splice(d,1),g.lines.length===0&&(g.data.id!==void 0&&this._entriesWithId.delete(g.key),this._dataByLinkId.delete(g.id)))}};n.OscLinkService=f=u([_(0,l.IBufferService)],f)},8343:(y,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const a="di$target",u="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(_){return _[u]||[]},n.createDecorator=function(_){if(n.serviceRegistry.has(_))return n.serviceRegistry.get(_);const l=function(f,g,b){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(d,o,r){o[a]===o?o[u].push({id:d,index:r}):(o[u]=[{id:d,index:r}],o[a]=o)})(l,f,b)};return l.toString=()=>_,n.serviceRegistry.set(_,l),l}},2585:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const u=a(8343);var _;n.IBufferService=(0,u.createDecorator)("BufferService"),n.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),n.ICoreService=(0,u.createDecorator)("CoreService"),n.ICharsetService=(0,u.createDecorator)("CharsetService"),n.IInstantiationService=(0,u.createDecorator)("InstantiationService"),function(l){l[l.TRACE=0]="TRACE",l[l.DEBUG=1]="DEBUG",l[l.INFO=2]="INFO",l[l.WARN=3]="WARN",l[l.ERROR=4]="ERROR",l[l.OFF=5]="OFF"}(_||(n.LogLevelEnum=_={})),n.ILogService=(0,u.createDecorator)("LogService"),n.IOptionsService=(0,u.createDecorator)("OptionsService"),n.IOscLinkService=(0,u.createDecorator)("OscLinkService"),n.IUnicodeService=(0,u.createDecorator)("UnicodeService"),n.IDecorationService=(0,u.createDecorator)("DecorationService")},1480:(y,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const u=a(8460),_=a(225);class l{static extractShouldJoin(g){return(1&g)!=0}static extractWidth(g){return g>>1&3}static extractCharKind(g){return g>>3}static createPropertyValue(g,b,d=!1){return(16777215&g)<<3|(3&b)<<1|(d?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new u.EventEmitter,this.onChange=this._onChange.event;const g=new _.UnicodeV6;this.register(g),this._active=g.version,this._activeProvider=g}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(g){if(!this._providers[g])throw new Error(`unknown Unicode version "${g}"`);this._active=g,this._activeProvider=this._providers[g],this._onChange.fire(g)}register(g){this._providers[g.version]=g}wcwidth(g){return this._activeProvider.wcwidth(g)}getStringCellWidth(g){let b=0,d=0;const o=g.length;for(let r=0;r<o;++r){let i=g.charCodeAt(r);if(55296<=i&&i<=56319){if(++r>=o)return b+this.wcwidth(i);const E=g.charCodeAt(r);56320<=E&&E<=57343?i=1024*(i-55296)+E-56320+65536:b+=this.wcwidth(E)}const h=this.charProperties(i,d);let p=l.extractWidth(h);l.extractShouldJoin(h)&&(p-=l.extractWidth(d)),b+=p,d=h}return b}charProperties(g,b){return this._activeProvider.charProperties(g,b)}}n.UnicodeService=l}},c={};function v(y){var n=c[y];if(n!==void 0)return n.exports;var a=c[y]={exports:{}};return s[y].call(a.exports,a,a.exports,v),a.exports}var I={};return(()=>{var y=I;Object.defineProperty(y,"__esModule",{value:!0}),y.Terminal=void 0;const n=v(9042),a=v(3236),u=v(844),_=v(5741),l=v(8285),f=v(7975),g=v(7090),b=["cols","rows"];class d extends u.Disposable{constructor(r){super(),this._core=this.register(new a.Terminal(r)),this._addonManager=this.register(new _.AddonManager),this._publicOptions={...this._core.options};const i=p=>this._core.options[p],h=(p,E)=>{this._checkReadonlyOptions(p),this._core.options[p]=E};for(const p in this._core.options){const E={get:i.bind(this,p),set:h.bind(this,p)};Object.defineProperty(this._publicOptions,p,E)}}_checkReadonlyOptions(r){if(b.includes(r))throw new Error(`Option "${r}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new f.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new g.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new l.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const r=this._core.coreService.decPrivateModes;let 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:r.applicationCursorKeys,applicationKeypadMode:r.applicationKeypad,bracketedPasteMode:r.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:r.origin,reverseWraparoundMode:r.reverseWraparound,sendFocusMode:r.sendFocus,wraparoundMode:r.wraparound}}get options(){return this._publicOptions}set options(r){for(const i in r)this._publicOptions[i]=r[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(r,i=!0){this._core.input(r,i)}resize(r,i){this._verifyIntegers(r,i),this._core.resize(r,i)}open(r){this._core.open(r)}attachCustomKeyEventHandler(r){this._core.attachCustomKeyEventHandler(r)}attachCustomWheelEventHandler(r){this._core.attachCustomWheelEventHandler(r)}registerLinkProvider(r){return this._core.registerLinkProvider(r)}registerCharacterJoiner(r){return this._checkProposedApi(),this._core.registerCharacterJoiner(r)}deregisterCharacterJoiner(r){this._checkProposedApi(),this._core.deregisterCharacterJoiner(r)}registerMarker(r=0){return this._verifyIntegers(r),this._core.registerMarker(r)}registerDecoration(r){return this._checkProposedApi(),this._verifyPositiveIntegers(r.x??0,r.width??0,r.height??0),this._core.registerDecoration(r)}hasSelection(){return this._core.hasSelection()}select(r,i,h){this._verifyIntegers(r,i,h),this._core.select(r,i,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(r,i){this._verifyIntegers(r,i),this._core.selectLines(r,i)}dispose(){super.dispose()}scrollLines(r){this._verifyIntegers(r),this._core.scrollLines(r)}scrollPages(r){this._verifyIntegers(r),this._core.scrollPages(r)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(r){this._verifyIntegers(r),this._core.scrollToLine(r)}clear(){this._core.clear()}write(r,i){this._core.write(r,i)}writeln(r,i){this._core.write(r),this._core.write(`\r `,i)}paste(r){this._core.paste(r)}refresh(r,i){this._verifyIntegers(r,i),this._core.refresh(r,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(r){this._addonManager.loadAddon(this,r)}static get strings(){return n}_verifyIntegers(...r){for(const i of r)if(i===1/0||isNaN(i)||i%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...r){for(const i of r)if(i&&(i===1/0||isNaN(i)||i%1!=0||i<0))throw new Error("This API only accepts positive integers")}}y.Terminal=d})(),I})())}(xs)),xs.exports}var Za=Ja();const Cr=Z.forwardRef(function({options:e={},addons:s,className:c,onBinary:v,onCursorMove:I,onData:y,onKey:n,onLineFeed:a,onScroll:u,onSelectionChange:_,onRender:l,onResize:f,onTitleChange:g,customKeyEventHandler:b,onOpen:d},o){const[r,i]=Z.useState(!1),h=Z.useRef(null),p=Z.useRef(new Za.Terminal(e));Z.useImperativeHandle(o,()=>p.current);const E=()=>{s&&s.forEach(C=>{var w;(w=p.current)==null||w.loadAddon(C)}),v&&p.current.onBinary(v),I&&p.current.onCursorMove(I),y&&p.current.onData(y),n&&p.current.onKey(n),a&&p.current.onLineFeed(a),u&&p.current.onScroll(u),_&&p.current.onSelectionChange(_),l&&p.current.onRender(l),f&&p.current.onResize(f),g&&p.current.onTitleChange(g),b&&p.current.attachCustomKeyEventHandler(b)};return Z.useEffect(()=>{var w;const C=h.current;return C&&(E(),(w=p.current)==null||w.open(C),i(!0)),()=>{var S;(S=p.current)==null||S.dispose()}},[]),Z.useLayoutEffect(()=>{r&&d&&d()},[r]),m.jsx("div",{className:c,ref:h})}),ec={theme:{background:"#292c2f"}},tc={command:"su -l",environment:[{key:"TERM",value:"xterm-256color"},{key:"HOME",value:"/root"},{key:"PATH",value:"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/run/current-system/sw/bin"},{key:"LANG",value:"C.UTF-8"},{key:"USER",value:"root"}],user:0,group:0},Er="user.ui_terminal_default_payload",sc=t=>{const e=t.config[Er];return e?JSON.parse(e):tc},ic=({instance:t,refreshInstance:e})=>{var A;const{name:s,project:c}=tt(),v=new TextEncoder,I=B.useNotify(),[y,n]=Z.useState(!1),[a,u]=Z.useState(null),[_,l]=Z.useState(null),[f,g]=Z.useState(sc(t)),[b]=Z.useState(new Sr.FitAddon),[d,o]=Z.useState(!1),r=Z.useRef(null),i=Z.useRef(null),[h,p]=Z.useState(0),{canUpdateInstanceState:E,canExecInstance:C}=Ue();er({when:d,message:"Are you sure you want to leave this page?"});const w=D=>{d&&(D.returnValue="Are you sure you want to leave this page?")};B.useListener(window,w,"beforeunload");const S=async D=>{if(!s){I.failure("Missing name",new Error);return}if(!c){I.failure("Missing project",new Error);return}n(!0);const T=await Ho(s,c,D).catch(P=>{n(!1),I.failure("Connection failed",P)});if(!T)return;const O=T.operation.split("?")[0],Y=location.protocol==="https:"?"wss":"ws",q=`${Y}://${location.host}${O}/websocket?secret=${T.metadata.metadata.fds[0]}`,se=`${Y}://${location.host}${O}/websocket?secret=${T.metadata.metadata.fds.control}`,te=new WebSocket(q),U=new WebSocket(se);return U.onopen=()=>{n(!1),l(U)},U.onerror=P=>{I.failure("Error",P)},U.onclose=P=>{P.code!==1005&&I.failure("Error",P.reason,wt(P.code)),l(null)},te.onopen=()=>{u(te)},te.onerror=P=>{I.failure("Error",P)},te.onclose=P=>{P.code!==1005&&I.failure("Error",P.reason,wt(P.code)),u(null),o(!1)},te.binaryType="arraybuffer",te.onmessage=P=>{var W;(W=r.current)==null||W.write(new Uint8Array(P.data))},[te,U]},x=rs(t),M=x&&(((A=t.state)==null?void 0:A.processes)??0)<1,k=x&&!M,N=C(t);Z.useEffect(()=>{if(M&&i.current===null){const O=setTimeout(()=>{e(),i.current=null,p(Y=>Y+1)},1e3);return i.current=O,()=>{clearTimeout(O)}}else return()=>{}},[M,h]),Z.useEffect(()=>{var D;if((D=r.current)==null||D.clear(),I.clear(),k&&N){const T=S(f);return()=>{T.then(O=>{O==null||O.map(Y=>{Y.close()})})}}else return()=>{}},[f,t.status,k,N]);const L=()=>{var T,O;if((_==null?void 0:_.readyState)===WebSocket.CLOSED)return;ht("p-terminal",void 0,10),(O=(T=r.current)==null?void 0:T.element)==null||O.style.setProperty("padding","1rem"),b.fit();const D=b.proposeDimensions();_==null||_.send(v.encode(JSON.stringify({command:"window-resize",args:{height:D==null?void 0:D.rows.toString(),width:D==null?void 0:D.cols.toString()}})))};B.useListener(window,()=>{L(),setTimeout(L,500)},"resize",!0);const F=()=>{var D;L(),(D=r.current)==null||D.focus()},{handleStart:G,isLoading:$}=lr(t);if(!N)return m.jsx(B.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to use the terminal for this instance."});const Q=!E(t)||M||$,V=()=>{var D,T;(T=(D=r.current)==null?void 0:D.element)==null||T.requestFullscreen().then(L).then(()=>{var O;(O=r.current)==null||O.focus()}).catch(O=>{I.failure("Failed to enter full-screen mode",O)})};return m.jsxs("div",{className:"instance-terminal-tab",children:[k&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"p-panel__controls",children:[m.jsx(B.Button,{className:"u-no-margin--bottom",onClick:V,disabled:y||!_,children:"Fullscreen"}),m.jsx(Qa,{reconnect:g,payload:f,instance:t})]}),m.jsx(ss,{}),y&&m.jsx(B.Spinner,{className:"u-loader",text:"Loading terminal session..."}),_&&m.jsx(Cr,{ref:r,addons:[b],options:ec,onData:D=>{o(!0),a==null||a.send(v.encode(D))},onOpen:F,className:"p-terminal"})]}),!k&&m.jsxs(B.EmptyState,{className:"empty-state",image:m.jsx(B.Icon,{name:"pods",className:"empty-state-icon"}),title:M?"Instance starting":"Instance stopped",children:[m.jsx("p",{children:M?"Terminal will be ready once the instance has finished booting.":"Start the instance to access the terminal."}),m.jsx(B.ActionButton,{appearance:"positive",loading:$||M,onClick:G,disabled:Q,title:E(t)?"":"You do not have permission to start this instance.",children:"Start instance"})]})]})},rc=async(t,e,s,c)=>{const v=new URLSearchParams;return v.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots?${v.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,expires_at:s,stateful:c})}).then(Pt).then(I=>I)},yr=async(t,e)=>{const s=new URLSearchParams;return s.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots/${encodeURIComponent(e.name)}?${s.toString()}`,{method:"DELETE"}).then(Pt).then(c=>c)},nc=async(t,e,s)=>{const c=[];return new Promise((v,I)=>{Promise.allSettled(e.map(async y=>{const n={name:y,type:"snapshot",href:`${fo(t.name,t.project)}/snapshots`};await yr(t,{name:y}).then(a=>{s.set(a.metadata.id,()=>{po(c,n)},u=>{gi(c,u,n)},()=>{vi(c,e.length,v)})}).catch(a=>{gi(c,a instanceof Error?a.message:"",n),vi(c,e.length,v)})})).catch(I)})},oc=async(t,e,s)=>{const c=new URLSearchParams;return c.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}?${c.toString()}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({restore:e.name,stateful:e.stateful?s:!1})}).then(Pt).then(v=>v)},ac=async(t,e,s)=>{const c=new URLSearchParams;return c.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots/${encodeURIComponent(e.name)}?${c.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s})}).then(Pt).then(v=>v)},cc=async(t,e,s)=>{const c=new URLSearchParams;return c.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots/${encodeURIComponent(e.name)}?${c.toString()}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({expires_at:s})}).then(Pt).then(v=>v)},hc=t=>!!t.config["migration.stateful"],lc=(t,e,s)=>["deduplicate","Snapshot name already in use",async c=>s&&c===s||go(c,t.project,e,`instances/${encodeURIComponent(t.name)}/snapshots`)],wr=(t,e,s)=>Qe().shape({name:qe().test(...lc(t,e,s)).matches(/^[A-Za-z0-9-_.:]+$/,{message:"Only alphanumeric characters, underscores, periods, hyphens, and colons are allowed in this field"}),expirationDate:qe().nullable().optional().test(...Xo()).test(...Qo()),expirationTime:qe().nullable().optional().test(...qo()),stateful:mo()}),It=({name:t,instance:e})=>m.jsx(Fe,{type:"snapshot",value:t,to:`/ui/project/${encodeURIComponent(e.project)}/instance/${encodeURIComponent(e.name)}/snapshots`}),uc=({instance:t,snapshot:e,close:s,onSuccess:c})=>{const v=ye(),I=B.useToastNotification(),y=Oe(),n=Z.useState(null),a=b=>{y.invalidateQueries({predicate:d=>d.queryKey[0]===Ee.instances}),c(m.jsxs(m.Fragment,{children:["Snapshot ",m.jsx(It,{name:b,instance:t})," ","saved for instance ",m.jsx(fe,{instance:t}),"."]})),s()},u=(b,d)=>{const o=d?{name:d}:e,r=m.jsx(fe,{instance:t});cc(t,o,b).then(i=>{v.set(i.metadata.id,()=>{a(d??e.name)},h=>{I.failure(`Snapshot update failed for instance ${t.name}`,new Error(h),r),g.setSubmitting(!1)})}).catch(i=>{I.failure(`Snapshot update failed for instance ${t.name}`,i,r),g.setSubmitting(!1)})},_=(b,d)=>{const o=m.jsx(It,{name:e.name,instance:t});ac(t,e,b).then(r=>{v.set(r.metadata.id,()=>{d?u(d,b):a(b)},i=>{I.failure(`Snapshot rename failed for ${e.name}`,new Error(i),o),g.setSubmitting(!1)})}).catch(r=>{I.failure(`Snapshot rename failed for ${e.name}`,r,o),g.setSubmitting(!1)})},[l,f]=e.expires_at===Rs?[null,null]:vo(new Date(e.expires_at)).slice(0,16).split(" "),g=Ne({initialValues:{name:e.name,stateful:e.stateful,expirationDate:l,expirationTime:f},validateOnMount:!0,validationSchema:wr(t,n,e.name),onSubmit:b=>{const d=b.name,o=b.expirationDate&&b.expirationTime?tr(fr(b.expirationDate,b.expirationTime)):Rs,r=d!==e.name,i=o!==e.expires_at;r&&i?_(d,o):r?_(d):u(o)}});return m.jsx(_r,{isEdit:!0,formik:g,close:s})},dc=({instance:t,snapshot:e,onSuccess:s,isDeleting:c,isRestoring:v,disabledReason:I})=>{const{openPortal:y,closePortal:n,isOpen:a,Portal:u}=B.usePortal();return m.jsxs(m.Fragment,{children:[a&&m.jsx(u,{children:m.jsx(uc,{close:n,instance:t,onSuccess:s,snapshot:e})}),m.jsx(B.Button,{appearance:"base",hasIcon:!0,dense:!0,disabled:c||v||!!I,onClick:y,type:"button","aria-label":"Edit snapshot",title:I??"Edit",children:m.jsx(B.Icon,{name:"edit"})})]})},_c=({instance:t,snapshot:e,close:s})=>{const c=ye(),v=B.useToastNotification(),I=Oe(),y=m.jsx(It,{name:e.name,instance:t}),{data:n}=Dt(t.project),{canCreateImageAliases:a}=Ye(),u=()=>{const g=m.jsx(Ks,{to:`/ui/project/${encodeURIComponent(t.project)}/images`,children:"created"});v.success(m.jsxs(m.Fragment,{children:["Image ",g," from snapshot ",y,"."]}))},_=()=>{I.invalidateQueries({predicate:g=>g.queryKey[0]===Ee.images})},l=(g,b,d)=>JSON.stringify({public:d,source:{type:"snapshot",name:`${g.name}/${b.name}`}}),f=Ne({initialValues:{alias:"",isPublic:!1},validationSchema:Qe().shape({alias:qe()}),onSubmit:g=>{const b=g.alias;sr(l(t,e,g.isPublic),t).then(d=>{v.info(m.jsxs(m.Fragment,{children:["Creation of image from snapshot ",y," started."]})),c.set(d.metadata.id,o=>{var r;if(b){const i=((r=o.metadata.metadata)==null?void 0:r.fingerprint)??"";ir(i,b,t.project).then(_).then(u).catch(h=>{v.failure(`Image creation from snapshot "${e.name}" succeeded. Failed to create an alias.`,h)})}else _(),u()},o=>{v.failure(`Image creation from snapshot "${e.name}" failed.`,new Error(o),y)})}).catch(d=>{v.failure(`Image creation from snapshot "${e.name}" failed.`,d,y)}).finally(()=>{s()})}});return m.jsx(B.Modal,{close:s,title:"Create image from instance snapshot",buttonRow:m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:s,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:f.isSubmitting,disabled:!f.isValid||f.isSubmitting,onClick:()=>void f.submitForm(),children:"Create image"})]}),children:m.jsxs(B.Form,{onSubmit:f.handleSubmit,children:[m.jsx(B.Input,{type:"text",label:"Instance",value:t.name,disabled:!0}),m.jsx(B.Input,{type:"text",label:"Snapshot",value:e.name,disabled:!0}),m.jsx(B.Input,{...f.getFieldProps("alias"),type:"text",label:"Alias",error:f.touched.alias?f.errors.alias:null,disabled:!a(n),title:a(n)?"":"You do not have permission to create image aliases in this project"}),m.jsx(B.Input,{...f.getFieldProps("isPublic"),type:"checkbox",label:"Make the image publicly available",error:f.touched.isPublic?f.errors.isPublic:null}),m.jsx(B.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},fc=({instance:t,snapshot:e,isDeleting:s,isRestoring:c})=>{const{openPortal:v,closePortal:I,isOpen:y,Portal:n}=B.usePortal(),{data:a}=Dt(t.project),{canCreateImages:u}=Ye();return m.jsxs(m.Fragment,{children:[y&&m.jsx(n,{children:m.jsx(_c,{close:I,instance:t,snapshot:e})}),m.jsx(B.Button,{appearance:"base",hasIcon:!0,dense:!0,disabled:s||c||!u(a),onClick:v,type:"button","aria-label":"Create image",title:u(a)?"Create image":"You do not have permission to create images in this project",children:m.jsx(B.Icon,{name:"export"})})]})},pc=(t,e,s)=>{const c={name:t.instanceName,description:e.description,architecture:e.architecture,ephemeral:s.ephemeral,mode:"pull",devices:{...e.devices,root:{path:"/",type:"disk",pool:t.targetStoragePool}}},v={project:e.project,type:"copy",source:`${e.name}/${s.name}`,base_image:s.config["volatile.base_image"]??""};return s.stateful&&t.stateful&&(c.stateful=!0,v.live=!1),{...c,source:v}},mc=({instance:t,snapshot:e,close:s})=>{var h,p,E;const c=B.useToastNotification(),v=ts(),I=Z.useState(null),y=ye(),{data:n=[],isLoading:a}=Lt(),{canCreateInstances:u}=Ye(),{data:_=[],isLoading:l}=rr(),{data:f=[]}=mr(t.project),g=(C,w,S)=>{const x=m.jsx(fe,{instance:{name:C,project:w,type:S}}),M=m.jsxs(m.Fragment,{children:["Created instance ",x,"."]});c.success(M)},b=C=>{const w=f.map(x=>x.name),S=nr(C.name,`-${e.name}-copy`);if(w.includes(S)){let x=1;for(;w.includes(`${S}-${x}`);)x++;return`${S}-${x}`}return S},d=C=>{const w={};return C.stateful&&(C.targetProject===t.project&&(w.targetProject="Stateful instance snapshot duplication must be in a different project"),C.instanceName!==t.name&&(w.instanceName="Instance name must be the same for stateful duplication")),w},o=n.filter(u),r=o.some(C=>C.name===t.project),i=Ne({initialValues:{instanceName:b(t),targetProject:r?t.project:(h=o[0])==null?void 0:h.name,stateful:!1,targetClusterMember:v?t.location:"",targetStoragePool:((p=t.devices.root)==null?void 0:p.pool)??((E=_[0])==null?void 0:E.name)},enableReinitialize:!0,validate:d,validationSchema:Qe().shape({instanceName:Gs(t.project,I).required()}),onSubmit:C=>{const w=m.jsx(fe,{instance:t});ur(JSON.stringify(pc(C,t,e)),C.targetProject,C.targetClusterMember).then(S=>{c.info(m.jsxs(m.Fragment,{children:["Instance creation started for"," ",m.jsx(jt,{bold:!0,type:t.type,value:C.instanceName}),"."]})),y.set(S.metadata.id,()=>{g(C.instanceName,C.targetProject,t.type)},x=>c.failure("Instance creation failed.",new Error(x),w))}).catch(S=>{c.failure("Instance creation failed.",S,w)}).finally(()=>{s()})}});return m.jsx(B.Modal,{close:s,className:"create-instance-from-snapshot-modal",title:"Create instance from snapshot",buttonRow:m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:s,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:i.isSubmitting,disabled:!i.isValid||i.isSubmitting||l||a,onClick:()=>void i.submitForm(),children:"Create"})]}),children:m.jsxs(B.Form,{onSubmit:i.handleSubmit,children:[m.jsx(B.Input,{type:"text",label:"Snapshot name",disabled:!0,value:e.name}),m.jsx(B.Input,{...i.getFieldProps("instanceName"),type:"text",label:"New instance name",error:i.errors.instanceName}),m.jsx(pr,{...i.getFieldProps("targetClusterMember"),id:"targetClusterMember",label:"Target cluster member"}),m.jsx(B.Select,{...i.getFieldProps("targetStoragePool"),id:"storagePool",label:"Storage pool",options:_.map(C=>({label:C.name,value:C.name}))}),m.jsx(B.Select,{...i.getFieldProps("targetProject"),id:"project",label:"Target project",options:o.map(C=>({label:C.name,value:C.name})),error:i.errors.targetProject}),e.stateful&&m.jsx(B.Input,{...i.getFieldProps("stateful"),type:"checkbox",label:"Copy stateful"}),m.jsx(B.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},gc=({instance:t,snapshot:e,isDeleting:s,isRestoring:c})=>{const{openPortal:v,closePortal:I,isOpen:y,Portal:n}=B.usePortal(),{data:a=[]}=Lt(),{canCreateInstances:u}=Ye(),_=a.filter(u);return m.jsxs(m.Fragment,{children:[y&&m.jsx(n,{children:m.jsx(mc,{close:I,instance:t,snapshot:e})}),m.jsx(B.Button,{appearance:"base",hasIcon:!0,dense:!0,"aria-label":"Create instance",disabled:s||c||!_.length,onClick:v,title:_.length>0?"Create instance":"You do not have permission to create instances",children:m.jsx(B.Icon,{name:"plus"})})]})},vc=({instance:t,snapshot:e,onSuccess:s,onFailure:c})=>{const v=ye(),[I,y]=Z.useState(!1),[n,a]=Z.useState(!1),[u,_]=Z.useState(!0),l=Oe(),{canManageInstanceSnapshots:f}=Ue(),g=f(t)?void 0:"You do not have permission to manage snapshots for this instance",b=()=>{y(!0),yr(t,e).then(o=>{v.set(o.metadata.id,()=>{s(m.jsxs(m.Fragment,{children:["Snapshot"," ",m.jsx(jt,{bold:!0,type:"snapshot",value:e.name})," ","deleted for instance ",m.jsx(fe,{instance:t}),"."]}))},r=>{c("Snapshot deletion failed",new Error(r))},()=>{y(!1),l.invalidateQueries({predicate:r=>r.queryKey[0]===Ee.instances})})}).catch(o=>{c("Snapshot deletion failed",o),y(!1)})},d=()=>{a(!0),oc(t,e,u).then(o=>{v.set(o.metadata.id,()=>{s(m.jsxs(m.Fragment,{children:["Snapshot"," ",m.jsx(It,{name:e.name,instance:t})," ","restored for instance ",m.jsx(fe,{instance:t}),"."]}))},r=>{c("Snapshot restore failed",new Error(r))},()=>{a(!1),l.invalidateQueries({predicate:r=>r.queryKey[0]===Ee.instances})})}).catch(o=>{c("Snapshot restore failed",o),a(!1)})};return m.jsx(m.Fragment,{children:m.jsx(B.List,{inline:!0,className:st("u-no-margin--bottom","actions-list",{"u-snapshot-actions":!I&&!n}),items:[m.jsx(dc,{instance:t,snapshot:e,onSuccess:s,isDeleting:I,isRestoring:n,disabledReason:g},"edit"),m.jsx(B.ConfirmationButton,{appearance:"base",loading:n,className:"has-icon is-dense",title:"Confirm restore",confirmationModalProps:{title:"Confirm restore",children:m.jsxs("p",{children:["This will restore snapshot"," ",m.jsx(jt,{type:"snapshot",value:e.name,bold:!0}),".",m.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmExtra:e.stateful?m.jsx(Bo,{label:"Restore the instance state",force:[u,_]}):void 0,confirmButtonLabel:g??"Restore snapshot",confirmButtonAppearance:"positive",close:()=>{_(!0)},onConfirm:d},disabled:I||n||!!g,shiftClickEnabled:!0,showShiftClickHint:!0,children:m.jsx(B.Icon,{name:"change-version"})},"restore"),m.jsx(fc,{instance:t,snapshot:e,isRestoring:n,isDeleting:I},"publish"),m.jsx(gc,{instance:t,snapshot:e,isDeleting:I,isRestoring:n},"duplicate"),m.jsx(B.ConfirmationButton,{appearance:"base",loading:I,className:"has-icon is-dense",confirmationModalProps:{title:"Confirm delete",children:m.jsxs("p",{children:["This will permanently delete snapshot"," ",m.jsx(jt,{type:"snapshot",value:e.name,bold:!0}),".",m.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:g??"Delete snapshot",onConfirm:b},disabled:I||n||!!g,shiftClickEnabled:!0,showShiftClickHint:!0,children:m.jsx(B.Icon,{name:"delete"})},"delete")]})})},Sc=({instance:t,snapshotNames:e,onStart:s,onFinish:c,onSuccess:v,onFailure:I})=>{const y=ye(),[n,a]=Z.useState(!1),u=Oe(),{canManageInstanceSnapshots:_}=Ue(),l=ra(),f=e.length,g=()=>{a(!0),s(),nc(t,e,y).then(b=>{const{fulfilledCount:d,rejectedCount:o}=So(b);d===f?v(m.jsxs(m.Fragment,{children:[m.jsx("b",{children:e.length})," ",ot("snapshot",e.length)," deleted."]}),l(b)):o===f?I("Snapshot bulk deletion failed",void 0,m.jsxs(m.Fragment,{children:[m.jsx("b",{children:f})," ",ot("snapshot",f)," could not be deleted."]}),l(b)):I("Snapshot bulk deletion partially failed",void 0,m.jsxs(m.Fragment,{children:[m.jsx("b",{children:d})," ",ot("snapshot",d)," ","deleted.",m.jsx("br",{}),m.jsx("b",{children:o})," ",ot("snapshot",o)," ","could not be deleted."]}),l(b)),u.invalidateQueries({predicate:r=>r.queryKey[0]===Ee.instances}),a(!1),c()}).catch(b=>{I("Snapshot bulk deletion failed",b),a(!1)})};return m.jsx(ia,{confirmationButtonProps:{loading:n,disabled:n||!_(t),appearance:""},onDelete:g,entityType:"snapshot",entities:e,deletableEntities:e,disabledReason:_(t)?void 0:"You do not have permission to manage snapshots for this instance",buttonLabel:`Delete ${ot("snapshot",e.length)}`})},bc=({instance:t,close:e,onSuccess:s,onFailure:c})=>{const v=ye(),{project:I}=tt(),y=Oe(),n=Ne({initialValues:at(t),validationSchema:gr,onSubmit:u=>{const _=Ht(t,u);xt(_,I??"").then(l=>{v.set(l.metadata.id,()=>{s("Configuration updated.")},f=>{c("Configuration update failed",new Error(f))},()=>{e(),y.invalidateQueries({queryKey:[Ee.instances]})})}).catch(l=>{c("Configuration update failed",l)})}}),a=u=>{u.key==="Escape"&&e()};return m.jsx(B.Modal,{close:e,className:"edit-snapshot-config",title:"Snapshot configuration",buttonRow:n.values.readOnly?m.jsx(B.Button,{className:"u-no-margin--bottom u-no-margin--right",onClick:e,children:"Close"}):m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:n.isSubmitting,disabled:n.isSubmitting,onClick:()=>void n.submitForm(),children:"Save"})]}),onKeyDown:a,children:m.jsx(vr,{formik:n})})},Ii=({instance:t,onSuccess:e,onFailure:s,isDisabled:c,className:v})=>{const{openPortal:I,closePortal:y,isOpen:n,Portal:a}=B.usePortal(),{canEditInstance:u}=Ue();return m.jsxs(m.Fragment,{children:[n&&m.jsx(a,{children:m.jsx("div",{className:"snapshot-list",children:m.jsx(bc,{close:y,instance:t,onSuccess:e,onFailure:s})})}),m.jsx(B.Button,{onClick:I,className:v,disabled:c||!u(t),title:u()?"":"You do not have permission to configure this instance",children:"See configuration"})]})},Cc=150,Ec=({close:t,instance:e,onSuccess:s})=>{const c=ye(),v=B.useNotify(),I=B.useToastNotification(),y=Oe(),n=Z.useState(null),a=Ne({initialValues:{name:"",stateful:!1,expirationDate:null,expirationTime:null},validateOnMount:!0,validationSchema:wr(e,n),onSubmit:(g,{resetForm:b})=>{v.clear();const d=g.expirationDate&&g.expirationTime?tr(fr(g.expirationDate,g.expirationTime)):Rs,o=m.jsx(fe,{instance:e});rc(e,g.name,d,g.stateful||!1).then(r=>{c.set(r.metadata.id,()=>{y.invalidateQueries({predicate:i=>i.queryKey[0]===Ee.instances}),s(m.jsxs(m.Fragment,{children:["Snapshot"," ",m.jsx(It,{name:bo(r.metadata),instance:e})," ","created for instance ",o,"."]})),b(),t()},i=>{I.failure(`Snapshot creation failed for instance ${e.name}`,new Error(i),o),a.setSubmitting(!1),t()})}).catch(r=>{v.failure("Snapshot creation failed",r,o),a.setSubmitting(!1),t()})}});let u=m.jsxs(m.Fragment,{children:[`To create a stateful snapshot, the instance needs `,"the ",m.jsx("code",{children:"migration.stateful"})," config set to true"]});const _=hc(e),l=e.status==="Running";_&&(u=`To create a stateful snapshot, the instance must be running`),_&&l&&(u="");const f=m.jsx(B.List,{inline:!0,items:[m.jsx(B.Input,{id:"stateful",name:"stateful",type:"checkbox",label:"Stateful",wrapperClassName:"u-inline-block",disabled:!_||!l,onChange:a.handleChange,onBlur:a.handleBlur,defaultChecked:a.values.stateful},"stateful"),...u?[m.jsx(B.Tooltip,{position:"btm-left",message:u,zIndex:Cc,children:m.jsx(B.Icon,{name:"information"})},"stateful-info")]:[]]});return m.jsx(_r,{isEdit:!1,formik:a,close:t,additionalFormInput:f})},Ai=({instance:t,onSuccess:e,isDisabled:s,className:c})=>{const{openPortal:v,closePortal:I,isOpen:y,Portal:n}=B.usePortal(),{canManageInstanceSnapshots:a}=Ue();return m.jsxs(m.Fragment,{children:[y&&m.jsx(n,{children:m.jsx(Ec,{close:I,instance:t,onSuccess:e})}),m.jsx(B.Button,{appearance:"positive",className:c,onClick:v,disabled:s||!a(t),title:a(t)?"":"You do not have permission to create snapshots for this instance",children:s?m.jsx(B.Tooltip,{message:`Snapshot creation has been disabled for instances in the project ${t.project}`,children:"Create snapshot"}):"Create snapshot"})]})},yc=1250,Pi=()=>window.innerWidth<=yc,wc=t=>{var w,S;const{instance:e}=t,[s,c]=Z.useState(""),v=B.useNotify(),I=B.useToastNotification(),[y,n]=Z.useState([]),[a,u]=Z.useState([]),[_,l]=Z.useState(Pi()),{project:f}=Ys(),g=Jo(f),b=(x,M)=>{I.success(x,M)},d=(x,M,k,N)=>{v.failure(x,M,k,N)};Z.useEffect(()=>{var k;const x=new Set((k=e.snapshots)==null?void 0:k.map(N=>N.name)),M=y.filter(N=>x.has(N));M.length!==y.length&&n(M)},[e.snapshots]);const o=((w=e.snapshots)==null?void 0:w.filter(x=>!(s&&!x.name.toLowerCase().includes(s.toLowerCase()))))??[],r=e.snapshots&&e.snapshots.length>0,i=[{content:_?m.jsxs(m.Fragment,{children:["Name",m.jsx("br",{}),m.jsx("div",{className:"header-second-row",children:"Date created"})]}):"Name",sortKey:_?"created_at":"name",className:"name"},..._?[]:[{content:"Date created",sortKey:"created_at",className:"created"}],{content:"Expiry date",sortKey:"expires_at",className:"expiration"},{content:"Stateful",sortKey:"stateful",className:"stateful"},{"aria-label":"Actions",className:"actions"}],h=o.map(x=>{const M=m.jsx(vc,{instance:e,snapshot:x,onSuccess:b,onFailure:d});return{key:x.name,className:"u-row",name:x.name,columns:[{content:m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"u-truncate",title:`Snapshot ${x.name}`,children:m.jsx(ta,{item:x})}),_&&m.jsx("div",{className:"u-text--muted",children:yt(x.created_at)})]}),role:"rowheader","aria-label":"Name",className:"name"},..._?[]:[{content:yt(x.created_at),role:"cell","aria-label":"Created at",className:"created"}],{content:yt(x.expires_at),role:"cell","aria-label":"Expires at",className:"expiration"},{content:x.stateful?"Yes":"No",role:"cell","aria-label":"Stateful",className:"stateful"},{content:M,role:"cell","aria-label":"Actions",className:"u-align--right actions"}],sortData:{name:x.name.toLowerCase(),created_at:x.created_at,expires_at:x.expires_at,stateful:x.stateful}}}),{rows:p,updateSort:E}=pa({rows:h,defaultSort:"created_at",defaultSortDirection:"descending"}),C=()=>{l(Pi())};return B.useListener(window,C,"resize",!0),m.jsxs("div",{className:"snapshot-list",children:[r&&m.jsx("div",{className:"upper-controls-bar",children:y.length===0?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"search-box-wrapper",children:m.jsx(B.SearchBox,{name:"search-snapshot",className:"search-box margin-right",type:"text",onChange:x=>{c(x)},placeholder:"Search for snapshots",value:s,"aria-label":"Search for snapshots"})}),m.jsx(Ii,{instance:e,className:"u-no-margin--right",onFailure:d,onSuccess:b}),m.jsx(Ai,{instance:e,onSuccess:b,onFailure:d,className:"u-float-right",isDisabled:g})]}):m.jsx("div",{className:"p-panel__controls",children:m.jsx(Sc,{instance:e,snapshotNames:y,onStart:()=>{u(y)},onFinish:()=>{u([])},onSuccess:b,onFailure:d})})}),m.jsx(ss,{}),r?m.jsx(m.Fragment,{children:m.jsx(B.ScrollableTable,{dependencies:[o,v.notification],tableId:"instance-snapshot-table",belowIds:["status-bar"],children:m.jsx(B.TablePagination,{data:p,id:"pagination",itemName:"snapshot",className:"u-no-margin--top","aria-label":"Table pagination control",description:y.length>0&&m.jsx(na,{totalCount:((S=e.snapshots)==null?void 0:S.length)??0,itemName:"snapshot",parentName:"instance",selectedNames:y,setSelectedNames:n,filteredNames:o.map(x=>x.name)}),children:m.jsx(sa,{id:"instance-snapshot-table",headers:i,rows:p,responsive:!0,sortable:!0,emptyStateMsg:"No snapshot found matching this search",itemName:"snapshot",parentName:"instance",selectedNames:y,setSelectedNames:n,disabledNames:a,filteredNames:o.map(x=>x.name),onUpdateSort:E,defaultSort:"created_at",defaultSortDirection:"descending"})})})}):m.jsxs(B.EmptyState,{className:"empty-state",image:m.jsx(B.Icon,{name:"snapshot",className:"empty-state-icon"}),title:"No snapshots found",children:[m.jsx("p",{children:f&&g?m.jsxs(m.Fragment,{children:["Snapshots are disabled for project"," ",m.jsx(Fe,{type:"project",value:f.name,to:`/ui/project/${f.name}/configuration`}),"."]}):"There are no snapshots of this instance."}),m.jsx("p",{children:m.jsx(Co,{docPath:"/howto/storage_backup_volume/#storage-backup-snapshots",hasExternalIcon:!0,children:"Learn more about snapshots"})}),m.jsx(Ii,{instance:e,onFailure:d,onSuccess:b,isDisabled:g}),m.jsx(Ai,{instance:e,onSuccess:b,onFailure:d,className:"empty-state-button",isDisabled:g})]})]})};var R={SPICE_MAGIC:"REDQ",SPICE_VERSION_MAJOR:2,SPICE_VERSION_MINOR:2,SPICE_CONNECT_TIMEOUT:30*1e3,SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION:0,SPICE_COMMON_CAP_AUTH_SPICE:1,SPICE_COMMON_CAP_MINI_HEADER:3,SPICE_TICKET_KEY_PAIR_LENGTH:1024,SPICE_TICKET_PUBKEY_BYTES:1024/8+34,SPICE_LINK_ERR_OK:0,SPICE_LINK_ERR_PERMISSION_DENIED:7,SPICE_MSG_SET_ACK:3,SPICE_MSG_PING:4,SPICE_MSG_NOTIFY:7,SPICE_MSG_MAIN_MIGRATE_BEGIN:101,SPICE_MSG_MAIN_MIGRATE_CANCEL:102,SPICE_MSG_MAIN_INIT:103,SPICE_MSG_MAIN_CHANNELS_LIST:104,SPICE_MSG_MAIN_MOUSE_MODE:105,SPICE_MSG_MAIN_MULTI_MEDIA_TIME:106,SPICE_MSG_MAIN_AGENT_CONNECTED:107,SPICE_MSG_MAIN_AGENT_DISCONNECTED:108,SPICE_MSG_MAIN_AGENT_DATA:109,SPICE_MSG_MAIN_AGENT_TOKEN:110,SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST:111,SPICE_MSG_MAIN_MIGRATE_END:112,SPICE_MSG_MAIN_NAME:113,SPICE_MSG_MAIN_UUID:114,SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS:115,SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS:116,SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK:117,SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK:118,SPICE_MSGC_ACK_SYNC:1,SPICE_MSGC_ACK:2,SPICE_MSGC_PONG:3,SPICE_MSGC_MAIN_ATTACH_CHANNELS:104,SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST:105,SPICE_MSGC_MAIN_AGENT_START:106,SPICE_MSGC_MAIN_AGENT_DATA:107,SPICE_MSG_DISPLAY_MODE:101,SPICE_MSG_DISPLAY_MARK:102,SPICE_MSG_DISPLAY_RESET:103,SPICE_MSG_DISPLAY_COPY_BITS:104,SPICE_MSG_DISPLAY_INVAL_LIST:105,SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS:106,SPICE_MSG_DISPLAY_INVAL_PALETTE:107,SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES:108,SPICE_MSG_DISPLAY_STREAM_CREATE:122,SPICE_MSG_DISPLAY_STREAM_DATA:123,SPICE_MSG_DISPLAY_STREAM_CLIP:124,SPICE_MSG_DISPLAY_STREAM_DESTROY:125,SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL:126,SPICE_MSG_DISPLAY_DRAW_FILL:302,SPICE_MSG_DISPLAY_DRAW_OPAQUE:303,SPICE_MSG_DISPLAY_DRAW_COPY:304,SPICE_MSG_DISPLAY_DRAW_BLEND:305,SPICE_MSG_DISPLAY_DRAW_BLACKNESS:306,SPICE_MSG_DISPLAY_DRAW_WHITENESS:307,SPICE_MSG_DISPLAY_DRAW_INVERS:308,SPICE_MSG_DISPLAY_DRAW_ROP3:309,SPICE_MSG_DISPLAY_DRAW_STROKE:310,SPICE_MSG_DISPLAY_DRAW_TRANSPARENT:312,SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND:313,SPICE_MSG_DISPLAY_SURFACE_CREATE:314,SPICE_MSG_DISPLAY_SURFACE_DESTROY:315,SPICE_MSG_DISPLAY_STREAM_DATA_SIZED:316,SPICE_MSG_DISPLAY_MONITORS_CONFIG:317,SPICE_MSG_DISPLAY_DRAW_COMPOSITE:318,SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT:319,SPICE_MSGC_DISPLAY_INIT:101,SPICE_MSGC_DISPLAY_STREAM_REPORT:102,SPICE_MSG_INPUTS_INIT:101,SPICE_MSG_INPUTS_KEY_MODIFIERS:102,SPICE_MSG_INPUTS_MOUSE_MOTION_ACK:111,SPICE_MSGC_INPUTS_KEY_DOWN:101,SPICE_MSGC_INPUTS_KEY_UP:102,SPICE_MSGC_INPUTS_MOUSE_MOTION:111,SPICE_MSGC_INPUTS_MOUSE_POSITION:112,SPICE_MSGC_INPUTS_MOUSE_PRESS:113,SPICE_MSGC_INPUTS_MOUSE_RELEASE:114,SPICE_MSG_CURSOR_INIT:101,SPICE_MSG_CURSOR_RESET:102,SPICE_MSG_CURSOR_SET:103,SPICE_MSG_CURSOR_MOVE:104,SPICE_MSG_CURSOR_HIDE:105,SPICE_MSG_CURSOR_TRAIL:106,SPICE_MSG_CURSOR_INVAL_ONE:107,SPICE_MSG_CURSOR_INVAL_ALL:108,SPICE_MSG_PLAYBACK_DATA:101,SPICE_MSG_PLAYBACK_MODE:102,SPICE_MSG_PLAYBACK_START:103,SPICE_MSG_PLAYBACK_STOP:104,SPICE_MSG_PLAYBACK_VOLUME:105,SPICE_MSG_PLAYBACK_MUTE:106,SPICE_MSG_PLAYBACK_LATENCY:107,SPICE_MSG_SPICEVMC_DATA:101,SPICE_MSG_PORT_INIT:201,SPICE_MSG_PORT_EVENT:202,SPICE_PLAYBACK_CAP_OPUS:3,SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS:2,SPICE_DISPLAY_CAP_SIZED_STREAM:0,SPICE_DISPLAY_CAP_STREAM_REPORT:4,SPICE_DISPLAY_CAP_MULTI_CODEC:8,SPICE_DISPLAY_CAP_CODEC_MJPEG:9,SPICE_DISPLAY_CAP_CODEC_VP8:10,SPICE_AUDIO_DATA_MODE_OPUS:3,SPICE_AUDIO_FMT_S16:1,SPICE_CHANNEL_MAIN:1,SPICE_CHANNEL_DISPLAY:2,SPICE_CHANNEL_INPUTS:3,SPICE_CHANNEL_CURSOR:4,SPICE_CHANNEL_PLAYBACK:5,SPICE_CHANNEL_RECORD:6,SPICE_CHANNEL_TUNNEL:7,SPICE_CHANNEL_SMARTCARD:8,SPICE_CHANNEL_USBREDIR:9,SPICE_CHANNEL_PORT:10,SPICE_CHANNEL_WEBDAV:11,SPICE_SURFACE_FLAGS_PRIMARY:1,SPICE_NOTIFY_SEVERITY_WARN:1,SPICE_NOTIFY_SEVERITY_ERROR:2,SPICE_MOUSE_MODE_SERVER:1,SPICE_MOUSE_MODE_CLIENT:2,SPICE_CLIP_TYPE_NONE:0,SPICE_CLIP_TYPE_RECTS:1,SPICE_IMAGE_TYPE_BITMAP:0,SPICE_IMAGE_TYPE_QUIC:1,SPICE_IMAGE_TYPE_LZ_RGB:101,SPICE_IMAGE_TYPE_FROM_CACHE:103,SPICE_IMAGE_TYPE_SURFACE:104,SPICE_IMAGE_TYPE_JPEG:105,SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS:106,SPICE_IMAGE_TYPE_JPEG_ALPHA:108,SPICE_IMAGE_FLAGS_CACHE_ME:1,SPICE_IMAGE_FLAGS_HIGH_BITS_SET:2,SPICE_BITMAP_FLAGS_PAL_FROM_CACHE:2,SPICE_BITMAP_FLAGS_TOP_DOWN:4,SPICE_BITMAP_FMT_32BIT:8,SPICE_BITMAP_FMT_RGBA:9,SPICE_CURSOR_FLAGS_NONE:1,SPICE_MOUSE_BUTTON_MASK_LEFT:1,SPICE_MOUSE_BUTTON_LEFT:1,SPICE_MOUSE_BUTTON_UP:4,SPICE_MOUSE_BUTTON_DOWN:5,SPICE_BRUSH_TYPE_SOLID:1,SPICE_BRUSH_TYPE_PATTERN:2,SPICE_SURFACE_FMT_32_xRGB:32,SPICE_SURFACE_FMT_32_ARGB:96,SPICE_ROPD_OP_PUT:8,LZ_IMAGE_TYPE_RGB32:8,LZ_IMAGE_TYPE_RGBA:9,LZ_IMAGE_TYPE_XXXA:10,SPICE_INPUT_MOTION_ACK_BUNCH:4,SPICE_CURSOR_TYPE_ALPHA:0,SPICE_VIDEO_CODEC_TYPE_MJPEG:1,SPICE_VIDEO_CODEC_TYPE_VP8:2,VD_AGENT_PROTOCOL:1,VD_AGENT_MAX_DATA_SIZE:2048,VD_AGENT_MONITORS_CONFIG:2,VD_AGENT_ANNOUNCE_CAPABILITIES:6,VD_AGENT_FILE_XFER_START:10,VD_AGENT_FILE_XFER_STATUS:11,VD_AGENT_FILE_XFER_DATA:12,VD_AGENT_CAP_MOUSE_STATE:0,VD_AGENT_CAP_MONITORS_CONFIG:1,VD_AGENT_CAP_REPLY:2,VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:0,VD_AGENT_FILE_XFER_STATUS_CANCELLED:1,VD_AGENT_FILE_XFER_STATUS_ERROR:2,VD_AGENT_FILE_XFER_STATUS_SUCCESS:3};function ee(t,e,s){e!==void 0?s!==void 0?this.u8=new Uint8Array(t,e,s):this.u8=new Uint8Array(t,e):this.u8=new Uint8Array(t)}ee.prototype={getUint8:function(t){return this.u8[t]},getUint16:function(t,e){var s=1,c=0;return e&&(s=0,c=1),this.u8[t+c]<<8|this.u8[t+s]},getUint32:function(t,e){var s=2,c=0;return e&&(s=0,c=2),this.getUint16(t+c,e)<<16|this.getUint16(t+s,e)},getUint64:function(t,e){var s=4,c=0;return e&&(s=0,c=4),this.getUint32(t+c,e)<<32|this.getUint32(t+s,e)},setUint8:function(t,e){this.u8[t]=e&255},setUint16:function(t,e,s){var c=1,v=0;s&&(c=0,v=1),this.u8[t+v]=(e&65535)>>8,this.u8[t+c]=e&255},setUint32:function(t,e,s){var c=2,v=0;s&&(c=0,v=2),this.setUint16(t+v,(e&4294967295)>>16,s),this.setUint16(t+c,e&65535,s)},setUint64:function(t,e,s){var c=4,v=0;s&&(c=0,v=4),this.setUint32(t+v,(e&18446744073709552e3)>>32,s),this.setUint32(t+c,e&4294967295,s)}};var Xe;function ie(t,e,s){t!=null&&(typeof t=="number"?this.fromNumber(t,e,s):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}function He(){return new ie(null)}function xc(t,e,s,c,v,I){for(;--I>=0;){var y=e*this[t++]+s[c]+v;v=Math.floor(y/67108864),s[c++]=y&67108863}return v}function Ic(t,e,s,c,v,I){for(var y=e&32767,n=e>>15;--I>=0;){var a=this[t]&32767,u=this[t++]>>15,_=n*a+u*y;a=y*a+((_&32767)<<15)+s[c]+(v&1073741823),v=(a>>>30)+(_>>>15)+n*u+(v>>>30),s[c++]=a&1073741823}return v}function Ac(t,e,s,c,v,I){for(var y=e&16383,n=e>>14;--I>=0;){var a=this[t]&16383,u=this[t++]>>14,_=n*a+u*y;a=y*a+((_&16383)<<14)+s[c]+v,v=(a>>28)+(_>>14)+n*u,s[c++]=a&268435455}return v}navigator.appName=="Microsoft Internet Explorer"?(ie.prototype.am=Ic,Xe=30):navigator.appName!="Netscape"?(ie.prototype.am=xc,Xe=26):(ie.prototype.am=Ac,Xe=28);ie.prototype.DB=Xe;ie.prototype.DM=(1<<Xe)-1;ie.prototype.DV=1<<Xe;var Ws=52;ie.prototype.FV=Math.pow(2,Ws);ie.prototype.F1=Ws-Xe;ie.prototype.F2=2*Xe-Ws;var Pc="0123456789abcdefghijklmnopqrstuvwxyz",ns=new Array,lt,Te;lt=48;for(Te=0;Te<=9;++Te)ns[lt++]=Te;lt=97;for(Te=10;Te<36;++Te)ns[lt++]=Te;lt=65;for(Te=10;Te<36;++Te)ns[lt++]=Te;function Di(t){return Pc.charAt(t)}function Dc(t,e){var s=ns[t.charCodeAt(e)];return s??-1}function Lc(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function Mc(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+DV:this.t=0}function xr(t){var e=He();return e.fromInt(t),e}function Rc(t,e){var s;if(e==16)s=4;else if(e==8)s=3;else if(e==256)s=8;else if(e==2)s=1;else if(e==32)s=5;else if(e==4)s=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var c=t.length,v=!1,I=0;--c>=0;){var y=s==8?t[c]&255:Dc(t,c);if(y<0){t.charAt(c)=="-"&&(v=!0);continue}v=!1,I==0?this[this.t++]=y:I+s>this.DB?(this[this.t-1]|=(y&(1<<this.DB-I)-1)<<I,this[this.t++]=y>>this.DB-I):this[this.t-1]|=y<<I,I+=s,I>=this.DB&&(I-=this.DB)}s==8&&(t[0]&128)!=0&&(this.s=-1,I>0&&(this[this.t-1]|=(1<<this.DB-I)-1<<I)),this.clamp(),v&&ie.ZERO.subTo(this,this)}function Tc(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function kc(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var s=(1<<e)-1,c,v=!1,I="",y=this.t,n=this.DB-y*this.DB%e;if(y-- >0)for(n<this.DB&&(c=this[y]>>n)>0&&(v=!0,I=Di(c));y>=0;)n<e?(c=(this[y]&(1<<n)-1)<<e-n,c|=this[--y]>>(n+=this.DB-e)):(c=this[y]>>(n-=e)&s,n<=0&&(n+=this.DB,--y)),c>0&&(v=!0),v&&(I+=Di(c));return v?I:"0"}function Bc(){var t=He();return ie.ZERO.subTo(this,t),t}function Oc(){return this.s<0?this.negate():this}function Nc(t){var e=this.s-t.s;if(e!=0)return e;var s=this.t;if(e=s-t.t,e!=0)return e;for(;--s>=0;)if((e=this[s]-t[s])!=0)return e;return 0}function $s(t){var e=1,s;return(s=t>>>16)!=0&&(t=s,e+=16),(s=t>>8)!=0&&(t=s,e+=8),(s=t>>4)!=0&&(t=s,e+=4),(s=t>>2)!=0&&(t=s,e+=2),(s=t>>1)!=0&&(t=s,e+=1),e}function Uc(){return this.t<=0?0:this.DB*(this.t-1)+$s(this[this.t-1]^this.s&this.DM)}function jc(t,e){var s;for(s=this.t-1;s>=0;--s)e[s+t]=this[s];for(s=t-1;s>=0;--s)e[s]=0;e.t=this.t+t,e.s=this.s}function Fc(t,e){for(var s=t;s<this.t;++s)e[s-t]=this[s];e.t=Math.max(this.t-t,0),e.s=this.s}function Hc(t,e){var s=t%this.DB,c=this.DB-s,v=(1<<c)-1,I=Math.floor(t/this.DB),y=this.s<<s&this.DM,n;for(n=this.t-1;n>=0;--n)e[n+I+1]=this[n]>>c|y,y=(this[n]&v)<<s;for(n=I-1;n>=0;--n)e[n]=0;e[I]=y,e.t=this.t+I+1,e.s=this.s,e.clamp()}function Kc(t,e){e.s=this.s;var s=Math.floor(t/this.DB);if(s>=this.t){e.t=0;return}var c=t%this.DB,v=this.DB-c,I=(1<<c)-1;e[0]=this[s]>>c;for(var y=s+1;y<this.t;++y)e[y-s-1]|=(this[y]&I)<<v,e[y-s]=this[y]>>c;c>0&&(e[this.t-s-1]|=(this.s&I)<<v),e.t=this.t-s,e.clamp()}function Gc(t,e){for(var s=0,c=0,v=Math.min(t.t,this.t);s<v;)c+=this[s]-t[s],e[s++]=c&this.DM,c>>=this.DB;if(t.t<this.t){for(c-=t.s;s<this.t;)c+=this[s],e[s++]=c&this.DM,c>>=this.DB;c+=this.s}else{for(c+=this.s;s<t.t;)c-=t[s],e[s++]=c&this.DM,c>>=this.DB;c-=t.s}e.s=c<0?-1:0,c<-1?e[s++]=this.DV+c:c>0&&(e[s++]=c),e.t=s,e.clamp()}function Yc(t,e){var s=this.abs(),c=t.abs(),v=s.t;for(e.t=v+c.t;--v>=0;)e[v]=0;for(v=0;v<c.t;++v)e[v+s.t]=s.am(0,c[v],e,v,0,s.t);e.s=0,e.clamp(),this.s!=t.s&&ie.ZERO.subTo(e,e)}function zc(t){for(var e=this.abs(),s=t.t=2*e.t;--s>=0;)t[s]=0;for(s=0;s<e.t-1;++s){var c=e.am(s,e[s],t,2*s,0,1);(t[s+e.t]+=e.am(s+1,2*e[s],t,2*s+1,c,e.t-s-1))>=e.DV&&(t[s+e.t]-=e.DV,t[s+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(s,e[s],t,2*s,0,1)),t.s=0,t.clamp()}function Wc(t,e,s){var c=t.abs();if(!(c.t<=0)){var v=this.abs();if(v.t<c.t){e!=null&&e.fromInt(0),s!=null&&this.copyTo(s);return}s==null&&(s=He());var I=He(),y=this.s,n=t.s,a=this.DB-$s(c[c.t-1]);a>0?(c.lShiftTo(a,I),v.lShiftTo(a,s)):(c.copyTo(I),v.copyTo(s));var u=I.t,_=I[u-1];if(_!=0){var l=_*(1<<this.F1)+(u>1?I[u-2]>>this.F2:0),f=this.FV/l,g=(1<<this.F1)/l,b=1<<this.F2,d=s.t,o=d-u,r=e??He();for(I.dlShiftTo(o,r),s.compareTo(r)>=0&&(s[s.t++]=1,s.subTo(r,s)),ie.ONE.dlShiftTo(u,r),r.subTo(I,I);I.t<u;)I[I.t++]=0;for(;--o>=0;){var i=s[--d]==_?this.DM:Math.floor(s[d]*f+(s[d-1]+b)*g);if((s[d]+=I.am(0,i,s,o,0,u))<i)for(I.dlShiftTo(o,r),s.subTo(r,s);s[d]<--i;)s.subTo(r,s)}e!=null&&(s.drShiftTo(u,e),y!=n&&ie.ZERO.subTo(e,e)),s.t=u,s.clamp(),a>0&&s.rShiftTo(a,s),y<0&&ie.ZERO.subTo(s,s)}}}function $c(t){var e=He();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(ie.ZERO)>0&&t.subTo(e,e),e}function ut(t){this.m=t}function Vc(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function qc(t){return t}function Xc(t){t.divRemTo(this.m,null,t)}function Qc(t,e,s){t.multiplyTo(e,s),this.reduce(s)}function Jc(t,e){t.squareTo(e),this.reduce(e)}ut.prototype.convert=Vc;ut.prototype.revert=qc;ut.prototype.reduce=Xc;ut.prototype.mulTo=Qc;ut.prototype.sqrTo=Jc;function Zc(){if(this.t<1)return 0;var t=this[0];if((t&1)==0)return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function dt(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function eh(t){var e=He();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(ie.ZERO)>0&&this.m.subTo(e,e),e}function th(t){var e=He();return t.copyTo(e),this.reduce(e),e}function sh(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var s=t[e]&32767,c=s*this.mpl+((s*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(s=e+this.m.t,t[s]+=this.m.am(0,c,t,e,0,this.m.t);t[s]>=t.DV;)t[s]-=t.DV,t[++s]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function ih(t,e){t.squareTo(e),this.reduce(e)}function rh(t,e,s){t.multiplyTo(e,s),this.reduce(s)}dt.prototype.convert=eh;dt.prototype.revert=th;dt.prototype.reduce=sh;dt.prototype.mulTo=rh;dt.prototype.sqrTo=ih;function nh(){return(this.t>0?this[0]&1:this.s)==0}function oh(t,e){if(t>4294967295||t<1)return ie.ONE;var s=He(),c=He(),v=e.convert(this),I=$s(t)-1;for(v.copyTo(s);--I>=0;)if(e.sqrTo(s,c),(t&1<<I)>0)e.mulTo(c,v,s);else{var y=s;s=c,c=y}return e.revert(s)}function ah(t,e){var s;return t<256||e.isEven()?s=new ut(e):s=new dt(e),this.exp(t,s)}ie.prototype.copyTo=Lc;ie.prototype.fromInt=Mc;ie.prototype.fromString=Rc;ie.prototype.clamp=Tc;ie.prototype.dlShiftTo=jc;ie.prototype.drShiftTo=Fc;ie.prototype.lShiftTo=Hc;ie.prototype.rShiftTo=Kc;ie.prototype.subTo=Gc;ie.prototype.multiplyTo=Yc;ie.prototype.squareTo=zc;ie.prototype.divRemTo=Wc;ie.prototype.invDigit=Zc;ie.prototype.isEven=nh;ie.prototype.exp=oh;ie.prototype.toString=kc;ie.prototype.negate=Bc;ie.prototype.abs=Oc;ie.prototype.compareTo=Nc;ie.prototype.bitLength=Uc;ie.prototype.mod=$c;ie.prototype.modPowInt=ah;ie.ZERO=xr(0);ie.ONE=xr(1);function Vs(){this.i=0,this.j=0,this.S=new Array}function ch(t){var e,s,c;for(e=0;e<256;++e)this.S[e]=e;for(s=0,e=0;e<256;++e)s=s+this.S[e]+t[e%t.length]&255,c=this.S[e],this.S[e]=this.S[s],this.S[s]=c;this.i=0,this.j=0}function hh(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}Vs.prototype.init=ch;Vs.prototype.next=hh;function lh(){return new Vs}var Ts=256,Bt,Re,be;function uh(t){Re[be++]^=t&255,Re[be++]^=t>>8&255,Re[be++]^=t>>16&255,Re[be++]^=t>>24&255,be>=Ts&&(be-=Ts)}function Ir(){uh(new Date().getTime())}if(Re==null){Re=new Array,be=0;var Ze;if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var Li=window.crypto.random(32);for(Ze=0;Ze<Li.length;++Ze)Re[be++]=Li.charCodeAt(Ze)&255}for(;be<Ts;)Ze=Math.floor(65536*Math.random()),Re[be++]=Ze>>>8,Re[be++]=Ze&255;be=0,Ir()}function dh(){if(Bt==null){for(Ir(),Bt=lh(),Bt.init(Re),be=0;be<Re.length;++be)Re[be]=0;be=0}return Bt.next()}function _h(t){var e;for(e=0;e<t.length;++e)t[e]=dh()}function qs(){}qs.prototype.nextBytes=_h;function fh(t,e){return new ie(t,e)}function ph(t,e){if(e<t.length+11)return alert("Message too long for RSA"),null;for(var s=new Array,c=t.length-1;c>=0&&e>0;){var v=t.charCodeAt(c--);v<128?s[--e]=v:v>127&&v<2048?(s[--e]=v&63|128,s[--e]=v>>6|192):(s[--e]=v&63|128,s[--e]=v>>6&63|128,s[--e]=v>>12|224)}s[--e]=0;for(var I=new qs,y=new Array;e>2;){for(y[0]=0;y[0]==0;)I.nextBytes(y);s[--e]=y[0]}return s[--e]=2,s[--e]=0,new ie(s)}function os(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function mh(t,e){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=fh(t,16),this.e=parseInt(e,16)):alert("Invalid RSA public key")}function gh(t){return t.modPowInt(this.e,this.n)}function vh(t){var e=ph(t,this.n.bitLength()+7>>3);if(e==null)return null;var s=this.doPublic(e);if(s==null)return null;var c=s.toString(16);return(c.length&1)==0?c:"0"+c}os.prototype.doPublic=gh;os.prototype.setPublic=mh;os.prototype.encrypt=vh;var Mi=0;function Sh(t){return bh(Xs(Ch(t)))}function Xs(t){return yh(wh(Eh(t),t.length*8))}function bh(t){for(var e=Mi?"0123456789ABCDEF":"0123456789abcdef",s="",c,v=0;v<t.length;v++)c=t.charCodeAt(v),s+=e.charAt(c>>>4&15)+e.charAt(c&15);return s}function Ch(t){for(var e="",s=-1,c,v;++s<t.length;)c=t.charCodeAt(s),v=s+1<t.length?t.charCodeAt(s+1):0,55296<=c&&c<=56319&&56320<=v&&v<=57343&&(c=65536+((c&1023)<<10)+(v&1023),s++),c<=127?e+=String.fromCharCode(c):c<=2047?e+=String.fromCharCode(192|c>>>6&31,128|c&63):c<=65535?e+=String.fromCharCode(224|c>>>12&15,128|c>>>6&63,128|c&63):c<=2097151&&(e+=String.fromCharCode(240|c>>>18&7,128|c>>>12&63,128|c>>>6&63,128|c&63));return e}function Eh(t){for(var e=Array(t.length>>2),s=0;s<e.length;s++)e[s]=0;for(var s=0;s<t.length*8;s+=8)e[s>>5]|=(t.charCodeAt(s/8)&255)<<24-s%32;return e}function yh(t){for(var e="",s=0;s<t.length*32;s+=8)e+=String.fromCharCode(t[s>>5]>>>24-s%32&255);return e}function wh(t,e){t[e>>5]|=128<<24-e%32,t[(e+64>>9<<4)+15]=e;for(var s=Array(80),c=1732584193,v=-271733879,I=-1732584194,y=271733878,n=-1009589776,a=0;a<t.length;a+=16){for(var u=c,_=v,l=I,f=y,g=n,b=0;b<80;b++){b<16?s[b]=t[a+b]:s[b]=Is(s[b-3]^s[b-8]^s[b-14]^s[b-16],1);var d=Ge(Ge(Is(c,5),xh(b,v,I,y)),Ge(Ge(n,s[b]),Ih(b)));n=y,y=I,I=Is(v,30),v=c,c=d}c=Ge(c,u),v=Ge(v,_),I=Ge(I,l),y=Ge(y,f),n=Ge(n,g)}return Array(c,v,I,y,n)}function xh(t,e,s,c){return t<20?e&s|~e&c:t<40?e^s^c:t<60?e&s|e&c|s&c:e^s^c}function Ih(t){return t<20?1518500249:t<40?1859775393:t<60?-1894007588:-899497514}function Ge(t,e){var s=(t&65535)+(e&65535),c=(t>>16)+(e>>16)+(s>>16);return c<<16|s&65535}function Is(t,e){return t<<e|t>>>32-e}var As=20;function Ri(t,e){var s,c,v;for(s=0,v=0;v<t.length;s++){var I=new String;for(c=0;c<e.length;c++)I+=String.fromCharCode(e[c]);I+=String.fromCharCode(s>>24&255),I+=String.fromCharCode(s>>16&255),I+=String.fromCharCode(s>>8&255),I+=String.fromCharCode(s&255);var y=Xs(I);for(c=0;c<y.length&&v<t.length;c++,v++)t[v]=y.charCodeAt(c)}}function Ah(t,e,s){var c=new Array(As),v=new qs;v.nextBytes(c);var I=t-1-c.length,y=new Array(I),n=I-e.length-1,a;if(s===void 0&&(s=""),n<As)return console.log("Error - data too large for key size."),null;for(a=0;a<n;a++)y[a]=0;var u=Xs(s);for(a=0;a<u.length;a++)y[a]=u.charCodeAt(a);for(y[n]=1,a=0;a<e.length;a++)y[a+n+1]=e.charCodeAt(a);var _=new Array(I);if(Ri(_,c)<0)return null;for(a=0;a<_.length;a++)y[a]^=_[a];var l=Array(As);if(Ri(l,y)<0)return null;for(a=0;a<l.length;a++)c[a]^=l[a];var f=new String;for(f+="\0",a=0;a<c.length;a++)f+=String.fromCharCode(c[a]);for(a=0;a<y.length;a++)f+=String.fromCharCode(y[a]);return f}function Ft(t,e){var s=t[e++];if(s>128){if(s!=129)return console.log("Error: we lazily don't support keys bigger than 255 bytes. It'd be easy to fix."),null;s=t[e++]}return[e,s]}function Ps(t,e){var s;return e=e||0,t[e++]!=48?(console.log("Error: public key should start with a sequence flag."),null):(s=Ft(t,e),s||null)}function Ph(t,e){var s=new Uint8Array(t),c,v,I,y,n;if(v=Ps(s,e),!v||(e=v[0],v=Ps(s,e),!v))return null;if(e=v[0]+v[1],s[e++]!=3)return console.log("Error: expecting bit string next."),null;if(c=Ft(s,e),!c)return null;if(e=c[0],s[e]!=0&&s[e+1]!=48)return console.log("Error: unexpected values in bit string."),null;if(v=Ps(s,e+1),!v)return null;if(e=v[0],s[e++]!=2)return console.log("Error: expecting integer n next."),null;if(c=Ft(s,e),!c)return null;for(e=c[0],I=new Array(c[1]),y=0;y<c[1];y++)I[y]=s[e+y];if(n=new os,n.n=new ie(I),e+=c[1],s[e++]!=2)return console.log("Error: expecting integer e next."),null;if(c=Ft(s,e),!c)return null;for(e=c[0],n.e=s[e++],y=1;y<c[1];y++)n.e<<=8,n.e|=s[e++];return n}function Dh(t,e){var s,c=[],v=Ah(t.n.bitLength()+7>>3,e);if(!v)return null;var I=new Array(v.length);for(s=0;s<v.length;s++)I[s]=v.charCodeAt(s);var y=new ie(I),n=t.doPublic(y),a=n.toString(16);for((a.length&1)!=0&&(a="0"+a),s=0;s<a.length;s+=2)c[s/2]=parseInt(a.substring(s,s+2),16);return c}var Ve,Ce={QUIC_IMAGE_TYPE_INVALID:0,QUIC_IMAGE_TYPE_GRAY:1,QUIC_IMAGE_TYPE_RGB16:2,QUIC_IMAGE_TYPE_RGB24:3,QUIC_IMAGE_TYPE_RGB32:4,QUIC_IMAGE_TYPE_RGBA:5},Lh=3,Mh=6,Rh=2048,Ti=!0,ki=26,Ar=Lh,Je=Mh,ct=Rh,Th={nGRcodewords:[0,0,0,0,0,0,0,0],notGRcwlen:[0,0,0,0,0,0,0,0],notGRprefixmask:[0,0,0,0,0,0,0,0],notGRsuffixlen:[0,0,0,0,0,0,0,0],xlatU2L:[0,0,0,0,0,0,0,0],xlatL2U:[0,0,0,0,0,0,0,0]},pe={nGRcodewords:[0,0,0,0,0,0,0,0],notGRcwlen:[0,0,0,0,0,0,0,0],notGRprefixmask:[0,0,0,0,0,0,0,0],notGRsuffixlen:[0,0,0,0,0,0,0,0],xlatU2L:[0,0,0,0,0,0,0,0],xlatL2U:[0,0,0,0,0,0,0,0]},Ae=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215,33554431,67108863,134217727,268435455,536870911,1073741823,2147483647,4294967295],Pr=[],kh=[[550,900,800,700,500,350,300,200,180,180,160],[110,550,900,800,550,400,350,250,140,160,140],[100,120,550,900,700,500,400,300,220,250,160]],ks=[0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,5,5,6,6,7,7,8,9,10,11,12,13,14,15],Ot=[8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Bh=[46495042,893548311,794435923,2453991765,2077388039,894197842,1462934312,697534094,1826128012,343623392,2581292719,3811265708,459739748,2638427270,1654964626,101227083,2654850628,3668700691,572794346,2758751005,3445133904,2344099199,3367450297,898927923,3618406352,1606297603,754696453,20823118,2050458127,972590750,3990194068,3305596553,4239238564,1690498157,3015324227,2306127097,1510321853,548392192,971157512,2292288069,1611390505,4086766286,4084927083,1883326811,1891043243,113180603,1107690783,3778825955,3248980775,2443839100,2190866218,1932072870,495393613,1078522166,4051963518,1784694977,1768732442,2146763203,264646923,1474361405,2361552500,296035746,2489922759,2094565616,2409465348,1334241083,72483606,3740181004,4057920662,1734898312,4114662834,574624900,880305546,3258472262,26713132,1571648456,52557195,4043234286,2458021343,676064371,1528437109,64953873,546717185,2709319979,1947039598,2812723004,28691684,286829174,4235176970,3465707163,12526951,2154766700,3165032534,2036061161,3386656087,2301212354,2023576300,1061142336,3105452904,2743866805,3283373992,3397596080,3085489552,3196092395,3210707808,3651022684,925444321,2088074316,230011220,3223248386,533229176,523863486,3028311159,13140218,2538347282,900399636,3000796173,1526771255,3541282854,2992674461,2135722105,389334227,1225164337,3119947809,1803959919,3471171263,704170491,1407019136,1924534819,526887421,168782227,333811993,298623278,4268451686,381087740,2542899140,3266880867,2498950977,200969370,3511909096,3252303004,2268881098,2499828613,2606499854,3163208665,3790254546,1840025712,1319758833,3771674836,519421307,3512796222,1563402978,4284300462,2263719815,715250337,3178437172,2660191010,2982332026,3256309961,2709659997,3434092872,2367065591,69438718,915160508,183164069,3134331940,175242981,2680543346,1421955782,4231173251,1736652874,3990568476,1710820912,2286604440,3464587098,1261907837,1757387321,1128554270,1090050251,2429922486,1288729218,882830086,211637042,1376462063,2147615815,1737974929,798170275,4271572277,4241687072,1638524620,2760366295,1065115089,2097227717,1224023317,1625204849,3383303351,1488272307,2640186157,1649047732,819719707,2615091943,502645401,760628135,4108137983,63606742,1404337880,1865161130,4272996852,1239761976,790984678,3213322601,1917062825,4195069880,1962259360,2111002573,2311983960,1861406170,511141875,2797510619,1331661048,3130608186,147483493,3767089176,2650841450,4096523407,2574446300,1956416337,851468126,3607527519,1811658703,3642821136,832691095,2453312857,933732854,94341217,3393797730,1695907457,2405722077,2877685663,2469507058,2249636341,3988608661,4001245617,825934927,3103985967,1127151177,3691656896,1640967098,2168932645,2830550957,3998822878,3002602893,1509651465,775813869,2599574079,3791574229],oe=3,De=2,Le=1,Me=0,ae=4;function Bi(t){if(t===1)return 0;var e=1;for(t-=1;t=t>>>1;)e++;return e}function Oi(t,e,s){var c;for(c=0;c<e;c++){var v,I;v=s-e,v>Ae[e-c]&&(v=Ae[e-c]),I=Ae[e]+1-(v<<c),t.nGRcodewords[c]=v<<c,t.notGRcwlen[c]=v+Bi(I),t.notGRprefixmask[c]=Ae[32-v]>>>0,t.notGRsuffixlen[c]=Bi(I)}var y=Ae[e],n=y>>>1,a;for(a=0;a<=y;a++)a<=n?t.xlatU2L[a]=a<<1:t.xlatU2L[a]=(y-a<<1)+1;for(a=0;a<=y;a++)a&1?t.xlatL2U[a]=y-(a>>>1):t.xlatL2U[a]=a>>>1}function Oh(t){switch(t){case Ce.QUIC_IMAGE_TYPE_GRAY:return 8;case Ce.QUIC_IMAGE_TYPE_RGB16:return 5;case Ce.QUIC_IMAGE_TYPE_RGB24:return 8;case Ce.QUIC_IMAGE_TYPE_RGB32:return 8;case Ce.QUIC_IMAGE_TYPE_RGBA:return 8;case Ce.QUIC_IMAGE_TYPE_INVALID:default:return console.log(`quic: bad image type `),0}}function Nh(t){return t&4286578688?Ot[t>>>24]:t&4294934528?8+Ot[t>>>16&255]:t&4294967168?16+Ot[t>>>8&255]:24+Ot[t&255]}function Be(t,e){var s,c;if(e<0||e>pe.notGRprefixmask[t]){var v=Nh(e);c=v+1+t,s=v<<t|e>>32-c&Ae[t]}else c=pe.notGRcwlen[t],s=pe.nGRcodewords[t]+(e>>32-c&Ae[pe.notGRsuffixlen[t]]);return{codewordlen:c,rc:s}}function Ni(t,e){return t<pe.nGRcodewords[e]?(t>>>e)+1+e:pe.notGRcwlen[e]}function Bs(t){var e,s=0;switch(this.levels=1<<t,this.n_buckets_ptrs=0,Ar){case 1:this.repfirst=3,this.firstsize=1,this.repnext=2,this.mulsize=2;break;case 3:this.repfirst=1,this.firstsize=1,this.repnext=1,this.mulsize=2;break;case 5:this.repfirst=1,this.firstsize=1,this.repnext=1,this.mulsize=4;break;case 0:case 2:case 4:console.log(`quic: findmodelparams(): evol value obsolete!!! `);break;default:console.log(`quic: findmodelparams(): evol out of range!!! `)}this.n_buckets=0;var c=this.repfirst+1,v=this.firstsize;do this.n_buckets?e=s+1:e=0,--c||(c=this.repnext,v*=this.mulsize),s=e+v-1,s+v>=this.levels&&(s=this.levels-1),this.n_buckets_ptrs||(this.n_buckets_ptrs=this.levels),this.n_buckets++;while(s<this.levels-1)}Bs.prototype={n_buckets:0,n_buckets_ptrs:0,repfirst:0,firstsize:0,repnext:0,mulsize:0,levels:0};function Dr(){this.counters=[0,0,0,0,0,0,0,0]}Dr.prototype={bestcode:0,reste:function(t){this.bestcode=t,this.counters=[0,0,0,0,0,0,0,0]},update_model_8bpc:function(t,e,s){var c,v=s-1,I=this.counters[v]+=Ni(e,v);for(c=s-2;c>=0;c--){var y=this.counters[c]+=Ni(e,c);y<I&&(v=c,I=y)}if(this.bestcode=v,I>t.wm_trigger)for(c=0;c<s;c++)this.counters[c]=this.counters[c]>>>1}};function Os(){this.buckets_ptrs=[],this.buckets_buf=[]}Os.prototype={fill_model_structures:function(t){var e,s=0,c=0,v=t.repfirst+1,I=t.firstsize;do{c?e=s+1:e=0,--v||(v=t.repnext,I*=t.mulsize),s=e+I-1,s+I>=t.levels&&(s=t.levels-1),this.buckets_buf[c]=new Dr;var y;for(y=e;y<=s;y++)this.buckets_ptrs[y]=this.buckets_buf[c];c++}while(s<t.levels-1);return!0}};function Lr(t,e){this.state=new Qs,this.family_stat_8bpc=new Os,this.family_stat_5bpc=new Os,this.correlate_row={zero:0,row:[]},this.model_8bpc=t,this.model_5bpc=e,this.buckets_ptrs=[],this.family_stat_8bpc.fill_model_structures(this.model_8bpc)&&this.family_stat_5bpc.fill_model_structures(this.model_5bpc)}Lr.prototype={reste:function(t){var e;if(this.correlate_row={zero:0,row:[]},t==8){for(e=0;e<this.model_8bpc.n_buckets;e++)this.family_stat_8bpc.buckets_buf[e].reste(7);this.buckets_ptrs=this.family_stat_8bpc.buckets_ptrs}else if(t==5){for(e=0;e<this.model_5bpc.n_buckets;e++)this.family_stat_8bpc.buckets_buf[e].reste(4);this.buckets_ptrs=this.family_stat_5bpc.buckets_ptrs}else return console.log(`quic: %s: bad bpc %d `,__FUNCTION__,t),!1;return this.state.reste(),!0}};function Qs(){}Qs.prototype={waitcnt:0,tabrand_seed:255,wm_trigger:0,wmidx:0,wmileft:ct,melcstate:0,melclen:0,melcorder:0,set_wm_trigger:function(){var t=this.wmidx;t>10&&(t=10),this.wm_trigger=kh[Math.floor(Ar/2)][t]},reste:function(){this.waitcnt=0,this.tabrand_seed=255,this.wmidx=0,this.wmileft=ct,this.set_wm_trigger(),this.melcstate=0,this.melclen=ks[0],this.melcorder=1<<this.melclen},tabrand:function(){return this.tabrand_seed++,Bh[this.tabrand_seed&255]}};function me(){this.rgb_state=new Qs,this.model_8bpc=new Bs(8),this.model_5bpc=new Bs(5),this.channels=[];var t;for(t=0;t<4;t++)if(this.channels[t]=new Lr(this.model_8bpc,this.model_5bpc),!this.channels[t]){console.log("quic: failed to create channel");return}}me.prototype={type:0,width:0,height:0,io_idx:0,io_available_bits:0,io_word:0,io_next_word:0,io_now:0,io_end:0,rows_completed:0};me.prototype.reste=function(t){return this.rgb_state.reste(),this.io_now=t,this.io_end=this.io_now.length,this.io_idx=0,this.rows_completed=0,!0};me.prototype.read_io_word=function(){if(this.io_idx>=this.io_end)throw"quic: out of data";this.io_next_word=this.io_now[this.io_idx++]|this.io_now[this.io_idx++]<<8|this.io_now[this.io_idx++]<<16|this.io_now[this.io_idx++]<<24};me.prototype.decode_eatbits=function(t){this.io_word=this.io_word<<t;var e=this.io_available_bits-t;e>=0?(this.io_available_bits=e,this.io_word|=this.io_next_word>>>this.io_available_bits):(e=-1*e,this.io_word|=this.io_next_word<<e,this.read_io_word(),this.io_available_bits=32-e,this.io_word|=this.io_next_word>>>this.io_available_bits)};me.prototype.decode_eat32bits=function(){this.decode_eatbits(16),this.decode_eatbits(16)};me.prototype.reste_channels=function(t){var e;for(e=0;e<4;e++)if(!this.channels[e].reste(t))return!1;return!0};me.prototype.quic_decode_begin=function(t){if(!this.reste(t))return!1;this.io_idx=0,this.io_next_word=this.io_now[this.io_idx++]|this.io_now[this.io_idx++]<<8|this.io_now[this.io_idx++]<<16|this.io_now[this.io_idx++]<<24,this.io_word=this.io_next_word,this.io_available_bits=0;var e=this.io_word;if(this.decode_eat32bits(),e!=1128879441)return console.log("quic: bad magic "+e.toString(16)),!1;var s=this.io_word;if(this.decode_eat32bits(),s!=0)return console.log("quic: bad version "+s.toString(16)),!1;this.type=this.io_word,this.decode_eat32bits(),this.width=this.io_word,this.decode_eat32bits(),this.height=this.io_word,this.decode_eat32bits();var c=Oh(this.type);return!!this.reste_channels(c)};me.prototype.quic_rgb32_uncompress_row0_seg=function(t,e,s,c,v,I){var y,n=3,a,u;if(t)y=t+this.rgb_state.waitcnt;else{e[oe]=0,a=0;do u=Be(this.channels[a].buckets_ptrs[this.channels[a].correlate_row.zero].bestcode,this.io_word),this.channels[a].correlate_row.row[0]=u.rc,e[2-a]=pe.xlatL2U[u.rc]&255,this.decode_eatbits(u.codewordlen);while(++a<n);if(this.rgb_state.waitcnt)--this.rgb_state.waitcnt;else{this.rgb_state.waitcnt=this.rgb_state.tabrand()&c,a=0;do this.channels[a].buckets_ptrs[this.channels[a].correlate_row.zero].update_model_8bpc(this.rgb_state,this.channels[a].correlate_row.row[0],v);while(++a<n)}y=++t+this.rgb_state.waitcnt}for(;y<s;){for(;t<=y;t++){e[t*ae+oe]=0,a=0;do u=Be(this.channels[a].buckets_ptrs[this.channels[a].correlate_row.row[t-1]].bestcode,this.io_word),this.channels[a].correlate_row.row[t]=u.rc,e[t*ae+(2-a)]=pe.xlatL2U[u.rc]+e[(t-1)*ae+(2-a)]&I,this.decode_eatbits(u.codewordlen);while(++a<n)}a=0;do this.channels[a].buckets_ptrs[this.channels[a].correlate_row.row[y-1]].update_model_8bpc(this.rgb_state,this.channels[a].correlate_row.row[y],v);while(++a<n);y=t+(this.rgb_state.tabrand()&c)}for(;t<s;t++){e[t*ae+oe]=0,a=0;do u=Be(this.channels[a].buckets_ptrs[this.channels[a].correlate_row.row[t-1]].bestcode,this.io_word),this.channels[a].correlate_row.row[t]=u.rc,e[t*ae+(2-a)]=pe.xlatL2U[u.rc]+e[(t-1)*ae+(2-a)]&I,this.decode_eatbits(u.codewordlen);while(++a<n)}this.rgb_state.waitcnt=y-s};me.prototype.quic_rgb32_uncompress_row0=function(t){for(var e=8,s=255,c=0,v=this.width;Je>this.rgb_state.wmidx&&this.rgb_state.wmileft<=v;)this.rgb_state.wmileft&&(this.quic_rgb32_uncompress_row0_seg(c,t,c+this.rgb_state.wmileft,Ae[this.rgb_state.wmidx],e,s),c+=this.rgb_state.wmileft,v-=this.rgb_state.wmileft),this.rgb_state.wmidx++,this.rgb_state.set_wm_trigger(),this.rgb_state.wmileft=ct;v&&(this.quic_rgb32_uncompress_row0_seg(c,t,c+v,Ae[this.rgb_state.wmidx],e,s),Je>this.rgb_state.wmidx&&(this.rgb_state.wmileft-=v))};me.prototype.quic_rgb32_uncompress_row_seg=function(t,e,s,c,v,I){var y=3,n=Ae[this.rgb_state.wmidx],a,u=0,_=0,l=0,f;if(s)_=s+this.rgb_state.waitcnt;else{e[oe]=0,f=0;do a=Be(this.channels[f].buckets_ptrs[this.channels[f].correlate_row.zero].bestcode,this.io_word),this.channels[f].correlate_row.row[0]=a.rc,e[2-f]=pe.xlatL2U[this.channels[f].correlate_row.row[0]]+t[2-f]&I,this.decode_eatbits(a.codewordlen);while(++f<y);if(this.rgb_state.waitcnt)--this.rgb_state.waitcnt;else{this.rgb_state.waitcnt=this.rgb_state.tabrand()&n,f=0;do this.channels[f].buckets_ptrs[this.channels[f].correlate_row.zero].update_model_8bpc(this.rgb_state,this.channels[f].correlate_row.row[0],v);while(++f<y)}_=++s+this.rgb_state.waitcnt}for(;;){for(var g=0;_<c&&!g;){for(;s<=_&&!g;s++){var b=s*ae,d=(s-1)*ae,o=(s-2)*ae;if(t[d+De]==t[b+De]&&t[d+Le]==t[b+Le]&&t[d+Me]==t[b+Me]&&u!=s&&s>2&&e[d+De]==e[o+De]&&e[d+Le]==e[o+Le]&&e[d+Me]==e[o+Me]){for(this.rgb_state.waitcnt=_-s,u=s,l=s+this.decode_run(this.rgb_state);s<l;s++){var b=s*ae,d=(s-1)*ae;e[b+oe]=0,e[b+De]=e[d+De],e[b+Le]=e[d+Le],e[b+Me]=e[d+Me]}if(s==c)return;_=s+this.rgb_state.waitcnt,g=1;break}f=0,e[b+oe]=0;do{var r=this.channels[f],i=r.correlate_row;a=Be(r.buckets_ptrs[i.row[s-1]].bestcode,this.io_word),i.row[s]=a.rc,e[b+(2-f)]=pe.xlatL2U[a.rc]+(e[d+(2-f)]+t[b+(2-f)]>>1)&I,this.decode_eatbits(a.codewordlen)}while(++f<y)}if(g)break;f=0;do this.channels[f].buckets_ptrs[this.channels[f].correlate_row.row[_-1]].update_model_8bpc(this.rgb_state,this.channels[f].correlate_row.row[_],v);while(++f<y);_=s+(this.rgb_state.tabrand()&n)}for(;s<c&&!g;s++){var b=s*ae,d=(s-1)*ae,o=(s-2)*ae;if(t[d+De]==t[b+De]&&t[d+Le]==t[b+Le]&&t[d+Me]==t[b+Me]&&u!=s&&s>2&&e[d+De]==e[o+De]&&e[d+Le]==e[o+Le]&&e[d+Me]==e[o+Me]){for(this.rgb_state.waitcnt=_-s,u=s,l=s+this.decode_run(this.rgb_state);s<l;s++){var b=s*ae,d=(s-1)*ae;e[b+oe]=0,e[b+De]=e[d+De],e[b+Le]=e[d+Le],e[b+Me]=e[d+Me]}if(s==c)return;_=s+this.rgb_state.waitcnt,g=1;break}e[b+oe]=0,f=0;do a=Be(this.channels[f].buckets_ptrs[this.channels[f].correlate_row.row[s-1]].bestcode,this.io_word),this.channels[f].correlate_row.row[s]=a.rc,e[b+(2-f)]=pe.xlatL2U[a.rc]+(e[d+(2-f)]+t[b+(2-f)]>>1)&I,this.decode_eatbits(a.codewordlen);while(++f<y)}if(!g){this.rgb_state.waitcnt=_-c;return}}};me.prototype.decode_run=function(t){var e=0;do{var s,c=~(this.io_word>>>24)>>>0&255,v=Pr[c];for(s=1;s<=v;s++)e+=t.melcorder,t.melcstate<32&&(t.melclen=ks[++t.melcstate],t.melcorder=1<<t.melclen);if(v!=8){this.decode_eatbits(v+1);break}this.decode_eatbits(8)}while(!0);return t.melclen&&(e+=this.io_word>>>32-t.melclen,this.decode_eatbits(t.melclen)),t.melcstate&&(t.melclen=ks[--t.melcstate],t.melcorder=1<<t.melclen),e};me.prototype.quic_rgb32_uncompress_row=function(t,e){for(var s=8,c=255,v=0,I=this.width;Je>this.rgb_state.wmidx&&this.rgb_state.wmileft<=I;)this.rgb_state.wmileft&&(this.quic_rgb32_uncompress_row_seg(t,e,v,v+this.rgb_state.wmileft,s,c),v+=this.rgb_state.wmileft,I-=this.rgb_state.wmileft),this.rgb_state.wmidx++,this.rgb_state.set_wm_trigger(),this.rgb_state.wmileft=ct;I&&(this.quic_rgb32_uncompress_row_seg(t,e,v,v+I,s,c),Je>this.rgb_state.wmidx&&(this.rgb_state.wmileft-=I))};me.prototype.quic_four_uncompress_row0_seg=function(t,e,s,c,v,I,y,n){var a,u;for(e==0?(u=Be(t.buckets_ptrs[s.zero].bestcode,this.io_word),s.row[0]=u.rc,c[oe]=pe.xlatL2U[u.rc],this.decode_eatbits(u.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&I,t.buckets_ptrs[s.zero].update_model_8bpc(t.state,s.row[0],y)),a=++e+t.state.waitcnt):a=e+t.state.waitcnt;a<v;){for(var _;e<=a;e++)_=t.buckets_ptrs[s.row[e-1]],u=Be(_.bestcode,this.io_word),s.row[e]=u.rc,c[e*ae+oe]=pe.xlatL2U[u.rc]+c[(e-1)*ae+oe]&n,this.decode_eatbits(u.codewordlen);_.update_model_8bpc(t.state,s.row[a],y),a=e+(t.state.tabrand()&I)}for(;e<v;e++)u=Be(t.buckets_ptrs[s.row[e-1]].bestcode,this.io_word),s.row[e]=u.rc,c[e*ae+oe]=pe.xlatL2U[u.rc]+c[(e-1)*ae+oe]&n,this.decode_eatbits(u.codewordlen);t.state.waitcnt=a-v};me.prototype.quic_four_uncompress_row0=function(t,e){for(var s=8,c=255,v=t.correlate_row,I=0,y=this.width;Je>t.state.wmidx&&t.state.wmileft<=y;)t.state.wmileft&&(this.quic_four_uncompress_row0_seg(t,I,v,e,I+t.state.wmileft,Ae[t.state.wmidx],s,c),I+=t.state.wmileft,y-=t.state.wmileft),t.state.wmidx++,t.state.set_wm_trigger(),t.state.wmileft=ct;y&&(this.quic_four_uncompress_row0_seg(t,I,v,e,I+y,Ae[t.state.wmidx],s,c),Je>t.state.wmidx&&(t.state.wmileft-=y))};me.prototype.quic_four_uncompress_row_seg=function(t,e,s,c,v,I,y,n){var a=Ae[t.state.wmidx],u,_=0,l,f;for(v==0?(f=Be(t.buckets_ptrs[e.zero].bestcode,this.io_word),e.row[0]=f.rc,c[oe]=pe.xlatL2U[f.rc]+s[oe]&n,this.decode_eatbits(f.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&a,t.buckets_ptrs[e.zero].update_model_8bpc(t.state,e.row[0],y)),u=++v+t.state.waitcnt):u=v+t.state.waitcnt;;){for(var g=0;u<I&&!g;){for(var b;v<=u&&!g;v++){var d=v*ae,o=(v-1)*ae,r=(v-2)*ae;if(s[o+oe]==s[d+oe]&&_!=v&&v>2&&c[o+oe]==c[r+oe]){for(t.state.waitcnt=u-v,_=v,l=v+this.decode_run(t.state);v<l;v++){var d=v*ae,o=(v-1)*ae;c[d+oe]=c[o+oe]}if(v==I)return;u=v+t.state.waitcnt,g=1;break}b=t.buckets_ptrs[e.row[v-1]],f=Be(b.bestcode,this.io_word),e.row[v]=f.rc,c[d+oe]=pe.xlatL2U[f.rc]+(c[o+oe]+s[d+oe]>>1)&n,this.decode_eatbits(f.codewordlen)}if(g)break;b.update_model_8bpc(t.state,e.row[u],y),u=v+(t.state.tabrand()&a)}for(;v<I&&!g;v++){var d=v*ae,o=(v-1)*ae,r=(v-2)*ae;if(s[o+oe]==s[d+oe]&&_!=v&&v>2&&c[o+oe]==c[r+oe]){for(t.state.waitcnt=u-v,_=v,l=v+this.decode_run(t.state);v<l;v++){var d=v*ae,o=(v-1)*ae;c[d+oe]=c[o+oe]}if(v==I)return;u=v+t.state.waitcnt,g=1;break}f=Be(t.buckets_ptrs[e.row[v-1]].bestcode,this.io_word),e.row[v]=f.rc,c[d+oe]=pe.xlatL2U[f.rc]+(c[o+oe]+s[d+oe]>>1)&n,this.decode_eatbits(f.codewordlen)}if(!g){t.state.waitcnt=u-I;return}}};me.prototype.quic_four_uncompress_row=function(t,e,s){for(var c=8,v=255,I=t.correlate_row,y=0,n=this.width;Je>t.state.wmidx&&t.state.wmileft<=n;)t.state.wmileft&&(this.quic_four_uncompress_row_seg(t,I,e,s,y,y+t.state.wmileft,c,v),y+=t.state.wmileft,n-=t.state.wmileft),t.state.wmidx++,t.state.set_wm_trigger(),t.state.wmileft=ct;n&&(this.quic_four_uncompress_row_seg(t,I,e,s,y,y+n,c,v),Je>t.state.wmidx&&(t.state.wmileft-=n))};me.prototype.quic_decode=function(t,e){var s;switch(this.type){case Ce.QUIC_IMAGE_TYPE_RGB32:case Ce.QUIC_IMAGE_TYPE_RGB24:for(this.channels[0].correlate_row.zero=0,this.channels[1].correlate_row.zero=0,this.channels[2].correlate_row.zero=0,this.quic_rgb32_uncompress_row0(t),this.rows_completed++,s=1;s<this.height;s++){var c=t;t=c.subarray(e),this.channels[0].correlate_row.zero=this.channels[0].correlate_row.row[0],this.channels[1].correlate_row.zero=this.channels[1].correlate_row.row[0],this.channels[2].correlate_row.zero=this.channels[2].correlate_row.row[0],this.quic_rgb32_uncompress_row(c,t),this.rows_completed++}break;case Ce.QUIC_IMAGE_TYPE_RGB16:return console.log(`quic: unsupported output format `),!1;case Ce.QUIC_IMAGE_TYPE_RGBA:for(this.channels[0].correlate_row.zero=0,this.channels[1].correlate_row.zero=0,this.channels[2].correlate_row.zero=0,this.quic_rgb32_uncompress_row0(t),this.channels[3].correlate_row.zero=0,this.quic_four_uncompress_row0(this.channels[3],t),this.rows_completed++,s=1;s<this.height;s++){var c=t;t=c.subarray(e),this.channels[0].correlate_row.zero=this.channels[0].correlate_row.row[0],this.channels[1].correlate_row.zero=this.channels[1].correlate_row.row[0],this.channels[2].correlate_row.zero=this.channels[2].correlate_row.row[0],this.quic_rgb32_uncompress_row(c,t),this.channels[3].correlate_row.zero=this.channels[3].correlate_row.row[0],this.quic_four_uncompress_row(Ve.channels[3],c,t),this.rows_completed++}break;case Ce.QUIC_IMAGE_TYPE_GRAY:return console.log(`quic: unsupported output format `),!1;case Ce.QUIC_IMAGE_TYPE_INVALID:default:return console.log(`quic: bad image type `),!1}return!0};me.prototype.simple_quic_decode=function(t){var e=4;if(this.quic_decode_begin(t)&&!(this.type!=Ce.QUIC_IMAGE_TYPE_RGB32&&this.type!=Ce.QUIC_IMAGE_TYPE_RGB24&&this.type!=Ce.QUIC_IMAGE_TYPE_RGBA)){var s=new Uint8Array(this.width*this.height*4);if(s[0]=69,this.quic_decode(s,this.width*e))return s}};function Mr(){}Mr.prototype={from_dv:function(t,e,s){if(!Ve)throw"quic: no quic encoder";this.data_size=t.getUint32(e,!0),e+=4;var c=new Uint8Array(s.slice(e));return this.outptr=Ve.simple_quic_decode(c),this.outptr&&(this.type=Ve.type,this.width=Ve.width,this.height=Ve.height),e+=c.length,e}};function Uh(t,e){var s=t.createImageData(e.width,e.height),c;for(c=0;c<s.width*s.height*4;c+=4)s.data[c+0]=e.outptr[c+2],s.data[c+1]=e.outptr[c+1],s.data[c+2]=e.outptr[c+0],e.type!==Ce.QUIC_IMAGE_TYPE_RGBA?s.data[c+3]=255:s.data[c+3]=255-e.outptr[c+3];return s}if(Ti){Ti=!1,Oi(pe,8,ki),Oi(Th,5,ki);var Nt,Ds,Ut,Ls;for(Ds=Ut=1,Ls=8,Nt=0;Nt<256;++Nt)Pr[Nt]=Ls,--Ut,Ut==0&&(Ut=Ds,--Ls,Ds*=2);if(Ve=new me,!Ve)throw"quic: failed to create encoder"}function Rr(){}Rr.prototype={from_dv:function(t,e,s){return this.type=t.getUint8(e,!0),e++,this.id=t.getUint8(e,!0),e++,e}};function it(){}it.prototype={from_dv:function(t,e,s){return this.top=t.getUint32(e,!0),e+=4,this.left=t.getUint32(e,!0),e+=4,this.bottom=t.getUint32(e,!0),e+=4,this.right=t.getUint32(e,!0),e+=4,e},is_same_size:function(t){return this.bottom-this.top==t.bottom-t.top&&this.right-this.left==t.right-t.left}};function Tr(){}Tr.prototype={from_dv:function(t,e,s){var c;for(this.num_rects=t.getUint32(e,!0),e+=4,this.num_rects>0&&(this.rects=[]),c=0;c<this.num_rects;c++)this.rects[c]=new it,e=this.rects[c].from_dv(t,e,s);return e}};function as(){}as.prototype={from_dv:function(t,e,s){return this.type=t.getUint8(e,!0),e++,this.type==R.SPICE_CLIP_TYPE_RECTS&&(this.rects=new Tr,e=this.rects.from_dv(t,e,s)),e}};function kr(){}kr.prototype={from_dv:function(t,e,s){return this.id=t.getUint64(e,!0),e+=8,this.type=t.getUint8(e,!0),e++,this.flags=t.getUint8(e,!0),e++,this.width=t.getUint32(e,!0),e+=4,this.height=t.getUint32(e,!0),e+=4,e}};function Br(){}Br.prototype={from_dv:function(t,e,s){var c;for(this.unique=t.getUint64(e,!0),e+=8,this.num_ents=t.getUint16(e,!0),e+=2,this.ents=[],c=0;c<this.num_ents;c++)this.ents[c]=t.getUint32(e,!0),e+=4;return e}};function Or(){}Or.prototype={from_dv:function(t,e,s){if(this.format=t.getUint8(e,!0),e++,this.flags=t.getUint8(e,!0),e++,this.x=t.getUint32(e,!0),e+=4,this.y=t.getUint32(e,!0),e+=4,this.stride=t.getUint32(e,!0),e+=4,this.flags&R.SPICE_BITMAP_FLAGS_PAL_FROM_CACHE)this.palette_id=t.getUint64(e,!0),e+=8;else{var c=t.getUint32(e,!0);e+=4,c==0?this.palette=null:(this.palette=new Br,this.palette.from_dv(t,c,s))}return this.data=s.slice(e),e+=this.data.byteLength,e}};function cs(){}cs.prototype={from_dv:function(t,e,s){if(this.descriptor=new kr,e=this.descriptor.from_dv(t,e,s),this.descriptor.type==R.SPICE_IMAGE_TYPE_LZ_RGB){this.lz_rgb=new Object,this.lz_rgb.length=t.getUint32(e,!0),e+=4;var c=e;this.lz_rgb.magic="";for(var v=3;v>=0;v--)this.lz_rgb.magic+=String.fromCharCode(t.getUint8(e+v));e+=4,this.lz_rgb.version=t.getUint32(e),e+=4,this.lz_rgb.type=t.getUint32(e),e+=4,this.lz_rgb.width=t.getUint32(e),e+=4,this.lz_rgb.height=t.getUint32(e),e+=4,this.lz_rgb.stride=t.getUint32(e),e+=4,this.lz_rgb.top_down=t.getUint32(e),e+=4;var I=e-c;this.lz_rgb.data=s.slice(e,this.lz_rgb.length+e-I),e+=this.lz_rgb.data.byteLength}if(this.descriptor.type==R.SPICE_IMAGE_TYPE_BITMAP&&(this.bitmap=new Or,e=this.bitmap.from_dv(t,e,s)),this.descriptor.type==R.SPICE_IMAGE_TYPE_SURFACE&&(this.surface_id=t.getUint32(e,!0),e+=4),this.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG&&(this.jpeg=new Object,this.jpeg.data_size=t.getUint32(e,!0),e+=4,this.jpeg.data=s.slice(e),e+=this.jpeg.data.byteLength),this.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG_ALPHA){this.jpeg_alpha=new Object,this.jpeg_alpha.flags=t.getUint8(e,!0),e+=1,this.jpeg_alpha.jpeg_size=t.getUint32(e,!0),e+=4,this.jpeg_alpha.data_size=t.getUint32(e,!0),e+=4,this.jpeg_alpha.data=s.slice(e,this.jpeg_alpha.jpeg_size+e),e+=this.jpeg_alpha.data.byteLength,this.jpeg_alpha.alpha=new Object,this.jpeg_alpha.alpha.length=this.jpeg_alpha.data_size-this.jpeg_alpha.jpeg_size;var c=e;this.jpeg_alpha.alpha.magic="";for(var v=3;v>=0;v--)this.jpeg_alpha.alpha.magic+=String.fromCharCode(t.getUint8(e+v));e+=4,this.jpeg_alpha.alpha.version=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.type=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.width=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.height=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.stride=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.top_down=t.getUint32(e),e+=4;var I=e-c;this.jpeg_alpha.alpha.data=s.slice(e,this.jpeg_alpha.alpha.length+e-I),e+=this.jpeg_alpha.alpha.data.byteLength}return this.descriptor.type==R.SPICE_IMAGE_TYPE_QUIC&&(this.quic=new Mr,e=this.quic.from_dv(t,e,s)),e}};function Js(){}Js.prototype={from_dv:function(t,e,s){this.flags=t.getUint8(e,!0),e++,this.pos=new hs,e=this.pos.from_dv(t,e,s);var c=t.getUint32(e,!0);return e+=4,c==0?(this.bitmap=null,e):(this.bitmap=new cs,this.bitmap.from_dv(t,c,s))}};function Nr(){}Nr.prototype={from_dv:function(t,e,s){var c=t.getUint32(e,!0);return e+=4,c==0?this.pat=null:(this.pat=new cs,this.pat.from_dv(t,c,s)),this.pos=new hs,this.pos.from_dv(t,e,s)}};function Ur(){}Ur.prototype={from_dv:function(t,e,s){return this.type=t.getUint8(e,!0),e++,this.type==R.SPICE_BRUSH_TYPE_SOLID?(this.color=t.getUint32(e,!0),e+=4):this.type==R.SPICE_BRUSH_TYPE_PATTERN&&(this.pattern=new Nr,e=this.pattern.from_dv(t,e,s)),e}};function jr(){}jr.prototype={from_dv:function(t,e,s){return this.brush=new Ur,e=this.brush.from_dv(t,e,s),this.rop_descriptor=t.getUint16(e,!0),e+=2,this.mask=new Js,this.mask.from_dv(t,e,s)}};function Fr(){}Fr.prototype={from_dv:function(t,e,s){var c=t.getUint32(e,!0);return e+=4,c==0?this.src_bitmap=null:(this.src_bitmap=new cs,this.src_bitmap.from_dv(t,c,s)),this.src_area=new it,e=this.src_area.from_dv(t,e,s),this.rop_descriptor=t.getUint16(e,!0),e+=2,this.scale_mode=t.getUint8(e,!0),e++,this.mask=new Js,this.mask.from_dv(t,e,s)}};function Zs(){}Zs.prototype={from_dv:function(t,e,s){return this.x=t.getUint16(e,!0),e+=2,this.y=t.getUint16(e,!0),e+=2,e}};function hs(){}hs.prototype={from_dv:function(t,e,s){return this.x=t.getUint32(e,!0),e+=4,this.y=t.getUint32(e,!0),e+=4,e}};function Hr(){}Hr.prototype={from_dv:function(t,e,s){return this.unique=t.getUint64(e,!0),e+=8,this.type=t.getUint8(e,!0),e++,this.width=t.getUint16(e,!0),e+=2,this.height=t.getUint16(e,!0),e+=2,this.hot_spot_x=t.getUint16(e,!0),e+=2,this.hot_spot_y=t.getUint16(e,!0),e+=2,e}};function ei(){}ei.prototype={from_dv:function(t,e,s){return this.flags=t.getUint16(e,!0),e+=2,this.flags&R.SPICE_CURSOR_FLAGS_NONE?this.header=null:(this.header=new Hr,e=this.header.from_dv(t,e,s),this.data=s.slice(e),e+=this.data.byteLength),e}};function Kr(){}Kr.prototype={from_dv:function(t,e,s){return this.surface_id=t.getUint32(e,!0),e+=4,this.width=t.getUint32(e,!0),e+=4,this.height=t.getUint32(e,!0),e+=4,this.format=t.getUint32(e,!0),e+=4,this.flags=t.getUint32(e,!0),e+=4,e}};var K={KEY_Escape:1,KEY_1:2,KEY_2:3,KEY_3:4,KEY_4:5,KEY_5:6,KEY_6:7,KEY_7:8,KEY_8:9,KEY_9:10,KEY_0:11,KEY_Minus:12,KEY_Equal:13,KEY_BackSpace:14,KEY_Tab:15,KEY_Q:16,KEY_W:17,KEY_E:18,KEY_R:19,KEY_T:20,KEY_Y:21,KEY_U:22,KEY_I:23,KEY_O:24,KEY_P:25,KEY_LBrace:26,KEY_RBrace:27,KEY_Enter:28,KEY_LCtrl:29,KEY_A:30,KEY_S:31,KEY_D:32,KEY_F:33,KEY_G:34,KEY_H:35,KEY_J:36,KEY_K:37,KEY_L:38,KEY_SemiColon:39,KEY_Quote:40,KEY_Tilde:41,KEY_ShiftL:42,KEY_BSlash:43,KEY_Z:44,KEY_X:45,KEY_C:46,KEY_V:47,KEY_B:48,KEY_N:49,KEY_M:50,KEY_Comma:51,KEY_Period:52,KEY_Slash:53,KEY_KP_Multiply:55,KEY_Alt:56,KEY_Space:57,KEY_CapsLock:58,KEY_F1:59,KEY_F2:60,KEY_F3:61,KEY_F4:62,KEY_F5:63,KEY_F6:64,KEY_F7:65,KEY_F8:66,KEY_F9:67,KEY_F10:68,KEY_NumLock:69,KEY_ScrollLock:70,KEY_KP_7:71,KEY_KP_8:72,KEY_KP_9:73,KEY_KP_4:75,KEY_KP_5:76,KEY_KP_6:77,KEY_KP_Plus:78,KEY_KP_1:79,KEY_KP_2:80,KEY_KP_3:81,KEY_KP_0:82,KEY_KP_Decimal:83,KEY_F11:87,KEY_F12:88};const j=[];j.Escape=1;j.Digit1=2;j.Digit2=3;j.Digit3=4;j.Digit4=5;j.Digit5=6;j.Digit6=7;j.Digit7=8;j.Digit8=9;j.Digit9=10;j.Digit0=11;j.Minus=12;j.Equal=13;j.Backspace=14;j.Tab=15;j.KeyQ=16;j.KeyW=17;j.KeyE=18;j.KeyR=19;j.KeyT=20;j.KeyY=21;j.KeyU=22;j.KeyI=23;j.KeyO=24;j.KeyP=25;j.BracketLeft=26;j.BracketRight=27;j.Enter=28;j.ControlLeft=29;j.KeyA=30;j.KeyS=31;j.KeyD=32;j.KeyF=33;j.KeyG=34;j.KeyH=35;j.KeyJ=36;j.KeyK=37;j.KeyL=38;j.Semicolon=39;j.Quote=40;j.Backquote=41;j.ShiftLeft=42;j.Backslash=43;j.KeyZ=44;j.KeyX=45;j.KeyC=46;j.KeyV=47;j.KeyB=48;j.KeyN=49;j.KeyM=50;j.Comma=51;j.Period=52;j.Slash=53;j.ShiftRight=54;j.NumpadMultiply=55;j.AltLeft=56;j.Space=57;j.CapsLock=58;j.F1=59;j.F2=60;j.F3=61;j.F4=62;j.F5=63;j.F6=64;j.F7=65;j.F8=66;j.F9=67;j.F10=68;j.Pause=69;j.ScrollLock=70;j.Numpad7=71;j.Numpad8=72;j.Numpad9=73;j.NumpadSubtract=74;j.Numpad4=75;j.Numpad5=76;j.Numpad6=77;j.NumpadAdd=78;j.Numpad1=79;j.Numpad2=80;j.Numpad3=81;j.Numpad0=82;j.NumpadDecimal=83;j.PrintScreen=84;j.IntlBackslash=86;j.F11=87;j.F12=88;j.NumpadEqual=89;j.F13=100;j.F14=101;j.F15=102;j.F16=103;j.F17=104;j.F18=105;j.F19=106;j.F20=107;j.F21=108;j.F22=109;j.F23=110;j.KanaMode=112;j.IntlRo=115;j.F24=118;j.Convert=121;j.NonConvert=123;j.IntlYen=125;j.NumpadComma=126;j.MediaTrackPrevious=4320;j.MediaTrackNext=6624;j.NumpadEnter=7392;j.ControlRight=7648;j.AudioVolumeMute=8416;j.LaunchApp2=8672;j.MediaPlayPause=8928;j.MediaStop=9440;j.VolumeDown=12e3;j.VolumeUp=12512;j.BrowserHome=13024;j.NumpadDivide=13792;j.PrintScreen=14304;j.AltRight=14560;j.NumLock=17888;j.Pause=18144;j.Home=18400;j.ArrowUp=18656;j.PageUp=18912;j.ArrowLeft=19424;j.ArrowRight=19936;j.End=20448;j.ArrowDown=20704;j.PageDown=20960;j.Insert=21216;j.Delete=21472;j.MetaLeft=23520;j.MetaRight=23776;j.ContextMenu=24032;j.Power=24288;j.BrowserSearch=26080;j.BrowserFavorites=26336;j.BrowserRefresh=26592;j.BrowserStop=26848;j.BrowserForward=27104;j.BrowserBack=27360;j.LaunchApp1=27616;j.LaunchMail=27872;j.MediaSelect=28128;var jh=0,Fh="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Hh(t){return String.fromCharCode.apply(null,new Uint16Array(t))}var z=[];z[49]=K.KEY_1;z[50]=K.KEY_2;z[51]=K.KEY_3;z[52]=K.KEY_4;z[53]=K.KEY_5;z[54]=K.KEY_6;z[55]=K.KEY_7;z[56]=K.KEY_8;z[57]=K.KEY_9;z[48]=K.KEY_0;z[145]=K.KEY_ScrollLock;z[103]=K.KEY_KP_7;z[104]=K.KEY_KP_8;z[105]=K.KEY_KP_9;z[100]=K.KEY_KP_4;z[101]=K.KEY_KP_5;z[102]=K.KEY_KP_6;z[107]=K.KEY_KP_Plus;z[97]=K.KEY_KP_1;z[98]=K.KEY_KP_2;z[99]=K.KEY_KP_3;z[96]=K.KEY_KP_0;z[109]=K.KEY_Minus;z[110]=K.KEY_KP_Decimal;z[191]=K.KEY_Slash;z[190]=K.KEY_Period;z[188]=K.KEY_Comma;z[220]=K.KEY_BSlash;z[192]=K.KEY_Tilde;z[222]=K.KEY_Quote;z[219]=K.KEY_LBrace;z[221]=K.KEY_RBrace;z[81]=K.KEY_Q;z[87]=K.KEY_W;z[69]=K.KEY_E;z[82]=K.KEY_R;z[84]=K.KEY_T;z[89]=K.KEY_Y;z[85]=K.KEY_U;z[73]=K.KEY_I;z[79]=K.KEY_O;z[80]=K.KEY_P;z[65]=K.KEY_A;z[83]=K.KEY_S;z[68]=K.KEY_D;z[70]=K.KEY_F;z[71]=K.KEY_G;z[72]=K.KEY_H;z[74]=K.KEY_J;z[75]=K.KEY_K;z[76]=K.KEY_L;z[90]=K.KEY_Z;z[88]=K.KEY_X;z[67]=K.KEY_C;z[86]=K.KEY_V;z[66]=K.KEY_B;z[78]=K.KEY_N;z[77]=K.KEY_M;z[32]=K.KEY_Space;z[13]=K.KEY_Enter;z[27]=K.KEY_Escape;z[8]=K.KEY_BackSpace;z[9]=K.KEY_Tab;z[16]=K.KEY_ShiftL;z[17]=K.KEY_LCtrl;z[18]=K.KEY_Alt;z[20]=K.KEY_CapsLock;z[44]=K.KEY_SysReqest;z[144]=K.KEY_NumLock;z[112]=K.KEY_F1;z[113]=K.KEY_F2;z[114]=K.KEY_F3;z[115]=K.KEY_F4;z[116]=K.KEY_F5;z[117]=K.KEY_F6;z[118]=K.KEY_F7;z[119]=K.KEY_F8;z[120]=K.KEY_F9;z[121]=K.KEY_F10;z[122]=K.KEY_F11;z[123]=K.KEY_F12;z[42]=99;z[19]=101;z[111]=224|K.KEY_Slash<<8;z[106]=224|K.KEY_KP_Multiply<<8;z[36]=224|K.KEY_KP_7<<8;z[38]=224|K.KEY_KP_8<<8;z[33]=224|K.KEY_KP_9<<8;z[37]=224|K.KEY_KP_4<<8;z[39]=224|K.KEY_KP_6<<8;z[35]=224|K.KEY_KP_1<<8;z[40]=224|K.KEY_KP_2<<8;z[34]=224|K.KEY_KP_3<<8;z[45]=224|K.KEY_KP_0<<8;z[46]=224|K.KEY_KP_Decimal<<8;z[91]=23520;z[92]=23776;z[93]=24032;var ls=[];ls[173]=K.KEY_Minus;ls[61]=K.KEY_Equal;ls[59]=K.KEY_SemiColon;var us=[];us[189]=K.KEY_Minus;us[187]=K.KEY_Equal;us[186]=K.KEY_SemiColon;function Gr(t,e){return j[e]!==void 0?j[e]:z[t]===void 0?navigator.userAgent.indexOf("Firefox")!=-1?ls[t]:us[t]:z[t]}function Kh(t,e){var s=Gr(t,e);return s===void 0?(alert("no map for "+t),0):s}function Gh(t,e){var s=Gr(t,e);return s===void 0?0:s<256?s|128:s|32768}function Yr(t){var e="[networkState "+t.networkState+"|readyState "+t.readyState+"|error "+t.error+"|seeking "+t.seeking+"|duration "+t.duration+"|paused "+t.paused+"|ended "+t.error+"|buffered "+Yh(t.buffered)+"]";return e}function Yh(t){var e;if(t){var s=t.length;e="{len "+s,s>0&&(e+="; start "+t.start(0)+"; end "+t.end(s-1)),e+="}"}else e="N/A";return e}function Kt(t,e){this.magic=R.SPICE_MAGIC,this.major_version=R.SPICE_VERSION_MAJOR,this.minor_version=R.SPICE_VERSION_MINOR,this.size=0,t!==void 0&&this.from_buffer(t,e)}Kt.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.magic="";for(var c=0;c<4;c++)this.magic+=String.fromCharCode(s.getUint8(e+c));e+=4,this.major_version=s.getUint32(e,!0),e+=4,this.minor_version=s.getUint32(e,!0),e+=4,this.size=s.getUint32(e,!0),e+=4},to_buffer:function(t,e){e=e||0;for(var s=new ee(t),c=0;c<4;c++)s.setUint8(e+c,this.magic.charCodeAt(c));e+=4,s.setUint32(e,this.major_version,!0),e+=4,s.setUint32(e,this.minor_version,!0),e+=4,s.setUint32(e,this.size,!0),e+=4},buffer_size:function(){return 16}};function zr(t,e){this.connection_id=0,this.channel_type=0,this.channel_id=0,this.common_caps=[],this.channel_caps=[],t!==void 0&&this.from_buffer(t,e)}zr.prototype={from_buffer:function(t,e){e=e||0;var s,c=e,v=new ee(t);this.connection_id=v.getUint32(e,!0),e+=4,this.channel_type=v.getUint8(e,!0),e++,this.channel_id=v.getUint8(e,!0),e++;var I=v.getUint32(e,!0);e+=4;var y=v.getUint32(e,!0);e+=4;var n=v.getUint32(e,!0);for(e+=4,e=c+n,this.common_caps=[],s=0;s<I;s++)this.common_caps.unshift(v.getUint32(e,!0)),e+=4;for(this.channel_caps=[],s=0;s<y;s++)this.channel_caps.unshift(v.getUint32(e,!0)),e+=4},to_buffer:function(t,e){e=e||0;var s=e,c,v=new ee(t);for(v.setUint32(e,this.connection_id,!0),e+=4,v.setUint8(e,this.channel_type,!0),e++,v.setUint8(e,this.channel_id,!0),e++,v.setUint32(e,this.common_caps.length,!0),e+=4,v.setUint32(e,this.channel_caps.length,!0),e+=4,v.setUint32(e,e-s+4,!0),e+=4,c=0;c<this.common_caps.length;c++)v.setUint32(e,this.common_caps[c],!0),e+=4;for(c=0;c<this.channel_caps.length;c++)v.setUint32(e,this.channel_caps[c],!0),e+=4},buffer_size:function(){return 18+4*this.common_caps.length+4*this.channel_caps.length}};function Wr(t,e){this.error=0,this.pub_key=void 0,this.common_caps=[],this.channel_caps=[],t!==void 0&&this.from_buffer(t,e)}Wr.prototype={from_buffer:function(t,e){e=e||0;var s,c=e,v=new ee(t);this.error=v.getUint32(e,!0),e+=4,this.pub_key=Ph(t,e),e+=R.SPICE_TICKET_PUBKEY_BYTES;var I=v.getUint32(e,!0);e+=4;var y=v.getUint32(e,!0);e+=4;var n=v.getUint32(e,!0);for(e+=4,e=c+n,this.common_caps=[],s=0;s<I;s++)this.common_caps.unshift(v.getUint32(e,!0)),e+=4;for(this.channel_caps=[],s=0;s<y;s++)this.channel_caps.unshift(v.getUint32(e,!0)),e+=4}};function $r(t,e){this.auth_mechanism=0,this.encrypted_data=void 0}$r.prototype={to_buffer:function(t,e){e=e||0;var s,c=new ee(t);for(c.setUint32(e,this.auth_mechanism,!0),e+=4,s=0;s<R.SPICE_TICKET_KEY_PAIR_LENGTH/8;s++)this.encrypted_data&&s<this.encrypted_data.length?c.setUint8(e,this.encrypted_data[s],!0):c.setUint8(e,0,!0),e++},buffer_size:function(){return 4+R.SPICE_TICKET_KEY_PAIR_LENGTH/8}};function Ns(t,e){this.auth_code=0,t!==void 0&&this.from_buffer(t,e)}Ns.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.auth_code=s.getUint32(e,!0),e+=4},buffer_size:function(){return 4}};function le(t,e){this.type=0,this.size=0,this.data=void 0,t!==void 0&&this.from_buffer(t,e)}le.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.type=s.getUint16(e,!0),e+=2,this.size=s.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength)},to_buffer:function(t,e){e=e||0;var s,c=new ee(t);if(c.setUint16(e,this.type,!0),e+=2,c.setUint32(e,this.data?this.data.byteLength:0,!0),e+=4,this.data&&this.data.byteLength>0){var v=new Uint8Array(this.data);for(s=0;s<v.length;s++,e++)c.setUint8(e,v[s],!0)}},build_msg:function(t,e){this.type=t,this.size=e.buffer_size(),this.data=new ArrayBuffer(this.size),e.to_buffer(this.data)},buffer_size:function(){return this.data?6+this.data.byteLength:6}};function Vr(t,e){this.num_of_channels=0,this.channels=[],t!==void 0&&this.from_buffer(t,e)}Vr.prototype={from_buffer:function(t,e){e=e||0;var s,c=new ee(t);for(this.num_of_channels=c.getUint32(e,!0),e+=4,s=0;s<this.num_of_channels;s++){var v=new Rr;e=v.from_dv(c,e,t),this.channels.push(v)}}};function qr(t,e){this.from_buffer(t,e)}qr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.session_id=s.getUint32(e,!0),e+=4,this.display_channels_hint=s.getUint32(e,!0),e+=4,this.supported_mouse_modes=s.getUint32(e,!0),e+=4,this.current_mouse_mode=s.getUint32(e,!0),e+=4,this.agent_connected=s.getUint32(e,!0),e+=4,this.agent_tokens=s.getUint32(e,!0),e+=4,this.multi_media_time=s.getUint32(e,!0),e+=4,this.ram_hint=s.getUint32(e,!0),e+=4}};function Xr(t,e){this.from_buffer(t,e)}Xr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.supported_modes=s.getUint16(e,!0),e+=2,this.current_mode=s.getUint16(e,!0),e+=2}};function Qr(t,e){this.from_buffer(t,e)}Qr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.protocol=s.getUint32(e,!0),e+=4,this.type=s.getUint32(e,!0),e+=4,this.opaque=s.getUint64(e,!0),e+=8,this.size=s.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength)}};function Us(t,e){this.from_buffer(t,e)}Us.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.num_tokens=s.getUint32(e,!0),e+=4}};function Jr(t,e){this.from_buffer(t,e)}Jr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.generation=s.getUint32(e,!0),e+=4,this.window=s.getUint32(e,!0),e+=4}};function Zr(t){this.generation=t.generation}Zr.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.generation,!0),e+=4},buffer_size:function(){return 4}};function en(t){this.mode=t}en.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint16(e,this.mode,!0),e+=2},buffer_size:function(){return 2}};function tn(t){this.num_tokens=t}tn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.num_tokens,!0),e+=4},buffer_size:function(){return 4}};function sn(t,e){this.protocol=R.VD_AGENT_PROTOCOL,this.type=t,this.opaque=0,this.size=e.buffer_size(),this.data=e}sn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.protocol,!0),e+=4,s.setUint32(e,this.type,!0),e+=4,s.setUint64(e,this.opaque,!0),e+=8,s.setUint32(e,this.size,!0),e+=4,this.data.to_buffer(t,e)},buffer_size:function(){return 20+this.data.buffer_size()}};function ti(t,e){e?(this.request=t,this.caps=e):this.from_buffer(t)}ti.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.request,!0),e+=4,s.setUint32(e,this.caps,!0),e+=4},from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.request=s.getUint32(e,!0),e+=4,this.caps=s.getUint32(e,!0),e+=4,e},buffer_size:function(){return 8}};function rn(t,e,s,c,v,I){this.num_mon=1,this.flags=t,this.width=e,this.height=s,this.depth=c,this.x=v,this.y=I}rn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.num_mon,!0),e+=4,s.setUint32(e,this.flags,!0),e+=4,s.setUint32(e,this.height,!0),e+=4,s.setUint32(e,this.width,!0),e+=4,s.setUint32(e,this.depth,!0),e+=4,s.setUint32(e,this.x,!0),e+=4,s.setUint32(e,this.y,!0),e+=4},buffer_size:function(){return 28}};function si(t,e){e?(this.id=t,this.result=e):this.from_buffer(t)}si.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.id,!0),e+=4,s.setUint32(e,this.result,!0),e+=4},from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.id=s.getUint32(e,!0),e+=4,this.result=s.getUint32(e,!0),e+=4,e},buffer_size:function(){return 8}};function nn(t,e,s){this.id=t,this.string=`[vdagent-file-xfer] name=`+e+` size=`+s+` `}nn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.id,!0),e+=4;for(var c=0;c<this.string.length;c++,e++)s.setUint8(e,this.string.charCodeAt(c))},buffer_size:function(){return 4+this.string.length+1}};function on(t,e,s){this.id=t,this.size=e,this.data=s}on.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);if(s.setUint32(e,this.id,!0),e+=4,s.setUint64(e,this.size,!0),e+=8,this.data&&this.data.byteLength>0)for(var c=new Uint8Array(this.data),v=0;v<c.length;v++,e++)s.setUint8(e,c[v])},buffer_size:function(){return 12+this.size}};function an(t,e){this.from_buffer(t,e)}an.prototype={from_buffer:function(t,e){e=e||0;var s,c=new ee(t);for(this.time_stamp=c.getUint64(e,!0),e+=8,this.severity=c.getUint32(e,!0),e+=4,this.visibility=c.getUint32(e,!0),e+=4,this.what=c.getUint32(e,!0),e+=4,this.message_len=c.getUint32(e,!0),e+=4,this.message="",s=0;s<this.message_len;s++){var v=c.getUint8(e,!0);e++,this.message+=String.fromCharCode(v)}}};function cn(){this.pixmap_cache_id=1,this.glz_dictionary_id=0,this.pixmap_cache_size=10*1024*1024,this.glz_dictionary_window_size=0}cn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint8(e,this.pixmap_cache_id,!0),e++,s.setUint64(e,this.pixmap_cache_size,!0),e+=8,s.setUint8(e,this.glz_dictionary_id,!0),e++,s.setUint32(e,this.glz_dictionary_window_size,!0),e+=4},buffer_size:function(){return 14}};function Mt(){}Mt.prototype={from_dv:function(t,e,s){return this.surface_id=t.getUint32(e,!0),e+=4,this.box=new it,e=this.box.from_dv(t,e,s),this.clip=new as,this.clip.from_dv(t,e,s)}};function hn(t,e){this.from_buffer(t,e)}hn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.base=new Mt,e=this.base.from_dv(s,e,t),this.data=new Fr,this.data.from_dv(s,e,t)}};function ln(t,e){this.from_buffer(t,e)}ln.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.base=new Mt,e=this.base.from_dv(s,e,t),this.data=new jr,this.data.from_dv(s,e,t)}};function un(t,e){this.from_buffer(t,e)}un.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.base=new Mt,e=this.base.from_dv(s,e,t),this.src_pos=new hs,this.src_pos.from_dv(s,e,t)}};function dn(t,e){this.from_buffer(t,e)}dn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.surface=new Kr,this.surface.from_dv(s,e,t)}};function _n(t,e){this.from_buffer(t,e)}_n.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.surface_id=s.getUint32(e,!0),e+=4}};function fn(t,e){this.from_buffer(t,e)}fn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.keyboard_modifiers=s.getUint16(e,!0),e+=2,e}};function pn(t,e){this.from_buffer(t,e)}pn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.keyboard_modifiers=s.getUint16(e,!0),e+=2,e}};function mn(t,e){this.from_buffer(t,e)}mn.prototype={from_buffer:function(t,e,s){e=e||0;var c=new ee(t);return this.position=new Zs,e=this.position.from_dv(c,e,s),this.trail_length=c.getUint16(e,!0),e+=2,this.trail_frequency=c.getUint16(e,!0),e+=2,this.visible=c.getUint8(e,!0),e++,this.cursor=new ei,this.cursor.from_dv(c,e,t)}};function gn(t,e){this.from_buffer(t,e)}gn.prototype={from_buffer:function(t,e,s){e=e||0;var c=new ee(t);return this.time=c.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength),e}};function vn(t,e){this.from_buffer(t,e)}vn.prototype={from_buffer:function(t,e,s){e=e||0;var c=new ee(t);return this.time=c.getUint32(e,!0),e+=4,this.mode=c.getUint16(e,!0),e+=2,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength),e}};function Sn(t,e){this.from_buffer(t,e)}Sn.prototype={from_buffer:function(t,e,s){e=e||0;var c=new ee(t);return this.channels=c.getUint32(e,!0),e+=4,this.format=c.getUint16(e,!0),e+=2,this.frequency=c.getUint32(e,!0),e+=4,this.time=c.getUint32(e,!0),e+=4,e}};function bn(t,e){this.from_buffer(t,e)}bn.prototype={from_buffer:function(t,e,s){e=e||0;var c=new ee(t);return this.position=new Zs,e=this.position.from_dv(c,e,s),this.visible=c.getUint8(e,!0),e++,this.cursor=new ei,this.cursor.from_dv(c,e,t)}};function Cn(t){const e=document.getElementById(t.screen_id),s=e==null?void 0:e.clientWidth,c=e==null?void 0:e.firstChild.width;return!c||!s?1:s>0&&c>s?c/s:1}function ds(t,e){if(this.display_id=0,this.buttons_state=t.buttons_state,e){const s=Cn(t);this.x=e.offsetX*s,this.y=e.offsetY*s,t.mousex=e.offsetX*s,t.mousey=e.offsetY*s}else this.x=this.y=this.buttons_state=0}ds.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint32(e,this.x,!0),e+=4,s.setUint32(e,this.y,!0),e+=4,s.setUint16(e,this.buttons_state,!0),e+=2,s.setUint8(e,this.display_id,!0),e+=1,e},buffer_size:function(){return 11}};function ii(t,e){if(this.display_id=0,this.buttons_state=t.buttons_state,e){const s=Cn(t);this.x=e.offsetX*s,this.y=e.offsetY*s,t.mousex!==void 0&&(this.x-=t.mousex*s,this.y-=t.mousey*s),t.mousex=e.offsetX*s,t.mousey=e.offsetY*s}else this.x=this.y=this.buttons_state=0}ii.prototype.to_buffer=ds.prototype.to_buffer;ii.prototype.buffer_size=ds.prototype.buffer_size;function Rt(t,e){e?(this.button=e.button+1,this.buttons_state=1<<e.button,t.buttons_state=this.buttons_state):(this.button=R.SPICE_MOUSE_BUTTON_LEFT,this.buttons_state=R.SPICE_MOUSE_BUTTON_MASK_LEFT)}Rt.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint8(e,this.button,!0),e++,s.setUint16(e,this.buttons_state,!0),e+=2,e},buffer_size:function(){return 3}};function _s(t,e){e?(this.button=e.button+1,this.buttons_state=0,t.buttons_state=this.buttons_state):(this.button=R.SPICE_MOUSE_BUTTON_LEFT,this.buttons_state=0)}_s.prototype.to_buffer=Rt.prototype.to_buffer;_s.prototype.buffer_size=Rt.prototype.buffer_size;function _t(t){t?this.code=Kh(t.keyCode,t.code):this.code=0}_t.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint32(e,this.code,!0),e+=4,e},buffer_size:function(){return 4}};function fs(t){t?this.code=Gh(t.keyCode,t.code):this.code=0}fs.prototype.to_buffer=_t.prototype.to_buffer;fs.prototype.buffer_size=_t.prototype.buffer_size;function En(t,e){this.from_buffer(t,e)}En.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.surface_id=s.getUint32(e,!0),e+=4,this.id=s.getUint32(e,!0),e+=4,this.flags=s.getUint8(e,!0),e+=1,this.codec_type=s.getUint8(e,!0),e+=1,this.stamp=s.getUint64(e,!0),e+=8,this.stream_width=s.getUint32(e,!0),e+=4,this.stream_height=s.getUint32(e,!0),e+=4,this.src_width=s.getUint32(e,!0),e+=4,this.src_height=s.getUint32(e,!0),e+=4,this.dest=new it,e=this.dest.from_dv(s,e,t),this.clip=new as,this.clip.from_dv(s,e,t)}};function ri(t,e){}ri.prototype={from_dv:function(t,e,s){return this.id=t.getUint32(e,!0),e+=4,this.multi_media_time=t.getUint32(e,!0),e+=4,e}};function yn(t,e){this.from_buffer(t,e)}yn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.base=new ri,e=this.base.from_dv(s,e,t),this.data_size=s.getUint32(e,!0),e+=4,this.data=s.u8.subarray(e,e+this.data_size)}};function wn(t,e){this.from_buffer(t,e)}wn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.base=new ri,e=this.base.from_dv(s,e,t),this.width=s.getUint32(e,!0),e+=4,this.height=s.getUint32(e,!0),e+=4,this.dest=new it,e=this.dest.from_dv(s,e,t),this.data_size=s.getUint32(e,!0),e+=4,this.data=s.u8.subarray(e,e+this.data_size)}};function xn(t,e){this.from_buffer(t,e)}xn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.id=s.getUint32(e,!0),e+=4,this.clip=new as,this.clip.from_dv(s,e,t)}};function In(t,e){this.from_buffer(t,e)}In.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.id=s.getUint32(e,!0),e+=4}};function An(t,e){this.from_buffer(t,e)}An.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.stream_id=s.getUint32(e,!0),e+=4,this.unique_id=s.getUint32(e,!0),e+=4,this.max_window_size=s.getUint32(e,!0),e+=4,this.timeout_ms=s.getUint32(e,!0),e+=4}};function Pn(t,e){this.stream_id=t,this.unique_id=e,this.start_frame_mm_time=0,this.end_frame_mm_time=0,this.num_frames=0,this.num_drops=0,this.last_frame_delay=0,this.audio_delay=-1}Pn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint32(e,this.stream_id,!0),e+=4,s.setUint32(e,this.unique_id,!0),e+=4,s.setUint32(e,this.start_frame_mm_time,!0),e+=4,s.setUint32(e,this.end_frame_mm_time,!0),e+=4,s.setUint32(e,this.num_frames,!0),e+=4,s.setUint32(e,this.num_drops,!0),e+=4,s.setUint32(e,this.last_frame_delay,!0),e+=4,s.setUint32(e,this.audio_delay,!0),e+=4,e},buffer_size:function(){return 8*4}};function Dn(t,e){this.count=0,this.resources=[],this.from_buffer(t,e)}Dn.prototype={from_buffer:function(t,e){var s;e=e||0;var c=new ee(t);for(this.count=c.getUint16(e,!0),e+=2,s=0;s<this.count;s++)this.resources[s]={},this.resources[s].type=c.getUint8(e,!0),e++,this.resources[s].id=c.getUint64(e,!0),e+=8}};function Ln(t,e){this.from_buffer(t,e)}Ln.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t),c=s.getUint32(e,!0);e+=4;var v=s.getUint32(e,!0);e+=4,this.opened=s.getUint8(e,!0),e+=1,this.name=t.slice(v,v+c-1)}};var Mn=Array(256),Rn=0;function zh(){var t,e,s;for(e=0;e<256;e++){for(t=e,s=0;s<8;s++)t&1?t=(3988292384^t>>>1)>>>0&4294967295:t=t>>>1;Mn[e]=t}Rn=1}function Wh(t,e,s,c){var v=t,I;for(Rn||zh(),I=0;I<c;I++)v=Mn[(v^e[s+I])&255]^v>>>8;return v}function $h(t,e,s){return Wh(4294967295,t,e,s)^4294967295}function ni(t,e,s){var c=new Uint8Array(t);return $h(c,e,s)}function Tn(t,e){this.width=t,this.height=e,this.depth=8,this.type=6,this.compression=0,this.filter=0,this.interlace=0}Tn.prototype={to_buffer:function(t,e){e=e||0;var s=e,c=new ee(t);return c.setUint32(e,this.buffer_size()-12),e+=4,c.setUint8(e,73),e++,c.setUint8(e,72),e++,c.setUint8(e,68),e++,c.setUint8(e,82),e++,c.setUint32(e,this.width),e+=4,c.setUint32(e,this.height),e+=4,c.setUint8(e,this.depth),e++,c.setUint8(e,this.type),e++,c.setUint8(e,this.compression),e++,c.setUint8(e,this.filter),e++,c.setUint8(e,this.interlace),e++,c.setUint32(e,ni(t,s+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 25}};function kn(){this.s1=1,this.s2=0}kn.prototype.update=function(t){this.s1+=t,this.s1%=65521,this.s2+=this.s1,this.s2%=65521};function Bn(t,e,s){if(s.byteLength>65535)throw new Error("Cannot handle more than 64K");this.data=s,this.width=t,this.height=e}Bn.prototype={to_buffer:function(t,e){e=e||0;var s=e,c,v,I,y=new ee(t),n=new kn;y.setUint32(e,this.buffer_size()-12),e+=4,y.setUint8(e,73),e++,y.setUint8(e,68),e++,y.setUint8(e,65),e++,y.setUint8(e,84),e++,y.setUint8(e,120),e++,y.setUint8(e,1),e++,y.setUint8(e,128),e++,y.setUint16(e,this.data.byteLength+this.height),e+=2,y.setUint16(e,~(this.data.byteLength+this.height)),e+=2;var a=new Uint8Array(this.data);for(I=0,v=0;v<this.height;v++)for(y.setUint8(e,0),e++,n.update(0),c=0;c<this.width&&I<this.data.byteLength;c++)n.update(a[I]),y.setUint8(e,a[I++]),e++,n.update(a[I]),y.setUint8(e,a[I++]),e++,n.update(a[I]),y.setUint8(e,a[I++]),e++,n.update(a[I]),y.setUint8(e,a[I++]),e++;return y.setUint16(e,n.s2),e+=2,y.setUint16(e,n.s1),e+=2,y.setUint32(e,ni(t,s+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 12+this.data.byteLength+this.height+4+2+1+2+2}};function On(){}On.prototype={to_buffer:function(t,e){e=e||0;var s=e,c=new ee(t);return c.setUint32(e,this.buffer_size()-12),e+=4,c.setUint8(e,73),e++,c.setUint8(e,69),e++,c.setUint8(e,78),e++,c.setUint8(e,68),e++,c.setUint32(e,ni(t,s+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 12}};function Vh(t,e,s){var c,v=new Tn(t,e),I=new Bn(t,e,s),y=new On,n=new ArrayBuffer(v.buffer_size()+I.buffer_size()+y.buffer_size()),a=v.to_buffer(n);a=I.to_buffer(n,a),a=y.to_buffer(n,a);var u=new Uint8Array(n),_="";for(c=0;c<a;c++)_+="%",u[c]<16&&(_+="0"),_+=u[c].toString(16);return"%89PNG%0D%0A%1A%0A"+_}var Se={cursors:new Array,unknown_cursors:new Array,warned:!1,add_cursor:function(t,e){Se.cursors[t]=e},unknown_cursor:function(t,e){Se.warned||(Se.warned=!0,alert(`Internet Explorer does not support dynamic cursors. This page will now simulate cursors with images, which will be imperfect. We recommend using Chrome or Firefox instead. If you need to use Internet Explorer, you can create a static cursor file for each cursor your application uses. View the console log for more information on creating static cursors for your environment.`)),Se.unknown_cursors[t]||(Se.unknown_cursors[t]=e,console.log("Unknown cursor. Simulation required. To avoid simulation for this cursor, create and include a custom javascript file, and add the following line:"),console.log('SpiceCursorSimulator.add_cursor("'+t+'"), "<your filename here>.cur");'),console.log("And then run following command, redirecting output into <your filename here>.cur:"),console.log(`php -r "echo urldecode('`+e+`');"`))},simulate_cursor:function(t,e,s,c){var v=Sh(c+" "+e.header.hot_spot_x+" "+e.header.hot_spot_y);if(typeof Se.cursors<"u"&&typeof Se.cursors[v]<"u"){var I="url("+Se.cursors[v]+"), default";s.style.cursor=I}window.getComputedStyle(s,null).cursor=="auto"?(Se.unknown_cursor(v,Se.create_icondir(e.header.width,e.header.height,e.data.byteLength,e.header.hot_spot_x,e.header.hot_spot_y)+c),document.getElementById(t.parent.screen_id).style.cursor="none",t.spice_simulated_cursor||(t.spice_simulated_cursor=document.createElement("img"),t.spice_simulated_cursor.style.position="absolute",t.spice_simulated_cursor.style.display="none",t.spice_simulated_cursor.style.overflow="hidden",t.spice_simulated_cursor.spice_screen=document.getElementById(t.parent.screen_id),t.spice_simulated_cursor.addEventListener("mousemove",Se.handle_sim_mousemove),t.spice_simulated_cursor.spice_screen.appendChild(t.spice_simulated_cursor)),t.spice_simulated_cursor.src="data:image/png,"+c,t.spice_simulated_cursor.spice_hot_x=e.header.hot_spot_x,t.spice_simulated_cursor.spice_hot_y=e.header.hot_spot_y,t.spice_simulated_cursor.style.pointerEvents="none"):t.spice_simulated_cursor&&(t.spice_simulated_cursor.spice_screen.removeChild(t.spice_simulated_cursor),delete t.spice_simulated_cursor)},handle_sim_mousemove:function(t){var e=Se.duplicate_mouse_event(t,this.spice_screen);return this.spice_screen.dispatchEvent(e)},duplicate_mouse_event:function(t,e){var s=document.createEvent("mouseevent");return s.initMouseEvent(t.type,!0,!0,t.view,t.detail,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,t.button,t.relatedTarget),s},ICONDIR:function(){},ICONDIRENTRY:function(t,e,s,c,v){this.width=t,this.height=e,this.bytes=s,this.hot_x=c,this.hot_y=v},create_icondir:function(t,e,s,c,v){var I,y=new Se.ICONDIR,n=new Se.ICONDIRENTRY(t,e,s,c,v),a=new ArrayBuffer(y.buffer_size()+n.buffer_size()),u=y.to_buffer(a);u=n.to_buffer(a,u);var _=new Uint8Array(a),l="";for(I=0;I<u;I++)l+="%",_[I]<16&&(l+="0"),l+=_[I].toString(16);return l}};Se.ICONDIR.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint16(e,0,!0),e+=2,s.setUint16(e,2,!0),e+=2,s.setUint16(e,1,!0),e+=2,e},buffer_size:function(){return 6}};Se.ICONDIRENTRY.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint8(e,this.width),e++,s.setUint8(e,this.height),e++,s.setUint8(e,0),e++,s.setUint8(e,0),e++,s.setUint16(e,this.hot_x,!0),e+=2,s.setUint16(e,this.hot_y,!0),e+=2,s.setUint32(e,this.bytes,!0),e+=4,s.setUint32(e,e+4,!0),e+=4,e},buffer_size:function(){return 16}};function oi(t,e){this.sc=t,this.callback=e,this.needed=0,this.size=0,this.buffers=[],this.sc.ws.wire_reader=this,this.sc.ws.binaryType="arraybuffer",this.sc.ws.addEventListener("message",qh)}oi.prototype={inbound:function(t){if(this.needed==0){this.buffers.push(t),this.size+=t.byteLength;return}for(this.buffers.length==0&&t.byteLength>=this.needed?(t.byteLength>this.needed&&(this.size=t.byteLength-this.needed,this.buffers.push(t.slice(this.needed)),t=t.slice(0,this.needed)),this.callback.call(this.sc,t,this.saved_msg_header||void 0)):(this.buffers.push(t),this.size+=t.byteLength);this.size>=this.needed;){for(var e=0,s=new ArrayBuffer(this.needed),c=new Uint8Array(s);e<s.byteLength&&this.buffers.length>0;){var v=this.buffers.shift();if(!v)return;var I=new Uint8Array(v),y=s.byteLength-e;if(I.length<=y)c.set(I,e),e+=I.length,this.size-=I.length;else{var n=I.slice(0,y);c.set(n,e),e+=n.length,this.size-=n.length,this.buffers.unshift(I.slice(y))}}this.callback.call(this.sc,s,this.saved_msg_header||void 0)}},request:function(t){this.needed=t},save_header:function(t){this.saved_msg_header=t},clear_header:function(){this.saved_msg_header=void 0}};function qh(t){oi.prototype.inbound.call(this.wire_reader,t.data)}var Xh=[26,69,223,163],Qh=[66,134],Jh=[66,247],Zh=[66,242],el=[66,243],tl=[66,130],sl=[66,135],il=[66,133],rl=[24,83,128,103],Nn=[21,73,169,102],Ui=[42,215,177],ji=[77,128],Fi=[87,65],nl=[17,77,155,116],ol=[77,187],Hi=[83,171],Ki=[83,172],Un=[22,84,174,107],jn=[174],Gt=[215],Yt=[115,197],zt=[131],Wt=[185],$t=[136],Vt=[85,170],qt=[156],Xt=[109,231],Qt=[85,238],Jt=[170],Zt=[86,187],Gi=[86,170],Yi=[99,162],es=[134],al=[224],zi=[154],Wi=[176],$i=[186],cl=[225],Vi=[181],qi=[159],hl=[31,67,182,117],Xi=[231],ll=[163],_e={CLUSTER_SIMPLEBLOCK_FLAG_KEYFRAME:128,OPUS_FREQUENCY:48e3,OPUS_CHANNELS:2,SPICE_PLAYBACK_CODEC:'audio/webm; codecs="opus"',MAX_CLUSTER_TIME:1e3,EXPECTED_PACKET_DURATION:10,GAP_DETECTION_THRESHOLD:50,SPICE_VP8_CODEC:'video/webm; codecs="vp8"'};function rt(t,e,s){var c=128|t;return e.setUint8(s,c),s+1}function ce(t,e,s,c){return c=ve(t,s,c),c=rt(1,s,c),s.setUint8(c,e),c+1}function At(t,e,s,c){return c=ve(t,s,c),c=rt(4,s,c),s.setUint32(c,e),c+4}function js(t,e,s,c){return c=ve(t,s,c),c=rt(2,s,c),s.setUint16(c,e),c+2}function ul(t,e,s,c){return c=ve(t,s,c),c=rt(4,s,c),s.setFloat32(c,e),c+4}function Ke(t,e,s){e.setUint8(s++,1),e.setUint8(s++,0),e.setUint8(s++,0),e.setUint8(s++,0);for(var c=t&4294967295,v=24;v>=0;v-=8)e.setUint8(s++,c>>v);return s}function ve(t,e,s){for(var c=0;c<t.length;c++)e.setUint8(s+c,t[c]);return s+t.length}function dl(t,e,s){for(var c=0;c<t.length;c++)e.setUint8(s+c,t.charCodeAt(c));return s+t.length}function et(t,e,s,c){return c=ve(t,s,c),e.length<127?c=rt(e.length,s,c):c=Ke(e.length,s,c),typeof e=="string"?c=dl(e,s,c):c=ve(e,s,c),c}function Fn(){this.id=Xh,this.Version=1,this.ReadVersion=1,this.MaxIDLength=4,this.MaxSizeLength=8,this.DocType="webm",this.DocTypeVersion=2,this.DocTypeReadVersion=2}Fn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(31,s,e),e=ce(Qh,this.Version,s,e),e=ce(Jh,this.ReadVersion,s,e),e=ce(Zh,this.MaxIDLength,s,e),e=ce(el,this.MaxSizeLength,s,e),e=et(tl,this.DocType,s,e),e=ce(sl,this.DocTypeVersion,s,e),e=ce(il,this.DocTypeReadVersion,s,e),e},buffer_size:function(){return 39+this.id.length}};function Hn(){this.id=rl}Hn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),s.setUint8(e++,255),e},buffer_size:function(){return this.id.length+1}};function Kn(){this.id=Nn,this.timecode_scale=1e6,this.muxing_app="spice",this.writing_app="spice-html5"}Kn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(this.buffer_size()-8-this.id.length,s,e),e=At(Ui,this.timecode_scale,s,e),e=et(ji,this.muxing_app,s,e),e=et(Fi,this.writing_app,s,e),e},buffer_size:function(){return this.id.length+8+Ui.length+1+4+ji.length+1+this.muxing_app.length+Fi.length+1+this.writing_app.length}};function Gn(t){this.id=cl,this.sampling_frequency=t,this.channels=_e.OPUS_CHANNELS}Gn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(this.buffer_size()-8-this.id.length,s,e),e=ce(qi,this.channels,s,e),e=ul(Vi,this.sampling_frequency,s,e),e},buffer_size:function(){return this.id.length+8+Vi.length+1+4+qi.length+1+1}};function Yn(t,e){this.id=al,this.flag_interlaced=0,this.width=t,this.height=e}Yn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(this.buffer_size()-8-this.id.length,s,e),e=ce(zi,this.flag_interlaced,s,e),e=js(Wi,this.width,s,e),e=js($i,this.height,s,e),e},buffer_size:function(){return this.id.length+8+zi.length+1+1+Wi.length+1+2+$i.length+1+2}};function Fs(t,e){this.id=ol,this.pos=e,this.seekid=t}Fs.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=rt(this.buffer_size()-1-this.id.length,s,e),e=et(Hi,this.seekid,s,e),e=js(Ki,this.pos,s,e),e},buffer_size:function(){return this.id.length+1+Hi.length+1+this.seekid.length+Ki.length+1+2}};function zn(t,e){this.id=nl,this.info=new Fs(Nn,t),this.track=new Fs(Un,e)}zn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(this.buffer_size()-8-this.id.length,s,e),e=this.info.to_buffer(t,e),e=this.track.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+this.info.buffer_size()+this.track.buffer_size()}};function Wn(){this.id=jn,this.number=1,this.uid=2,this.type=2,this.flag_enabled=1,this.flag_default=1,this.flag_forced=1,this.flag_lacing=0,this.min_cache=0,this.max_block_addition_id=0,this.codec_decode_all=0,this.seek_pre_roll=0,this.codec_delay=8e7,this.codec_id="A_OPUS",this.audio=new Gn(_e.OPUS_FREQUENCY),this.codec_private=[79,112,117,115,72,101,97,100,1,_e.OPUS_CHANNELS,0,15,128,187,0,0,0,0,0]}Wn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(this.buffer_size()-8-this.id.length,s,e),e=ce(Gt,this.number,s,e),e=ce(Yt,this.uid,s,e),e=ce(Wt,this.flag_enabled,s,e),e=ce($t,this.flag_default,s,e),e=ce(Vt,this.flag_forced,s,e),e=ce(qt,this.flag_lacing,s,e),e=et(es,this.codec_id,s,e),e=ce(Xt,this.min_cache,s,e),e=ce(Qt,this.max_block_addition_id,s,e),e=ce(Jt,this.codec_decode_all,s,e),e=At(Gi,this.codec_delay,s,e),e=At(Zt,this.seek_pre_roll,s,e),e=ce(zt,this.type,s,e),e=et(Yi,this.codec_private,s,e),e=this.audio.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+Gt.length+1+1+Yt.length+1+1+zt.length+1+1+Wt.length+1+1+$t.length+1+1+Vt.length+1+1+qt.length+1+1+Xt.length+1+1+Qt.length+1+1+Jt.length+1+1+Zt.length+1+4+Gi.length+1+4+es.length+this.codec_id.length+1+Yi.length+1+this.codec_private.length+this.audio.buffer_size()}};function $n(t,e){this.id=jn,this.number=1,this.uid=1,this.type=1,this.flag_enabled=1,this.flag_default=1,this.flag_forced=1,this.flag_lacing=1,this.min_cache=0,this.max_block_addition_id=0,this.codec_id="V_VP8",this.codec_decode_all=1,this.seek_pre_roll=0,this.video=new Yn(t,e)}$n.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(this.buffer_size()-8-this.id.length,s,e),e=ce(Gt,this.number,s,e),e=ce(Yt,this.uid,s,e),e=ce(Wt,this.flag_enabled,s,e),e=ce($t,this.flag_default,s,e),e=ce(Vt,this.flag_forced,s,e),e=ce(qt,this.flag_lacing,s,e),e=et(es,this.codec_id,s,e),e=ce(Xt,this.min_cache,s,e),e=ce(Qt,this.max_block_addition_id,s,e),e=ce(Jt,this.codec_decode_all,s,e),e=At(Zt,this.seek_pre_roll,s,e),e=ce(zt,this.type,s,e),e=this.video.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+Gt.length+1+1+Yt.length+1+1+Wt.length+1+1+$t.length+1+1+Vt.length+1+1+qt.length+1+1+es.length+this.codec_id.length+1+Xt.length+1+1+Qt.length+1+1+Jt.length+1+1+Zt.length+1+4+zt.length+1+1+this.video.buffer_size()}};function ai(t){this.id=Un,this.track_entry=t}ai.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),e=Ke(this.buffer_size()-8-this.id.length,s,e),e=this.track_entry.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+this.track_entry.buffer_size()}};function ci(t,e){this.id=hl,this.timecode=t,this.data=e}ci.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=ve(this.id,s,e),s.setUint8(e++,255),e=At(Xi,this.timecode,s,e),e},buffer_size:function(){return this.id.length+1+Xi.length+1+4}};function hi(t,e,s){this.id=ll,this.timecode=t,this.data=e,this.keyframe=s}hi.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);e=ve(this.id,s,e),e=Ke(this.data.byteLength+4,s,e),e=rt(1,s,e),s.setUint16(e,this.timecode),e+=2,s.setUint8(e,this.keyframe?_e.CLUSTER_SIMPLEBLOCK_FLAG_KEYFRAME:0),e+=1;for(var c=new Uint8Array(this.data),v=0;v<this.data.byteLength;v++)s.setUint8(e++,c[v]);return e},buffer_size:function(){return this.id.length+8+1+2+1+this.data.byteLength}};function li(){this.ebml=new Fn,this.segment=new Hn,this.seek_head=new zn(0,0),this.seek_head.info.pos=this.segment.buffer_size()+this.seek_head.buffer_size(),this.info=new Kn,this.seek_head.track.pos=this.seek_head.info.pos+this.info.buffer_size()}li.prototype={to_buffer:function(t,e){return e=e||0,e=this.ebml.to_buffer(t,e),e=this.segment.to_buffer(t,e),e=this.info.to_buffer(t,e),e},buffer_size:function(){return this.ebml.buffer_size()+this.segment.buffer_size()+this.info.buffer_size()}};function we(t){if(t===void 0||t.uri===void 0||!t.uri)throw new Error("You must specify a uri");if(this.ws=new WebSocket(t.uri),!this.ws.binaryType)throw new Error("WebSocket doesn't support binaryType. Try a different browser.");if(this.connection_id=t.connection_id!==void 0?t.connection_id:0,this.type=t.type!==void 0?t.type:R.SPICE_CHANNEL_MAIN,this.chan_id=t.chan_id!==void 0?t.chan_id:0,t.parent!==void 0&&(this.parent=t.parent,this.message_id=t.parent.message_id,this.password=t.parent.password),t.screen_id!==void 0&&(this.screen_id=t.screen_id),t.dump_id!==void 0&&(this.dump_id=t.dump_id),t.message_id!==void 0&&(this.message_id=t.message_id),t.password!==void 0&&(this.password=t.password),t.onerror!==void 0&&(this.onerror=t.onerror),t.onsuccess!==void 0&&(this.onsuccess=t.onsuccess),t.onagent!==void 0&&(this.onagent=t.onagent),this.state="connecting",this.ws.parent=this,this.wire_reader=new oi(this,this.process_inbound),this.messages_sent=0,this.warnings=[],this.ws.addEventListener("open",function(e){this.parent.send_hdr(),this.parent.wire_reader.request(Kt.prototype.buffer_size()),this.parent.state="start"}),this.ws.addEventListener("error",function(e){"url"in e.target&&this.parent.log_err("WebSocket error: Can't connect to websocket on URL: "+e.target.url),this.parent.report_error(e)}),this.ws.addEventListener("close",function(e){var s,c;if(this.parent.state!="closing"&&this.parent.state!="error"&&this.parent.onerror!==void 0){var e;this.parent.state=="connecting"?e=new Error("Connection refused."):this.parent.state=="start"||this.parent.state=="link"?e=new Error("Unexpected protocol mismatch."):this.parent.state=="ticket"?e=new Error("Bad password."):e=new Error("Unexpected close while "+this.parent.state),this.parent.onerror(e),this.parent.log_err(e.toString())}else((c=(s=this.parent)==null?void 0:s.parent)==null?void 0:c.onerror)!==void 0&&this.parent.parent.onerror(new Error("Connection closed"))}),this.ws.readyState==2||this.ws.readyState==3)throw new Error("Unable to connect to "+t.uri);this.timeout=window.setTimeout(_l,R.SPICE_CONNECT_TIMEOUT,this)}we.prototype={send_hdr:function(){var t=new Kt,e=new zr;if(e.connection_id=this.connection_id,e.channel_type=this.type,e.channel_id=this.chan_id,e.common_caps.push(1<<R.SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION|1<<R.SPICE_COMMON_CAP_MINI_HEADER),e.channel_type==R.SPICE_CHANNEL_PLAYBACK){var s=0;"MediaSource"in window&&MediaSource.isTypeSupported(_e.SPICE_PLAYBACK_CODEC)&&(s|=1<<R.SPICE_PLAYBACK_CAP_OPUS),e.channel_caps.push(s)}else if(e.channel_type==R.SPICE_CHANNEL_MAIN)e.channel_caps.push(1<<R.SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS);else if(e.channel_type==R.SPICE_CHANNEL_DISPLAY){var s=1<<R.SPICE_DISPLAY_CAP_SIZED_STREAM|1<<R.SPICE_DISPLAY_CAP_STREAM_REPORT|1<<R.SPICE_DISPLAY_CAP_MULTI_CODEC|1<<R.SPICE_DISPLAY_CAP_CODEC_MJPEG;"MediaSource"in window&&MediaSource.isTypeSupported(_e.SPICE_VP8_CODEC)&&(s|=1<<R.SPICE_DISPLAY_CAP_CODEC_VP8),e.channel_caps.push(s)}t.size=e.buffer_size();var c=new ArrayBuffer(t.buffer_size()+e.buffer_size());t.to_buffer(c),e.to_buffer(c,t.buffer_size()),this.ws.send(c)},send_ticket:function(t){var e=new $r;e.auth_mechanism=R.SPICE_COMMON_CAP_AUTH_SPICE,e.encrypted_data=t;var s=new ArrayBuffer(e.buffer_size());e.to_buffer(s),this.ws.send(s)},send_msg:function(t){var e=new ArrayBuffer(t.buffer_size());t.to_buffer(e),this.messages_sent++,this.ws.send(e)},process_inbound:function(t,e){if(this.state=="ready")if(e==null){var s=new le(t);s.type>500,s.size==0?(this.process_message(s),this.wire_reader.request(le.prototype.buffer_size())):(this.wire_reader.request(s.size),this.wire_reader.save_header(s))}else e.data=t,this.process_message(e),this.wire_reader.request(le.prototype.buffer_size()),this.wire_reader.save_header(void 0);else if(this.state=="start")if(this.reply_hdr=new Kt(t),this.reply_hdr.magic!=R.SPICE_MAGIC){this.state="error";var c=new Error("Error: magic mismatch: "+this.reply_hdr.magic);this.report_error(c)}else this.wire_reader.request(this.reply_hdr.size),this.state="link";else if(this.state=="link")if(this.reply_link=new Wr(t),this.reply_link.error){this.state="error";var c=new Error("Error: reply link error "+this.reply_link.error);this.report_error(c)}else this.send_ticket(Dh(this.reply_link.pub_key,this.password+"\0")),this.state="ticket",this.wire_reader.request(Ns.prototype.buffer_size());else if(this.state=="ticket")if(this.auth_reply=new Ns(t),this.auth_reply.auth_code==R.SPICE_LINK_ERR_OK){if(this.type==R.SPICE_CHANNEL_DISPLAY){var v=new cn,I=new le;I.build_msg(R.SPICE_MSGC_DISPLAY_INIT,v),this.send_msg(I)}this.state="ready",this.wire_reader.request(le.prototype.buffer_size()),this.timeout&&(window.clearTimeout(this.timeout),delete this.timeout)}else{if(this.state="error",this.auth_reply.auth_code==R.SPICE_LINK_ERR_PERMISSION_DENIED)var c=new Error("Permission denied.");else var c=new Error("Unexpected link error "+this.auth_reply.auth_code);this.report_error(c)}},process_common_messages:function(t){if(t.type==R.SPICE_MSG_SET_ACK){var e=new Jr(t.data);this.ack_window=e.window,this.msgs_until_ack=this.ack_window;var s=new Zr(e),c=new le;return c.build_msg(R.SPICE_MSGC_ACK_SYNC,s),this.send_msg(c),!0}if(t.type==R.SPICE_MSG_PING){var v=new le;return v.type=R.SPICE_MSGC_PONG,t.data&&(v.data=t.data.slice(0,12)),v.size=v.buffer_size(),this.send_msg(v),!0}if(t.type==R.SPICE_MSG_NOTIFY){var I=new an(t.data);return I.severity==R.SPICE_NOTIFY_SEVERITY_ERROR?this.log_err(I.message):I.severity==R.SPICE_NOTIFY_SEVERITY_WARN?this.log_warn(I.message):this.log_info(I.message),!0}return!1},process_message:function(t){var e,s=Date.now();if(e=this.process_common_messages(t),e||(this.process_channel_message?(e=this.process_channel_message(t),e||this.log_warn(this.channel_type()+": Unknown message type "+t.type+"!")):this.log_err(this.channel_type()+": No message handlers for this channel; message "+t.type)),this.msgs_until_ack!==void 0&&this.ack_window&&(this.msgs_until_ack--,this.msgs_until_ack<=0)){this.msgs_until_ack=this.ack_window;var c=new le;c.type=R.SPICE_MSGC_ACK,this.send_msg(c)}var v=Date.now()-s;return v>_e.GAP_DETECTION_THRESHOLD&&console.log("delta "+this.channel_type()+":"+t.type+" "+v),e},channel_type:function(){return this.type==R.SPICE_CHANNEL_MAIN?"main":this.type==R.SPICE_CHANNEL_DISPLAY?"display":this.type==R.SPICE_CHANNEL_INPUTS?"inputs":this.type==R.SPICE_CHANNEL_CURSOR?"cursor":this.type==R.SPICE_CHANNEL_PLAYBACK?"playback":this.type==R.SPICE_CHANNEL_RECORD?"record":this.type==R.SPICE_CHANNEL_TUNNEL?"tunnel":this.type==R.SPICE_CHANNEL_SMARTCARD?"smartcard":this.type==R.SPICE_CHANNEL_USBREDIR?"Fusbredir":this.type==R.SPICE_CHANNEL_PORT?"port":this.type==R.SPICE_CHANNEL_WEBDAV?"webdav":"unknown-"+this.type},log_info:function(){var t=Array.prototype.join.call(arguments," ");if(console.log(t),this.message_id){var e=document.createElement("p");e.appendChild(document.createTextNode(t)),e.className+="spice-message-info",document.getElementById(this.message_id).appendChild(e)}},log_warn:function(){var t=Array.prototype.join.call(arguments," ");if(console.log("WARNING: "+t),this.message_id){var e=document.createElement("p");e.appendChild(document.createTextNode(t)),e.className+="spice-message-warning",document.getElementById(this.message_id).appendChild(e)}},log_err:function(){var t=Array.prototype.join.call(arguments," ");if(console.log("ERROR: "+t),this.message_id){var e=document.createElement("p");e.appendChild(document.createTextNode(t)),e.className+="spice-message-error",document.getElementById(this.message_id).appendChild(e)}},known_unimplemented:function(t,e){if(!this.warnings[t]||jh>1){var s="";s=" [ further notices suppressed ]",this.log_warn("Unimplemented function "+t+"("+e+")"+s),this.warnings[t]=!0}},report_error:function(t){if(this.log_err(t.toString()),this.onerror!=null)this.onerror(t);else throw t},report_success:function(t){this.onsuccess!=null&&this.onsuccess(t)},cleanup:function(){this.timeout&&(window.clearTimeout(this.timeout),delete this.timeout),this.ws&&(this.ws.close(),this.ws=void 0)},handle_timeout:function(){var t=new Error("Connection timed out.");this.report_error(t)}};function _l(t){we.prototype.handle_timeout.call(t)}function ps(){we.apply(this,arguments)}ps.prototype=Object.create(we.prototype);ps.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_CURSOR_INIT){var e=new mn(t.data);return this.parent&&this.parent.inputs&&this.parent.inputs.mouse_mode==R.SPICE_MOUSE_MODE_SERVER&&(this.parent.inputs.mousex=e.position.x,this.parent.inputs.mousey=e.position.y),!0}if(t.type==R.SPICE_MSG_CURSOR_SET){var s=new bn(t.data);return s.flags&R.SPICE_CURSOR_FLAGS_NONE?(document.getElementById(this.parent.screen_id).style.cursor="none",!0):(s.flags>0&&this.log_warn("FIXME: No support for cursor flags "+s.flags),s.cursor.header.type!=R.SPICE_CURSOR_TYPE_ALPHA?(this.log_warn("FIXME: No support for cursor type "+s.cursor.header.type),!1):(this.set_cursor(s.cursor),!0))}return t.type==R.SPICE_MSG_CURSOR_MOVE?(this.known_unimplemented(t.type,"Cursor Move"),!0):t.type==R.SPICE_MSG_CURSOR_HIDE?(document.getElementById(this.parent.screen_id).style.cursor="none",!0):t.type==R.SPICE_MSG_CURSOR_TRAIL?(this.known_unimplemented(t.type,"Cursor Trail"),!0):t.type==R.SPICE_MSG_CURSOR_RESET?(document.getElementById(this.parent.screen_id).style.cursor="auto",!0):t.type==R.SPICE_MSG_CURSOR_INVAL_ONE?(this.known_unimplemented(t.type,"Cursor Inval One"),!0):t.type==R.SPICE_MSG_CURSOR_INVAL_ALL};ps.prototype.set_cursor=function(t){var e=Vh(t.header.width,t.header.height,t.data),s="url(data:image/png,"+e+") "+t.header.hot_spot_x+" "+t.header.hot_spot_y+", default",c=document.getElementById(this.parent.screen_id);c.style.cursor="auto",c.style.cursor=s,window.getComputedStyle(c,null).cursor=="auto"&&Se.simulate_cursor(this,t,c,e)};function ms(t,e){this.id=t,this.file=e}ms.prototype.create_progressbar=function(){var t=this,e=document.createElement("input");this.progressbar_container=document.createElement("div"),this.progressbar=document.createElement("progress"),e.type="button",e.value="Cancel",e.style.float="right",e.onclick=function(){t.cancelled=!0,t.remove_progressbar()},this.progressbar.setAttribute("max",this.file.size),this.progressbar.setAttribute("value",0),this.progressbar.style.width="100%",this.progressbar.style.margin="4px auto",this.progressbar.style.display="inline-block",this.progressbar_container.style.width="90%",this.progressbar_container.style.margin="auto",this.progressbar_container.style.padding="4px",this.progressbar_container.textContent=this.file.name,this.progressbar_container.appendChild(e),this.progressbar_container.appendChild(this.progressbar),document.getElementById("spice-xfer-area").appendChild(this.progressbar_container)};ms.prototype.update_progressbar=function(t){this.progressbar.setAttribute("value",t)};ms.prototype.remove_progressbar=function(){this.progressbar_container&&this.progressbar_container.parentNode&&this.progressbar_container.parentNode.removeChild(this.progressbar_container)};var nt=-1,bt=-1,Ct=-1,Et=-1;function ui(){we.apply(this,arguments),this.mousex=void 0,this.mousey=void 0,this.button_state=0,this.waiting_for_ack=0}ui.prototype=Object.create(we.prototype);ui.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_INPUTS_INIT){var e=new fn(t.data);return this.keyboard_modifiers=e.keyboard_modifiers,!0}if(t.type==R.SPICE_MSG_INPUTS_KEY_MODIFIERS){var s=new pn(t.data);return this.keyboard_modifiers=s.keyboard_modifiers,!0}return t.type==R.SPICE_MSG_INPUTS_MOUSE_MOTION_ACK?(this.waiting_for_ack-=R.SPICE_INPUT_MOTION_ACK_BUNCH,!0):!1};function Vn(t){var e=new le,s;this.sc.mouse_mode==R.SPICE_MOUSE_MODE_CLIENT?(s=new ds(this.sc,t),e.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_POSITION,s)):(s=new ii(this.sc,t),e.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_MOTION,s)),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.waiting_for_ack<2*R.SPICE_INPUT_MOTION_ACK_BUNCH&&(this.sc.inputs.send_msg(e),this.sc.inputs.waiting_for_ack++),this.sc&&this.sc.cursor&&this.sc.cursor.spice_simulated_cursor&&(this.sc.cursor.spice_simulated_cursor.style.display="block",this.sc.cursor.spice_simulated_cursor.style.left=t.pageX-this.sc.cursor.spice_simulated_cursor.spice_hot_x+"px",this.sc.cursor.spice_simulated_cursor.style.top=t.pageY-this.sc.cursor.spice_simulated_cursor.spice_hot_y+"px",t.preventDefault())}function qn(t){var e=new Rt(this.sc,t),s=new le;s.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_PRESS,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function Xn(t){return t.preventDefault(),!1}function Qn(t){var e=new _s(this.sc,t),s=new le;s.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_RELEASE,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function Jn(t){var e=new Rt,s=new _s;t.deltaY<0?e.button=s.button=R.SPICE_MOUSE_BUTTON_UP:e.button=s.button=R.SPICE_MOUSE_BUTTON_DOWN,e.buttons_state=0,s.buttons_state=0;var c=new le;c.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_PRESS,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(c),c.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_RELEASE,s),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(c),t.preventDefault(),window.dispatchEvent(new CustomEvent("spice-wheel",{detail:{wheelEvent:t}}))}function Zn(t){var e=new _t(t),s=new le;to(t,e.code,this.sc),s.build_msg(R.SPICE_MSGC_INPUTS_KEY_DOWN,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function eo(t){var e=new fs(t),s=new le;to(t,e.code,this.sc),s.build_msg(R.SPICE_MSGC_INPUTS_KEY_UP,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function di(t,e){var s=new le,c=new _t;c.code=e,s.build_msg(R.SPICE_MSGC_INPUTS_KEY_DOWN,c),t.inputs.send_msg(s),c.code=128|e,s.build_msg(R.SPICE_MSGC_INPUTS_KEY_UP,c),t.inputs.send_msg(s)}function fl(t){t&&t.inputs&&t.inputs.state==="ready"&&(ke(!0,K.KEY_LCtrl,t),ke(!0,K.KEY_Alt,t),di(t,K.KEY_KP_Decimal),setTimeout(()=>{ke(!1,K.KEY_LCtrl,t),ke(!1,K.KEY_Alt,t)},100))}function pl(t){t&&t.inputs&&t.inputs.state==="ready"&&(ke(!0,K.KEY_Alt,t),di(t,K.KEY_F4),setTimeout(()=>{ke(!1,K.KEY_Alt,t)},100))}function ml(t){t&&t.inputs&&t.inputs.state==="ready"&&(ke(!0,K.KEY_Alt,t),di(t,K.KEY_Tab),setTimeout(()=>{ke(!1,K.KEY_Alt,t)},100))}function ke(t,e,s){var c=new le;if(t){var v=new _t;v.code=e,c.build_msg(R.SPICE_MSGC_INPUTS_KEY_DOWN,v)}else{var v=new fs;v.code=128|e,c.build_msg(R.SPICE_MSGC_INPUTS_KEY_UP,v)}s.inputs.send_msg(c)}function to(t,e,s){nt===-1&&(nt=t.shiftKey,bt=t.ctrlKey,Ct=t.altKey,Et=t.metaKey),e===K.KEY_ShiftL?nt=!0:e===K.KEY_Alt?Ct=!0:e===K.KEY_LCtrl?bt=!0:e===57525?Et=!0:e===(128|K.KEY_ShiftL)?nt=!1:e===(128|K.KEY_Alt)?Ct=!1:e===(128|K.KEY_LCtrl)?bt=!1:e===57525&&(Et=!1),s&&s.inputs&&s.inputs.state==="ready"&&(nt!=t.shiftKey&&(console.log("Shift state out of sync"),ke(t.shiftKey,K.KEY_ShiftL,s),nt=t.shiftKey),Ct!=t.altKey&&(console.log("Alt state out of sync"),ke(t.altKey,K.KEY_Alt,s),Ct=t.altKey),bt!=t.ctrlKey&&(console.log("Ctrl state out of sync"),ke(t.ctrlKey,K.KEY_LCtrl,s),bt=t.ctrlKey),Et!=t.metaKey&&(console.log("Meta state out of sync"),ke(t.metaKey,57525,s),Et=t.metaKey))}function Ms(t,e,s,c,v){var I=e,y=0,n,a=0;for(n=t[I++];y*4<s.length;n=t[I++]){var u=y,_=n>>5,l=(n&31)<<8;if(n>=32){var f;if(_--,_==6)do f=t[I++],_+=f;while(f==255);if(f=t[I++],l+=f,f==255&&l-f==7936&&(l=t[I++]<<8,l+=t[I++],l+=8191),_+=1,c==R.LZ_IMAGE_TYPE_RGBA&&(_+=2),l+=1,u-=l,u==y-1)for(var g=u;_;--_){if(c==R.LZ_IMAGE_TYPE_RGBA)s[y*4+3]=s[g*4+3];else for(a=0;a<4;a++)s[y*4+a]=s[g*4+a];y++}else for(;_;--_){if(c==R.LZ_IMAGE_TYPE_RGBA)s[y*4+3]=s[u*4+3];else for(a=0;a<4;a++)s[y*4+a]=s[u*4+a];y++,u++}}else for(n++,c==R.LZ_IMAGE_TYPE_RGBA?s[y*4+3]=t[I++]:(s[y*4+0]=t[I+2],s[y*4+1]=t[I+1],s[y*4+2]=t[I+0],v&&(s[y*4+3]=255),I+=3),y++,--n;n;n--)c==R.LZ_IMAGE_TYPE_RGBA?s[y*4+3]=t[I++]:(s[y*4+0]=t[I+2],s[y*4+1]=t[I+1],s[y*4+2]=t[I+0],v&&(s[y*4+3]=255),I+=3),y++}return I-1}function gl(t){for(var e=t.width*4,s=t.height,c=s,v=new Uint8Array(t.width*t.height*4);c--;)v.set(t.data.subarray(c*e,(c+1)*e),(s-c-1)*e);t.data.set(v)}function Qi(t,e){var s;if(e.type===R.LZ_IMAGE_TYPE_RGB32||e.type===R.LZ_IMAGE_TYPE_RGBA){var c=new Uint8Array(e.data),v=t.createImageData(e.width,e.height);s=Ms(c,0,v.data,R.LZ_IMAGE_TYPE_RGB32,e.type!=R.LZ_IMAGE_TYPE_RGBA),e.top_down||gl(v),e.type==R.LZ_IMAGE_TYPE_RGBA&&Ms(c,s,v.data,R.LZ_IMAGE_TYPE_RGBA,!1)}else if(e.type===R.LZ_IMAGE_TYPE_XXXA){var c=new Uint8Array(e.data),v=t.createImageData(e.width,e.height);Ms(c,0,v.data,R.LZ_IMAGE_TYPE_RGBA,!1)}else return;return v}function vl(t,e){var s,c,v,I=0,y=0,n=new Uint8Array(e.data);if(!(e.format!=R.SPICE_BITMAP_FMT_32BIT&&e.format!=R.SPICE_BITMAP_FMT_RGBA)){for(e.flags&R.SPICE_BITMAP_FLAGS_TOP_DOWN||(I=(e.y-1)*e.stride,y=2*e.stride),s=t.createImageData(e.x,e.y),c=0;c<e.y*e.stride;I-=y)for(v=0;v<e.x;v++,c+=4,I+=4)s.data[c+0]=n[I+2],s.data[c+1]=n[I+1],s.data[c+2]=n[I+0],e.format==R.SPICE_BITMAP_FMT_32BIT?s.data[c+3]=255:s.data[c+3]=n[I];return s}}function so(t,e,s,c){var v=document.createElement("canvas"),I=v.getContext("2d");v.setAttribute("width",e.width),v.setAttribute("height",e.height),I.putImageData(e,0,0),t.drawImage(v,s,c,e.width,e.height)}function Sl(t){var e;for(e=0;e<t.width*t.height*4;e+=4)t.data[e+3]=255}function ze(){we.apply(this,arguments)}ze.prototype=Object.create(we.prototype);ze.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_DISPLAY_MODE)return this.known_unimplemented(t.type,"Display Mode"),!0;if(t.type==R.SPICE_MSG_DISPLAY_MARK)return this.known_unimplemented(t.type,"Display Mark"),!0;if(t.type==R.SPICE_MSG_DISPLAY_RESET)return this.surfaces[this.primary_surface].canvas.context.restore(),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_COPY){var e=new hn(t.data);if(e.base.box.is_same_size(e.data.src_area)||this.log_warn("FIXME: DrawCopy src_area is a different size than base.box; we do not handle that yet."),e.base.clip.type!=R.SPICE_CLIP_TYPE_NONE&&this.log_warn("FIXME: DrawCopy we don't handle clipping yet"),e.data.rop_descriptor!=R.SPICE_ROPD_OP_PUT&&this.log_warn("FIXME: DrawCopy we don't handle ropd type: "+e.data.rop_descriptor),e.data.mask.flags&&this.log_warn("FIXME: DrawCopy we don't handle mask flag: "+e.data.mask.flags),e.data.mask.bitmap&&this.log_warn("FIXME: DrawCopy we don't handle mask"),e.data&&e.data.src_bitmap)if(e.data.src_bitmap.descriptor.flags&&e.data.src_bitmap.descriptor.flags!=R.SPICE_IMAGE_FLAGS_CACHE_ME&&e.data.src_bitmap.descriptor.flags!=R.SPICE_IMAGE_FLAGS_HIGH_BITS_SET&&(this.log_warn("FIXME: DrawCopy unhandled image flags: "+e.data.src_bitmap.descriptor.flags),this.log_draw("DrawCopy",e)),e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_QUIC){var s=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.quic)return this.log_warn("FIXME: DrawCopy could not handle this QUIC file."),!1;var c=Uh(s.context,e.data.src_bitmap.quic);return this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:c,tag:"copyquic."+e.data.src_bitmap.quic.type,has_alpha:e.data.src_bitmap.quic.type==Ce.QUIC_IMAGE_TYPE_RGBA,descriptor:e.data.src_bitmap.descriptor})}else{if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_FROM_CACHE||e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS)return!this.cache||!this.cache[e.data.src_bitmap.descriptor.id]?(this.log_warn("FIXME: DrawCopy did not find image id "+e.data.src_bitmap.descriptor.id+" in cache."),!1):this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:this.cache[e.data.src_bitmap.descriptor.id],tag:"copycache."+e.data.src_bitmap.descriptor.id,has_alpha:!0,descriptor:e.data.src_bitmap.descriptor});if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_SURFACE){var v=this.surfaces[e.data.src_bitmap.surface_id].canvas.context;this.surfaces[e.base.surface_id].canvas.context;var c=v.getImageData(e.data.src_area.left,e.data.src_area.top,e.data.src_area.right-e.data.src_area.left,e.data.src_area.bottom-e.data.src_area.top),I=new it;return I.top=I.left=0,I.right=c.width,I.bottom=c.height,this.draw_copy_helper({base:e.base,src_area:I,image_data:c,tag:"copysurf."+e.data.src_bitmap.surface_id,has_alpha:this.surfaces[e.data.src_bitmap.surface_id].format!=R.SPICE_SURFACE_FMT_32_xRGB,descriptor:e.data.src_bitmap.descriptor})}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG){if(!e.data.src_bitmap.jpeg)return this.log_warn("FIXME: DrawCopy could not handle this JPEG file."),!1;var y="data:image/jpeg,",n=new Image,a,u=new Uint8Array(e.data.src_bitmap.jpeg.data);for(a=0;a<u.length;a++)y+="%",u[a]<16&&(y+="0"),y+=u[a].toString(16);return n.o={base:e.base,tag:"jpeg."+e.data.src_bitmap.surface_id,descriptor:e.data.src_bitmap.descriptor,sc:this},n.onload=Hs,n.src=y,!0}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG_ALPHA){if(!e.data.src_bitmap.jpeg_alpha)return this.log_warn("FIXME: DrawCopy could not handle this JPEG ALPHA file."),!1;var y="data:image/jpeg,",n=new Image,a,u=new Uint8Array(e.data.src_bitmap.jpeg_alpha.data);for(a=0;a<u.length;a++)y+="%",u[a]<16&&(y+="0"),y+=u[a].toString(16);if(n.o={base:e.base,tag:"jpeg."+e.data.src_bitmap.surface_id,descriptor:e.data.src_bitmap.descriptor,sc:this},this.surfaces[e.base.surface_id].format==R.SPICE_SURFACE_FMT_32_ARGB){var s=this.surfaces[e.base.surface_id].canvas;n.alpha_img=Qi(s.context,e.data.src_bitmap.jpeg_alpha.alpha)}return n.onload=Hs,n.src=y,!0}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_BITMAP){var s=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.bitmap)return this.log_err("null bitmap"),!1;var c=vl(s.context,e.data.src_bitmap.bitmap);return c?this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:c,tag:"bitmap."+e.data.src_bitmap.bitmap.format,has_alpha:e.data.src_bitmap.bitmap!=R.SPICE_BITMAP_FMT_32BIT,descriptor:e.data.src_bitmap.descriptor}):(this.log_warn("FIXME: Unable to interpret bitmap of format: "+e.data.src_bitmap.bitmap.format),!1)}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_LZ_RGB){var s=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.lz_rgb)return this.log_err("null lz_rgb "),!1;var c=Qi(s.context,e.data.src_bitmap.lz_rgb);return c?this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:c,tag:"lz_rgb."+e.data.src_bitmap.lz_rgb.type,has_alpha:e.data.src_bitmap.lz_rgb.type==R.LZ_IMAGE_TYPE_RGBA,descriptor:e.data.src_bitmap.descriptor}):(this.log_warn("FIXME: Unable to interpret bitmap of type: "+e.data.src_bitmap.lz_rgb.type),!1)}else return this.log_warn("FIXME: DrawCopy unhandled image type: "+e.data.src_bitmap.descriptor.type),this.log_draw("DrawCopy",e),!1}return this.log_warn("FIXME: DrawCopy no src_bitmap."),!1}if(t.type==R.SPICE_MSG_DISPLAY_DRAW_FILL){var _=new ln(t.data);if(_.data.rop_descriptor!=R.SPICE_ROPD_OP_PUT&&this.log_warn("FIXME: DrawFill we don't handle ropd type: "+_.data.rop_descriptor),_.data.mask.flags&&this.log_warn("FIXME: DrawFill we don't handle mask flag: "+_.data.mask.flags),_.data.mask.bitmap&&this.log_warn("FIXME: DrawFill we don't handle mask"),_.data.brush.type==R.SPICE_BRUSH_TYPE_SOLID){var l=_.data.brush.color&16777215,f="rgb("+(l>>16)+", "+(l>>8&255)+", "+(l&255)+")";this.surfaces[_.base.surface_id].canvas.context.fillStyle=f,this.surfaces[_.base.surface_id].canvas.context.fillRect(_.base.box.left,_.base.box.top,_.base.box.right-_.base.box.left,_.base.box.bottom-_.base.box.top),this.surfaces[_.base.surface_id].draw_count++}else this.log_warn("FIXME: DrawFill can't handle brush type: "+_.data.brush.type);return!0}if(t.type==R.SPICE_MSG_DISPLAY_DRAW_OPAQUE)return this.known_unimplemented(t.type,"Display Draw Opaque"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_BLEND)return this.known_unimplemented(t.type,"Display Draw Blend"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_BLACKNESS)return this.known_unimplemented(t.type,"Display Draw Blackness"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_WHITENESS)return this.known_unimplemented(t.type,"Display Draw Whiteness"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_INVERS)return this.known_unimplemented(t.type,"Display Draw Invers"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_ROP3)return this.known_unimplemented(t.type,"Display Draw ROP3"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_STROKE)return this.known_unimplemented(t.type,"Display Draw Stroke"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_TRANSPARENT)return this.known_unimplemented(t.type,"Display Draw Transparent"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND)return this.known_unimplemented(t.type,"Display Draw Alpha Blend"),!0;if(t.type==R.SPICE_MSG_DISPLAY_COPY_BITS){var g=new un(t.data),b=this.surfaces[g.base.surface_id].canvas,v=b.context,d=b.width-g.src_pos.x,o=b.height-g.src_pos.y;d>g.base.box.right-g.base.box.left&&(d=g.base.box.right-g.base.box.left),o>g.base.box.bottom-g.base.box.top&&(o=g.base.box.bottom-g.base.box.top);var c=v.getImageData(g.src_pos.x,g.src_pos.y,d,o);return so(v,c,g.base.box.left,g.base.box.top),this.surfaces[g.base.surface_id].draw_count++,!0}if(t.type==R.SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS)return this.known_unimplemented(t.type,"Display Inval All Pixmaps"),!0;if(t.type==R.SPICE_MSG_DISPLAY_INVAL_PALETTE)return this.known_unimplemented(t.type,"Display Inval Palette"),!0;if(t.type==R.SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES)return this.known_unimplemented(t.type,"Inval All Palettes"),!0;if(t.type==R.SPICE_MSG_DISPLAY_SURFACE_CREATE){"surfaces"in this||(this.surfaces=[]);var r=new dn(t.data);if(r.surface.format!=R.SPICE_SURFACE_FMT_32_xRGB&&r.surface.format!=R.SPICE_SURFACE_FMT_32_ARGB)return this.log_warn("FIXME: cannot handle surface format "+r.surface.format+" yet."),!1;var s=document.createElement("canvas");return s.setAttribute("width",r.surface.width),s.setAttribute("height",r.surface.height),s.setAttribute("id","spice_surface_"+r.surface.surface_id),s.setAttribute("tabindex",r.surface.surface_id),s.context=s.getContext("2d"),r.surface.canvas=s,r.surface.draw_count=0,this.surfaces[r.surface.surface_id]=r.surface,r.surface.flags&R.SPICE_SURFACE_FLAGS_PRIMARY&&(this.primary_surface=r.surface.surface_id,s.context.save(),document.getElementById(this.parent.screen_id).appendChild(s),document.getElementById(this.parent.screen_id).style.height=r.surface.height+"px",this.hook_events()),!0}if(t.type==R.SPICE_MSG_DISPLAY_SURFACE_DESTROY){var r=new _n(t.data);return this.delete_surface(r.surface_id),!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_CREATE){var r=new En(t.data);if(this.streams||(this.streams=new Array),this.streams[r.id]?console.log("Stream "+r.id+" already exists"):this.streams[r.id]=r,r.codec_type==R.SPICE_VIDEO_CODEC_TYPE_VP8){var i=new MediaSource,h=document.createElement("video");h.src=window.URL.createObjectURL(i),h.setAttribute("muted",!0),h.setAttribute("autoplay",!0),h.setAttribute("width",r.stream_width),h.setAttribute("height",r.stream_height);var p=r.dest.left,E=r.dest.top;this.surfaces[r.surface_id]!==void 0&&(p+=this.surfaces[r.surface_id].canvas.offsetLeft,E+=this.surfaces[r.surface_id].canvas.offsetTop),document.getElementById(this.parent.screen_id).appendChild(h),h.setAttribute("style","pointer-events:none; position: absolute; top:"+E+"px; left:"+p+"px;"),i.addEventListener("sourceopen",Cl,!1),i.addEventListener("sourceended",El,!1),i.addEventListener("sourceclosed",yl,!1);var C=this.streams[r.id];C.video=h,C.media=i,C.queue=new Array,C.start_time=0,C.cluster_time=0,C.append_okay=!1,i.stream=C,i.spiceconn=this,h.spice_stream=C}else r.codec_type==R.SPICE_VIDEO_CODEC_TYPE_MJPEG?this.streams[r.id].frames_loading=0:console.log("Unhandled stream codec: "+r.codec_type);return!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DATA||t.type==R.SPICE_MSG_DISPLAY_STREAM_DATA_SIZED){var r;if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DATA_SIZED?r=new wn(t.data):r=new yn(t.data),!this.streams[r.base.id])return console.log("no stream for data"),!1;var w=r.base.multi_media_time-this.parent.relative_now();return this.streams[r.base.id].codec_type===R.SPICE_VIDEO_CODEC_TYPE_MJPEG&&bl(this,r,w),this.streams[r.base.id].codec_type===R.SPICE_VIDEO_CODEC_TYPE_VP8&&Il(this.streams[r.base.id],r),!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT){var r=new An(t.data),S=new Pn(r.stream_id,r.unique_id);return this.streams[r.stream_id]&&(this.streams[r.stream_id].report=S,this.streams[r.stream_id].max_window_size=r.max_window_size,this.streams[r.stream_id].timeout_ms=r.timeout_ms),!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_CLIP){var r=new xn(t.data);return this.streams[r.id].clip=r.clip,!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DESTROY){var r=new In(t.data);return this.streams[r.id].codec_type==R.SPICE_VIDEO_CODEC_TYPE_VP8&&(document.getElementById(this.parent.screen_id).removeChild(this.streams[r.id].video),this.streams[r.id].source_buffer=null,this.streams[r.id].media=null,this.streams[r.id].video=null),this.streams[r.id]=void 0,!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL)return this.known_unimplemented(t.type,"Display Stream Destroy All"),!0;if(t.type==R.SPICE_MSG_DISPLAY_INVAL_LIST){var r=new Dn(t.data),a;for(a=0;a<r.count;a++)this.cache[r.resources[a].id]!=null&&delete this.cache[r.resources[a].id];return!0}return t.type==R.SPICE_MSG_DISPLAY_MONITORS_CONFIG?(this.known_unimplemented(t.type,"Display Monitors Config"),!0):t.type==R.SPICE_MSG_DISPLAY_DRAW_COMPOSITE?(this.known_unimplemented(t.type,"Display Draw Composite"),!0):!1};ze.prototype.delete_surface=function(t){var s;var e=document.getElementById("spice_surface_"+t);this.primary_surface==t&&(this.unhook_events(),this.primary_surface=void 0,(s=document.getElementById(this.parent.screen_id))==null||s.removeChild(e)),delete this.surfaces[t]};ze.prototype.draw_copy_helper=function(t){var e=this.surfaces[t.base.surface_id].canvas;return t.has_alpha?this.surfaces[t.base.surface_id].format==R.SPICE_SURFACE_FMT_32_xRGB?(Sl(t.image_data),e.context.putImageData(t.image_data,t.base.box.left,t.base.box.top)):so(e.context,t.image_data,t.base.box.left,t.base.box.top):e.context.putImageData(t.image_data,t.base.box.left,t.base.box.top),(t.src_area.left>0||t.src_area.top>0)&&this.log_warn("FIXME: DrawCopy not shifting draw copies just yet..."),t.descriptor&&t.descriptor.flags&R.SPICE_IMAGE_FLAGS_CACHE_ME&&("cache"in this||(this.cache={}),this.cache[t.descriptor.id]=t.image_data),this.surfaces[t.base.surface_id].draw_count++,!0};ze.prototype.log_draw=function(t,e){var s=t+"."+e.base.surface_id+"."+this.surfaces[e.base.surface_id].draw_count+": ";s+="base.box "+e.base.box.left+", "+e.base.box.top+" to "+e.base.box.right+", "+e.base.box.bottom,s+="; clip.type "+e.base.clip.type,e.data&&(e.data.src_area&&(s+="; src_area "+e.data.src_area.left+", "+e.data.src_area.top+" to "+e.data.src_area.right+", "+e.data.src_area.bottom),e.data.src_bitmap&&e.data.src_bitmap!=null?(s+="; src_bitmap id: "+e.data.src_bitmap.descriptor.id,s+="; src_bitmap width "+e.data.src_bitmap.descriptor.width+", height "+e.data.src_bitmap.descriptor.height,s+="; src_bitmap type "+e.data.src_bitmap.descriptor.type+", flags "+e.data.src_bitmap.descriptor.flags,e.data.src_bitmap.surface_id!==void 0&&(s+="; src_bitmap surface_id "+e.data.src_bitmap.surface_id),e.data.src_bitmap.bitmap&&(s+="; BITMAP format "+e.data.src_bitmap.bitmap.format+"; flags "+e.data.src_bitmap.bitmap.flags+"; x "+e.data.src_bitmap.bitmap.x+"; y "+e.data.src_bitmap.bitmap.y+"; stride "+e.data.src_bitmap.bitmap.stride),e.data.src_bitmap.quic&&(s+="; QUIC type "+e.data.src_bitmap.quic.type+"; width "+e.data.src_bitmap.quic.width+"; height "+e.data.src_bitmap.quic.height),e.data.src_bitmap.lz_rgb&&(s+="; LZ_RGB length "+e.data.src_bitmap.lz_rgb.length+"; magic "+e.data.src_bitmap.lz_rgb.magic+"; version 0x"+e.data.src_bitmap.lz_rgb.version.toString(16)+"; type "+e.data.src_bitmap.lz_rgb.type+"; width "+e.data.src_bitmap.lz_rgb.width+"; height "+e.data.src_bitmap.lz_rgb.height+"; stride "+e.data.src_bitmap.lz_rgb.stride+"; top down "+e.data.src_bitmap.lz_rgb.top_down)):s+="; src_bitmap is null",e.data.brush&&(e.data.brush.type==R.SPICE_BRUSH_TYPE_SOLID&&(s+="; brush.color 0x"+e.data.brush.color.toString(16)),e.data.brush.type==R.SPICE_BRUSH_TYPE_PATTERN&&(s+="; brush.pat ",e.data.brush.pattern.pat!=null?s+="[SpiceImage]":s+="[null]",s+=" at "+e.data.brush.pattern.pos.x+", "+e.data.brush.pattern.pos.y)),s+="; rop_descriptor "+e.data.rop_descriptor,e.data.scale_mode!==void 0&&(s+="; scale_mode "+e.data.scale_mode),s+="; mask.flags "+e.data.mask.flags,s+="; mask.pos "+e.data.mask.pos.x+", "+e.data.mask.pos.y,e.data.mask.bitmap!=null?(s+="; mask.bitmap width "+e.data.mask.bitmap.descriptor.width+", height "+e.data.mask.bitmap.descriptor.height,s+="; mask.bitmap type "+e.data.mask.bitmap.descriptor.type+", flags "+e.data.mask.bitmap.descriptor.flags):s+="; mask.bitmap is null"),console.log(s)};ze.prototype.hook_events=function(){if(this.primary_surface!==void 0){var t=this.surfaces[this.primary_surface].canvas;t.sc=this.parent,t.addEventListener("mousemove",Vn),t.addEventListener("mousedown",qn),t.addEventListener("contextmenu",Xn),t.addEventListener("mouseup",Qn),t.addEventListener("keydown",Zn),t.addEventListener("keyup",eo),t.addEventListener("mouseout",ro),t.addEventListener("mouseover",io),t.addEventListener("wheel",Jn),t.focus()}};ze.prototype.unhook_events=function(){if(this.primary_surface!==void 0){var t=this.surfaces[this.primary_surface].canvas;t.removeEventListener("mousemove",Vn),t.removeEventListener("mousedown",qn),t.removeEventListener("contextmenu",Xn),t.removeEventListener("mouseup",Qn),t.removeEventListener("keydown",Zn),t.removeEventListener("keyup",eo),t.removeEventListener("mouseout",ro),t.removeEventListener("mouseover",io),t.removeEventListener("wheel",Jn)}};ze.prototype.destroy_surfaces=function(){for(var t in this.surfaces)this.delete_surface(this.surfaces[t].surface_id);this.surfaces=void 0};function io(t){this.focus()}function ro(t){this.sc&&this.sc.cursor&&this.sc.cursor.spice_simulated_cursor&&(this.sc.cursor.spice_simulated_cursor.style.display="none"),this.blur()}function Hs(){var t=null,e;if("streams"in this.o.sc&&this.o.sc.streams[this.o.id]&&this.o.sc.streams[this.o.id].frames_loading--,this.o.sc.surfaces[this.o.base.surface_id]===void 0?(t=document.createElement("canvas"),t.setAttribute("width",this.o.base.box.right),t.setAttribute("height",this.o.base.box.bottom),e=t.getContext("2d")):e=this.o.sc.surfaces[this.o.base.surface_id].canvas.context,this.alpha_img){var s=document.createElement("canvas"),c=s.getContext("2d");s.setAttribute("width",this.alpha_img.width),s.setAttribute("height",this.alpha_img.height),c.putImageData(this.alpha_img,0,0),c.globalCompositeOperation="source-in",c.drawImage(this,0,0),e.drawImage(s,this.o.base.box.left,this.o.base.box.top),this.o.descriptor&&this.o.descriptor.flags&R.SPICE_IMAGE_FLAGS_CACHE_ME&&("cache"in this.o.sc||(this.o.sc.cache={}),this.o.sc.cache[this.o.descriptor.id]=c.getImageData(0,0,this.alpha_img.width,this.alpha_img.height))}else e.drawImage(this,this.o.base.box.left,this.o.base.box.top),this.onload=void 0,this.src=Fh,this.o.descriptor&&this.o.descriptor.flags&R.SPICE_IMAGE_FLAGS_CACHE_ME&&("cache"in this.o.sc||(this.o.sc.cache={}),this.o.sc.cache[this.o.descriptor.id]=e.getImageData(this.o.base.box.left,this.o.base.box.top,this.o.base.box.right-this.o.base.box.left,this.o.base.box.bottom-this.o.base.box.top));t==null&&this.o.sc.surfaces[this.o.base.surface_id].draw_count++,this.o.sc.streams[this.o.id]&&"report"in this.o.sc.streams[this.o.id]&&no(this.o.sc,this.o.id,this.o.msg_mmtime,this.o.msg_mmtime-this.o.sc.parent.relative_now())}function bl(t,e,s){if(s<0&&t.streams[e.base.id].frames_loading>0){"report"in t.streams[e.base.id]&&t.streams[e.base.id].report.num_drops++;return}var c="data:image/jpeg,",v=new Image,I;for(I=0;I<e.data.length;I++)c+="%",e.data[I]<16&&(c+="0"),c+=e.data[I].toString(16);var y=new Mt;y.surface_id=t.streams[e.base.id].surface_id,y.box=e.dest||t.streams[e.base.id].dest,y.clip=t.streams[e.base.id].clip,v.o={base:y,tag:"mjpeg."+e.base.id,descriptor:null,sc:t,id:e.base.id,msg_mmtime:e.base.multi_media_time},v.onload=Hs,v.src=c,t.streams[e.base.id].frames_loading++}function no(t,e,s,c){if(t.streams[e].report.num_frames++,t.streams[e].report.start_frame_mm_time==0&&(t.streams[e].report.start_frame_mm_time=s),t.streams[e].report.num_frames>t.streams[e].max_window_size||s-t.streams[e].report.start_frame_mm_time>t.streams[e].timeout_ms){t.streams[e].report.end_frame_mm_time=s,t.streams[e].report.last_frame_delay=c;var v=new le;v.build_msg(R.SPICE_MSGC_DISPLAY_STREAM_REPORT,t.streams[e].report),t.send_msg(v),t.streams[e].report.start_frame_mm_time=0,t.streams[e].report.num_frames=0,t.streams[e].report.num_drops=0}}function Cl(t){var e=this.stream,s=this.spiceconn;if(!e.source_buffer){var c=this.addSourceBuffer(_e.SPICE_VP8_CODEC);if(!c){s.log_err("Codec "+_e.SPICE_VP8_CODEC+" not available.");return}e.source_buffer=c,c.spiceconn=s,c.stream=e,Dl(e);var v=new li,I=new $n(this.stream.stream_width,this.stream.stream_height),y=new ai(I),n=new ArrayBuffer(v.buffer_size()+y.buffer_size()),a=v.to_buffer(n);y.to_buffer(n,a),c.addEventListener("error",xl,!1),c.addEventListener("updateend",wl,!1),_i(c,n)}}function El(t){var e=this.spiceconn;e.log_err("Video source unexpectedly ended.")}function yl(t){var e=this.spiceconn;e.log_err("Video source unexpectedly closed.")}function _i(t,e){try{t.stream.append_okay=!1,t.appendBuffer(e)}catch(c){var s=t.spiceconn;s.log_err("Error invoking appendBuffer: "+c.message)}}function wl(t){var e=this.stream;if(e.current_frame&&"report"in e){var s=this.stream.media.spiceconn,c=this.stream.current_frame.msg_mmtime;no(s,e.id,c,c-s.parent.relative_now())}if(e.queue.length>0?(e.current_frame=e.queue.shift(),_i(e.source_buffer,e.current_frame.mb)):e.append_okay=!0,!!e.video&&(e.video.buffered.length>0&&e.video.currentTime<e.video.buffered.start(e.video.buffered.length-1)&&(console.log("Video appears to have fallen behind; advancing to "+e.video.buffered.start(e.video.buffered.length-1)),e.video.currentTime=e.video.buffered.start(e.video.buffered.length-1)),this.stream.video.paused&&this.stream.video.readyState>=2))var v=this.stream.video.play()}function xl(t){var e=this.spiceconn;e.log_err("source_buffer error "+t.message)}function oo(t,e,s){var c={msg_mmtime:e.base.multi_media_time};t.append_okay?(t.current_frame=c,_i(t.source_buffer,s)):(c.mb=s,t.queue.push(c))}function ao(t,e,s){var c=new hi(e.base.multi_media_time-t.cluster_time,e.data,s),v=new ArrayBuffer(c.buffer_size());c.to_buffer(v),oo(t,e,v)}function Ji(t,e){t.cluster_time=e.base.multi_media_time;var s=new ci(t.cluster_time-t.start_time,e.data),c=new ArrayBuffer(s.buffer_size());s.to_buffer(c),oo(t,e,c),ao(t,e,!0)}function Il(t,e){t.start_time==0?(t.start_time=e.base.multi_media_time,Ji(t,e)):e.base.multi_media_time-t.cluster_time>=_e.MAX_CLUSTER_TIME?Ji(t,e):ao(t,e,!1)}function Al(t){var e=this.spice_stream;e.video&&e.video.buffered.len>1&&console.log(e.video.currentTime+":id "+e.id+" event "+t.type+Yr(e.video)),e.queue.length>1&&console.log(" queue len "+e.queue.length+"; append_okay: "+e.append_okay)}function Pl(t){this.addEventListener(t,Al)}function Dl(t){var e=["abort","error"];e.forEach(Pl,t.video)}function ft(){we.apply(this,arguments),this.queue=new Array,this.append_okay=!1,this.start_time=0}ft.prototype=Object.create(we.prototype);ft.prototype.process_channel_message=function(t){if(!window.MediaSource)return this.log_err("MediaSource API is not available"),!1;if(t.type==R.SPICE_MSG_PLAYBACK_START){var e=new Sn(t.data);if(e.frequency!=_e.OPUS_FREQUENCY)return this.log_err("This player cannot handle frequency "+e.frequency),!1;if(e.channels!=_e.OPUS_CHANNELS)return this.log_err("This player cannot handle "+e.channels+" channels"),!1;if(e.format!=R.SPICE_AUDIO_FMT_S16)return this.log_err("This player cannot format "+e.format),!1;if(!this.source_buffer)return this.media_source=new MediaSource,this.media_source.spiceconn=this,this.audio=document.createElement("audio"),this.audio.spiceconn=this,this.audio.setAttribute("autoplay",!0),this.audio.src=window.URL.createObjectURL(this.media_source),document.getElementById(this.parent.screen_id).appendChild(this.audio),this.media_source.addEventListener("sourceopen",Ll,!1),this.media_source.addEventListener("sourceended",Ml,!1),this.media_source.addEventListener("sourceclosed",Rl,!1),this.bytes_written=0,!0}if(t.type==R.SPICE_MSG_PLAYBACK_DATA){var s=new gn(t.data);return this.source_buffer&&(this.audio.readyState>=3&&this.audio.buffered.length>1&&this.audio.currentTime==this.audio.buffered.end(0)&&this.audio.currentTime<this.audio.buffered.start(this.audio.buffered.length-1)&&(console.log("Audio underrun: we appear to have fallen behind; advancing to "+this.audio.buffered.start(this.audio.buffered.length-1)),this.audio.currentTime=this.audio.buffered.start(this.audio.buffered.length-1)),this.start_time!=0&&s.time!=this.last_data_time+_e.EXPECTED_PACKET_DURATION&&Math.abs(s.time-(_e.EXPECTED_PACKET_DURATION+this.last_data_time))<_e.MAX_CLUSTER_TIME&&(s.time=this.last_data_time+_e.EXPECTED_PACKET_DURATION),this.last_data_time=s.time,this.start_time==0?this.start_playback(s):s.time-this.cluster_time>=_e.MAX_CLUSTER_TIME?this.new_cluster(s):this.simple_block(s,!1)),!0}if(t.type==R.SPICE_MSG_PLAYBACK_MODE){var c=new vn(t.data);return c.mode!=R.SPICE_AUDIO_DATA_MODE_OPUS&&(this.log_err("This player cannot handle mode "+c.mode),delete this.source_buffer),!0}return t.type==R.SPICE_MSG_PLAYBACK_STOP&&this.source_buffer?(document.getElementById(this.parent.screen_id).removeChild(this.audio),window.URL.revokeObjectURL(this.audio.src),delete this.source_buffer,delete this.media_source,delete this.audio,this.append_okay=!1,this.queue=new Array,this.start_time=0,!0):t.type==R.SPICE_MSG_PLAYBACK_VOLUME?(this.known_unimplemented(t.type,"Playback Volume"),!0):t.type==R.SPICE_MSG_PLAYBACK_MUTE?(this.known_unimplemented(t.type,"Playback Mute"),!0):t.type==R.SPICE_MSG_PLAYBACK_LATENCY?(this.known_unimplemented(t.type,"Playback Latency"),!0):!1};ft.prototype.start_playback=function(t){this.start_time=t.time;var e=new li,s=new Wn,c=new ai(s),v=new ArrayBuffer(e.buffer_size()+c.buffer_size());this.bytes_written=e.to_buffer(v),this.bytes_written=c.to_buffer(v,this.bytes_written),this.source_buffer.addEventListener("error",Bl,!1),this.source_buffer.addEventListener("updateend",kl,!1),gs(this,v),this.new_cluster(t)};ft.prototype.new_cluster=function(t){this.cluster_time=t.time;var e=new ci(t.time-this.start_time),s=new ArrayBuffer(e.buffer_size());this.bytes_written+=e.to_buffer(s),this.append_okay?gs(this,s):this.queue.push(s),this.simple_block(t,!0)};ft.prototype.simple_block=function(t,e){var s=new hi(t.time-this.cluster_time,t.data,e),c=new ArrayBuffer(s.buffer_size());this.bytes_written+=s.to_buffer(c),this.append_okay?gs(this,c):this.queue.push(c)};function Ll(t){var e=this.spiceconn;if(!e.source_buffer){if(e.source_buffer=this.addSourceBuffer(_e.SPICE_PLAYBACK_CODEC),!e.source_buffer){e.log_err("Codec "+_e.SPICE_PLAYBACK_CODEC+" not available.");return}Ul(e),e.source_buffer.spiceconn=e,e.source_buffer.mode="segments"}}function Ml(t){var e=this.spiceconn;e.log_err("Audio source unexpectedly ended.")}function Rl(t){var e=this.spiceconn;e.log_err("Audio source unexpectedly closed.")}function Tl(t){if(t.length==1)return t.shift();var e=0,s=0;for(s=0;s<t.length;s++)e+=t[s].byteLength;var c=new ArrayBuffer(e),v=new Uint8Array(c);for(e=0,s=0;s<t.length;s++)v.set(new Uint8Array(t[s]),e),e+=t[s].byteLength;return t.length=0,c}function kl(t){var e=this.spiceconn;if(e.queue.length>0){var s=Tl(e.queue);gs(e,s)}else e.append_okay=!0}function Bl(t){var e=this.spiceconn;e.log_err("source_buffer error "+t.message)}function gs(t,e){try{t.source_buffer.appendBuffer(e),t.append_okay=!1}catch(s){t.log_err("Error invoking appendBuffer: "+s.message)}}function Ol(t){var e=this.spiceconn;e.audio&&e.audio.buffered.len>1&&console.log(e.audio.currentTime+": event "+t.type+Yr(e.audio)),e.queue.length>1&&console.log(" queue len "+e.queue.length+"; append_okay: "+e.append_okay)}function Nl(t){this.addEventListener(t,Ol)}function Ul(t){var e=["abort","error"];e.forEach(Nl,t.audio)}function fi(){we.apply(this,arguments),this.port_name=null}fi.prototype=Object.create(we.prototype);fi.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_PORT_INIT){if(this.port_name===null){var e=new Ln(t.data);return this.portName=Hh(new Uint8Array(e.name)),this.portOpened=e.opened,!0}}else if(t.type==R.SPICE_MSG_PORT_EVENT){var s=new CustomEvent("spice-port-event",{detail:{channel:this,spiceEvent:new Uint8Array(t.data)},bubbles:!0,cancelable:!0});return window.dispatchEvent(s),!0}else if(t.type==R.SPICE_MSG_SPICEVMC_DATA){var s=new CustomEvent("spice-port-data",{detail:{channel:this,data:t.data},bubbles:!0,cancelable:!0});return window.dispatchEvent(s),!0}return!1};function jl(t){if(t){var e=document.getElementById(t.screen_id).clientWidth,s=document.getElementById("spice-area"),c=document.isFullScreen||document.fullscreenElement||document.webkitIsFullScreen||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement,v=window.innerHeight-s.getBoundingClientRect().top;c||(v=v-65),v<200&&(v=200),v%8>0&&(v-=v%8),e%8>0&&(e-=e%8),t.resize_window(0,e,v,32,0,0),t.spice_resize_timer=void 0}}function Fl(t){var e=window.spice_connection;e&&(e.spice_resize_timer&&(window.clearTimeout(e.spice_resize_timer),e.spice_resize_timer=void 0),e.spice_resize_timer=window.setTimeout(jl,200,e))}function xe(){if(typeof WebSocket>"u")throw new Error("WebSocket unavailable. You need to use a different browser.");we.apply(this,arguments),this.agent_msg_queue=[],this.file_xfer_tasks={},this.file_xfer_task_id=0,this.file_xfer_read_queue=[],this.ports=[]}xe.prototype=Object.create(we.prototype);xe.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_MAIN_MIGRATE_BEGIN)return this.known_unimplemented(t.type,"Main Migrate Begin"),!0;if(t.type==R.SPICE_MSG_MAIN_MIGRATE_CANCEL)return this.known_unimplemented(t.type,"Main Migrate Cancel"),!0;if(t.type==R.SPICE_MSG_MAIN_INIT){this.log_info("Connected to "+this.ws.url),this.report_success("Connected"),this.main_init=new qr(t.data),this.connection_id=this.main_init.session_id,this.agent_tokens=this.main_init.agent_tokens,this.our_mm_time=Date.now(),this.mm_time=this.main_init.multi_media_time,this.handle_mouse_mode(this.main_init.current_mouse_mode,this.main_init.supported_mouse_modes),this.main_init.agent_connected&&this.connect_agent();var e=new le;return e.type=R.SPICE_MSGC_MAIN_ATTACH_CHANNELS,e.size=e.buffer_size(),this.send_msg(e),!0}if(t.type==R.SPICE_MSG_MAIN_MOUSE_MODE){var s=new Xr(t.data);return this.handle_mouse_mode(s.current_mode,s.supported_modes),!0}if(t.type==R.SPICE_MSG_MAIN_MULTI_MEDIA_TIME)return this.known_unimplemented(t.type,"Main Multi Media Time"),!0;if(t.type==R.SPICE_MSG_MAIN_CHANNELS_LIST){var c,v;for(v=new Vr(t.data),c=0;c<v.channels.length;c++){var I={uri:this.ws.url,parent:this,connection_id:this.connection_id,type:v.channels[c].type,chan_id:v.channels[c].id};v.channels[c].type==R.SPICE_CHANNEL_DISPLAY?v.channels[c].id==0?this.display=new ze(I):this.log_warn("The spice-html5 client does not handle multiple heads."):v.channels[c].type==R.SPICE_CHANNEL_INPUTS?(this.inputs=new ui(I),this.inputs.mouse_mode=this.mouse_mode):v.channels[c].type==R.SPICE_CHANNEL_CURSOR?this.cursor=new ps(I):v.channels[c].type==R.SPICE_CHANNEL_PLAYBACK?this.cursor=new ft(I):v.channels[c].type==R.SPICE_CHANNEL_PORT?this.ports.push(new fi(I)):("extra_channels"in this||(this.extra_channels=[]),this.extra_channels[c]=new we(I),this.log_err("Channel type "+this.extra_channels[c].channel_type()+" not implemented"))}return!0}if(t.type==R.SPICE_MSG_MAIN_AGENT_CONNECTED)return this.connect_agent(),!0;if(t.type==R.SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS){var y=new Us(t.data);return this.agent_tokens=y.num_tokens,this.connect_agent(),!0}if(t.type==R.SPICE_MSG_MAIN_AGENT_TOKEN){var n,a=new Us(t.data);for(this.agent_tokens+=a.num_tokens,this.send_agent_message_queue(),n=this.agent_tokens;n>0&&this.file_xfer_read_queue.length>0;){var u=this.file_xfer_read_queue.shift();this.file_xfer_read(u,u.read_bytes),n--}return!0}if(t.type==R.SPICE_MSG_MAIN_AGENT_DISCONNECTED)return this.agent_connected=!1,!0;if(t.type==R.SPICE_MSG_MAIN_AGENT_DATA){var _=new Qr(t.data);if(_.type==R.VD_AGENT_ANNOUNCE_CAPABILITIES){var l=new ti(_.data);return l.request&&this.announce_agent_capabilities(0),!0}else if(_.type==R.VD_AGENT_FILE_XFER_STATUS)return this.handle_file_xfer_status(new si(_.data)),!0;return!1}return t.type==R.SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST?(this.known_unimplemented(t.type,"Main Migrate Switch Host"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_END?(this.known_unimplemented(t.type,"Main Migrate End"),!0):t.type==R.SPICE_MSG_MAIN_NAME?(this.known_unimplemented(t.type,"Main Name"),!0):t.type==R.SPICE_MSG_MAIN_UUID?(this.known_unimplemented(t.type,"Main UUID"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS?(this.known_unimplemented(t.type,"Main Migrate Begin Seamless"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK?(this.known_unimplemented(t.type,"Main Migrate Dst Seamless ACK"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK?(this.known_unimplemented(t.type,"Main Migrate Dst Seamless NACK"),!0):!1};xe.prototype.stop=function(t){if(this.state="closing",this.inputs&&(this.inputs.cleanup(),this.inputs=void 0),this.cursor&&(this.cursor.cleanup(),this.cursor=void 0),this.display&&(this.display.cleanup(),this.display.destroy_surfaces(),this.display=void 0),this.cleanup(),"extra_channels"in this)for(var e in this.extra_channels)this.extra_channels[e].cleanup();this.extra_channels=void 0};xe.prototype.send_agent_message_queue=function(t){if(this.agent_connected)for(t&&this.agent_msg_queue.push(t);this.agent_tokens>0&&this.agent_msg_queue.length>0;){var e=this.agent_msg_queue.shift();this.send_msg(e),this.agent_tokens--}};xe.prototype.send_agent_message=function(t,e){var s=new sn(t,e),c=0,v=R.VD_AGENT_MAX_DATA_SIZE-le.prototype.buffer_size(),I=new ArrayBuffer(s.buffer_size());for(s.to_buffer(I);c<s.buffer_size();){var y=Math.min(c+v,s.buffer_size()),n=new le;n.type=R.SPICE_MSGC_MAIN_AGENT_DATA,n.size=y-c,n.data=I.slice(c,y),this.send_agent_message_queue(n),c=y}};xe.prototype.announce_agent_capabilities=function(t){var e=new ti(t,1<<R.VD_AGENT_CAP_MOUSE_STATE|1<<R.VD_AGENT_CAP_MONITORS_CONFIG|1<<R.VD_AGENT_CAP_REPLY);this.send_agent_message(R.VD_AGENT_ANNOUNCE_CAPABILITIES,e)};xe.prototype.resize_window=function(t,e,s,c,v,I){var y=new rn(t,e,s,c,v,I);this.send_agent_message(R.VD_AGENT_MONITORS_CONFIG,y)};xe.prototype.file_xfer_start=function(t){var e,s,c;e=this.file_xfer_task_id++,c=new ms(e,t),c.create_progressbar(),this.file_xfer_tasks[e]=c,s=new nn(e,t.name,t.size),this.send_agent_message(R.VD_AGENT_FILE_XFER_START,s)};xe.prototype.handle_file_xfer_status=function(t){var e,s;if(this.file_xfer_tasks[t.id]){switch(s=this.file_xfer_tasks[t.id],t.result){case R.VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:this.file_xfer_read(s);return;case R.VD_AGENT_FILE_XFER_STATUS_CANCELLED:e="transfer is cancelled by spice agent";break;case R.VD_AGENT_FILE_XFER_STATUS_ERROR:e="some errors occurred in the spice agent";break;case R.VD_AGENT_FILE_XFER_STATUS_SUCCESS:break;default:e="unhandled status type: "+t.result;break}this.file_xfer_completed(s,e)}};xe.prototype.file_xfer_read=function(t,e){var s=32*R.VD_AGENT_MAX_DATA_SIZE,c=this,v,I,y,n;if(!(!t||!this.file_xfer_tasks[t.id]||e>0&&e==t.file.size)){if(t.cancelled){var a=new si(t.id,R.VD_AGENT_FILE_XFER_STATUS_CANCELLED);this.send_agent_message(R.VD_AGENT_FILE_XFER_STATUS,a),delete this.file_xfer_tasks[t.id];return}if(v=e||0,I=Math.min(v+s,t.file.size),!this.agent_tokens){t.read_bytes=v,this.file_xfer_read_queue.push(t);return}n=new FileReader,n.onload=function(u){var _=new on(t.id,u.target.result.byteLength,u.target.result);c.send_agent_message(R.VD_AGENT_FILE_XFER_DATA,_),c.file_xfer_read(t,I),t.update_progressbar(I)},y=t.file.slice(v,I),n.readAsArrayBuffer(y)}};xe.prototype.file_xfer_completed=function(t,e){e?this.log_err(e):this.log_info("transfer of '"+t.file.name+"' was successful"),t.remove_progressbar(),delete this.file_xfer_tasks[t.id]};xe.prototype.connect_agent=function(){this.agent_connected=!0;var t=new tn(-1),e=new le;e.build_msg(R.SPICE_MSGC_MAIN_AGENT_START,t),this.send_msg(e),this.announce_agent_capabilities(1),this.onagent!==void 0&&this.onagent(this)};xe.prototype.handle_mouse_mode=function(t,e){if(this.mouse_mode=t,t!=R.SPICE_MOUSE_MODE_CLIENT&&e&R.SPICE_MOUSE_MODE_CLIENT){var s=new en(R.SPICE_MOUSE_MODE_CLIENT),c=new le;c.build_msg(R.SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST,s),this.send_msg(c)}this.inputs&&(this.inputs.mouse_mode=t)};xe.prototype.relative_now=function(){var t=Date.now()-this.our_mm_time+this.mm_time;return t};const Hl=({instance:t,onMount:e,onFailure:s})=>{var b;const{name:c,project:v}=tt(),I=B.useNotify(),y=Z.useRef(null),[n,a]=Z.useState(!1),u=rs(t),_=d=>{s("Console error",d)},l=()=>{ht("spice-wrapper"),Fl()},f=async()=>{if(!c){s("Missing name",new Error);return}if(!v){s("Missing project",new Error);return}a(!0);const d=await Ko(c,v).catch(E=>{a(!1),u&&s("Connection failed",E)});if(!d)return;const o=d.operation.split("?")[0],r=location.protocol==="https:"?"wss":"ws",i=`${r}://${location.host}${o}/websocket?secret=${d.metadata.metadata.fds[0]}`,h=`${r}://${location.host}${o}/websocket?secret=${d.metadata.metadata.fds.control}`,p=new WebSocket(h);p.onerror=_,p.onclose=E=>{E.code!==1005&&s("Console error",E.reason,wt(E.code))},p.onmessage=E=>{console.log("control message",E)};try{window.spice_connection=new xe({uri:i,screen_id:"spice-screen",onerror:_,onsuccess:()=>{a(!1),l()},onagent:l})}catch(E){u&&s("Connection failed",E)}return p};return B.useListener(window,l,"resize",!0),Z.useEffect(l,[(b=I.notification)==null?void 0:b.message]),B.useListener(window,d=>{var r;if(!((r=y.current)!=null&&r.parentElement)||!("detail"in d))return;const o=d.detail.wheelEvent;y.current.parentElement.scrollBy(o.deltaX,o.deltaY)},"spice-wheel"),Z.useEffect(()=>{I.clear();const d=f();return()=>{var o;try{(o=window.spice_connection)==null||o.stop()}catch(r){console.error(r)}d.then(r=>r==null?void 0:r.close())}},[t.status]),e(()=>{const d=y.current;d&&d.requestFullscreen().then(l).catch(o=>{s("Failed to enter full-screen mode",o)})}),m.jsx(m.Fragment,{children:n?m.jsx(B.Spinner,{className:"u-loader",text:"Loading VGA session..."}):m.jsx("div",{id:"spice-area",ref:y,children:m.jsx("div",{id:"spice-screen",className:"spice-screen"})})})},Kl=({instance:t,onFailure:e,showNotRunningInfo:s})=>{const{name:c,project:v}=tt(),I=new TextEncoder,[y,n]=Z.useState(!1),[a,u]=Z.useState(""),[_,l]=Z.useState(null),[f]=Z.useState(new Sr.FitAddon),[g,b]=Z.useState(!1),d=Z.useRef(null),o=B.useNotify();er({when:g,message:"Are you sure you want to leave this page?"});const r=C=>{g&&(C.returnValue="Are you sure you want to leave this page?")};B.useListener(window,r,"beforeunload");const i=rs(t),h=C=>{e("Error",C)},p=async()=>{if(!c){e("Missing name",new Error);return}if(!v){e("Missing project",new Error);return}n(!0),Go(c,v).then(u).catch(console.error);const C=await Yo(c,v).catch(L=>{n(!1),i?e("Connection failed",L):s()});if(!C)return;const w=C.operation.split("?")[0],S=location.protocol==="https:"?"wss":"ws",x=`${S}://${location.host}${w}/websocket?secret=${C.metadata.metadata.fds[0]}`,M=`${S}://${location.host}${w}/websocket?secret=${C.metadata.metadata.fds.control}`,k=new WebSocket(x),N=new WebSocket(M);return N.onopen=()=>{n(!1)},N.onerror=h,N.onclose=L=>{L.code!==1005&&e("Error",L.reason,wt(L.code))},k.onopen=()=>{l(k)},k.onerror=h,k.onclose=L=>{L.code!==1005&&e("Error",L.reason,wt(L.code)),l(null),b(!1)},k.binaryType="arraybuffer",k.onmessage=L=>{var F;(F=d.current)==null||F.write(new Uint8Array(L.data))},[k,N]};Z.useEffect(()=>{var C;i&&((C=d.current)==null||C.focus())},[i]),Z.useEffect(()=>{if(_)return;o.clear();const C=p();return()=>{C.then(w=>{w==null||w.map(S=>{S.close()})})}},[f,t.status]),Z.useEffect(()=>{!a||!d.current||y||(d.current.write(a),u(""))},[a,y]);const E=()=>{var C,w;ht("p-terminal",void 0,10),(w=(C=d.current)==null?void 0:C.element)==null||w.style.setProperty("padding","1rem"),f.fit()};return B.useListener(window,()=>{E(),setTimeout(E,500)},"resize",!0),m.jsx(m.Fragment,{children:y?m.jsx(B.Spinner,{className:"u-loader",text:"Loading text console..."}):m.jsx(Cr,{ref:d,addons:[f],onData:C=>{b(!0),_==null||_.send(I.encode(C))},className:"p-terminal",onOpen:E})})},Gl=({instance:t})=>{const e=ye(),{project:s}=tt(),c=B.useToastNotification(),v=Oe(),{openPortal:I,closePortal:y,isOpen:n,Portal:a}=B.usePortal(),[u,_]=Z.useState(!1),{canEditInstance:l}=Ue(),f=t.devices["iso-volume"],g=()=>{_(!0);const o=at(t);o.devices=o.devices.filter(h=>h.name!=="iso-volume");const r=Ht(t,o),i=m.jsx(fe,{instance:t});xt(r,s??"").then(h=>{e.set(h.metadata.id,()=>c.success(m.jsxs(m.Fragment,{children:["ISO"," ",m.jsx(Fe,{to:`/ui/project/${encodeURIComponent(s??"")}/storage/custom-isos`,type:"iso-volume",value:(f==null?void 0:f.source)??""})," ","detached from ",i]})),p=>c.failure("Detaching ISO failed.",new Error(p),i),()=>{v.invalidateQueries({queryKey:[Ee.instances,t.name,s]}),_(!1)})}).catch(h=>{_(!1),c.failure("Detaching ISO failed.",h,i)})},b=o=>{_(!0),y();const r=at(t),i=oa(o);r.devices.push(i);const h=Ht(t,r);xt(h,s??"").then(p=>{const E=or({operation:p,project:s,instanceType:t.type});e.set(p.metadata.id,()=>c.success(m.jsxs(m.Fragment,{children:["ISO"," ",m.jsx(Fe,{to:`/ui/project/${encodeURIComponent(s??"")}/storage/custom-isos`,type:"iso-volume",value:o.aliases})," ","attached to ",E]})),C=>c.failure("Attaching ISO failed.",new Error(C),E),()=>{v.invalidateQueries({queryKey:[Ee.instances,t.name,s]}),_(!1)})}).catch(p=>{_(!1),c.failure("Attaching ISO failed.",p)})},d=l(t)?void 0:"You do not have permission to edit this instance.";return f?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"u-text--muted margin-right",children:f.source}),m.jsx(B.ActionButton,{loading:u,onClick:g,className:"u-no-margin--bottom",disabled:!!d||u,title:d,children:"Detach ISO"})]}):m.jsxs(m.Fragment,{children:[m.jsx(B.ActionButton,{loading:u,onClick:I,className:"u-no-margin--bottom",disabled:!!d||u,title:d,children:"Attach ISO"}),n&&m.jsx(a,{children:m.jsx(ma,{onClose:y,onSelect:b})})]})},Yl=({instance:t})=>{const e=B.useNotify(),s=t.type==="virtual-machine",[c,v]=Z.useState(s),{hasCustomVolumeIso:I}=ar(),{canUpdateInstanceState:y,canAccessInstanceConsole:n}=Ue(),a=rs(t),u=(o,r,i)=>{e.failure(o,r,i)},_=()=>{e.info("Start the instance to interact with the text console.","Instance not running")};let l=()=>{};const f=o=>{l=o},g=o=>{e.clear(),v(o)},{handleStart:b,isLoading:d}=lr(t);return n(t)?m.jsxs("div",{className:"instance-console-tab",children:[s&&m.jsxs("div",{className:"p-panel__controls",children:[m.jsxs("div",{className:"console-radio-wrapper",children:[m.jsx(B.RadioInput,{labelClassName:"right-margin",label:"Graphic",checked:c,onChange:()=>{g(!0)}}),m.jsx(B.RadioInput,{label:"Text console",checked:!c,onChange:()=>{g(!1)}})]}),c&&a&&m.jsxs("div",{children:[I&&m.jsx(Gl,{instance:t}),m.jsx(B.Button,{className:"u-no-margin--bottom",onClick:()=>{l()},children:m.jsx("span",{children:"Fullscreen"})}),m.jsx(B.ContextualMenu,{hasToggleIcon:!0,toggleLabel:"Shortcuts",toggleClassName:"u-no-margin--bottom",links:[{children:"Send Ctrl + Alt + Del",onClick:()=>{fl(window.spice_connection)}},{children:"Send Alt + TAB",onClick:()=>{ml(window.spice_connection)}},{children:"Send Alt + F4",onClick:()=>{pl(window.spice_connection)}}]})]})]}),m.jsx(ss,{}),c&&!a&&m.jsxs(B.EmptyState,{className:"empty-state",image:m.jsx(B.Icon,{name:"pods",className:"empty-state-icon"}),title:"Instance stopped",children:[m.jsx("p",{children:"Start the instance to access the graphic console."}),m.jsx(B.ActionButton,{appearance:"positive",loading:d,"aria-disabled":d,onClick:b,disabled:!y(t)||d,title:y(t)?"":"You do not have permission to start this instance.",children:"Start instance"})]}),c&&a&&m.jsx("div",{className:"spice-wrapper",children:m.jsx(Hl,{instance:t,onMount:f,onFailure:u})}),!c&&m.jsx(Kl,{instance:t,onFailure:u,showNotRunningInfo:_})]}):m.jsx(B.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to access the console for this instance."})},zl=({instance:t,content:e,fileName:s})=>{const c=Z.useRef(null),v=(y,n)=>{const a=document.createElement("a");return a.setAttribute("href",n),a.setAttribute("target","_blank"),a.setAttribute("download",s),a.setAttribute("id",y),a.style.display="none",a},I=async()=>{var f;const y=`link-${s.toLowerCase().replace(" ","-")}`,n=document.getElementById(y);if(n){n.click();return}const a=e||await dr(t.name,t.project,s),u=new Blob([a],{type:"text/plain"}),_=URL.createObjectURL(u),l=v(y,_);(f=c.current)==null||f.appendChild(l),l.click()};return m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",onClick:()=>void I(),title:`Download ${s}`,"aria-label":`Download ${s} file`,hasIcon:!0,dense:!0,ref:c,children:m.jsx(B.Icon,{name:"begin-downloading",alt:"download"})})},Wl=({instance:t,path:e})=>{const s=e.split("/").at(-1)??"",c=`/ui/project/${encodeURIComponent(t.project)}/instance/${encodeURIComponent(t.name)}/logs/?file=${encodeURIComponent(s)}`,[v,I]=Z.useState(Eo("file")===s),{data:y,isLoading:n,isSuccess:a}=cr({queryKey:[Ee.logs,t.name,t.project,s],queryFn:async()=>dr(t.name,t.project,s),enabled:v}),u=()=>{I(_=>!_)};return m.jsxs("div",{className:"p-code-snippet file-row",children:[m.jsxs("div",{className:"p-code-snippet__header file-row-header",children:[m.jsxs(B.Button,{appearance:"base",hasIcon:!0,className:"u-no-margin--bottom file-row-toggle","aria-label":`Toggle ${s} visibility`,"aria-controls":s,"aria-hidden":!v,onClick:u,children:[m.jsx(B.Icon,{name:v?"chevron-up":"chevron-down"}),m.jsx("h2",{className:"p-code-snippet__title file-row-title",children:s})]}),m.jsx("a",{href:c,"aria-label":`File ${s} URL`,className:"p-button--base u-no-margin--bottom",children:m.jsx(B.Icon,{name:"get-link",alt:"link"})}),m.jsx(zl,{fileName:s,instance:t,content:y??""})]}),v&&m.jsx("pre",{id:s,className:"p-code-snippet__block","aria-hidden":!v,children:m.jsxs("code",{children:[n&&m.jsx(m.Fragment,{children:"Downloading file content..."}),a&&!y&&m.jsx(m.Fragment,{children:"This file is empty."}),a&&y&&m.jsx(m.Fragment,{children:y})]})})]})},$l=({instance:t})=>{const{data:e=[],isLoading:s}=cr({queryKey:[Ee.logs,t.name,t.project],queryFn:async()=>zo(t.name,t.project)});return m.jsxs(m.Fragment,{children:[s&&m.jsx(B.Spinner,{className:"u-loader",text:"Loading logs..."}),!s&&e.length===0&&m.jsx("div",{className:"u-align-text--center",children:"There are no log files for this instance."}),!s&&e.length>0&&e.map(c=>m.jsx(Wl,{instance:t,path:c},c))]})},Vl=({instanceProfiles:t,profiles:e})=>t.some(c=>!(e!=null&&e.find(v=>v.name===c)))?m.jsx(B.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to view all profiles applied to this instance. This may cause inherited configuration values to be displayed incorrectly."}):null,ql=({instance:t})=>{const e=ye(),s=B.useToastNotification(),{project:c,section:v}=tt(),I=Oe(),y=is(),[n,a]=Z.useState(0),{canEditInstance:u}=Ue();if(!c)return m.jsx(m.Fragment,{children:"Missing project"});const{data:_=[]}=Zi(c),l=()=>{ht("form-contents","p-bottom-controls")};Z.useEffect(l,[v]),B.useListener(window,l,"resize",!0);const f=u(t)?void 0:"You do not have permission to edit this instance",g=Ne({initialValues:at(t,f),validationSchema:gr,enableReinitialize:!0,onSubmit:i=>{const h=i.yaml?ga(i.yaml):Ht(t,i);h.etag=t.etag;const p=m.jsx(fe,{instance:t});xt(h,c).then(E=>{e.set(E.metadata.id,()=>{s.success(m.jsxs(m.Fragment,{children:["Instance ",p," updated."]})),g.setValues(at(h))},C=>s.failure("Instance update failed.",new Error(C),p),()=>{g.setSubmitting(!1),I.invalidateQueries({queryKey:[Ee.instances]})})}).catch(E=>{g.setSubmitting(!1),s.failure("Instance update failed.",E,p)})}}),b=`/ui/project/${encodeURIComponent(c)}/instance/${encodeURIComponent(t.name)}/configuration`,d=i=>{g.values.yaml&&i!==St&&g.setFieldValue("yaml",void 0),y(i===Es?b:`${b}/${ge(i)}`)},o=()=>{const i=new Set(["backups","snapshots","state","expanded_config","expanded_devices","etag"]),h=Object.fromEntries(Object.entries(t).filter(p=>!i.has(p[0])));return Ma(h)},r=g.values.readOnly;return m.jsxs("div",{className:"edit-instance",children:[m.jsxs(B.Form,{onSubmit:g.handleSubmit,className:"form",children:[v!==ge(St)&&m.jsx(va,{active:v??ge(Es),setActive:d,isDisabled:!1,hasDiskError:bi(g),hasNetworkError:Si(g)}),m.jsx(B.Row,{className:"form-contents",children:m.jsxs(B.Col,{size:12,children:[v!==ge(St)&&m.jsx(Vl,{instanceProfiles:t.profiles,profiles:_}),(v===ge(Es)||!v)&&m.jsx(aa,{formik:g,project:c}),v===ge(Sa)&&m.jsx(Ra,{formik:g,project:c}),v===ge(ba)&&m.jsx(Ta,{formik:g,project:c}),v===ge(Ca)&&m.jsx(ka,{formik:g,project:c}),v===ge(Ea)&&m.jsx(Ba,{formik:g,project:c}),v===ge(ya)&&m.jsx(Oa,{formik:g,project:c}),v===ge(wa)&&m.jsx(ca,{formik:g}),v===ge(xa)&&m.jsx(ha,{formik:g}),v===ge(Ia)&&m.jsx(vr,{formik:g}),v===ge(Aa)&&m.jsx(la,{formik:g}),v===ge(Pa)&&m.jsx(ua,{formik:g}),v===ge(Da)&&m.jsx(da,{formik:g},`yaml-form-${n}`),v===ge(St)&&m.jsx(_a,{yaml:o(),setYaml:i=>{fa(g),g.setFieldValue("yaml",i)},readOnly:!!g.values.editRestriction,readOnlyMessage:g.values.editRestriction,children:m.jsx(Ua,{entity:"instance",docPath:"/instances"})},`yaml-form-${n}`)]})},v)]}),m.jsxs(Na,{children:[m.jsx(La,{formik:g,section:v,setSection:d}),r?null:m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",onClick:()=>{g.setValues(at(t)),a(i=>i+1)},children:"Cancel"}),m.jsx(ja,{formik:g,baseUrl:b,isYaml:v===ge(St),disabled:bi(g)||Si(g)})]})]})]})},Xl=({onSelect:t,disableMember:e})=>{const{data:s=[],isLoading:c}=yo(),v=[{content:"Name",sortKey:"name"},{content:"Roles",sortKey:"roles"},{content:"Architecture",sortKey:"architecture"},{content:"Status",sortKey:"status"},{"aria-label":"Actions",className:"actions"}],I=s.map(y=>{const n=(e==null?void 0:e.name)===y.server_name?e==null?void 0:e.reason:null,a=()=>{n||t(y.server_name)};return{key:y.server_name,className:st("u-row",{"u-text--muted":n,"u-row--disabled":n}),columns:[{content:m.jsx("div",{className:"u-truncate migrate-instance-name",title:y.server_name,children:y.server_name}),role:"rowheader","aria-label":"Name",onClick:a},{content:y.roles.join(", "),role:"cell","aria-label":"Roles",onClick:a},{content:y.architecture,role:"cell","aria-label":"Architecture",onClick:a},{content:y.status,role:"cell","aria-label":"Status",onClick:a},{content:m.jsx(B.Button,{onClick:a,dense:!0,title:n,disabled:!!n,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:a}],sortData:{name:y.server_name.toLowerCase(),roles:y.roles.join(", ").toLowerCase(),architecture:y.architecture.toLowerCase(),status:y.status.toLowerCase()}}});return m.jsx("div",{className:"migrate-instance-table u-selectable-table-rows",children:m.jsx(B.ScrollableTable,{dependencies:[s],tableId:"migrate-instance-table",belowIds:["status-bar","migrate-instance-actions"],children:m.jsx(B.MainTable,{id:"migrate-instance-table",headers:v,rows:I,sortable:!0,className:"u-table-layout--auto",emptyStateMsg:c?"Loading cluster members...":"No cluster members available"})})})},Ql=({instance:t,onSelect:e,targetMember:s,onCancel:c,migrate:v})=>{const I=m.jsx("div",{className:"migrate-instance-summary",children:m.jsxs("p",{children:["This will migrate instance ",m.jsx("strong",{children:t.name})," to cluster member ",m.jsx("b",{children:s}),"."]})});return m.jsxs(m.Fragment,{children:[s&&I,!s&&m.jsx(Xl,{onSelect:e,disableMember:{name:t.location,reason:"Instance already on this member"}}),m.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[m.jsx(B.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:c,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{v(s)},disabled:!s,children:"Migrate"})]})]})},Jl=({instance:t,onSelect:e,targetPool:s,onCancel:c,migrate:v})=>{const I=m.jsx("div",{className:"migrate-instance-summary",children:m.jsxs("p",{children:["This will migrate the instance ",m.jsx("strong",{children:t.name})," root storage to pool ",m.jsx("b",{children:s}),"."]})});return m.jsxs(m.Fragment,{children:[s&&I,!s&&m.jsx(Ka,{onSelect:e,disablePool:{name:wo(t),reason:"Instance root storage already in this pool"}}),m.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[m.jsx(B.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:c,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{v(s)},disabled:!s,children:"Migrate"})]})]})},Zl=({instance:t,close:e,type:s,target:c})=>{const v=B.useToastNotification(),I=zs(),y=ye(),n=Oe(),a=is(),u=()=>{let b="";if(s==="cluster member"&&(b=m.jsxs(m.Fragment,{children:["Instance ",m.jsx(fe,{instance:t})," successfully migrated to cluster member"," ",m.jsx(Fe,{type:"cluster-member",value:c,to:`/ui/cluster/member/${encodeURIComponent(c)}`})]})),s==="root storage pool"&&(b=m.jsxs(m.Fragment,{children:["Instance ",m.jsx(fe,{instance:t})," root storage successfully moved to pool"," ",m.jsx(Fe,{type:"pool",value:c,to:`/ui/project/${encodeURIComponent(t.project)}/storage/pool/${encodeURIComponent(c)}`})]})),s==="project"){b=m.jsxs(m.Fragment,{children:["Instance"," ",m.jsx(fe,{instance:{...t,project:c}}),"successfully moved to project"," ",m.jsx(Fe,{type:"project",value:c,to:`/ui/project/${encodeURIComponent(c)}`})]});const d=window.location.pathname,o=d.replace(`/project/${t.project}/instance/${t.name}`,`/project/${c}/instance/${t.name}`);d!==o&&a(o)}v.success(b)},_=b=>{let d="";s==="cluster member"&&(d=`Cluster member migration failed for instance ${t.name}`),s==="root storage pool"&&(d=`Root storage move failed for instance ${t.name}`),s==="project"&&(d=`Project move failed for instance ${t.name}`),I.setFinish(t),v.failure(d,b,m.jsx(fe,{instance:t}))},l=b=>{_(new Error(b))},f=()=>{n.invalidateQueries({queryKey:[Ee.instances,t.name,t.project]}),I.setFinish(t)};return{handleMigrate:()=>{I.setLoading(t,"Migrating");const b=s==="cluster member"?c:void 0,d=s==="root storage pool"?c:void 0,o=s==="project"?c:void 0;Wo(t.name,t.project,b,d,o).then(r=>{y.set(r.metadata.id,u,i=>{l(i)},f),v.info(m.jsxs(m.Fragment,{children:[xo(s)," migration started for"," ",m.jsx(fe,{instance:t}),"."]})),n.invalidateQueries({queryKey:[Ee.instances,t.name,t.project]})}).catch(r=>{_(r)}).finally(()=>{e()})}}},eu=({onSelect:t,disableProject:e})=>{const{data:s=[]}=Lt(),{canCreateInstances:c}=Ye(),v=[{content:"Name",sortKey:"name"},{"aria-label":"Actions",className:"actions"}],I=s.map(y=>{const n=()=>c(y)?(e==null?void 0:e.name)===y.name?e==null?void 0:e.reason:null:"You do not have permission to create instances in this project",a=()=>{n()||t(y.name)};return{key:y.name,className:st("u-row",{"u-text--muted":!!n(),"u-row--disabled":!!n()}),columns:[{content:m.jsx("div",{className:"u-truncate migrate-instance-name",title:y.name,children:y.name}),role:"rowheader","aria-label":"Name",onClick:a},{content:m.jsx(B.Button,{onClick:a,dense:!0,title:n(),disabled:!!n(),children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:a}],sortData:{name:y.name.toLowerCase()}}});return m.jsx("div",{className:"migrate-instance-table u-selectable-table-rows",children:m.jsx(B.ScrollableTable,{dependencies:[s],tableId:"migrate-instance-table",belowIds:["status-bar","migrate-instance-actions"],children:m.jsx(B.MainTable,{id:"migrate-instance-table",headers:v,rows:I,sortable:!0,className:"u-table-layout--auto"})})})},tu=({instance:t,onSelect:e,targetProject:s,onCancel:c,migrate:v})=>{const I=m.jsx("div",{className:"migrate-instance-summary",children:m.jsxs("p",{children:["This will migrate the instance ",m.jsx("strong",{children:t.name})," to the project ",m.jsx("b",{children:s}),"."]})});return m.jsxs(m.Fragment,{children:[s&&I,!s&&m.jsx(eu,{onSelect:e,disableProject:{name:t.project,reason:"Instance already in this project"}}),m.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[m.jsx(B.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:c,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{v(s)},disabled:!s,children:"Migrate"})]})]})},su=({close:t,instance:e})=>{const s=ts(),[c,v]=Z.useState(""),[I,y]=Z.useState(""),{handleMigrate:n}=Zl({close:t,instance:e,type:c,target:I}),a=f=>{f.key==="Escape"&&t()},u=()=>{if(I){y("");return}if(c){v("");return}},_=m.jsxs(m.Fragment,{children:["Choose ",c," for instance ",m.jsx("strong",{children:e.name})]}),l=c?m.jsx(Ha,{title:I?"Confirm migration":_,onClick:u,linkText:I?`Choose ${c}`:"Choose migration method"}):"Choose migration method";return m.jsxs(B.Modal,{close:t,className:"migrate-instance-modal",onKeyDown:a,"aria-labelledby":"migrate-title",children:[m.jsxs("header",{className:"p-modal__header",children:[m.jsx("h2",{className:"p-modal__title",id:"migrate-title",children:l},c?I?"confirm":"select":"start"),m.jsx("button",{className:"p-modal__close","aria-label":"Close active modal",onClick:t,children:"Close"})]}),!c&&m.jsxs("div",{className:"choose-migration-type",children:[s&&m.jsx(ys,{icon:"cluster-host",title:"Migrate instance to a different cluster member",onClick:()=>{v("cluster member")}}),m.jsx(ys,{icon:"switcher-dashboard",title:"Move instance root storage to a different pool",onClick:()=>{v("root storage pool")}}),m.jsx(ys,{icon:"folder",title:"Move instance to a different project",onClick:()=>{v("project")}})]}),c==="cluster member"&&m.jsx(Ql,{instance:e,onSelect:y,targetMember:I,onCancel:u,migrate:n}),c==="root storage pool"&&m.jsx(Jl,{instance:e,onSelect:y,targetPool:I,onCancel:u,migrate:n}),c==="project"&&m.jsx(tu,{instance:e,onSelect:y,targetProject:I,onCancel:u,migrate:n})]})},iu=({instance:t,classname:e})=>{const{openPortal:s,closePortal:c,isOpen:v,Portal:I}=B.usePortal(),{canEditInstance:y}=Ue(),n=zs(),a=n.getType(t)==="Migrating"||t.status==="Migrating",u=a||!!n.getType(t);return m.jsxs(m.Fragment,{children:[v&&m.jsx(I,{children:m.jsx(su,{close:c,instance:t})}),m.jsxs(B.ActionButton,{onClick:s,type:"button",className:st("u-no-margin--bottom has-icon",e),loading:a,disabled:u||!y(t)||a,title:y()?"Migrate instance":"You do not have permission to migrate this instance",children:[m.jsx(B.Icon,{name:"machines"}),m.jsx("span",{children:"Migrate"})]})]})},ru=({instance:t,close:e})=>{const s=ye(),c=B.useToastNotification(),v=Oe(),I=m.jsx(fe,{instance:t}),{data:y}=Dt(t.project),{canCreateImageAliases:n}=Ye(),a=()=>{const f=m.jsx(Ks,{to:`/ui/project/${encodeURIComponent(t.project)}/images`,children:"created"});c.success(m.jsxs(m.Fragment,{children:["Image ",f," from instance ",I,"."]}))},u=()=>{v.invalidateQueries({predicate:f=>f.queryKey[0]===Ee.images})},_=(f,g)=>JSON.stringify({public:g,source:{name:f.name,type:"instance"}}),l=Ne({initialValues:{alias:n(y)?`from-instance-${t.name}`:"",isPublic:!1},validationSchema:Qe().shape({alias:qe()}),onSubmit:f=>{const g=f.alias;sr(_(t,f.isPublic),t).then(b=>{c.info(m.jsxs(m.Fragment,{children:["Creation of image from instance ",I," started."]})),s.set(b.metadata.id,d=>{var o;if(g){const r=((o=d.metadata.metadata)==null?void 0:o.fingerprint)??"";ir(r,g,t.project).then(u).then(a).catch(i=>{c.failure(`Image creation from instance "${t.name}" succeeded. Failed to create an alias.`,i)})}else u(),a()},d=>{c.failure(`Image creation from instance "${t.name}" failed.`,new Error(d),I)})}).catch(b=>{c.failure(`Image creation from instance "${t.name}" failed.`,b,I)}).finally(()=>{e()})}});return m.jsx(B.Modal,{close:e,className:"create-image-from-instance-modal",title:"Create image from instance",buttonRow:m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:l.isSubmitting,disabled:!l.isValid||l.isSubmitting,onClick:()=>void l.submitForm(),children:"Create image"})]}),children:m.jsxs(B.Form,{onSubmit:l.handleSubmit,children:[m.jsx(B.Input,{type:"text",label:"Instance",value:t.name,disabled:!0}),m.jsx(B.Input,{...l.getFieldProps("alias"),type:"text",label:"Alias",error:l.touched.alias?l.errors.alias:null,disabled:!n(y),title:n(y)?"":"You do not have permission to create image aliases in this project"}),m.jsx(B.Input,{...l.getFieldProps("isPublic"),type:"checkbox",label:"Make the image publicly available",error:l.touched.isPublic?l.errors.isPublic:null}),m.jsx(B.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},nu=({instance:t,classname:e,onClose:s})=>{const{openPortal:c,closePortal:v,isOpen:I,Portal:y}=B.usePortal(),{data:n}=Dt(t.project),{canCreateImages:a}=Ye(),u=zs(),_=["Error","Frozen","Running"],l=()=>{v(),s==null||s()},f=()=>a(n)?_.includes(t==null?void 0:t.status)||!!u.getType(t)?"Stop the instance to create an image":"":"You do not have permission to create images in this project";return m.jsxs(m.Fragment,{children:[I&&m.jsx(y,{children:m.jsx(ru,{close:l,instance:t})}),m.jsxs(B.ActionButton,{appearance:"default",className:st("u-no-margin--bottom has-icon",e),onClick:c,"aria-label":"Create image",title:f()||"Create image",disabled:!!f(),children:[m.jsx(B.Icon,{name:"plus"}),m.jsx("span",{children:"Create Image"})]})]})},ou=({instance:t,close:e})=>{var o,r;const s=B.useToastNotification(),c=ts(),v=Z.useState(null),I=is(),y=ye(),{data:n=[],isLoading:a}=Lt(),{canCreateInstances:u}=Ye(),{data:_=[],isLoading:l}=rr(),{data:f=[]}=mr(t.project),g=(i,h,p)=>{const E=`/ui/project/${encodeURIComponent(h)}/instance/${encodeURIComponent(i)}`,C=m.jsxs(m.Fragment,{children:["Created instance"," ",m.jsx(Fe,{type:p,value:i,to:E}),"."]}),w=[{label:"Configure",onClick:async()=>I(`${E}/configuration`)}];s.success(C,w)},d=Ne({initialValues:{instanceName:(i=>{const h=nr(i.name,"-copy");return Io(h,f)})(t),targetProject:t.project,allowInconsistent:!1,instanceOnly:!1,targetClusterMember:c?t.location:"",targetStoragePool:((o=t.devices.root)==null?void 0:o.pool)??((r=_[0])==null?void 0:r.name)},enableReinitialize:!0,validationSchema:Qe().shape({instanceName:Gs(t.project,v).required()}),onSubmit:i=>{const h=m.jsx(fe,{instance:t});ur(JSON.stringify({description:t.description,name:i.instanceName,architecture:t.architecture,source:{allow_inconsistent:i.allowInconsistent,instance_only:i.instanceOnly,source:t.name,type:"copy",project:t.project},devices:{...t.devices,root:{path:"/",type:"disk",pool:i.targetStoragePool}}}),i.targetProject,i.targetClusterMember).then(p=>{s.info(m.jsxs(m.Fragment,{children:["Copy of instance ",h," started."]})),y.set(p.metadata.id,()=>{g(i.instanceName,i.targetProject,t.type)},E=>s.failure("Instance copy failed.",new Error(E),h))}).catch(p=>{s.failure("Instance copy failed.",p,h)}).finally(()=>{e()})}});return m.jsx(B.Modal,{close:e,className:"copy-instances-modal",title:"Copy Instance",buttonRow:m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:d.isSubmitting,disabled:!d.isValid||d.isSubmitting||l||a,onClick:()=>void d.submitForm(),children:"Copy"})]}),children:m.jsxs(B.Form,{onSubmit:d.handleSubmit,children:[m.jsx(B.Input,{...d.getFieldProps("instanceName"),type:"text",label:"New instance name",error:d.touched.instanceName?d.errors.instanceName:null}),m.jsx(pr,{...d.getFieldProps("targetClusterMember"),id:"targetClusterMember",label:"Target cluster member"}),m.jsx(Ga,{...d.getFieldProps("targetStoragePool"),setValue:i=>void d.setFieldValue("targetStoragePool",i),selectProps:{id:"storagePool",label:"Storage pool"}}),m.jsx(B.Select,{...d.getFieldProps("targetProject"),id:"project",label:"Target project",options:n.filter(u).map(i=>({label:i.name,value:i.name}))}),m.jsx(B.Input,{...d.getFieldProps("allowInconsistent"),type:"checkbox",label:"Ignore copy errors for volatile files",error:d.touched.allowInconsistent?d.errors.allowInconsistent:null}),m.jsx(B.Input,{...d.getFieldProps("instanceOnly"),type:"checkbox",label:"Copy without instance snapshots",error:d.touched.instanceOnly?d.errors.instanceOnly:null}),m.jsx(B.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},au=({instance:t,isLoading:e,classname:s,onClose:c})=>{const{openPortal:v,closePortal:I,isOpen:y,Portal:n}=B.usePortal(),{data:a}=Dt(t.project),{data:u}=Lt(),{canCreateInstances:_}=Ye(),l=()=>{I(),c==null||c()},f=()=>{const g=u==null?void 0:u.filter(_);return!_(a)||!(g!=null&&g.length)?"You do not have permission to copy instances":e?"Loading...":""};return m.jsxs(m.Fragment,{children:[y&&m.jsx(n,{children:m.jsx(ou,{close:l,instance:t})}),m.jsxs(B.Button,{appearance:"default","aria-label":"Copy instance",className:st("u-no-margin--bottom has-icon",s),disabled:!!f(),onClick:v,title:f()||"Copy instance",children:[m.jsx(B.Icon,{name:"canvas"}),m.jsx("span",{children:"Copy"})]})]})},cu=({instance:t,close:e})=>{var d;const s=ye(),c=B.useToastNotification(),v=m.jsx(fe,{instance:t}),{hasBackupMetadataVersion:I}=ar(),y=Oe(),{data:n}=hr(),a=((d=n==null?void 0:n.environment)==null?void 0:d.backup_metadata_version_range)??[],u=o=>{const r=`/1.0/instances/${encodeURIComponent(t.name)}/backups/${encodeURIComponent(o)}/export?project=${encodeURIComponent(t.project)}`,i=document.createElement("a");i.href=r,i.download=o,i.click(),window.URL.revokeObjectURL(r),c.success(m.jsxs(m.Fragment,{children:["Instance ",v," download started:",m.jsx("br",{}),m.jsx("a",{href:r,children:o})]}))},_=o=>{const r=new Date;return r.setHours(r.getHours()+o),r},l=o=>{const r=new Date().toISOString().replaceAll(":","-").split(".")[0],i=`${t.name}-${r}.tar${o.compression==="gzip"?".gz":""}`,h=JSON.stringify({name:i,expires_at:_(o.expirationHours).toISOString(),compression_algorithm:o.compression,instance_only:o.instanceOnly,optimized_storage:o.optimizedStorage,version:I?Number(o.exportVersion):void 0});$o(t.name,t.project,h).then(p=>{c.info(m.jsxs(m.Fragment,{children:["Backing up instance ",v,".",m.jsx("br",{}),"Download will start, when the export is ready."]})),s.set(p.metadata.id,()=>{u(i)},E=>c.failure(`Could not download instance ${t.name}`,new Error(E),v))}).catch(p=>c.failure(`Could not download instance ${t.name}`,p,v)).finally(()=>{y.invalidateQueries({queryKey:[Ee.operations]}),e()})},f=Ne({initialValues:{compression:"gzip",exportVersion:"2",expirationHours:6,instanceOnly:!1,optimizedStorage:!0},onSubmit:o=>{l(o)}}),g=Object.values((t==null?void 0:t.expanded_devices)??{}).filter(Ao).filter(o=>o.path!=="/"),b=g.length>0;return m.jsx(B.Modal,{close:e,className:"export-instance-modal",title:"Export Instance",buttonRow:m.jsxs(m.Fragment,{children:[m.jsx(B.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),m.jsx(B.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:f.isSubmitting,disabled:f.isSubmitting,onClick:()=>void f.submitForm(),children:"Export instance"})]}),children:m.jsxs(B.Form,{onSubmit:f.handleSubmit,children:[b&&m.jsxs(B.Notification,{severity:"information",title:"Custom disks wil be ignored",children:["This instance has ",g.length," custom"," ",ot("disk",g.length),", which will be ignored in the export."]}),m.jsx(B.Select,{...f.getFieldProps("compression"),id:"project",label:"Compression",help:"No compression will be faster, but larger",options:[{value:"gzip",label:"Gzip"},{value:"none",label:"None"}]}),m.jsx(B.Select,{...f.getFieldProps("expirationHours"),id:"project",label:"Expiration",help:"Duration that the backup remains on the server",options:[{value:1,label:"1 hour"},{value:6,label:"6 hours"},{value:12,label:"12 hours"},{value:24,label:"1 day"},{value:72,label:"3 days"},{value:168,label:"7 days"}]}),I&&m.jsx(B.Select,{...f.getFieldProps("exportVersion"),id:"exportVersion",label:"Export version",help:"Lower versions allow imports on older LXD versions",options:a.map(o=>({value:o.toString(),label:o.toString()}))}),m.jsx(B.Input,{...f.getFieldProps("optimizedStorage"),type:"checkbox",label:"Use storage driver optimized format",help:"Can only be restored on a similar pool",checked:f.values.optimizedStorage}),m.jsx(B.Input,{...f.getFieldProps("instanceOnly"),type:"checkbox",label:"Export without instance snapshots",error:f.touched.instanceOnly?f.errors.instanceOnly:null,checked:f.values.instanceOnly}),m.jsx(B.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},hu=({instance:t,classname:e,onClose:s})=>{const{openPortal:c,closePortal:v,isOpen:I,Portal:y}=B.usePortal(),{canManageInstanceBackups:n}=Ue(),{project:a}=Ys(),u=Zo(a),_=()=>{v(),s==null||s()},l=()=>n(t)?u?`Project "${a==null?void 0:a.name}" doesn't allow for backup creation.`:"Export instance":"You do not have permission to export this instance.";return m.jsxs(m.Fragment,{children:[I&&m.jsx(y,{children:m.jsx(cu,{close:_,instance:t})}),m.jsxs(B.Button,{appearance:"default",className:st("u-no-margin--bottom has-icon",e),onClick:c,title:l(),disabled:!n(t)||u,children:[m.jsx(B.Icon,{name:"export"}),m.jsx("span",{children:"Export"})]})]})},lu=({instance:t,project:e,isLoading:s})=>{const c=Po(Do),v=c?"p-contextual-menu__link":"p-segmented-control__button",I=[m.jsx(iu,{instance:t,project:e,classname:v},"migrate"),m.jsx(nu,{instance:t,classname:v},"publish"),m.jsx(au,{instance:t,isLoading:s,classname:v},"copy"),m.jsx(hu,{instance:t,classname:v},"export"),m.jsx(Oo,{instance:t,classname:v},"delete")];return m.jsx(m.Fragment,{children:c?m.jsx(B.ContextualMenu,{closeOnOutsideClick:!1,toggleLabel:"Actions",position:"left",hasToggleIcon:!0,title:"actions",children:y=>m.jsx("span",{children:[...I].map(n=>Z.cloneElement(n,{onClose:y}))})}):m.jsx("div",{className:"p-segmented-control",children:m.jsx("div",{className:"p-segmented-control__list",children:I})})})},uu=({name:t,instance:e,project:s,isLoading:c})=>{const v=ye(),I=is(),y=B.useToastNotification(),{canEditInstance:n}=Ue(),a=Z.useState(null),{canViewProject:u}=Ys(),_=Qe().shape({name:Gs(s,a,t).required("Instance name is required")}),l=Ne({initialValues:{name:t,isRenaming:!1},validationSchema:_,onSubmit:g=>{if(t===g.name){l.setFieldValue("isRenaming",!1),l.setSubmitting(!1);return}Vo(t,g.name,s).then(b=>{const d=m.jsx(fe,{instance:{name:g.name,project:s,type:(e==null?void 0:e.type)||"instance"}});v.set(b.metadata.id,()=>{I(`/ui/project/${encodeURIComponent(s)}/instance/${encodeURIComponent(g.name)}`),y.success(m.jsxs(m.Fragment,{children:["Instance"," ",m.jsx("strong",{children:Lo(b.metadata)})," renamed to ",d,"."]})),l.setFieldValue("isRenaming",!1)},o=>y.failure("Renaming instance failed.",new Error(o),or({operation:b,project:s,instanceType:(e==null?void 0:e.type)||"instance"})),()=>{l.setSubmitting(!1)})}).catch(b=>{l.setSubmitting(!1),y.failure("Renaming instance failed.",b,e&&m.jsx(fe,{instance:e}))})}}),f=()=>{if(!n(e))return"You do not have permission to rename this instance";if(!e)return"Invalid Instance: Cannot be renamed";if(e.status!=="Stopped")return"Stop the instance to rename"};return!c&&m.jsx(Fa,{name:t,titleClassName:"instance-detail-title",parentItems:[m.jsx(Ks,{to:u?`/ui/project/${encodeURIComponent(s)}/instances`:"/ui/all-projects/instances",children:"Instances"},1)],renameDisabledReason:f(),centerControls:e?m.jsxs("div",{className:"instance-header-state-controls",children:[m.jsx("i",{className:"status u-text--muted",children:e.status}),m.jsx(No,{instance:e},"state")]}):null,controls:e?m.jsx(lu,{instance:e,project:s,isLoading:c}):null,isLoaded:!!e,formik:l})},du=(t,e,s)=>{var I,y;const c=((I=s==null?void 0:s.config)==null?void 0:I["user.ui_grafana_base_url"])??((y=s==null?void 0:s.config)==null?void 0:y["user.grafana_base_url"])??"";return c?(c.includes("{instance}")?c:`${c}&var-job=lxd&var-project={project}&var-name={instance}&var-top=5`).replace("{instance}",encodeURIComponent(t)).replace("{project}",encodeURIComponent(e)):""},_u=["Overview","Configuration","Snapshots","Terminal","Console","Logs"],cd=()=>{const{data:t}=hr(),{name:e,project:s,activeTab:c}=tt();if(!e)return m.jsx(m.Fragment,{children:"Missing name"});if(!s)return m.jsx(m.Fragment,{children:"Missing project"});const{data:v,error:I,refetch:y,isLoading:n}=ea(e,s),a=[..._u],u=du(e,s,t);return u&&a.push({label:m.jsxs("div",{children:[m.jsx(B.Icon,{name:"external-link"})," Metrics"]}),href:u,target:"_blank",rel:"noopener noreferrer"}),m.jsxs(B.CustomLayout,{header:m.jsx(uu,{name:e,instance:v,project:s,isLoading:n}),contentClassName:"detail-page",children:[n&&m.jsx(B.Spinner,{className:"u-loader",text:"Loading instance details..."}),!n&&!v&&!I&&m.jsx(m.Fragment,{children:"Loading instance failed"}),I&&m.jsx(B.Strip,{children:m.jsx(B.Notification,{severity:"negative",title:"Error",children:I.message})}),!n&&v&&m.jsxs(B.Row,{children:[m.jsx(Ya,{tabs:a,activeTab:c,tabUrl:`/ui/project/${encodeURIComponent(s)}/instance/${encodeURIComponent(e)}`}),!c&&m.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:m.jsx(Va,{instance:v})}),c==="configuration"&&m.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:m.jsx(ql,{instance:v})}),c==="snapshots"&&m.jsx("div",{role:"tabpanel","aria-labelledby":"snapshots",children:m.jsx(wc,{instance:v})}),c==="terminal"&&m.jsx("div",{role:"tabpanel","aria-labelledby":"terminal",children:m.jsx(ic,{instance:v,refreshInstance:y})}),c==="console"&&m.jsx("div",{role:"tabpanel","aria-labelledby":"console",children:m.jsx(Yl,{instance:v})}),c==="logs"&&m.jsx("div",{role:"tabpanel","aria-labelledby":"logs",children:m.jsx($l,{instance:v})})]})]})};export{cd as default};
Copyright ©2k19 -
Hexid
|
Tex7ure