@kauakdev/kauak 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,349 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-B-9xDvMq.js","assets/webworkerAll-gM2Z784I.js","assets/Filter-IrwvDh3w.js","assets/WebGPURenderer-ByQ-10KB.js","assets/BufferResource-CHYsmqd5.js","assets/RenderTargetSystem-CBR4meCp.js","assets/WebGLRenderer-DprtkQRW.js","assets/CanvasRenderer-DY1TnK1M.js","assets/demo-mFndvU9t.js","assets/demo-DyZsh87s.css"])))=>i.map(i=>d[i]);
2
+ var pp=Object.defineProperty;var _p=(t,e,s)=>e in t?pp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var w=(t,e,s)=>_p(t,typeof e!="symbol"?e+"":e,s);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function s(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=s(r);fetch(r.href,n)}})();const mp="modulepreload",gp=function(t){return"/"+t},Ch={},ai=function(e,s,i){let r=Promise.resolve();if(s&&s.length>0){let o=function(h){return Promise.all(h.map(c=>Promise.resolve(c).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=o(s.map(h=>{if(h=gp(h),h in Ch)return;Ch[h]=!0;const c=h.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${d}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":mp,c||(u.as="script"),u.crossOrigin="",u.href=h,l&&u.setAttribute("nonce",l),document.head.appendChild(u),c)return new Promise((f,p)=>{u.addEventListener("load",f),u.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&n(a.reason);return e().catch(n)})};function li(t){try{return localStorage.getItem(t)}catch{return null}}function ci(t,e){try{localStorage.setItem(t,e)}catch{}}const yp=["claude","codex","gemini","cursor","copilot","opencode"],vp=["amp","agy","cline","devin","droid","grok","hermes","kilo","kimi","kiro","letta","maki","mastracode","muse","omp","pi","qodercli","qwen"],En="kauak.build.agent",bp=6e4,wp=8e3;class xp{constructor(e){w(this,"btn",document.getElementById("btn-build"));w(this,"form",document.getElementById("build-form"));w(this,"title",document.getElementById("build-title"));w(this,"note",this.form.querySelector(".note"));w(this,"err",this.form.querySelector(".err"));w(this,"submit",this.form.querySelector("button[type=submit]"));w(this,"field",e=>this.form.elements.namedItem(e));w(this,"agent",this.form.elements.namedItem("agent"));w(this,"toast",document.getElementById("toast"));w(this,"on",!1);w(this,"target",null);w(this,"floor",{id:"",label:"",remote:!1,runtime:""});w(this,"mode","desk");w(this,"reqId",0);w(this,"pending",null);w(this,"timer",null);w(this,"toastTimer",null);w(this,"isTyping",()=>!1);this.h=e,this.agent.innerHTML='<option value="">None (just a shell)</option>'+yp.map(s=>`<option>${s}</option>`).join("")+`<optgroup label="More agents">${vp.map(s=>`<option>${s}</option>`).join("")}</optgroup>`,this.agent.value=li(En)??"",this.agent.selectedIndex<0&&(this.agent.value=""),this.btn.addEventListener("click",()=>this.toggle(!this.on));for(const s of this.form.querySelectorAll("[data-cancel]"))s.addEventListener("click",()=>this.close());for(const s of this.form.querySelectorAll("input[name=kind]"))s.addEventListener("change",()=>this.setMode(s.value));this.form.addEventListener("submit",s=>{s.preventDefault(),this.send()}),this.toast.addEventListener("click",()=>{this.toast.hidden=!0}),addEventListener("keydown",s=>{s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement||s.target instanceof HTMLSelectElement||this.isTyping()||s.metaKey||s.ctrlKey||s.altKey||s.key==="b"&&this.toggle(!this.on)}),addEventListener("keydown",s=>{s.key!=="Escape"||this.isTyping()||(this.form.hidden?this.on&&!document.body.classList.contains("panel-open")&&(s.stopPropagation(),this.toggle(!1)):(s.stopPropagation(),this.close()))},!0)}isOn(){return this.on}hasFocus(){return this.form.contains(document.activeElement)}toggle(e){e!==this.on&&(this.on=e,this.btn.setAttribute("aria-pressed",String(e)),document.body.classList.toggle("building",e),e||this.close(),this.h.onToggle(e))}open(e,s,i,r){var o,a,l;if(this.pending!==null)return;if(this.target=e,this.floor=s,this.form.reset(),this.agent.value=li(En)??"",this.agent.selectedIndex<0&&(this.agent.value=""),e.kind==="desk")this.title.textContent=`New desk · ${e.room.workspace.label||e.room.workspace.workspace_id}`,this.setMode("desk");else{const h=e.wing,c=(a=(o=h==null?void 0:h.rooms.find(u=>u.workspace.repo))==null?void 0:o.workspace.repo)==null?void 0:a.root,d=c??((l=h==null?void 0:h.rooms.flatMap(u=>u.desks)[0])==null?void 0:l.pane.cwd)??"";this.title.textContent=h?`New room · ${h.name}`:"New room",this.field("cwd").value=d,this.setMode(c?"worktree":"folder")}this.showError(""),this.form.hidden=!1,this.place(i,r),(this.mode==="desk"?this.agent:this.mode==="worktree"?this.field("branch"):this.field("cwd")).focus()}close(){this.form.hidden=!0,this.target=null,this.settle()}created(e,s){s===this.pending&&(this.settle(),this.form.hidden=!0,this.h.onCreated(e))}failed(e,s,i){if(i){this.showToast(e);return}s===this.pending&&(this.settle(),this.showError(e))}setMode(e){this.mode=e;const s=e==="desk"?["desk"]:["room",e];for(const i of this.form.querySelectorAll("[data-for]")){const r=i.dataset.for.split(" ").some(n=>s.includes(n));i.hidden=!r;for(const n of i.querySelectorAll("input[data-required]"))n.required=r}for(const i of this.form.querySelectorAll("input[name=kind]"))i.checked=i.value===e;this.field("cwd").previousElementSibling.textContent=e==="worktree"?"Repository":"Folder",this.field("cwd").placeholder=this.floor.remote?"/home/you/code/project":"~/code/project",this.note.textContent=e==="desk"?`Opens a new tab in this room in ${this.floor.runtime}. An agent must be installed on ${this.floor.label} to start.`:e==="worktree"?"Creates a git worktree on a new branch (in ~/.herdr/worktrees) and opens it as a room.":`Opens a ${this.floor.runtime} workspace in that folder${this.floor.remote?` on ${this.floor.label} (absolute path)`:""}.`}send(){const e=this.target;if(!e||this.pending!==null)return;const s=this.agent.value||null;ci(En,this.agent.value);const i=++this.reqId,r=a=>this.field(a).value.trim();let n;if(e.kind==="desk")n=this.h.createDesk(e.room.workspace.workspace_id,s,i);else{const a=r("label")||void 0,l=this.mode==="worktree"?{kind:"worktree",cwd:r("cwd"),branch:r("branch"),base:r("base")||void 0,label:a}:{kind:"folder",cwd:r("cwd"),label:a};n=this.h.createRoom(this.floor.id,l,s,i)}if(!n){this.showError("The bridge is offline. Try again once it reconnects.");return}this.pending=i,this.submit.disabled=!0,this.submit.textContent="Creating…",this.showError("");const o=`No answer from the bridge. Check ${this.floor.runtime}, then try again.`;this.timer=window.setTimeout(()=>this.failed(o,i),bp)}settle(){this.pending=null,this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.submit.disabled=!1,this.submit.textContent="Create"}showError(e){this.err.textContent=e,this.err.hidden=!e}place(e,s){const i=this.form.offsetWidth,r=this.form.offsetHeight,n=12,o=innerWidth<600;this.form.style.left=`${o?(innerWidth-i)/2:Math.max(n,Math.min(e+16,innerWidth-i-n))}px`,this.form.style.top=`${o?64:Math.max(64,Math.min(s-24,innerHeight-r-n))}px`}showToast(e){this.toast.textContent=e,this.toast.hidden=!1,this.toastTimer!==null&&clearTimeout(this.toastTimer),this.toastTimer=window.setTimeout(()=>{this.toast.hidden=!0},wp)}}function se(t){return t.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[e])}function yd(t){if(t.state==="live")return"";if(t.state==="connecting")return"connecting…";const e=t.message;if(/timed out/i.test(e))return"offline · ssh timed out";if(/Permission denied/i.test(e))return"ssh key refused";if(/Host key verification failed/i.test(e))return t.ssh?`unknown host key · run ssh ${t.ssh} once`:"unknown host key";if(/Could not resolve hostname|Name or service not known/i.test(e))return"unknown host";if(/Connection refused/i.test(e))return"ssh refused the connection";const s=t.runtime.name;return e.includes(`${s} is not running`)?`${s} is not running`:e.includes(`no reply from ${s}`)?`${s} is not answering`:e||"unreachable"}function vd(t){return t.runtime.version?`${t.runtime.name} ${t.runtime.version}`:t.runtime.name}const Sp={workspaces:[],panes:[]};function St(t,e){return`${t}/${e}`}function Ps(t){const e=t.indexOf("/");return{machine:t.slice(0,e),id:t.slice(e+1)}}function fs(t){return Ps(t).machine}function Cp(t,e){const s=i=>St(t,i);return{workspaces:e.workspaces.map(i=>({...i,workspace_id:s(i.workspace_id)})),panes:e.panes.map(i=>({...i,pane_id:s(i.pane_id),workspace_id:s(i.workspace_id)}))}}function kp(t){const e=t.map(s=>s.snapshot).filter(s=>s!==null);return{workspaces:e.flatMap(s=>s.workspaces),panes:e.flatMap(s=>s.panes)}}class Mp{constructor(e,s){w(this,"el",document.getElementById("floors"));w(this,"list",document.getElementById("floor-list"));w(this,"form",document.getElementById("floor-add"));w(this,"err",this.form.querySelector(".err"));w(this,"submit",this.form.querySelector("button[type=submit]"));w(this,"input",this.form.querySelector("input[name=ssh]"));w(this,"isTyping",()=>!1);this.state=e,this.h=s,document.getElementById("floor-add-btn").addEventListener("click",()=>this.toggleForm(this.form.hidden)),this.form.querySelector("[data-cancel]").addEventListener("click",()=>this.toggleForm(!1)),addEventListener("keydown",i=>{i.key==="Escape"&&!this.form.hidden&&!this.isTyping()&&(i.stopPropagation(),this.toggleForm(!1))},!0),this.form.addEventListener("submit",i=>{i.preventDefault();const r=new FormData(this.form),n=String(r.get("ssh")??"").trim();if(n){if(this.input.focus(),!this.h.onAdd(n,String(r.get("label")??"").trim())){this.showError("The bridge is offline. Try again once it reconnects.");return}this.submit.disabled=!0,this.showError("")}}),this.list.addEventListener("click",i=>{const r=i.target,n=r.closest("[data-rm]");if(n){const a=this.state.floors().find(l=>l.info.id===n.dataset.rm);a&&confirm(`Remove floor ${a.number} (${a.info.label})? The machine and its agents are not touched.`)&&this.h.onRemove(a.info.id);return}const o=r.closest("[data-floor]");o&&this.state.goToFloor(o.dataset.floor)}),addEventListener("keydown",i=>{if(i.target instanceof HTMLInputElement||i.target instanceof HTMLTextAreaElement||this.isTyping()||i.metaKey||i.ctrlKey||i.altKey)return;const r=this.state.floors();if(/^[1-9]$/.test(i.key)){const n=r[Number(i.key)-1];n&&this.state.goToFloor(n.info.id)}else if(i.key==="PageUp"||i.key==="PageDown"){i.preventDefault();const n=r.findIndex(a=>a.info.id===this.state.current),o=r[n+(i.key==="PageUp"?1:-1)];o&&this.state.goToFloor(o.info.id)}}),e.subscribe(i=>{i.type!=="selection"&&this.render()})}render(){const e=this.state.floors(),s=this.state.current;this.list.innerHTML=[...e].reverse().map(i=>{var c;const{info:r}=i,n={};let o=0;for(const d of((c=i.snapshot)==null?void 0:c.panes)??[])d.agent&&(o++,n[d.agent_status]=(n[d.agent_status]??0)+1);const a=r.state==="live"?`${o} agent${o===1?"":"s"}${r.ssh?` · ssh ${r.ssh}`:" · this machine"}`:yd(r),l=["blocked","done"].filter(d=>n[d]).map(d=>`<b class="badge st-${d}" title="${n[d]} ${d}">${n[d]}</b>`).join(""),h=`${i.number}F · ${r.label}${r.runtime.version?` · ${vd(r)}`:""}
3
+ ${r.state}${r.message?`: ${r.message}`:""}
4
+ key ${i.number<=9?i.number:"—"}`;return`<div class="floor conn-${r.state} ${r.id===s?"current":""}" role="listitem"><button class="go" data-floor="${se(r.id)}" title="${se(h)}" ${r.id===s?'aria-current="true"':""}><span class="fn">${i.number}F</span><span class="txt"><span class="name">${se(r.label)}</span><span class="sub">${se(a)}</span></span><span class="badges">${l}<i class="conn-dot"></i></span></button>`+(r.id==="local"?"":`<button class="rm" data-rm="${se(r.id)}" title="Remove this floor" aria-label="Remove floor ${se(r.label)}">×</button>`)+"</div>"}).join("")}added(){this.form.reset(),this.toggleForm(!1)}showError(e){this.submit.disabled=!1,this.err.textContent=e,this.err.hidden=!e,e&&this.input.select()}toggleForm(e){this.form.hidden=!e,this.el.classList.toggle("adding",e),this.showError(""),e&&this.input.focus()}}const kh="kauak.floor";class Tp{constructor(e){w(this,"machines",[]);w(this,"snapshots",new Map);w(this,"floorId");w(this,"paneId",null);w(this,"wantPane");w(this,"listeners",new Set);this.floorId=e.get("floor")??li(kh)??"local";let s=e.get("pane");s&&!s.includes("/")&&(s=St("local",s)),s&&(this.floorId=fs(s)),this.wantPane=s}get current(){return this.floorId}get selected(){return this.paneId}floors(){return this.machines.map((e,s)=>({info:e,number:s+1,snapshot:this.snapshots.get(e.id)??null}))}snapshot(e){return this.snapshots.get(e)}pane(e){var s;return(s=this.snapshots.get(fs(e)))==null?void 0:s.panes.find(i=>i.pane_id===e)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setMachines(e){this.machines=e;const s=new Set(e.map(i=>i.id));for(const i of[...this.snapshots.keys()])s.has(i)||this.snapshots.delete(i);!s.has(this.floorId)&&e.length>0?this.goToFloor(e[0].id):this.emit({type:"floors",current:!0})}setSnapshot(e,s){this.snapshots.set(e,Cp(e,s)),this.emit({type:"floors",current:e===this.floorId}),this.wantPane&&fs(this.wantPane)===e&&(this.pane(this.wantPane)&&this.select(this.wantPane),this.wantPane=null)}goToFloor(e){const s=this.floors(),i=s.find(o=>o.info.id===this.floorId),r=s.find(o=>o.info.id===e);if(!r)return;const n=i&&i!==r?Math.sign(r.number-i.number):0;this.floorId=e,ci(kh,e),this.emit({type:"floor",dir:n})}select(e){if(!this.pane(e))return;const s=fs(e);s!==this.floorId&&this.goToFloor(s),this.paneId=e,this.emit({type:"selection"})}deselect(){this.paneId!==null&&(this.paneId=null,this.emit({type:"selection"}))}emit(e){for(const s of[...this.listeners])s(e)}}const Ep=.6,Pp=.85,Ap={ok:8376761,warn:16757575,full:16739179};function Ua(t){return t.max>0?Math.min(1,Math.max(0,t.used/t.max)):0}function qa(t){const e=Ua(t);return e>=Pp?"full":e>=Ep?"warn":"ok"}function Xr(t){return`${Math.round(Ua(t)*100)}%`}function Va(t){return`${Mh(t.used)} of ${Mh(t.max)} tokens (${Xr(t)})`}function Mh(t){return t>=1e6?`${+(t/1e6).toFixed(t%1e6===0?0:1)}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}const Jt=3,yt=1,Pn=2,An=3,pr=Jt+yt*2;function Rp(t,e,s){const i=Math.max(1,e.length+(s?1:0)),r=Math.ceil(Math.sqrt(i)),n=Math.ceil(i/r),o=a=>({x:yt+a%r*Jt+1,y:yt+Math.floor(a/r)*Jt+1});return{workspace:t,x:0,y:0,w:r*Jt+yt*2,h:n*Jt+yt*2,desks:e.map((a,l)=>({pane:a,...o(l)})),focused:t.focused||e.some(a=>a.focused),slot:s?o(e.length):null}}function bd(t,e){var i,r,n;const s=((i=e[0])==null?void 0:i.cwd)??t.label??"loose";return{key:((r=t.repo)==null?void 0:r.key)??`dir:${s}`,name:((n=t.repo)==null?void 0:n.name)??(s.split("/").pop()||"loose")}}function Bp(t,e=!1){const s=new Map;for(const l of t.panes){const h=s.get(l.workspace_id)??[];h.push(l),s.set(l.workspace_id,h)}const i=new Map;for(const l of[...t.workspaces].sort((h,c)=>h.number-c.number)){const{key:h,name:c}=bd(l,s.get(l.workspace_id)??[]),d=i.get(h)??{name:c,ws:[]};d.ws.push(l),i.set(h,d)}const r=[];let n=0,o=0;for(const[l,h]of i){const c=h.ws.map(_=>Rp(_,s.get(_.workspace_id)??[],e));let d=0,u=0;for(const _ of c){_.x=d,_.y=n;for(const g of _.desks)g.x+=_.x,g.y+=_.y;_.slot&&(_.slot.x+=_.x,_.slot.y+=_.y),d+=_.w+Pn,u=Math.max(u,_.h)}const f=e?{x:d,y:n,w:pr,h:pr}:null;f&&(d+=f.w+Pn);const p=Math.max(0,d-Pn);r.push({key:l,name:h.name,x:0,y:n,w:p,h:u,rooms:c,slot:f}),o=Math.max(o,p),n+=u+An}const a=e?{x:0,y:n,w:pr,h:pr}:null;return a&&(o=Math.max(o,a.w),n+=a.h+An),{wings:r,w:o,h:Math.max(0,n-An),slot:a}}const Lp=["working","idle","blocked","done","unknown"],Th=40,Eh="kauak.feed-hidden";class Ip{constructor(e,s){w(this,"roster",document.getElementById("roster-body"));w(this,"feed",document.getElementById("feed-body"));w(this,"stats",document.getElementById("stats"));w(this,"clock",document.getElementById("clock"));w(this,"empty",document.getElementById("empty"));w(this,"tracked",new Map);w(this,"isTyping",()=>!1);w(this,"items",[]);w(this,"floors",[]);w(this,"current","");w(this,"bridgeUp",!1);w(this,"seen",new Set);w(this,"order",[]);this.state=e,document.getElementById("btn-fit").addEventListener("click",()=>s.onFit()),document.getElementById("btn-zoom-in").addEventListener("click",()=>s.onZoom(1.25)),document.getElementById("btn-zoom-out").addEventListener("click",()=>s.onZoom(.8)),document.getElementById("btn-roster").addEventListener("click",()=>document.body.classList.toggle("roster-hidden")),document.getElementById("btn-feed").addEventListener("click",()=>this.toggleFeed()),document.getElementById("feed-hide").addEventListener("click",r=>{r.stopPropagation(),this.toggleFeed(!0)}),document.querySelector("#feed header").addEventListener("click",()=>{document.body.classList.contains("feed-hidden")&&this.toggleFeed(!1)}),this.toggleFeed(li(Eh)==="1"),addEventListener("keydown",r=>{r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||this.isTyping()||r.metaKey||r.ctrlKey||r.altKey||(r.key==="f"?s.onFit():r.key==="r"?document.body.classList.toggle("roster-hidden"):r.key==="a"?this.toggleFeed():r.key==="j"||r.key==="k"||r.key==="ArrowDown"||r.key==="ArrowUp"?(r.preventDefault(),this.step(r.key==="j"||r.key==="ArrowDown"?1:-1)):r.key==="+"||r.key==="="?s.onZoom(1.25):r.key==="-"&&s.onZoom(.8))});const i=()=>{this.clock.textContent=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};i(),setInterval(i,15e3),setInterval(()=>this.refreshTimes(),1e4),e.subscribe(r=>{r.type==="selection"?this.markSelected():this.render()})}setBridge(e){this.bridgeUp=e,this.renderConn()}markSelected(){const e=this.state.selected;for(const s of this.roster.querySelectorAll(".pane"))s.classList.toggle("selected",s.dataset.pane===e)}render(){const e=this.state.floors();this.floors=e,this.current=this.state.current;const s=Date.now(),i=new Set,r=new Set(e.map(o=>o.info.id));for(const o of e){const a=o.snapshot;if(!a)continue;const l=!this.seen.has(o.info.id);this.seen.add(o.info.id);const h=new Map(a.workspaces.map(c=>{var d;return[c.workspace_id,c.label||((d=c.repo)==null?void 0:d.name)||c.workspace_id]}));for(const c of a.panes){i.add(c.pane_id);const d=h.get(c.workspace_id)??"?",u=this.tracked.get(c.pane_id),f=c.agent??"shell",p=(_,g)=>this.push({at:s,text:_,status:g,paneId:c.pane_id,floor:o.info.id});u?((u.agent??null)!==(c.agent??null)&&c.agent&&p(`${c.agent} sat down in ${d}`,c.agent_status),u.status!==c.agent_status&&(u.since=s,p(`${f} in ${d} is now ${c.agent_status}`,c.agent_status)),u.status=c.agent_status,u.agent=c.agent??null,u.room=d):(this.tracked.set(c.pane_id,{status:c.agent_status,agent:c.agent??null,since:s,room:d}),!l&&c.agent&&p(`${f} joined ${d}`,c.agent_status))}}for(const[o,a]of[...this.tracked]){if(i.has(o))continue;this.tracked.delete(o);const l=fs(o);a.agent&&r.has(l)&&this.push({at:s,text:`${a.agent} left ${a.room}`,status:"unknown",paneId:o,floor:l})}for(const o of[...this.seen])r.has(o)||this.seen.delete(o);const n=e.flatMap(o=>{var a;return((a=o.snapshot)==null?void 0:a.panes)??[]});this.renderStats(n),this.renderRoster(),this.renderFeed(),this.renderConn()}toggleFeed(e=!document.body.classList.contains("feed-hidden")){document.body.classList.toggle("feed-hidden",e),document.getElementById("btn-feed").setAttribute("aria-expanded",String(!e)),ci(Eh,e?"1":"0")}showEmpty(e,s){this.empty.hidden=!1,this.empty.querySelector("h2").textContent=e,this.empty.querySelector("p").textContent=s}push(e){this.items.unshift(e),this.items.length>Th&&(this.items.length=Th)}renderConn(){const e=document.getElementById("conn"),s=this.floors.find(n=>n.info.id===this.current);let i=!1,r;this.bridgeUp?s?s.info.state==="down"?(r=`${s.info.label} unreachable`,this.showEmpty(`Floor ${s.number} · ${s.info.label} is unreachable`,`${(s.info.message||`${s.info.runtime.name} did not answer`).replace(/\.?$/,".")} Retrying on its own.`)):s.snapshot?(i=s.info.state==="live",r=`${s.number}F · ${vd(s.info)}`,s.snapshot.panes.length===0?this.showEmpty(`Floor ${s.number} is empty`,`Open a workspace or pane in ${s.info.runtime.name}${s.info.ssh?` on ${s.info.label}`:""} and it will appear here.`):this.empty.hidden=!0):(r="connecting…",this.showEmpty(`Taking the elevator to ${s.info.label}…`,s.info.message||`Waiting for ${s.info.runtime.name}.`)):(r="connecting…",this.empty.hidden=!0):(r="bridge offline · retrying",this.showEmpty("The bridge is offline","Start it with npx @kauakdev/kauak serve (or pnpm dev in a checkout). This page reconnects on its own.")),e.classList.toggle("ok",i),e.classList.toggle("bad",!i),document.getElementById("conn-text").textContent=r}renderStats(e){const s={working:0,idle:0,blocked:0,done:0,unknown:0};let i=0;for(const n of e)n.agent&&(i++,s[n.agent_status]++);const r=[`<span class="chip"><b>${i}</b> agent${i===1?"":"s"} · <b>${e.length}</b> pane${e.length===1?"":"s"}</span>`];for(const n of Lp)n==="unknown"&&s[n]===0||r.push(`<span class="chip st-${n} ${s[n]===0?"zero":""}"><i class="dot"></i>${s[n]} ${n}</span>`);this.stats.innerHTML=r.join(""),document.title=s.blocked>0?`(${s.blocked} blocked) kauak`:"kauak"}renderRoster(){this.order=[];const e=this.floors.length>1,s=[];for(const i of[...this.floors].reverse()){const r=yd(i.info);e&&s.push(`<h2 class="floor-h conn-${i.info.state} ${i.info.id===this.current?"current":""}"><span class="fn">${i.number}F</span><span class="name">${se(i.info.label)}</span>${r?`<span class="state" title="${se(i.info.message)}">${se(r)}</span>`:""}</h2>`),i.snapshot&&s.push(`<div class="floor-body conn-${i.info.state}">${this.rosterGroups(i.snapshot,i.info.runtime.name)}</div>`)}this.roster.innerHTML=s.join("");for(const i of this.roster.querySelectorAll(".pane"))i.addEventListener("click",()=>this.state.select(i.dataset.pane))}rosterGroups(e,s){var n;const i=new Map;for(const o of e.panes)i.set(o.workspace_id,[...i.get(o.workspace_id)??[],o]);const r=new Map;for(const o of[...e.workspaces].sort((a,l)=>a.number-l.number)){const a=i.get(o.workspace_id)??[],{key:l,name:h}=bd(o,a),c=r.get(l)??{name:h,rows:[]};c.rows.push(`<div class="room"><span>${se(o.label||o.workspace_id)}</span>${o.focused?`<em title="focused in ${se(s)}">●</em>`:""}</div>`);for(const d of a){this.order.push(d.pane_id);const u=this.tracked.get(d.pane_id),f=d.title||((n=d.cwd)==null?void 0:n.split("/").pop())||d.pane_id;c.rows.push(`<button class="pane st-${d.agent_status} ${d.pane_id===this.state.selected?"selected":""}" data-pane="${se(d.pane_id)}"><i class="dot"></i><span class="kind">${se(d.agent??"shell")}</span><span class="title">${se(f)}</span>${Dp(d)}<span class="age" data-since="${(u==null?void 0:u.since)??Date.now()}">${Rn((u==null?void 0:u.since)??Date.now())}</span></button>`)}r.set(l,c)}return[...r.values()].map(o=>`<section><h3>${se(o.name)}</h3>${o.rows.join("")}</section>`).join("")}renderFeed(){if(this.items.length===0){this.feed.innerHTML='<div class="quiet">Quiet so far. Status changes show up here.</div>';return}const e=this.floors.length>1,s=new Map(this.floors.map(i=>[i.info.id,i.number]));this.feed.innerHTML=this.items.slice(0,12).map(i=>{const r=s.get(i.floor),n=e&&r?`<b class="fl">${r}F</b>`:"";return`<button class="ev st-${i.status}" data-pane="${se(i.paneId)}"><i class="dot"></i><span>${n}${se(i.text)}</span><time data-since="${i.at}">${Rn(i.at)}</time></button>`}).join("");for(const i of this.feed.querySelectorAll(".ev"))i.addEventListener("click",()=>{this.tracked.has(i.dataset.pane)&&this.state.select(i.dataset.pane)})}refreshTimes(){for(const e of document.querySelectorAll("[data-since]"))e.textContent=Rn(Number(e.dataset.since))}step(e){if(this.order.length===0)return;const s=this.order.indexOf(this.state.selected??""),i=s===-1?e>0?0:this.order.length-1:(s+e+this.order.length)%this.order.length;this.state.select(this.order[i])}}function Dp(t){const e=t.context;return e?`<span class="ctx ${qa(e)}" title="Context: ${se(Va(e))}"><i style="width:${Xr(e)}"></i></span>`:"<span></span>"}function Rn(t){const e=Math.max(0,Math.round((Date.now()-t)/1e3));if(e<5)return"now";if(e<60)return`${e}s`;const s=Math.round(e/60);if(s<60)return`${s}m`;const i=Math.round(s/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}/**
5
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
6
+ * @license MIT
7
+ *
8
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
9
+ * @license MIT
10
+ *
11
+ * Originally forked from (with the author's permission):
12
+ * Fabrice Bellard's javascript vt100 for jslinux:
13
+ * http://bellard.org/jslinux/
14
+ * Copyright (c) 2011 Fabrice Bellard
15
+ */var wd=Object.defineProperty,Op=Object.getOwnPropertyDescriptor,Fp=(t,e)=>{for(var s in e)wd(t,s,{get:e[s],enumerable:!0})},Pe=(t,e,s,i)=>{for(var r=i>1?void 0:i?Op(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=(i?o(e,s,r):o(r))||r);return i&&r&&wd(e,s,r),r},W=(t,e)=>(s,i)=>e(s,i,t),Ph="Terminal input",Eo={get:()=>Ph,set:t=>Ph=t},Ah="Too much output to announce, navigate to rows manually to read",Po={get:()=>Ah,set:t=>Ah=t};function $p(t){return t.replace(/\r?\n/g,"\r")}function Np(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function Hp(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function Wp(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");xd(r,e,s,i)}}function xd(t,e,s,i){t=$p(t),t=Np(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Sd(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,n=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function Rh(t,e,s,i,r){Sd(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function cs(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function gn(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let n=t[r];n>65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var zp=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let n=t.charCodeAt(r++);56320<=n&&n<=57343?e[i++]=(this._interim-55296)*1024+n-56320+65536:(e[i++]=this._interim,e[i++]=n),this._interim=0}for(let n=r;n<s;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=s)return this._interim=o,i;let a=t.charCodeAt(n);56320<=a&&a<=57343?e[i++]=(o-55296)*1024+a-56320+65536:(e[i++]=o,e[i++]=a);continue}o!==65279&&(e[i++]=o)}return i}},Gp=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,n,o,a,l=0,h=0;if(this.interim[0]){let u=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let p=0,_;for(;(_=this.interim[++p]&63)&&p<4;)f<<=6,f|=_;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,m=g-p;for(;h<m;){if(h>=s)return 0;if(_=t[h++],(_&192)!==128){h--,u=!0;break}else this.interim[p++]=_,f<<=6,f|=_&63}u||(g===2?f<128?h--:e[i++]=f:g===3?f<2048||f>=55296&&f<=57343||f===65279||(e[i++]=f):f<65536||f>1114111||(e[i++]=f)),this.interim.fill(0)}let c=s-4,d=h;for(;d<s;){for(;d<c&&!((r=t[d])&128)&&!((n=t[d+1])&128)&&!((o=t[d+2])&128)&&!((a=t[d+3])&128);)e[i++]=r,e[i++]=n,e[i++]=o,e[i++]=a,d+=4;if(r=t[d++],r<128)e[i++]=r;else if((r&224)===192){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(l=(r&31)<<6|n&63,l<128){d--;continue}e[i++]=l}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=t[d++],(o&192)!==128){d--;continue}if(l=(r&15)<<12|(n&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;e[i++]=l}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,i;if(a=t[d++],(a&192)!==128){d--;continue}if(l=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;e[i++]=l}}return i}},Cd="",ps=" ",or=class kd{constructor(){this.fg=0,this.bg=0,this.extended=new Zr}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new kd;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Zr=class Md{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Md(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Et=class Td extends or{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Zr,this.combinedData=""}static fromCharData(e){let s=new Td;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?cs(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Bh="di$target",Ao="di$dependencies",Bn=new Map;function Up(t){return t[Ao]||[]}function Ze(t){if(Bn.has(t))return Bn.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");qp(e,s,r)};return e._id=t,Bn.set(t,e),e}function qp(t,e,s){e[Bh]===e?e[Ao].push({id:t,index:s}):(e[Ao]=[{id:t,index:s}],e[Bh]=e)}var ht=Ze("BufferService"),Ed=Ze("CoreMouseService"),qs=Ze("CoreService"),Vp=Ze("CharsetService"),Ya=Ze("InstantiationService"),Pd=Ze("LogService"),lt=Ze("OptionsService"),Ad=Ze("OscLinkService"),Yp=Ze("UnicodeService"),ar=Ze("DecorationService"),Ro=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){var c;let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,n=new Et,o=s.getTrimmedLength(),a=-1,l=-1,h=!1;for(let d=0;d<o;d++)if(!(l===-1&&!s.hasContent(d))){if(s.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(l===-1){l=d,a=n.extended.urlId;continue}else h=n.extended.urlId!==a;else l!==-1&&(h=!0);if(h||l!==-1&&d===o-1){let u=(c=this._oscLinkService.getLinkData(a))==null?void 0:c.uri;if(u){let f={start:{x:l+1,y:t},end:{x:d+(!h&&d===o-1?1:0),y:t}},p=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let _=new URL(u);["http:","https:"].includes(_.protocol)||(p=!0)}catch{p=!0}p||i.push({text:u,range:f,activate:(_,g)=>r?r.activate(_,g,f):Kp(_,g),hover:(_,g)=>{var m;return(m=r==null?void 0:r.hover)==null?void 0:m.call(r,_,g,f)},leave:(_,g)=>{var m;return(m=r==null?void 0:r.leave)==null?void 0:m.call(r,_,g,f)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(l=d,a=n.extended.urlId):(l=-1,a=-1)}}e(i)}};Ro=Pe([W(0,ht),W(1,lt),W(2,Ad)],Ro);function Kp(t,e){if(confirm(`Do you want to navigate to ${e}?
16
+
17
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var yn=Ze("CharSizeService"),is=Ze("CoreBrowserService"),Ka=Ze("MouseService"),rs=Ze("RenderService"),jp=Ze("SelectionService"),Rd=Ze("CharacterJoinerService"),gi=Ze("ThemeService"),Bd=Ze("LinkProviderService"),Xp=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Lh.isErrorNoTelemetry(t)?new Lh(t.message+`
18
+
19
+ `+t.stack):new Error(t.message+`
20
+
21
+ `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},Zp=new Xp;function Wr(t){Jp(t)||Zp.onUnexpectedError(t)}var Bo="Canceled";function Jp(t){return t instanceof Qp?!0:t instanceof Error&&t.name===Bo&&t.message===Bo}var Qp=class extends Error{constructor(){super(Bo),this.name=this.message}};function e_(t){return new Error(`Illegal argument: ${t}`)}var Lh=class Lo extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Lo)return e;let s=new Lo;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Io=class Ld extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ld.prototype)}};function _t(t,e=0){return t[t.length-(1+e)]}var t_;(t=>{function e(n){return n<0}t.isLessThan=e;function s(n){return n<=0}t.isLessThanOrEqual=s;function i(n){return n>0}t.isGreaterThan=i;function r(n){return n===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(t_||(t_={}));function s_(t,e){let s=this,i=!1,r;return function(){return i||(i=!0,e||(r=t.apply(s,arguments))),r}}var Id;(t=>{function e(b){return b&&typeof b=="object"&&typeof b[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function i(){return s}t.empty=i;function*r(b){yield b}t.single=r;function n(b){return e(b)?b:r(b)}t.wrap=n;function o(b){return b||s}t.from=o;function*a(b){for(let S=b.length-1;S>=0;S--)yield b[S]}t.reverse=a;function l(b){return!b||b[Symbol.iterator]().next().done===!0}t.isEmpty=l;function h(b){return b[Symbol.iterator]().next().value}t.first=h;function c(b,S){let x=0;for(let M of b)if(S(M,x++))return!0;return!1}t.some=c;function d(b,S){for(let x of b)if(S(x))return x}t.find=d;function*u(b,S){for(let x of b)S(x)&&(yield x)}t.filter=u;function*f(b,S){let x=0;for(let M of b)yield S(M,x++)}t.map=f;function*p(b,S){let x=0;for(let M of b)yield*S(M,x++)}t.flatMap=p;function*_(...b){for(let S of b)yield*S}t.concat=_;function g(b,S,x){let M=x;for(let O of b)M=S(M,O);return M}t.reduce=g;function*m(b,S,x=b.length){for(S<0&&(S+=b.length),x<0?x+=b.length:x>b.length&&(x=b.length);S<x;S++)yield b[S]}t.slice=m;function y(b,S=Number.POSITIVE_INFINITY){let x=[];if(S===0)return[x,b];let M=b[Symbol.iterator]();for(let O=0;O<S;O++){let B=M.next();if(B.done)return[x,t.empty()];x.push(B.value)}return[x,{[Symbol.iterator](){return M}}]}t.consume=y;async function v(b){let S=[];for await(let x of b)S.push(x);return Promise.resolve(S)}t.asyncToArray=v})(Id||(Id={}));function zs(t){if(Id.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(i){e.push(i)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function i_(...t){return be(()=>zs(t))}function be(t){return{dispose:s_(()=>{t()})}}var Dd=class Od{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{zs(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Od.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};Dd.DISABLE_DISPOSED_WARNING=!1;var gs=Dd,J=class{constructor(){this._store=new gs,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};J.None=Object.freeze({dispose(){}});var di=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){var e;this._isDisposed||t===this._value||((e=this._value)==null||e.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){var t;this._isDisposed=!0,(t=this._value)==null||t.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Qt=typeof window=="object"?window:globalThis,Do=class Oo{constructor(e){this.element=e,this.next=Oo.Undefined,this.prev=Oo.Undefined}};Do.Undefined=new Do(void 0);var we=Do,Ih=class{constructor(){this._first=we.Undefined,this._last=we.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===we.Undefined}clear(){let t=this._first;for(;t!==we.Undefined;){let e=t.next;t.prev=we.Undefined,t.next=we.Undefined,t=e}this._first=we.Undefined,this._last=we.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new we(t);if(this._first===we.Undefined)this._first=s,this._last=s;else if(e){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==we.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==we.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==we.Undefined&&t.next!==we.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===we.Undefined&&t.next===we.Undefined?(this._first=we.Undefined,this._last=we.Undefined):t.next===we.Undefined?(this._last=this._last.prev,this._last.next=we.Undefined):t.prev===we.Undefined&&(this._first=this._first.next,this._first.prev=we.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==we.Undefined;)yield t.element,t=t.next}},r_=globalThis.performance&&typeof globalThis.performance.now=="function",n_=class Fd{static create(e){return new Fd(e)}constructor(e){this._now=r_&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},it;(t=>{t.None=()=>J.None;function e(C,k){return d(C,()=>{},0,void 0,!0,void 0,k)}t.defer=e;function s(C){return(k,P=null,$)=>{let T=!1,R;return R=C(F=>{if(!T)return R?R.dispose():T=!0,k.call(P,F)},null,$),T&&R.dispose(),R}}t.once=s;function i(C,k,P){return h(($,T=null,R)=>C(F=>$.call(T,k(F)),null,R),P)}t.map=i;function r(C,k,P){return h(($,T=null,R)=>C(F=>{k(F),$.call(T,F)},null,R),P)}t.forEach=r;function n(C,k,P){return h(($,T=null,R)=>C(F=>k(F)&&$.call(T,F),null,R),P)}t.filter=n;function o(C){return C}t.signal=o;function a(...C){return(k,P=null,$)=>{let T=i_(...C.map(R=>R(F=>k.call(P,F))));return c(T,$)}}t.any=a;function l(C,k,P,$){let T=P;return i(C,R=>(T=k(T,R),T),$)}t.reduce=l;function h(C,k){let P,$={onWillAddFirstListener(){P=C(T.fire,T)},onDidRemoveLastListener(){P==null||P.dispose()}},T=new N($);return k==null||k.add(T),T.event}function c(C,k){return k instanceof Array?k.push(C):k&&k.add(C),C}function d(C,k,P=100,$=!1,T=!1,R,F){let D,G,Q,U=0,te,ae={leakWarningThreshold:R,onWillAddFirstListener(){D=C(de=>{U++,G=k(G,de),$&&!Q&&(fe.fire(G),G=void 0),te=()=>{let z=G;G=void 0,Q=void 0,(!$||U>1)&&fe.fire(z),U=0},typeof P=="number"?(clearTimeout(Q),Q=setTimeout(te,P)):Q===void 0&&(Q=0,queueMicrotask(te))})},onWillRemoveListener(){T&&U>0&&(te==null||te())},onDidRemoveLastListener(){te=void 0,D.dispose()}},fe=new N(ae);return F==null||F.add(fe),fe.event}t.debounce=d;function u(C,k=0,P){return t.debounce(C,($,T)=>$?($.push(T),$):[T],k,void 0,!0,void 0,P)}t.accumulate=u;function f(C,k=($,T)=>$===T,P){let $=!0,T;return n(C,R=>{let F=$||!k(R,T);return $=!1,T=R,F},P)}t.latch=f;function p(C,k,P){return[t.filter(C,k,P),t.filter(C,$=>!k($),P)]}t.split=p;function _(C,k=!1,P=[],$){let T=P.slice(),R=C(G=>{T?T.push(G):D.fire(G)});$&&$.add(R);let F=()=>{T==null||T.forEach(G=>D.fire(G)),T=null},D=new N({onWillAddFirstListener(){R||(R=C(G=>D.fire(G)),$&&$.add(R))},onDidAddFirstListener(){T&&(k?setTimeout(F):F())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return $&&$.add(D),D.event}t.buffer=_;function g(C,k){return(P,$,T)=>{let R=k(new y);return C(function(F){let D=R.evaluate(F);D!==m&&P.call($,D)},void 0,T)}}t.chain=g;let m=Symbol("HaltChainable");class y{constructor(){this.steps=[]}map(k){return this.steps.push(k),this}forEach(k){return this.steps.push(P=>(k(P),P)),this}filter(k){return this.steps.push(P=>k(P)?P:m),this}reduce(k,P){let $=P;return this.steps.push(T=>($=k($,T),$)),this}latch(k=(P,$)=>P===$){let P=!0,$;return this.steps.push(T=>{let R=P||!k(T,$);return P=!1,$=T,R?T:m}),this}evaluate(k){for(let P of this.steps)if(k=P(k),k===m)break;return k}}function v(C,k,P=$=>$){let $=(...D)=>F.fire(P(...D)),T=()=>C.on(k,$),R=()=>C.removeListener(k,$),F=new N({onWillAddFirstListener:T,onDidRemoveLastListener:R});return F.event}t.fromNodeEventEmitter=v;function b(C,k,P=$=>$){let $=(...D)=>F.fire(P(...D)),T=()=>C.addEventListener(k,$),R=()=>C.removeEventListener(k,$),F=new N({onWillAddFirstListener:T,onDidRemoveLastListener:R});return F.event}t.fromDOMEventEmitter=b;function S(C){return new Promise(k=>s(C)(k))}t.toPromise=S;function x(C){let k=new N;return C.then(P=>{k.fire(P)},()=>{k.fire(void 0)}).finally(()=>{k.dispose()}),k.event}t.fromPromise=x;function M(C,k){return C(P=>k.fire(P))}t.forward=M;function O(C,k,P){return k(P),C($=>k($))}t.runAndSubscribe=O;class B{constructor(k,P){this._observable=k,this._counter=0,this._hasChanged=!1;let $={onWillAddFirstListener:()=>{k.addObserver(this)},onDidRemoveLastListener:()=>{k.removeObserver(this)}};this.emitter=new N($),P&&P.add(this.emitter)}beginUpdate(k){this._counter++}handlePossibleChange(k){}handleChange(k,P){this._hasChanged=!0}endUpdate(k){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function I(C,k){return new B(C,k).emitter.event}t.fromObservable=I;function L(C){return(k,P,$)=>{let T=0,R=!1,F={beginUpdate(){T++},endUpdate(){T--,T===0&&(C.reportChanges(),R&&(R=!1,k.call(P)))},handlePossibleChange(){},handleChange(){R=!0}};C.addObserver(F),C.reportChanges();let D={dispose(){C.removeObserver(F)}};return $ instanceof gs?$.add(D):Array.isArray($)&&$.push(D),D}}t.fromObservableLight=L})(it||(it={}));var Fo=class $o{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${$o._idPool++}`,$o.all.add(this)}start(e){this._stopWatch=new n_,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Fo.all=new Set,Fo._idPool=0;var o_=Fo,a_=-1,$d=class Nd{constructor(e,s,i=(Nd._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new c_(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[i,r]of this._stacks)(!e||s<r)&&(e=[i,r],s=r);return e}};$d._idPool=1;var h_=$d,l_=class Hd{constructor(e){this.value=e}static create(){let e=new Error;return new Hd(e.stack??"")}print(){console.warn(this.value.split(`
22
+ `).slice(2).join(`
23
+ `))}},c_=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},d_=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},u_=0,Ln=class{constructor(t){this.value=t,this.id=u_++}},f_=2,p_,N=class{constructor(e){var s,i,r,n;this._size=0,this._options=e,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new h_((e==null?void 0:e.onListenerError)??Wr,((i=this._options)==null?void 0:i.leakWarningThreshold)??a_):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new o_(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var e,s,i,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,s,i)=>{var a,l,h,c,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new d_(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((a=this._options)==null?void 0:a.onListenerError)||Wr)(p),J.None}if(this._disposed)return J.None;s&&(e=e.bind(s));let r=new Ln(e),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=l_.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ln?(this._deliveryQueue??(this._deliveryQueue=new __),this._listeners=[this._listeners,r]):this._listeners.push(r):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=r,(d=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||d.call(c,this)),this._size++;let o=be(()=>{n==null||n(),this._removeListener(r)});return i instanceof gs?i.add(o):Array.isArray(i)&&i.push(o),o}),this._event}_removeListener(e){var n,o,a,l;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||l.call(a,this),this._size=0;return}let s=this._listeners,i=s.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*f_<=s.length){let h=0;for(let c=0;c<s.length;c++)s[c]?s[h++]=s[c]:r&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=h}}_deliver(e,s){var r;if(!e)return;let i=((r=this._options)==null?void 0:r.onListenerError)||Wr;if(!i){e.value(s);return}try{e.value(s)}catch(n){i(n)}}_deliverQueue(e){let s=e.current._listeners;for(;e.i<e.end;)this._deliver(s[e.i++],e.value);e.reset()}fire(e){var s,i,r,n;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof Ln)this._deliver(this._listeners,e);else{let o=this._deliveryQueue;o.enqueue(this,e,this._listeners.length),this._deliverQueue(o)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},__=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},No=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new N,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new N,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};No.INSTANCE=new No;var ja=No;function m_(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}ja.INSTANCE.onDidChangeZoomLevel;function g_(t){return ja.INSTANCE.getZoomFactor(t)}ja.INSTANCE.onDidChangeFullscreen;var yi=typeof navigator=="object"?navigator.userAgent:"",Ho=yi.indexOf("Firefox")>=0,y_=yi.indexOf("AppleWebKit")>=0,Xa=yi.indexOf("Chrome")>=0,v_=!Xa&&yi.indexOf("Safari")>=0;yi.indexOf("Electron/")>=0;yi.indexOf("Android")>=0;var In=!1;if(typeof Qt.matchMedia=="function"){let t=Qt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Qt.matchMedia("(display-mode: fullscreen)");In=t.matches,m_(Qt,t,({matches:s})=>{In&&e.matches||(In=s)})}var ii="en",Wo=!1,zo=!1,zr=!1,Wd=!1,_r,Gr=ii,Dh=ii,b_,Rt,Hs=globalThis,et,_d;typeof Hs.vscode<"u"&&typeof Hs.vscode.process<"u"?et=Hs.vscode.process:typeof process<"u"&&typeof((_d=process==null?void 0:process.versions)==null?void 0:_d.node)=="string"&&(et=process);var md,w_=typeof((md=et==null?void 0:et.versions)==null?void 0:md.electron)=="string",x_=w_&&(et==null?void 0:et.type)==="renderer",gd;if(typeof et=="object"){Wo=et.platform==="win32",zo=et.platform==="darwin",zr=et.platform==="linux",zr&&et.env.SNAP&&et.env.SNAP_REVISION,et.env.CI||et.env.BUILD_ARTIFACTSTAGINGDIRECTORY,_r=ii,Gr=ii;let t=et.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);_r=e.userLocale,Dh=e.osLocale,Gr=e.resolvedLanguage||ii,b_=(gd=e.languagePack)==null?void 0:gd.translationsConfigFile}catch{}Wd=!0}else typeof navigator=="object"&&!x_?(Rt=navigator.userAgent,Wo=Rt.indexOf("Windows")>=0,zo=Rt.indexOf("Macintosh")>=0,(Rt.indexOf("Macintosh")>=0||Rt.indexOf("iPad")>=0||Rt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,zr=Rt.indexOf("Linux")>=0,(Rt==null?void 0:Rt.indexOf("Mobi"))>=0,Gr=globalThis._VSCODE_NLS_LANGUAGE||ii,_r=navigator.language.toLowerCase(),Dh=_r):console.error("Unable to resolve platform.");var zd=Wo,qt=zo,S_=zr,Oh=Wd,Yt=Rt,os=Gr,C_;(t=>{function e(){return os}t.value=e;function s(){return os.length===2?os==="en":os.length>=3?os[0]==="e"&&os[1]==="n"&&os[2]==="-":!1}t.isDefaultVariant=s;function i(){return os==="en"}t.isDefault=i})(C_||(C_={}));var k_=typeof Hs.postMessage=="function"&&!Hs.importScripts;(()=>{if(k_){let t=[];Hs.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=t.length;i<r;i++){let n=t[i];if(n.id===s.data.vscodeScheduleAsyncWork){t.splice(i,1),n.callback();return}}});let e=0;return s=>{let i=++e;t.push({id:i,callback:s}),Hs.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var M_=!!(Yt&&Yt.indexOf("Chrome")>=0);Yt&&Yt.indexOf("Firefox")>=0;!M_&&Yt&&Yt.indexOf("Safari")>=0;Yt&&Yt.indexOf("Edg/")>=0;Yt&&Yt.indexOf("Android")>=0;var Ys=typeof navigator=="object"?navigator:{};Oh||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ys&&Ys.clipboard&&Ys.clipboard.writeText,Oh||Ys&&Ys.clipboard&&Ys.clipboard.readText;var Za=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Dn=new Za,Fh=new Za,$h=new Za,T_=new Array(230),Gd;(t=>{function e(a){return Dn.keyCodeToStr(a)}t.toString=e;function s(a){return Dn.strToKeyCode(a)}t.fromString=s;function i(a){return Fh.keyCodeToStr(a)}t.toUserSettingsUS=i;function r(a){return $h.keyCodeToStr(a)}t.toUserSettingsGeneral=r;function n(a){return Fh.strToKeyCode(a)||$h.strToKeyCode(a)}t.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Dn.keyCodeToStr(a)}t.toElectronAccelerator=o})(Gd||(Gd={}));var E_=class Ud{constructor(e,s,i,r,n){this.ctrlKey=e,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=n}equals(e){return e instanceof Ud&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new P_([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},P_=class{constructor(t){if(t.length===0)throw e_("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function A_(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return Gd.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(Ho)switch(e){case 59:return 85;case 60:if(S_)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(qt)return 57;break}else if(y_&&(qt&&e===93||!qt&&e===92))return 57;return T_[e]||0}var R_=qt?256:2048,B_=512,L_=1024,I_=qt?2048:256,Nh=class{constructor(t){var s;this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=(s=e.getModifierState)==null?void 0:s.call(e,"AltGraph"),this.keyCode=A_(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=R_),this.altKey&&(e|=B_),this.shiftKey&&(e|=L_),this.metaKey&&(e|=I_),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new E_(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},Hh=new WeakMap;function D_(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var O_=class{static getSameOriginWindowChain(t){let e=Hh.get(t);if(!e){e=[],Hh.set(t,e);let s=t,i;do i=D_(s),i?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(t);for(let n of r){let o=n.window.deref();if(s+=(o==null?void 0:o.scrollY)??0,i+=(o==null?void 0:o.scrollX)??0,o===e||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();s+=a.top,i+=a.left}return{top:s,left:i}}},mr=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=O_.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Wh=class{constructor(t,e=0,s=0){var r;this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let i=!1;if(Xa){let n=navigator.userAgent.match(/Chrome\/(\d+)/);i=(n?parseInt(n[1]):123)<=122}if(t){let n=t,o=t,a=((r=t.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")i?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Ho&&!qt?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof n.wheelDeltaX<"u")v_&&zd?this.deltaX=-(n.wheelDeltaX/120):i?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Ho&&!qt?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(i?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){var t;(t=this.browserEvent)==null||t.preventDefault()}stopPropagation(){var t;(t=this.browserEvent)==null||t.stopPropagation()}},qd=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),F_;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof $_?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:it.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:qd})})(F_||(F_={}));var $_=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?qd:(this._emitter||(this._emitter=new N),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ja=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new Io("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new Io("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},N_=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var t;(t=this.disposable)==null||t.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new Io("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{t()},e);this.disposable=be(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},H_;(t=>{async function e(i){let r,n=await Promise.all(i.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}t.settled=e;function s(i){return new Promise(async(r,n)=>{try{await i(r,n)}catch(o){n(o)}})}t.withAsyncBody=s})(H_||(H_={}));var zh=class wt{static fromArray(e){return new wt(s=>{s.emitMany(e)})}static fromPromise(e){return new wt(async s=>{s.emitMany(await e)})}static fromPromises(e){return new wt(async s=>{await Promise.all(e.map(async i=>s.emitOne(await i)))})}static merge(e){return new wt(async s=>{await Promise.all(e.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new N,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await it.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(e,s){return new wt(async i=>{for await(let r of e)i.emitOne(s(r))})}map(e){return wt.map(this,e)}static filter(e,s){return new wt(async i=>{for await(let r of e)s(r)&&i.emitOne(r)})}filter(e){return wt.filter(this,e)}static coalesce(e){return wt.filter(e,s=>!!s)}coalesce(){return wt.coalesce(this)}static async toPromise(e){let s=[];for await(let i of e)s.push(i);return s}toPromise(){return wt.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};zh.EMPTY=zh.fromArray([]);var{getWindow:Ut,getWindowId:W_,onDidRegisterWindow:z_}=(function(){let t=new Map,e={window:Qt,disposables:new gs};t.set(Qt.vscodeWindowId,e);let s=new N,i=new N,r=new N;function n(o,a){return(typeof o=="number"?t.get(o):void 0)??(a?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(o){if(t.has(o.vscodeWindowId))return J.None;let a=new gs,l={window:o,disposables:a.add(new gs)};return t.set(o.vscodeWindowId,l),a.add(be(()=>{t.delete(o.vscodeWindowId),i.fire(o)})),a.add(Y(o,qe.BEFORE_UNLOAD,()=>{r.fire(o)})),s.fire(l),a},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:n,getWindow(o){var h;let a=o;if((h=a==null?void 0:a.ownerDocument)!=null&&h.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l!=null&&l.view?l.view.window:Qt},getDocument(o){return Ut(o).document}}})(),G_=class{constructor(t,e,s,i){this._node=t,this._type=e,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Y(t,e,s,i){return new G_(t,e,s,i)}var Gh=function(t,e,s,i){return Y(t,e,s,i)},Qa,U_=class extends N_{constructor(t){super(),this.defaultTarget=t&&Ut(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},Uh=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){Wr(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,i=new Map,r=n=>{s.set(n,!1);let o=t.get(n)??[];for(e.set(n,o),t.set(n,[]),i.set(n,!0);o.length>0;)o.sort(Uh.sort),o.shift().execute();i.set(n,!1)};Qa=(n,o,a=0)=>{let l=W_(n),h=new Uh(o,a),c=t.get(l);return c||(c=[],t.set(l,c)),c.push(h),s.get(l)||(s.set(l,!0),n.requestAnimationFrame(()=>r(l))),h}})();function q_(t){let e=t.getBoundingClientRect(),s=Ut(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var qe={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},V_=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=ct(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=ct(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=ct(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=ct(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=ct(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=ct(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=ct(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=ct(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=ct(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=ct(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=ct(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=ct(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=ct(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=ct(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function ct(t){return typeof t=="number"?`${t}px`:t}function zi(t){return new V_(t)}var Vd=class{constructor(){this._hooks=new gs,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let n=t;try{t.setPointerCapture(e),this._hooks.add(be(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{n=Ut(t)}this._hooks.add(Y(n,qe.POINTER_MOVE,o=>{if(o.buttons!==s){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Y(n,qe.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Y_(t,e,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let n=`$memoize$${e}`;s[i]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Nt;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(Nt||(Nt={}));var Di=class rt extends J{constructor(){super(),this.dispatched=!1,this.targets=new Ih,this.ignoreTargets=new Ih,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(it.runAndSubscribe(z_,({window:e,disposables:s})=>{s.add(Y(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Y(e.document,"touchend",i=>this.onTouchEnd(e,i))),s.add(Y(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Qt,disposables:this._store}))}static addTarget(e){if(!rt.isTouchDevice())return J.None;rt.INSTANCE||(rt.INSTANCE=new rt);let s=rt.INSTANCE.targets.push(e);return be(s)}static ignoreTarget(e){if(!rt.isTouchDevice())return J.None;rt.INSTANCE||(rt.INSTANCE=new rt);let s=rt.INSTANCE.ignoreTargets.push(e);return be(s)}static isTouchDevice(){return"ontouchstart"in Qt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=e.targetTouches.length;i<r;i++){let n=e.targetTouches.item(i);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:s,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[s],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(Nt.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=s.changedTouches.length;n<o;n++){let a=s.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<rt.HOLD_DELAY&&Math.abs(l.initialPageX-_t(l.rollingPageX))<30&&Math.abs(l.initialPageY-_t(l.rollingPageY))<30){let c=this.newGestureEvent(Nt.Tap,l.initialTarget);c.pageX=_t(l.rollingPageX),c.pageY=_t(l.rollingPageY),this.dispatchEvent(c)}else if(h>=rt.HOLD_DELAY&&Math.abs(l.initialPageX-_t(l.rollingPageX))<30&&Math.abs(l.initialPageY-_t(l.rollingPageY))<30){let c=this.newGestureEvent(Nt.Contextmenu,l.initialTarget);c.pageX=_t(l.rollingPageX),c.pageY=_t(l.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=_t(l.rollingPageX),d=_t(l.rollingPageY),u=_t(l.rollingTimestamps)-l.rollingTimestamps[0],f=c-l.rollingPageX[0],p=d-l.rollingPageY[0],_=[...this.targets].filter(g=>l.initialTarget instanceof Node&&g.contains(l.initialTarget));this.inertia(e,_,i,Math.abs(f)/u,f>0?1:-1,c,Math.abs(p)/u,p>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Nt.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(e){if(e.type===Nt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>rt.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,e.tapCount=i}else(e.type===Nt.Change||e.type===Nt.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(e.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(e.initialTarget)){let r=0,n=e.initialTarget;for(;n&&n!==i;)r++,n=n.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,i,r,n,o,a,l,h){this.handle=Qa(e,()=>{let c=Date.now(),d=c-i,u=0,f=0,p=!0;r+=rt.SCROLL_FRICTION*d,a+=rt.SCROLL_FRICTION*d,r>0&&(p=!1,u=n*r*d),a>0&&(p=!1,f=l*a*d);let _=this.newGestureEvent(Nt.Change);_.translationX=u,_.translationY=f,s.forEach(g=>g.dispatchEvent(_)),p||this.inertia(e,s,c,r,n,o+u,a,l,h+f)})}onTouchMove(e){let s=Date.now();for(let i=0,r=e.changedTouches.length;i<r;i++){let n=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(Nt.Change,o.initialTarget);a.translationX=n.pageX-_t(o.rollingPageX),a.translationY=n.pageY-_t(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};Di.SCROLL_FRICTION=-.005,Di.HOLD_DELAY=700,Di.CLEAR_TAP_COUNT_TIME=400,Pe([Y_],Di,"isTouchDevice",1);var K_=Di,eh=class extends J{onclick(t,e){this._register(Y(t,qe.CLICK,s=>e(new mr(Ut(t),s))))}onmousedown(t,e){this._register(Y(t,qe.MOUSE_DOWN,s=>e(new mr(Ut(t),s))))}onmouseover(t,e){this._register(Y(t,qe.MOUSE_OVER,s=>e(new mr(Ut(t),s))))}onmouseleave(t,e){this._register(Y(t,qe.MOUSE_LEAVE,s=>e(new mr(Ut(t),s))))}onkeydown(t,e){this._register(Y(t,qe.KEY_DOWN,s=>e(new Nh(s))))}onkeyup(t,e){this._register(Y(t,qe.KEY_UP,s=>e(new Nh(s))))}oninput(t,e){this._register(Y(t,qe.INPUT,e))}onblur(t,e){this._register(Y(t,qe.BLUR,e))}onfocus(t,e){this._register(Y(t,qe.FOCUS,e))}onchange(t,e){this._register(Y(t,qe.CHANGE,e))}ignoreGesture(t){return K_.ignoreTarget(t)}},qh=11,j_=class extends eh{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=qh+"px",this.domNode.style.height=qh+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new Vd),this._register(Gh(this.bgDomNode,qe.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Gh(this.domNode,qe.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new U_),this._pointerdownScheduleRepeatTimer=this._register(new Ja)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ut(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},X_=class Go{constructor(e,s,i,r,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new Go(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new Go(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let i=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},Z_=class extends J{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new X_(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){var i;let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;e?i=new Yh(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=Yh.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},Vh=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function On(t,e){let s=e-t;return function(i){return t+s*em(i)}}function J_(t,e,s){return function(i){return i<s?t(i/s):e((i-s)/(1-s))}}var Yh=class Uo{constructor(e,s,i,r){this.from=e,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,i){if(Math.abs(e-s)>2.5*i){let r,n;return e<s?(r=e+.75*i,n=s-.75*i):(r=e-.75*i,n=s+.75*i),J_(On(e,r),On(n,s),.33)}return On(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new Vh(i,r,!1)}return new Vh(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,i){return Uo.start(e,s,i)}static start(e,s,i){i=i+10;let r=Date.now()-10;return new Uo(e,s,r,i)}};function Q_(t){return Math.pow(t,3)}function em(t){return 1-Q_(1-t)}var tm=class extends J{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Ja)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var t;(t=this._domNode)==null||t.setClassName(this._visibleClassName)},0))}_hide(t){var e;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(e=this._domNode)==null||e.setClassName(this._invisibleClassName+(t?" fade":"")))}},sm=140,Yd=class extends eh{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new tm(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Vd),this._shouldRender=!0,this.domNode=zi(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Y(this.domNode.domNode,qe.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new j_(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,i){this.slider=zi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Y(this.slider.domNode,qe.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),i=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(t);s<=r&&r<=i?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let r=q_(this.domNode.domNode);e=t.pageX-r.left,s=t.pageY-r.top}let i=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-s);if(zd&&o>sm){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let a=this._sliderPointerPosition(r)-e;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Kd=class qo{constructor(e,s,i,r,n,o){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new qo(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,i,r,n){let o=Math.max(0,i-e),a=Math.max(0,o-2*s),l=r>0&&r>i;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(i*a/r))),c=(a-h)/(r-i),d=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let e=qo._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},im=class extends Yd{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Kd(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},rm=class extends Yd{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Kd(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},nm=500,Kh=50,om=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},Vo=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,i=1,r=this._rear;do{let n=r===this._front?e:Math.pow(2,-i);if(e-=n,s+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(Xa){let s=Ut(e.browserEvent),i=g_(s);this.accept(Date.now(),e.deltaX*i,e.deltaY*i)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,i){let r=null,n=new om(e,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),s){let r=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(s.deltaX),a=Math.abs(s.deltaY),l=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,a),1),c=Math.max(r,o),d=Math.max(n,a);c%l===0&&d%h===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Vo.INSTANCE=new Vo;var am=Vo,hm=class extends eh{constructor(t,e,s){super(),this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new N),this.onWillScroll=this._onWillScroll.event,this._options=cm(e),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new rm(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new im(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=zi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=zi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=zi(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Ja),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=zs(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,qt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new Wh(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=zs(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new Wh(s))};this._mouseWheelToDispose.push(Y(this._listenOnDomNode,qe.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){var r;if((r=t.browserEvent)!=null&&r.defaultPrevented)return;let e=am.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let n=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!qt&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),h={};if(n){let c=Kh*n,d=l.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(h,d)}if(o){let c=Kh*o,d=l.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(h,d)}h=this._scrollable.validateScrollPosition(h),(l.scrollLeft!==h.scrollLeft||l.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,i=s?" left":"",r=e?" top":"",n=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),nm)}},lm=class extends hm{constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function cm(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,qt&&(e.className+=" mac"),e}var Yo=class extends J{constructor(t,e,s,i,r,n,o,a){super(),this._bufferService=s,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new N),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new Z_({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Qa(i.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new lm(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(it.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(be(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(be(()=>this._styleElement.remove())),this._register(it.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
24
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var t;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((t=this._optionsService.rawOptions.overviewRuler)==null?void 0:t.width)||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Yo=Pe([W(2,ht),W(3,is),W(4,Ed),W(5,gi),W(6,lt),W(7,rs)],Yo);var Ko=class extends J{constructor(t,e,s,i,r){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,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(n=>this._removeDecoration(n))),this._register(be(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){var i;let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",((i=t==null?void 0:t.options)==null?void 0:i.layer)==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){var e;(e=this._decorationElements.get(t))==null||e.remove(),this._decorationElements.delete(t),t.dispose()}};Ko=Pe([W(1,ht),W(2,is),W(3,ar),W(4,rs)],Ko);var dm=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(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},Ot={full:0,left:0,center:0,right:0},as={full:0,left:0,center:0,right:0},bi={full:0,left:0,center:0,right:0},Jr=class extends J{constructor(t,e,s,i,r,n,o,a){var h;super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new dm,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(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(be(()=>{var c;return(c=this._canvas)==null?void 0:c.remove()}));let l=this._canvas.getContext("2d");if(l)this._ctx=l;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var t;return((t=this._optionsService.options.overviewRuler)==null?void 0:t.width)||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);as.full=this._canvas.width,as.left=t,as.center=e,as.right=t,this._refreshDrawHeightConstants(),bi.full=1,bi.left=1,bi.center=1+as.left,bi.right=1+as.left+as.center}_refreshDrawHeightConstants(){Ot.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);Ot.left=e,Ot.center=e,Ot.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ot.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ot.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ot.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ot.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(bi[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-Ot[t.position||"full"]/2),as[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ot[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Jr=Pe([W(2,ht),W(3,ar),W(4,rs),W(5,lt),W(6,gi),W(7,is)],Jr);var A;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
25
+ `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(A||(A={}));var Ur;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(Ur||(Ur={}));var jd;(t=>t.ST=`${A.ESC}\\`)(jd||(jd={}));var jo=class{constructor(t,e,s,i,r,n){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${A.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};jo=Pe([W(2,ht),W(3,lt),W(4,qs),W(5,rs)],jo);var Ve=0,Ye=0,Ke=0,ke=0,jh={css:"#00000000",rgba:0},De;(t=>{function e(r,n,o,a){return a!==void 0?`#${Ss(r)}${Ss(n)}${Ss(o)}${Ss(a)}`:`#${Ss(r)}${Ss(n)}${Ss(o)}`}t.toCss=e;function s(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}t.toRgba=s;function i(r,n,o,a){return{css:t.toCss(r,n,o,a),rgba:t.toRgba(r,n,o,a)}}t.toColor=i})(De||(De={}));var ge;(t=>{function e(l,h){if(ke=(h.rgba&255)/255,ke===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,d=h.rgba>>16&255,u=h.rgba>>8&255,f=l.rgba>>24&255,p=l.rgba>>16&255,_=l.rgba>>8&255;Ve=f+Math.round((c-f)*ke),Ye=p+Math.round((d-p)*ke),Ke=_+Math.round((u-_)*ke);let g=De.toCss(Ve,Ye,Ke),m=De.toRgba(Ve,Ye,Ke);return{css:g,rgba:m}}t.blend=e;function s(l){return(l.rgba&255)===255}t.isOpaque=s;function i(l,h,c){let d=qr.ensureContrastRatio(l.rgba,h.rgba,c);if(d)return De.toColor(d>>24&255,d>>16&255,d>>8&255)}t.ensureContrastRatio=i;function r(l){let h=(l.rgba|255)>>>0;return[Ve,Ye,Ke]=qr.toChannels(h),{css:De.toCss(Ve,Ye,Ke),rgba:h}}t.opaque=r;function n(l,h){return ke=Math.round(h*255),[Ve,Ye,Ke]=qr.toChannels(l.rgba),{css:De.toCss(Ve,Ye,Ke,ke),rgba:De.toRgba(Ve,Ye,Ke,ke)}}t.opacity=n;function o(l,h){return ke=l.rgba&255,n(l,ke*h/255)}t.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}t.toColorRGB=a})(ge||(ge={}));var xe;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ve=parseInt(r.slice(1,2).repeat(2),16),Ye=parseInt(r.slice(2,3).repeat(2),16),Ke=parseInt(r.slice(3,4).repeat(2),16),De.toColor(Ve,Ye,Ke);case 5:return Ve=parseInt(r.slice(1,2).repeat(2),16),Ye=parseInt(r.slice(2,3).repeat(2),16),Ke=parseInt(r.slice(3,4).repeat(2),16),ke=parseInt(r.slice(4,5).repeat(2),16),De.toColor(Ve,Ye,Ke,ke);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ve=parseInt(n[1]),Ye=parseInt(n[2]),Ke=parseInt(n[3]),ke=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),De.toColor(Ve,Ye,Ke,ke);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Ve,Ye,Ke,ke]=e.getImageData(0,0,1,1).data,ke!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:De.toRgba(Ve,Ye,Ke,ke),css:r}}t.toColor=i})(xe||(xe={}));var ot;(t=>{function e(i){return s(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function s(i,r,n){let o=i/255,a=r/255,l=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+d*.0722}t.relativeLuminance2=s})(ot||(ot={}));var qr;(t=>{function e(o,a){if(ke=(a&255)/255,ke===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,f=o>>8&255;return Ve=d+Math.round((l-d)*ke),Ye=u+Math.round((h-u)*ke),Ke=f+Math.round((c-f)*ke),De.toRgba(Ve,Ye,Ke)}t.blend=e;function s(o,a,l){let h=ot.relativeLuminance(o>>8),c=ot.relativeLuminance(a>>8);if(Kt(h,c)<l){if(c<h){let f=i(o,a,l),p=Kt(h,ot.relativeLuminance(f>>8));if(p<l){let _=r(o,a,l),g=Kt(h,ot.relativeLuminance(_>>8));return p>g?f:_}return f}let d=r(o,a,l),u=Kt(h,ot.relativeLuminance(d>>8));if(u<l){let f=i(o,a,l),p=Kt(h,ot.relativeLuminance(f>>8));return u>p?d:f}return d}}t.ensureContrastRatio=s;function i(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,p=a>>8&255,_=Kt(ot.relativeLuminance2(u,f,p),ot.relativeLuminance2(h,c,d));for(;_<l&&(u>0||f>0||p>0);)u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),p-=Math.max(0,Math.ceil(p*.1)),_=Kt(ot.relativeLuminance2(u,f,p),ot.relativeLuminance2(h,c,d));return(u<<24|f<<16|p<<8|255)>>>0}t.reduceLuminance=i;function r(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,p=a>>8&255,_=Kt(ot.relativeLuminance2(u,f,p),ot.relativeLuminance2(h,c,d));for(;_<l&&(u<255||f<255||p<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),_=Kt(ot.relativeLuminance2(u,f,p),ot.relativeLuminance2(h,c,d));return(u<<24|f<<16|p<<8|255)>>>0}t.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=n})(qr||(qr={}));function Ss(t){let e=t.toString(16);return e.length<2?"0"+e:e}function Kt(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var um=class extends or{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Qr=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Et}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],i=e.translateToString(!0),r=0,n=0,o=0,a=e.getFg(0),l=e.getBg(0);for(let h=0;h<e.getTrimmedLength();h++)if(e.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-r>1){let c=this._getJoinedRanges(i,o,n,e,r);for(let d=0;d<c.length;d++)s.push(c[d])}r=h,o=n,a=this._workCell.fg,l=this._workCell.bg}n+=this._workCell.getChars().length||ps.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(i,o,n,e,r);for(let c=0;c<h.length;c++)s.push(h[c])}return s}_getJoinedRanges(t,e,s,i,r){let n=t.substring(e,s),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let l=this._characterJoiners[a].handler(n);for(let h=0;h<l.length;h++)Qr._mergeRanges(o,l[h])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,i,r),o}_stringRangesToCellRanges(t,e,s){let i=0,r=!1,n=0,o=t[i];if(o){for(let a=s;a<this._bufferService.cols;a++){let l=e.getWidth(a),h=e.getString(a).length||ps.length;if(l!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=t[++i],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let i=0;i<t.length;i++){let r=t[i];if(s){if(e[1]<=r[0])return t[i-1][1]=e[1],t;if(e[1]<=r[1])return t[i-1][1]=Math.max(e[1],r[1]),t.splice(i,1),t;t.splice(i,1),i--}else{if(e[1]<=r[0])return t.splice(i,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Qr=Pe([W(0,ht)],Qr);function fm(t){return 57508<=t&&t<=57558}function pm(t){return 9472<=t&&t<=9631}function _m(t){return fm(t)||pm(t)}function mm(){return{css:{canvas:gr(),cell:gr()},device:{canvas:gr(),cell:gr(),char:{width:0,height:0,left:0,top:0}}}}function gr(){return{width:0,height:0}}var Xo=class{constructor(t,e,s,i,r,n,o){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new Et,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,i,r,n,o,a,l,h,c){let d=[],u=this._characterJoinerService.getJoinedCharacters(e),f=this._themeService.colors,p=t.getNoBgTrimmedLength();s&&p<n+1&&(p=n+1);let _,g=0,m="",y=0,v=0,b=0,S=0,x=!1,M=0,O=!1,B=0,I=0,L=[],C=h!==-1&&c!==-1;for(let k=0;k<p;k++){t.loadCell(k,this._workCell);let P=this._workCell.getWidth();if(P===0)continue;let $=!1,T=k>=I,R=k,F=this._workCell;if(u.length>0&&k===u[0][0]&&T){let q=u.shift(),me=this._isCellInSelection(q[0],e);for(y=q[0]+1;y<q[1];y++)T&&(T=me===this._isCellInSelection(y,e));T&&(T=!s||n<q[0]||n>=q[1]),T?($=!0,F=new um(this._workCell,t.translateToString(!0,q[0],q[1]),q[1]-q[0]),R=q[1]-1,P=F.getWidth()):I=q[1]}let D=this._isCellInSelection(k,e),G=s&&k===n,Q=C&&k>=h&&k<=c,U=!1;this._decorationService.forEachDecorationAtCell(k,e,void 0,q=>{U=!0});let te=F.getChars()||ps;if(te===" "&&(F.isUnderline()||F.isOverline())&&(te=" "),B=P*a-l.get(te,F.isBold(),F.isItalic()),!_)_=this._document.createElement("span");else if(g&&(D&&O||!D&&!O&&F.bg===v)&&(D&&O&&f.selectionForeground||F.fg===b)&&F.extended.ext===S&&Q===x&&B===M&&!G&&!$&&!U&&T){F.isInvisible()?m+=ps:m+=te,g++;continue}else g&&(_.textContent=m),_=this._document.createElement("span"),g=0,m="";if(v=F.bg,b=F.fg,S=F.extended.ext,x=Q,M=B,O=D,$&&n>=k&&n<=R&&(n=k),!this._coreService.isCursorHidden&&G&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&L.push("xterm-cursor-blink"),L.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":L.push("xterm-cursor-outline");break;case"block":L.push("xterm-cursor-block");break;case"bar":L.push("xterm-cursor-bar");break;case"underline":L.push("xterm-cursor-underline");break}}if(F.isBold()&&L.push("xterm-bold"),F.isItalic()&&L.push("xterm-italic"),F.isDim()&&L.push("xterm-dim"),F.isInvisible()?m=ps:m=F.getChars()||ps,F.isUnderline()&&(L.push(`xterm-underline-${F.extended.underlineStyle}`),m===" "&&(m=" "),!F.isUnderlineColorDefault()))if(F.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${or.toColorRGB(F.getUnderlineColor()).join(",")})`;else{let q=F.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&F.isBold()&&q<8&&(q+=8),_.style.textDecorationColor=f.ansi[q].css}F.isOverline()&&(L.push("xterm-overline"),m===" "&&(m=" ")),F.isStrikethrough()&&L.push("xterm-strikethrough"),Q&&(_.style.textDecoration="underline");let ae=F.getFgColor(),fe=F.getFgColorMode(),de=F.getBgColor(),z=F.getBgColorMode(),K=!!F.isInverse();if(K){let q=ae;ae=de,de=q;let me=fe;fe=z,z=me}let he,Be,_e=!1;this._decorationService.forEachDecorationAtCell(k,e,void 0,q=>{q.options.layer!=="top"&&_e||(q.backgroundColorRGB&&(z=50331648,de=q.backgroundColorRGB.rgba>>8&16777215,he=q.backgroundColorRGB),q.foregroundColorRGB&&(fe=50331648,ae=q.foregroundColorRGB.rgba>>8&16777215,Be=q.foregroundColorRGB),_e=q.options.layer==="top")}),!_e&&D&&(he=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,de=he.rgba>>8&16777215,z=50331648,_e=!0,f.selectionForeground&&(fe=50331648,ae=f.selectionForeground.rgba>>8&16777215,Be=f.selectionForeground)),_e&&L.push("xterm-decoration-top");let ne;switch(z){case 16777216:case 33554432:ne=f.ansi[de],L.push(`xterm-bg-${de}`);break;case 50331648:ne=De.toColor(de>>16,de>>8&255,de&255),this._addStyle(_,`background-color:#${Xh((de>>>0).toString(16),"0",6)}`);break;case 0:default:K?(ne=f.foreground,L.push("xterm-bg-257")):ne=f.background}switch(he||F.isDim()&&(he=ge.multiplyOpacity(ne,.5)),fe){case 16777216:case 33554432:F.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(_,ne,f.ansi[ae],F,he,void 0)||L.push(`xterm-fg-${ae}`);break;case 50331648:let q=De.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(_,ne,q,F,he,Be)||this._addStyle(_,`color:#${Xh(ae.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,ne,f.foreground,F,he,Be)||K&&L.push("xterm-fg-257")}L.length&&(_.className=L.join(" "),L.length=0),!G&&!$&&!U&&T?g++:_.textContent=m,B!==this.defaultSpacing&&(_.style.letterSpacing=`${B}px`),d.push(_),k=R}return _&&g&&(_.textContent=m),d}_applyMinimumContrast(t,e,s,i,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||_m(i.getCode()))return!1;let o=this._getContrastCache(i),a;if(!r&&!n&&(a=o.getColor(e.rgba,s.rgba)),a===void 0){let l=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);a=ge.ensureContrastRatio(r||e,n||s,l),o.setColor((r||e).rgba,(n||s).rgba,a??null)}return a?(this._addStyle(t,`color:${a.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?t>=s[0]&&e>=s[1]&&t<i[0]&&e<=i[1]:t<s[0]&&e>=s[1]&&t>=i[0]&&e<=i[1]:e>s[1]&&e<i[1]||s[1]===i[1]&&e===s[1]&&t>=s[0]&&t<i[0]||s[1]<i[1]&&e===i[1]&&t<i[0]||s[1]<i[1]&&e===s[1]&&t>=s[0]}};Xo=Pe([W(1,Rd),W(2,lt),W(3,is),W(4,qs),W(5,ar),W(6,gi)],Xo);function Xh(t,e,s){for(;t.length<s;)t=e+t;return t}var gm=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=t.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[s,i,r,n],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(n),e.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(t,e,s,i){t===this._font&&e===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(t,e,s){let i=0;if(!e&&!s&&t.length===1&&(i=t.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let o=this._measure(t,0);return o>0&&(this._flat[i]=o),o}let r=t;e&&(r+="B"),s&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;e&&(o|=1),s&&(o|=2),n=this._measure(t,o),n>0&&this._holey.set(r,n)}return n}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},ym=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,i=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let r=t.buffers.active.ydisp,n=e[1]-r,o=s[1]-r,a=Math.max(n,0),l=Math.min(o,t.rows-1);if(a>=t.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function vm(){return new ym}var Fn="xterm-dom-renderer-owner-",bt="xterm-rows",yr="xterm-fg-",Zh="xterm-bg-",wi="xterm-focus",vr="xterm-selection",bm=1,Zo=class extends J{constructor(t,e,s,i,r,n,o,a,l,h,c,d,u,f){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=l,this._optionsService=h,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=f,this._terminalClass=bm++,this._rowElements=[],this._selectionRenderModel=vm(),this.onRequestRedraw=this._register(new N).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(bt),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(vr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=mm(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Xo,document),this._element.classList.add(Fn+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(be(()=>{this._element.classList.remove(Fn+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new gm(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),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/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${bt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,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(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${bt} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${bt} .xterm-dim { color: ${ge.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${i} { 50% { box-shadow: none; }}`,e+=`@keyframes ${r} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${bt}.${wi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${bt}.${wi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${bt}.${wi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${bt} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${bt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${bt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${bt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${bt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${vr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${vr} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${vr} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of t.ansi.entries())e+=`${this._terminalSelector} .${yr}${n} { color: ${o.css}; }${this._terminalSelector} .${yr}${n}.xterm-dim { color: ${ge.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${Zh}${n} { background-color: ${o.css}; }`;e+=`${this._terminalSelector} .${yr}257 { color: ${ge.opaque(t.background).css}; }${this._terminalSelector} .${yr}257.xterm-dim { color: ${ge.multiplyOpacity(ge.opaque(t.background),.5).css}; }${this._terminalSelector} .${Zh}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),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(wi),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(wi),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(s){let l=t[0]>e[0];a.appendChild(this._createSelectionElement(n,l?e[0]:t[0],l?t[0]:e[0],o-n+1))}else{let l=i===n?t[0]:0,h=n===r?e[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,l,h));let c=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,c)),n!==o){let d=r===o?e[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(t,e,s,i=1){let r=this._document.createElement("div"),n=e*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(s-e);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=t;l<=e;l++){let h=l+s.ydisp,c=this._rowElements[l],d=s.lines.get(h);if(!c||!d)break;c.replaceChildren(...this._rowFactory.createRow(d,h,h===i,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Fn}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,i,r,n){s<0&&(t=0),i<0&&(e=0);let o=this._bufferService.rows-1;s=Math.max(Math.min(s,o),0),i=Math.max(Math.min(i,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,l=a.ybase+a.y,h=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=s;f<=i;++f){let p=f+a.ydisp,_=this._rowElements[f],g=a.lines.get(p);if(!_||!g)break;_.replaceChildren(...this._rowFactory.createRow(g,p,p===l,d,u,h,c,this.dimensions.css.cell.width,this._widthCache,n?f===s?t:0:-1,n?(f===i?e:r)-1:-1))}}};Zo=Pe([W(7,Ya),W(8,yn),W(9,lt),W(10,ht),W(11,qs),W(12,is),W(13,gi)],Zo);var Jo=class extends J{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new N),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new xm(this._optionsService))}catch{this._measureStrategy=this._register(new wm(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};Jo=Pe([W(2,lt)],Jo);var Xd=class extends J{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},wm=class extends Xd{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},xm=class extends Xd{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},Sm=class extends J{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Cm(this._window)),this._onDprChange=this._register(new N),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new N),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(it.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Y(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Y(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,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}},Cm=class extends J{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new di),this._onDprChange=this._register(new N),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(be(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Y(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var t;this._outerListener&&((t=this._resolutionMediaMatchList)==null||t.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)}},km=class extends J{constructor(){super(),this.linkProviders=[],this._register(be(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function th(t,e,s){let i=s.getBoundingClientRect(),r=t.getComputedStyle(s),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-i.left-n,e.clientY-i.top-o]}function Mm(t,e,s,i,r,n,o,a,l){if(!n)return;let h=th(t,e,s);if(h)return h[0]=Math.ceil((h[0]+(l?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),i+(l?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h}var Qo=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,i,r){return Mm(window,t,e,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(t,e){let s=th(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Qo=Pe([W(0,rs),W(1,yn)],Qo);var Tm=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},Zd={};Fp(Zd,{getSafariVersion:()=>Pm,isChromeOS:()=>tu,isFirefox:()=>Jd,isIpad:()=>Am,isIphone:()=>Rm,isLegacyEdge:()=>Em,isLinux:()=>sh,isMac:()=>en,isNode:()=>vn,isSafari:()=>Qd,isWindows:()=>eu});var vn=typeof process<"u"&&"title"in process,hr=vn?"node":navigator.userAgent,lr=vn?"node":navigator.platform,Jd=hr.includes("Firefox"),Em=hr.includes("Edge"),Qd=/^((?!chrome|android).)*safari/i.test(hr);function Pm(){if(!Qd)return 0;let t=hr.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var en=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(lr),Am=lr==="iPad",Rm=lr==="iPhone",eu=["Windows","Win16","Win32","WinCE"].includes(lr),sh=lr.indexOf("Linux")>=0,tu=/\bCrOS\b/.test(hr),su=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,s=0,i=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),r=t.timeRemaining(),s*1.5>r){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=r}this.clear()}},Bm=class extends su{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Lm=class extends su{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},tn=!vn&&"requestIdleCallback"in window?Lm:Bm,Im=class{constructor(){this._queue=new tn}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},ea=class extends J{constructor(t,e,s,i,r,n,o,a,l){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new di),this._pausedResizeTask=new Im,this._observerDisposable=this._register(new di),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 N),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new N),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new N),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new N),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Tm((h,c)=>this._renderRows(h,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Dm(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(be(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=be(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.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(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let i=this._syncOutputHandler.flush();i&&(t=Math.min(t,i.start),e=Math.max(e,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,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(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var t,e;this._renderer.value&&((e=(t=this._renderer.value).clearTextureAtlas)==null||e.call(t),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(t,e)}):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){var t;(t=this._renderer.value)==null||t.handleCharSizeChanged()}handleBlur(){var t;(t=this._renderer.value)==null||t.handleBlur()}handleFocus(){var t;(t=this._renderer.value)==null||t.handleFocus()}handleSelectionChanged(t,e,s){var i;this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(t,e,s)}handleCursorMove(){var t;(t=this._renderer.value)==null||t.handleCursorMove()}clear(){var t;(t=this._renderer.value)==null||t.clear()}};ea=Pe([W(2,lt),W(3,yn),W(4,qs),W(5,ar),W(6,ht),W(7,is),W(8,gi)],ea);var Dm=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Om(t,e,s,i){let r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return Nm(r,n,t,e,s,i)+bn(n,e,s,i)+Hm(r,n,t,e,s,i);let o;if(n===e)return o=r>t?"D":"C",Yi(Math.abs(r-t),Vi(o,i));o=n>e?"D":"C";let a=Math.abs(n-e),l=$m(n>e?t:r,s)+(a-1)*s.cols+1+Fm(n>e?r:t);return Yi(l,Vi(o,i))}function Fm(t,e){return t-1}function $m(t,e){return e.cols-t}function Nm(t,e,s,i,r,n){return bn(e,i,r,n).length===0?"":Yi(ru(t,e,t,e-Gs(e,r),!1,r).length,Vi("D",n))}function bn(t,e,s,i){let r=t-Gs(t,s),n=e-Gs(e,s),o=Math.abs(r-n)-Wm(t,e,s);return Yi(o,Vi(iu(t,e),i))}function Hm(t,e,s,i,r,n){let o;bn(e,i,r,n).length>0?o=i-Gs(i,r):o=e;let a=i,l=zm(t,e,s,i,r,n);return Yi(ru(t,o,s,a,l==="C",r).length,Vi(l,n))}function Wm(t,e,s){var o;let i=0,r=t-Gs(t,s),n=e-Gs(e,s);for(let a=0;a<Math.abs(r-n);a++){let l=iu(t,e)==="A"?-1:1;(o=s.buffer.lines.get(r+l*a))!=null&&o.isWrapped&&i++}return i}function Gs(t,e){let s=0,i=e.buffer.lines.get(t),r=i==null?void 0:i.isWrapped;for(;r&&t>=0&&t<e.rows;)s++,i=e.buffer.lines.get(--t),r=i==null?void 0:i.isWrapped;return s}function zm(t,e,s,i,r,n){let o;return bn(s,i,r,n).length>0?o=i-Gs(i,r):o=e,t<s&&o<=i||t>=s&&o<i?"C":"D"}function iu(t,e){return t>e?"A":"B"}function ru(t,e,s,i,r,n){let o=t,a=e,l="";for(;(o!==s||a!==i)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(l+=n.buffer.translateBufferLineToString(a,!1,t,o),o=0,t=0,a++):!r&&o<0&&(l+=n.buffer.translateBufferLineToString(a,!1,0,t+1),o=n.cols-1,t=o,a--);return l+n.buffer.translateBufferLineToString(a,!1,t,o)}function Vi(t,e){let s=e?"O":"[";return A.ESC+s+t}function Yi(t,e){t=Math.floor(t);let s="";for(let i=0;i<t;i++)s+=e;return s}var Gm=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Jh(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var $n=50,Um=15,qm=50,Vm=500,Ym=" ",Km=new RegExp(Ym,"g"),ta=class extends J{constructor(t,e,s,i,r,n,o,a,l){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Et,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new N),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new N),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new N),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new N),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new Gm(this._bufferService),this._activeSelectionMode=0,this._register(be(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let r=t[0]<e[0]?t[0]:e[0],n=t[0]<e[0]?e[0]:t[0];for(let o=t[1];o<=e[1];o++){let a=s.translateBufferLineToString(o,!0,r,n);i.push(a)}}else{let r=t[1]===e[1]?e[0]:void 0;i.push(s.translateBufferLineToString(t[1],!0,t[0],r));for(let n=t[1]+1;n<=e[1]-1;n++){let o=s.lines.get(n),a=s.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?i[i.length-1]+=a:i.push(a)}if(t[1]!==e[1]){let n=s.lines.get(e[1]),o=s.translateBufferLineToString(e[1],!0,0,e[0]);n&&n.isWrapped?i[i.length-1]+=o:i.push(o)}}return i.map(r=>r.replace(Km," ")).join(eu?`\r
26
+ `:`
27
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),sh&&t&&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(t){let e=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!e?!1:this._areCoordsInSelection(e,s,i)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([t,e],s,i)}_areCoordsInSelection(t,e,s){return t[1]>e[1]&&t[1]<s[1]||e[1]===s[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<s[0]||e[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||e[1]<s[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){var r,n;let s=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Jh(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(t);return i?(this._selectWordAt(i,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=th(this._coreBrowserService.window,t,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=s?0:(e>s&&(e-=s),e=Math.min(Math.max(e,-$n),$n),e/=$n,e/Math.abs(e)+Math.round(e*(Um-1)))}shouldForceSelection(t){return en?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),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(),qm)}_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(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(en&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!e||e[0]!==this._model.selectionEnd[0]||e[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let t=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&e<Vm&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Om(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,s=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(t,e,s);return}!t||!e||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||e[0]!==this._oldSelectionEnd[0]||e[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,e,s)}_fireOnSelectionChange(t,e,s){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let s=e;for(let i=0;e>=i;i++){let r=t.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&e!==i&&(s+=r-1)}return s}setSelection(t,e,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,s=!0,i=!0){if(t[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(t[1]);if(!n)return;let o=r.translateBufferLineToString(t[1],!1),a=this._convertViewportColToCharacterIndex(n,t[0]),l=a,h=t[0]-a,c=0,d=0,u=0,f=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;l<o.length&&o.charAt(l+1)===" ";)l++}else{let g=t[0],m=t[0];n.getWidth(g)===0&&(c++,g--),n.getWidth(m)===2&&(d++,m++);let y=n.getString(m).length;for(y>1&&(f+=y-1,l+=y-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,g--):v>1&&(u+=v-1,a-=v-1),a--,g--}for(;m<n.length&&l+1<o.length&&!this._isCharWordSeparator(n.loadCell(m+1,this._workCell));){n.loadCell(m+1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,m++):v>1&&(f+=v-1,l+=v-1),l++,m++}}l++;let p=a+h-c+u,_=Math.min(this._bufferService.cols,l-a+c+d-u-f);if(!(!e&&o.slice(a,l).trim()==="")){if(s&&p===0&&n.getCodePoint(0)!==32){let g=r.lines.get(t[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let m=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(m){let y=this._bufferService.cols-m.start;p-=y,_+=y}}}if(i&&p+_===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(t[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let m=this._getWordAt([0,t[1]+1],!1,!1,!0);m&&(_+=m.length)}}return{start:p,length:_}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Jh(s,this._bufferService.cols)}};ta=Pe([W(3,ht),W(4,qs),W(5,Ka),W(6,lt),W(7,rs),W(8,is)],ta);var Qh=class{constructor(){this._data={}}set(t,e,s){this._data[t]||(this._data[t]={}),this._data[t][e]=s}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},el=class{constructor(){this._color=new Qh,this._css=new Qh}setCss(t,e,s){this._css.set(t,e,s)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,s){this._color.set(t,e,s)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},Ne=Object.freeze((()=>{let t=[xe.toColor("#2e3436"),xe.toColor("#cc0000"),xe.toColor("#4e9a06"),xe.toColor("#c4a000"),xe.toColor("#3465a4"),xe.toColor("#75507b"),xe.toColor("#06989a"),xe.toColor("#d3d7cf"),xe.toColor("#555753"),xe.toColor("#ef2929"),xe.toColor("#8ae234"),xe.toColor("#fce94f"),xe.toColor("#729fcf"),xe.toColor("#ad7fa8"),xe.toColor("#34e2e2"),xe.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=e[s/36%6|0],r=e[s/6%6|0],n=e[s%6];t.push({css:De.toCss(i,r,n),rgba:De.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:De.toCss(i,i,i),rgba:De.toRgba(i,i,i)})}return t})()),As=xe.toColor("#ffffff"),Oi=xe.toColor("#000000"),tl=xe.toColor("#ffffff"),sl=Oi,xi={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},jm=As,sa=class extends J{constructor(t){super(),this._optionsService=t,this._contrastCache=new el,this._halfContrastCache=new el,this._onChangeColors=this._register(new N),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:As,background:Oi,cursor:tl,cursorAccent:sl,selectionForeground:void 0,selectionBackgroundTransparent:xi,selectionBackgroundOpaque:ge.blend(Oi,xi),selectionInactiveBackgroundTransparent:xi,selectionInactiveBackgroundOpaque:ge.blend(Oi,xi),scrollbarSliderBackground:ge.opacity(As,.2),scrollbarSliderHoverBackground:ge.opacity(As,.4),scrollbarSliderActiveBackground:ge.opacity(As,.5),overviewRulerBorder:As,ansi:Ne.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=pe(t.foreground,As),e.background=pe(t.background,Oi),e.cursor=ge.blend(e.background,pe(t.cursor,tl)),e.cursorAccent=ge.blend(e.background,pe(t.cursorAccent,sl)),e.selectionBackgroundTransparent=pe(t.selectionBackground,xi),e.selectionBackgroundOpaque=ge.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=pe(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=ge.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?pe(t.selectionForeground,jh):void 0,e.selectionForeground===jh&&(e.selectionForeground=void 0),ge.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=ge.opacity(e.selectionBackgroundTransparent,.3)),ge.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=ge.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=pe(t.scrollbarSliderBackground,ge.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=pe(t.scrollbarSliderHoverBackground,ge.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=pe(t.scrollbarSliderActiveBackground,ge.opacity(e.foreground,.5)),e.overviewRulerBorder=pe(t.overviewRulerBorder,jm),e.ansi=Ne.slice(),e.ansi[0]=pe(t.black,Ne[0]),e.ansi[1]=pe(t.red,Ne[1]),e.ansi[2]=pe(t.green,Ne[2]),e.ansi[3]=pe(t.yellow,Ne[3]),e.ansi[4]=pe(t.blue,Ne[4]),e.ansi[5]=pe(t.magenta,Ne[5]),e.ansi[6]=pe(t.cyan,Ne[6]),e.ansi[7]=pe(t.white,Ne[7]),e.ansi[8]=pe(t.brightBlack,Ne[8]),e.ansi[9]=pe(t.brightRed,Ne[9]),e.ansi[10]=pe(t.brightGreen,Ne[10]),e.ansi[11]=pe(t.brightYellow,Ne[11]),e.ansi[12]=pe(t.brightBlue,Ne[12]),e.ansi[13]=pe(t.brightMagenta,Ne[13]),e.ansi[14]=pe(t.brightCyan,Ne[14]),e.ansi[15]=pe(t.brightWhite,Ne[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let i=0;i<s;i++)e.ansi[i+16]=pe(t.extendedAnsi[i],Ne[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(t===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(t){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[t]=this._restoreColors.ansi[t]}}modifyColors(t){t(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()}}};sa=Pe([W(0,lt)],sa);function pe(t,e){if(t!==void 0)try{return xe.toColor(t)}catch{}return e}var Xm=class{constructor(...t){this._entries=new Map;for(let[e,s]of t)this.set(e,s)}set(t,e){let s=this._entries.get(t);return this._entries.set(t,e),s}forEach(t){for(let[e,s]of this._entries.entries())t(e,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},Zm=class{constructor(){this._services=new Xm,this._services.set(Ya,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=Up(t).sort((n,o)=>n.index-o.index),i=[];for(let n of s){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.id._id}.`);i.push(o)}let r=s.length>0?s[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}},Jm={trace:0,debug:1,info:2,warn:3,error:4,off:5},Qm="xterm.js: ",ia=class extends J{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Jm[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":Qm)+e,...s)}trace(t,...e){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,t,e)}debug(t,...e){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,t,e)}info(t,...e){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,t,e)}warn(t,...e){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,t,e)}error(t,...e){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,t,e)}};ia=Pe([W(0,lt)],ia);var il=class extends J{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new N),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new N),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new N),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let e=new Array(t);for(let s=0;s<Math.min(t,this.length);s++)e[s]=this._array[this._getCyclicIndex(s)];this._array=e,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let e=this._length;e<t;e++)this._array[e]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,e){this._array[this._getCyclicIndex(t)]=e}push(t){this._array[this._getCyclicIndex(this._length)]=t,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(t,e,...s){if(e){for(let i=t;i<this._length-e;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let i=this._length-1;i>=t;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(t+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,s){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=e-1;r>=0;r--)this.set(t+r+s,this.get(t+r));let i=t+e+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<e;i++)this.set(t+i+s,this.get(t+i))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},Z=3,Ie=Object.freeze(new or),br=0,Nn=2,Fi=class nu{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Z);let r=s||Et.fromCharData([0,Cd,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let s=this._data[e*Z+0],i=s&2097151;return[this._data[e*Z+1],s&2097152?this._combined[e]:i?cs(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*Z+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*Z+0]=e|2097152|s[2]<<22):this._data[e*Z+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*Z+0]>>22}hasWidth(e){return this._data[e*Z+0]&12582912}getFg(e){return this._data[e*Z+1]}getBg(e){return this._data[e*Z+2]}hasContent(e){return this._data[e*Z+0]&4194303}getCodePoint(e){let s=this._data[e*Z+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*Z+0]&2097152}getString(e){let s=this._data[e*Z+0];return s&2097152?this._combined[e]:s&2097151?cs(s&2097151):""}isProtected(e){return this._data[e*Z+2]&536870912}loadCell(e,s){return br=e*Z,s.content=this._data[br+0],s.fg=this._data[br+1],s.bg=this._data[br+2],s.content&2097152&&(s.combinedData=this._combined[e]),s.bg&268435456&&(s.extended=this._extendedAttrs[e]),s}setCell(e,s){s.content&2097152&&(this._combined[e]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*Z+0]=s.content,this._data[e*Z+1]=s.fg,this._data[e*Z+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Z+0]=s|i<<22,this._data[e*Z+1]=r.fg,this._data[e*Z+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*Z+0];r&2097152?this._combined[e]+=cs(s):r&2097151?(this._combined[e]=cs(r&2097151)+cs(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*Z+0]=r}insertCells(e,s,i){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length-e){let r=new Et;for(let n=this.length-e-s-1;n>=0;--n)this.setCell(e+s+n,this.loadCell(e+n,r));for(let n=0;n<s;++n)this.setCell(e+n,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,s,i){if(e%=this.length,s<this.length-e){let r=new Et;for(let n=0;n<this.length-e-s;++n)this.setCell(e+n,this.loadCell(e+s+n,r));for(let n=this.length-s;n<this.length;++n)this.setCell(n,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,s,i,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.setCell(e++,i)}resize(e,s){if(e===this.length)return this._data.length*4*Nn<this._data.buffer.byteLength;let i=e*Z;if(e>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=e&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=e&&delete this._extendedAttrs[a]}}return this.length=e,i*4*Nn<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Nn<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let s in e._combined)this._combined[s]=e._combined[s];this._extendedAttrs={};for(let s in e._extendedAttrs)this._extendedAttrs[s]=e._extendedAttrs[s];this.isWrapped=e.isWrapped}clone(){let e=new nu(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let s in this._combined)e._combined[s]=this._combined[s];for(let s in this._extendedAttrs)e._extendedAttrs[s]=this._extendedAttrs[s];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Z+0]&4194303)return e+(this._data[e*Z+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Z+0]&4194303||this._data[e*Z+2]&50331648)return e+(this._data[e*Z+0]>>22);return 0}copyCellsFrom(e,s,i,r,n){let o=e._data;if(n)for(let l=r-1;l>=0;l--){for(let h=0;h<Z;h++)this._data[(i+l)*Z+h]=o[(s+l)*Z+h];o[(s+l)*Z+2]&268435456&&(this._extendedAttrs[i+l]=e._extendedAttrs[s+l])}else for(let l=0;l<r;l++){for(let h=0;h<Z;h++)this._data[(i+l)*Z+h]=o[(s+l)*Z+h];o[(s+l)*Z+2]&268435456&&(this._extendedAttrs[i+l]=e._extendedAttrs[s+l])}let a=Object.keys(e._combined);for(let l=0;l<a.length;l++){let h=parseInt(a[l],10);h>=s&&(this._combined[h-s+i]=e._combined[h])}}translateToString(e,s,i,r){s=s??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;s<i;){let o=this._data[s*Z+0],a=o&2097151,l=o&2097152?this._combined[s]:a?cs(a):ps;if(n+=l,r)for(let h=0;h<l.length;++h)r.push(s);s+=o>>22||1}return r&&r.push(s),n}};function eg(t,e,s,i,r,n){let o=[];for(let a=0;a<t.length-1;a++){let l=a,h=t.get(++l);if(!h.isWrapped)continue;let c=[t.get(a)];for(;l<t.length&&h.isWrapped;)c.push(h),h=t.get(++l);if(!n&&i>=a&&i<l){a+=c.length-1;continue}let d=0,u=Ki(c,d,e),f=1,p=0;for(;f<c.length;){let g=Ki(c,f,e),m=g-p,y=s-u,v=Math.min(m,y);c[d].copyCellsFrom(c[f],p,u,v,!1),u+=v,u===s&&(d++,u=0),p+=v,p===g&&(f++,p=0),u===0&&d!==0&&c[d-1].getWidth(s-1)===2&&(c[d].copyCellsFrom(c[d-1],s-1,u++,1,!1),c[d-1].setCell(s-1,r))}c[d].replaceCells(u,s,r);let _=0;for(let g=c.length-1;g>0&&(g>d||c[g].getTrimmedLength()===0);g--)_++;_>0&&(o.push(a+c.length-_),o.push(_)),a+=c.length-1}return o}function tg(t,e){let s=[],i=0,r=e[i],n=0;for(let o=0;o<t.length;o++)if(r===o){let a=e[++i];t.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=e[++i]}else s.push(o);return{layout:s,countRemoved:n}}function sg(t,e){let s=[];for(let i=0;i<e.length;i++)s.push(t.get(e[i]));for(let i=0;i<s.length;i++)t.set(i,s[i]);t.length=e.length}function ig(t,e,s){let i=[],r=t.map((l,h)=>Ki(t,h,e)).reduce((l,h)=>l+h),n=0,o=0,a=0;for(;a<r;){if(r-a<s){i.push(r-a);break}n+=s;let l=Ki(t,o,e);n>l&&(n-=l,o++);let h=t[o].getWidth(n-1)===2;h&&n--;let c=h?s-1:s;i.push(c),a+=c}return i}function Ki(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let i=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,r=t[e+1].getWidth(0)===2;return i&&r?s-1:s}var ou=class au{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=au._nextId++,this._onDispose=this.register(new N),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),zs(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};ou._nextId=1;var rg=ou,Ge={},Rs=Ge.B;Ge[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ge.A={"#":"£"};Ge.B=void 0;Ge[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ge.C=Ge[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ge.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ge.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ge.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ge.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ge.E=Ge[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ge.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ge.H=Ge[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ge["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var rl=4294967295,nl=class{constructor(t,e,s){this._hasScrollback=t,this._optionsService=e,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ie.clone(),this.savedCharset=Rs,this.markers=[],this._nullCell=Et.fromCharData([0,Cd,1,0]),this._whitespaceCell=Et.fromCharData([0,ps,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new tn,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new il(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Zr),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Zr),this._whitespaceCell}getBlankLine(t,e){return new Fi(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>rl?rl:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Ie);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new il(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Ie),i=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(t,s);let n=0;if(this._rows<e)for(let o=this._rows;o<e;o++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Fi(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Fi(t,s)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let n=0;n<this.lines.length;n++)i+=+this.lines.get(n).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=eg(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Ie),s);if(i.length>0){let r=tg(this.lines,i);sg(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Ie),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Fi(t,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Ie),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=t)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!s){let v=this.ybase+this.y;if(v>=o&&v<o+l.length)continue}let h=l[l.length-1].getTrimmedLength(),c=ig(l,this._cols,t),d=c.length-l.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+d):u=Math.max(0,this.lines.length-this.lines.maxLength+d);let f=[];for(let v=0;v<d;v++){let b=this.getBlankLine(Ie,!0);f.push(b)}f.length>0&&(r.push({start:o+l.length+n,newLines:f}),n+=f.length),l.push(...f);let p=c.length-1,_=c[p];_===0&&(p--,_=c[p]);let g=l.length-d-1,m=h;for(;g>=0;){let v=Math.min(m,_);if(l[p]===void 0)break;if(l[p].copyCellsFrom(l[g],m-v,_-v,v,!0),_-=v,_===0&&(p--,_=c[p]),m-=v,m===0){g--;let b=Math.max(g,0);m=Ki(l,b,this._cols)}}for(let v=0;v<l.length;v++)c[v]<t&&l[v].setCell(c[v],i);let y=d-u;for(;y-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+e-1)}if(r.length>0){let o=[],a=[];for(let _=0;_<this.lines.length;_++)a.push(this.lines.get(_));let l=this.lines.length,h=l-1,c=0,d=r[c];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let u=0;for(let _=Math.min(this.lines.maxLength-1,l+n-1);_>=0;_--)if(d&&d.start>h+u){for(let g=d.newLines.length-1;g>=0;g--)this.lines.set(_--,d.newLines[g]);_++,o.push({index:h+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c]}else this.lines.set(_,a[h--]);let f=0;for(let _=o.length-1;_>=0;_--)o[_].index+=f,this.lines.onInsertEmitter.fire(o[_]),f+=o[_].amount;let p=Math.max(0,l+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,s=0,i){let r=this.lines.get(t);return r?r.translateToString(e,s,i):""}getWrappedRangeForLine(t){let e=t,s=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:e,last:s}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new rg(t);return this.markers.push(e),e.register(this.lines.onTrim(s=>{e.line-=s,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(s=>{e.line>=s.index&&(e.line+=s.amount)})),e.register(this.lines.onDelete(s=>{e.line>=s.index&&e.line<s.index+s.amount&&e.dispose(),e.line>s.index&&(e.line-=s.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},ng=class extends J{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new N),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 nl(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new nl(!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(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),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(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},hu=2,lu=1,ra=class extends J{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new N),this.onResize=this._onResize.event,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,hu),this.rows=Math.max(t.rawOptions.rows||0,lu),this.buffers=this._register(new ng(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let s=this.cols!==t,i=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==t.fg||i.getBg(0)!==t.bg)&&(i=s.getBlankLine(t,e),this._cachedBlankLine=i),i.isWrapped=e;let r=s.ybase+s.scrollTop,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let o=s.lines.isFull;n===s.lines.length-1?o?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),o?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let o=n-r+1;s.lines.shiftElements(r+1,o-1,-1),s.lines.set(n,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(t,e){let s=this.buffer;if(t<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),i!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};ra=Pe([W(0,lt)],ra);var Ks={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:en,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},og=["normal","bold","100","200","300","400","500","600","700","800","900"],ag=class extends J{constructor(t){super(),this._onOptionChange=this._register(new N),this.onOptionChange=this._onOptionChange.event;let e={...Ks};for(let s in t)if(s in e)try{let i=t[s];e[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(be(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(s=>{s===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(s=>{t.indexOf(s)!==-1&&e()})}_setupOptions(){let t=s=>{if(!(s in Ks))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in Ks))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Ks[t]),!hg(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Ks[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=og.includes(e)?e:Ks[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function hg(t){return t==="block"||t==="underline"||t==="bar"}function $i(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let i in t)s[i]=e<=1?t[i]:t[i]&&$i(t[i],e-1);return s}var ol=Object.freeze({insertMode:!1}),al=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),na=class extends J{constructor(t,e,s){super(),this._bufferService=t,this._logService=e,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new N),this.onData=this._onData.event,this._onUserInput=this._register(new N),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new N),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new N),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=$i(ol),this.decPrivateModes=$i(al)}reset(){this.modes=$i(ol),this.decPrivateModes=$i(al)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(i=>i.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};na=Pe([W(0,ht),W(1,Pd),W(2,lt)],na);var hl={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Hn(t,e){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(s|=64,s|=t.action):(s|=t.button&3,t.button&4&&(s|=64),t.button&8&&(s|=128),t.action===32?s|=32:t.action===0&&!e&&(s|=3)),s}var Wn=String.fromCharCode,ll={DEFAULT:t=>{let e=[Hn(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Wn(e[0])}${Wn(e[1])}${Wn(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Hn(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Hn(t,!0)};${t.x};${t.y}${e}`}},oa=class extends J{constructor(t,e,s){super(),this._bufferService=t,this._coreService=e,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new N),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(hl))this.addProtocol(i,hl[i]);for(let i of Object.keys(ll))this.addEncoding(i,ll[i]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,s){if(t.deltaY===0||t.shiftKey||e===void 0||s===void 0)return 0;let i=e/s,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,s){if(s){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};oa=Pe([W(0,ht),W(1,qs),W(2,lt)],oa);var zn=[[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]],lg=[[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]],He;function cg(t,e){let s=0,i=e.length-1,r;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=s;)if(r=s+i>>1,t>e[r][1])s=r+1;else if(t<e[r][0])i=r-1;else return!0;return!1}var dg=class{constructor(){if(this.version="6",!He){He=new Uint8Array(65536),He.fill(1),He[0]=0,He.fill(0,1,32),He.fill(0,127,160),He.fill(2,4352,4448),He[9001]=2,He[9002]=2,He.fill(2,11904,42192),He[12351]=1,He.fill(2,44032,55204),He.fill(2,63744,64256),He.fill(2,65040,65050),He.fill(2,65072,65136),He.fill(2,65280,65377),He.fill(2,65504,65511);for(let t=0;t<zn.length;++t)He.fill(0,zn[t][0],zn[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?He[t]:cg(t,lg)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),i=s===0&&e!==0;if(i){let r=$s.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return $s.createPropertyValue(0,s,i)}},$s=class Vr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new N,this.onChange=this._onChange.event;let e=new dg;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,i=!1){return(e&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,i=0,r=e.length;for(let n=0;n<r;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return s+this.wcwidth(o);let h=e.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:s+=this.wcwidth(h)}let a=this.charProperties(o,i),l=Vr.extractWidth(a);Vr.extractShouldJoin(a)&&(l-=Vr.extractWidth(i)),s+=l,i=a}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},ug=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function cl(t){var i;let e=(i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1))==null?void 0:i.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&e&&(s.isWrapped=e[3]!==0&&e[3]!==32)}var Si=2147483647,fg=256,cu=class aa{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>fg)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let s=new aa;if(!e.length)return s;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){let r=e[i];if(Array.isArray(r))for(let n=0;n<r.length;++n)s.addSubParam(r[n]);else s.addParam(r)}return s}clone(){let e=new aa(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let s=0;s<this.length;++s){e.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Si?Si:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>Si?Si:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let s=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(e[s]=this._subParams.slice(i,r))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+e,Si):e}},Ci=[],pg=class{constructor(){this._state=0,this._active=Ci,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ci}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=Ci,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ci,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,s){if(!this._active.length)this._handlerFb(this._id,"PUT",gn(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}start(){this.reset(),this._state=1}put(t,e,s){if(this._state!==3){if(this._state===1)for(;e<s;){let i=t[e++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-e>0&&this._put(t,e,s)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Ci,this._id=-1,this._state=0}}},mt=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=gn(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,e}},ki=[],_g=class{constructor(){this._handlers=Object.create(null),this._active=ki,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ki}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=ki,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||ki,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(e)}put(t,e,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",gn(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=ki,this._ident=0}},Ni=new cu;Ni.addParam(0);var dl=class{constructor(t){this._handler=t,this._data="",this._params=Ni,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Ni,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=gn(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(s=>(this._params=Ni,this._data="",this._hitLimit=!1,s));return this._params=Ni,this._data="",this._hitLimit=!1,e}},mg=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,i){this.table[e<<8|t]=s<<4|i}addMany(t,e,s,i){for(let r=0;r<t.length;r++)this.table[e<<8|t[r]]=s<<4|i}},Ct=160,gg=(function(){let t=new mg(4095),e=Array.apply(null,Array(256)).map((a,l)=>l),s=(a,l)=>e.slice(a,l),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let n=s(0,14),o;t.setDefault(1,0),t.addMany(i,0,2,0);for(o in n)t.addMany([24,26,153,154],o,3,0),t.addMany(s(128,144),o,3,0),t.addMany(s(144,152),o,3,0),t.add(156,o,0,0),t.add(27,o,11,1),t.add(157,o,4,8),t.addMany([152,158,159],o,0,7),t.add(155,o,11,3),t.add(144,o,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(i,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(i,7,0,7),t.addMany(r,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(r,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(i,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Ct,0,2,0),t.add(Ct,8,5,8),t.add(Ct,6,0,6),t.add(Ct,11,0,11),t.add(Ct,13,13,13),t})(),yg=class extends J{constructor(t=gg){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new cu,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,i)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(be(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new pg),this._dcsParser=this._register(new _g),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<t.intermediates.length;++r){let n=t.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}if(t.final.length!==1)throw new Error("final must be a single byte");let i=t.final.charCodeAt(0);if(e[0]>i||i>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=i,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}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(t,e,s,i,r){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(t,e,s){let i=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&l>-1){for(;l>=0&&(o=a[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 4:if(s===!1&&l>-1){for(;l>=0&&(o=a[l](),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 6:if(i=t[this._parseStack.chunkPos],o=this._dcsParser.unhook(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=t[this._parseStack.chunkPos],o=this._oscParser.end(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a<e;++a){switch(i=t[a],r=this._transitions.table[this.currentState<<8|(i<160?i:Ct)],r>>4){case 2:for(let u=a+1;;++u){if(u>=e||(i=t[u])<32||i>126&&i<Ct){this._printHandler(t,a,u),a=u-1;break}if(++u>=e||(i=t[u])<32||i>126&&i<Ct){this._printHandler(t,a,u),a=u-1;break}if(++u>=e||(i=t[u])<32||i>126&&i<Ct){this._printHandler(t,a,u),a=u-1;break}if(++u>=e||(i=t[u])<32||i>126&&i<Ct){this._printHandler(t,a,u),a=u-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|i],h=l?l.length-1:-1;for(;h>=0&&(o=l[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(3,l,h,r,a),o;h<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a<e&&(i=t[a])>47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],d=c?c.length-1:-1;for(;d>=0&&(o=c[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,c,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let u=a+1;;++u)if(u>=e||(i=t[u])===24||i===26||i===27||i>127&&i<Ct){this._dcsParser.put(t,a,u),a=u-1;break}break;case 14:if(o=this._dcsParser.unhook(i!==24&&i!==26),o)return this._preserveStack(6,[],0,r,a),o;i===27&&(r|=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 u=a+1;;u++)if(u>=e||(i=t[u])<32||i>127&&i<Ct){this._oscParser.put(t,a,u),a=u-1;break}break;case 6:if(o=this._oscParser.end(i!==24&&i!==26),o)return this._preserveStack(5,[],0,r,a),o;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},vg=/^([\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})$/,bg=/^[\da-f]+$/;function ul(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=vg.exec(e);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),bg.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,i=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?n<<4:s===2?n:s===3?n>>4:n>>8}return i}}function Gn(t,e){let s=t.toString(16),i=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function wg(t,e=16){let[s,i,r]=t;return`rgb:${Gn(s,e)}/${Gn(i,e)}/${Gn(r,e)}`}var xg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},hs=131072,fl=10;function pl(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var _l=5e3,ml=0,Sg=class extends J{constructor(t,e,s,i,r,n,o,a,l=new yg){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new zp,this._utf8Decoder=new Gp,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ie.clone(),this._eraseAttrDataInternal=Ie.clone(),this._onRequestBell=this._register(new N),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new N),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new N),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new N),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new N),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new N),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new N),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new N),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new N),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new N),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new N),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new N),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 ha(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:c.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:c,data:d})}),this._parser.setDcsHandlerFallback((h,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:c,payload:d})}),this._parser.setPrintHandler((h,c,d)=>this.print(h,c,d)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(A.BEL,()=>this.bell()),this._parser.setExecuteHandler(A.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(A.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(A.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(A.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(A.BS,()=>this.backspace()),this._parser.setExecuteHandler(A.HT,()=>this.tab()),this._parser.setExecuteHandler(A.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(A.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ur.IND,()=>this.index()),this._parser.setExecuteHandler(Ur.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ur.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new mt(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new mt(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new mt(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new mt(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new mt(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new mt(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new mt(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new mt(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new mt(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new mt(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new mt(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new mt(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Ge)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new dl((h,c)=>this.requestStatusString(h,c)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),_l))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${_l} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>hs&&(n=this._parseStack.position+hs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(h=>h.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<hs&&(this._parseBuffer=new Uint32Array(Math.min(t.length,hs))),o||this._dirtyRowTracker.clearRange(),t.length>hs)for(let h=n;h<t.length;h+=hs){let c=h+hs<t.length?h+hs:t.length,d=typeof t=="string"?this._stringDecoder.decode(t.substring(h,c),this._parseBuffer):this._utf8Decoder.decode(t.subarray(h,c),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(i,r,d,h),this._logSlowResolvingAsync(s),s}else if(!o){let h=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,h))return this._preserveStack(i,r,h,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(t,e,s){let i,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,c=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let f=e;f<s;++f){if(i=t[f],i<127&&n){let m=n[String.fromCharCode(i)];m&&(i=m.charCodeAt(0))}let p=this._unicodeService.charProperties(i,u);r=$s.extractWidth(p);let _=$s.extractShouldJoin(p),g=_?$s.extractWidth(u):0;if(u=p,o&&this._onA11yChar.fire(cs(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>a){if(l){let m=d,y=this._activeBuffer.x-g;for(this._activeBuffer.x=g,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&d instanceof Fi&&d.copyCellsFrom(m,y,0,g,!1);y<a;)m.setCellFromCodepoint(y++,0,1,c)}else if(this._activeBuffer.x=a-1,r===2)continue}if(_&&this._activeBuffer.x){let m=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-m,i,r);for(let y=r-g;--y>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(d.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(c)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=u,this._activeBuffer.x<a&&s-e>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>pl(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new dl(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new mt(e))}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 t;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&&((t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&t.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,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(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,s,i=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.isWrapped=!1)}_resetBufferLine(t,e=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,e=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);s<this._bufferService.rows;s++)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;e--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)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(t){let e=t.params[0]||1;for(;e--;)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(Ie));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let s=t.params[0]||1,i=$s.extractWidth(e),r=this._activeBuffer.x-i,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*s),a=0;for(let h=0;h<n.length;){let c=n.codePointAt(h)||0;o[a++]=c,h+=c>65535?2:1}let l=a;for(let h=1;h<s;++h)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(A.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(A.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(A.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(A.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(A.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Rs),this._charsetService.setgCharset(1,Rs),this._charsetService.setgCharset(2,Rs),this._charsetService.setgCharset(3,Rs);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:h,alt:c}=a,d=this._optionsService.rawOptions,u=(_,g)=>(o.triggerDataEvent(`${A.ESC}[${e?"":"?"}${_};${g}$y`),!0),f=_=>_?1:2,p=t.params[0];return e?p===2?u(p,4):p===4?u(p,f(o.modes.insertMode)):p===12?u(p,3):p===20?u(p,f(d.convertEol)):u(p,0):p===1?u(p,f(i.applicationCursorKeys)):p===3?u(p,d.windowOptions.setWinLines?l===80?2:l===132?1:0:0):p===6?u(p,f(i.origin)):p===7?u(p,f(i.wraparound)):p===8?u(p,3):p===9?u(p,f(r==="X10")):p===12?u(p,f(d.cursorBlink)):p===25?u(p,f(!o.isCursorHidden)):p===45?u(p,f(i.reverseWraparound)):p===66?u(p,f(i.applicationKeypad)):p===67?u(p,4):p===1e3?u(p,f(r==="VT200")):p===1002?u(p,f(r==="DRAG")):p===1003?u(p,f(r==="ANY")):p===1004?u(p,f(i.sendFocus)):p===1005?u(p,4):p===1006?u(p,f(n==="SGR")):p===1015?u(p,4):p===1016?u(p,f(n==="SGR_PIXELS")):p===1048?u(p,1):p===47||p===1047||p===1049?u(p,f(h===c)):p===2004?u(p,f(i.bracketedPasteMode)):p===2026?u(p,f(i.synchronizedOutput)):u(p,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=or.fromColorRGB([s,i,r])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let i=[0,0,-1,0,0,0],r=0,n=0;do{if(i[n+r]=t.params[e+n],t.hasSubParams(e+n)){let o=t.getSubParams(e+n),a=0;do i[1]===5&&(r=1),i[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<i.length);break}if(i[1]===5&&n+r>=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+e<t.length&&n+r<i.length);for(let o=2;o<i.length;++o)i[o]===-1&&(i[o]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return n}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=Ie.fg,t.bg=Ie.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,s,i=this._curAttrData;for(let r=0;r<e;r++)s=t.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Ie.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ie.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(t,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Ie.fg&16777215,i.bg&=-67108864,i.bg|=Ie.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${A.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${A.ESC}[${e};${s}R`);break}return!0}deviceStatusPrivate(t){switch(t.params[0]){case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${A.ESC}[?${e};${s}R`);break}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ie.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(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=e%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(t){let e=t.params[0]||1,s;return(t.length<2||(s=t.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(t){if(!pl(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${A.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>fl&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>fl&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){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(t){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(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],s=t.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let n=parseInt(i);if(gl(n))if(r==="?")e.push({type:0,index:n});else{let o=ul(r);o&&e.push({type:1,index:n,color:o})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let s=t.slice(0,e).trim(),i=t.slice(e+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),i,r=s.findIndex(n=>n.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let s=t.split(";");for(let i=0;i<s.length&&!(e>=this._specialColors.length);++i,++e)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=ul(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],s=t.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);gl(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){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,Rs),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(xg[t[0]],Ge[t[1]]||Rs),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,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=Ie.clone(),this._eraseAttrDataInternal=Ie.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Et;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let s=this._activeBuffer.ybase+this._activeBuffer.y+e,i=this._activeBuffer.lines.get(s);i&&(i.fill(t),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=o=>(this._coreService.triggerDataEvent(`${A.ESC}${o}${A.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},ha=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(ml=t,t=e,e=ml),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ha=Pe([W(0,ht)],ha);function gl(t){return 0<=t&&t<256}var Cg=5e7,yl=12,kg=50,Mg=class extends J{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new N),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>Cg)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,e);if(r){let o=a=>performance.now()-s>=yl?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=yl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>kg&&(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()}},la=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let a=e.addMarker(e.ybase+e.y),l={data:t,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._dataByLinkId.set(l.id,l),l.id}let s=t,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,e.ybase+e.y),r.id;let n=e.addMarker(e.ybase+e.y),o={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(i=>i.line!==e)){let i=this._bufferService.buffer.addMarker(e);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(t){var e;return(e=this._dataByLinkId.get(t))==null?void 0:e.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let s=t.lines.indexOf(e);s!==-1&&(t.lines.splice(s,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};la=Pe([W(0,ht)],la);var vl=!1,Tg=class extends J{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new di),this._onBinary=this._register(new N),this.onBinary=this._onBinary.event,this._onData=this._register(new N),this.onData=this._onData.event,this._onLineFeed=this._register(new N),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new N),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new N),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new N),this._instantiationService=new Zm,this.optionsService=this._register(new ag(t)),this._instantiationService.setService(lt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ra)),this._instantiationService.setService(ht,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ia)),this._instantiationService.setService(Pd,this._logService),this.coreService=this._register(this._instantiationService.createInstance(na)),this._instantiationService.setService(qs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(oa)),this._instantiationService.setService(Ed,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance($s)),this._instantiationService.setService(Yp,this.unicodeService),this._charsetService=this._instantiationService.createInstance(ug),this._instantiationService.setService(Vp,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(la),this._instantiationService.setService(Ad,this._oscLinkService),this._inputHandler=this._register(new Sg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(it.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(it.forward(this._bufferService.onResize,this._onResize)),this._register(it.forward(this.coreService.onData,this._onData)),this._register(it.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Mg((e,s)=>this._inputHandler.parse(e,s))),this._register(it.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new N),this._onScroll.event(t=>{var e;(e=this._onScrollApi)==null||e.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!vl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),vl=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,hu),e=Math.max(e,lu),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(cl.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(cl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=be(()=>{for(let e of t)e.dispose()})}}},Eg={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function Pg(t,e,s,i){var o;let r={type:0,cancel:!1,key:void 0},n=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?r.key=A.ESC+"OA":r.key=A.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=A.ESC+"OD":r.key=A.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=A.ESC+"OC":r.key=A.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=A.ESC+"OB":r.key=A.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":A.DEL,t.altKey&&(r.key=A.ESC+r.key);break;case 9:if(t.shiftKey){r.key=A.ESC+"[Z";break}r.key=A.HT,r.cancel=!0;break;case 13:r.key=t.altKey?A.ESC+A.CR:A.CR,r.cancel=!0;break;case 27:r.key=A.ESC,t.altKey&&(r.key=A.ESC+A.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=A.ESC+"[1;"+(n+1)+"D":e?r.key=A.ESC+"OD":r.key=A.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=A.ESC+"[1;"+(n+1)+"C":e?r.key=A.ESC+"OC":r.key=A.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=A.ESC+"[1;"+(n+1)+"A":e?r.key=A.ESC+"OA":r.key=A.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=A.ESC+"[1;"+(n+1)+"B":e?r.key=A.ESC+"OB":r.key=A.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=A.ESC+"[2~");break;case 46:n?r.key=A.ESC+"[3;"+(n+1)+"~":r.key=A.ESC+"[3~";break;case 36:n?r.key=A.ESC+"[1;"+(n+1)+"H":e?r.key=A.ESC+"OH":r.key=A.ESC+"[H";break;case 35:n?r.key=A.ESC+"[1;"+(n+1)+"F":e?r.key=A.ESC+"OF":r.key=A.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=A.ESC+"[5;"+(n+1)+"~":r.key=A.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=A.ESC+"[6;"+(n+1)+"~":r.key=A.ESC+"[6~";break;case 112:n?r.key=A.ESC+"[1;"+(n+1)+"P":r.key=A.ESC+"OP";break;case 113:n?r.key=A.ESC+"[1;"+(n+1)+"Q":r.key=A.ESC+"OQ";break;case 114:n?r.key=A.ESC+"[1;"+(n+1)+"R":r.key=A.ESC+"OR";break;case 115:n?r.key=A.ESC+"[1;"+(n+1)+"S":r.key=A.ESC+"OS";break;case 116:n?r.key=A.ESC+"[15;"+(n+1)+"~":r.key=A.ESC+"[15~";break;case 117:n?r.key=A.ESC+"[17;"+(n+1)+"~":r.key=A.ESC+"[17~";break;case 118:n?r.key=A.ESC+"[18;"+(n+1)+"~":r.key=A.ESC+"[18~";break;case 119:n?r.key=A.ESC+"[19;"+(n+1)+"~":r.key=A.ESC+"[19~";break;case 120:n?r.key=A.ESC+"[20;"+(n+1)+"~":r.key=A.ESC+"[20~";break;case 121:n?r.key=A.ESC+"[21;"+(n+1)+"~":r.key=A.ESC+"[21~";break;case 122:n?r.key=A.ESC+"[23;"+(n+1)+"~":r.key=A.ESC+"[23~";break;case 123:n?r.key=A.ESC+"[24;"+(n+1)+"~":r.key=A.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=A.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=A.DEL:t.keyCode===219?r.key=A.ESC:t.keyCode===220?r.key=A.FS:t.keyCode===221&&(r.key=A.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=(o=Eg[t.keyCode])==null?void 0:o[t.shiftKey?1:0];if(a)r.key=A.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,h=String.fromCharCode(l);t.shiftKey&&(h=h.toUpperCase()),r.key=A.ESC+h}else if(t.keyCode===32)r.key=A.ESC+(t.ctrlKey?A.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=A.ESC+l,r.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=A.US),t.key==="@"&&(r.key=A.NUL));break}return r}var Ae=0,Ag=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new tn,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new tn,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),e=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(i[r]=t[e],e++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(Ae=this._search(e),Ae===-1)||this._getKey(this._array[Ae])!==e)return!1;do if(this._array[Ae]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ae),!0;while(++Ae<this._array.length&&this._getKey(this._array[Ae])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,n)=>r-n),e=0,s=new Array(this._array.length-t.length),i=0;for(let r=0;r<this._array.length;r++)t[e]===r?e++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ae=this._search(t),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===t))do yield this._array[Ae];while(++Ae<this._array.length&&this._getKey(this._array[Ae])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ae=this._search(t),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===t))do e(this._array[Ae]);while(++Ae<this._array.length&&this._getKey(this._array[Ae])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let i=e+s>>1,r=this._getKey(this._array[i]);if(r>t)s=i-1;else if(r<t)e=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===t;)i--;return i}}return e}},Un=0,bl=0,Rg=class extends J{constructor(){super(),this._decorations=new Ag(t=>t==null?void 0:t.marker.line),this._onDecorationRegistered=this._register(new N),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new N),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(be(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new Bg(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),i=e.onDispose(()=>{i.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),s.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,s){let i=0,r=0;for(let n of this._decorations.getKeyIterator(e))i=n.options.x??0,r=i+(n.options.width??1),t>=i&&t<r&&(!s||(n.options.layer??"bottom")===s)&&(yield n)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{Un=r.options.x??0,bl=Un+(r.options.width??1),t>=Un&&t<bl&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},Bg=class extends gs{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new N),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new N),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=xe.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=xe.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Lg=1e3,Ig=class{constructor(t,e=Lg){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},wl=20,sn=class extends J{constructor(t,e,s,i){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Ig(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
28
+ `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Y(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(be(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<wl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
29
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===wl+1&&(this._liveRegion.textContent+=Po.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=t;r<=e;r++){let n=s.lines.get(s.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",l=(s.ydisp+r+1).toString(),h=this._rowElements[r];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",l),h.setAttribute("aria-setsize",i),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,i=this._rowElements[e===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||t.relatedTarget!==i)return;let o,a;if(e===0?(o=s,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=s,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((a=i.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(s.node))return;let r=({node:l,offset:h})=>{let c=l instanceof Text?l.parentNode:l,d=parseInt(c==null?void 0:c.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(c);if(!u)return console.warn("columns is null. Race condition?"),null;let f=h<u.length?u[h]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++d,f=0),{row:d,column:f}},n=r(e),o=r(s);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){var r,n;t.style.transform="";let e=t.getBoundingClientRect().width,s=(n=(r=this._rowColumns.get(t))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${i/e})`}};sn=Pe([W(1,Ya),W(2,is),W(3,rs)],sn);var ca=class extends J{constructor(t,e,s,i,r){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new N),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new N),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(be(()=>{var n;zs(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Y(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Y(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Y(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Y(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){var i,r;(!this._activeProviderReplies||!e)&&((i=this._activeProviderReplies)==null||i.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())e?(r=this._activeProviderReplies)!=null&&r.get(n)&&(s=this._checkLinkProviderResult(n,t,s)):o.provideLinks(t.y,a=>{var h,c;if(this._isMouseOut)return;let l=a==null?void 0:a.map(d=>({link:d}));(h=this._activeProviderReplies)==null||h.set(n,l),s=this._checkLinkProviderResult(n,t,s),((c=this._activeProviderReplies)==null?void 0:c.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let i=0;i<e.size;i++){let r=e.get(i);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<t?0:o.link.range.start.x,l=o.link.range.end.y>t?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=l;h++){if(s.has(h)){r.splice(n--,1);break}s.add(h)}}}}_checkLinkProviderResult(t,e,s){var n;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&i){let o=i.find(a=>this._linkAtPosition(a.link,e));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(l=>this._linkAtPosition(l.link,e));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&Dg(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,zs(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,r,n;(i=this._currentLink)!=null&&i.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(t,e,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,i=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return s<=r&&r<=i}_positionFromMouseEvent(t,e,s){let i=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,i,r){return{x1:t,y1:e,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};ca=Pe([W(1,Ka),W(2,rs),W(3,ht),W(4,Bd)],ca);function Dg(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var Og=class extends Tg{constructor(t={}){super(t),this._linkifier=this._register(new di),this.browser=Zd,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new di),this._onCursorMove=this._register(new N),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new N),this.onKey=this._onKey.event,this._onRender=this._register(new N),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new N),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new N),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new N),this.onBell=this._onBell.event,this._onFocus=this._register(new N),this._onBlur=this._register(new N),this._onA11yCharEmitter=this._register(new N),this._onA11yTabEmitter=this._register(new N),this._onWillOpen=this._register(new N),this._setup(),this._decorationService=this._instantiationService.createInstance(Rg),this._instantiationService.setService(ar,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(km),this._instantiationService.setService(Bd,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ro)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh((e==null?void 0:e.start)??0,(e==null?void 0:e.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(it.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(it.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(it.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(it.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(be(()=>{var e,s;this._customKeyEventHandler=void 0,(s=(e=this.element)==null?void 0:e.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let s,i="";switch(e.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+e.index}switch(e.type){case 0:let r=ge.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${A.ESC}]${i};${wg(r)}${jd.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(n=>n.ansi[e.index]=De.toColor(...e.color));else{let n=s;this._themeService.modifyColors(o=>o[n]=De.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(sn,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(A.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var t;return(t=this.textarea)==null?void 0:t.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(A.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=e.getWidth(s),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Y(this.element,"copy",e=>{this.hasSelection()&&Hp(e,this._selectionService)}));let t=e=>Wp(e,this.textarea,this.coreService,this.optionsService);this._register(Y(this.textarea,"paste",t)),this._register(Y(this.element,"paste",t)),Jd?this._register(Y(this.element,"mousedown",e=>{e.button===2&&Rh(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Y(this.element,"contextmenu",e=>{Rh(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sh&&this._register(Y(this.element,"auxclick",e=>{e.button===1&&Sd(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Y(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(Y(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(Y(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(Y(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Y(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(Y(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Y(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){var r;if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.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"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Y(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Eo.get()),tu||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Sm,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(is,this._coreBrowserService),this._register(Y(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(Y(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jo,this._document,this._helperContainer),this._instantiationService.setService(yn,this._charSizeService),this._themeService=this._instantiationService.createInstance(sa),this._instantiationService.setService(gi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Qr),this._instantiationService.setService(Rd,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ea,this.rows,this.screenElement)),this._instantiationService.setService(rs,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(jo,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Qo),this._instantiationService.setService(Ka,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(ca,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Yo,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ta,this.element,this.screenElement,i)),this._instantiationService.setService(jp,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(it.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Ko,this.screenElement)),this._register(Y(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),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(sn,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Jr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Jr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Zo,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(n){var h,c,d,u,f;let o=t._mouseService.getMouseReportCoords(n,t.screenElement);if(!o)return!1;let a,l;switch(n.overrideType||n.type){case"mousemove":l=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":l=0,a=n.button<3?n.button:3;break;case"mousedown":l=1,a=n.button<3?n.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(n)===!1)return!1;let p=n.deltaY;if(p===0||t.coreMouseService.consumeWheelEvent(n,(u=(d=(c=(h=t._renderService)==null?void 0:h.dimensions)==null?void 0:c.device)==null?void 0:d.cell)==null?void 0:u.height,(f=t._coreBrowserService)==null?void 0:f.dpr)===0)return!1;l=p<0?0:1,a=4;break;default:return!1}return l===void 0||a===void 0||a>4?!1:t.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:l,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(s(n),n.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(n)),wheel:n=>(s(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&s(n)},mousemove:n=>{n.buttons||s(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),n&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),n&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),n&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Y(e,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return s(n),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(n)})),this._register(Y(e,"wheel",n=>{var o,a,l,h,c;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(n,(h=(l=(a=(o=t._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:l.cell)==null?void 0:h.height,(c=t._coreBrowserService)==null?void 0:c.dpr)===0)return this.cancel(n,!0);let d=A.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(t,e){var s;(s=this._renderService)==null||s.refreshRows(t,e)}updateCursorStyle(t){var e;(e=this._selectionService)!=null&&e.shouldColumnSelect(t)?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(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){xd(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,s){this._selectionService.setSelection(t,e,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var t;(t=this._selectionService)==null||t.clearSelection()}selectAll(){var t;(t=this._selectionService)==null||t.selectAll()}selectLines(t,e){var s;(s=this._selectionService)==null||s.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=Pg(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(t,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===A.ETX||s.key===A.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let s=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?s:s&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(Fg(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(Ie));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var e;this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),(e=this._selectionService)==null||e.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){var t;(t=this._renderService)==null||t.clearTextureAtlas()}_reportFocus(){var t;(t=this.element)!=null&&t.classList.contains("focus")?this.coreService.triggerDataEvent(A.ESC+"[I"):this.coreService.triggerDataEvent(A.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${A.ESC}[4;${s};${e}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${A.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function Fg(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var $g=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let s={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(s),e.dispose=()=>this._wrappedAddonDispose(s),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){e=s;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}},Ng=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new Et)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},xl=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,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(t){let e=this._buffer.lines.get(t);if(e)return new Ng(e)}getNullCell(){return new Et}},Hg=class extends J{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new N),this.onBufferChange=this._onBufferChange.event,this._normal=new xl(this._core.buffers.normal,"normal"),this._alternate=new xl(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)}},Wg=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,s=>e(s.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(s,i)=>e(s,i.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},zg=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},Gg=["cols","rows"],Ft=0,Ug=class extends J{constructor(t){super(),this._core=this._register(new Og(t)),this._addonManager=this._register(new $g),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:e.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(t){if(Gg.includes(t))throw new Error(`Option "${t}" 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 Wg(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new zg(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 Hg(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
30
+ `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Eo.get()},set promptLabel(t){Eo.set(t)},get tooMuchOutput(){return Po.get()},set tooMuchOutput(t){Po.set(t)}}}_verifyIntegers(...t){for(Ft of t)if(Ft===1/0||isNaN(Ft)||Ft%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Ft of t)if(Ft&&(Ft===1/0||isNaN(Ft)||Ft%1!==0||Ft<0))throw new Error("This API only accepts positive integers")}};const qg=/^(Try "|Press |Message @)/,Sl=6;function Vg(t){const e=t.split(`\r
31
+ `);for(let s=e.length-1;s>0;s--){const i=qn(e[s]);if(!/^❯[ \u00a0]/.test(wr(i))||!Cl(wr(qn(e[s-1]))))continue;const r=[i.slice(2)];let n=s+1;for(;n<e.length&&n<=s+Sl;n++){const h=qn(e[n]);if(Cl(wr(h)))break;r.push(h)}if(n>=e.length||n>s+Sl)return null;const a=r.flat().filter(h=>h.ch.trim()!=="");if(!a.some(h=>h.dim)||a.some(h=>!h.dim&&!h.inverse))return null;const l=r.map(h=>wr(h).replace(/\u00a0/g," ").trim()).filter(Boolean).join(" ");return{text:l,suggestion:!qg.test(l)}}return null}const Yg=/\x1b\[([0-9;:]*)m|\x1b(?:\[[0-9;:?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[()][A-Za-z0-9]|.)|([^\x1b]+)/g;function qn(t){const e=[];let s=!1,i=!1;for(const r of t.matchAll(Yg))if(r[1]!==void 0){const n=r[1].split(";");for(let o=0;o<n.length;o++){const a=n[o]===""?0:Number(n[o]);a===0?s=i=!1:a===2?s=!0:a===22?s=!1:a===7?i=!0:a===27?i=!1:(a===38||a===48||a===58)&&(o+=n[o+1]==="5"?2:n[o+1]==="2"?4:0)}}else if(r[2]!==void 0)for(const n of r[2])e.push({ch:n,dim:s,inverse:i});return e}function wr(t){return t.map(e=>e.ch).join("")}function Cl(t){return/^─{3,}/.test(t.trim())}const Kg=/^\/([\w.:-]*)$/;class jg{constructor(e,s){w(this,"onPick",()=>{});w(this,"commands",[]);w(this,"shown",[]);w(this,"active",0);w(this,"query",null);w(this,"dismissed",null);this.el=e,this.box=s,this.box.setAttribute("aria-controls",e.id),this.box.setAttribute("aria-autocomplete","list"),e.addEventListener("mousedown",i=>i.preventDefault()),e.addEventListener("click",i=>{var n;const r=Number((n=i.target.closest("[data-i]"))==null?void 0:n.dataset.i);this.shown[r]&&this.onPick(this.shown[r])}),e.addEventListener("mousemove",i=>{var n;const r=Number((n=i.target.closest("[data-i]"))==null?void 0:n.dataset.i);Number.isInteger(r)&&r!==this.active&&this.highlight(r)})}get open(){return this.shown.length>0}get any(){return this.commands.length>0}setCommands(e){this.commands=e,this.query=null,this.update(this.box.value)}find(e){return this.commands.find(s=>s.name===e)}get current(){return this.shown[this.active]}update(e){const s=Kg.exec(e);e!==this.dismissed&&(this.dismissed=null);const i=s&&this.dismissed===null?s[1].toLowerCase():null;i===this.query&&this.shown.length||(this.query=i,this.shown=i===null?[]:Xg(this.commands,i),this.active=0,this.render())}dismiss(){this.dismissed=this.box.value,this.close()}close(){this.query=null,this.shown=[],this.render()}move(e){this.open&&this.highlight((this.active+e+this.shown.length)%this.shown.length)}highlight(e){var i;(i=this.el.children[this.active])==null||i.setAttribute("aria-selected","false"),this.active=e;const s=this.el.children[e];s==null||s.setAttribute("aria-selected","true"),s==null||s.scrollIntoView({block:"nearest"}),this.box.setAttribute("aria-activedescendant",`slash-${e}`)}render(){if(this.el.hidden=!this.open,this.box.setAttribute("aria-expanded",String(this.open)),!this.open){this.box.removeAttribute("aria-activedescendant"),this.el.replaceChildren();return}this.el.replaceChildren(...this.shown.map((e,s)=>{var n;const i=document.createElement("li");i.id=`slash-${s}`,i.dataset.i=String(s),i.setAttribute("role","option"),i.setAttribute("aria-selected",String(s===this.active));const r=xr("n",`/${e.name}`);return(n=e.aliases)!=null&&n.length&&r.append(xr("a",` (${e.aliases.join(", ")})`)),i.append(r,xr("d",e.description)),e.source!=="built-in"&&i.append(xr("s",e.source)),i.title=[`/${e.name}${e.hint?` ${e.hint}`:""}`,e.description].filter(Boolean).join(`
32
+ `),i})),this.el.scrollTop=0,this.box.setAttribute("aria-activedescendant","slash-0")}}function xr(t,e){const s=document.createElement("span");return s.className=t,s.textContent=e,s}function Xg(t,e){const s=[];for(const r of t){const n=r.name.toLowerCase(),o=[n,n.slice(n.lastIndexOf(":")+1),...r.aliases??[]];let a;if(!e)a=0;else if(o.includes(e))a=0;else if(n.startsWith(e))a=1;else if(o.some(l=>l.startsWith(e)))a=2;else if(n.split(/[-_:.]/).some(l=>l.startsWith(e)))a=3;else if(n.includes(e))a=4;else if(Zg(e,n))a=5;else continue;s.push([a,r])}return(s.some(([r])=>r<5)?s.filter(([r])=>r<5):s).sort((r,n)=>r[0]-n[0]||r[1].name.localeCompare(n[1].name)).map(([,r])=>r)}function Zg(t,e){let s=0;for(const i of e)i===t[s]&&s++;return s===t.length}const Jg=400,Qg=1e3,e0="\x1B[5~",t0="\x1B[6~",s0=.4,i0=16,r0=[0,120],Sr=13,n0=8,o0={ArrowUp:"up",ArrowDown:"down",Tab:"tab"},a0="\x1B[200~",h0="\x1B[201~",Vn="kauak.panel-width",l0=420,kl=300;class c0{constructor(e){w(this,"el",document.getElementById("panel"));w(this,"titleEl",document.getElementById("panel-title"));w(this,"metaEl",document.getElementById("panel-meta"));w(this,"hintEl",document.getElementById("panel-hint"));w(this,"host",document.getElementById("panel-term"));w(this,"form",document.getElementById("panel-input"));w(this,"box",document.getElementById("panel-text"));w(this,"sendBtn",document.getElementById("panel-send"));w(this,"takeBtn",document.getElementById("panel-take"));w(this,"liveBtn",document.getElementById("panel-live"));w(this,"focusBtn",document.getElementById("panel-focus"));w(this,"menu",new jg(document.getElementById("panel-slash"),this.box));w(this,"term");w(this,"pane",null);w(this,"lastText",null);w(this,"drafts",new Map);w(this,"commands",new Map);w(this,"commandsFor","");w(this,"shadow",null);w(this,"fontCap",Sr);w(this,"fitFor","");w(this,"readRows",0);w(this,"readCols",0);w(this,"pinned",!0);w(this,"history",!1);w(this,"held",null);w(this,"wheel",0);w(this,"readSeq",0);w(this,"appliedSeq",0);w(this,"inputId",0);w(this,"timer",null);w(this,"hintTimer",null);w(this,"onRead",()=>{});w(this,"onInput",()=>!1);w(this,"onListCommands",()=>{});w(this,"onFocus",()=>{});w(this,"onResize",()=>{});this.state=e,this.term=new Ug({disableStdin:!0,cursorBlink:!1,cursorInactiveStyle:"none",fontSize:Sr,fontFamily:"ui-monospace, 'JetBrains Mono', Menlo, monospace",convertEol:!1,scrollback:0,theme:{background:"#0f1118",foreground:"#e8e9f0"}}),this.term.open(this.host),this.term.attachCustomWheelEventHandler(()=>!1),document.getElementById("panel-close").addEventListener("click",()=>this.close()),this.focusBtn.addEventListener("click",()=>{this.pane&&this.onFocus(this.pane.pane_id)});for(const r of this.el.querySelectorAll("[data-key]"))r.addEventListener("click",()=>this.sendKey(r.dataset.key));for(const r of this.el.querySelectorAll("button"))r.addEventListener("mousedown",n=>n.preventDefault());this.form.addEventListener("submit",r=>{r.preventDefault(),this.submit()}),this.box.addEventListener("keydown",r=>this.onKey(r)),this.box.addEventListener("input",()=>this.changed()),this.box.addEventListener("blur",()=>this.changed()),this.box.addEventListener("focus",()=>this.changed()),this.menu.onPick=r=>this.complete(r),this.takeBtn.addEventListener("click",()=>this.takeSuggestion()),addEventListener("resize",()=>this.autosize());const s=document.getElementById("panel-resize");this.setWidth(Number(li(Vn))||null),s.addEventListener("pointerdown",r=>this.dragWidth(r,s)),s.addEventListener("dblclick",()=>{this.setWidth(null),ci(Vn,""),this.onResize()}),this.host.addEventListener("click",()=>{!this.term.hasSelection()&&Ml()&&this.box.focus()}),this.host.addEventListener("scroll",()=>{this.pinned=this.atEdge(1),this.pinned&&this.release(),this.renderLive()}),this.host.addEventListener("wheel",r=>this.onWheel(r),{passive:!0}),this.liveBtn.addEventListener("click",()=>this.toBottom());const i=new ResizeObserver(()=>{this.fit(),this.keepBottom()});i.observe(this.host),i.observe(this.host.querySelector(".xterm-screen")),addEventListener("keydown",r=>{r.key==="Escape"&&!this.isTyping()&&this.close()}),this.changed(),e.subscribe(r=>{r.type!=="selection"?this.setSnapshot(kp(e.floors())):e.selected?this.open(e.pane(e.selected)):this.pane&&this.close()})}isTyping(){return this.pane!==null&&document.activeElement===this.box}setSnapshot(e){if(!this.pane)return;const s=e.panes.find(i=>i.pane_id===this.pane.pane_id);if(!s){this.close();return}this.pane=s,this.renderHeader(),this.resizeToPane(),this.askCommands()}open(e){var i;const s=((i=this.pane)==null?void 0:i.pane_id)!==e.pane_id;s&&this.saveDraft(),this.pane=e,this.el.classList.add("open"),document.body.classList.add("panel-open"),this.renderHeader(),s&&(this.lastText=null,this.readRows=this.readCols=0,this.pinned=!0,this.history=!1,this.held=null,this.renderLive(),this.term.reset(),this.resizeToPane(),this.shadow=null,this.menu.setCommands(this.commands.get(e.pane_id)??[]),this.box.value=this.drafts.get(e.pane_id)??"",this.changed()),this.askCommands(),this.timer===null&&(this.poll(),this.timer=window.setInterval(()=>this.poll(),Jg)),Ml()&&this.box.focus(),requestAnimationFrame(()=>this.fit())}close(){const e=this.pane!==null;this.saveDraft(),this.el.classList.remove("open"),document.body.classList.remove("panel-open"),this.pane=null,this.commandsFor="",this.box.blur(),e&&this.state.deselect(),this.timer!==null&&(clearInterval(this.timer),this.timer=null)}setCommands(e,s){var i;this.commands.set(e,s),e===((i=this.pane)==null?void 0:i.pane_id)&&(this.menu.setCommands(s),this.renderHint())}receive(e,s,i){if(!(!this.pane||e!==this.pane.pane_id||i<=this.appliedSeq)){if(this.appliedSeq=i,!this.pinned&&this.history){s!==this.lastText&&(this.held=s),this.renderLive();return}this.show(s)}}show(e){var n;if(!this.pane)return;const s=e.split(`\r
33
+ `),i=((n=this.pane.screen)==null?void 0:n.rows)??s.length;this.history=s.length>i||this.pane.scrollback,this.readRows=s.length,this.readCols=Math.max(this.readCols,...s.map(o=>f0(u0(o))));const r=this.resizeToPane();e===this.lastText&&!r||(this.lastText=e,this.term.write(`\x1B[?7l\x1B[H\x1B[2J${e}\x1B[?25l`,()=>this.keepBottom()),this.setShadow(this.pane.agent==="claude"?Vg(s.slice(-i).join(`\r
34
+ `)):null))}inputAcked(e,s){if(!(!this.pane||e!==this.pane.pane_id||s!==this.inputId))for(const i of r0)window.setTimeout(()=>this.poll(),i)}inputFailed(e,s,i){!this.pane||e!==this.pane.pane_id||this.flashHint(`input failed: ${s}`)}onKey(e){var n;if(e.isComposing)return;const s=!e.ctrlKey&&!e.metaKey&&!e.altKey;if(this.menu.open&&s&&this.menuKey(e)){e.preventDefault(),e.stopPropagation();return}if(e.key==="Enter"&&!e.shiftKey&&!e.altKey){e.preventDefault(),this.submit();return}const i=this.box.value==="";if(i&&s&&!e.shiftKey&&e.key==="Tab"&&((n=this.shadow)!=null&&n.suggestion)){e.preventDefault(),this.takeSuggestion();return}let r;e.key==="Escape"?r="esc":i&&e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()==="c"?r="ctrl+c":i&&s&&e.key==="Tab"?r=e.shiftKey?"shift+tab":"tab":i&&s&&!e.shiftKey&&(r=o0[e.key]),r&&(e.preventDefault(),e.stopPropagation(),this.sendKey(r))}menuKey(e){const s=this.menu.current;if(!s)return!1;if(e.key==="ArrowDown"||e.key==="ArrowUp")this.menu.move(e.key==="ArrowDown"?1:-1);else if(e.key==="Tab")e.shiftKey?this.menu.move(-1):this.complete(s);else if(e.key==="Enter"&&!e.shiftKey)this.submit();else if(e.key==="Escape")this.menu.dismiss(),this.changed();else return!1;return!0}complete(e){this.box.value=`/${e.name} `,this.box.setSelectionRange(this.box.value.length,this.box.value.length),this.box.focus(),this.changed()}takeSuggestion(){var e;!((e=this.shadow)!=null&&e.suggestion)||this.box.value||(this.box.value=this.shadow.text,this.box.setSelectionRange(this.box.value.length,this.box.value.length),this.box.focus(),this.changed())}setShadow(e){var s,i;(e==null?void 0:e.text)===((s=this.shadow)==null?void 0:s.text)&&(e==null?void 0:e.suggestion)===((i=this.shadow)==null?void 0:i.suggestion)||(this.shadow=e,this.renderPlaceholder(),this.changed())}askCommands(){const e=this.pane,s=e!=null&&e.agent?`${e.pane_id}|${e.agent}|${e.cwd}`:"";s!==this.commandsFor&&(this.commandsFor=s,e&&(e.agent?this.onListCommands(e.pane_id):this.setCommands(e.pane_id,[])))}submit(){const e=this.menu.current;e&&(this.box.value=`/${e.name}`);const s=this.box.value.replace(/\s+$/,""),i=[];s&&i.push({text:s.includes(`
35
+ `)?a0+s.replace(/\r?\n/g,"\r")+h0:s}),i.push({keys:["enter"]}),this.send(i)&&(this.box.value="",this.changed(),this.toBottom())}sendKey(e){this.send([{keys:[e]}])&&this.toBottom()}send(e){return this.pane?this.onInput(this.pane.pane_id,e,++this.inputId)?!0:(this.flashHint("bridge offline · nothing was sent"),!1):!1}saveDraft(){this.pane&&(this.box.value?this.drafts.set(this.pane.pane_id,this.box.value):this.drafts.delete(this.pane.pane_id))}changed(){var e;document.activeElement===this.box?this.menu.update(this.box.value):this.menu.close(),this.autosize(),this.takeBtn.hidden=!((e=this.shadow)!=null&&e.suggestion&&this.box.value===""),this.renderHint()}autosize(){this.box.style.height="",this.box.value&&(this.box.style.height=`${this.box.scrollHeight}px`);const e=this.box.value.trim()==="",s=this.menu.current;this.sendBtn.textContent=s?"Run":e?"Enter ↵":"Send",this.sendBtn.title=s?"Run the highlighted command (Enter)":e?"Press Enter in the pane (to accept a prompt, say)":"Send the message, then Enter (Enter)"}renderHint(){var i,r;if(this.hintTimer!==null)return;this.hintEl.classList.remove("warn");const e=/^\/([\w.:-]+) /.exec(this.box.value),s=e&&((i=this.menu.find(e[1]))==null?void 0:i.hint);this.hintEl.textContent=this.menu.open?"↑ ↓ pick · Tab completes · Enter runs · Esc closes":s?`/${e[1]} ${s}`:this.box.value===""&&((r=this.shadow)!=null&&r.suggestion)?"Tab takes the suggestion · Esc, and ↑ ↓ ⌃C in an empty box, go to the pane":`Enter sends · Shift+Enter new line${this.menu.any?" · / for commands":""} · Esc, and ↑ ↓ Tab ⌃C in an empty box, go to the pane`}flashHint(e){this.hintEl.textContent=e,this.hintEl.classList.add("warn"),this.hintTimer!==null&&clearTimeout(this.hintTimer),this.hintTimer=window.setTimeout(()=>{this.hintTimer=null,this.renderHint()},2500)}poll(){var e;this.pane&&this.onRead(this.pane.pane_id,++this.readSeq,(((e=this.pane.screen)==null?void 0:e.rows)??0)+Qg)}renderHeader(){var n;if(!this.pane)return;const e=this.pane;this.titleEl.textContent=e.title||e.pane_id,this.metaEl.textContent=`${e.pane_id} · ${(e.cwd??"").replace(/^\/home\/[^/]+/,"~")}`;const s=document.getElementById("panel-kind");s.textContent=e.agent??"shell",s.dataset.kind=e.agent??"",document.getElementById("panel-status").textContent=e.agent?e.agent_status:"no agent";const i=((n=this.state.floors().find(o=>o.info.id===fs(e.pane_id)))==null?void 0:n.info.runtime.name)??"";this.focusBtn.textContent=`Focus in ${i}`,this.focusBtn.title=`Switch ${i} to this pane`;const r=document.getElementById("panel-ctx");r.hidden=!e.context,e.context&&(r.title=`Context: ${Va(e.context)}`,r.querySelector(".ctx").className=`ctx ${qa(e.context)}`,r.querySelector(".ctx i").style.width=Xr(e.context),r.querySelector(".pct").textContent=`${Xr(e.context)} context`),this.el.dataset.status=e.agent_status,this.renderPlaceholder()}renderPlaceholder(){var s;const e=this.pane;this.box.placeholder=((s=this.shadow)==null?void 0:s.text)??(e!=null&&e.agent?`Message ${e.agent}`:"Run a command")}resizeToPane(){if(!this.pane)return!1;const e=this.pane.screen,s=Math.max(5,this.readRows||(e==null?void 0:e.rows)||this.term.rows),i=Math.max(20,e!=null&&e.exact&&e.cols?e.cols:Math.max(this.readCols,(e==null?void 0:e.cols)??0));return i===this.term.cols&&s===this.term.rows?!1:(this.term.resize(i,s),this.fit(),!0)}fit(){const e=this.host.querySelector(".xterm-screen");if(!e||!this.el.classList.contains("open"))return;const s=getComputedStyle(this.host),i=this.host.clientWidth-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight),r=e.getBoundingClientRect();if(i<=0||!r.width)return;const n=`${i}:${this.term.cols}`;n!==this.fitFor&&(this.fitFor=n,this.fontCap=Sr);const o=this.term.options.fontSize??Sr;r.width>i+.5&&(this.fontCap=Math.min(this.fontCap,o-.5));const a=Math.floor(o*(i/r.width)*2)/2,l=Math.max(n0,Math.min(this.fontCap,a));l!==o&&(this.term.options.fontSize=l)}dragWidth(e,s){if(e.button!==0)return;e.preventDefault(),s.setPointerCapture(e.pointerId),document.body.classList.add("resizing-panel");let i=null;const r=o=>{i=this.setWidth(innerWidth-o.clientX)},n=()=>{s.removeEventListener("pointermove",r),s.removeEventListener("pointerup",n),s.removeEventListener("pointercancel",n),document.body.classList.remove("resizing-panel"),i!==null&&(ci(Vn,String(i)),this.onResize())};s.addEventListener("pointermove",r),s.addEventListener("pointerup",n),s.addEventListener("pointercancel",n)}setWidth(e){const s=document.documentElement.style;if(e===null)return s.removeProperty("--panel-custom"),null;const i=Math.round(Math.max(l0,Math.min(innerWidth-kl,e)));return s.setProperty("--panel-custom",`min(${i}px, calc(100vw - ${kl}px))`),i}keepBottom(){this.pinned&&(this.host.scrollTop=this.host.scrollHeight)}atEdge(e){const s=this.host;return e<0?s.scrollTop<=0:s.scrollTop+s.clientHeight>=s.scrollHeight-2}toBottom(){this.pinned=!0,this.host.scrollTop=this.host.scrollHeight,this.release(),this.renderLive()}release(){const e=this.held;this.held=null,e!==null&&this.show(e)}renderLive(){this.liveBtn.hidden=this.pinned||!this.history,this.liveBtn.textContent=this.held!==null?"New output ↓":"Jump to bottom ↓"}onWheel(e){var o;if(!((o=this.pane)!=null&&o.agent)||this.history||e.ctrlKey)return;const s=this.host.querySelector(".xterm-screen"),i=e.deltaY*(e.deltaMode===1?i0:e.deltaMode===2?this.host.clientHeight:1);if(i===0||!this.atEdge(i<0?-1:1)){this.wheel=0;return}Math.sign(i)!==Math.sign(this.wheel)&&(this.wheel=0),this.wheel+=i;const r=Math.max(40,s.getBoundingClientRect().height*s0),n=Math.trunc(this.wheel/r);n&&(this.wheel-=n*r,this.send([{text:(n<0?e0:t0).repeat(Math.min(Math.abs(n),5))}]))}}function Ml(){return matchMedia("(hover: hover) and (pointer: fine)").matches}const d0=/\x1b(?:\[[0-9;:?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[()][A-Za-z0-9]|.)/g;function u0(t){return t.replace(d0,"")}function f0(t){let e=0;for(const s of t){const i=s.codePointAt(0);if(i<768)e+=1;else{if(i<=879||i===8205||i>=65024&&i<=65039)continue;e+=p0(i)?2:1}}return e}function p0(t){return t>=4352&&t<=4447||t>=11904&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=127744&&t<=129791||t>=131072&&t<=262141}const Tl=50;function _0(t){return t.git_root?St(fs(t.workspace_id),t.git_root):null}class m0{constructor(){w(this,"sheets",new Map);w(this,"queued",new Map);w(this,"seen",new Set)}reset(e,s){for(const i of[...this.sheets.keys()])fs(i)===e&&(this.sheets.delete(i),this.queued.delete(i));for(const i of s)this.list(St(e,i.root)).push(i),this.seen.add(i.id)}add(e,s){const i=St(e,s.root),r=this.list(i);r.push(s),r.length>Tl&&r.splice(0,r.length-Tl),this.queued.set(i,Math.min(r.length,(this.queued.get(i)??0)+1))}printed(e){const s=this.sheets.get(e)??[];return s.slice(0,s.length-(this.queued.get(e)??0))}printedCount(e){var s;return(((s=this.sheets.get(e))==null?void 0:s.length)??0)-(this.queued.get(e)??0)}latest(e){var s;return((s=this.sheets.get(e))==null?void 0:s[this.printedCount(e)-1])??null}done(e,s=!1){const i=this.queued.get(e)??0;i>0&&this.queued.set(e,s?0:i-1)}queuedCount(e){return this.queued.get(e)??0}unread(e){const s=this.sheets.get(e)??[];let i=0;for(let r=0,n=this.printedCount(e);r<n;r++)this.seen.has(s[r].id)||i++;return i}markRead(e){this.seen.add(e)}list(e){let s=this.sheets.get(e);return s||this.sheets.set(e,s=[]),s}}const Yn=720,Kn=460,El=150,g0=32/Math.SQRT1_2,y0=.3,v0="perspective(1800px)",b0=500;class w0{constructor(e){w(this,"el");w(this,"backdrop");w(this,"sheet");w(this,"nav");w(this,"count");w(this,"prevBtn");w(this,"nextBtn");w(this,"tabs");w(this,"key",null);w(this,"label","");w(this,"mode","edits");w(this,"index",0);w(this,"file",0);w(this,"jumping",0);w(this,"work",null);w(this,"asked",0);w(this,"askedAt",-1);w(this,"tray",()=>null);w(this,"busy",!1);w(this,"closing",!1);w(this,"returnFocus",null);w(this,"sync",0);w(this,"request",()=>!1);this.prints=e,this.el=document.createElement("div"),this.el.id="printout",this.el.hidden=!0,this.el.innerHTML=`
36
+ <div class="po-backdrop"></div>
37
+ <article class="po-sheet" role="dialog" aria-modal="true" aria-labelledby="po-path" tabindex="-1"></article>
38
+ <nav class="po-nav card">
39
+ <div class="po-tabs" role="tablist" aria-label="What to read">
40
+ <button role="tab" data-mode="edits" title="Each edit, as it was printed (U)">Edits <span class="n"></span></button>
41
+ <button role="tab" data-mode="uncommitted" title="Everything not committed yet (U)">Uncommitted</button>
42
+ </div>
43
+ <button class="btn" data-go="prev"></button>
44
+ <span class="po-count"></span>
45
+ <button class="btn" data-go="next"></button>
46
+ <button class="btn" data-go="close">Close<kbd>Esc</kbd></button>
47
+ </nav>`,document.body.appendChild(this.el),this.backdrop=this.el.querySelector(".po-backdrop"),this.sheet=this.el.querySelector(".po-sheet"),this.nav=this.el.querySelector(".po-nav"),this.count=this.el.querySelector(".po-count"),this.prevBtn=this.el.querySelector('[data-go="prev"]'),this.nextBtn=this.el.querySelector('[data-go="next"]'),this.tabs=[...this.el.querySelectorAll("[data-mode]")],this.backdrop.addEventListener("click",()=>this.close()),this.nav.addEventListener("click",s=>{const i=s.target.closest("button");i!=null&&i.dataset.mode?this.setMode(i.dataset.mode):(i==null?void 0:i.dataset.go)==="prev"?this.step(-1):(i==null?void 0:i.dataset.go)==="next"?this.step(1):(i==null?void 0:i.dataset.go)==="close"&&this.close()}),this.sheet.addEventListener("click",s=>{const i=s.target.closest("[data-jump]");i&&(s.preventDefault(),this.goToFile(Number(i.dataset.jump)))}),this.sheet.addEventListener("scroll",()=>this.fileInView(),!0),addEventListener("keydown",s=>{if(!(!this.isOpen()||s.metaKey||s.ctrlKey||s.altKey)){if(s.key==="Escape")this.close();else if(s.key==="ArrowLeft")this.step(-1);else if(s.key==="ArrowRight")this.step(1);else if(s.key==="u"||s.key==="U")this.setMode(this.mode==="edits"?"uncommitted":"edits");else return;s.preventDefault(),s.stopPropagation()}},!0),addEventListener("resize",()=>{this.isOpen()&&!this.busy&&this.place(this.rest())})}isOpen(){return this.key!==null}open(e,s,i){if(this.isOpen())return;this.key=e,this.label=s,this.tray=i,this.index=Math.max(0,this.sheets().length-1),this.work=null,this.mode=this.sheets().length?"edits":"uncommitted",this.mode==="uncommitted"&&this.ask(),this.returnFocus=document.activeElement,this.el.hidden=!1,this.el.classList.remove("closing"),document.body.classList.add("printout-open"),this.render(),this.sync=window.setInterval(()=>this.syncNav(),b0),this.sheet.focus({preventScroll:!0});const r=this.trayPose(),n=this.rest();this.busy=!0,this.animate(this.backdrop,[{opacity:0},{opacity:1}],Yn*.7,"ease-out"),this.animate(this.nav,[{opacity:0,transform:"translate(-50%, 12px)"},{opacity:0,offset:.55},{opacity:1,transform:"translate(-50%, 0)"}],Yn,"ease-out"),this.animate(this.sheet,[{transform:this.transform(r),boxShadow:"0 1px 2px #0000",opacity:1},{transform:this.transform(this.lifted(r,n)),boxShadow:"0 40px 70px #0007",opacity:1,offset:.42},{transform:this.transform(n),boxShadow:"0 30px 80px #000a",opacity:1}],Yn,"cubic-bezier(.25,.75,.25,1)").then(()=>{this.closing||(this.busy=!1)})}close(){if(!this.isOpen()||this.closing)return;this.closing=!0,clearInterval(this.sync),this.el.classList.add("closing");const e=this.freeze(this.sheet),s=this.trayPose(),i=!this.tray();this.busy=!0,this.animate(this.backdrop,[{opacity:1},{opacity:0}],Kn,"ease-in"),this.animate(this.nav,[{opacity:1},{opacity:0}],Kn*.4,"ease-in"),this.animate(this.sheet,[{transform:e,opacity:1},{transform:this.transform(this.lifted(s,this.rest())),opacity:1,offset:.45},{transform:this.transform(s),opacity:i?0:1}],Kn,"cubic-bezier(.5,0,.75,.4)").then(()=>{this.el.hidden=!0,document.body.classList.remove("printout-open"),this.key=null,this.busy=this.closing=!1,this.returnFocus instanceof HTMLElement&&this.returnFocus.focus({preventScroll:!0})})}receive(e,s,i){if(e!==this.key||s!==this.asked||this.closing||(this.work={...i,at:Date.now()},this.mode!=="uncommitted"))return;const r=this.sheet.querySelector(".po-body"),n=(r==null?void 0:r.scrollTop)??0;this.render();const o=this.sheet.querySelector(".po-body");o&&(o.scrollTop=n),this.fileInView()}sheets(){return this.key?this.prints.printed(this.key):[]}ask(){this.key&&(this.askedAt=this.sheets().length,this.request(this.key,++this.asked)||(this.work={files:[],incomplete:!1,error:"The bridge is not connected.",at:Date.now()}))}setMode(e){e===this.mode||this.busy||this.closing||(e==="uncommitted"&&this.ask(),this.swap(e==="uncommitted"?1:-1,()=>{this.mode=e}))}step(e){if(this.mode==="uncommitted"){this.goToFile(this.file+e);return}const s=this.index+e;s<0||s>=this.sheets().length||this.swap(e,()=>{this.index=s})}async swap(e,s){if(this.busy||this.closing)return;this.busy=!0;const i=this.rest(),r=o=>({...i,x:i.x+o*70,turn:i.turn+o*5,scale:.97});if(await this.animate(this.sheet,[{transform:this.transform(i),opacity:1},{transform:this.transform(r(-e)),opacity:0}],El,"ease-in"),this.closing)return;s(),this.render();const n=this.rest();await this.animate(this.sheet,[{transform:this.transform({...r(e),y:n.y}),opacity:0},{transform:this.transform(n),opacity:1}],El*1.3,"ease-out"),this.closing||(this.busy=!1)}goToFile(e){const s=this.sheet.querySelector(".po-body"),i=s==null?void 0:s.querySelector(`.po-file[data-file="${e}"]`);if(!s||!i)return;this.file=e,this.jumping=performance.now()+700;const r=matchMedia("(prefers-reduced-motion: reduce)").matches;s.scrollTo({top:i.offsetTop-s.offsetTop-4,behavior:r?"auto":"smooth"}),this.syncNav()}fileInView(){if(this.mode!=="uncommitted"||performance.now()<this.jumping)return;const e=this.sheet.querySelector(".po-body");if(!e)return;let s=0;for(const i of e.querySelectorAll(".po-file"))i.offsetTop-e.offsetTop<=e.scrollTop+24&&(s=Number(i.dataset.file));s!==this.file&&(this.file=s,this.syncNav())}syncNav(){var r;const e=this.sheets().length,s=this.mode==="edits";for(const n of this.tabs){const o=n.dataset.mode===this.mode;n.setAttribute("aria-selected",String(o)),n.classList.toggle("on",o)}this.tabs[0].querySelector(".n").textContent=e?String(e):"";const i=((r=this.work)==null?void 0:r.files.length)??0;this.prevBtn.textContent=s?"‹ Older":"‹ File",this.nextBtn.textContent=s?"Newer ›":"File ›",this.prevBtn.title=s?"Older sheet (←)":"Previous file (←)",this.nextBtn.title=s?"Newer sheet (→)":"Next file (→)",this.prevBtn.disabled=s?this.index<=0:this.file<=0,this.nextBtn.disabled=s?this.index>=e-1:this.file>=i-1,this.count.textContent=s?e?`${this.index+1} / ${e}`:"0 / 0":i?`${this.file+1} / ${i}`:"—",!s&&this.isOpen()&&!this.closing&&e!==this.askedAt&&this.ask()}render(){this.sheet.classList.toggle("long",this.mode==="uncommitted"),this.mode==="uncommitted"?this.renderUncommitted():this.renderSheet(),this.syncNav()}renderSheet(){const e=this.sheets(),s=e[this.index];if(!s){this.sheet.innerHTML=`
48
+ <header class="po-head"><div class="po-meta"><span>kauak print service</span><span>${se(this.label)}</span></div>
49
+ <h2 id="po-path" class="po-path">Nothing printed yet</h2></header>
50
+ <div class="po-body po-empty">Each time a file in this room's checkout changes, the printer prints a sheet with what changed.
51
+ Everything not committed yet is under Uncommitted.</div>
52
+ <footer class="po-foot">· · ·</footer>`;return}this.prints.markRead(s.id);const i=new Date(s.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});this.sheet.innerHTML=`
53
+ <header class="po-head">
54
+ <div class="po-meta"><span>kauak print service · ${se(this.label)}</span><span>#${String(this.index+1).padStart(3,"0")} · ${i}</span></div>
55
+ <h2 id="po-path" class="po-path">${Al(s.path)}</h2>
56
+ <div class="po-sub">${jn(s)}${Cr(s.added,s.removed)}<span class="ago">${C0(s.at)}</span></div>
57
+ </header>
58
+ <div class="po-body">${Pl(s)}</div>
59
+ <footer class="po-foot">— sheet ${this.index+1} of ${e.length} —</footer>`,this.sheet.querySelector(".po-body").scrollTop=0}renderUncommitted(){const e=this.work,s=h=>`
60
+ <header class="po-head">
61
+ <div class="po-meta"><span>kauak print service · ${se(this.label)}</span><span>uncommitted${e?` · ${S0(e.at)}`:""}</span></div>
62
+ <h2 id="po-path" class="po-path">Uncommitted changes</h2>
63
+ ${h}
64
+ </header>`;if(!e){this.sheet.innerHTML=`${s("")}<div class="po-body po-empty po-printing">Printing the working tree<span class="dots"></span></div><footer class="po-foot">· · ·</footer>`;return}if(e.error||!e.files.length){const h=e.error?`Could not read the checkout: ${se(e.error)}`:"Nothing uncommitted: the working tree matches the last commit.";this.sheet.innerHTML=`${s("")}<div class="po-body po-empty">${h}</div><footer class="po-foot">· · ·</footer>`;return}this.file=Math.min(this.file,e.files.length-1);const i=e.files.reduce((h,c)=>h+c.added,0),r=e.files.reduce((h,c)=>h+c.removed,0),n=`<div class="po-sub"><span class="files">${e.files.length} file${e.files.length===1?"":"s"}</span>${Cr(i,r)}<span class="ago">against the last commit</span></div>`,o=e.files.map((h,c)=>`<li><a href="#" data-jump="${c}">${jn(h,!0)}<span class="p">${se(h.path)}</span>${Cr(h.added,h.removed)}</a></li>`).join(""),a=e.files.map((h,c)=>`
65
+ <section class="po-file" data-file="${c}">
66
+ <h3 class="po-file-h">${jn(h)}<span class="p">${Al(h.path)}</span>${Cr(h.added,h.removed)}</h3>
67
+ ${h.from?`<div class="po-from">from ${se(h.from)}</div>`:""}
68
+ ${Pl(h)}
69
+ </section>`).join(""),l=e.incomplete?"… there was more than fits in one printout":"— end of printout —";this.sheet.innerHTML=`${s(n)}<div class="po-body"><ol class="po-index">${o}</ol>${a}<div class="po-more">${l}</div></div>
70
+ <footer class="po-foot">— uncommitted · ${e.files.length} file${e.files.length===1?"":"s"} —</footer>`}rest(){const e=this.sheet.offsetWidth,s=this.sheet.offsetHeight,i=this.nav.offsetHeight+36;return{x:innerWidth/2-e/2,y:Math.max(12,(innerHeight-i-s)/2),tilt:0,turn:-1.2,scale:1}}trayPose(){const e=this.sheet.offsetWidth,s=this.sheet.offsetHeight,i=this.tray();if(!i)return{x:innerWidth/2-e/2,y:innerHeight+s*.2,tilt:50,turn:20,scale:.3};const r=Math.max(.01,y0*g0*i.scale/e);return{x:i.x-e/2,y:i.y-s/2,tilt:60,turn:45,scale:r}}lifted(e,s){return{x:e.x+(s.x-e.x)*.4,y:e.y+(s.y-e.y)*.4-Math.min(120,innerHeight*.12),tilt:32,turn:16,scale:e.scale+(s.scale-e.scale)*.35}}transform(e){return`translate(${e.x}px, ${e.y}px) ${v0} rotateX(${e.tilt}deg) rotateZ(${e.turn}deg) scale(${e.scale})`}place(e){this.sheet.style.transform=this.transform(e)}freeze(e){const s=getComputedStyle(e).transform;for(const i of e.getAnimations())i.cancel();return e.style.transform=s==="none"?"":s,e.style.transform}animate(e,s,i,r){const{offset:n,easing:o,composite:a,...l}=s[s.length-1],h=()=>{for(const[d,u]of Object.entries(l))e.style.setProperty(k0(d),String(u))};if(matchMedia("(prefers-reduced-motion: reduce)").matches)return h(),Promise.resolve();for(const d of e.getAnimations())d.cancel();const c=e.animate(s,{duration:i,easing:r,fill:"forwards"});return c.finished.then(()=>{h(),c.cancel()},()=>{})}}function Pl(t){const e=t.truncated?'<div class="po-more">… the rest did not fit on the sheet</div>':"";return t.note?`<div class="po-note">${se(t.note)}</div>`:x0(t.diff)+e}function x0(t){let e=0,s=0;const i=[];for(const r of t.split(`
71
+ `)){const n=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(r);if(n){e=Number(n[1]),s=Number(n[2]),i.push(`<div class="r hunk"><span></span><span></span><span></span><code>${se(r)}</code></div>`);continue}const o=r[0],a=se(r.slice(1));o==="+"?i.push(`<div class="r add"><span></span><span>${s++}</span><span>+</span><code>${a}</code></div>`):o==="-"?i.push(`<div class="r del"><span>${e++}</span><span></span><span>−</span><code>${a}</code></div>`):i.push(`<div class="r"><span>${e++}</span><span>${s++}</span><span></span><code>${a}</code></div>`)}return i.join("")}function jn(t,e=!1){const s=t.untracked?"untracked":t.change,i=t.untracked?"?":s[0].toUpperCase();return`<span class="chg chg-${t.untracked?"added":t.change}" title="${s}">${e?i:s}</span>`}function Cr(t,e){return`<span class="add${t?"":" none"}">+${t}</span><span class="del${e?"":" none"}">−${e}</span>`}function Al(t){const e=t.lastIndexOf("/");return`<span class="dir">${se(t.slice(0,e+1))}</span>${se(t.slice(e+1))}`}function S0(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function C0(t){const e=Math.max(0,Math.round((Date.now()-t)/1e3));return e<10?"just now":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)} min ago`:`${Math.floor(e/3600)} h ago`}function k0(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}const Cs=[{freq:95.5,name:"CLIAMP Lofi",genre:"lofi hip hop",url:"https://radio.cliamp.stream/lofi/stream",site:"https://cliamp.stream"}],$t=87.5,js=108,Rl=.8,M0=.2,T0=70,du="kauak.radio";class E0{constructor(){w(this,"card",document.getElementById("radio"));w(this,"toggle",document.getElementById("btn-radio"));w(this,"dial",document.getElementById("radio-dial"));w(this,"scale",document.getElementById("radio-scale"));w(this,"needle",document.getElementById("radio-needle"));w(this,"knob",document.getElementById("radio-knob"));w(this,"powerBtn",document.getElementById("radio-power"));w(this,"volume",document.getElementById("radio-volume"));w(this,"freqEl",document.getElementById("radio-freq"));w(this,"nameEl",document.getElementById("radio-name"));w(this,"infoEl",document.getElementById("radio-info"));w(this,"credit",document.getElementById("radio-credit"));w(this,"bars",[...this.card.querySelectorAll(".bars i")]);w(this,"audio",new Audio);w(this,"graph",null);w(this,"freq",Cs[0].freq);w(this,"on",!1);w(this,"wantResume",!1);w(this,"tuned",null);w(this,"live",!1);w(this,"failed",!1);w(this,"tuneTimer",0);w(this,"settleTimer",0);w(this,"offTimer",0);w(this,"anim",0);w(this,"target",0);w(this,"isTyping",()=>!1);const e=P0(),s=typeof e.freq=="number"?Math.min(js,Math.max($t,e.freq)):null,i=s!==null&&this.reception(s).station!==null;i&&(this.freq=s),typeof e.volume=="number"&&(this.volume.value=String(e.volume));const r=c=>`${(c-$t)/(js-$t)*100}%`;let n="";for(let c=88;c<=108;c++)n+=`<i class="tick${c%4===0?" major":""}" style="left:${r(c)}"></i>`,c%4===0&&(n+=`<span class="num" style="left:${r(c)}">${c}</span>`);for(const c of Cs)n+=`<b class="st" style="left:${r(c.freq)}" title="${c.freq} · ${c.name}"></b>`;this.scale.insertAdjacentHTML("afterbegin",n);const o=c=>new URL(c.site).host;for(const c of Cs){const d=document.createElement("p"),u=document.createElement("a");Object.assign(u,{href:c.site,target:"_blank",rel:"noopener noreferrer",textContent:o(c)}),d.append(`Stream: ${c.name} · `,u),this.credit.append(d)}const a=[...new Set(Cs.map(o))],l=document.createElement("p");l.textContent=`Plays straight from ${a.join(", ")}; your browser connects to ${a.length>1?"them":"it"} directly.`,this.credit.append(l),this.audio.crossOrigin="anonymous",this.audio.preload="none",this.audio.addEventListener("playing",()=>{this.live=!0,this.failed=!1,this.update()});for(const c of["waiting","emptied","pause"])this.audio.addEventListener(c,()=>{this.live=!1,this.update()});this.audio.addEventListener("error",()=>{if(!this.audio.getAttribute("src"))return;this.live=!1,this.failed=!0,this.update();const c=this.tuned;window.setTimeout(()=>{this.on&&this.failed&&this.tuned===c&&this.load(c)},5e3)}),this.toggle.addEventListener("click",()=>this.show(this.card.hidden)),this.powerBtn.addEventListener("click",()=>this.power(!this.lit)),document.getElementById("radio-prev").addEventListener("click",()=>this.seek(-1)),document.getElementById("radio-next").addEventListener("click",()=>this.seek(1)),this.volume.addEventListener("input",()=>{this.update(),this.persist()}),this.drag(this.dial,c=>{const d=this.scale.getBoundingClientRect();this.setFreq($t+(c.clientX-d.left)/d.width*(js-$t))}),this.drag(this.knob,(c,d,u)=>{!d&&!u?this.knob.focus():this.setFreq(this.freq+(d-u)*.025)});const h=c=>{c.preventDefault(),this.stopSweep(),this.setFreq(this.freq-Math.sign(c.deltaY)*Math.min(Math.abs(c.deltaY),100)*.0015),window.clearTimeout(this.settleTimer),this.settleTimer=window.setTimeout(()=>this.settle(),350)};if(this.dial.addEventListener("wheel",h,{passive:!1}),this.knob.addEventListener("wheel",h,{passive:!1}),this.knob.addEventListener("keydown",c=>{const d=p=>{this.stopSweep(),this.setFreq(Math.round((this.freq+p)*10)/10),this.persist()},f={ArrowRight:()=>d(.1),ArrowUp:()=>d(.1),ArrowLeft:()=>d(-.1),ArrowDown:()=>d(-.1),PageUp:()=>this.seek(1),PageDown:()=>this.seek(-1),Home:()=>d($t-this.freq),End:()=>d(js-this.freq)}[c.key];f&&(c.preventDefault(),c.stopPropagation(),f())}),addEventListener("keydown",c=>{c.target instanceof HTMLInputElement||c.target instanceof HTMLTextAreaElement||this.isTyping()||c.metaKey||c.ctrlKey||c.altKey||c.key==="m"&&this.power(!this.lit)}),addEventListener("keydown",c=>{c.key==="Escape"&&!this.card.hidden&&!this.isTyping()&&(c.stopPropagation(),this.show(!1))},!0),addEventListener("pointerdown",c=>{const d=c.target;!this.card.hidden&&!this.card.contains(d)&&!this.toggle.contains(d)&&this.show(!1)}),e.on===!0&&i){this.wantResume=!0;const c=d=>{this.powerBtn.contains(d.target)||(removeEventListener("pointerdown",c),removeEventListener("keydown",c),this.wantResume&&this.power(!0))};addEventListener("pointerdown",c),addEventListener("keydown",c)}this.update()}get lit(){return this.on||this.wantResume}show(e){this.card.hidden=!e,this.toggle.setAttribute("aria-expanded",String(e))}power(e){if(this.wantResume=!1,this.on=e,window.clearTimeout(this.offTimer),e){this.graph??(this.graph=this.build()),this.graph.ctx.resume();const{station:s}=this.reception();s!==this.tuned||!this.live?this.load(s):this.update()}else this.update(),this.offTimer=window.setTimeout(()=>{var s;this.load(null),(s=this.graph)==null||s.ctx.suspend()},250);this.persist()}build(){const e=new AudioContext,s=new GainNode(e,{gain:0});s.connect(e.destination);const i=e.createBuffer(1,e.sampleRate*2,e.sampleRate),r=i.getChannelData(0);for(let h=0;h<r.length;h++)r[h]=Math.random()*2-1;const n=new AudioBufferSourceNode(e,{buffer:i,loop:!0}),o=new GainNode(e,{gain:0});n.connect(new BiquadFilterNode(e,{type:"bandpass",frequency:2200,Q:.5})).connect(o).connect(s),n.start();const a=new BiquadFilterNode(e,{type:"lowpass",frequency:500}),l=new GainNode(e,{gain:0});return e.createMediaElementSource(this.audio).connect(a).connect(l).connect(s),{ctx:e,master:s,music:l,tone:a,hiss:o}}setFreq(e){this.freq=Math.min(js,Math.max($t,e));const{station:s}=this.reception();this.on&&s!==this.tuned&&(window.clearTimeout(this.tuneTimer),this.tuneTimer=window.setTimeout(()=>{const i=this.reception().station;this.on&&i!==this.tuned&&this.load(i)},300)),this.update()}load(e){window.clearTimeout(this.tuneTimer),this.tuned=e,this.live=!1,this.failed=!1,e&&this.on?(this.audio.src=e.url,this.audio.play().catch(()=>{})):this.audio.getAttribute("src")&&(this.audio.pause(),this.audio.removeAttribute("src"),this.audio.load()),this.update()}reception(e=this.freq){let s=null,i=1/0;for(const r of Cs){const n=Math.abs(r.freq-e);n<i&&(i=n,s=r)}return i<Rl?{station:s,signal:1-i/Rl}:{station:null,signal:0}}settle(){const{station:e}=this.reception();e&&Math.abs(e.freq-this.freq)>.01?this.sweepTo(e.freq,180):this.persist()}seek(e){const s=this.anim?this.target:this.freq,i=e>0?Cs:[...Cs].reverse(),r=i.find(n=>e>0?n.freq>s+.05:n.freq<s-.05)??i[0];this.sweepTo(r.freq,Math.min(1400,250+Math.abs(r.freq-this.freq)*70))}sweepTo(e,s){this.stopSweep(),this.target=e;const i=this.freq,r=performance.now(),n=o=>{const a=Math.min(1,(o-r)/s);this.setFreq(i+(e-i)*(a<.5?2*a*a:1-(-2*a+2)**2/2)),a<1?this.anim=requestAnimationFrame(n):(this.anim=0,this.persist())};this.anim=requestAnimationFrame(n)}stopSweep(){cancelAnimationFrame(this.anim),this.anim=0}drag(e,s){e.addEventListener("pointerdown",i=>{if(i.button!==0)return;i.preventDefault(),this.stopSweep(),e.setPointerCapture(i.pointerId);let r=i.clientX,n=i.clientY;s(i,0,0);const o=l=>{s(l,l.clientX-r,l.clientY-n),r=l.clientX,n=l.clientY},a=()=>{e.removeEventListener("pointermove",o),e.removeEventListener("pointerup",a),e.removeEventListener("pointercancel",a),this.settle()};e.addEventListener("pointermove",o),e.addEventListener("pointerup",a),e.addEventListener("pointercancel",a)})}update(){const{station:e,signal:s}=this.reception(),i=this.on&&this.live&&e===this.tuned?s:0,r=this.graph;if(r){const o=r.ctx.currentTime,a=.06;r.master.gain.setTargetAtTime(this.on?(Number(this.volume.value)/100)**2:0,o,a),r.music.gain.setTargetAtTime(i**1.5,o,a),r.hiss.gain.setTargetAtTime(M0*(1-i)**2,o,a),r.tone.frequency.setTargetAtTime(500+i**3*19500,o,a)}const n=this.freq.toFixed(1);this.needle.style.left=`${(this.freq-$t)/(js-$t)*100}%`,this.knob.style.setProperty("--turn",`${(this.freq-$t)*T0}deg`),this.knob.setAttribute("aria-valuenow",n),this.knob.setAttribute("aria-valuetext",`${n} FM${e?`, ${e.name}`:""}`),this.freqEl.textContent=n,this.nameEl.textContent=(e==null?void 0:e.name)??"—",this.infoEl.textContent=this.wantResume?"click anywhere to resume":this.on?e?this.failed?"no signal, retrying…":i>0?e.genre:"tuning…":"static":(e==null?void 0:e.genre)??"between stations",this.bars.forEach((o,a)=>{o.classList.toggle("lit",this.on&&s>a/this.bars.length)}),this.card.dataset.state=this.lit?i>.85?"locked":"on":"off",this.powerBtn.setAttribute("aria-pressed",String(this.lit)),this.toggle.classList.toggle("on",this.lit),this.toggle.classList.toggle("playing",i>0),this.toggle.title=this.on&&e?`Radio · ${e.name}, ${e.freq} FM (M: on/off)`:"Radio (M: on/off)"}persist(){const e={freq:Math.round(this.freq*10)/10,volume:Number(this.volume.value),on:this.lit};ci(du,JSON.stringify(e))}}function P0(){try{const t=JSON.parse(li(du)??"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}const ji={"office.theme":{defaultId:"kauak.classic"},"office.characters":{defaultId:"kauak.classic"}},uu="kauak.appearance.v1",A0="kauak.",ih=64*1024,da=8,rn=15e5,Bl=["working","idle","blocked","done","unknown"],ze=(t,e)=>{throw new Error(`${t}: ${e}`)};function vt(t,e){return(!t||typeof t!="object"||Array.isArray(t))&&ze(e,"expected an object"),t}function Vt(t,e,s){for(const i of Object.keys(t))e.includes(i)||ze(`${s}.${i}`,"unsupported field")}function ys(t,e,s=160){return(typeof t!="string"||!t.trim()||t.length>s)&&ze(e,`expected text of 1–${s} characters`),t}function rh(t,e){const s=ys(t,e,80);return/^[a-z0-9][a-z0-9.-]*$/.test(s)||ze(e,"use lowercase letters, numbers, dots or hyphens"),s}function It(t,e,s,i){return(typeof t!="number"||!Number.isFinite(t)||t<s||t>i)&&ze(e,`expected a number between ${s} and ${i}`),t}function ui(t,e,s){return e.includes(t)||ze(s,`expected ${e.join(" or ")}`),t}function wn(t,e){return t!==1&&ze(e,"only version 1 is supported"),1}function Xi(t,e){return(typeof t!="string"||!/^#[0-9a-fA-F]{6}$/.test(t))&&ze(e,"expected #RRGGBB"),t.toLowerCase()}function nn(t,e){return(!Array.isArray(t)||t.length<1||t.length>12)&&ze(e,"expected 1–12 colors"),t.map((s,i)=>Xi(s,`${e}[${i}]`))}function R0(t,e,s){const i=vt(t,s);return Vt(i,e,s),Object.fromEntries(e.map(r=>[r,Xi(i[r],`${s}.${r}`)]))}function B0(t,e){const s=vt(t,e);return Vt(s,["id","name","origin","x","y","z","width","height","facing"],e),{id:rh(s.id,`${e}.id`),name:ys(s.name,`${e}.name`,60),origin:ui(s.origin,["campus","first-room"],`${e}.origin`),x:It(s.x,`${e}.x`,-3,8),y:It(s.y,`${e}.y`,-3,8),z:It(s.z,`${e}.z`,0,40),width:It(s.width,`${e}.width`,1,7),height:It(s.height,`${e}.height`,20,64),facing:ui(s.facing,["x","y"],`${e}.facing`)}}function L0(t){const e="office.theme",s=vt(t,e);Vt(s,["apiVersion","palette","materials","architecture","bannerAnchors"],e);const i=vt(s.palette,`${e}.palette`),r=["background","ground","groundLine","path","wall","accent","focus","light"];Vt(i,[...r,"rugs","wings"],`${e}.palette`);const n={...Object.fromEntries(r.map(h=>[h,Xi(i[h],`${e}.palette.${h}`)])),rugs:nn(i.rugs,`${e}.palette.rugs`),wings:nn(i.wings,`${e}.palette.wings`)},o=R0(s.materials,["wood","woodDark","metal","chair","pot","leaf","leafDark","paper","screenOff","white"],`${e}.materials`),a=vt(s.architecture,`${e}.architecture`);Vt(a,["wallHeight","floorPattern","decor","lightIntensity"],`${e}.architecture`),(!Array.isArray(s.bannerAnchors)||s.bannerAnchors.length<1||s.bannerAnchors.length>4)&&ze(`${e}.bannerAnchors`,"expected 1–4 banner locations");const l=s.bannerAnchors.map((h,c)=>B0(h,`${e}.bannerAnchors[${c}]`));return new Set(l.map(h=>h.id)).size!==l.length&&ze(`${e}.bannerAnchors`,"duplicate location id"),{apiVersion:wn(s.apiVersion,`${e}.apiVersion`),palette:n,materials:o,bannerAnchors:l,architecture:{wallHeight:It(a.wallHeight,`${e}.architecture.wallHeight`,24,48),floorPattern:ui(a.floorPattern,["checker","inset","planks"],`${e}.architecture.floorPattern`),decor:ui(a.decor,["botanical","technical","alpine"],`${e}.architecture.decor`),lightIntensity:It(a.lightIntensity,`${e}.architecture.lightIntensity`,0,1)}}}function I0(t){const e="office.characters",s=vt(t,e);Vt(s,["apiVersion","model","skin","hair","shell","visor","animation"],e);const i=vt(s.animation,`${e}.animation`);Vt(i,["tempo","amplitude","glyphs"],`${e}.animation`);const r=vt(i.tempo,`${e}.animation.tempo`);return Vt(r,[...Bl],`${e}.animation.tempo`),(!Array.isArray(i.glyphs)||i.glyphs.length<1||i.glyphs.length>16)&&ze(`${e}.animation.glyphs`,"expected 1–16 glyphs"),{apiVersion:wn(s.apiVersion,`${e}.apiVersion`),model:ui(s.model,["human","robot","climber","suit"],`${e}.model`),skin:nn(s.skin,`${e}.skin`),hair:nn(s.hair,`${e}.hair`),shell:Xi(s.shell,`${e}.shell`),visor:Xi(s.visor,`${e}.visor`),animation:{tempo:Object.fromEntries(Bl.map(n=>[n,It(r[n],`${e}.animation.tempo.${n}`,0,3)])),amplitude:It(i.amplitude,`${e}.animation.amplitude`,0,2),glyphs:i.glyphs.map((n,o)=>ys(n,`${e}.animation.glyphs[${o}]`,4))}}}function nh(t,e=!1){const s=vt(t,"package");Vt(s,["schemaVersion","id","name","version","description","capabilities"],"package");const i=rh(s.id,"package.id");!e&&i.startsWith(A0)&&ze("package.id","kauak.* is reserved for included packages");const r=ys(s.version,"package.version",32);/^\d+\.\d+\.\d+$/.test(r)||ze("package.version","expected a version such as 1.0.0");const n=vt(s.capabilities,"package.capabilities");Vt(n,Object.keys(ji),"package.capabilities"),Object.keys(n).length||ze("package.capabilities","declare at least one capability");const o={};return n["office.theme"]!==void 0&&(o["office.theme"]=L0(n["office.theme"])),n["office.characters"]!==void 0&&(o["office.characters"]=I0(n["office.characters"])),{schemaVersion:wn(s.schemaVersion,"package.schemaVersion"),id:i,name:ys(s.name,"package.name",60),version:r,description:ys(s.description,"package.description",240),capabilities:o}}function fu(t){new TextEncoder().encode(t).byteLength>ih&&ze("package","file exceeds 64 KB");let e;try{e=JSON.parse(t)}catch{ze("package","choose a valid JSON file")}return nh(e)}class Zi{constructor(e,s=[]){w(this,"entries",new Map);w(this,"warnings",[]);var i;for(const r of e)try{this.register(r,!0)}catch(n){this.warnings.push(`Skipped an included package: ${n.message}`)}for(const r of s)try{this.register(r)}catch(n){this.warnings.push(`Skipped a saved package: ${n.message}`)}for(const[r,n]of Object.entries(ji))if(!((i=this.entries.get(n.defaultId))!=null&&i.capabilities[r]))throw new Error(`Missing default for ${r}`)}copy(){return Object.assign(Object.create(Zi.prototype),{entries:new Map(this.entries),warnings:[...this.warnings]})}register(e,s=!1){const i=nh(e,s);if(this.entries.has(i.id))throw new Error(`Package ${i.id} is already installed. Remove the custom package before replacing it.`);return this.entries.set(i.id,i),i}list(e){return[...this.entries.values()].filter(s=>s.capabilities[e])}resolve(e,s){const i=this.entries.get(s);return i!=null&&i.capabilities[e]?{package:i,fallback:!1}:{package:this.entries.get(ji[e].defaultId),fallback:!0}}}function pu(){return{schemaVersion:1,selections:Object.fromEntries(Object.entries(ji).map(([t,e])=>[t,e.defaultId])),packages:[],banner:null}}function _u(t){const e=vt(t,"banner"),s=ys(e.dataUrl,"banner.image",rn);/^data:image\/png;base64,[A-Za-z0-9+/]+={0,2}$/.test(s)||ze("banner.image","expected a locally processed PNG image");const i=It(e.width,"banner.width",1,1600),r=It(e.height,"banner.height",1,800);return(!Number.isInteger(i)||!Number.isInteger(r)||typeof e.visible!="boolean")&&ze("banner","invalid size or visibility"),{dataUrl:s,name:ys(e.name,"banner.name",120),width:i,height:r,anchorId:rh(e.anchorId,"banner.location"),visible:e.visible,background:e.background===void 0?"light":ui(e.background,["light","dark"],"banner.background")}}function D0(t){try{return O0(t.getItem(uu))}catch{return{value:pu(),warnings:["Saved appearance settings could not be read. Included packages are being used."]}}}function O0(t){const e=pu(),s=[];if(!t)return{value:e,warnings:s};if(t.length>rn+ih*da+4096)throw new Error("saved settings exceed the size limit");const i=vt(JSON.parse(t),"settings");wn(i.schemaVersion,"settings.schemaVersion");const r=vt(i.selections,"settings.selections");for(const n of Object.keys(ji)){const o=r[n];typeof o=="string"&&(e.selections[n]=o)}if(Array.isArray(i.packages))for(const n of i.packages.slice(0,da))try{e.packages.push(fu(JSON.stringify(n)))}catch(o){s.push(`Skipped a saved package: ${o.message}`)}if(i.banner!=null)try{e.banner=_u(i.banner)}catch{s.push("The saved banner could not be restored. Upload it again.")}return{value:e,warnings:s}}function F0(t,e){try{return t.setItem(uu,JSON.stringify(e)),null}catch{return"This browser could not save the change. Free some site storage or allow local storage, then try again."}}function mu(t,e){return t.bannerAnchors.find(s=>s.id===e)??t.bannerAnchors[0]}const le=t=>Number.parseInt(t.slice(1),16),$0=1,N0="example.harbor",H0="Harbor office",W0="1.0.0",z0="An example custom office palette. Mix it with either included character set.",G0={"office.theme":{apiVersion:1,palette:{background:"#182c2b",ground:"#294542",groundLine:"#426282",path:"#4a667f",wall:"#567b72",accent:"#e8cb8c",focus:"#a5cae0",light:"#b5e6ff",rugs:["#87cddd","#7ca5ce"],wings:["#476962","#54716b"]},materials:{wood:"#89aaba",woodDark:"#416580",metal:"#b6cfda",chair:"#365276",pot:"#51738a",leaf:"#82d8ed",leafDark:"#446c88",paper:"#d5e9f1",screenOff:"#0d1017",white:"#eef8fa"},architecture:{wallHeight:38,floorPattern:"inset",decor:"technical",lightIntensity:.18},bannerAnchors:[{id:"entrance",name:"Entrance sign",origin:"campus",x:.2,y:-2.4,z:14,width:5.8,height:58,facing:"x"},{id:"studio",name:"First room wall",origin:"first-room",x:.5,y:0,z:32,width:3.8,height:46,facing:"x"}]}},U0={schemaVersion:$0,id:N0,name:H0,version:W0,description:z0,capabilities:G0},q0=1,V0="kauak.classic",Y0="Classic office",K0="1.0.0",j0="The original office: warm wood desks, leafy corners and people at work.",X0={"office.theme":{apiVersion:1,palette:{background:"#171a26",ground:"#1f2230",groundLine:"#272b3b",path:"#2a2e40",wall:"#5a6080",accent:"#ffd166",focus:"#5a6aa8",light:"#fff2d0",rugs:["#d97757","#6f7bf7"],wings:["#3a3f55","#3d4452","#44405a","#3a4a4e","#4a4040"]},materials:{wood:"#8b6b4a",woodDark:"#6f5238",metal:"#6b7089",chair:"#2b2e3b",pot:"#a0563b",leaf:"#4f9d5a",leafDark:"#3a7a44",paper:"#d8dbe6",screenOff:"#0d1017",white:"#e6e8f0"},architecture:{wallHeight:30,floorPattern:"checker",decor:"botanical",lightIntensity:.105},bannerAnchors:[{id:"entrance",name:"Entrance sign",origin:"campus",x:.2,y:-2.4,z:14,width:5.8,height:58,facing:"x"},{id:"studio",name:"First room wall",origin:"first-room",x:.5,y:0,z:32,width:3.8,height:46,facing:"x"}]},"office.characters":{apiVersion:1,model:"human",skin:["#f1d3b3","#e0b48f","#c68642","#8d5524","#ffdbac"],hair:["#2b1d14","#5a3a22","#c7813a","#1b1b1f","#8c2f2f","#e0c080","#4a4e69"],shell:"#e6e8f0",visor:"#2ec4b6",animation:{tempo:{working:1,idle:1,blocked:1,done:1,unknown:1},amplitude:1,glyphs:["{","}",";","=>","()","fn","if","λ","0x","//","<>","&&"]}}},Z0={schemaVersion:q0,id:V0,name:Y0,version:K0,description:j0,capabilities:X0},J0=1,Q0="kauak.orbital",ey="Orbital workshop",ty="1.0.0",sy="Cobalt decks, illuminated seams, instrument stations and helpful little robots.",iy={"office.theme":{apiVersion:1,palette:{background:"#101e32",ground:"#1b3553",groundLine:"#426282",path:"#4a667f",wall:"#416586",accent:"#82d8ed",focus:"#a5cae0",light:"#b5e6ff",rugs:["#87cddd","#7ca5ce"],wings:["#4c7892","#506f9a","#537f82","#546b88"]},materials:{wood:"#89aaba",woodDark:"#416580",metal:"#b6cfda",chair:"#365276",pot:"#51738a",leaf:"#82d8ed",leafDark:"#446c88",paper:"#d5e9f1",screenOff:"#0d1017",white:"#eef8fa"},architecture:{wallHeight:38,floorPattern:"inset",decor:"technical",lightIntensity:.18},bannerAnchors:[{id:"entrance",name:"Entrance sign",origin:"campus",x:.2,y:-2.4,z:14,width:5.8,height:58,facing:"x"},{id:"studio",name:"First room wall",origin:"first-room",x:.5,y:0,z:32,width:3.8,height:46,facing:"x"}]},"office.characters":{apiVersion:1,model:"robot",skin:["#f1d3b3","#e0b48f","#c68642","#8d5524","#ffdbac"],hair:["#2b1d14","#5a3a22","#c7813a","#1b1b1f","#8c2f2f","#e0c080","#4a4e69"],shell:"#d5e9f1",visor:"#173653",animation:{tempo:{working:.7,idle:.55,blocked:.8,done:.7,unknown:.6},amplitude:.65,glyphs:["01","10","+","•","[]","OK"]}}},ry={schemaVersion:J0,id:Q0,name:ey,version:ty,description:sy,capabilities:iy},ny=1,oy="kauak.basecamp",ay="Alpine basecamp",hy="1.0.0",ly="Timber huts on the snowline: plank floors, gear racks, fire pits, route maps, tents along the trail and climbers roped up for the summit.",cy={"office.theme":{apiVersion:1,palette:{background:"#0f1c2b",ground:"#9fb1c2",groundLine:"#c3d1de",path:"#7d8fa1",wall:"#8b6b4c",accent:"#ff8c42",focus:"#d9a066",light:"#ffd9a0",rugs:["#b5452f","#2f6b8a","#c9a227"],wings:["#6f5d4e","#66584c","#745f4a","#5f5850","#6d5a52"]},materials:{wood:"#c08f5c",woodDark:"#6e4f36",metal:"#98a3ae",chair:"#3b4656",pot:"#7c848d",leaf:"#4c8a63",leafDark:"#2f5f47",paper:"#efe6d2",screenOff:"#0d1017",white:"#f4f7fa"},architecture:{wallHeight:34,floorPattern:"planks",decor:"alpine",lightIntensity:.16},bannerAnchors:[{id:"entrance",name:"Entrance sign",origin:"campus",x:.2,y:-2.4,z:14,width:5.8,height:58,facing:"x"},{id:"studio",name:"First room wall",origin:"first-room",x:.5,y:0,z:36,width:3.8,height:46,facing:"x"}]},"office.characters":{apiVersion:1,model:"climber",skin:["#f1d3b3","#e0b48f","#c68642","#8d5524","#ffdbac"],hair:["#2b1d14","#5a3a22","#c7813a","#1b1b1f","#8c2f2f","#e0c080","#4a4e69"],shell:"#f2c14e",visor:"#5ec8e5",animation:{tempo:{working:.85,idle:.75,blocked:.9,done:1.1,unknown:.7},amplitude:.9,glyphs:["▲","↑","5.9","5.12","WI4","M6","8a","+50m","8000","❄","N↑","△"]}}},dy={schemaVersion:ny,id:oy,name:ay,version:hy,description:ly,capabilities:cy},ua=[Z0,ry,dy],gu=new Zi(ua),yu=gu.resolve("office.theme","kauak.classic").package.capabilities["office.theme"],vu=gu.resolve("office.characters","kauak.classic").package.capabilities["office.characters"],uy=4*1024*1024;async function fy(t,e){if(!t.size||t.size>uy)throw new Error("Choose an image smaller than 4 MB.");if(!["image/png","image/jpeg","image/webp"].includes(t.type))throw new Error("Choose a PNG, JPEG or WebP image. SVG is not supported.");const s=URL.createObjectURL(t);try{const i=await fa(s);if(i.naturalWidth>8192||i.naturalHeight>8192||i.naturalWidth*i.naturalHeight>24e6)throw new Error("This image is too large to process. Resize it to at most 8192 pixels per side and 24 megapixels.");const r=Math.min(1,1600/i.naturalWidth,800/i.naturalHeight),n=document.createElement("canvas"),o=n.getContext("2d");if(!o)throw new Error("This browser cannot process the image. Try another browser.");let a=r;for(let l=0;l<8;l++){n.width=Math.max(1,Math.round(i.naturalWidth*a)),n.height=Math.max(1,Math.round(i.naturalHeight*a)),o.drawImage(i,0,0,n.width,n.height);const h=n.toDataURL("image/png");if(h.length<=rn)return _u({dataUrl:h,name:t.name.slice(0,120)||"Company banner",width:n.width,height:n.height,anchorId:e,visible:!0});a*=Math.min(.9,Math.sqrt(rn/h.length)*.95)}throw new Error("This image could not be resized for local storage. Choose another image.")}finally{URL.revokeObjectURL(s)}}async function fa(t){const e=new Image;e.src=t;try{await e.decode()}catch{throw new Error("The image could not be read. Choose another PNG, JPEG or WebP file.")}if(!e.naturalWidth||!e.naturalHeight)throw new Error("This image is empty. Choose another file.");return e}const py="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201600%201000'%20preserveAspectRatio='xMidYMid%20slice'%3e%3cdefs%3e%3clinearGradient%20id='sky'%20x2='0'%20y2='1'%3e%3cstop%20stop-color='%2307111f'/%3e%3cstop%20offset='.55'%20stop-color='%23132d48'/%3e%3cstop%20offset='1'%20stop-color='%230b1728'/%3e%3c/linearGradient%3e%3clinearGradient%20id='far'%20x2='0'%20y2='1'%3e%3cstop%20stop-color='%23345675'/%3e%3cstop%20offset='1'%20stop-color='%23162a42'/%3e%3c/linearGradient%3e%3clinearGradient%20id='near'%20x2='0'%20y2='1'%3e%3cstop%20stop-color='%2315354f'/%3e%3cstop%20offset='1'%20stop-color='%23081422'/%3e%3c/linearGradient%3e%3cradialGradient%20id='haze'%3e%3cstop%20stop-color='%2364b9da'%20stop-opacity='.15'/%3e%3cstop%20offset='1'%20stop-color='%2364b9da'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3clinearGradient%20id='rim'%3e%3cstop%20stop-color='%235797b9'%20stop-opacity='.5'/%3e%3cstop%20offset='.5'%20stop-color='%235797b9'%20stop-opacity='.05'/%3e%3cstop%20offset='1'%20stop-color='%235797b9'%20stop-opacity='.35'/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20fill='url(%23sky)'%20d='M0%200H1600V1000H0Z'/%3e%3cellipse%20cx='920'%20cy='420'%20rx='940'%20ry='390'%20fill='url(%23haze)'/%3e%3cg%20fill='%239fc7df'%20opacity='.28'%3e%3ccircle%20cx='275'%20cy='100'%20r='1'/%3e%3ccircle%20cx='480'%20cy='165'%20r='1'/%3e%3ccircle%20cx='965'%20cy='75'%20r='1.2'/%3e%3ccircle%20cx='1350'%20cy='178'%20r='1'/%3e%3ccircle%20cx='1130'%20cy='136'%20r='.8'/%3e%3ccircle%20cx='710'%20cy='80'%20r='.8'/%3e%3c/g%3e%3cpath%20d='M0%20430%2075%20391%20146%20305%20206%20360%20278%20244%20355%20340%20433%20396%20488%20365%20561%20437%20650%20424%20748%20475%20844%20443%20935%20462%201018%20402%201071%20342%201132%20390%201200%20302%201247%20333%201307%20214%201350%20292%201404%20263%201478%20353%201529%20317%201600%20383V1000H0Z'%20fill='url(%23far)'/%3e%3cg%20fill='%237099b6'%20opacity='.28'%3e%3cpath%20d='m278%20244-48%2089%2048-26%2038%2012Z'/%3e%3cpath%20d='m1307%20214-47%2091%2045-31%2040%209Z'/%3e%3cpath%20d='m1200%20302-39%2055%2039-19%2025%207Z'/%3e%3c/g%3e%3cpath%20d='M0%20556%2057%20500%20123%20464%20179%20391%20228%20425%20271%20510%20326%20476%20405%20540%20490%20553%20562%20529%20642%20595%20718%20571%20799%20622%20899%20577%20973%20587%201040%20534%201095%20563%201163%20496%201226%20469%201299%20383%201332%20414%201390%20357%201448%20443%201512%20472%201600%20421V1000H0Z'%20fill='%23132e47'/%3e%3cpath%20d='M0%20556%2057%20500%20123%20464%20179%20391%20228%20425%20271%20510%20326%20476%20405%20540%20490%20553%20562%20529%20642%20595%20718%20571%20799%20622%20899%20577%20973%20587%201040%20534%201095%20563%201163%20496%201226%20469%201299%20383%201332%20414%201390%20357%201448%20443%201512%20472%201600%20421'%20fill='none'%20stroke='url(%23rim)'%20stroke-width='1.5'/%3e%3cellipse%20cx='810'%20cy='626'%20rx='900'%20ry='145'%20fill='url(%23haze)'/%3e%3cpath%20d='M0%20626%2065%20595%20134%20533%20191%20578%20250%20672%20320%20655%20392%20698%20459%20674%20522%20725%20604%20746%20694%20727%20790%20785%20904%20735%20997%20714%201052%20745%201137%20670%201206%20646%201263%20572%201325%20610%201388%20523%201452%20562%201497%20525%201559%20602%201600%20570V1000H0Z'%20fill='url(%23near)'/%3e%3cg%20fill='%230b1a2c'%20opacity='.7'%3e%3cpath%20d='m134%20533%2016%20139-74%2037Z'/%3e%3cpath%20d='m1388%20523-24%20232%2088-85Z'/%3e%3cpath%20d='m1263%20572-29%20173%2066-70Z'/%3e%3c/g%3e%3cpath%20d='M0%20831%2098%20780%20184%20807%20250%20784%20346%20850%20454%20835%20545%20893%20665%20875%20790%20922%20941%20892%201083%20858%201154%20874%201270%20821%201358%20849%201432%20772%201509%20787%201600%20756V1000H0Z'%20fill='%2307121f'/%3e%3c/svg%3e",_y="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201600%201000'%20preserveAspectRatio='xMidYMid%20slice'%3e%3cdefs%3e%3clinearGradient%20id='sky'%20x2='0'%20y2='1'%3e%3cstop%20stop-color='%23050d1b'/%3e%3cstop%20offset='.6'%20stop-color='%23102640'/%3e%3cstop%20offset='1'%20stop-color='%23081422'/%3e%3c/linearGradient%3e%3cradialGradient%20id='halo'%3e%3cstop%20stop-color='%23609ec6'%20stop-opacity='.16'/%3e%3cstop%20offset='1'%20stop-color='%23609ec6'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3clinearGradient%20id='face'%20x2='1'%20y2='1'%3e%3cstop%20stop-color='%23294e71'/%3e%3cstop%20offset='1'%20stop-color='%230a1b30'/%3e%3c/linearGradient%3e%3clinearGradient%20id='ice'%20x2='0'%20y2='1'%3e%3cstop%20stop-color='%2386b7cd'%20stop-opacity='.75'/%3e%3cstop%20offset='1'%20stop-color='%233c688b'%20stop-opacity='.05'/%3e%3c/linearGradient%3e%3cradialGradient%20id='mist'%3e%3cstop%20stop-color='%234aa8c8'%20stop-opacity='.12'/%3e%3cstop%20offset='1'%20stop-color='%234aa8c8'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3c/defs%3e%3cpath%20fill='url(%23sky)'%20d='M0%200H1600V1000H0Z'/%3e%3ccircle%20cx='440'%20cy='195'%20r='230'%20fill='url(%23halo)'/%3e%3ccircle%20cx='440'%20cy='195'%20r='22'%20fill='%23c7deeb'%20opacity='.65'/%3e%3ccircle%20cx='433'%20cy='190'%20r='3'%20fill='%239bb6cb'%20opacity='.4'/%3e%3ccircle%20cx='449'%20cy='202'%20r='5'%20fill='%239bb6cb'%20opacity='.35'/%3e%3cg%20fill='%23d3e8ef'%20opacity='.35'%3e%3ccircle%20cx='225'%20cy='180'%20r='1'/%3e%3ccircle%20cx='700'%20cy='84'%20r='1.2'/%3e%3ccircle%20cx='1060'%20cy='194'%20r='.8'/%3e%3ccircle%20cx='925'%20cy='135'%20r='1'/%3e%3ccircle%20cx='1460'%20cy='97'%20r='1'/%3e%3ccircle%20cx='1270'%20cy='189'%20r='1'/%3e%3ccircle%20cx='603'%20cy='248'%20r='.8'/%3e%3ccircle%20cx='380'%20cy='87'%20r='.8'/%3e%3c/g%3e%3cpath%20d='M0%20533%20111%20464%20229%20503%20350%20388%20458%20452%20550%20563%20721%20532%20845%20586%201002%20434%201080%20465%201203%20321%201300%20437%201417%20350%201505%20424%201600%20381V1000H0Z'%20fill='%2318334f'/%3e%3cpath%20d='M0%20728%20110%20629%20190%20582%20333%20329%20465%20583%20575%20671%20687%20619%20797%20706%20905%20612%201035%20467%201178%20223%201328%20501%201426%20452%201600%20643V1000H0Z'%20fill='url(%23face)'/%3e%3cpath%20d='m1178%20223%2016%20279%2067%2076%2067-77Z'%20fill='%230a1b2e'/%3e%3cpath%20d='m1178%20223-77%20132%2050-21%2027%2040%2018-15%2042%2037-29-114Z'%20fill='url(%23ice)'/%3e%3cpath%20d='m333%20329-65%20116%2045-25%2020%2018%2028-9%2034%2024Z'%20fill='url(%23ice)'%20opacity='.65'/%3e%3cpath%20d='m333%20329%205%20223%2090%2081%2037-50Z'%20fill='%230c2037'/%3e%3cg%20fill='none'%20stroke='%2367aaca'%20stroke-width='1.3'%20opacity='.45'%3e%3cpath%20d='m1035%20467%20143-244%2083%20152'/%3e%3cpath%20d='m190%20582%20143-253%2062%20124'/%3e%3c/g%3e%3cg%20fill='none'%20stroke='%2348718b'%20opacity='.25'%3e%3cpath%20d='m1151%20334-53%20212-106%20126'/%3e%3cpath%20d='m1194%20502%2057%20215'/%3e%3cpath%20d='m1261%20578%2045%20104'/%3e%3cpath%20d='m313%20420-54%20196-89%2078'/%3e%3c/g%3e%3cellipse%20cx='800'%20cy='718'%20rx='910'%20ry='180'%20fill='url(%23mist)'/%3e%3cpath%20d='M0%20867%20129%20774%20256%20794%20369%20733%20493%20819%20651%20852%20800%20834%20918%20883%201079%20791%201155%20817%201300%20729%201414%20798%201537%20718%201600%20768V1000H0Z'%20fill='%23071423'/%3e%3c/svg%3e",my="/assets/contours-DG3HeJNa.svg",on=[{id:"alpine",name:"Alpine dusk",description:"Blue ridges fading into a quiet valley.",image:py},{id:"summit",name:"Moonlit summit",description:"Sharp peaks, icy light and a deep night sky.",image:_y},{id:"contours",name:"Contour map",description:"Subtle elevation lines for a quieter workspace.",image:my},{id:"original",name:"Original",description:"The office package’s plain background.",image:null}],Ll="kauak.background.v1";function Il(t){return on.some(e=>e.id===t)}class gy{constructor(e){w(this,"layer",document.createElement("div"));w(this,"selected","original");this.layer.id="office-background",this.layer.setAttribute("aria-hidden","true"),e.prepend(this.layer);let s=null;try{s=localStorage.getItem(Ll)}catch{}const i=new URLSearchParams(location.search).get("background");this.apply(Il(i)?i:Il(s)?s:"original")}get value(){return this.selected}choose(e){this.apply(e);const s=new URL(location.href);s.searchParams.delete("background"),history.replaceState(history.state,"",s);try{return localStorage.setItem(Ll,e),!0}catch{return!1}}apply(e){this.selected=e;const s=on.find(i=>i.id===e);this.layer.dataset.background=e,this.layer.style.backgroundImage=s.image?`url("${s.image}")`:"none"}}const yy="appearances.json",vy=3e3;function by(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const{dir:e,packages:s}=t;if(typeof e!="string"||!Array.isArray(s))return null;const i=[];for(const r of s){if(!r||typeof r!="object"||typeof r.file!="string")return null;const{file:n,error:o}=r;i.push(typeof o=="string"?{file:n,error:o}:{file:n,package:r.package})}return{dir:e,packages:i}}async function wy(t=fetch,e=vy){try{const s=await t(yy,{cache:"no-store",signal:AbortSignal.timeout(e)});return!s.ok||!(s.headers.get("content-type")??"").startsWith("application/json")?null:by(await s.json())}catch{return null}}function xy(t){return t.split(/[\\/]/).pop()||t}class Sy{constructor(e,s){w(this,"dialog",document.createElement("dialog"));w(this,"registry");w(this,"prefs");w(this,"bannerImage",null);w(this,"busy",!1);w(this,"button",document.getElementById("btn-appearance"));w(this,"startupWarnings");w(this,"base",new Zi(ua));w(this,"installed",null);w(this,"installedRows",[]);w(this,"installedIds",new Map);w(this,"storage",{getItem:e=>localStorage.getItem(e),setItem:(e,s)=>localStorage.setItem(e,s)});this.host=e,this.background=s;const i=D0(this.storage);this.prefs=i.value;const r=this.buildRegistry(this.prefs.packages);this.registry=r.registry,this.startupWarnings=[...i.warnings,...this.base.warnings,...r.warnings],this.dialog.id="appearance",this.dialog.setAttribute("aria-labelledby","appearance-title"),this.dialog.innerHTML=`<header><div><h2 id="appearance-title">Make this office yours</h2><p>Choose the space, the team and a place for your company.</p></div><button class="btn" data-close aria-label="Close appearance settings">✕</button></header>
72
+ <div class="appearance-body"><section><h3>Office & team</h3><p>Your sessions and agent states stay the same.</p>
73
+ <div class="appearance-pair"><label>Office<select id="appearance-theme"></select><small id="theme-description"></small></label><label>Characters<select id="appearance-characters"></select><small id="characters-description"></small></label></div>
74
+ <p id="appearance-fallback" class="appearance-warning" hidden></p>
75
+ </section><section aria-labelledby="background-title"><h3 id="background-title">Beyond the office</h3><p>A little of the mountains, wherever you work.</p>
76
+ <fieldset class="background-options" aria-labelledby="background-title">${on.map(n=>`<label class="background-choice"><input type="radio" name="office-background" value="${n.id}"><span class="background-swatch" aria-hidden="true" data-background-swatch="${n.id}"></span><span class="background-caption"><strong>${n.name}</strong><small>${n.description}</small></span></label>`).join("")}</fieldset>
77
+ <div class="background-preview-actions"><small>Switch instantly to compare. Your choice stays on this browser.</small><button class="btn" id="background-view">View in office</button></div>
78
+ </section><section><h3>Company banner</h3><p>Show a logo or banner on this floor. Images keep their proportions.</p>
79
+ <div id="banner-preview"><span>No company image yet</span><img hidden alt="Your company banner preview"></div>
80
+ <div class="appearance-pair"><label><span id="banner-upload-label">Choose an image</span><input id="banner-file" type="file" accept="image/png,image/jpeg,image/webp"><small>PNG, JPEG or WebP · up to 4 MB</small></label><label>Place it at<select id="banner-anchor"></select><small>Appears on every floor with rooms.</small></label></div>
81
+ <label class="banner-background">Panel background<select id="banner-background"><option value="light">Light</option><option value="dark">Dark</option></select><small>Choose a background that makes your logo easy to read.</small></label>
82
+ <div class="banner-actions"><label><input id="banner-visible" type="checkbox"> Show in office</label><button class="btn" id="banner-view">Show me</button><button class="btn" id="banner-remove">Remove image</button></div>
83
+ <p id="banner-location-note" class="appearance-warning" hidden></p>
84
+ </section><section><h3>More appearances</h3><p>An appearance package is a JSON file of colors and shapes, no code. Start from the example, then import it here or install it for every browser that opens this office.</p>
85
+ <div class="appearance-pair"><label>Import a package<input id="package-file" type="file" accept=".json,application/json"><small>Kept on this browser · up to 64 KB</small></label><div class="appearance-example"><span>Start from an example</span><button class="btn" id="example-download">Download harbor.json</button><small>Change its id, name and colors.</small></div></div>
86
+ <ul id="appearance-packages"></ul>
87
+ <div id="installed" hidden><h4>Installed on this machine</h4><p id="installed-note"></p><ul id="installed-packages"></ul></div>
88
+ </section>
89
+ <p id="appearance-message" role="status" aria-live="polite">Changes are saved on this browser.</p></div><footer><span>Local to this browser. Your banner stays when you change office.</span><button class="btn primary" data-close>Done</button></footer>`,document.body.append(this.dialog);for(const n of on)n.image&&(this.dialog.querySelector(`[data-background-swatch="${n.id}"]`).style.backgroundImage=`url("${n.image}")`);this.button.addEventListener("click",()=>{this.render(),this.dialog.showModal(),this.button.setAttribute("aria-expanded","true"),this.el("appearance-theme").focus()}),this.dialog.querySelectorAll("[data-close]").forEach(n=>{n.addEventListener("click",()=>this.dialog.close())}),this.dialog.addEventListener("close",()=>{this.button.setAttribute("aria-expanded","false"),this.button.focus()}),window.addEventListener("keydown",n=>{this.isOpen()&&n.stopImmediatePropagation()},!0);for(const[n,o]of[["appearance-theme","office.theme"],["appearance-characters","office.characters"]])this.el(n).addEventListener("change",()=>this.commit({...this.prefs,selections:{...this.prefs.selections,[o]:this.el(n).value}}));this.dialog.querySelectorAll('input[name="office-background"]').forEach(n=>{n.addEventListener("change",()=>{if(!n.checked)return;const o=this.background.choose(n.value);this.message(o?"Background saved on this browser. View it in the office.":"Background previewed. This browser could not save the choice.",!o)})}),this.el("background-view").addEventListener("click",()=>this.dialog.close()),this.el("banner-file").addEventListener("change",()=>void this.uploadBanner()),this.el("package-file").addEventListener("change",()=>void this.importPackage()),this.el("example-download").addEventListener("click",()=>this.downloadExample()),this.el("banner-anchor").addEventListener("change",()=>{this.prefs.banner&&this.commit({...this.prefs,banner:{...this.prefs.banner,anchorId:this.el("banner-anchor").value}})}),this.el("banner-visible").addEventListener("change",()=>{this.prefs.banner&&this.commit({...this.prefs,banner:{...this.prefs.banner,visible:this.el("banner-visible").checked}})}),this.el("banner-background").addEventListener("change",()=>{this.prefs.banner&&this.commit({...this.prefs,banner:{...this.prefs.banner,background:this.el("banner-background").value}})}),this.el("banner-remove").addEventListener("click",()=>{this.commit({...this.prefs,banner:null})&&(this.bannerImage=null,this.host.setBanner(null,null))}),this.el("banner-view").addEventListener("click",()=>{this.dialog.close(),this.host.previewBanner()}),this.render()}async loadInstalled(){var i;this.installed=await wy();const e=new Zi(ua);this.installedRows=[],this.installedIds.clear();for(const r of((i=this.installed)==null?void 0:i.packages)??[])try{if("error"in r)throw new Error(r.error);const n=nh(r.package),o=this.installedIds.get(n.id);if(o)throw new Error(`its id, ${n.id}, is taken by ${o}`);e.register(n),this.installedIds.set(n.id,r.file),this.installedRows.push({file:r.file,label:`${n.name} · ${n.version}`,error:null})}catch(n){this.installedRows.push({file:r.file,label:xy(r.file),error:n.message})}this.base=e;const s=this.buildRegistry(this.prefs.packages);this.registry=s.registry,this.startupWarnings.push(...[...e.warnings,...s.warnings].filter(r=>!this.startupWarnings.includes(r))),this.apply(),this.render()}async restoreBanner(){if(this.prefs.banner){try{const e=this.prefs.banner,s=await fa(e.dataUrl);if(s.naturalWidth!==e.width||s.naturalHeight!==e.height)throw new Error("invalid saved dimensions");this.bannerImage=s,this.host.setBanner(e,s)}catch{this.startupWarnings.push("The saved banner could not be displayed. Replace or remove the image.")}this.render()}}isOpen(){return this.dialog.open}el(e){return this.dialog.querySelector(`#${e}`)}buildRegistry(e){const s=this.base.copy(),i=[];for(const r of e)try{this.installedIds.has(r.id)||s.register(r)}catch(n){i.push(`Skipped a saved package: ${n.message}`)}return{registry:s,warnings:i}}apply(){const e=this.registry.resolve("office.theme",this.prefs.selections["office.theme"]).package.capabilities["office.theme"],s=this.registry.resolve("office.characters",this.prefs.selections["office.characters"]).package.capabilities["office.characters"];this.host.setAppearance(e,s),this.host.setBanner(this.prefs.banner,this.bannerImage)}commit(e){const s=F0(this.storage,e);return s?(this.message(s,!0),this.render(!1),!1):(this.prefs=e,this.registry=this.buildRegistry(e.packages).registry,this.startupWarnings=[],this.apply(),this.render(!1),this.message("Saved on this browser."),!0)}message(e,s=!1){const i=this.el("appearance-message");i.textContent=e,i.classList.toggle("error",s),i.setAttribute("role",s?"alert":"status")}render(e=!0){this.dialog.querySelectorAll('input[name="office-background"]').forEach(u=>{u.checked=u.value===this.background.value});const s=[];for(const[u,f,p]of[["appearance-theme","office.theme","theme-description"],["appearance-characters","office.characters","characters-description"]]){const _=this.el(u),g=this.registry.resolve(f,this.prefs.selections[f]);_.replaceChildren(...this.registry.list(f).map(m=>new Option(m.name,m.id))),_.value=g.package.id,this.el(p).textContent=g.package.description,g.fallback&&s.push(`${f==="office.theme"?"Office":"Characters"} was unavailable. Using ${g.package.name}.`)}const i=this.el("appearance-fallback");i.textContent=s.join(" "),i.hidden=!s.length;const r=this.registry.resolve("office.theme",this.prefs.selections["office.theme"]).package.capabilities["office.theme"],n=this.prefs.banner,o=this.el("banner-anchor"),a=(n==null?void 0:n.anchorId)??r.bannerAnchors[0].id,l=mu(r,a);o.replaceChildren(...r.bannerAnchors.map(u=>new Option(u.name,u.id))),o.value=l.id;const h=this.el("banner-location-note");h.hidden=!n||l.id===a,h.textContent=`This office uses ${l.name}. Your original location will return with an office that supports it.`;const c=this.dialog.querySelector("#banner-preview img"),d=this.dialog.querySelector("#banner-preview span");c.hidden=!n||!this.bannerImage,d.hidden=!c.hidden,d.textContent=n?"Image unavailable. Replace it to display your banner.":"No company image yet",n&&this.bannerImage?(c.src=n.dataUrl,c.alt=`Banner preview: ${n.name}`):c.removeAttribute("src"),this.el("banner-upload-label").textContent=n?"Replace image":"Choose an image",this.el("banner-visible").checked=!!(n!=null&&n.visible),this.el("banner-background").value=(n==null?void 0:n.background)??"light",this.el("banner-preview").classList.toggle("dark",(n==null?void 0:n.background)==="dark");for(const u of["banner-anchor","banner-visible","banner-background","banner-remove","banner-view"])this.el(u).disabled=!n||this.busy||u==="banner-view"&&(!n.visible||!this.bannerImage);this.el("appearance-packages").replaceChildren(...this.prefs.packages.map(u=>this.packageRow(u))),this.el("installed").hidden=!this.installed,this.installed&&(this.el("installed-note").textContent=this.installedRows.length?`Loaded from ${this.installed.dir} when the page opens. Edit a file and reload the page; remove it to uninstall.`:`Put a package in ${this.installed.dir} and reload the page, or start kauak with --appearance <file>.`,this.el("installed-packages").replaceChildren(...this.installedRows.map(u=>this.installedRow(u))));for(const u of["appearance-theme","appearance-characters","banner-file","package-file","example-download"])this.el(u).disabled=this.busy;e&&this.startupWarnings.length&&this.message(this.startupWarnings.join(" "),!0)}installedRow(e){const s=document.createElement("li"),i=document.createElement("span"),r=document.createElement("small");return i.textContent=e.error?`${e.label} could not be loaded: ${e.error}`:e.label,e.error&&(i.className="appearance-warning"),r.textContent=e.file,r.title=e.file,s.append(i,r),s}downloadExample(){const e=document.createElement("a");e.href=`data:application/json;charset=utf-8,${encodeURIComponent(`${JSON.stringify(U0,null,2)}
90
+ `)}`,e.download="harbor.json",e.hidden=!0,this.dialog.append(e),e.click(),e.remove(),this.message("harbor.json is downloading. Change its id, name and colors, then import it or install it.")}packageRow(e){const s=document.createElement("li"),i=document.createElement("span"),r=document.createElement("button"),n=this.installedIds.get(e.id);return i.textContent=n?`${e.name} · ${e.version} is also installed on this machine, and the installed file is used. Remove this copy.`:`${e.name} · ${e.version}`,n&&(i.className="appearance-warning",i.title=n),r.textContent="Remove",r.className="btn",r.disabled=this.busy,r.setAttribute("aria-label",`Remove ${e.name}`),r.addEventListener("click",()=>this.commit({...this.prefs,packages:this.prefs.packages.filter(o=>o.id!==e.id)})),s.append(i,r),s}async uploadBanner(){var i,r;const e=this.el("banner-file"),s=(i=e.files)==null?void 0:i[0];if(!(!s||this.busy)){this.busy=!0,this.render(!1),this.message("Preparing your image…");try{const n=await fy(s,this.el("banner-anchor").value),o=await fa(n.dataUrl);n.background=((r=this.prefs.banner)==null?void 0:r.background)??"light";const a=this.bannerImage;this.bannerImage=o,this.commit({...this.prefs,banner:n})||(this.bannerImage=a)}catch(n){this.message(n.message,!0)}finally{this.busy=!1,e.value="",this.render(!1)}}}async importPackage(){var i;const e=this.el("package-file"),s=(i=e.files)==null?void 0:i[0];if(!(!s||this.busy)){this.busy=!0,this.render(!1);try{if(s.size>ih)throw new Error("Choose an appearance package smaller than 64 KB.");if(this.prefs.packages.length>=da)throw new Error("Remove a custom appearance before adding another. This browser can keep up to eight.");const r=fu(await s.text()),n=this.installedIds.get(r.id);if(n)throw new Error(`${r.id} is installed on this machine, from ${n}. Give this package another id to import it, or edit that file.`);this.registry.copy().register(r),this.commit({...this.prefs,packages:[...this.prefs.packages,r]})}catch(r){this.message(r.message,!0)}finally{this.busy=!1,e.value="",this.render(!1)}}}}var X=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGLLoader="webgl-loader",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.WebGPULoader="webgpu-loader",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.CanvasLoader="canvas-loader",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.TextureUploaderWebGL="texture-uploader-webgl",t.TextureUploaderWebGPU="texture-uploader-webgpu",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(X||{});const pa=t=>{if(typeof t=="function"||typeof t=="object"&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={...typeof t.extension!="object"?{type:t.extension}:t.extension,ref:t}}if(typeof t=="object")t={...t};else throw new Error("Invalid extension type");return typeof t.type=="string"&&(t.type=[t.type]),t},kr=(t,e)=>pa(t).priority??e,Re={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(pa).forEach(e=>{e.type.forEach(s=>{var i,r;return(r=(i=this._removeHandlers)[s])==null?void 0:r.call(i,e)})}),this},add(...t){return t.map(pa).forEach(e=>{e.type.forEach(s=>{var n,o;const i=this._addHandlers,r=this._queue;i[s]?(o=i[s])==null||o.call(i,e):(r[s]=r[s]||[],(n=r[s])==null||n.push(e))})}),this},handle(t,e,s){var o;const i=this._addHandlers,r=this._removeHandlers;if(i[t]||r[t])throw new Error(`Extension type ${t} already has a handler`);i[t]=e,r[t]=s;const n=this._queue;return n[t]&&((o=n[t])==null||o.forEach(a=>e(a)),delete n[t]),this},handleByMap(t,e){return this.handle(t,s=>{s.name&&(e[s.name]=s.ref)},s=>{s.name&&delete e[s.name]})},handleByNamedList(t,e,s=-1){return this.handle(t,i=>{e.findIndex(n=>n.name===i.name)>=0||(e.push({name:i.name,value:i.ref}),e.sort((n,o)=>kr(o.value,s)-kr(n.value,s)))},i=>{const r=e.findIndex(n=>n.name===i.name);r!==-1&&e.splice(r,1)})},handleByList(t,e,s=-1){return this.handle(t,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((r,n)=>kr(n,s)-kr(r,s)))},i=>{const r=e.indexOf(i.ref);r!==-1&&e.splice(r,1)})},mixin(t,...e){for(const s of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(s))}},Cy={extension:{type:X.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ai(()=>import("./browserAll-B-9xDvMq.js"),__vite__mapDeps([0,1,2]))}},ky={extension:{type:X.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ai(()=>import("./webworkerAll-gM2Z784I.js"),__vite__mapDeps([1,2]))}};class tt{constructor(e,s,i){this._x=s||0,this._y=i||0,this._observer=e}clone(e){return new tt(e??this._observer,this._x,this._y)}set(e=0,s=e){return(this._x!==e||this._y!==s)&&(this._x=e,this._y=s,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}function My(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xn={exports:{}},Dl;function Ty(){return Dl||(Dl=1,(function(t){var e=Object.prototype.hasOwnProperty,s="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(s=!1));function r(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,d||l,u),p=s?s+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,d;if(this._eventsCount===0)return h;for(d in c=this._events)e.call(c,d)&&h.push(s?d.slice(1):d);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=s?s+h:h,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,f=d.length,p=new Array(f);u<f;u++)p[u]=d[u].fn;return p},a.prototype.listenerCount=function(h){var c=s?s+h:h,d=this._events[c];return d?d.fn?1:d.length:0},a.prototype.emit=function(h,c,d,u,f,p){var _=s?s+h:h;if(!this._events[_])return!1;var g=this._events[_],m=arguments.length,y,v;if(g.fn){switch(g.once&&this.removeListener(h,g.fn,void 0,!0),m){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,d),!0;case 4:return g.fn.call(g.context,c,d,u),!0;case 5:return g.fn.call(g.context,c,d,u,f),!0;case 6:return g.fn.call(g.context,c,d,u,f,p),!0}for(v=1,y=new Array(m-1);v<m;v++)y[v-1]=arguments[v];g.fn.apply(g.context,y)}else{var b=g.length,S;for(v=0;v<b;v++)switch(g[v].once&&this.removeListener(h,g[v].fn,void 0,!0),m){case 1:g[v].fn.call(g[v].context);break;case 2:g[v].fn.call(g[v].context,c);break;case 3:g[v].fn.call(g[v].context,c,d);break;case 4:g[v].fn.call(g[v].context,c,d,u);break;default:if(!y)for(S=1,y=new Array(m-1);S<m;S++)y[S-1]=arguments[S];g[v].fn.apply(g[v].context,y)}}return!0},a.prototype.on=function(h,c,d){return n(this,h,c,d,!1)},a.prototype.once=function(h,c,d){return n(this,h,c,d,!0)},a.prototype.removeListener=function(h,c,d,u){var f=s?s+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!u||p.once)&&(!d||p.context===d)&&o(this,f);else{for(var _=0,g=[],m=p.length;_<m;_++)(p[_].fn!==c||u&&!p[_].once||d&&p[_].context!==d)&&g.push(p[_]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=s?s+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=s,a.EventEmitter=a,t.exports=a})(Xn)),Xn.exports}var Ey=Ty();const Dt=My(Ey),Py=Math.PI*2,Ay=180/Math.PI,Ry=Math.PI/180;class nt{constructor(e=0,s=0){this.x=0,this.y=0,this.x=e,this.y=s}clone(){return new nt(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,s=e){return this.x=e,this.y=s,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Zn.x=0,Zn.y=0,Zn}}const Zn=new nt;class re{constructor(e=1,s=0,i=0,r=1,n=0,o=0){this.array=null,this.a=e,this.b=s,this.c=i,this.d=r,this.tx=n,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,s,i,r,n,o){return this.a=e,this.b=s,this.c=i,this.d=r,this.tx=n,this.ty=o,this}toArray(e,s){this.array||(this.array=new Float32Array(9));const i=s||this.array;return e?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(e,s){s=s||new nt;const i=e.x,r=e.y;return s.x=this.a*i+this.c*r+this.tx,s.y=this.b*i+this.d*r+this.ty,s}applyInverse(e,s){s=s||new nt;const i=this.a,r=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(i*o+n*-r),c=e.x,d=e.y;return s.x=o*h*c+-n*h*d+(l*n-a*o)*h,s.y=i*h*d+-r*h*c+(-l*i+a*r)*h,s}translate(e,s){return this.tx+=e,this.ty+=s,this}scale(e,s){return this.a*=e,this.d*=s,this.c*=e,this.b*=s,this.tx*=e,this.ty*=s,this}rotate(e){const s=Math.cos(e),i=Math.sin(e),r=this.a,n=this.c,o=this.tx;return this.a=r*s-this.b*i,this.b=r*i+this.b*s,this.c=n*s-this.d*i,this.d=n*i+this.d*s,this.tx=o*s-this.ty*i,this.ty=o*i+this.ty*s,this}append(e){const s=this.a,i=this.b,r=this.c,n=this.d;return this.a=e.a*s+e.b*r,this.b=e.a*i+e.b*n,this.c=e.c*s+e.d*r,this.d=e.c*i+e.d*n,this.tx=e.tx*s+e.ty*r+this.tx,this.ty=e.tx*i+e.ty*n+this.ty,this}appendFrom(e,s){const i=e.a,r=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=s.a,c=s.b,d=s.c,u=s.d;return this.a=i*h+r*d,this.b=i*c+r*u,this.c=n*h+o*d,this.d=n*c+o*u,this.tx=a*h+l*d+s.tx,this.ty=a*c+l*u+s.ty,this}setTransform(e,s,i,r,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(i*this.a+r*this.c),this.ty=s-(i*this.b+r*this.d),this}prepend(e){const s=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,r=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d}return this.tx=s*e.a+this.ty*e.c+e.tx,this.ty=s*e.b+this.ty*e.d+e.ty,this}decompose(e){const s=this.a,i=this.b,r=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-r,n),l=Math.atan2(i,s),h=Math.abs(a+l);let c=Math.sqrt(s*s+i*i);return h<1e-5||Math.abs(Py-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):Math.abs(Math.PI-h)<1e-5?(e.rotation=l-Math.PI,e.skew.x=e.skew.y=0,c=-c):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=c,e.scale.y=Math.sqrt(r*r+n*n),e.position.x=this.tx+(o.x*s+o.y*r),e.position.y=this.ty+(o.x*i+o.y*n),e}invert(){const e=this.a,s=this.b,i=this.c,r=this.d,n=this.tx,o=e*r-s*i;return this.a=r/o,this.b=-s/o,this.c=-i/o,this.d=e/o,this.tx=(i*this.ty-r*n)/o,this.ty=-(e*this.ty-s*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new re;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Ly.identity()}static get shared(){return By.identity()}}const By=new re,Ly=new re,Bs=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ls=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Is=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ds=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],_a=[],bu=[],Mr=Math.sign;function Iy(){for(let t=0;t<16;t++){const e=[];_a.push(e);for(let s=0;s<16;s++){const i=Mr(Bs[t]*Bs[s]+Is[t]*Ls[s]),r=Mr(Ls[t]*Bs[s]+Ds[t]*Ls[s]),n=Mr(Bs[t]*Is[s]+Is[t]*Ds[s]),o=Mr(Ls[t]*Is[s]+Ds[t]*Ds[s]);for(let a=0;a<16;a++)if(Bs[a]===i&&Ls[a]===r&&Is[a]===n&&Ds[a]===o){e.push(a);break}}}for(let t=0;t<16;t++){const e=new re;e.set(Bs[t],Ls[t],Is[t],Ds[t],0,0),bu.push(e)}}Iy();const oe={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>Bs[t],uY:t=>Ls[t],vX:t=>Is[t],vY:t=>Ds[t],inv:t=>t&8?t&15:-t&7,add:(t,e)=>_a[t][e],sub:(t,e)=>_a[t][oe.inv(e)],rotate180:t=>t^4,isVertical:t=>(t&3)===2,byDirection:(t,e)=>Math.abs(t)*2<=Math.abs(e)?e>=0?oe.S:oe.N:Math.abs(e)*2<=Math.abs(t)?t>0?oe.E:oe.W:e>0?t>0?oe.SE:oe.SW:t>0?oe.NE:oe.NW,matrixAppendRotationInv:(t,e,s=0,i=0,r=0,n=0)=>{const o=bu[oe.inv(e)],a=o.a,l=o.b,h=o.c,c=o.d,d=s-Math.min(0,a*r,h*n,a*r+h*n),u=i-Math.min(0,l*r,c*n,l*r+c*n),f=t.a,p=t.b,_=t.c,g=t.d;t.a=a*f+l*_,t.b=a*p+l*g,t.c=h*f+c*_,t.d=h*p+c*g,t.tx=d*f+u*_+t.tx,t.ty=d*p+u*g+t.ty},transformRectCoords:(t,e,s,i)=>{const{x:r,y:n,width:o,height:a}=t,{x:l,y:h,width:c,height:d}=e;return s===oe.E?(i.set(r+l,n+h,o,a),i):s===oe.S?i.set(c-n-a+l,r+h,a,o):s===oe.W?i.set(c-r-o+l,d-n-a+h,o,a):s===oe.N?i.set(n+l,d-r-o+h,a,o):i.set(r+l,n+h,o,a)}},Tr=[new nt,new nt,new nt,new nt];class Ee{constructor(e=0,s=0,i=0,r=0){this.type="rectangle",this.x=Number(e),this.y=Number(s),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new Ee(0,0,0,0)}clone(){return new Ee(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,s){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&s>=this.y&&s<this.y+this.height}strokeContains(e,s,i,r=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,h=i*(1-r),c=i-h,d=a-h,u=a+n+h,f=l-h,p=l+o+h,_=a+c,g=a+n-c,m=l+c,y=l+o-c;return e>=d&&e<=u&&s>=f&&s<=p&&!(e>_&&e<g&&s>m&&s<y)}intersects(e,s){if(!s){const O=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=O)return!1;const I=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>I}const i=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=i||o<=n)return!1;const a=Tr[0].set(e.left,e.top),l=Tr[1].set(e.left,e.bottom),h=Tr[2].set(e.right,e.top),c=Tr[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const d=Math.sign(s.a*s.d-s.b*s.c);if(d===0||(s.apply(a,a),s.apply(l,l),s.apply(h,h),s.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=r||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const u=d*(l.y-a.y),f=d*(a.x-l.x),p=u*i+f*n,_=u*r+f*n,g=u*i+f*o,m=u*r+f*o;if(Math.max(p,_,g,m)<=u*a.x+f*a.y||Math.min(p,_,g,m)>=u*c.x+f*c.y)return!1;const y=d*(a.y-h.y),v=d*(h.x-a.x),b=y*i+v*n,S=y*r+v*n,x=y*i+v*o,M=y*r+v*o;return!(Math.max(b,S,x,M)<=y*a.x+v*a.y||Math.min(b,S,x,M)>=y*c.x+v*c.y)}pad(e=0,s=e){return this.x-=e,this.y-=s,this.width+=e*2,this.height+=s*2,this}fit(e){const s=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=s,this.width=Math.max(i-s,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(e=1,s=.001){const i=Math.ceil((this.x+this.width-s)*e)/e,r=Math.ceil((this.y+this.height-s)*e)/e;return this.x=Math.floor((this.x+s)*e)/e,this.y=Math.floor((this.y+s)*e)/e,this.width=i-this.x,this.height=r-this.y,this}scale(e,s=e){return this.x*=e,this.y*=s,this.width*=e,this.height*=s,this}enlarge(e){const s=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=s,this.width=i-s,this.y=r,this.height=n-r,this}getBounds(e){return e||(e=new Ee),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const s=e.x,i=e.y,r=e.x+e.width,n=e.y+e.height;return s>=this.x&&s<this.x+this.width&&i>=this.y&&i<this.y+this.height&&r>=this.x&&r<=this.x+this.width&&n>=this.y&&n<=this.y+this.height}set(e,s,i,r){return this.x=e,this.y=s,this.width=i,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Jn={default:-1};function ve(t="default"){return Jn[t]===void 0&&(Jn[t]=-1),++Jn[t]}const Ol=new Set,Me="8.0.0",Dy="8.3.4",ds="8.21.0",ri={quiet:!1,noColor:!1},j=((t,e,s=3)=>{if(ri.quiet||Ol.has(e))return;let i=new Error().stack;const r=`${e}
91
+ Deprecated since v${t}`,n=typeof console.groupCollapsed=="function"&&!ri.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",r):(i=i.split(`
92
+ `).splice(s).join(`
93
+ `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(i))),Ol.add(e)});Object.defineProperties(j,{quiet:{get:()=>ri.quiet,set:t=>{ri.quiet=t},enumerable:!0,configurable:!1},noColor:{get:()=>ri.noColor,set:t=>{ri.noColor=t},enumerable:!0,configurable:!1}});const wu=()=>{};function fi(t){return t+=t===0?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1}function pi(t){return!(t&t-1)&&!!t}function xu(t){const e={};for(const s in t)t[s]!==void 0&&(e[s]=t[s]);return e}const Fl=Object.create(null);function Oy(t){const e=Fl[t];return e===void 0&&(Fl[t]=ve("resource")),e}const Su=class Cu extends Dt{constructor(e={}){super(),this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,e={...Cu.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){j(Me,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Oy(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Su.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ws=Su;const ku=class Mu extends Dt{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ve("textureSource"),this._resourceType="textureSource",this._resourceId=ve("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this._batchTick=-1,this._textureBindLocation=-1,e={...Mu.defaultOptions,...e},this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=e.dimensions,this.viewDimension=e.viewDimension??e.dimensions,this.arrayLayerCount=e.arrayLayerCount,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.transient=e.transient??!1,this.alphaMode=e.alphaMode,this.style=new Ws(xu(e)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){var s,i;this.style!==e&&(this._ownsStyle=!1,(s=this._style)==null||s.off("change",this._onStyleChange,this),this._style=e,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._ownsStyle&&this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var e,s;this._resourceId=ve("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(s=(e=this._gpuData[i])==null?void 0:e.destroy)==null||s.call(e);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,s,i){i||(i=this._resolution),e||(e=this.width),s||(s=this.height);const r=Math.round(e*i),n=Math.round(s*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=ve("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=pi(this.pixelWidth)&&pi(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};ku.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ut=ku;class oh extends ut{constructor(e){const s=e.resource||new Float32Array(e.width*e.height*4);let i=e.format;i||(s instanceof Float32Array?i="rgba32float":s instanceof Int32Array||s instanceof Uint32Array?i="rgba32uint":s instanceof Int16Array||s instanceof Uint16Array?i="rgba16uint":(s instanceof Int8Array,i="bgra8unorm")),super({...e,resource:s,format:i}),this.uploadMethodId="buffer"}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}oh.extension=X.TextureSource;const $l=new re;class Fy{constructor(e,s){this.mapCoord=new re,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof s>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=s,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){var s;this._texture!==e&&((s=this._texture)==null||s.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this)),this.update()}destroy(){var e;(e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=null}multiplyUvs(e,s){s===void 0&&(s=e);const i=this.mapCoord;for(let r=0;r<e.length;r+=2){const n=e[r],o=e[r+1];s[r]=n*i.a+o*i.c+i.tx,s[r+1]=n*i.b+o*i.d+i.ty}return s}update(){const e=this._texture;this._updateID++;const s=e.uvs;this.mapCoord.set(s.x1-s.x0,s.y1-s.y0,s.x3-s.x0,s.y3-s.y0,s.x0,s.y0);const i=e.orig,r=e.trim;r&&($l.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append($l));const n=e.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(e.frame.x+a+l)/n.width,o[1]=(e.frame.y+a+l)/n.height,o[2]=(e.frame.x+e.frame.width-a+l)/n.width,o[3]=(e.frame.y+e.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=e.frame.width===n.width&&e.frame.height===n.height&&e.rotate===0,!0}}class ue extends Dt{constructor({source:e,label:s,frame:i,orig:r,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:h}={}){if(super(),this.uid=ve("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Ee,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=s,this.source=(e==null?void 0:e.source)??new ut,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:c,height:d}=this._source;this.frame.width=c,this.frame.height=d}this.orig=r||this.frame,this.trim=n,this.rotate=l??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=h||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Fy(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:s}=this,{width:i,height:r}=this._source,n=s.x/i,o=s.y/r,a=s.width/i,l=s.height/r;let h=this.rotate;if(h){const c=a/2,d=l/2,u=n+c,f=o+d;h=oe.add(h,oe.NW),e.x0=u+c*oe.uX(h),e.y0=f+d*oe.uY(h),h=oe.add(h,2),e.x1=u+c*oe.uX(h),e.y1=f+d*oe.uY(h),h=oe.add(h,2),e.x2=u+c*oe.uX(h),e.y2=f+d*oe.uY(h),h=oe.add(h,2),e.x3=u+c*oe.uX(h),e.y3=f+d*oe.uY(h)}else e.x0=n,e.y0=o,e.x1=n+a,e.y1=o,e.x2=n+a,e.y2=o+l,e.x3=n,e.y3=o+l}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return j(Me,"Texture.baseTexture is now Texture.source"),this._source}}ue.EMPTY=new ue({label:"EMPTY",source:new ut({label:"EMPTY"})});ue.EMPTY.destroy=wu;ue.WHITE=new ue({source:new oh({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});ue.WHITE.destroy=wu;function Tu(t,e,s){const{width:i,height:r}=s.orig,n=s.trim;if(n){const o=n.width,a=n.height;t.minX=n.x-e._x*i,t.maxX=t.minX+o,t.minY=n.y-e._y*r,t.maxY=t.minY+a}else t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*r,t.maxY=t.minY+r}const Nl=new re;class Pt{constructor(e=1/0,s=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Nl,this.minX=e,this.minY=s,this.maxX=i,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Ee);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Nl,this}set(e,s,i,r){this.minX=e,this.minY=s,this.maxX=i,this.maxY=r}addFrame(e,s,i,r,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,d=n.ty;let u=this.minX,f=this.minY,p=this.maxX,_=this.maxY,g=o*e+l*s+c,m=a*e+h*s+d;g<u&&(u=g),m<f&&(f=m),g>p&&(p=g),m>_&&(_=m),g=o*i+l*s+c,m=a*i+h*s+d,g<u&&(u=g),m<f&&(f=m),g>p&&(p=g),m>_&&(_=m),g=o*e+l*r+c,m=a*e+h*r+d,g<u&&(u=g),m<f&&(f=m),g>p&&(p=g),m>_&&(_=m),g=o*i+l*r+c,m=a*i+h*r+d,g<u&&(u=g),m<f&&(f=m),g>p&&(p=g),m>_&&(_=m),this.minX=u,this.minY=f,this.maxX=p,this.maxY=_}addRect(e,s){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,s)}addBounds(e,s){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,s)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const s=this.minX,i=this.minY,r=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:h,tx:c,ty:d}=e;let u=o*s+l*i+c,f=a*s+h*i+d;this.minX=u,this.minY=f,this.maxX=u,this.maxY=f,u=o*r+l*i+c,f=a*r+h*i+d,this.minX=u<this.minX?u:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=o*s+l*n+c,f=a*s+h*n+d,this.minX=u<this.minX?u:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=o*r+l*n+c,f=a*r+h*n+d,this.minX=u<this.minX?u:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,s,i,r){return this.minX<e&&(this.minX=e),this.maxX>s&&(this.maxX=s),this.minY<i&&(this.minY=i),this.maxY>r&&(this.maxY=r),this}pad(e,s=e){return this.minX-=e,this.maxX+=e,this.minY-=s,this.maxY+=s,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Pt(this.minX,this.minY,this.maxX,this.maxY)}scale(e,s=e){return this.minX*=e,this.minY*=s,this.maxX*=e,this.maxY*=s,this}get x(){return this.minX}set x(e){const s=this.maxX-this.minX;this.minX=e,this.maxX=e+s}get y(){return this.minY}set y(e){const s=this.maxY-this.minY;this.minY=e,this.maxY=e+s}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,s,i,r){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;r||(r=this.matrix);const h=r.a,c=r.b,d=r.c,u=r.d,f=r.tx,p=r.ty;for(let _=s;_<i;_+=2){const g=e[_],m=e[_+1],y=h*g+d*m+f,v=c*g+u*m+p;n=y<n?y:n,o=v<o?v:o,a=y>a?y:a,l=v>l?v:l}this.minX=n,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(e,s){return this.minX<=e&&this.minY<=s&&this.maxX>=e&&this.maxY>=s}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var $y={grad:.9,turn:360,rad:360/(2*Math.PI)},jt=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},je=function(t,e,s){return e===void 0&&(e=0),s===void 0&&(s=Math.pow(10,e)),Math.round(s*t)/s+0},kt=function(t,e,s){return e===void 0&&(e=0),s===void 0&&(s=1),t>s?s:t>e?t:e},Eu=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Hl=function(t){return{r:kt(t.r,0,255),g:kt(t.g,0,255),b:kt(t.b,0,255),a:kt(t.a)}},Qn=function(t){return{r:je(t.r),g:je(t.g),b:je(t.b),a:je(t.a,3)}},Ny=/^#([0-9a-f]{3,8})$/i,Er=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Pu=function(t){var e=t.r,s=t.g,i=t.b,r=t.a,n=Math.max(e,s,i),o=n-Math.min(e,s,i),a=o?n===e?(s-i)/o:n===s?2+(i-e)/o:4+(e-s)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:r}},Au=function(t){var e=t.h,s=t.s,i=t.v,r=t.a;e=e/360*6,s/=100,i/=100;var n=Math.floor(e),o=i*(1-s),a=i*(1-(e-n)*s),l=i*(1-(1-e+n)*s),h=n%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:r}},Wl=function(t){return{h:Eu(t.h),s:kt(t.s,0,100),l:kt(t.l,0,100),a:kt(t.a)}},zl=function(t){return{h:je(t.h),s:je(t.s),l:je(t.l),a:je(t.a,3)}},Gl=function(t){return Au((s=(e=t).s,{h:e.h,s:(s*=((i=e.l)<50?i:100-i)/100)>0?2*s/(i+s)*100:0,v:i+s,a:e.a}));var e,s,i},Gi=function(t){return{h:(e=Pu(t)).h,s:(r=(200-(s=e.s))*(i=e.v)/100)>0&&r<200?s*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,s,i,r},Hy=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wy=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,zy=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gy=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ma={string:[[function(t){var e=Ny.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?je(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?je(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=zy.exec(t)||Gy.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Hl({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Hy.exec(t)||Wy.exec(t);if(!e)return null;var s,i,r=Wl({h:(s=e[1],i=e[2],i===void 0&&(i="deg"),Number(s)*($y[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Gl(r)},"hsl"]],object:[[function(t){var e=t.r,s=t.g,i=t.b,r=t.a,n=r===void 0?1:r;return jt(e)&&jt(s)&&jt(i)?Hl({r:Number(e),g:Number(s),b:Number(i),a:Number(n)}):null},"rgb"],[function(t){var e=t.h,s=t.s,i=t.l,r=t.a,n=r===void 0?1:r;if(!jt(e)||!jt(s)||!jt(i))return null;var o=Wl({h:Number(e),s:Number(s),l:Number(i),a:Number(n)});return Gl(o)},"hsl"],[function(t){var e=t.h,s=t.s,i=t.v,r=t.a,n=r===void 0?1:r;if(!jt(e)||!jt(s)||!jt(i))return null;var o=(function(a){return{h:Eu(a.h),s:kt(a.s,0,100),v:kt(a.v,0,100),a:kt(a.a)}})({h:Number(e),s:Number(s),v:Number(i),a:Number(n)});return Au(o)},"hsv"]]},Ul=function(t,e){for(var s=0;s<e.length;s++){var i=e[s][0](t);if(i)return[i,e[s][1]]}return[null,void 0]},Uy=function(t){return typeof t=="string"?Ul(t.trim(),ma.string):typeof t=="object"&&t!==null?Ul(t,ma.object):[null,void 0]},eo=function(t,e){var s=Gi(t);return{h:s.h,s:kt(s.s+100*e,0,100),l:s.l,a:s.a}},to=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},ql=function(t,e){var s=Gi(t);return{h:s.h,s:s.s,l:kt(s.l+100*e,0,100),a:s.a}},ga=(function(){function t(e){this.parsed=Uy(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return je(to(this.rgba),2)},t.prototype.isDark=function(){return to(this.rgba)<.5},t.prototype.isLight=function(){return to(this.rgba)>=.5},t.prototype.toHex=function(){return e=Qn(this.rgba),s=e.r,i=e.g,r=e.b,o=(n=e.a)<1?Er(je(255*n)):"","#"+Er(s)+Er(i)+Er(r)+o;var e,s,i,r,n,o},t.prototype.toRgb=function(){return Qn(this.rgba)},t.prototype.toRgbString=function(){return e=Qn(this.rgba),s=e.r,i=e.g,r=e.b,(n=e.a)<1?"rgba("+s+", "+i+", "+r+", "+n+")":"rgb("+s+", "+i+", "+r+")";var e,s,i,r,n},t.prototype.toHsl=function(){return zl(Gi(this.rgba))},t.prototype.toHslString=function(){return e=zl(Gi(this.rgba)),s=e.h,i=e.s,r=e.l,(n=e.a)<1?"hsla("+s+", "+i+"%, "+r+"%, "+n+")":"hsl("+s+", "+i+"%, "+r+"%)";var e,s,i,r,n},t.prototype.toHsv=function(){return e=Pu(this.rgba),{h:je(e.h),s:je(e.s),v:je(e.v),a:je(e.a,3)};var e},t.prototype.invert=function(){return Ht({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),Ht(eo(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),Ht(eo(this.rgba,-e))},t.prototype.grayscale=function(){return Ht(eo(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),Ht(ql(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),Ht(ql(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?Ht({r:(s=this.rgba).r,g:s.g,b:s.b,a:e}):je(this.rgba.a,3);var s},t.prototype.hue=function(e){var s=Gi(this.rgba);return typeof e=="number"?Ht({h:e,s:s.s,l:s.l,a:s.a}):je(s.h)},t.prototype.isEqual=function(e){return this.toHex()===Ht(e).toHex()},t})(),Ht=function(t){return t instanceof ga?t:new ga(t)},Vl=[],qy=function(t){t.forEach(function(e){Vl.indexOf(e)<0&&(e(ga,ma),Vl.push(e))})};function Vy(t,e){var s={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in s)i[s[r]]=r;var n={};t.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),d=1/0,u="black";if(!n.length)for(var f in s)n[f]=new t(s[f]).toRgb();for(var p in s){var _=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<d&&(d=_,u=p)}return u}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":s[a];return l?new t(l).toRgb():null},"name"])}qy([Vy]);const _i=class Hi{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(e){if(e instanceof Hi)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,s){const i=typeof e;if(i!==typeof s)return!1;if(i==="number"||i==="string"||e instanceof Number)return e===s;if(Array.isArray(e)&&Array.isArray(s)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(s))return e.length!==s.length?!1:e.every((n,o)=>n===s[o]);if(e!==null&&s!==null){const n=Object.keys(e),o=Object.keys(s);return n.length!==o.length?!1:n.every(a=>e[a]===s[a])}return e===s}toRgba(){const[e,s,i,r]=this._components;return{r:e,g:s,b:i,a:r}}toRgb(){const[e,s,i]=this._components;return{r:e,g:s,b:i}}toRgbaString(){const[e,s,i]=this.toUint8RgbArray();return`rgba(${e},${s},${i},${this.alpha})`}toUint8RgbArray(e){const[s,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(s*255),e[1]=Math.round(i*255),e[2]=Math.round(r*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[s,i,r,n]=this._components;return e[0]=s,e[1]=i,e[2]=r,e[3]=n,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[s,i,r]=this._components;return e[0]=s,e[1]=i,e[2]=r,e}toNumber(){return this._int}toBgrNumber(){const[e,s,i]=this.toUint8RgbArray();return(i<<16)+(s<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[s,i,r,n]=Hi._temp.setValue(e)._components;return this._components[0]*=s,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(e,s=!0){return s&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,s=!0){if(e===1)return(255<<24)+this._int;if(e===0)return s?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return s&&(i=i*e+.5|0,r=r*e+.5|0,n=n*e+.5|0),(e*255<<24)+(i<<16)+(r<<8)+n}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const s=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-s.length)+s}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(e){let s,i,r,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;s=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[s,i,r,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[s,i,r,n=255]=e,s/=255,i/=255,r/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=Hi.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=Ht(e);o.isValid()&&({r:s,g:i,b:r,a:n}=o.rgba,s/=255,i/=255,r/=255)}if(s!==void 0)this._components[0]=s,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[e,s,i]=this._components;this._int=(e*255<<16)+(s*255<<8)+(i*255|0)}_clamp(e,s=0,i=1){return typeof e=="number"?Math.min(Math.max(e,s),i):(e.forEach((r,n)=>{e[n]=Math.min(Math.max(r,s),i)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof Hi||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};_i.shared=new _i;_i._temp=new _i;_i.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Ce=_i;const Yy={cullArea:null,cullable:!1,cullableChildren:!0};let so=0;const Yl=500;function $e(...t){so!==Yl&&(so++,so===Yl?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...t))}const cr={_registeredResources:new Set,register(t){this._registeredResources.add(t)},unregister(t){this._registeredResources.delete(t)},release(){this._registeredResources.forEach(t=>t.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(t){return this._registeredResources.has(t)},reset(){this._registeredResources.clear()}};class Ky{constructor(e,s){this._pool=[],this._count=0,this._index=0,this._classType=e,s&&this.prepopulate(s)}prepopulate(e){for(let s=0;s<e;s++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){var i;let s;return this._index>0?s=this._pool[--this._index]:(s=new this._classType,this._count++),(i=s.init)==null||i.call(s,e),s}return(e){var s;(s=e.reset)==null||s.call(e),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}class jy{constructor(){this._poolsByClass=new Map}prepopulate(e,s){this.getPool(e).prepopulate(s)}get(e,s){return this.getPool(e).get(s)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Ky(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(s=>{const i=e[s._classType.name]?s._classType.name+s._classType.ID:s._classType.name;e[i]={free:s.totalFree,used:s.totalUsed,size:s.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}}const ft=new jy;cr.register(ft);const Xy={get isCachedAsTexture(){var t;return!!((t=this.renderGroup)!=null&&t.isCachedAsTexture)},cacheAsTexture(t){typeof t=="boolean"&&t===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(t===!0?{}:t))},updateCacheTexture(){var t;(t=this.renderGroup)==null||t.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){j("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}};function Zy(t,e,s){const i=t.length;let r;if(e>=i||s===0)return;s=e+s>i?i-e:s;const n=i-s;for(r=e;r<n;++r)t[r]=t[r+s];t.length=n}const Jy={allowChildren:!0,removeChildren(t=0,e){var n;const s=e??this.children.length,i=s-t,r=[];if(i>0&&i<=s){for(let a=s-1;a>=t;a--){const l=this.children[a];l&&(r.push(l),l.parent=null)}Zy(this.children,t,s);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(r);for(let a=0;a<r.length;++a){const l=r[a];(n=l.parentRenderLayer)==null||n.detach(l),this.emit("childRemoved",l,this,a),r[a].emit("removed",this)}return r.length>0&&this._didViewChangeTick++,r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||j(Me,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:s}=this;if(e<0||e>s.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${s.length}`);const i=t.parent===this;if(t.parent){const n=t.parent.children.indexOf(t);if(i){if(n===e)return t;t.parent.children.splice(n,1)}else t.removeFromParent()}e===s.length?s.push(t):s.splice(e,0,t);const r=this.renderGroup||this.parentRenderGroup;return this.sortableChildren&&(this.sortDirty=!0),i?(r&&(r.structureDidChange=!0),t):(t.parent=this,t.didChange=!0,t._updateFlags=15,r&&r.addChild(t),this.emit("childAdded",t,this,e),t.emit("added",this),t)},swapChildren(t,e){if(t===e)return;const s=this.getChildIndex(t),i=this.getChildIndex(e);this.children[s]=e,this.children[i]=t;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)},reparentChild(...t){return t.length===1?this.reparentChildAt(t[0],this.children.length):(t.forEach(e=>this.reparentChildAt(e,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;const s=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,e);const i=this.worldTransform.clone();return i.invert(),s.prepend(i),t.setFromMatrix(s),t},replaceChild(t,e){t.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(t)),e.setFromMatrix(t.localTransform),e.updateLocalTransform(),this.removeChild(t)}},Qy={collectRenderables(t,e,s){this.parentRenderLayer&&this.parentRenderLayer!==s||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,e,s):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,e,s))},collectRenderablesSimple(t,e,s){const i=this.children,r=i.length;for(let n=0;n<r;n++)i[n].collectRenderables(t,e,s)},collectRenderablesWithEffects(t,e,s){const{renderPipes:i}=e;for(let r=0;r<this.effects.length;r++){const n=this.effects[r];i[n.pipe].push(n,this,t)}this.collectRenderablesSimple(t,e,s);for(let r=this.effects.length-1;r>=0;r--){const n=this.effects[r];i[n.pipe].pop(n,this,t)}}};class Kl{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}class ev{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let s=0;s<this._tests.length;s++){const i=this._tests[s];if(i.test(e))return ft.get(i.maskClass,e)}return e}returnMaskEffect(e){ft.return(e)}}const ya=new ev;Re.handleByList(X.MaskEffect,ya._effectClasses);const tv={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){this.effects.indexOf(t)===-1&&(this.effects.push(t),this.effects.sort((s,i)=>s.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const e=this.effects.indexOf(t);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const e=this._maskEffect;(e==null?void 0:e.mask)!==t&&(e&&(this.removeEffect(e),ya.returnMaskEffect(e),this._maskEffect=null),t!=null&&(this._maskEffect=ya.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){var t;return(t=this._maskEffect)==null?void 0:t.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){var n;!Array.isArray(t)&&t&&(t=[t]);const e=this._filterEffect||(this._filterEffect=new Kl);t=t;const s=(t==null?void 0:t.length)>0,i=((n=e.filters)==null?void 0:n.length)>0,r=s!==i;t=Array.isArray(t)?t.slice(0):t,e.filters=Object.freeze(t),r&&(s?this.addEffect(e):(this.removeEffect(e),e.filters=t??null))},get filters(){var t;return(t=this._filterEffect)==null?void 0:t.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new Kl),this._filterEffect.filterArea=t},get filterArea(){var t;return(t=this._filterEffect)==null?void 0:t.filterArea}},sv={label:null,get name(){return j(Me,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){j(Me,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,e=!1){return this.getChildByLabel(t,e)},getChildByLabel(t,e=!1){const s=this.children;for(let i=0;i<s.length;i++){const r=s[i];if(r.label===t||t instanceof RegExp&&t.test(r.label))return r}if(e)for(let i=0;i<s.length;i++){const n=s[i].getChildByLabel(t,!0);if(n)return n}return null},getChildrenByLabel(t,e=!1,s=[]){const i=this.children;for(let r=0;r<i.length;r++){const n=i[r];(n.label===t||t instanceof RegExp&&t.test(n.label))&&s.push(n)}if(e)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(t,!0,s);return s}},at=ft.getPool(re),es=ft.getPool(Pt),iv=new re,rv={getFastGlobalBounds(t,e){e||(e=new Pt),e.clear(),this._getGlobalBoundsRecursive(!!t,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const s=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(s.worldTransform),e},_getGlobalBoundsRecursive(t,e,s){let i=e;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==s||this.localDisplayStatus!==7||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(i=es.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(t,i,s)}if(r){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(iv).invert()),e.addBounds(i),es.return(i)}else this.renderGroup&&(e.addBounds(i,this.relativeGroupTransform),es.return(i))}};function Ru(t,e,s){s.clear();let i,r;return t.parent?e?i=t.parent.worldTransform:(r=at.get().identity(),i=ah(t,r)):i=re.IDENTITY,Bu(t,s,i,e),r&&at.return(r),s.isValid||s.set(0,0,0,0),s}function Bu(t,e,s,i){var a,l;if(!t.visible||!t.measurable)return;let r;i?r=t.worldTransform:(t.updateLocalTransform(),r=at.get(),r.appendFrom(t.localTransform,s));const n=e,o=!!t.effects.length;if(o&&(e=es.get().clear()),t.boundsArea)e.addRect(t.boundsArea,r);else{const h=t.bounds;h&&!h.isEmpty()&&(e.matrix=r,e.addBounds(h));for(let c=0;c<t.children.length;c++)Bu(t.children[c],e,r,i)}if(o){for(let h=0;h<t.effects.length;h++)(l=(a=t.effects[h]).addBounds)==null||l.call(a,e);n.addBounds(e,re.IDENTITY),es.return(e)}i||at.return(r)}function ah(t,e){const s=t.parent;return s&&(ah(s,e),s.updateLocalTransform(),e.append(s.localTransform)),e}function Lu(t,e){if(t===16777215||!e)return e;if(e===16777215||!t)return t;const s=t>>16&255,i=t>>8&255,r=t&255,n=e>>16&255,o=e>>8&255,a=e&255,l=s*n/255|0,h=i*o/255|0,c=r*a/255|0;return(l<<16)+(h<<8)+c}const jl=16777215;function Xl(t,e){return t===jl?e:e===jl?t:Lu(t,e)}function Yr(t){return((t&255)<<16)+(t&65280)+(t>>16&255)}const nv={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,s=this.parent;for(;s;)e*=s.alpha,s=s.parent;return e},getGlobalTransform(t=new re,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const s=ah(this,at.get().identity());return t.appendFrom(this.localTransform,s),at.return(s),t},getGlobalTint(t){if(t)return this.renderGroup?Yr(this.renderGroup.worldColor):this.parentRenderGroup?Yr(Xl(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,s=this.parent;for(;s;)e=Xl(e,s.localColor),s=s.parent;return Yr(e)}};function Iu(t,e,s){return e.clear(),s||(s=re.IDENTITY),Du(t,e,s,t,!0),e.isValid||e.set(0,0,0,0),e}function Du(t,e,s,i,r){var l,h;let n;if(r)n=at.get(),n=s.copyTo(n);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const c=t.localTransform;n=at.get(),n.appendFrom(c,s)}const o=e,a=!!t.effects.length;if(a&&(e=es.get().clear()),t.boundsArea)e.addRect(t.boundsArea,n);else{t.renderPipeId&&(e.matrix=n,e.addBounds(t.bounds));const c=t.children;for(let d=0;d<c.length;d++)Du(c[d],e,n,i,!1)}if(a){for(let c=0;c<t.effects.length;c++)(h=(l=t.effects[c]).addLocalBounds)==null||h.call(l,e,i);o.addBounds(e,re.IDENTITY),es.return(e)}at.return(n)}function Ou(t,e){const s=t.children;for(let i=0;i<s.length;i++){const r=s[i],n=r.uid,o=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,a=e.index;(e.data[a]!==n||e.data[a+1]!==o)&&(e.data[e.index]=n,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,r.children.length&&Ou(r,e)}return e.didChange}const ov=new re,av={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,e){const s=Math.sign(this.scale.x)||1;e!==0?this.scale.x=t/e*s:this.scale.x=s},_setHeight(t,e){const s=Math.sign(this.scale.y)||1;e!==0?this.scale.y=t/e*s:this.scale.y=s},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Pt});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),Ou(this,t),t.didChange&&Iu(this,t.localBounds,ov),t.localBounds},getBounds(t,e){return Ru(this,t,e||new Pt)}},hv={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t){this._onRender&&(e==null||e.removeOnRender(this)),this._onRender=null;return}this._onRender||e==null||e.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},lv={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(cv))}};function cv(t,e){return t._zIndex-e._zIndex}const dv={getGlobalPosition(t=new nt,e=!1){return this.parent?this.parent.toGlobal(this._position,t,e):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,e,s=!1){const i=this.getGlobalTransform(at.get(),s);return e=i.apply(t,e),at.return(i),e},toLocal(t,e,s,i){e&&(t=e.toGlobal(t,s,i));const r=this.getGlobalTransform(at.get(),i);return s=r.applyInverse(t,s),at.return(r),s}};class hh{constructor(){this.uid=ve("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){var e,s;if(this.renderPipes)for(const i in this.renderPipes)(s=(e=this.renderPipes[i]).destroyInstructionSet)==null||s.call(e,this);this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class Fu{constructor(){this._screenSizes=new Map,this._widths=[],this._heights=[]}get size(){return this._screenSizes.size}set(e,s,i){const r=this._screenSizes.get(e);return r&&r.pixelWidth===s&&r.pixelHeight===i?!1:(this._screenSizes.set(e,{pixelWidth:s,pixelHeight:i}),this._update(),!0)}remove(e){return this._screenSizes.delete(e)?(this._update(),!0):!1}getFittingWidth(e){return this._getFittingAxis(e,this._widths)}getFittingHeight(e){return this._getFittingAxis(e,this._heights)}hasWidth(e){return this._widths.includes(e)}hasHeight(e){return this._heights.includes(e)}_getFittingAxis(e,s){for(let i=0;i<s.length;i++){const r=s[i];if(r>=e)return r}}_update(){this._widths=[...this._screenSizes.values()].map(e=>e.pixelWidth).filter((e,s,i)=>i.indexOf(e)===s).sort((e,s)=>e-s),this._heights=[...this._screenSizes.values()].map(e=>e.pixelHeight).filter((e,s,i)=>i.indexOf(e)===s).sort((e,s)=>e-s)}}let uv=0;const io=32767,fv=4294967296,pv=8589934592,Zl=Object.create(null);let _v=0;function mv(t){const e=Zl[t];return e!==void 0?e:Zl[t]=_v++}function gv(t,e,s,i,r,n){return(t<<17)+(e<<2)+((i?1:0)<<1)+(s?1:0)+(n==="nearest"?1:0)*fv+mv(r)*pv}class yv{constructor(e){this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new Fu,this._enableFullScreen=!1,this.textureOptions=e||{}}get textureStyle(){return j(ds,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle||(this._textureStyle=new Ws(this.textureOptions)),this._textureStyle}set textureStyle(e){j(ds,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle=e}get enableFullScreen(){return j(ds,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){j(ds,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen=e}createTexture(...e){let s=e[0];typeof s=="number"&&(j(ds,"TexturePool.createTexture params are now an options object. See params: { width, height, antialias, autoGenerateMipmaps }"),s={width:s,height:e[1],antialias:e[2]??!1,autoGenerateMipmaps:e[3]??!1});const i=s.format??this.textureOptions.format??ut.defaultOptions.format,r=s.scaleMode??this.textureOptions.scaleMode??Ws.defaultOptions.scaleMode,n=new ut({...this.textureOptions,width:s.width,height:s.height,resolution:1,antialias:s.antialias??!1,autoGarbageCollect:!1,autoGenerateMipmaps:s.autoGenerateMipmaps??!1,format:i,scaleMode:r});return new ue({source:n,label:`texturePool_${uv++}`})}getOptimalTexture(...e){let s=e[0];typeof s=="number"&&(j(ds,"TexturePool.getOptimalTexture params are now an options object. See params: { width, height, resolution, antialias, autoGenerateMipmaps }"),s={width:s,height:e[1],resolution:e[2]??1,antialias:e[3]??!1,autoGenerateMipmaps:e[4]??!1});const i=s.width,r=s.height,n=s.resolution??1,o=s.antialias??!1,a=s.autoGenerateMipmaps??!1,l=s.format??this.textureOptions.format??ut.defaultOptions.format,h=s.scaleMode??this.textureOptions.scaleMode??Ws.defaultOptions.scaleMode,{width:c,height:d}=this.getOptimalSize(i,r,n);(c>io||d>io)&&$e(`TexturePool: ${c}x${d} is larger than the ${io}px pool key limit, textures of this size may be pooled together`);const u=gv(c,d,o,a,l,h);let f=this._buckets.get(u);f||(f=[],this._buckets.set(u,f));let p=f.pop();return p||(p=this.createTexture({width:c,height:d,antialias:o,autoGenerateMipmaps:a,format:l,scaleMode:h}),this._poolStyle[p.uid]=p.source.style),p.source._resolution=n,p.source.width=c/n,p.source.height=d/n,p.source.pixelWidth=c,p.source.pixelHeight=d,p.frame.x=0,p.frame.y=0,p.frame.width=i,p.frame.height=r,p.updateUvs(),this._poolKey[p.uid]=u,p}getOptimalSize(e,s,i=1){const r=Math.ceil(e*i-1e-6),n=Math.ceil(s*i-1e-6),o=fi(r),a=this._screens.getFittingWidth(r),l=fi(n),h=this._screens.getFittingHeight(n);return{width:a!==void 0?Math.min(a,o):o,height:h!==void 0?Math.min(h,l):l}}getSameSizeTexture(e,s=!1){const i=e.source;return this.getOptimalTexture({width:e.width,height:e.height,resolution:i._resolution,antialias:s})}returnTexture(e,s=!1){const i=e.uid,r=this._poolKey[i];if(r===void 0){$e("TexturePool: returnTexture was passed a texture that did not come from this pool, ignoring it");return}const n=this._poolStyle[i];s&&e.source.style!==n&&(e.source.style=n);const o=this._buckets.get(r);if(!o){delete this._poolKey[i],delete this._poolStyle[i],e.destroy(!0);return}o.push(e)}setScreenSize(e,s,i){this._screens.set(e,s,i)&&this._pruneScreenTextures()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenTextures()}_pruneScreenTextures(){for(const[e,s]of this._buckets){const i=e>>>0,r=i>>>17,n=i>>>2&32767;(pi(r)||this._screens.hasWidth(r))&&(pi(n)||this._screens.hasHeight(n))||(this._dropTextures(s,!0),this._buckets.delete(e))}}_dropTextures(e,s){for(let i=0;i<e.length;i++){const r=e[i];delete this._poolKey[r.uid],delete this._poolStyle[r.uid],s&&r.destroy(!0)}}clear(e){for(const s of this._buckets.values())this._dropTextures(s,e!==!1);this._buckets.clear()}}const xn=new yv;cr.register(xn);class vv{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new re,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new hh,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const s=e.children;for(let i=0;i<s.length;i++){const r=s[i];r._updateFlags=15,this.addChild(r)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(xn.returnTexture(this.texture),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const s=this.childrenToUpdate[e];s.list.fill(null),s.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){const s=this.renderGroupChildren.indexOf(e);s>-1&&this.renderGroupChildren.splice(s,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const s=e.children;for(let i=0;i<s.length;i++)this.addChild(s[i])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const s=e.children;for(let i=0;i<s.length;i++)this.removeChild(s[i])}removeChildren(e){for(let s=0;s<e.length;s++)this.removeChild(e[s])}onChildUpdate(e){let s=this.childrenToUpdate[e.relativeRenderGroupDepth];s||(s=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),s.list[s.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.indexOf(e)===-1&&this._onRenderContainers.push(e)}removeOnRender(e){const s=this._onRenderContainers.indexOf(e);s!==-1&&this._onRenderContainers.splice(s,1)}runOnRender(e){for(let s=0;s<this._onRenderContainers.length;s++)this._onRenderContainers[s]._onRender(e)}destroy(){var e;this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,(e=this.instructionSet)==null||e.destroy(),this.instructionSet=null}getChildren(e=[]){const s=this.root.children;for(let i=0;i<s.length;i++)this._getChildren(s[i],e);return e}_getChildren(e,s=[]){if(s.push(e),e.renderGroup)return s;const i=e.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],s);return s}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new re),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new re),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new re),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function bv(t,e,s={}){for(const i in e)!s[i]&&e[i]!==void 0&&(t[i]=e[i])}const ro=new tt(null),Pr=new tt(null),no=new tt(null,1,1),Ar=new tt(null),Jl=1,wv=2,oo=4;class ce extends Dt{constructor(e={}){var s,i;super(),this.uid=ve("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new re,this.relativeGroupTransform=new re,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new tt(this,0,0),this._scale=no,this._pivot=Pr,this._origin=Ar,this._skew=ro,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],bv(this,e,{children:!0,parent:!0,effects:!0}),(s=e.children)==null||s.forEach(r=>this.addChild(r)),(i=e.parent)==null||i.addChild(this)}static mixin(e){j("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),Re.mixin(ce,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||j(Me,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let r=0;r<e.length;r++)this.addChild(e[r]);return e[0]}const s=e[0],i=this.renderGroup||this.parentRenderGroup;return s.parent===this?(this.children.splice(this.children.indexOf(s),1),this.children.push(s),i&&(i.structureDidChange=!0),s):(s.parent&&s.parent.removeChild(s),this.children.push(s),this.sortableChildren&&(this.sortDirty=!0),s.parent=this,s.didChange=!0,s._updateFlags=15,i&&i.addChild(s),this.emit("childAdded",s,this,this.children.length-1),s.emit("added",this),this._didViewChangeTick++,s._zIndex!==0&&s.depthOfChildModified(),s)}removeChild(...e){if(e.length>1){for(let r=0;r<e.length;r++)this.removeChild(e[r]);return e[0]}const s=e[0],i=this.children.indexOf(s);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(s):this.parentRenderGroup&&this.parentRenderGroup.removeChild(s),s.parentRenderLayer&&s.parentRenderLayer.detach(s),s.parent=null,this.emit("childRemoved",s,this,i),s.emit("removed",this)),s}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=ft.get(vv,this),this.groupTransform=re.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),ft.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new re),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*Ay}set angle(e){this.rotation=e*Ry}get pivot(){return this._pivot===Pr&&(this._pivot=new tt(this,0,0)),this._pivot}set pivot(e){this._pivot===Pr&&(this._pivot=new tt(this,0,0),this._origin!==Ar&&$e("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===ro&&(this._skew=new tt(this,0,0)),this._skew}set skew(e){this._skew===ro&&(this._skew=new tt(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===no&&(this._scale=new tt(this,1,1)),this._scale}set scale(e){this._scale===no&&(this._scale=new tt(this,0,0)),typeof e=="string"&&(e=parseFloat(e)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===Ar&&(this._origin=new tt(this,0,0)),this._origin}set origin(e){this._origin===Ar&&(this._origin=new tt(this,0,0),this._pivot!==Pr&&$e("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){const s=this.getLocalBounds().width;this._setWidth(e,s)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const s=this.getLocalBounds().height;this._setHeight(e,s)}getSize(e){e||(e={});const s=this.getLocalBounds();return e.width=Math.abs(this.scale.x*s.width),e.height=Math.abs(this.scale.y*s.height),e}setSize(e,s){const i=this.getLocalBounds();typeof e=="object"?(s=e.height??e.width,e=e.width):s??(s=e),e!==void 0&&this._setWidth(e,i.width),s!==void 0&&this._setHeight(s,i.height)}_updateSkew(){const e=this._rotation,s=this._skew;this._cx=Math.cos(e+s._y),this._sx=Math.sin(e+s._y),this._cy=-Math.sin(e-s._x),this._sy=Math.cos(e-s._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX:this.scale.x,typeof e.scaleY=="number"?e.scaleY:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX=="number"?e.originX:this.origin.x,typeof e.originY=="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const s=this.localTransform,i=this._scale,r=this._pivot,n=this._origin,o=this._position,a=i._x,l=i._y,h=r._x,c=r._y,d=-n._x,u=-n._y;s.a=this._cx*a,s.b=this._sx*a,s.c=this._cy*l,s.d=this._sy*l,s.tx=o._x-(h*s.a+c*s.c)+(d*s.a+u*s.c)-d,s.ty=o._y-(h*s.b+c*s.d)+(d*s.b+u*s.d)-u}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=Jl,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const i=Ce.shared.setValue(e??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=Jl,this._onUpdate())}get tint(){return Yr(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=wv,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const s=e?2:0;(this.localDisplayStatus&2)!==s&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=oo,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const s=e?0:4;(this.localDisplayStatus&4)!==s&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=oo,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const s=e?1:0;(this.localDisplayStatus&1)!==s&&(this._updateFlags|=oo,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){var r;if(this.destroyed)return;this.destroyed=!0;let s;if(this.children.length&&(s=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof e=="boolean"?e:e==null?void 0:e.children)&&s)for(let n=0;n<s.length;++n)s[n].destroy(e);(r=this.renderGroup)==null||r.destroy(),this.renderGroup=null}}Re.mixin(ce,Jy,rv,dv,hv,av,tv,sv,lv,Yy,Xy,nv,Qy);class lh extends ce{constructor(e){super(e),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new Pt(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const s=this.bounds,{x:i,y:r}=e;return i>=s.minX&&i<=s.maxX&&r>=s.minY&&r<=s.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){var e;this.emit("unload",this);for(const s in this._gpuData)(e=this._gpuData[s])==null||e.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,s,i){const{renderPipes:r}=s;r.blendMode.pushBlendMode(this,this.groupBlendMode,e);const o=r[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,e),this.didViewUpdate=!1;const a=this.children,l=a.length;for(let h=0;h<l;h++)a[h].collectRenderables(e,s,i);r.blendMode.popBlendMode(e)}}class mi extends lh{constructor(e=ue.EMPTY){e instanceof ue&&(e={texture:e});const{texture:s=ue.EMPTY,anchor:i,roundPixels:r,width:n,height:o,...a}=e;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new tt({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:s.defaultAnchor&&(this.anchor=s.defaultAnchor),this.texture=s,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(e,s=!1){return e instanceof ue?new mi(e):new mi(ue.from(e,s))}set texture(e){e||(e=ue.EMPTY);const s=this._texture;s!==e&&(s&&s.dynamic&&s.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return Tu(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return j("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,s=this._texture,i=this._bounds,{width:r,height:n}=s.orig;i.minX=-e._x*r,i.maxX=i.minX+r,i.minY=-e._y*n,i.maxY=i.minY+n}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,s){typeof e=="object"?(s=e.height??e.width,e=e.width):s??(s=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),s!==void 0&&this._setHeight(s,this._texture.orig.height)}}const xv=new Pt;function $u(t,e,s){const i=xv;t.measurable=!0,Ru(t,s,i),e.addBoundsMask(i),t.measurable=!1}function Nu(t,e,s){const i=es.get();t.measurable=!0;const r=at.get().identity(),n=Hu(t,s,r);Iu(t,i,n),t.measurable=!1,e.addBoundsMask(i),at.return(r),es.return(i)}function Hu(t,e,s){return t?(t!==e&&(Hu(t.parent,e,s),t.updateLocalTransform(),s.append(t.localTransform)),s):($e("Mask bounds, renderable is not inside the root container"),s)}class Wu{constructor(e){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof mi),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(e,s){this.inverse||$u(this.mask,e,s)}addLocalBounds(e,s){Nu(this.mask,e,s)}containsPoint(e,s){const i=this.mask;return s(i,e)}destroy(){this.reset()}static test(e){return e instanceof mi}}Wu.extension=X.MaskEffect;class zu{constructor(e){this.priority=0,this.pipe="colorMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}zu.extension=X.MaskEffect;class Gu{constructor(e){this.priority=0,this.pipe="stencilMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,s){$u(this.mask,e,s)}addLocalBounds(e,s){Nu(this.mask,e,s)}containsPoint(e,s){const i=this.mask;return s(i,e)}destroy(){this.reset()}static test(e){return e instanceof ce}}Gu.extension=X.MaskEffect;const Sv={createCanvas:(t,e)=>{const s=document.createElement("canvas");return s.width=t,s.height=e,s},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>new DOMParser().parseFromString(t,"text/xml")};let Ql=Sv;const Oe={get(){return Ql},set(t){Ql=t}};class Uu extends ut{constructor(e){e.resource||(e.resource=Oe.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(e=this.width,s=this.height,i=this._resolution){const r=super.resize(e,s,i);return r&&this.resizeCanvas(),r}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Uu.extension=X.TextureSource;class an extends ut{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}an.extension=X.TextureSource;var hn=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(hn||{});class ao{constructor(e,s=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=s,this.priority=i,this._once=r}match(e,s=null){return this._fn===e&&this._context===s}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));const s=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),s}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const s=this.next;return this.next=e?null:s,this.previous=null,s}}const qu=class gt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new ao(null,null,1/0),this.deltaMS=1/gt.targetFPMS,this.elapsedMS=1/gt.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,s,i=hn.NORMAL){return this._addListener(new ao(e,s,i))}addOnce(e,s,i=hn.NORMAL){return this._addListener(new ao(e,s,i,!0))}_addListener(e){let s=this._head.next,i=this._head;if(!s)e.connect(i);else{for(;s;){if(e.priority>s.priority){e.connect(i);break}i=s,s=s.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,s){let i=this._head.next;for(;i;)i.match(e,s)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,s=this._head;for(;s=s.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let s;if(e>this.lastTime){if(s=this.elapsedMS=e-this.lastTime,s>this._maxElapsedMS&&(s=this._maxElapsedMS),s*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=e-n%this._minElapsedMS}this.deltaMS=s,this.deltaTime=this.deltaMS*gt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const s=Math.min(Math.max(0,e)/1e3,gt.targetFPMS);this._maxElapsedMS=1/s,this._minElapsedMS&&e>this.maxFPS&&(this.maxFPS=e)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!gt._shared){const e=gt._shared=new gt;e.autoStart=!0,e._protected=!0}return gt._shared}static get system(){if(!gt._system){const e=gt._system=new gt;e.autoStart=!0,e._protected=!0}return gt._system}};qu.targetFPMS=.06;let ni=qu,ho;async function Cv(){return ho??(ho=(async()=>{var o;const e=Oe.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const s=await new Promise(a=>{const l=document.createElement("video");l.onloadeddata=()=>a(l),l.onerror=()=>a(null),l.autoplay=!1,l.crossOrigin="anonymous",l.preload="auto",l.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",l.load()});if(!s)return"premultiply-alpha-on-upload";const i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,s);const n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(r),e.deleteTexture(i),(o=e.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ho}const Sn=class Vu extends ut{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...Vu.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=ni.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const e=this.resource,s=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(s.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.isValid||e.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await Cv(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,s.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${s.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("loadedmetadata",this._onLoadedMetadata),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ni.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ni.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ni.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Sn.extension=X.TextureSource;Sn.defaultOptions={...ut.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Sn.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let kv=Sn;const ti=(t,e,s=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(i=>typeof i=="string"||s?e(i):i):t);class Mv{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const s=this._cache.get(e);return s||$e(`[Assets] Asset id ${e} was not found in the Cache`),s}set(e,s){const i=ti(e);let r;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.test(s)){r=h.getCacheableAssets(i,s);break}}const n=new Map(Object.entries(r||{}));r||i.forEach(l=>{n.set(l,s)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const h=r?r[l]:s;this._cache.has(l)&&this._cache.get(l)!==h&&$e("[Cache] already has key:",l),this._cache.set(l,n.get(l))})}remove(e){if(!this._cacheMap.has(e)){$e(`[Assets] Asset id ${e} was not found in the Cache`);return}const s=this._cacheMap.get(e);s.cacheKeys.forEach(r=>{this._cache.delete(r)}),s.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const si=new Mv,va=[];Re.handleByList(X.TextureSource,va);function Yu(t={}){const e=t&&t.resource,s=e?t.resource:t,i=e?t:{resource:t};for(let r=0;r<va.length;r++){const n=va[r];if(n.test(s))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Tv(t={},e=!1){const s=t&&t.resource,i=s?t.resource:t,r=s?t:{resource:t};if(!e&&si.has(i))return si.get(i);const n=new ue({source:Yu(r)});return n.on("destroy",()=>{si.has(i)&&si.remove(i)}),e||si.set(i,n),n}function Ev(t,e=!1){return typeof t=="string"?si.get(t):t instanceof ut?new ue({source:t}):Tv(t,e)}ue.from=Ev;ut.from=Yu;Re.add(Wu,zu,Gu,kv,an,Uu,oh);var Ku=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(Ku||{});function At(t){if(typeof t!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function Mi(t){return t.split("?")[0].split("#")[0]}function Pv(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Av(t,e,s){return t.replace(new RegExp(Pv(e),"g"),s)}function Rv(t,e){let s="",i=0,r=-1,n=0,o=-1;for(let a=0;a<=t.length;++a){if(a<t.length)o=t.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||n===1))if(r!==a-1&&n===2){if(s.length<2||i!==2||s.charCodeAt(s.length-1)!==46||s.charCodeAt(s.length-2)!==46){if(s.length>2){const l=s.lastIndexOf("/");if(l!==s.length-1){l===-1?(s="",i=0):(s=s.slice(0,l),i=s.length-1-s.lastIndexOf("/")),r=a,n=0;continue}}else if(s.length===2||s.length===1){s="",i=0,r=a,n=0;continue}}}else s.length>0?s+=`/${t.slice(r+1,a)}`:s=t.slice(r+1,a),i=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return s}const Ji={toPosix(t){return Av(t,"\\","/")},isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl(t){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t)},isBlobUrl(t){return t.startsWith("blob:")},hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){At(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const s=/^[^/:]+:\/{0,2}/.exec(t);return s?s[0]:""},toAbsolute(t,e,s){if(At(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const i=Mi(this.toPosix(e??Oe.get().getBaseUrl())),r=Mi(this.toPosix(s??this.rootname(i)));return t=this.toPosix(t),t.startsWith("/")?Ji.join(r,t.slice(1)):this.isAbsolute(t)?t:this.join(i,t)},normalize(t){if(At(t),t.length===0)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;t=this.toPosix(t);let e="";const s=t.startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const i=t.endsWith("/");return t=Rv(t),t.length>0&&i&&(t+="/"),s?`/${t}`:e+t},isAbsolute(t){return At(t),t=this.toPosix(t),this.hasProtocol(t)?!0:t.startsWith("/")},join(...t){if(t.length===0)return".";let e;for(let s=0;s<t.length;++s){const i=t[s];if(At(i),i.length>0)if(e===void 0)e=i;else{const r=t[s-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(t){if(At(t),t.length===0)return".";t=this.toPosix(t);let e=t.charCodeAt(0);const s=e===47;let i=-1,r=!0;const n=this.getProtocol(t),o=t;t=t.slice(n.length);for(let a=t.length-1;a>=1;--a)if(e=t.charCodeAt(a),e===47){if(!r){i=a;break}}else r=!1;return i===-1?s?"/":this.isUrl(o)?n+t:n:s&&i===1?"//":n+t.slice(0,i)},rootname(t){At(t),t=this.toPosix(t);let e="";if(t.startsWith("/")?e="/":e=this.getProtocol(t),this.isUrl(t)){const s=t.indexOf("/",e.length);s!==-1?e=t.slice(0,s):e=t,e.endsWith("/")||(e+="/")}return e},basename(t,e){At(t),e&&At(e),t=Mi(this.toPosix(t));let s=0,i=-1,r=!0,n;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let o=e.length-1,a=-1;for(n=t.length-1;n>=0;--n){const l=t.charCodeAt(n);if(l===47){if(!r){s=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return s===i?i=a:i===-1&&(i=t.length),t.slice(s,i)}for(n=t.length-1;n>=0;--n)if(t.charCodeAt(n)===47){if(!r){s=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":t.slice(s,i)},extname(t){At(t),t=Mi(this.toPosix(t));let e=-1,s=0,i=-1,r=!0,n=0;for(let o=t.length-1;o>=0;--o){const a=t.charCodeAt(o);if(a===47){if(!r){s=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?e===-1?e=o:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||i===-1||n===0||n===1&&e===i-1&&e===s+1?"":t.slice(e,i)},parse(t){At(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;t=Mi(this.toPosix(t));let s=t.charCodeAt(0);const i=this.isAbsolute(t);let r;e.root=this.rootname(t),i||this.hasProtocol(t)?r=1:r=0;let n=-1,o=0,a=-1,l=!0,h=t.length-1,c=0;for(;h>=r;--h){if(s=t.charCodeAt(h),s===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),s===46?n===-1?n=h:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?e.base=e.name=t.slice(1,a):e.base=e.name=t.slice(o,a)):(o===0&&i?(e.name=t.slice(1,n),e.base=t.slice(1,a)):(e.name=t.slice(o,n),e.base=t.slice(o,a)),e.ext=t.slice(n,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function ju(t,e,s,i,r){const n=e[s];for(let o=0;o<n.length;o++){const a=n[o];s<e.length-1?ju(t.replace(i[s],a),e,s+1,i,r):r.push(t.replace(i[s],a))}}function Bv(t){const e=/\{(.*?)\}/g,s=t.match(e),i=[];if(s){const r=[];s.forEach(n=>{const o=n.substring(1,n.length-1).split(",");r.push(o)}),ju(t,r,0,s,i)}else i.push(t);return i}const ec=t=>!Array.isArray(t);class Xu{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,s)=>`${e}${this._bundleIdConnector}${s}`,extractAssetIdFromBundle:(e,s)=>s.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(s=>{this._preferredOrder.push(s),s.priority||(s.priority=Object.keys(s.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const s=e;this._defaultSearchParams=Object.keys(s).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(s[i])}`).join("&")}}getAlias(e){const{alias:s,src:i}=e;return ti(s||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}removeAlias(e,s){this._assetMap[e]&&(s&&s!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&$e("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(s=>{this.addBundle(s.name,s.assets)})}addBundle(e,s){const i=[];let r=s;Array.isArray(s)||(r=Object.entries(s).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const h=this._createBundleAssetId(e,a);i.push(h),l=[a,h]}else{const h=a.map(c=>this._createBundleAssetId(e,c));i.push(...h),l=[...a,...h]}this.add({...n,alias:l,src:o})}),this._bundles[e]=i}add(e){const s=[];Array.isArray(e)?s.push(...e):s.push(e);let i;i=n=>{this.hasKey(n)&&$e(`[Resolver] already has key: ${n} overwriting`)},ti(s).forEach(n=>{const{src:o}=n;let{data:a,format:l,loadParser:h,parser:c}=n;const d=ti(o).map(_=>typeof _=="string"?Bv(_):Array.isArray(_)?_:[_]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const f=[],p=_=>{const g=this._parsers.find(m=>m.test(_));return{src:_,...g==null?void 0:g.parse(_)}};d.forEach(_=>{_.forEach(g=>{let m={};if(typeof g!="object"?m=p(g):(a=g.data??a,l=g.format??l,(g.loadParser||g.parser)&&(h=g.loadParser??h,c=g.parser??c),m={...p(g.src),...g}),!u)throw new Error(`[Resolver] alias is undefined for this asset: ${m.src}`);m=this._buildResolvedAsset(m,{aliases:u,data:a,format:l,loadParser:h,parser:c,progressSize:n.progressSize}),f.push(m)})}),u.forEach(_=>{this._assetMap[_]=f})})}resolveBundle(e){const s=ec(e);e=ti(e);const i={};return e.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(r,l)]=h}i[r]=a}}),s?i[e[0]]:i}resolveUrl(e){const s=this.resolve(e);if(typeof e!="string"){const i={};for(const r in s)i[r]=s[r].src;return i}return s.src}resolve(e){const s=ec(e);e=ti(e);const i={};return e.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(l=>{const h=n.filter(c=>c[a]?c[a]===l:!1);h.length&&(n=h)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),s?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let s=0;s<e.length;s++){const i=e[s],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const s=/\?/.test(e)?"&":"?";return`${e}${s}${this._defaultSearchParams}`}_buildResolvedAsset(e,s){const{aliases:i,data:r,loadParser:n,parser:o,format:a,progressSize:l}=s;return(this._basePath||this._rootPath)&&(e.src=Ji.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...r||{},...e.data},e.loadParser=n??e.loadParser,e.parser=o??e.parser,e.format=a??e.format??Lv(e.src),l!==void 0&&(e.progressSize=l),e}}Xu.RETINA_PREFIX=/@([0-9\.]+)x/;function Lv(t){return t.split(".").pop().split("?").shift().split("#").shift()}const tc=(t,e)=>{const s=e.split("?")[1];return s&&(t+=`?${s}`),t},Zu=class Wi{constructor(e,s){this.linkedSheets=[];let i=e;(e==null?void 0:e.source)instanceof ut&&(i={texture:e,data:s});const{texture:r,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=r instanceof ue?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Wi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,s=!1){let i=e;const r=s?1/0:Wi.BATCH_SIZE;for(;i-e<r&&i<this._frameKeys.length;){const n=this._frameKeys[i],o=this._frames[n],a=o.frame;if(a){let l=null,h=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,d=new Ee(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?l=new Ee(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):l=new Ee(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(h=new Ee(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new ue({source:this.textureSource,frame:l,orig:d,trim:h,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}i++}}_processAnimations(){const e=this.data.animations||{};for(const s in e){this.animations[s]=[];for(let i=0;i<e[s].length;i++){const r=e[s][i];this.animations[s].push(this.textures[r])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Wi.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Wi.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var s;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((s=this._texture)==null||s.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Zu.BATCH_SIZE=1e3;let sc=Zu;const Iv=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Ju(t,e,s){const i={};if(t.forEach(r=>{i[r]=e}),Object.keys(e.textures).forEach(r=>{i[`${e.cachePrefix}${r}`]=e.textures[r]}),!s){const r=Ji.dirname(t[0]);e.linkedSheets.forEach((n,o)=>{const a=Ju([`${r}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const Dv={extension:X.Asset,cache:{test:t=>t instanceof sc,getCacheableAssets:(t,e)=>Ju(t,e,!1)},resolver:{extension:{type:X.ResolveParser,name:"resolveSpritesheet"},test:t=>{const s=t.split("?")[0].split("."),i=s.pop(),r=s.pop();return i==="json"&&Iv.includes(r)},parse:t=>{var s;const e=t.split(".");return{resolution:parseFloat(((s=Xu.RETINA_PREFIX.exec(t))==null?void 0:s[1])??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:X.LoadParser,priority:Ku.Normal,name:"spritesheetLoader"},async testParse(t,e){return Ji.extname(e.src).toLowerCase()===".json"&&!!t.frames},async parse(t,e,s){var d,u;const{texture:i,imageFilename:r,textureOptions:n,cachePrefix:o}=(e==null?void 0:e.data)??{};let a=Ji.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(i instanceof ue)l=i;else{const f=tc(a+(r??t.meta.image),e.src);l=(await s.load([{src:f,data:n}]))[f]}const h=new sc({texture:l.source,data:t,cachePrefix:o});await h.parse();const c=(d=t==null?void 0:t.meta)==null?void 0:d.related_multi_packs;if(Array.isArray(c)){const f=[];for(const _ of c){if(typeof _!="string")continue;let g=a+_;(u=e.data)!=null&&u.ignoreMultiPack||(g=tc(g,e.src),f.push(s.load({src:g,data:{textureOptions:n,ignoreMultiPack:!0}})))}const p=await Promise.all(f);h.linkedSheets=p,p.forEach(_=>{_.linkedSheets=[h].concat(h.linkedSheets.filter(g=>g!==_))})}return h},async unload(t,e,s){await s.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};Re.add(Dv);const lo=Object.create(null),ic=Object.create(null);function Cn(t,e){let s=ic[t];return s===void 0&&(lo[e]===void 0&&(lo[e]=1),ic[t]=s=lo[e]++),s}let Xs;function Qu(){return(!Xs||Xs!=null&&Xs.isContextLost())&&(Xs=Oe.get().createCanvas().getContext("webgl",{})),Xs}let Rr;function Ov(){if(!Rr){Rr="mediump";const t=Qu();t&&t.getShaderPrecisionFormat&&(Rr=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision?"highp":"mediump")}return Rr}function Fv(t,e,s){return e?t:s?(t=t.replace("out vec4 finalColor;",""),`
94
+
95
+ #ifdef GL_ES // This checks if it is WebGL1
96
+ #define in varying
97
+ #define finalColor gl_FragColor
98
+ #define texture texture2D
99
+ #endif
100
+ ${t}
101
+ `):`
102
+
103
+ #ifdef GL_ES // This checks if it is WebGL1
104
+ #define in attribute
105
+ #define out varying
106
+ #endif
107
+ ${t}
108
+ `}function $v(t,e,s){const i=s?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(t.substring(0,9)!=="precision"){let r=s?e.requestedFragmentPrecision:e.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float;
109
+ ${t}`}else if(i!=="highp"&&t.substring(0,15)==="precision highp")return t.replace("precision highp","precision mediump");return t}function Nv(t,e){return e?`#version 300 es
110
+ ${t}`:t}const Hv={},Wv={};function zv(t,{name:e="pixi-program"},s=!0){e=e.replace(/\s+/g,"-"),e+=s?"-fragment":"-vertex";const i=s?Hv:Wv;return i[e]?(i[e]++,e+=`-${i[e]}`):i[e]=1,t.indexOf("#define SHADER_NAME")!==-1?t:`${`#define SHADER_NAME ${e}`}
111
+ ${t}`}function Gv(t,e){return e?t.replace("#version 300 es",""):t}const co={stripVersion:Gv,ensurePrecision:$v,addProgramDefines:Fv,setProgramName:zv,insertVersion:Nv},Ti=Object.create(null),ef=class ba{constructor(e){e={...ba.defaultOptions,...e};const s=e.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:s,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ov()},setProgramName:{name:e.name},addProgramDefines:s,insertVersion:s};let r=e.fragment,n=e.vertex;Object.keys(co).forEach(o=>{const a=i[o];r=co[o](r,a,!0),n=co[o](n,a,!1)}),this.fragment=r,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=Cn(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,Ti[this._cacheKey]=null}static from(e){const s=`${e.vertex}:${e.fragment}`;return Ti[s]||(Ti[s]=new ba(e),Ti[s]._cacheKey=s),Ti[s]}};ef.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let tf=ef;const rc={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Uv(t){return rc[t]??rc.float32}const qv={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},nc=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function oc(t,e){let s;for(;(s=nc.exec(t))!==null;){const i=qv[s[3]]??"float32";e[s[2]]={location:parseInt(s[1],10),format:i,stride:Uv(i).stride,offset:0,instance:!1,start:0}}nc.lastIndex=0}function Vv(t){return t.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Yv({source:t,entryPoint:e}){const s={},i=Vv(t),r=i.indexOf(`fn ${e}(`);if(r===-1)return s;const n=i.indexOf("->",r);if(n===-1)return s;const o=i.substring(r,n);if(oc(o,s),Object.keys(s).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const l=a[1],h=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),c=i.match(h);c&&oc(c[1],s)}}return s}function uo(t){var d,u;const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,s=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,h=(d=t.match(e))==null?void 0:d.map(f=>{const p=f.match(r),_=(p==null?void 0:p[1])??"";let g;return _==="<uniform>"?g="uniform":_.startsWith("<storage")&&(g="storage"),{group:parseInt(f.match(s)[1],10),binding:parseInt(f.match(i)[1],10),name:p[2],accessMode:g,type:f.match(n)[1]}});if(!h)return{groups:[],structs:[]};const c=((u=t.match(o))==null?void 0:u.map(f=>{const p=f.match(l)[1],_=f.match(a).reduce((g,m)=>{const[y,v]=m.split(":");return g[y.trim()]=v.trim(),g},{});return _?{name:p,members:_}:null}).filter(({name:f})=>h.some(p=>p.type===f||p.type.includes(`<${f}>`))))??[];return{groups:h,structs:c}}var We=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(We||{});function Kv({groups:t}){const e=[];for(let s=0;s<t.length;s++){const i=t[s];e[i.group]||(e[i.group]=[]),i.accessMode==="uniform"?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,buffer:{type:"uniform"}}):i.accessMode==="storage"?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,buffer:{type:"read-only-storage"}}):i.type==="sampler"?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,sampler:{type:"filtering"}}):i.type==="sampler_comparison"?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,sampler:{type:"comparison"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_depth_2d"?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d",multisampled:!1}}):i.type==="texture_depth_2d_array"?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d-array",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&e[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let s=0;s<e.length;s++)e[s]||(e[s]=[]);return e}function jv({groups:t}){const e=[];for(let s=0;s<t.length;s++){const i=t[s];e[i.group]||(e[i.group]={}),e[i.group][i.name]=i.binding}return e}function Xv(t,e){const s=new Set,i=new Set,r=[...t.structs,...e.structs].filter(o=>s.has(o.name)?!1:(s.add(o.name),!0)),n=[...t.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:r,groups:n}}const Ei=Object.create(null);class kn{constructor(e){var a,l;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:s,vertex:i,layout:r,gpuLayout:n,name:o}=e;if(this.name=o,this.fragment=s,this.vertex=i,s.source===i.source){const h=uo(s.source);this.structsAndGroups=h}else{const h=uo(i.source),c=uo(s.source);this.structsAndGroups=Xv(h,c)}this.layout=r??jv(this.structsAndGroups),this.gpuLayout=n??Kv(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((l=this.layout[1])==null?void 0:l.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:e,fragment:s}=this,i=e.source+s.source+e.entryPoint+s.entryPoint;this._layoutKey=Cn(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Yv(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Ei[this._cacheKey]=null}static from(e){const s=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return Ei[s]||(Ei[s]=new kn(e),Ei[s]._cacheKey=s),Ei[s]}}const sf=["f32","i32","u32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>","vec2<u32>","vec3<u32>","vec4<u32>"],Zv=sf.reduce((t,e)=>(t[e]=!0,t),{});function Jv(t,e){switch(t){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const rf=class nf extends Dt{constructor(e,s){super(),this.uid=ve("uniform"),this._resourceType="uniformGroup",this._resourceId=ve("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,s={...nf.defaultOptions,...s},this.uniformStructures=e;const i={};for(const r in e){const n=e[r];if(n.name=r,n.size=n.size??1,!Zv[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,l]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${l} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${sf.join(", ")}`)}n.value??(n.value=Jv(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=s.ubo,this.isStatic=s.isStatic,this._signature=Cn(Object.keys(i).map(r=>`${r}-${e[r].type}`).join("-"),"uniform-group")}get buffer(){return this._buffer}set buffer(e){var s;this._buffer!==e&&((s=this._buffer)==null||s.off("change",this.onBufferChange,this),this._buffer=e,e==null||e.on("change",this.onBufferChange,this))}get _gcLastUsed(){var e;return((e=this._buffer)==null?void 0:e._gcLastUsed)??-1}set _gcLastUsed(e){this._buffer&&(this._buffer._gcLastUsed=e)}onBufferChange(){this._resourceId=ve("resource"),this.emit("change",this)}update(){this._dirtyId++}};rf.defaultOptions={ubo:!1,isStatic:!1};let of=rf;class Kr{constructor(e){this.resources=Object.create(null),this._dirty=!0;let s=0;for(const i in e){const r=e[i];this.setResource(r,s++)}}get _key(){if(this._dirty){this._dirty=!1;const e=[];let s=0;for(const i in this.resources)e[s++]=this.resources[i]?this.resources[i]._resourceId:-1;this._keyValue=e.join("|")}return this._keyValue}setResource(e,s){var r,n;const i=this.resources[s];e!==i&&(i&&((r=i.off)==null||r.call(i,"change",this.onResourceChange,this)),(n=e.on)==null||n.call(e,"change",this.onResourceChange,this),this.resources[s]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e){const s=this.resources;for(const i in s){const r=s[i];r&&(r._gcLastUsed=e)}}destroy(){var s;const e=this.resources;for(const i in e){const r=e[i];(s=r==null?void 0:r.off)==null||s.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(e){if(this._dirty=!0,e.destroyed){const s=this.resources;for(const i in s)s[i]===e&&(s[i]=null);$e(`[BindGroup] a '${e._resourceType}' was destroyed while still bound to a shader. Remove it from the shader before destroying it.`)}}}var wa=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.CANVAS=4]="CANVAS",t[t.BOTH=3]="BOTH",t))(wa||{});class ln{constructor(e){this.data={...e};const s=Object.keys(e).sort().map(i=>`${i}:${e[i]}`).join("|");this.id=Cn(s,"shader-overrides")}static from(e){return e instanceof ln?e:new ln(e)}}class ch extends Dt{constructor(e){super(),this.uid=ve("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:s,glProgram:i,groups:r,resources:n,compatibleRenderers:o,groupMap:a,overrides:l}=e;this._overrides=l?ln.from(l):null,this.gpuProgram=s,this.glProgram=i,o===void 0&&(o=0,s&&(o|=wa.WEBGPU),i&&(o|=wa.WEBGL)),this.compatibleRenderers=o;const h={};if(a)for(const c in a)for(const d in a[c]){const u=a[c][d];h[u]={group:c,binding:d,name:u}}if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!s&&r&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(s&&r&&!a){const c=s.structsAndGroups.groups;a={},c.forEach(d=>{a[d.group]=a[d.group]||{},a[d.group][d.binding]=d.name,h[d.name]=d})}else if(n){r={},a||(a={}),s&&s.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let c=0;for(const d in n)h[d]||(s&&!i&&$e(`[Shader] the resource '${d}' matches no binding in the WGSL source — is the name correct?`),r[99]||(r[99]=new Kr,this._ownedBindGroups.push(r[99])),h[d]={group:99,binding:c,name:d},a[99]=a[99]||{},a[99][c]=d,c++);for(const d in n){const u=d;let f=n[d];!f.source&&!f._resourceType&&(f=new of(f));const p=h[u];p&&(r[p.group]||(r[p.group]=new Kr,this._ownedBindGroups.push(r[p.group])),r[p.group].setResource(f,p.binding))}}this.groups=r,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(r,h)}addResource(e,s,i){var r,n;(r=this._uniformBindMap)[s]||(r[s]={}),(n=this._uniformBindMap[s])[i]||(n[i]=e),this.groups[s]||(this.groups[s]=new Kr,this._ownedBindGroups.push(this.groups[s]))}_buildResourceAccessor(e,s){const i={};for(const r in s){const n=s[r];Object.defineProperty(i,n.name,{get(){return e[n.group].getResource(n.binding)},set(o){e[n.group].setResource(o,n.binding)}})}return i}destroy(e=!1){var s,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&((s=this.gpuProgram)==null||s.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null,this._overrides=null)}static from(e){const{gpu:s,gl:i,...r}=e;let n,o;return s&&(n=kn.from(s)),i&&(o=tf.from(i)),new ch({gpuProgram:n,glProgram:o,...r})}}const Qv={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},eb={BLEND:0,OFFSET:1,CULLING:2,DEPTH_TEST:3,WINDING:4,DEPTH_MASK:5},{BLEND:fo,OFFSET:po,CULLING:_o,DEPTH_TEST:mo,WINDING:go,DEPTH_MASK:yo}=eb,xa=class af{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<fo)}set blend(e){!!(this.data&1<<fo)!==e&&(this.data^=1<<fo)}get offsets(){return!!(this.data&1<<po)}set offsets(e){!!(this.data&1<<po)!==e&&(this.data^=1<<po)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<_o)}set culling(e){!!(this.data&1<<_o)!==e&&(this.data^=1<<_o)}get depthTest(){return!!(this.data&1<<mo)}set depthTest(e){!!(this.data&1<<mo)!==e&&(this.data^=1<<mo)}get depthMask(){return!!(this.data&1<<yo)}set depthMask(e){!!(this.data&1<<yo)!==e&&(this.data^=1<<yo)}get clockwiseFrontFace(){return!!(this.data&1<<go)}set clockwiseFrontFace(e){!!(this.data&1<<go)!==e&&(this.data^=1<<go)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=Qv[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new af;return e.depthTest=!1,e.depthMask=!1,e.blend=!0,e}};xa.default2d=xa.for2d();let hf=xa;const Sa=[];Re.handleByNamedList(X.Environment,Sa);async function tb(t){if(!t)for(let e=0;e<Sa.length;e++){const s=Sa[e];if(s.value.test()){await s.value.load();return}}}let Pi;function sb(){if(typeof Pi=="boolean")return Pi;try{Pi=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Pi=!1}return Pi}const Qi=new Set;let Ca=!1;function ac(t,e,s=2){const i=e&&e.length,r=i?e[0]*s:t.length;Qi.size&&Qi.clear();let n=lf(t,0,r,s,!0);const o=[];if(!n||n.next===n.prev)return o;let a=0,l=0,h=0;if(i&&(n=ab(t,e,n,s)),t.length>80*s){a=t[0],l=t[1];let c=a,d=l;for(let u=s;u<r;u+=s){const f=t[u],p=t[u+1];f<a&&(a=f),p<l&&(l=p),f>c&&(c=f),p>d&&(d=p)}h=Math.max(c-a,d-l),h=h!==0?32767/h:0}return ka(n,o,a,l,h),o}function lf(t,e,s,i,r){let n=null;if(r===bb(t,e,s,i)>0)for(let o=e;o<s;o+=i)n=cc(o/i|0,t[o],t[o+1],n);else for(let o=s-i;o>=e;o-=i)n=cc(o/i|0,t[o],t[o+1],n);return n&&er(n,n.next)&&(sr(n),n=n.next),n}function Us(t,e=t){const s=e===t;let i=t,r;do r=!1,i!==i.next&&(Qi.size===0||!Qi.has(i))&&(er(i,i.next)||Fe(i.prev,i,i.next)===0)?((s||i===e)&&(e=i.prev),Ca=!0,sr(i),i=i.prev,r=!0):(s||i!==e)&&(i=i.next,r=!s);while(r||i!==e);return e}function ka(t,e,s,i,r){r&&pb(t,s,i,r);let n=t,o=!1;for(;t.prev!==t.next;){const a=t.prev,l=t.next;if(Fe(a,t,l)<0&&(r?rb(t,s,i,r):ib(t))){e.push(a.i,t.i,l.i),sr(t),t=l,n=l;continue}if(t=l,t===n){if(Ca=!1,t=Us(t),Ca){n=t;continue}if(!o){t=nb(t,e),n=t,o=!0;continue}ob(t,e,s,i,r);break}}}function ib(t){const e=t.prev,s=t,i=t.next,r=e.x,n=s.x,o=i.x,a=e.y,l=s.y,h=i.y,c=Math.min(r,n,o),d=Math.min(a,l,h),u=Math.max(r,n,o),f=Math.max(a,l,h);let p=i.next;for(;p!==e;){if(p.x>=c&&p.x<=u&&p.y>=d&&p.y<=f&&!(r===p.x&&a===p.y)&&dn(r,a,n,l,o,h,p.x,p.y)&&Fe(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function rb(t,e,s,i){const r=t.prev,n=t,o=t.next,a=r.x,l=n.x,h=o.x,c=r.y,d=n.y,u=o.y,f=Math.min(a,l,h),p=Math.min(c,d,u),_=Math.max(a,l,h),g=Math.max(c,d,u),m=Pa(f,p,e,s,i),y=Pa(_,g,e,s,i);let v=t.prevZ;for(;v&&v.z>=m;){if(v.x>=f&&v.x<=_&&v.y>=p&&v.y<=g&&v!==o&&!(a===v.x&&c===v.y)&&dn(a,c,l,d,h,u,v.x,v.y)&&Fe(v.prev,v,v.next)>=0)return!1;v=v.prevZ}let b=t.nextZ;for(;b&&b.z<=y;){if(b.x>=f&&b.x<=_&&b.y>=p&&b.y<=g&&b!==o&&!(a===b.x&&c===b.y)&&dn(a,c,l,d,h,u,b.x,b.y)&&Fe(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function nb(t,e){let s=t,i=!1;do{const r=s.prev,n=s.next.next;uf(r,s,s.next,n,!1)&&tr(r,n)&&tr(n,r)&&(e.push(r.i,s.i,n.i),sr(s),sr(s.next),s=t=n,i=!0),s=s.next}while(s!==t);return i?Us(s):s}function ob(t,e,s,i,r){let n=t;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&gb(n,o)){let a=ff(n,o);n=Us(n,n.next),a=Us(a,a.next),ka(n,e,s,i,r),ka(a,e,s,i,r);return}o=o.next}n=n.next}while(n!==t)}let Ma=!1;function ab(t,e,s,i){const r=[];for(let n=0,o=e.length;n<o;n++){const a=e[n]*i,l=n<o-1?e[n+1]*i:t.length,h=lf(t,a,l,i,!1);h===h.next&&Qi.add(h),r.push(mb(h))}r.sort(hb),cb(t.length/i,e.length),df(s,s),Ma=!0;for(let n=0;n<r.length;n++)s=lb(r[n],s);return Ma=!1,Us(s)}function hb(t,e){return t.x-e.x||t.y-e.y||(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}function lb(t,e){const s=ub(t,e);if(!s)return e;const i=ff(s,t),r=i.next;return df(s,r.next),Us(i,i.next),Us(s,s.next)}const cf=16;let Te=new Float64Array(0),cn=0;const Ta=[],Ea=[];function cb(t,e){const s=Math.ceil((t+2*e)/cf)+e+2;Te.length<s*4&&(Te=new Float64Array(s*4)),cn=0}function df(t,e){let s=t;do{const i=cn++;Ta[i]=s;let r=1/0,n=1/0,o=-1/0,a=-1/0,l=0;do{const c=s.next;s.z=i,s.x<r&&(r=s.x),s.x>o&&(o=s.x),s.y<n&&(n=s.y),s.y>a&&(a=s.y),c.x<r&&(r=c.x),c.x>o&&(o=c.x),c.y<n&&(n=c.y),c.y>a&&(a=c.y),s=c}while(++l<cf&&s!==e);Ea[i]=s;const h=i*4;Te[h]=r,Te[h+1]=n,Te[h+2]=o,Te[h+3]=a}while(s!==e)}function db(t,e){const s=t.z*4;e.x<Te[s]&&(Te[s]=e.x),e.y<Te[s+1]&&(Te[s+1]=e.y),e.x>Te[s+2]&&(Te[s+2]=e.x),e.y>Te[s+3]&&(Te[s+3]=e.y)}function hc(t){let e=Ea[t];for(;e.prev.next!==e;)e=e.next;return Ea[t]=e,e}function lc(t){let e=Ta[t];for(;e.prev.next!==e;)e=e.next;return Ta[t]=e,e}function ub(t,e){let s=e;const i=t.x,r=t.y;let n=-1/0,o;if(er(t,s))return s;for(let u=0,f=0;u<cn;u++,f+=4){if(r<Te[f+1]||r>Te[f+3]||Te[f]>i||Te[f+2]<=n)continue;const p=hc(u);s=lc(u);do{if(s.prev.next===s){if(er(t,s.next))return s.next;if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const _=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(_<=i&&_>n&&(n=_,o=s.x<s.next.x?s:s.next,_===i))return o}}s=s.next}while(s!==p)}if(!o)return null;const a=o.x,l=o.y,h=Math.min(r,l),c=Math.max(r,l);let d=1/0;for(let u=0,f=0;u<cn;u++,f+=4){if(Te[f+2]<a||Te[f]>i||Te[f+3]<h||Te[f+1]>c)continue;const p=hc(u);s=lc(u);do{if(s.prev.next===s&&i>=s.x&&s.x>=a&&i!==s.x&&dn(r<l?i:n,r,a,l,r<l?n:i,r,s.x,s.y)){const _=Math.abs(r-s.y)/(i-s.x);(tr(s,t)||s.y===r&&s.next.y===r&&s.next.x>i)&&(_<d||_===d&&(s.x>o.x||s.x===o.x&&fb(o,s)))&&(o=s,d=_)}s=s.next}while(s!==p)}return o}function fb(t,e){return Fe(t.prev,t,e.prev)<0&&Fe(e.next,t,t.next)<0}const xt=[];let Ai=[],ks=new Uint32Array(0),Ri=new Uint32Array(0);const Bi=new Uint32Array(256);function pb(t,e,s,i){let r=t,n=0;do r.z=Pa(r.x,r.y,e,s,i),xt[n++]=r,r=r.next;while(r!==t);_b(n);let o=null;for(let a=0;a<n;a++){const l=xt[a];l.prevZ=o,o&&(o.nextZ=l),o=l}o.nextZ=null}function _b(t){if(t<=32){for(let e=1;e<t;e++){const s=xt[e],i=s.z;let r=e-1;for(;r>=0&&xt[r].z>i;)xt[r+1]=xt[r],r--;xt[r+1]=s}return}ks.length<t&&(ks=new Uint32Array(t),Ri=new Uint32Array(t),Ai=new Array(t));for(let e=0;e<t;e++)ks[e]=xt[e].z;Br(t,xt,ks,Ai,Ri,0),Br(t,Ai,Ri,xt,ks,8),Br(t,xt,ks,Ai,Ri,16),Br(t,Ai,Ri,xt,ks,24)}function Br(t,e,s,i,r,n){Bi.fill(0);for(let a=0;a<t;a++)Bi[s[a]>>>n&255]++;let o=0;for(let a=0;a<256;a++){const l=Bi[a];Bi[a]=o,o+=l}for(let a=0;a<t;a++){const l=s[a],h=Bi[l>>>n&255]++;i[h]=e[a],r[h]=l}}function Pa(t,e,s,i,r){return t=(t-s)*r|0,e=(e-i)*r|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function mb(t){let e=t,s=t;do(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next;while(e!==t);return s}function dn(t,e,s,i,r,n,o,a){return(r-o)*(e-a)>=(t-o)*(n-a)&&(t-o)*(i-a)>=(s-o)*(e-a)&&(s-o)*(n-a)>=(r-o)*(i-a)}function gb(t,e){const s=er(t,e)&&Fe(t.prev,t,t.next)>0&&Fe(e.prev,e,e.next)>0;return t.next.i!==e.i&&(s||tr(t,e)&&tr(e,t)&&(Fe(t.prev,t,e.prev)!==0||Fe(t,e.prev,e)!==0))&&!yb(t,e)&&(s||vb(t,e))}function Fe(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function er(t,e){return t.x===e.x&&t.y===e.y}function uf(t,e,s,i,r=!0){const n=Fe(t,e,s),o=Fe(t,e,i),a=Fe(s,i,t),l=Fe(s,i,e);return(n>0&&o<0||n<0&&o>0)&&(a>0&&l<0||a<0&&l>0)?!0:r?!!(n===0&&Lr(t,s,e)||o===0&&Lr(t,i,e)||a===0&&Lr(s,t,i)||l===0&&Lr(s,e,i)):!1}function Lr(t,e,s){return e.x<=Math.max(t.x,s.x)&&e.x>=Math.min(t.x,s.x)&&e.y<=Math.max(t.y,s.y)&&e.y>=Math.min(t.y,s.y)}function yb(t,e){const s=Math.min(t.x,e.x),i=Math.max(t.x,e.x),r=Math.min(t.y,e.y),n=Math.max(t.y,e.y);let o=t;do{const a=o.next;if(o.x>i&&a.x>i||o.x<s&&a.x<s||o.y>n&&a.y>n||o.y<r&&a.y<r){o=a;continue}if(o.i!==t.i&&a.i!==t.i&&o.i!==e.i&&a.i!==e.i&&uf(o,a,t,e))return!0;o=a}while(o!==t);return!1}function tr(t,e){return Fe(t.prev,t,t.next)<0?Fe(t,e,t.next)>=0&&Fe(t,t.prev,e)>=0:Fe(t,e,t.prev)<0||Fe(t,t.next,e)<0}function vb(t,e){let s=t,i=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{const o=s.next;s.y>n!=o.y>n&&r<(o.x-s.x)*(n-s.y)/(o.y-s.y)+s.x&&(i=!i),s=o}while(s!==t);return i}function ff(t,e){const s=Aa(t.i,t.x,t.y),i=Aa(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function cc(t,e,s,i){const r=Aa(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function sr(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ),Ma&&db(t.prev,t.next)}function Aa(t,e,s){return{i:t,x:e,y:s,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function bb(t,e,s,i){let r=0;for(let n=e,o=s-i;n<s;n+=i)r+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return r}const wb=ac.default||ac;var pf=(t=>(t[t.NONE=0]="NONE",t[t.COLOR=16384]="COLOR",t[t.STENCIL=1024]="STENCIL",t[t.DEPTH=256]="DEPTH",t[t.COLOR_DEPTH=16640]="COLOR_DEPTH",t[t.COLOR_STENCIL=17408]="COLOR_STENCIL",t[t.DEPTH_STENCIL=1280]="DEPTH_STENCIL",t[t.ALL=17664]="ALL",t))(pf||{});class xb{constructor(e){this.items=[],this._name=e}emit(e,s,i,r,n,o,a,l){const{name:h,items:c}=this;for(let d=0,u=c.length;d<u;d++)c[d][h](e,s,i,r,n,o,a,l);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){const s=this.items.indexOf(e);return s!==-1&&this.items.splice(s,1),this}contains(e){return this.items.indexOf(e)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const Sb=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],_f=class mf extends Dt{constructor(e){super(),this.tick=0,this.uid=ve("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;const s=[...Sb,...this.config.runners??[]];this._addRunners(...s),this._unsafeEvalCheck()}async init(e={}){const s=e.skipExtensionImports===!0?!0:e.manageImports===!1;await tb(s),!s&&this.config.loaders&&await Promise.all(this.config.loaders.map(i=>i.value.load())),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)e={...this._systemsHash[i].constructor.defaultOptions,...e};e={...mf.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(e);this._initOptions=e}render(e,s){this.tick++;let i=e;if(i instanceof ce&&(i={container:i},s&&(j(Me,"passing a second argument is deprecated, please use render options instead"),i.target=s.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:Ce.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i))}resize(e,s,i){const r=this.view.resolution;this.view.resize(e,s,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==r&&this.runners.resolutionChange.emit(i)}clear(e={}){const s=this;e.target||(e.target=s.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=pf.ALL);const{clear:i,clearColor:r,target:n,mipLevel:o,layer:a}=e;Ce.shared.setValue(r??this.background.colorRgba),s.renderTarget.clear(n,i,Ce.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...e){e.forEach(s=>{this.runners[s]=new xb(s)})}_addSystems(e){let s;for(s in e){const i=e[s];this._addSystem(i.value,i.name)}}_addSystem(e,s){const i=new e(this);if(this[s])throw new Error(`Whoops! The name "${s}" is already in use`);this[s]=i,this._systemsHash[s]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(e,s){const i=s.reduce((r,n)=>(r[n.name]=n.value,r),{});e.forEach(r=>{const n=r.value,o=r.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e=="object"&&e.releaseGlobalResources)&&cr.release(),Object.values(this.runners).forEach(s=>{s.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!sb())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};_f.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let gf=_f,Ir;function Cb(t){return Ir!==void 0||(Ir=(()=>{var s;const e={stencil:!0,failIfMajorPerformanceCaveat:t??gf.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Oe.get().getWebGLRenderingContext())return!1;let r=Oe.get().createCanvas().getContext("webgl",e);const n=!!((s=r==null?void 0:r.getContextAttributes())!=null&&s.stencil);if(r){const o=r.getExtension("WEBGL_lose_context");o&&o.loseContext()}return r=null,n}catch{return!1}})()),Ir}let Dr;async function kb(t={}){return Dr!==void 0||(Dr=await(async()=>{const e=Oe.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(t)).requestDevice(),!0}catch{return!1}})()),Dr}const dc=["webgl","webgpu","canvas"];async function Mb(t){let e=[];t.preference?Array.isArray(t.preference)?e=t.preference.slice():(e.push(t.preference),dc.forEach(n=>{n!==t.preference&&e.push(n)})):e=dc.slice();let s,i={};for(let n=0;n<e.length;n++){const o=e[n];if(o==="webgpu"&&await kb()){const{WebGPURenderer:a}=await ai(async()=>{const{WebGPURenderer:l}=await import("./WebGPURenderer-ByQ-10KB.js");return{WebGPURenderer:l}},__vite__mapDeps([3,4,5,2]));s=a,i={...t,...t.webgpu};break}else if(o==="webgl"&&Cb(t.failIfMajorPerformanceCaveat??gf.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await ai(async()=>{const{WebGLRenderer:l}=await import("./WebGLRenderer-DprtkQRW.js");return{WebGLRenderer:l}},__vite__mapDeps([6,4,5,2]));s=a,i={...t,...t.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await ai(async()=>{const{CanvasRenderer:l}=await import("./CanvasRenderer-DY1TnK1M.js");return{CanvasRenderer:l}},__vite__mapDeps([7,5,2]));s=a,i={...t,...t.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!s)throw new Error("No available renderer for the current environment");const r=new s;return await r.init(i),r}const yf="8.21.0";class vf{static init(){var e;(e=globalThis.__PIXI_APP_INIT__)==null||e.call(globalThis,this,yf)}static destroy(){}}vf.extension=X.Application;class Tb{constructor(e){this._renderer=e}init(){var e;(e=globalThis.__PIXI_RENDERER_INIT__)==null||e.call(globalThis,this._renderer,yf)}destroy(){this._renderer=null}}Tb.extension={type:[X.WebGLSystem,X.WebGPUSystem],name:"initHook",priority:-10};class bf{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(s){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=s,s&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let s,i;if(this._resizeTo===globalThis.window)s=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;s=r,i=n}this.renderer.resize(s,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}bf.extension=X.Application;class wf{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{configurable:!0,set(s){this._ticker&&this._ticker.remove(this.render,this),this._ticker=s,s&&s.add(this.render,this,hn.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?ni.shared:new ni,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}wf.extension=X.Application;Re.add(bf);Re.add(wf);const xf=class Ra{constructor(...e){this.stage=new ce,e[0]!==void 0&&j(Me,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new ce),this.renderer=await Mb(e),Ra._plugins.forEach(s=>{s.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return j(Me,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var e;return(e=this.renderer.renderPipes.dom)==null?void 0:e._domElement}destroy(e=!1,s=!1){const i=Ra._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(s),this.stage=null,this.renderer.destroy(e),this.renderer=null}};xf._plugins=[];let Sf=xf;Re.handleByList(X.Application,Sf._plugins);Re.add(vf);const vo={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Eb=/([astvzqmhlc])([^astvzqmhlc]*)/gi,Pb=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function Ab(t){const e=[];return t.replace(Eb,(s,i,r)=>{let n=i.toLowerCase(),o=i;const a=Rb(r);for(n==="m"&&a.length>2&&(e.push([o,...a.splice(0,2)]),n="l",o=o==="m"?"l":"L");;){if(a.length===vo[n])return e.push([o,...a]),"";if(a.length<vo[n])throw new Error("malformed path data");e.push([o,...a.splice(0,vo[n])])}}),e}function Rb(t){const e=t.match(Pb);return e?e.map(Number):[]}function Bb(t,e){const s=Ab(t),i=[];let r=null,n=0,o=0;for(let a=0;a<s.length;a++){const l=s[a],h=l[0],c=l;switch(h){case"M":n=c[1],o=c[2],e.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],e.moveTo(n,o);break;case"H":n=c[1],e.lineTo(n,o);break;case"h":n+=c[1],e.lineTo(n,o);break;case"V":o=c[1],e.lineTo(n,o);break;case"v":o+=c[1],e.lineTo(n,o);break;case"L":n=c[1],o=c[2],e.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],e.lineTo(n,o);break;case"C":n=c[5],o=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":e.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],e.bezierCurveToShort(c[1],c[2],n,o);break;case"s":e.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],e.quadraticCurveTo(c[1],c[2],n,o);break;case"q":e.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],e.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],e.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":e.closePath(),i.length>0&&(r=i.pop(),r?(n=r.startX,o=r.startY):(n=0,o=0)),r=null;break;default:$e(`Unknown SVG path command: ${h}`)}h!=="Z"&&h!=="z"&&r===null&&(r={startX:n,startY:o},i.push(r))}return e}class dh{constructor(e=0,s=0,i=0){this.type="circle",this.x=e,this.y=s,this.radius=i}clone(){return new dh(this.x,this.y,this.radius)}contains(e,s){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-e,n=this.y-s;return r*=r,n*=n,r+n<=i}strokeContains(e,s,i,r=.5){if(this.radius===0)return!1;const n=this.x-e,o=this.y-s,a=this.radius,l=(1-r)*i,h=Math.sqrt(n*n+o*o);return h<=a+l&&h>a-(i-l)}getBounds(e){return e||(e=new Ee),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class uh{constructor(e=0,s=0,i=0,r=0){this.type="ellipse",this.x=e,this.y=s,this.halfWidth=i,this.halfHeight=r}clone(){return new uh(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,s){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(e-this.x)/this.halfWidth,r=(s-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(e,s,i,r=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-r),l=i-a,h=n-l,c=o-l,d=n+a,u=o+a,f=e-this.x,p=s-this.y;return f*f/(d*d)+p*p/(u*u)>1?!1:h<=0||c<=0?!0:f*f/(h*h)+p*p/(c*c)>1}getBounds(e){return e||(e=new Ee),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Cf(t){const e=t.length;if(e<6)return 1;let s=0;for(let i=0,r=t[e-2],n=t[e-1];i<e;i+=2){const o=t[i],a=t[i+1];s+=(o-r)*(a+n),r=o,n=a}return s<0?-1:1}function Lb(t,e,s,i,r,n){const o=t-s,a=e-i,l=r-s,h=n-i,c=o*l+a*h,d=l*l+h*h;let u=-1;d!==0&&(u=c/d);let f,p;u<0?(f=s,p=i):u>1?(f=r,p=n):(f=s+u*l,p=i+u*h);const _=t-f,g=e-p;return _*_+g*g}let Ib,Db;class vs{constructor(...e){this.type="polygon";let s=Array.isArray(e[0])?e[0]:e;if(typeof s[0]!="number"){const i=[];for(let r=0,n=s.length;r<n;r++)i.push(s[r].x,s[r].y);s=i}this.points=s,this.closePath=!0}isClockwise(){let e=0;const s=this.points,i=s.length;for(let r=0;r<i;r+=2){const n=s[r],o=s[r+1],a=s[(r+2)%i],l=s[(r+3)%i];e+=(a-n)*(l+o)}return e<0}containsPolygon(e){const s=this.getBounds(Ib),i=e.getBounds(Db);if(!s.containsRect(i))return!1;const r=e.points;for(let n=0;n<r.length;n+=2){const o=r[n],a=r[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const e=this.points.slice(),s=new vs(e);return s.closePath=this.closePath,s}contains(e,s){let i=!1;const r=this.points.length/2;for(let n=0,o=r-1;n<r;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>s!=c>s&&e<(h-a)*((s-l)/(c-l))+a&&(i=!i)}return i}strokeContains(e,s,i,r=.5){const{points:n}=this,o=r===.5?r:(r-.5)*Cf(n)+.5,a=i*o,l=i-a,h=a*a,c=l*l,d=n.length-(this.closePath?0:2);for(let u=0;u<d;u+=2){const f=n[u],p=n[u+1],_=n[(u+2)%n.length],g=n[(u+3)%n.length],m=Lb(e,s,f,p,_,g),y=Math.sign((_-f)*(s-p)-(g-p)*(e-f));if(m<=(y<0?h:c))return!0}return!1}getBounds(e){e||(e=new Ee);const s=this.points;let i=1/0,r=-1/0,n=1/0,o=-1/0;for(let a=0,l=s.length;a<l;a+=2){const h=s[a],c=s[a+1];i=h<i?h:i,r=h>r?h:r,n=c<n?c:n,o=c>o?c:o}return e.x=i,e.width=r-i,e.y=n,e.height=o-n,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,s)=>`${e}, ${s}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return j("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return j("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Or=(t,e,s,i,r,n,o)=>{const a=t-s,l=e-i,h=Math.sqrt(a*a+l*l);return h>=r-n&&h<=r+o};class fh{constructor(e=0,s=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=e,this.y=s,this.width=i,this.height=r,this.radius=n}getBounds(e){return e||(e=new Ee),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new fh(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}contains(e,s){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&s>=this.y&&s<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(s>=this.y+i&&s<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let r=e-(this.x+i),n=s-(this.y+i);const o=i*i;if(r*r+n*n<=o||(r=e-(this.x+this.width-i),r*r+n*n<=o)||(n=s-(this.y+this.height-i),r*r+n*n<=o)||(r=e-(this.x+i),r*r+n*n<=o))return!0}return!1}strokeContains(e,s,i,r=.5){const{x:n,y:o,width:a,height:l,radius:h}=this,c=i*(1-r),d=i-c,u=n+h,f=o+h,p=a-h*2,_=l-h*2,g=n+a,m=o+l;return(e>=n-c&&e<=n+d||e>=g-d&&e<=g+c)&&s>=f&&s<=f+_||(s>=o-c&&s<=o+d||s>=m-d&&s<=m+c)&&e>=u&&e<=u+p?!0:e<u&&s<f&&Or(e,s,u,f,h,d,c)||e>g-h&&s<f&&Or(e,s,g-h,f,h,d,c)||e>g-h&&s>m-h&&Or(e,s,g-h,m-h,h,d,c)||e<u&&s>m-h&&Or(e,s,u,m-h,h,d,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const kf={};function Ob(t,e,s){let i=2166136261;for(let r=0;r<e;r++)i^=t[r].uid,i=Math.imul(i,16777619),i>>>=0;return kf[i]||Fb(t,e,i,s)}function Fb(t,e,s,i){const r={};let n=0;for(let a=0;a<i;a++){const l=a<e?t[a]:ue.EMPTY.source;r[n++]=l.source,r[n++]=l.style}const o=new Kr(r);return kf[s]=o,o}class uc{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}function fc(t,e,s,i){if(s??(s=0),i??(i=Math.min(t.byteLength-s,e.byteLength)),!(s&7)&&!(i&7)){const r=i/8;new Float64Array(e,0,r).set(new Float64Array(t,s,r))}else if(!(s&3)&&!(i&3)){const r=i/4;new Float32Array(e,0,r).set(new Float32Array(t,s,r))}else new Uint8Array(e).set(new Uint8Array(t,s,i))}const $b={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Nb=(t=>(t[t.DISABLED=0]="DISABLED",t[t.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",t[t.MASK_ACTIVE=2]="MASK_ACTIVE",t[t.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",t[t.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",t[t.NONE=5]="NONE",t))(Nb||{});function pc(t,e){return e.alphaMode==="no-premultiply-alpha"&&$b[t]||t}const Hb=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
112
+ `);function Wb(t){let e="";for(let s=0;s<t;++s)s>0&&(e+=`
113
+ else `),s<t-1&&(e+=`if(test == ${s}.0){}`);return e}function zb(t,e){if(t===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const s=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const i=Hb.replace(/%forloop%/gi,Wb(t));if(e.shaderSource(s,i),e.compileShader(s),!e.getShaderParameter(s,e.COMPILE_STATUS))t=t/2|0;else break}}finally{e.deleteShader(s)}return t}let Zs=null;function Gb(){var e;if(Zs)return Zs;const t=Qu();return Zs=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Zs=zb(Zs,t),(e=t.getExtension("WEBGL_lose_context"))==null||e.loseContext(),Zs}class Ub{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){const s=this.textures[e];this.textures[e]=null,this.ids[s.uid]=null}this.count=0}}class qb{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Ub,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Ui=[];let un=0;cr.register({clear:()=>{if(Ui.length>0)for(const t of Ui)t&&t.destroy();Ui.length=0,un=0}});function _c(){return un>0?Ui[--un]:new qb}function mc(t){t.elements=null,Ui[un++]=t}let Li=0;const Mf=class Tf{constructor(e){this.uid=ve("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...Tf.defaultOptions,...e},e.maxTextures||(j("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=Gb());const{maxTextures:s,attributesInitialSize:i,indicesInitialSize:r}=e;this.attributeBuffer=new uc(i*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=s}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)mc(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,s){const i=e._batch.textures.ids[s._source.uid];return!i&&i!==0?!1:(e._textureId=i,e.texture=s,!0)}updateElement(e){this.dirty=!0;const s=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,s.float32View,s.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,s.float32View,s.uint32View,e._attributeStart,e._textureId)}break(e){const s=this._elements;if(!s[this.elementStart])return;let i=_c(),r=i.textures;r.clear();const n=s[this.elementStart];let o=pc(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,c=this.indexBuffer;let d=this._batchIndexSize,u=this._batchIndexStart,f="startBatch",p=[];const _=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const m=s[g];s[g]=null;const v=m.texture._source,b=pc(m.blendMode,v),S=o!==b||a!==m.topology;if(v._batchTick===Li&&!S){m._textureId=v._textureBindLocation,d+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,l,h,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,l,h,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize)),m._batch=i,p.push(m);continue}v._batchTick=Li,(r.count>=_||S)&&(this._finishBatch(i,u,d-u,r,o,a,e,f,p),f="renderBatch",u=d,o=b,a=m.topology,i=_c(),r=i.textures,r.clear(),p=[],++Li),m._textureId=v._textureBindLocation=r.count,r.ids[v.uid]=r.count,r.textures[r.count++]=v,m._batch=i,p.push(m),d+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,l,h,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,l,h,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,u,d-u,r,o,a,e,f,p),u=d,++Li),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=d}_finishBatch(e,s,i,r,n,o,a,l,h){e.gpuBindGroup=null,e.bindGroup=null,e.action=l,e.batcher=this,e.textures=r,e.blendMode=n,e.topology=o,e.start=s,e.size=i,e.elements=h,++Li,this.batches[this.batchIndex++]=e,a.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){const s=Math.max(e,this.attributeBuffer.size*2),i=new uc(s);fc(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(e){const s=this.indexBuffer;let i=Math.max(e,s.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==s.BYTES_PER_ELEMENT)for(let n=0;n<s.length;n++)r[n]=s[n];else fc(s.buffer,r.buffer);this.indexBuffer=r}packQuadIndex(e,s,i){e[s]=i+0,e[s+1]=i+1,e[s+2]=i+2,e[s+3]=i+0,e[s+4]=i+2,e[s+5]=i+3}packIndex(e,s,i,r){const n=e.indices,o=e.indexSize,a=e.indexOffset,l=e.attributeOffset;for(let h=0;h<o;h++)s[i++]=r+n[h+a]-l}destroy(e={}){var s;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)mc(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&((s=this.shader)==null||s.destroy(),this.shader=null);for(let i=0;i<this._elements.length;i++)this._elements[i]&&(this._elements[i]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};Mf.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Vb=Mf;var dt=(t=>(t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE",t[t.STATIC=1024]="STATIC",t))(dt||{});class ir extends Dt{constructor(e){let{data:s,size:i}=e;const{usage:r,label:n,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ve("buffer"),this._resourceType="buffer",this._resourceId=ve("resource"),this._updateID=1,this._updateOffset=0,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,s instanceof Array&&(s=new Float32Array(s)),this._data=s,i??(i=s==null?void 0:s.byteLength);const a=!!s;this.descriptor={size:i,usage:r,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&dt.STATIC)}set static(e){e?this.descriptor.usage|=dt.STATIC:this.descriptor.usage&=~dt.STATIC}setDataWithSize(e,s,i){if(this._updateID++,this._updateSize=s*e.BYTES_PER_ELEMENT,this._updateOffset=0,this._data===e){i&&this.emit("update",this);return}const r=this._data;if(this._data=e,this._dataInt32=null,!r||r.length!==e.length){!this.shrinkToFit&&r&&e.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=ve("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(e,s){this._updateSize=e??this._updateSize,this._updateOffset=s||0,this._updateID++,this.emit("update",this)}unload(){var e;this.emit("unload",this);for(const s in this._gpuData)(e=this._gpuData[s])==null||e.destroy();this._gpuData=Object.create(null),this.destroyed||(this._resourceId=ve("resource"),this.emit("change",this))}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Ef(t,e){if(!(t instanceof ir)){let s=e?dt.INDEX:dt.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),s=dt.INDEX|dt.COPY_DST):(t=new Float32Array(t),s=dt.VERTEX|dt.COPY_DST)),t=new ir({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:s})}return t}function Yb(t,e,s){const i=t.getAttribute(e);if(!i)return s.minX=0,s.minY=0,s.maxX=0,s.maxY=0,s;const r=i.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const h=r.BYTES_PER_ELEMENT,c=(i.offset||0)/h,d=(i.stride||8)/h;for(let u=c;u<r.length;u+=d){const f=r[u],p=r[u+1];f>a&&(a=f),p>l&&(l=p),f<n&&(n=f),p<o&&(o=p)}return s.minX=n,s.minY=o,s.maxX=a,s.maxY=l,s}function Kb(t){return(t instanceof ir||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=Ef(t.buffer,!1),t}class jb extends Dt{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ve("geometry"),this._layoutKey=0,this.instanceCount=1,this.indexCount=0,this._bounds=new Pt,this._boundsDirty=!0,this._vertexCount=0,this._vertexCountDirty=!0;const{attributes:s,indexBuffer:i,topology:r}=e;if(this.buffers=[],this.attributes={},s)for(const n in s)this.addAttribute(n,s[n]);this.instanceCount=e.instanceCount??1,this.indexCount=e.indexCount??0,i&&this.addIndex(i),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this._vertexCountDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}get vertexCount(){if(!this._vertexCountDirty)return this._vertexCount;this._vertexCountDirty=!1;const e=this.attributes;for(const s in e){const i=e[s];if(i.instance)continue;const r=i.buffer;return this._vertexCount=r.data.length/(i.stride/4||i.size),this._vertexCount}return this._vertexCount=0,0}getSize(){return j("8.20.0","Geometry.getSize is deprecated, please use Geometry.vertexCount instead."),this.vertexCount}addAttribute(e,s){const i=Kb(s);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[e]=i,this._vertexCountDirty=!0}addIndex(e){this.indexBuffer=Ef(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Yb(this,"aPosition",this._bounds)):this._bounds}unload(){var e;this.emit("unload",this);for(const s in this._gpuData)(e=this._gpuData[s])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!1){this.emit("destroy",this);for(const s of this.buffers)s.off("update",this.onBufferUpdate,this),s.off("change",this.onBufferUpdate,this),e&&s.destroy();this.unload(),this.removeAllListeners(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Xb=new Float32Array(1),Zb=new Uint32Array(1);class Jb extends jb{constructor(){const s=new ir({data:Xb,label:"attribute-batch-buffer",usage:dt.VERTEX|dt.COPY_DST,shrinkToFit:!1}),i=new ir({data:Zb,label:"index-batch-buffer",usage:dt.INDEX|dt.COPY_DST,shrinkToFit:!1}),r=24;super({attributes:{aPosition:{buffer:s,format:"float32x2",stride:r,offset:0},aUV:{buffer:s,format:"float32x2",stride:r,offset:8},aColor:{buffer:s,format:"unorm8x4",stride:r,offset:16},aTextureIdAndRound:{buffer:s,format:"uint16x2",stride:r,offset:20}},indexBuffer:i})}}function gc(t,e,s){if(t)for(const i in t){const r=i.toLocaleLowerCase(),n=e[r];if(n){let o=t[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),s&&n.push(`//----${s}----//`),n.push(o)}else $e(`${i} placement hook does not exist in shader`)}}const Qb=/\{\{(.*?)\}\}/g;function yc(t){var i;const e={};return(((i=t.match(Qb))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{e[r]=[]}),e}function vc(t,e){let s;const i=/@in\s+([^;]+);/g;for(;(s=i.exec(t))!==null;)e.push(s[1])}function bc(t,e,s=!1){const i=[];vc(e,i),t.forEach(a=>{a.header&&vc(a.header,i)});const r=i;s&&r.sort();const n=r.map((a,l)=>` @location(${l}) ${a},`).join(`
114
+ `);let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
115
+ ${n}
116
+ `),o}function wc(t,e){let s;const i=/@out\s+([^;]+);/g;for(;(s=i.exec(t))!==null;)e.push(s[1])}function e1(t){const s=/\b(\w+)\s*:/g.exec(t);return s?s[1]:""}function t1(t){const e=/@.*?\s+/g;return t.replace(e,"")}function s1(t,e){const s=[];wc(e,s),t.forEach(l=>{l.header&&wc(l.header,s)});let i=0;const r=s.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`,
117
+ `),n=s.sort().map(l=>` var ${t1(l)};`).join(`
118
+ `),o=`return VSOutput(
119
+ ${s.sort().map(l=>` ${e1(l)}`).join(`,
120
+ `)});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
121
+ ${r}
122
+ `),a=a.replace("{{start}}",`
123
+ ${n}
124
+ `),a=a.replace("{{return}}",`
125
+ ${o}
126
+ `),a}function xc(t,e){let s=t;for(const i in e){const r=e[i];r.join(`
127
+ `).length?s=s.replace(`{{${i}}}`,`//-----${i} START-----//
128
+ ${r.join(`
129
+ `)}
130
+ //----${i} FINISH----//`):s=s.replace(`{{${i}}}`,"")}return s}const _s=Object.create(null),bo=new Map;let i1=0;function r1({template:t,bits:e}){const s=Pf(t,e);if(_s[s])return _s[s];const{vertex:i,fragment:r}=o1(t,e);return _s[s]=Af(i,r,e),_s[s]}function n1({template:t,bits:e}){const s=Pf(t,e);return _s[s]||(_s[s]=Af(t.vertex,t.fragment,e)),_s[s]}function o1(t,e){const s=e.map(o=>o.vertex).filter(o=>!!o),i=e.map(o=>o.fragment).filter(o=>!!o);let r=bc(s,t.vertex,!0);r=s1(s,r);const n=bc(i,t.fragment,!0);return{vertex:r,fragment:n}}function Pf(t,e){return e.map(s=>(bo.has(s)||bo.set(s,i1++),bo.get(s))).sort((s,i)=>s-i).join("-")+t.vertex+t.fragment}function Af(t,e,s){const i=yc(t),r=yc(e);return s.forEach(n=>{gc(n.vertex,i,n.name),gc(n.fragment,r,n.name)}),{vertex:xc(t,i),fragment:xc(e,r)}}const a1=`
131
+ @in aPosition: vec2<f32>;
132
+ @in aUV: vec2<f32>;
133
+
134
+ @out @builtin(position) vPosition: vec4<f32>;
135
+ @out vUV : vec2<f32>;
136
+ @out vColor : vec4<f32>;
137
+
138
+ {{header}}
139
+
140
+ struct VSOutput {
141
+ {{struct}}
142
+ };
143
+
144
+ @vertex
145
+ fn main( {{in}} ) -> VSOutput {
146
+
147
+ var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
148
+ var modelMatrix = mat3x3<f32>(
149
+ 1.0, 0.0, 0.0,
150
+ 0.0, 1.0, 0.0,
151
+ 0.0, 0.0, 1.0
152
+ );
153
+ var position = aPosition;
154
+ var uv = aUV;
155
+
156
+ {{start}}
157
+
158
+ vColor = vec4<f32>(1., 1., 1., 1.);
159
+
160
+ {{main}}
161
+
162
+ vUV = uv;
163
+
164
+ var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
165
+
166
+ vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
167
+
168
+ vColor *= globalUniforms.uWorldColorAlpha;
169
+
170
+ {{end}}
171
+
172
+ {{return}}
173
+ };
174
+ `,h1=`
175
+ @in vUV : vec2<f32>;
176
+ @in vColor : vec4<f32>;
177
+
178
+ {{header}}
179
+
180
+ @fragment
181
+ fn main(
182
+ {{in}}
183
+ ) -> @location(0) vec4<f32> {
184
+
185
+ {{start}}
186
+
187
+ var outColor:vec4<f32>;
188
+
189
+ {{main}}
190
+
191
+ var finalColor:vec4<f32> = outColor * vColor;
192
+
193
+ {{end}}
194
+
195
+ return finalColor;
196
+ };
197
+ `,l1=`
198
+ in vec2 aPosition;
199
+ in vec2 aUV;
200
+
201
+ out vec4 vColor;
202
+ out vec2 vUV;
203
+
204
+ {{header}}
205
+
206
+ void main(void){
207
+
208
+ mat3 worldTransformMatrix = uWorldTransformMatrix;
209
+ mat3 modelMatrix = mat3(
210
+ 1.0, 0.0, 0.0,
211
+ 0.0, 1.0, 0.0,
212
+ 0.0, 0.0, 1.0
213
+ );
214
+ vec2 position = aPosition;
215
+ vec2 uv = aUV;
216
+
217
+ {{start}}
218
+
219
+ vColor = vec4(1.);
220
+
221
+ {{main}}
222
+
223
+ vUV = uv;
224
+
225
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
226
+
227
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
228
+
229
+ vColor *= uWorldColorAlpha;
230
+
231
+ {{end}}
232
+ }
233
+ `,c1=`
234
+
235
+ in vec4 vColor;
236
+ in vec2 vUV;
237
+
238
+ out vec4 finalColor;
239
+
240
+ {{header}}
241
+
242
+ void main(void) {
243
+
244
+ {{start}}
245
+
246
+ vec4 outColor;
247
+
248
+ {{main}}
249
+
250
+ finalColor = outColor * vColor;
251
+
252
+ {{end}}
253
+ }
254
+ `,d1={name:"global-uniforms-bit",vertex:{header:`
255
+ struct GlobalUniforms {
256
+ uProjectionMatrix:mat3x3<f32>,
257
+ uWorldTransformMatrix:mat3x3<f32>,
258
+ uWorldColorAlpha: vec4<f32>,
259
+ uResolution: vec2<f32>,
260
+ }
261
+
262
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
263
+ `}},u1={name:"global-uniforms-bit",vertex:{header:`
264
+ uniform mat3 uProjectionMatrix;
265
+ uniform mat3 uWorldTransformMatrix;
266
+ uniform vec4 uWorldColorAlpha;
267
+ uniform vec2 uResolution;
268
+ `}};function f1({bits:t,name:e}){const s=r1({template:{fragment:h1,vertex:a1},bits:[d1,...t]});return kn.from({name:e,vertex:{source:s.vertex,entryPoint:"main"},fragment:{source:s.fragment,entryPoint:"main"}})}function p1({bits:t,name:e}){return new tf({name:e,...n1({template:{vertex:l1,fragment:c1},bits:[u1,...t]})})}const _1={name:"color-bit",vertex:{header:`
269
+ @in aColor: vec4<f32>;
270
+ `,main:`
271
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
272
+ `}},m1={name:"color-bit",vertex:{header:`
273
+ in vec4 aColor;
274
+ `,main:`
275
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
276
+ `}},wo={};function g1(t){const e=[];if(t===1)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let s=0;for(let i=0;i<t;i++)e.push(`@group(1) @binding(${s++}) var textureSource${i+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${s++}) var textureSampler${i+1}: sampler;`)}return e.join(`
277
+ `)}function y1(t){const e=[];if(t===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let s=0;s<t;s++)s===t-1?e.push(" default:{"):e.push(` case ${s}:{`),e.push(` outColor = textureSampleGrad(textureSource${s+1}, textureSampler${s+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join(`
278
+ `)}function v1(t){return wo[t]||(wo[t]={name:"texture-batch-bit",vertex:{header:`
279
+ @in aTextureIdAndRound: vec2<u32>;
280
+ @out @interpolate(flat) vTextureId : u32;
281
+ `,main:`
282
+ vTextureId = aTextureIdAndRound.y;
283
+ `,end:`
284
+ if(aTextureIdAndRound.x == 1)
285
+ {
286
+ vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
287
+ }
288
+ `},fragment:{header:`
289
+ @in @interpolate(flat) vTextureId: u32;
290
+
291
+ ${g1(t)}
292
+ `,main:`
293
+ var uvDx = dpdx(vUV);
294
+ var uvDy = dpdy(vUV);
295
+
296
+ ${y1(t)}
297
+ `}}),wo[t]}const xo={};function b1(t){const e=[];for(let s=0;s<t;s++)s>0&&e.push("else"),s<t-1&&e.push(`if(vTextureId < ${s}.5)`),e.push("{"),e.push(` outColor = texture(uTextures[${s}], vUV);`),e.push("}");return e.join(`
298
+ `)}function w1(t){return xo[t]||(xo[t]={name:"texture-batch-bit",vertex:{header:`
299
+ in vec2 aTextureIdAndRound;
300
+ out float vTextureId;
301
+
302
+ `,main:`
303
+ vTextureId = aTextureIdAndRound.y;
304
+ `,end:`
305
+ if(aTextureIdAndRound.x == 1.)
306
+ {
307
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
308
+ }
309
+ `},fragment:{header:`
310
+ in float vTextureId;
311
+
312
+ uniform sampler2D uTextures[${t}];
313
+
314
+ `,main:`
315
+
316
+ ${b1(t)}
317
+ `}}),xo[t]}const x1={name:"round-pixels-bit",vertex:{header:`
318
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
319
+ {
320
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
321
+ }
322
+ `}},S1={name:"round-pixels-bit",vertex:{header:`
323
+ vec2 roundPixels(vec2 position, vec2 targetSize)
324
+ {
325
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
326
+ }
327
+ `}},Sc={};function C1(t){let e=Sc[t];if(e)return e;const s=new Int32Array(t);for(let i=0;i<t;i++)s[i]=i;return e=Sc[t]=new of({uTextures:{value:s,type:"i32",size:t}},{isStatic:!0}),e}class Cc extends ch{constructor(e){const s=p1({name:"batch",bits:[m1,w1(e),S1]}),i=f1({name:"batch",bits:[_1,v1(e),x1]});super({glProgram:s,gpuProgram:i,resources:{batchSamplers:C1(e)}}),this.maxTextures=e}}let Ii=null;const Rf=class Bf extends Vb{constructor(e){super(e),this.geometry=new Jb,this.name=Bf.extension.name,this.vertexSize=6,Ii??(Ii=new Cc(e.maxTextures)),this.shader=Ii}packAttributes(e,s,i,r,n){const o=n<<16|e.roundPixels&65535,a=e.transform,l=a.a,h=a.b,c=a.c,d=a.d,u=a.tx,f=a.ty,{positions:p,uvs:_}=e,g=e.color,m=e.attributeOffset,y=m+e.attributeSize;for(let v=m;v<y;v++){const b=v*2,S=p[b],x=p[b+1];s[r++]=l*S+c*x+u,s[r++]=d*x+h*S+f,s[r++]=_[b],s[r++]=_[b+1],i[r++]=g,i[r++]=o}}packQuadAttributes(e,s,i,r,n){const o=e.texture,a=e.transform,l=a.a,h=a.b,c=a.c,d=a.d,u=a.tx,f=a.ty,p=e.bounds,_=p.maxX,g=p.minX,m=p.maxY,y=p.minY,v=o.uvs,b=e.color,S=n<<16|e.roundPixels&65535;s[r+0]=l*g+c*y+u,s[r+1]=d*y+h*g+f,s[r+2]=v.x0,s[r+3]=v.y0,i[r+4]=b,i[r+5]=S,s[r+6]=l*_+c*y+u,s[r+7]=d*y+h*_+f,s[r+8]=v.x1,s[r+9]=v.y1,i[r+10]=b,i[r+11]=S,s[r+12]=l*_+c*m+u,s[r+13]=d*m+h*_+f,s[r+14]=v.x2,s[r+15]=v.y2,i[r+16]=b,i[r+17]=S,s[r+18]=l*g+c*m+u,s[r+19]=d*m+h*g+f,s[r+20]=v.x3,s[r+21]=v.y3,i[r+22]=b,i[r+23]=S}_updateMaxTextures(e){this.shader.maxTextures!==e&&(Ii=new Cc(e),this.shader=Ii)}destroy(){this.shader=null,super.destroy()}};Rf.extension={type:[X.Batcher],name:"default"};let k1=Rf;class dr{constructor(e){this.items=Object.create(null);const{renderer:s,type:i,onUnload:r,priority:n,name:o}=e;this._renderer=s,s.gc.addResourceHash(this,"items",i,n??0),this._onUnload=r,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...s){var r;if(!this.items[e.uid])return;const i=e._gpuData[this._renderer.uid];i&&((r=this._onUnload)==null||r.call(this,e,...s),e.off("unload",this.remove,this),i.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(s=>s&&this.remove(s,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function M1(t,e,s,i,r,n,o,a=null){let l=0;s*=e,r*=n;const h=a.a,c=a.b,d=a.c,u=a.d,f=a.tx,p=a.ty;for(;l<o;){const _=t[s],g=t[s+1];i[r]=h*_+d*g+f,i[r+1]=c*_+u*g+p,r+=n,s+=e,l++}}function T1(t,e,s,i){let r=0;for(e*=s;r<i;)t[e]=0,t[e+1]=0,e+=s,r++}function Lf(t,e,s,i,r){const n=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;s||(s=0),i||(i=2),r||(r=t.length/i-s);let d=s*i;for(let u=0;u<r;u++){const f=t[d],p=t[d+1];t[d]=n*f+a*p+h,t[d+1]=o*f+l*p+c,d+=i}}const E1=new re;class ph{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const e=this.baseColor,s=e>>16|e&65280|(e&255)<<16,i=this.renderable;return i?Lu(s,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):s+(this.alpha*255<<24)}get transform(){var e;return((e=this.renderable)==null?void 0:e.groupTransform)||E1}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const rr={extension:{type:X.ShapeBuilder,name:"circle"},build(t,e){let s,i,r,n,o,a;if(t.type==="circle"){const b=t;if(o=a=b.radius,o<=0)return!1;s=b.x,i=b.y,r=n=0}else if(t.type==="ellipse"){const b=t;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;s=b.x,i=b.y,r=n=0}else{const b=t,S=b.width/2,x=b.height/2;s=b.x+S,i=b.y+x,o=a=Math.max(0,Math.min(b.radius,Math.min(S,x))),r=S-o,n=x-a}if(r<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(r?4:0)+(n?4:0);if(h===0)return!1;if(l===0)return e[0]=e[6]=s+r,e[1]=e[3]=i+n,e[2]=e[4]=s-r,e[5]=e[7]=i-n,!0;let c=0,d=l*4+(r?2:0)+2,u=d,f=h,p=r+o,_=n,g=s+p,m=s-p,y=i+_;if(e[c++]=g,e[c++]=y,e[--d]=y,e[--d]=m,n){const b=i-_;e[u++]=m,e[u++]=b,e[--f]=b,e[--f]=g}for(let b=1;b<l;b++){const S=Math.PI/2*(b/l),x=r+Math.cos(S)*o,M=n+Math.sin(S)*a,O=s+x,B=s-x,I=i+M,L=i-M;e[c++]=O,e[c++]=I,e[--d]=I,e[--d]=B,e[u++]=B,e[u++]=L,e[--f]=L,e[--f]=O}p=r,_=n+a,g=s+p,m=s-p,y=i+_;const v=i-_;return e[c++]=g,e[c++]=y,e[--f]=v,e[--f]=g,r&&(e[c++]=m,e[c++]=y,e[--f]=v,e[--f]=m),!0},triangulate(t,e,s,i,r,n){if(t.length===0)return;let o=0,a=0;for(let c=0;c<t.length;c+=2)o+=t[c],a+=t[c+1];o/=t.length/2,a/=t.length/2;let l=i;e[l*s]=o,e[l*s+1]=a;const h=l++;for(let c=0;c<t.length;c+=2)e[l*s]=t[c],e[l*s+1]=t[c+1],c>0&&(r[n++]=l,r[n++]=h,r[n++]=l-1),l++;r[n++]=h+1,r[n++]=h,r[n++]=l-1}},P1={...rr,extension:{...rr.extension,name:"ellipse"}},A1={...rr,extension:{...rr.extension,name:"roundedRectangle"}},If=1e-4,kc=1e-4;function Mc(t,e,s,i,r,n,o,a){const l=t-s*r,h=e-i*r,c=t+s*n,d=e+i*n;let u,f;o?(u=i,f=-s):(u=-i,f=s);const p=l+u,_=h+f,g=c+u,m=d+f;return a.push(p,_),a.push(g,m),2}function Ms(t,e,s,i,r,n,o,a){const l=s-t,h=i-e;let c=Math.atan2(l,h),d=Math.atan2(r-t,n-e);a&&c<d?c+=Math.PI*2:!a&&c>d&&(d+=Math.PI*2);let u=c;const f=d-c,p=Math.abs(f),_=Math.sqrt(l*l+h*h),g=(15*p*Math.sqrt(_)/Math.PI>>0)+1,m=f/g;if(u+=m,a){o.push(t,e),o.push(s,i);for(let y=1,v=u;y<g;y++,v+=m)o.push(t,e),o.push(t+Math.sin(v)*_,e+Math.cos(v)*_);o.push(t,e),o.push(r,n)}else{o.push(s,i),o.push(t,e);for(let y=1,v=u;y<g;y++,v+=m)o.push(t+Math.sin(v)*_,e+Math.cos(v)*_),o.push(t,e);o.push(r,n),o.push(t,e)}return g*2}function R1(t,e,s,i,r,n){const o=If;if(t.length===0)return;const a=e;let l=a.alignment;if(e.alignment!==.5){let D=Cf(t);l=(l-.5)*D+.5}const h=new nt(t[0],t[1]),c=new nt(t[t.length-2],t[t.length-1]),d=i,u=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(d){t=t.slice(),u&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const D=(h.x+c.x)*.5,G=(c.y+h.y)*.5;t.unshift(D,G),t.push(D,G)}const f=r,p=t.length/2;let _=t.length;const g=f.length/2,m=a.width/2,y=m*m,v=a.miterLimit*a.miterLimit;let b=t[0],S=t[1],x=t[2],M=t[3],O=0,B=0,I=-(S-M),L=b-x,C=0,k=0,P=Math.sqrt(I*I+L*L);I/=P,L/=P,I*=m,L*=m;const $=l,T=(1-$)*2,R=$*2;d||(a.cap==="round"?_+=Ms(b-I*(T-R)*.5,S-L*(T-R)*.5,b-I*T,S-L*T,b+I*R,S+L*R,f,!0)+2:a.cap==="square"&&(_+=Mc(b,S,I,L,T,R,!0,f))),f.push(b-I*T,S-L*T),f.push(b+I*R,S+L*R);for(let D=1;D<p-1;++D){b=t[(D-1)*2],S=t[(D-1)*2+1],x=t[D*2],M=t[D*2+1],O=t[(D+1)*2],B=t[(D+1)*2+1],I=-(S-M),L=b-x,P=Math.sqrt(I*I+L*L),I/=P,L/=P,I*=m,L*=m,C=-(M-B),k=x-O,P=Math.sqrt(C*C+k*k),C/=P,k/=P,C*=m,k*=m;const G=x-b,Q=S-M,U=x-O,te=B-M,ae=G*U+Q*te,fe=Q*U-te*G,de=fe<0;if(Math.abs(fe)<.001*Math.abs(ae)){f.push(x-I*T,M-L*T),f.push(x+I*R,M+L*R),ae>=0&&(a.join==="round"?_+=Ms(x,M,x-I*T,M-L*T,x-C*T,M-k*T,f,!1)+4:_+=2,f.push(x-C*R,M-k*R),f.push(x+C*T,M+k*T));continue}const z=(-I+b)*(-L+M)-(-I+x)*(-L+S),K=(-C+O)*(-k+M)-(-C+x)*(-k+B),he=(G*K-U*z)/fe,Be=(te*z-Q*K)/fe,_e=(he-x)*(he-x)+(Be-M)*(Be-M),ne=x+(he-x)*T,q=M+(Be-M)*T,me=x-(he-x)*R,Le=M-(Be-M)*R,ws=Math.min(G*G+Q*Q,U*U+te*te),xs=de?T:R,Vs=ws+xs*xs*y;_e<=Vs?a.join==="bevel"||_e/y>v?(de?(f.push(ne,q),f.push(x+I*R,M+L*R),f.push(ne,q),f.push(x+C*R,M+k*R)):(f.push(x-I*T,M-L*T),f.push(me,Le),f.push(x-C*T,M-k*T),f.push(me,Le)),_+=2):a.join==="round"?de?(f.push(ne,q),f.push(x+I*R,M+L*R),_+=Ms(x,M,x+I*R,M+L*R,x+C*R,M+k*R,f,!0)+4,f.push(ne,q),f.push(x+C*R,M+k*R)):(f.push(x-I*T,M-L*T),f.push(me,Le),_+=Ms(x,M,x-I*T,M-L*T,x-C*T,M-k*T,f,!1)+4,f.push(x-C*T,M-k*T),f.push(me,Le)):(f.push(ne,q),f.push(me,Le)):(f.push(x-I*T,M-L*T),f.push(x+I*R,M+L*R),a.join==="round"?de?_+=Ms(x,M,x+I*R,M+L*R,x+C*R,M+k*R,f,!0)+2:_+=Ms(x,M,x-I*T,M-L*T,x-C*T,M-k*T,f,!1)+2:a.join==="miter"&&_e/y<=v&&(de?(f.push(me,Le),f.push(me,Le)):(f.push(ne,q),f.push(ne,q)),_+=2),f.push(x-C*T,M-k*T),f.push(x+C*R,M+k*R),_+=2)}b=t[(p-2)*2],S=t[(p-2)*2+1],x=t[(p-1)*2],M=t[(p-1)*2+1],I=-(S-M),L=b-x,P=Math.sqrt(I*I+L*L),I/=P,L/=P,I*=m,L*=m,f.push(x-I*T,M-L*T),f.push(x+I*R,M+L*R),d||(a.cap==="round"?_+=Ms(x-I*(T-R)*.5,M-L*(T-R)*.5,x-I*T,M-L*T,x+I*R,M+L*R,f,!1)+2:a.cap==="square"&&(_+=Mc(x,M,I,L,T,R,!1,f)));const F=kc*kc;for(let D=g;D<_+g-2;++D)b=f[D*2],S=f[D*2+1],x=f[(D+1)*2],M=f[(D+1)*2+1],O=f[(D+2)*2],B=f[(D+2)*2+1],!(Math.abs(b*(M-B)+x*(B-S)+O*(S-M))<F)&&n.push(D,D+1,D+2)}function B1(t,e,s,i){const r=If;if(t.length===0)return;const n=t[0],o=t[1],a=t[t.length-2],l=t[t.length-1],h=e||Math.abs(n-a)<r&&Math.abs(o-l)<r,c=s,d=t.length/2,u=c.length/2;for(let f=0;f<d;f++)c.push(t[f*2]),c.push(t[f*2+1]);for(let f=0;f<d-1;f++)i.push(u+f,u+f+1);h&&i.push(u+d-1,u)}function Df(t,e,s,i,r,n,o){const a=wb(t,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)n[o++]=a[h]+r,n[o++]=a[h+1]+r,n[o++]=a[h+2]+r;let l=r*i;for(let h=0;h<t.length;h+=2)s[l]=t[h],s[l+1]=t[h+1],l+=i}const L1=[],I1={extension:{type:X.ShapeBuilder,name:"polygon"},build(t,e){for(let s=0;s<t.points.length;s++)e[s]=t.points[s];return!0},triangulate(t,e,s,i,r,n){Df(t,L1,e,s,i,r,n)}},D1={extension:{type:X.ShapeBuilder,name:"rectangle"},build(t,e){const s=t,i=s.x,r=s.y,n=s.width,o=s.height;return n>0&&o>0?(e[0]=i,e[1]=r,e[2]=i+n,e[3]=r,e[4]=i+n,e[5]=r+o,e[6]=i,e[7]=r+o,!0):!1},triangulate(t,e,s,i,r,n){let o=0;i*=s,e[i+o]=t[0],e[i+o+1]=t[1],o+=s,e[i+o]=t[2],e[i+o+1]=t[3],o+=s,e[i+o]=t[6],e[i+o+1]=t[7],o+=s,e[i+o]=t[4],e[i+o+1]=t[5],o+=s;const a=i/s;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},O1={extension:{type:X.ShapeBuilder,name:"triangle"},build(t,e){return e[0]=t.x,e[1]=t.y,e[2]=t.x2,e[3]=t.y2,e[4]=t.x3,e[5]=t.y3,!0},triangulate(t,e,s,i,r,n){let o=0;i*=s,e[i+o]=t[0],e[i+o+1]=t[1],o+=s,e[i+o]=t[2],e[i+o+1]=t[3],o+=s,e[i+o]=t[4],e[i+o+1]=t[5];const a=i/s;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},Tc=[{offset:0,color:"white"},{offset:1,color:"black"}],_h=class Ba{constructor(...e){this.uid=ve("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let s=F1(e);s={...s.type==="radial"?Ba.defaultRadialOptions:Ba.defaultLinearOptions,...xu(s)},this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,s.type==="radial"?(this.center=s.center,this.outerCenter=s.outerCenter??this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color)})}addColorStop(e,s){return this.colorStops.push({offset:e,color:Ce.shared.setValue(s).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:s}=this.start,{x:i,y:r}=this.end,n=i-e,o=r-s;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=e;e=i,i=g,n*=-1}if(o<0){const g=s;s=r,r=g,o*=-1}}const l=this.colorStops.length?this.colorStops:Tc,h=this._textureSize,{canvas:c,context:d}=Pc(h,1),u=a?d.createLinearGradient(this._textureSize,0,0,0):d.createLinearGradient(0,0,this._textureSize,0);Ec(u,l),d.fillStyle=u,d.fillRect(0,0,h,1),this.texture=new ue({source:new an({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),_=new re;_.scale(f/h,1),_.rotate(p),_.translate(e,s),this.textureSpace==="local"&&_.scale(h,h),this.transform=_}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:Tc,s=this._textureSize,{canvas:i,context:r}=Pc(s,s),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,h=this.innerRadius,c=this.outerRadius,d=a-c,u=l-c,f=s/(c*2),p=(n-d)*f,_=(o-u)*f,g=r.createRadialGradient(p,_,h*f,(a-d)*f,(l-u)*f,c*f);Ec(g,e),r.fillStyle=e[e.length-1].color,r.fillRect(0,0,s,s),r.fillStyle=g,r.translate(p,_),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-p,-_),r.fillRect(0,0,s,s),this.texture=new ue({source:new an({resource:i,addressMode:this._wrapMode})});const m=new re;this.textureSpace==="local"?m.scale(2*c,2*c):m.scale(1/f,1/f),m.translate(d,u),this.transform=m}destroy(){var e;(e=this.texture)==null||e.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};_h.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};_h.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let ss=_h;function Ec(t,e){for(let s=0;s<e.length;s++){const i=e[s];t.addColorStop(i.offset,i.color)}}function Pc(t,e){const s=Oe.get().createCanvas(t,e),i=s.getContext("2d");return{canvas:s,context:i}}function F1(t){let e=t[0]??{};return(typeof e=="number"||t[1])&&(j("8.5.2","use options object instead"),e={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:t[5]??ss.defaultLinearOptions.textureSize}),e}const $1=new re,N1=new Ee,H1=new re;function W1(t,e,s,i){const r=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if(e.textureSpace==="local"){const o=s.getBounds(N1);e.width&&o.pad(e.width);const{x:a,y:l}=o,h=1/o.width,c=1/o.height,d=-a*h,u=-l*c,f=r.a,p=r.b,_=r.c,g=r.d;r.a*=h,r.b*=h,r.c*=c,r.d*=c,r.tx=d*f+u*_+r.tx,r.ty=d*p+u*g+r.ty}else if(e.texture.rotate){const{uvs:o,orig:a}=e.texture;r.scale(1/a.width,1/a.height),r.prepend(H1.set(o.x1-o.x0,o.y1-o.y0,o.x3-o.x0,o.y3-o.y0,o.x0,o.y0))}else r.translate(e.texture.frame.x,e.texture.frame.y),r.scale(1/e.texture.source.width,1/e.texture.source.height);const n=e.texture.source.style;return!(e.fill instanceof ss)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&r.append($1.copyFrom(i).invert()),r}const Mn={};Re.handleByMap(X.ShapeBuilder,Mn);Re.add(D1,I1,O1,rr,P1,A1);const z1=new Ee,G1=new re;function U1(t,e){const{geometryData:s,batches:i}=e;i.length=0,s.indices.length=0,s.vertices.length=0,s.uvs.length=0;for(let r=0;r<t.instructions.length;r++){const n=t.instructions[r];if(n.action==="texture")q1(n.data,i,s);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,h=n.data.hole;o&&h&&Ac(h.shapePath,l,!0,i,s),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),Ac(a,l,o,i,s)}}}function q1(t,e,s){const i=[],r=Mn.rectangle,n=z1;n.x=t.dx,n.y=t.dy,n.width=t.dw,n.height=t.dh;const o=t.transform;if(!r.build(n,i))return;const{vertices:a,uvs:l,indices:h}=s,c=h.length,d=a.length/2;o&&Lf(i,o),r.triangulate(i,a,2,d,h,c);const u=t.image,f=u.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=ft.get(ph);p.indexOffset=c,p.indexSize=h.length-c,p.attributeOffset=d,p.attributeSize=a.length/2-d,p.baseColor=t.style,p.alpha=t.alpha,p.texture=u,p.geometryData=s,e.push(p)}function Ac(t,e,s,i,r){const{vertices:n,uvs:o,indices:a}=r;t.shapePrimitives.forEach(({shape:l,transform:h,holes:c})=>{const d=[],u=Mn[l.type];if(!u.build(l,d))return;const f=a.length,p=n.length/2;let _="triangle-list";if(h&&Lf(d,h),s){const v=l.closePath??!0,b=e;b.pixelLine?(B1(d,v,n,a),_="line-list"):R1(d,b,!1,v,n,a)}else if(c){const v=[],b=d.slice();V1(c).forEach(x=>{v.push(b.length/2),b.push(...x)}),Df(b,v,n,2,p,a,f)}else u.triangulate(d,n,2,p,a,f);const g=o.length/2,m=e.texture;if(m!==ue.WHITE){const v=W1(G1,e,l,h);M1(n,2,p,o,g,2,n.length/2-p,v)}else T1(o,g,2,n.length/2-p);const y=ft.get(ph);y.indexOffset=f,y.indexSize=a.length-f,y.attributeOffset=p,y.attributeSize=n.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=m,y.geometryData=r,y.topology=_,i.push(y)})}function V1(t){const e=[];for(let s=0;s<t.length;s++){const i=t[s].shape,r=[];Mn[i.type].build(i,r)&&e.push(r)}return e}class Y1{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{ft.return(e)}),this.graphicsData&&ft.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class K1{constructor(){this.instructions=new hh}init(e){const s=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(s):this.batcher=new k1({maxTextures:s}),this.instructions.reset()}get geometry(){return j(Dy,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const mh=class La{constructor(e){this._renderer=e,this._managedContexts=new dr({renderer:e,type:"resource",name:"graphicsContext"})}init(e){La.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??La.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const s=!!e._gpuData[this._renderer.uid],i=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!s){s&&i.reset(),U1(e,i);const r=e.batchMode;e.customShader||r==="no-batch"?i.isBatchable=!1:r==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,e.dirty=!1}return i}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const s=ft.get(K1,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=e._gpuData[this._renderer.uid],{batches:r,geometryData:n}=i;i.graphicsData=s;const o=n.vertices.length,a=n.indices.length;for(let d=0;d<r.length;d++)r[d].applyTransform=!1;const l=s.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let d=0;d<r.length;d++){const u=r[d];l.add(u)}l.finish(s.instructions);const h=l.geometry;h.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),h.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);const c=l.batches;for(let d=0;d<l.batchIndex;d++){const u=c[d];u.bindGroup=Ob(u.textures.textures,u.textures.count,this._renderer.limits.maxBatchableTextures)}return s}_initContext(e){const s=new Y1;return s.context=e,e._gpuData[this._renderer.uid]=s,this._managedContexts.add(e),s}destroy(){this._managedContexts.destroy(),this._renderer=null}};mh.extension={type:[X.WebGLSystem,X.WebGPUSystem],name:"graphicsContext"};mh.defaultOptions={bezierSmoothness:.5};let gh=mh;const j1=8,Fr=11920929e-14,X1=1;function Of(t,e,s,i,r,n,o,a,l,h){const d=Math.min(.99,Math.max(0,h??gh.defaultOptions.bezierSmoothness));let u=(X1-d)/1;return u*=u,Z1(e,s,i,r,n,o,a,l,t,u),t}function Z1(t,e,s,i,r,n,o,a,l,h){Ia(t,e,s,i,r,n,o,a,l,h,0),l.push(o,a)}function Ia(t,e,s,i,r,n,o,a,l,h,c){if(c>j1)return;const d=(t+s)/2,u=(e+i)/2,f=(s+r)/2,p=(i+n)/2,_=(r+o)/2,g=(n+a)/2,m=(d+f)/2,y=(u+p)/2,v=(f+_)/2,b=(p+g)/2,S=(m+v)/2,x=(y+b)/2;if(c>0){let M=o-t,O=a-e;const B=Math.abs((s-o)*O-(i-a)*M),I=Math.abs((r-o)*O-(n-a)*M);if(B>Fr&&I>Fr){if((B+I)*(B+I)<=h*(M*M+O*O)){l.push(S,x);return}}else if(B>Fr){if(B*B<=h*(M*M+O*O)){l.push(S,x);return}}else if(I>Fr){if(I*I<=h*(M*M+O*O)){l.push(S,x);return}}else if(M=S-(t+o)/2,O=x-(e+a)/2,M*M+O*O<=h){l.push(S,x);return}}Ia(t,e,d,u,m,y,S,x,l,h,c+1),Ia(S,x,v,b,_,g,o,a,l,h,c+1)}const J1=8,Q1=11920929e-14,ew=1;function tw(t,e,s,i,r,n,o,a){const h=Math.min(.99,Math.max(0,a??gh.defaultOptions.bezierSmoothness));let c=(ew-h)/1;return c*=c,sw(e,s,i,r,n,o,t,c),t}function sw(t,e,s,i,r,n,o,a){Da(o,t,e,s,i,r,n,a,0),o.push(r,n)}function Da(t,e,s,i,r,n,o,a,l){if(l>J1)return;const h=(e+i)/2,c=(s+r)/2,d=(i+n)/2,u=(r+o)/2,f=(h+d)/2,p=(c+u)/2;let _=n-e,g=o-s;const m=Math.abs((i-n)*g-(r-o)*_);if(m>Q1){if(m*m<=a*(_*_+g*g)){t.push(f,p);return}}else if(_=f-(e+n)/2,g=p-(s+o)/2,_*_+g*g<=a){t.push(f,p);return}Da(t,e,s,h,c,f,p,a,l+1),Da(t,f,p,d,u,n,o,a,l+1)}function Ff(t,e,s,i,r,n,o,a){let l=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(i,1/3)*(l/Math.PI)))),a=Math.max(a,3);let h=l/a,c=r;h*=o?-1:1;for(let d=0;d<a+1;d++){const u=Math.cos(c),f=Math.sin(c),p=e+u*i,_=s+f*i;t.push(p,_),c+=h}}function iw(t,e,s,i,r,n){const o=t[t.length-2],l=t[t.length-1]-s,h=o-e,c=r-s,d=i-e,u=Math.abs(l*d-h*c);if(u<1e-8||n===0){(t[t.length-2]!==e||t[t.length-1]!==s)&&t.push(e,s);return}const f=l*l+h*h,p=c*c+d*d,_=l*c+h*d,g=n*Math.sqrt(f)/u,m=n*Math.sqrt(p)/u,y=g*_/f,v=m*_/p,b=g*d+m*h,S=g*c+m*l,x=h*(m+y),M=l*(m+y),O=d*(g+v),B=c*(g+v),I=Math.atan2(M-S,x-b),L=Math.atan2(B-S,O-b);Ff(t,b+e,S+s,n,I,L,h*c>d*l)}const qi=Math.PI*2,So={centerX:0,centerY:0,ang1:0,ang2:0},Co=({x:t,y:e},s,i,r,n,o,a,l)=>{t*=s,e*=i;const h=r*t-n*e,c=n*t+r*e;return l.x=h+o,l.y=c+a,l};function rw(t,e){const s=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),i=e===1.5707963267948966?.551915024494:s,r=Math.cos(t),n=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-n*i,y:n+r*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Rc=(t,e,s,i)=>{const r=t*i-e*s<0?-1:1;let n=t*s+e*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},nw=(t,e,s,i,r,n,o,a,l,h,c,d,u)=>{const f=Math.pow(r,2),p=Math.pow(n,2),_=Math.pow(c,2),g=Math.pow(d,2);let m=f*p-f*g-p*_;m<0&&(m=0),m/=f*g+p*_,m=Math.sqrt(m)*(o===a?-1:1);const y=m*r/n*d,v=m*-n/r*c,b=h*y-l*v+(t+s)/2,S=l*y+h*v+(e+i)/2,x=(c-y)/r,M=(d-v)/n,O=(-c-y)/r,B=(-d-v)/n,I=Rc(1,0,x,M);let L=Rc(x,M,O,B);a===0&&L>0&&(L-=qi),a===1&&L<0&&(L+=qi),u.centerX=b,u.centerY=S,u.ang1=I,u.ang2=L};function ow(t,e,s,i,r,n,o,a=0,l=0,h=0){if(n===0||o===0)return;const c=Math.sin(a*qi/360),d=Math.cos(a*qi/360),u=d*(e-i)/2+c*(s-r)/2,f=-c*(e-i)/2+d*(s-r)/2;if(u===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const p=Math.pow(u,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);p>1&&(n*=Math.sqrt(p),o*=Math.sqrt(p)),nw(e,s,i,r,n,o,l,h,c,d,u,f,So);let{ang1:_,ang2:g}=So;const{centerX:m,centerY:y}=So;let v=Math.abs(g)/(qi/4);Math.abs(1-v)<1e-7&&(v=1);const b=Math.max(Math.ceil(v),1);g/=b;let S=t[t.length-2],x=t[t.length-1];const M={x:0,y:0};for(let O=0;O<b;O++){const B=rw(_,g),{x:I,y:L}=Co(B[0],n,o,d,c,m,y,M),{x:C,y:k}=Co(B[1],n,o,d,c,m,y,M),{x:P,y:$}=Co(B[2],n,o,d,c,m,y,M);Of(t,S,x,I,L,C,k,P,$),S=P,x=$,_+=g}}function aw(t,e,s){const i=(o,a)=>{const l=a.x-o.x,h=a.y-o.y,c=Math.sqrt(l*l+h*h),d=l/c,u=h/c;return{len:c,nx:d,ny:u}},r=(o,a)=>{o===0?t.moveTo(a.x,a.y):t.lineTo(a.x,a.y)};let n=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],l=a.radius??s;if(l<=0){r(o,a),n=a;continue}const h=e[(o+1)%e.length],c=i(a,n),d=i(a,h);if(c.len<1e-4||d.len<1e-4){r(o,a),n=a;continue}let u=Math.asin(c.nx*d.ny-c.ny*d.nx),f=1,p=!1;c.nx*d.nx-c.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,f=-1,p=!0):u>0&&(f=-1,p=!0);const _=u/2;let g,m=Math.abs(Math.cos(_)*l/Math.sin(_));m>Math.min(c.len/2,d.len/2)?(m=Math.min(c.len/2,d.len/2),g=Math.abs(m*Math.sin(_)/Math.cos(_))):g=l;const y=a.x+d.nx*m+-d.ny*g*f,v=a.y+d.ny*m+d.nx*g*f,b=Math.atan2(c.ny,c.nx)+Math.PI/2*f,S=Math.atan2(d.ny,d.nx)-Math.PI/2*f;o===0&&t.moveTo(y+Math.cos(b)*g,v+Math.sin(b)*g),t.arc(y,v,g,b,S,p),n=a}}function hw(t,e,s,i){const r=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),n=(a,l,h)=>({x:a.x+(l.x-a.x)*h,y:a.y+(l.y-a.y)*h}),o=e.length;for(let a=0;a<o;a++){const l=e[(a+1)%o],h=l.radius??s;if(h<=0){a===0?t.moveTo(l.x,l.y):t.lineTo(l.x,l.y);continue}const c=e[a],d=e[(a+2)%o],u=r(c,l);let f;if(u<1e-4)f=l;else{const g=Math.min(u/2,h);f=n(l,c,g/u)}const p=r(d,l);let _;if(p<1e-4)_=l;else{const g=Math.min(p/2,h);_=n(l,d,g/p)}a===0?t.moveTo(f.x,f.y):t.lineTo(f.x,f.y),t.quadraticCurveTo(l.x,l.y,_.x,_.y,i)}}const lw=new Ee;class cw{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Pt,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,s){return this.startPoly(e,s),this}lineTo(e,s){this._ensurePoly();const i=this._currentPoly.points,r=i[i.length-2],n=i[i.length-1];return(r!==e||n!==s)&&i.push(e,s),this}arc(e,s,i,r,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Ff(a,e,s,i,r,n,o),this}arcTo(e,s,i,r,n){this._ensurePoly();const o=this._currentPoly.points;return iw(o,e,s,i,r,n),this}arcToSvg(e,s,i,r,n,o,a){const l=this._currentPoly.points;return ow(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,s,i,r,n),this}bezierCurveTo(e,s,i,r,n,o,a){this._ensurePoly();const l=this._currentPoly;return Of(this._currentPoly.points,l.lastX,l.lastY,e,s,i,r,n,o,a),this}quadraticCurveTo(e,s,i,r,n){this._ensurePoly();const o=this._currentPoly;return tw(this._currentPoly.points,o.lastX,o.lastY,e,s,i,r,n),this}closePath(){return this.endPoly(!0),this}addPath(e,s){this.endPoly(),s&&!s.isIdentity()&&(e=e.clone(!0),e.transform(s));const i=this.shapePrimitives,r=i.length;for(let n=0;n<e.instructions.length;n++){const o=e.instructions[n];this[o.action](...o.data)}if(e.checkForHoles&&i.length-r>1){let n=null;for(let o=r;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const l=a.shape,h=n==null?void 0:n.shape;h&&h.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,s,i,r,n){return this.drawShape(new Ee(e,s,i,r),n),this}circle(e,s,i,r){return this.drawShape(new dh(e,s,i),r),this}poly(e,s,i){const r=new vs(e);return r.closePath=s,this.drawShape(r,i),this}regularPoly(e,s,i,r,n=0,o){r=Math.max(r|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/r,h=[];for(let c=0;c<r;c++){const d=a-c*l;h.push(e+i*Math.cos(d),s+i*Math.sin(d))}return this.poly(h,!0,o),this}roundPoly(e,s,i,r,n,o=0,a){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(e,s,i,r,o);const l=i*Math.sin(Math.PI/r)-.001;n=Math.min(n,l);const h=-1*Math.PI/2+o,c=Math.PI*2/r,d=(r-2)*Math.PI/r/2;for(let u=0;u<r;u++){const f=u*c+h,p=e+i*Math.cos(f),_=s+i*Math.sin(f),g=f+Math.PI+d,m=f-Math.PI-d,y=p+n*Math.cos(g),v=_+n*Math.sin(g),b=p+n*Math.cos(m),S=_+n*Math.sin(m);u===0?this.moveTo(y,v):this.lineTo(y,v),this.quadraticCurveTo(p,_,b,S,a)}return this.closePath()}roundShape(e,s,i=!1,r){return e.length<3?this:(i?hw(this,e,s,r):aw(this,e,s),this.closePath())}filletRect(e,s,i,r,n){if(n===0)return this.rect(e,s,i,r);const o=Math.min(i,r)/2,a=Math.min(o,Math.max(-o,n)),l=e+i,h=s+r,c=a<0?-a:0,d=Math.abs(a);return this.moveTo(e,s+d).arcTo(e+c,s+c,e+d,s,d).lineTo(l-d,s).arcTo(l-c,s+c,l,s+d,d).lineTo(l,h-d).arcTo(l-c,h-c,e+i-d,h,d).lineTo(e+d,h).arcTo(e+c,h-c,e,h-d,d).closePath()}chamferRect(e,s,i,r,n,o){if(n<=0)return this.rect(e,s,i,r);const a=Math.min(n,Math.min(i,r)/2),l=e+i,h=s+r,c=[e+a,s,l-a,s,l,s+a,l,h-a,l-a,h,e+a,h,e,h-a,e,s+a];for(let d=c.length-1;d>=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,o)}ellipse(e,s,i,r,n){return this.drawShape(new uh(e,s,i,r),n),this}roundRect(e,s,i,r,n,o){return this.drawShape(new fh(e,s,i,r,n),o),this}drawShape(e,s){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:s}),this}startPoly(e,s){let i=this._currentPoly;return i&&this.endPoly(),i=new vs,i.points.push(e,s),this._currentPoly=i,this}endPoly(e=!1){const s=this._currentPoly;return s&&s.points.length>2&&(s.closePath=e,this.shapePrimitives.push({shape:s})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new vs,e)){const s=this.shapePrimitives[this.shapePrimitives.length-1];if(s){let i=s.shape.x,r=s.shape.y;if(s.transform&&!s.transform.isIdentity()){const n=s.transform,o=i;i=n.a*i+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty}this._currentPoly.points.push(i,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let s=0;s<e.instructions.length;s++){const i=e.instructions[s];this[i.action](...i.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const s=this.shapePrimitives;for(let i=0;i<s.length;i++){const r=s[i],n=r.shape.getBounds(lw);r.transform?e.addRect(n,r.transform):e.addRect(n)}return e}}class ts{constructor(e,s=!1){this.instructions=[],this.uid=ve("graphicsPath"),this._dirty=!0,this.checkForHoles=s,typeof e=="string"?Bb(e,this):this.instructions=(e==null?void 0:e.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new cw(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,s){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,s]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,s,i,r,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(nt.shared);let l=0,h=0;if(!o||o.action!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.data[2],h=o.data[3];const c=a.x,d=a.y;l=c+(c-l),h=d+(d-h)}return this.instructions.push({action:"bezierCurveTo",data:[l,h,e,s,i,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,s,i){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(nt.shared);let o=0,a=0;if(!r||r.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=r.data[0],a=r.data[1];const l=n.x,h=n.y;o=l+(l-o),a=h+(h-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,s,i]}),this._dirty=!0,this}rect(e,s,i,r,n){return this.instructions.push({action:"rect",data:[e,s,i,r,n]}),this._dirty=!0,this}circle(e,s,i,r){return this.instructions.push({action:"circle",data:[e,s,i,r]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,s,i,r,n,o,a){n||(n=r/2);const l=-1*Math.PI/2+o,h=i*2,c=Math.PI*2/h,d=[];for(let u=0;u<h;u++){const f=u%2?n:r,p=u*c+l;d.push(e+f*Math.cos(p),s+f*Math.sin(p))}return this.poly(d,!0,a),this}clone(e=!1){const s=new ts;if(s.checkForHoles=this.checkForHoles,!e)s.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const r=this.instructions[i];s.instructions.push({action:r.action,data:r.data.slice()})}return s}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const s=e.a,i=e.b,r=e.c,n=e.d,o=e.tx,a=e.ty;let l=0,h=0,c=0,d=0,u=0,f=0,p=0,_=0;for(let g=0;g<this.instructions.length;g++){const m=this.instructions[g],y=m.data;switch(m.action){case"moveTo":case"lineTo":l=y[0],h=y[1],y[0]=s*l+r*h+o,y[1]=i*l+n*h+a;break;case"bezierCurveTo":c=y[0],d=y[1],u=y[2],f=y[3],l=y[4],h=y[5],y[0]=s*c+r*d+o,y[1]=i*c+n*d+a,y[2]=s*u+r*f+o,y[3]=i*u+n*f+a,y[4]=s*l+r*h+o,y[5]=i*l+n*h+a;break;case"quadraticCurveTo":c=y[0],d=y[1],l=y[2],h=y[3],y[0]=s*c+r*d+o,y[1]=i*c+n*d+a,y[2]=s*l+r*h+o,y[3]=i*l+n*h+a;break;case"arcToSvg":l=y[5],h=y[6],p=y[0],_=y[1],y[0]=s*p+r*_,y[1]=i*p+n*_,y[5]=s*l+r*h+o,y[6]=i*l+n*h+a;break;case"circle":y[4]=Js(y[3],e);break;case"rect":y[4]=Js(y[4],e);break;case"ellipse":y[8]=Js(y[8],e);break;case"roundRect":y[5]=Js(y[5],e);break;case"addPath":y[0].transform(e);break;case"poly":y[2]=Js(y[2],e);break;case"regularPoly":case"chamferRect":y[5]=Js(y[5],e);break;case"closePath":break;default:$e("unknown transform action",m.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let s=this.instructions.length-1,i=this.instructions[s];if(!i)return e.x=0,e.y=0,e;for(;i.action==="closePath";){if(s--,s<0)return e.x=0,e.y=0,e;i=this.instructions[s]}switch(i.action){case"moveTo":case"lineTo":e.x=i.data[0],e.y=i.data[1];break;case"quadraticCurveTo":e.x=i.data[2],e.y=i.data[3];break;case"bezierCurveTo":e.x=i.data[4],e.y=i.data[5];break;case"arc":case"arcToSvg":e.x=i.data[5],e.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(e);break}return e}}function Js(t,e){return t?t.prepend(e):e.clone()}function Ue(t,e,s){const i=t.getAttribute(e);return i?Number(i):s}function dw(t,e){const s=t.querySelectorAll("defs");for(let i=0;i<s.length;i++){const r=s[i];for(let n=0;n<r.children.length;n++){const o=r.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=uw(o);break;case"radialgradient":e.defs[o.id]=fw(o);break}}}}function Bt(t,e,s){const i=t.getAttribute(e);if(i!=null&&i.trim().endsWith("%")){const r=Number(i.trim().slice(0,-1));return Number.isNaN(r)?s:r/100}return Ue(t,e,s)}function $f(t){return(t.getAttribute("gradientUnits")||"objectBoundingBox")==="objectBoundingBox"?"local":"global"}function Nf(t){const e=[];for(let s=0;s<t.children.length;s++){const i=t.children[s],r=Bt(i,"offset",0),n=Ce.shared.setValue(i.getAttribute("stop-color")).toNumber();e.push({offset:r,color:n})}return e}function uw(t){const e=Bt(t,"x1",0),s=Bt(t,"y1",0),i=Bt(t,"x2",1),r=Bt(t,"y2",0);return new ss({type:"linear",start:{x:e,y:s},end:{x:i,y:r},textureSpace:$f(t),colorStops:Nf(t)})}function fw(t){const e=Bt(t,"cx",.5),s=Bt(t,"cy",.5),i=Bt(t,"r",.5),r=Bt(t,"fx",e),n=Bt(t,"fy",s),o=Bt(t,"fr",0);return new ss({type:"radial",center:{x:r,y:n},innerRadius:o,outerCenter:{x:e,y:s},outerRadius:i,textureSpace:$f(t),colorStops:Nf(t)})}function Bc(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const Lc={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function Hf(t,e){const s=t.getAttribute("style"),i={},r={},n={strokeStyle:i,fillStyle:r,useFill:!1,useStroke:!1};for(const o in Lc){const a=t.getAttribute(o);a&&Ic(e,n,o,a.trim())}if(s){const o=s.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[h,c]=l.split(":");Lc[h]&&Ic(e,n,h,c.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?r:null,useFill:n.useFill,useStroke:n.useStroke}}function Ic(t,e,s,i){switch(s){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const r=Bc(i);e.strokeStyle.fill=t.defs[r]}else e.strokeStyle.color=Ce.shared.setValue(i).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const r=Bc(i);e.fillStyle.fill=t.defs[r]}else e.fillStyle.color=Ce.shared.setValue(i).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(i);break;case"stroke-opacity":e.strokeStyle.alpha=Number(i);break;case"opacity":e.fillStyle.alpha=Number(i),e.strokeStyle.alpha=Number(i);break}}function pw(t){if(t.length<=2)return!0;const e=t.map(a=>a.area).sort((a,l)=>l-a),[s,i]=e,r=e[e.length-1],n=s/i,o=i/r;return!(n>3&&o<2)}function _w(t){return t.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function mw(t){const e=t.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const s=e.map(Number),i=[],r=[];for(let c=0;c<s.length;c+=2)c+1<s.length&&(i.push(s[c]),r.push(s[c+1]));if(i.length===0||r.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...r),l=Math.max(...r);return(o-n)*(l-a)}function Dc(t,e){const s=new ts(t,!1);for(const i of s.instructions)e.instructions.push(i)}function gw(t,e){if(typeof t=="string"){const o=document.createElement("div");o.innerHTML=t.trim(),t=o.querySelector("svg")}const s={context:e,defs:{},path:new ts};dw(t,s);const i=t.children,{fillStyle:r,strokeStyle:n}=Hf(t,s);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&Wf(a,s,r,n)}return e}function Wf(t,e,s,i){const r=t.children,{fillStyle:n,strokeStyle:o}=Hf(t,e);n&&s?s={...s,...n}:n&&(s=n),o&&i?i={...i,...o}:o&&(i=o);const a=!s&&!i;a&&(s={color:0});let l,h,c,d,u,f,p,_,g,m,y,v,b,S,x,M,O;switch(t.nodeName.toLowerCase()){case"path":{S=t.getAttribute("d");const B=t.getAttribute("fill-rule"),I=_w(S),L=B==="evenodd",C=I.length>1;if(L&&C){const P=I.map(T=>({path:T,area:mw(T)}));if(P.sort((T,R)=>R.area-T.area),I.length>3||!pw(P))for(let T=0;T<P.length;T++){const R=P[T],F=T===0;e.context.beginPath();const D=new ts(void 0,!0);Dc(R.path,D),e.context.path(D),F?(s&&e.context.fill(s),i&&e.context.stroke(i)):e.context.cut()}else for(let T=0;T<P.length;T++){const R=P[T],F=T%2===1;e.context.beginPath();const D=new ts(void 0,!0);Dc(R.path,D),e.context.path(D),F?e.context.cut():(s&&e.context.fill(s),i&&e.context.stroke(i))}}else{const P=B?B==="evenodd":!0;x=new ts(S,P),e.context.path(x),s&&e.context.fill(s),i&&e.context.stroke(i)}break}case"circle":p=Ue(t,"cx",0),_=Ue(t,"cy",0),g=Ue(t,"r",0),e.context.ellipse(p,_,g,g),s&&e.context.fill(s),i&&e.context.stroke(i);break;case"rect":l=Ue(t,"x",0),h=Ue(t,"y",0),M=Ue(t,"width",0),O=Ue(t,"height",0),m=Ue(t,"rx",0),y=Ue(t,"ry",0),m||y?e.context.roundRect(l,h,M,O,m||y):e.context.rect(l,h,M,O),s&&e.context.fill(s),i&&e.context.stroke(i);break;case"ellipse":p=Ue(t,"cx",0),_=Ue(t,"cy",0),m=Ue(t,"rx",0),y=Ue(t,"ry",0),e.context.beginPath(),e.context.ellipse(p,_,m,y),s&&e.context.fill(s),i&&e.context.stroke(i);break;case"line":c=Ue(t,"x1",0),d=Ue(t,"y1",0),u=Ue(t,"x2",0),f=Ue(t,"y2",0),e.context.beginPath(),e.context.moveTo(c,d),e.context.lineTo(u,f),i&&e.context.stroke(i);break;case"polygon":b=t.getAttribute("points"),v=b.match(/-?\d+/g).map(B=>parseInt(B,10)),e.context.poly(v,!0),s&&e.context.fill(s),i&&e.context.stroke(i);break;case"polyline":b=t.getAttribute("points"),v=b.match(/-?\d+/g).map(B=>parseInt(B,10)),e.context.poly(v,!1),i&&e.context.stroke(i);break;case"g":case"svg":break;default:{$e(`[SVG parser] <${t.nodeName}> elements unsupported`);break}}a&&(s=null);for(let B=0;B<r.length;B++)Wf(r[B],e,s,i)}function yw(t){return t.texture!==void 0}const Oc={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Tn{constructor(e,s){this.uid=ve("fillPattern"),this._tick=0,this.transform=new re;const i=yw(e)?e:{texture:e,repetition:s};this.texture=i.texture,this.textureSpace=i.textureSpace??"global";const r=i.repetition;r&&(this.texture.source.style.addressModeU=Oc[r].addressModeU,this.texture.source.style.addressModeV=Oc[r].addressModeV)}setTransform(e){if(e){if(this.transform.equals(e))return;this.transform.copyFrom(e)}else{if(this.transform.isIdentity())return;this.transform.identity()}this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function vw(t){return Ce.isColorLike(t)}function Fc(t){return t instanceof Tn}function $c(t){return t instanceof ss}function bw(t){return t instanceof ue}function ww(t,e,s){const i=Ce.shared.setValue(e??0);return t.color=i.toNumber(),t.alpha=i.alpha===1?s.alpha:i.alpha,t.texture=ue.WHITE,{...s,...t}}function xw(t,e,s){return t.texture=e,{...s,...t}}function Nc(t,e,s){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,{...s,...t}}function Hc(t,e,s){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,{...s,...t}}function Sw(t,e){const s={...e,...t},i=Ce.shared.setValue(s.color);return s.alpha*=i.alpha,s.color=i.toNumber(),s}function Ns(t,e){if(t==null)return null;const s={},i=t;return vw(t)?ww(s,t,e):bw(t)?xw(s,t,e):Fc(t)?Nc(s,t,e):$c(t)?Hc(s,t,e):i.fill&&Fc(i.fill)?Nc(i,i.fill,e):i.fill&&$c(i.fill)?Hc(i,i.fill,e):Sw(i,e)}function fn(t,e){const{width:s,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...l}=e,h=Ns(t,l);return h?{width:s,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...h}:null}function Cw(t,e){let s=1;const i=t.shapePath.shapePrimitives;for(let r=0;r<i.length;r++){const n=i[r].shape;if(n.type!=="polygon")continue;const o=n.points,a=o.length;if(a<6)continue;const l=n.closePath;for(let h=0;h<a;h+=2){if(!l&&(h===0||h===a-2))continue;const c=(h-2+a)%a,d=(h+2)%a,u=o[c],f=o[c+1],p=o[h],_=o[h+1],g=o[d],m=o[d+1],y=u-p,v=f-_,b=g-p,S=m-_,x=y*y+v*v,M=b*b+S*S;if(x<1e-12||M<1e-12)continue;let I=(y*b+v*S)/Math.sqrt(x*M);I<-1?I=-1:I>1&&(I=1);const L=Math.sqrt((1-I)*.5);if(L<1e-6)continue;const C=Math.min(1/L,e);C>s&&(s=C)}}return s}const kw=new nt,Wc=new re,yh=class Wt extends Dt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ve("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new ts,this._transform=new re,this._fillStyle={...Wt.defaultFillStyle},this._strokeStyle={...Wt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Pt,this._boundsDirty=!0}clone(){const e=new Wt;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=Ns(e,Wt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=fn(e,Wt.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Ns(e,Wt.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Ns(e,Wt.defaultStrokeStyle),this}texture(e,s,i,r,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:i||0,dy:r||0,dw:n||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:s||s===0?Ce.shared.setValue(s).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ts,this}fill(e,s){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&(r==null?void 0:r.action)==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(e!=null&&(s!==void 0&&typeof e=="number"&&(j(Me,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:s}),this._fillStyle=Ns(e,Wt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:s}=this._activePath.getLastPoint(nt.shared);this._activePath.clear(),this._activePath.moveTo(e,s)}stroke(e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?s=i.data.path:s=this._activePath.clone(),s?(e!=null&&(this._strokeStyle=fn(e,Wt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const s=this.instructions[this.instructions.length-1-e],i=this._activePath.clone();if(s&&(s.action==="stroke"||s.action==="fill"))if(s.data.hole)s.data.hole.addPath(i);else{s.data.hole=i;break}}return this._initNextPathLocation(),this}arc(e,s,i,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*s+a.tx,a.b*e+a.d*s+a.ty,i,r,n,o),this}arcTo(e,s,i,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*s+o.tx,o.b*e+o.d*s+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}arcToSvg(e,s,i,r,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(e,s,i,r,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(e,s,i,r,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*e+l.c*s+l.tx,l.b*e+l.d*s+l.ty,l.a*i+l.c*r+l.tx,l.b*i+l.d*r+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){var e;return this._tick++,(e=this._activePath)==null||e.closePath(),this}ellipse(e,s,i,r){return this._tick++,this._activePath.ellipse(e,s,i,r,this._transform.clone()),this}circle(e,s,i){return this._tick++,this._activePath.circle(e,s,i,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,s){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*e+i.c*s+i.tx,i.b*e+i.d*s+i.ty),this}moveTo(e,s){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*e+i.c*s+i.tx,o=i.b*e+i.d*s+i.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(e,s,i,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*s+o.tx,o.b*e+o.d*s+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}rect(e,s,i,r){return this._tick++,this._activePath.rect(e,s,i,r,this._transform.clone()),this}roundRect(e,s,i,r,n){return this._tick++,this._activePath.roundRect(e,s,i,r,n,this._transform.clone()),this}poly(e,s){return this._tick++,this._activePath.poly(e,s,this._transform.clone()),this}regularPoly(e,s,i,r,n=0,o){return this._tick++,this._activePath.regularPoly(e,s,i,r,n,o),this}roundPoly(e,s,i,r,n,o){return this._tick++,this._activePath.roundPoly(e,s,i,r,n,o),this}roundShape(e,s,i,r){return this._tick++,this._activePath.roundShape(e,s,i,r),this}filletRect(e,s,i,r,n){return this._tick++,this._activePath.filletRect(e,s,i,r,n),this}chamferRect(e,s,i,r,n,o){return this._tick++,this._activePath.chamferRect(e,s,i,r,n,o),this}star(e,s,i,r,n=0,o=0){return this._tick++,this._activePath.star(e,s,i,r,n,o,this._transform.clone()),this}svg(e){return this._tick++,gw(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(e){return this._transform.rotate(e),this}scale(e,s=e){return this._transform.scale(e,s),this}setTransform(e,s,i,r,n,o){return e instanceof re?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,s,i,r,n,o),this)}transform(e,s,i,r,n,o){return e instanceof re?(this._transform.append(e),this):(Wc.set(e,s,i,r,n,o),this._transform.append(Wc),this)}translate(e,s=e){return this._transform.translate(e,s),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const e=this._bounds;e.clear();for(let s=0;s<this.instructions.length;s++){const i=this.instructions[s],r=i.action;if(r==="fill"){const n=i.data;e.addBounds(n.path.bounds)}else if(r==="texture"){const n=i.data;e.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=i.data,o=n.style.alignment;let a=n.style.width*(1-o);n.style.join==="miter"&&(a*=Cw(n.path,n.style.miterLimit));const l=n.path.bounds;e.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){var r;if(!this.bounds.containsPoint(e.x,e.y))return!1;const s=this.instructions;let i=!1;for(let n=0;n<s.length;n++){const o=s[n],a=o.data,l=a.path;if(!o.action||!l)continue;const h=a.style,c=l.shapePath.shapePrimitives;for(let d=0;d<c.length;d++){const u=c[d].shape;if(!h||!u)continue;const f=c[d].transform,p=f?f.applyInverse(e,kw):e;if(o.action==="fill")i=u.contains(p.x,p.y);else{const g=h;i=u.strokeContains(p.x,p.y,g.width,g.alignment)}const _=a.hole;if(_){const g=(r=_.shapePath)==null?void 0:r.shapePrimitives;if(g)for(let m=0;m<g.length;m++)g[m].shape.contains(p.x,p.y)&&(i=!1)}if(i)return!0}}return i}unload(){var e;this.emit("unload",this);for(const s in this._gpuData)(e=this._gpuData[s])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(i)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(i))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};yh.defaultFillStyle={color:16777215,alpha:1,texture:ue.WHITE,matrix:null,fill:null,textureSpace:"local"};yh.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:ue.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Lt=yh,Qs;function zc(t){const e=Oe.get().createCanvas(6,1),s=e.getContext("2d");return s.fillStyle=t,s.fillRect(0,0,6,1),e}function Mw(){if(Qs!==void 0)return Qs;try{const t=zc("#ff00ff"),e=zc("#ffff00"),i=Oe.get().createCanvas(6,1).getContext("2d");i.globalCompositeOperation="multiply",i.drawImage(t,0,0),i.drawImage(e,2,0);const r=i.getImageData(2,0,1,1);if(!r)Qs=!1;else{const n=r.data;Qs=n[0]===255&&n[1]===0&&n[2]===0}}catch{Qs=!1}return Qs}const ye={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Mw(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:t=>{const e=t.source,s=e==null?void 0:e.resource;if(!s)return null;const i=e.alphaMode==="premultiplied-alpha",r=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=r!==e.pixelWidth||n!==e.pixelHeight;if(i){if((s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas)&&!o)return s;const a=ye._unpremultipliedCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas}if(s instanceof Uint8Array||s instanceof Uint8ClampedArray||s instanceof Int8Array||s instanceof Uint16Array||s instanceof Int16Array||s instanceof Uint32Array||s instanceof Int32Array||s instanceof Float32Array||s instanceof ArrayBuffer){const a=ye._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=Oe.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d"),c=h.createImageData(e.pixelWidth,e.pixelHeight),d=c.data,u=s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength);if(e.format==="bgra8unorm")for(let f=0;f<d.length&&f+3<u.length;f+=4)d[f]=u[f+2],d[f+1]=u[f+1],d[f+2]=u[f],d[f+3]=u[f+3];else d.set(u.subarray(0,d.length));return h.putImageData(c,0,0),ye._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}if(i){const a=Oe.get().createCanvas(e.pixelWidth,e.pixelHeight),l=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,l.drawImage(s,0,0);const h=l.getImageData(0,0,a.width,a.height),c=h.data;for(let d=0;d<c.length;d+=4){const u=c[d+3];if(u>0){const f=255/u;c[d]=Math.min(255,c[d]*f+.5),c[d+1]=Math.min(255,c[d+1]*f+.5),c[d+2]=Math.min(255,c[d+2]*f+.5)}}return l.putImageData(h,0,0),ye._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=ye._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=Oe.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d");return l.width=e.pixelWidth,l.height=e.pixelHeight,h.drawImage(s,0,0),ye._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}return s},getTintedCanvas:(t,e)=>{const s=t.texture,i=Ce.shared.setValue(e).toHex(),r=s.tintCache||(s.tintCache={}),n=r[i],o=s.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:Oe.get().createCanvas();return ye.tintMethod(s,e,a),a.tintId=o,r[i]=a,r[i]},getTintedPattern:(t,e)=>{const s=Ce.shared.setValue(e).toHex(),i=t.patternCache||(t.patternCache={}),r=t.source._resourceId;let n=i[s];return(n==null?void 0:n.tintId)===r||(ye.canvas||(ye.canvas=Oe.get().createCanvas()),ye.tintMethod(t,e,ye.canvas),n=ye.canvas.getContext("2d").createPattern(ye.canvas,"repeat"),n.tintId=r,i[s]=n),n},applyPatternTransform:(t,e,s=!0)=>{if(!e)return;const i=t;if(!i.setTransform)return;const r=globalThis.DOMMatrix;if(!r)return;const n=new r([e.a,e.b,e.c,e.d,e.tx,e.ty]);i.setTransform(s?n.inverse():n)},tintWithMultiply:(t,e,s)=>{const i=s.getContext("2d"),r=t.frame.clone(),n=t.source._resolution??t.source.resolution??1,o=t.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=oe.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;s.width=Math.ceil(l),s.height=Math.ceil(h),i.save(),e!==16777215&&(i.fillStyle=Ce.shared.setValue(e).toHex(),i.fillRect(0,0,l,h),i.globalCompositeOperation="multiply");const c=ye.getCanvasSource(t);if(!c){i.restore();return}o&&ye._applyInverseRotation(i,o,r.width,r.height),i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),e!==16777215&&(i.globalCompositeOperation="destination-atop",i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height)),i.restore()},tintWithOverlay:(t,e,s)=>{const i=s.getContext("2d"),r=t.frame.clone(),n=t.source._resolution??t.source.resolution??1,o=t.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=oe.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;s.width=Math.ceil(l),s.height=Math.ceil(h),i.save(),i.globalCompositeOperation="copy",i.fillStyle=Ce.shared.setValue(e).toHex(),i.fillRect(0,0,l,h),i.globalCompositeOperation="destination-atop";const c=ye.getCanvasSource(t);if(!c){i.restore();return}o&&ye._applyInverseRotation(i,o,r.width,r.height),i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.restore()},tintWithPerPixel:(t,e,s)=>{const i=s.getContext("2d"),r=t.frame.clone(),n=t.source._resolution??t.source.resolution??1,o=t.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=oe.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;s.width=Math.ceil(l),s.height=Math.ceil(h),i.save(),i.globalCompositeOperation="copy";const c=ye.getCanvasSource(t);if(!c){i.restore();return}o&&ye._applyInverseRotation(i,o,r.width,r.height),i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.restore();const d=e>>16&255,u=e>>8&255,f=e&255,p=i.getImageData(0,0,l,h),_=p.data;for(let g=0;g<_.length;g+=4)_[g]=_[g]*d/255,_[g+1]=_[g+1]*u/255,_[g+2]=_[g+2]*f/255;i.putImageData(p,0,0)},_applyInverseRotation:(t,e,s,i)=>{const r=oe.inv(e),n=oe.uX(r),o=oe.uY(r),a=oe.vX(r),l=oe.vY(r),h=-Math.min(0,n*s,a*i,n*s+a*i),c=-Math.min(0,o*s,l*i,o*s+l*i);t.transform(n,o,a,l,h,c)}};ye.tintMethod=ye.canUseMultiply?ye.tintWithMultiply:ye.tintWithPerPixel;const ko=32767;function Gc(t,e){return(t<<17)+(e<<2)}class Tw{constructor(e){this._buckets=new Map,this._screens=new Fu,this._enableFullScreen=!1,this.canvasOptions=e||{}}get enableFullScreen(){return j(ds,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){j(ds,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen=e}_createCanvasAndContext(e,s){const i=Oe.get().createCanvas();i.width=e,i.height=s;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(e,s,i=1){const{width:r,height:n}=this.getOptimalSize(e,s,i);(r>ko||n>ko)&&$e(`CanvasPool: ${r}x${n} is larger than the ${ko}px pool key limit, canvases of this size may be pooled together`);const o=Gc(r,n);let a=this._buckets.get(o);a||(a=[],this._buckets.set(o,a));let l=a.pop();return l||(l=this._createCanvasAndContext(r,n)),l}getOptimalSize(e,s,i=1){const r=Math.ceil(e*i-1e-6),n=Math.ceil(s*i-1e-6),o=fi(r),a=this._screens.getFittingWidth(r),l=fi(n),h=this._screens.getFittingHeight(n);return{width:a!==void 0?Math.min(a,o):o,height:h!==void 0?Math.min(h,l):l}}returnCanvasAndContext(e){const s=e.canvas,{width:i,height:r}=s,n=this._buckets.get(Gc(i,r));n&&(e.context.resetTransform(),e.context.clearRect(0,0,i,r),n.push(e))}setScreenSize(e,s,i){this._screens.set(e,s,i)&&this._pruneScreenCanvases()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(const[e]of this._buckets){const s=e>>>17,i=e>>>2&32767;(pi(s)||this._screens.hasWidth(s))&&(pi(i)||this._screens.hasHeight(i))||this._buckets.delete(e)}}}const Oa=new Tw;cr.register(Oa);const Ew=new Pt;function Pw(t,e,s,i,r=!1,n){const o=Ew;o.minX=0,o.minY=0,o.maxX=t.width/i|0,o.maxY=t.height/i|0;const a=xn.getOptimalTexture({width:o.width,height:o.height,resolution:i,autoGenerateMipmaps:r,scaleMode:n});return a.source.uploadMethodId="image",a.source.resource=t,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=e/i,a.frame.height=s/i,a.source.emit("update",a.source),a.updateUvs(),a}class Aw{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Rw{constructor(){this.instructions=new hh}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const vh=class Fa{constructor(e){this._renderer=e,this._managedContexts=new dr({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Fa.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Fa.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const s=e._gpuData,i=!!s[this._renderer.uid],r=s[this._renderer.uid]||this._initContext(e);return(e.dirty||!i)&&(i&&r.reset(),r.isBatchable=!1,e.dirty=!1),r}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const s=new Rw,i=this.getGpuContext(e);return i.graphicsData=s,s.init(),s}_initContext(e){const s=new Aw;return s.context=e,e._gpuData[this._renderer.uid]=s,this._managedContexts.add(e),s}destroy(){this._managedContexts.destroy(),this._renderer=null}};vh.extension={type:[X.CanvasSystem],name:"graphicsContext"};vh.defaultOptions={bezierSmoothness:.5};let Bw=vh;class zf{constructor(e,s){this.state=hf.for2d(),this.renderer=e,this._adaptor=s,this.renderer.runners.contextChange.add(this),this._managedGraphics=new dr({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,s){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(s),s.add(e)}updateRenderable(e){}execute(e){e.isRenderable&&this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}zf.extension={type:[X.CanvasPipes],name:"graphics"};function Lw(t,e,s){const i=(t>>24&255)/255;e[s++]=(t&255)/255*i,e[s++]=(t>>8&255)/255*i,e[s++]=(t>>16&255)/255*i,e[s++]=i}class Iw{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{ft.return(e)}),this.batches.length=0}}class Gf{constructor(e,s){this.state=hf.for2d(),this.renderer=e,this._adaptor=s,this.renderer.runners.contextChange.add(this),this._managedGraphics=new dr({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){const s=e.context,i=!!e._gpuData,n=this.renderer.graphicsContext.updateGpuContext(s);return!!(n.isBatchable||i!==n.isBatchable)}addRenderable(e,s){const r=this.renderer.graphicsContext.updateGpuContext(e.context);(e.didViewUpdate||!e._gpuData[this.renderer.uid])&&this._rebuild(e),r.isBatchable?this._addToBatcher(e,s):(this.renderer.renderPipes.batch.break(s),s.add(e))}updateRenderable(e){const i=this._getGpuDataForRenderable(e).batches;for(let r=0;r<i.length;r++){const n=i[r];n._batcher.updateElement(n)}}execute(e){if(!e.isRenderable)return;const s=this.renderer,i=e.context;if(!s.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;const o=n.resources.localUniforms.uniforms;o.uTransformMatrix=e.groupTransform,o.uRound=s._roundPixels|e._roundPixels,Lw(e.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){const s=this._getGpuDataForRenderable(e),r=this.renderer.graphicsContext.updateGpuContext(e.context);s.destroy(),r.isBatchable&&this._updateBatchesForRenderable(e,s)}_addToBatcher(e,s){const i=this.renderer.renderPipes.batch,r=this._getGpuDataForRenderable(e).batches;for(let n=0;n<r.length;n++){const o=r[n];i.addToBatch(o,s)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){const s=new Iw;return e._gpuData[this.renderer.uid]=s,this._managedGraphics.add(e),s}_updateBatchesForRenderable(e,s){const i=e.context,n=this.renderer.graphicsContext.getGpuContext(i),o=this.renderer._roundPixels|e._roundPixels;s.batches=n.batches.map(a=>{const l=ft.get(ph);return a.copyTo(l),l.renderable=e,l.roundPixels=o,l})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Gf.extension={type:[X.WebGLPipes,X.WebGPUPipes],name:"graphics"};Re.add(zf);Re.add(Gf);Re.add(Bw);Re.add(gh);class ee extends lh{constructor(e){e instanceof Lt&&(e={context:e});const{context:s,roundPixels:i,...r}=e||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",s?this.context=s:(this.context=this._ownedContext=new Lt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}set context(e){e!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=e,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(e){return this._context.containsPoint(e)}destroy(e){var s,i;this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||(e==null?void 0:e.context)===!0)&&this._context.destroy(e),(s=this._context)==null||s.off("update",this.onViewUpdate,this),(i=this._context)==null||i.off("unload",this.unload,this),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,s){return this.context[e](...s),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){return e?new ee(this._context.clone()):(this._ownedContext=null,new ee(this._context))}lineStyle(e,s,i){j(Me,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return e&&(r.width=e),s&&(r.color=s),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(e,s){j(Me,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return e!==void 0&&(i.color=e),s!==void 0&&(i.alpha=s),this.context.fillStyle=i,this}endFill(){j(Me,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const e=this.context.strokeStyle;return(e.width!==Lt.defaultStrokeStyle.width||e.color!==Lt.defaultStrokeStyle.color||e.alpha!==Lt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return j(Me,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return j(Me,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return j(Me,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return j(Me,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return j(Me,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return j(Me,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}class Dw extends lh{constructor(e,s){const{text:i,resolution:r,style:n,anchor:o,width:a,height:l,roundPixels:h,...c}=e;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=s,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new tt({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=h??!1,a!==void 0&&(this.width=a),l!==void 0&&(this.height=l)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){var s;e||(e={}),(s=this._style)==null||s.off("update",this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,s){typeof e=="object"?(s=e.height??e.width,e=e.width):s??(s=e),e!==void 0&&this._setWidth(e,this.bounds.width),s!==void 0&&this._setHeight(s,this.bounds.height)}containsPoint(e){const s=this.bounds.width,i=this.bounds.height,r=-s*this.anchor.x;let n=0;return e.x>=r&&e.x<=r+s&&(n=-i*this.anchor.y,e.y>=n&&e.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(e=!1){var s;(s=this._style)==null||s.off("update",this.onViewUpdate,this),super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e=="boolean"?e:e!=null&&e.style)&&this._style.destroy(e),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Ow(t,e){let s=t[0]??{};return(typeof s=="string"||t[1])&&(j(Me,`use new ${e}({ text: "hi!", style }) instead`),s={text:s,style:t[1]}),s}let Ts=null,Zt=null;function Fw(t,e){Ts||(Ts=Oe.get().createCanvas(256,128),Zt=Ts.getContext("2d",{willReadFrequently:!0}),Zt.globalCompositeOperation="copy",Zt.globalAlpha=1),(Ts.width<t||Ts.height<e)&&(Ts.width=fi(t),Ts.height=fi(e))}function Uc(t,e,s){for(let i=0,r=4*s*e;i<e;++i,r+=4)if(t[r+3]!==0)return!1;return!0}function qc(t,e,s,i,r){const n=4*e;for(let o=i,a=i*n+4*s;o<=r;++o,a+=n)if(t[a+3]!==0)return!1;return!0}function $w(...t){let e=t[0];e.canvas||(e={canvas:t[0],resolution:t[1]});const{canvas:s}=e,i=Math.min(e.resolution??1,1),r=e.width??s.width,n=e.height??s.height;let o=e.output;if(Fw(r,n),!Zt)throw new TypeError("Failed to get canvas 2D context");Zt.drawImage(s,0,0,r,n,0,0,r*i,n*i);const l=Zt.getImageData(0,0,r,n).data;let h=0,c=0,d=r-1,u=n-1;for(;c<n&&Uc(l,r,c);)++c;if(c===n)return Ee.EMPTY;for(;Uc(l,r,u);)--u;for(;qc(l,r,h,c,u);)++h;for(;qc(l,r,d,c,u);)--d;return++d,++u,Zt.globalCompositeOperation="source-over",Zt.strokeRect(h,c,d-h,u-c),Zt.globalCompositeOperation="copy",o??(o=new Ee),o.set(h/i,c/i,(d-h)/i,(u-c)/i),o}/**
328
+ * tiny-lru
329
+ *
330
+ * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
331
+ * @license BSD-3-Clause
332
+ * @version 11.4.7
333
+ */class Nw{constructor(e=0,s=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=i,this.size=0,this.ttl=s}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const s=this.items[e];delete this.items[e],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev)}return this}entries(e=this.keys()){const s=new Array(e.length);for(let i=0;i<e.length;i++){const r=e[i];s[i]=[r,this.get(r)]}return s}evict(e=!1){if(e||this.size>0){const s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null)}return this}expiresAt(e){let s;return this.has(e)&&(s=this.items[e].expiry),s}get(e){const s=this.items[e];if(s!==void 0){if(this.ttl>0&&s.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(s),s.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){const e=new Array(this.size);let s=this.first,i=0;for(;s!==null;)e[i++]=s.key,s=s.next;return e}setWithEvicted(e,s,i=this.resetTtl){let r=null;if(this.has(e))this.set(e,s,!0,i);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:s};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(e,s,i=!1,r=this.resetTtl){let n=this.items[e];return i||n!==void 0?(n.value=s,i===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:s},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(e=this.keys()){const s=new Array(e.length);for(let i=0;i<e.length;i++)s[i]=this.get(e[i]);return s}}function Hw(t=1e3,e=0,s=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new Nw(t,e,s)}function Uf(t){return!!t.tagStyles&&Object.keys(t.tagStyles).length>0}function qf(t){return t.includes("<")}function Ww(t,e){return t.clone().assign(e)}function zw(t,e){const s=[],i=e.tagStyles;if(!Uf(e)||!qf(t))return s.push({text:t,style:e}),s;const r=[e],n=[];let o="",a=0;for(;a<t.length;){const l=t[a];if(l==="<"){const h=t.indexOf(">",a);if(h===-1){o+=l,a++;continue}const c=t.indexOf("<",a+1);if(c!==-1&&c<h){o+=l,a++;continue}const d=t.slice(a+1,h);if(d.startsWith("/")){const u=d.slice(1).trim();if(n.length>0&&n[n.length-1]===u){o.length>0&&(s.push({text:o,style:r[r.length-1]}),o=""),r.pop(),n.pop(),a=h+1;continue}else{o+=t.slice(a,h+1),a=h+1;continue}}else{const u=d.trim();if(i[u]){o.length>0&&(s.push({text:o,style:r[r.length-1]}),o="");const f=r[r.length-1],p=Ww(f,i[u]);r.push(p),n.push(u),a=h+1;continue}else{o+=t.slice(a,h+1),a=h+1;continue}}}else o+=l,a++}return o.length>0&&s.push({text:o,style:r[r.length-1]}),s}const Gw=[10,13],Uw=new Set(Gw),qw=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Vw=new Set(qw),Yw=[9,32];new Set(Yw);const Kw=[45,8208,8211,8212,173],jw=new Set(Kw),Xw=/(\r\n|\r|\n)/,Zw=/(?:\r\n|\r|\n)/;function pn(t){return typeof t!="string"?!1:Uw.has(t.charCodeAt(0))}function Mt(t,e){return typeof t!="string"?!1:Vw.has(t.charCodeAt(0))}function Jw(t){return typeof t!="string"?!1:jw.has(t.charCodeAt(0))}function Vf(t){return t==="normal"||t==="pre-line"}function Yf(t){return t==="normal"}function Xt(t){if(typeof t!="string")return"";let e=t.length-1;for(;e>=0&&Mt(t[e]);)e--;return e<t.length-1?t.slice(0,e+1):t}function Kf(t){const e=[],s=[];if(typeof t!="string")return e;for(let i=0;i<t.length;i++){const r=t[i],n=t[i+1];if(Mt(r)||pn(r)){s.length>0&&(e.push(s.join("")),s.length=0),r==="\r"&&n===`
334
+ `?(e.push(`\r
335
+ `),i++):e.push(r);continue}s.push(r),Jw(r)&&n&&!Mt(n)&&!pn(n)&&(e.push(s.join("")),s.length=0)}return s.length>0&&e.push(s.join("")),e}function jf(t,e,s,i){const r=s(t),n=[];for(let o=0;o<r.length;o++){let a=r[o],l=a,h=1;for(;r[o+h];){const c=r[o+h];if(!i(l,c,t,o,e))a+=c,l=c,h++;else break}o+=h-1,n.push(a)}return n}const Qw=/\r\n|\r|\n/g;function ex(t,e,s,i,r,n,o,a,l){var P,$;const h=zw(t,e);if(Yf(e.whiteSpace))for(let T=0;T<h.length;T++){const R=h[T];h[T]={text:R.text.replace(Qw," "),style:R.style}}const d=[];let u=[];for(const T of h){const R=T.text.split(Xw);for(let F=0;F<R.length;F++){const D=R[F];D===`\r
336
+ `||D==="\r"||D===`
337
+ `?(d.push(u),u=[]):D.length>0&&u.push({text:D,style:T.style})}}(u.length>0||d.length===0)&&d.push(u);const f=s?tx(d,e,i,n,a,l):d,p=[],_=[],g=[],m=[],y=[];let v=0;const b=e._fontString,S=o(b);S.fontSize===0&&(S.fontSize=e.fontSize,S.ascent=e.fontSize);let x="",M=!!e.dropShadow,O=((P=e._stroke)==null?void 0:P.width)||0;for(const T of f){let R=0,F=S.ascent,D=S.descent,G="";for(const U of T){const te=U.style._fontString,ae=o(te);te!==x&&(i.font=te,x=te);const fe=r(U.text,U.style.letterSpacing,i);R+=fe,F=Math.max(F,ae.ascent),D=Math.max(D,ae.descent),G+=U.text;const de=(($=U.style._stroke)==null?void 0:$.width)||0;de>O&&(O=de),!M&&U.style.dropShadow&&(M=!0)}T.length===0&&(F=S.ascent,D=S.descent),p.push(R),_.push(F),g.push(D),y.push(G);const Q=e.lineHeight||F+D;m.push(Q+e.leading),v=Math.max(v,R)}const B=O,I=v+B+(e.dropShadow?e.dropShadow.distance:0);let L=0;for(let T=0;T<m.length;T++)L+=m[T];L=Math.max(L,m[0]+B);const C=L+(e.dropShadow?e.dropShadow.distance:0),k=e.lineHeight||S.fontSize;return{width:I,height:C,lines:y,lineWidths:p,lineHeight:k+e.leading,maxLineWidth:v,fontProperties:S,runsByLine:f,lineAscents:_,lineDescents:g,lineHeights:m,hasDropShadow:M}}function tx(t,e,s,i,r,n){var g;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:l,breakWords:h}=e,c=Vf(a),d=l+o,u={};let f="";const p=(m,y)=>{const v=`${m}|${y.styleKey}`;let b=u[v];if(b===void 0){const S=y._fontString;S!==f&&(s.font=S,f=S),b=i(m,y.letterSpacing,s)+y.letterSpacing,u[v]=b}return b},_=[];for(const m of t){const y=sx(m),v=_.length,b=C=>{let k=0,P=C;do{const{token:$,style:T}=y[P];k+=p($,T),P++}while(P<y.length&&y[P].continuesFromPrevious);return k},S=C=>{const k=[];let P=C;do k.push({token:y[P].token,style:y[P].style}),P++;while(P<y.length&&y[P].continuesFromPrevious);return k};let x=[],M=0,O=!c,B=null;const I=()=>{B&&B.text.length>0&&x.push(B),B=null},L=()=>{if(I(),x.length>0){const C=x[x.length-1];C.text=Xt(C.text),C.text.length===0&&x.pop()}_.push(x),x=[],M=0,O=!1};for(let C=0;C<y.length;C++){const{token:k,style:P,continuesFromPrevious:$}=y[C],T=p(k,P);if(c){const D=Mt(k),G=(B==null?void 0:B.text[B.text.length-1])??((g=x[x.length-1])==null?void 0:g.text.slice(-1))??"",Q=G?Mt(G):!1;if(D&&Q)continue}const R=!$,F=R?b(C):T;if(F>d&&R)if(M>0&&L(),h){const D=S(C);for(let G=0;G<D.length;G++){const Q=D[G].token,U=D[G].style,te=jf(Q,h,n,r);for(const ae of te){const fe=p(ae,U);fe+M>d&&L(),!B||B.style!==U?(I(),B={text:ae,style:U}):B.text+=ae,M+=fe}}C+=D.length-1}else{const D=S(C);I(),_.push(D.map(G=>({text:G.token,style:G.style}))),O=!1,C+=D.length-1}else if(F+M>d&&R){if(Mt(k)){O=!1;continue}L(),B={text:k,style:P},M=T}else if($&&!h)!B||B.style!==P?(I(),B={text:k,style:P}):B.text+=k,M+=T;else{const D=Mt(k);if(M===0&&D&&!O)continue;!B||B.style!==P?(I(),B={text:k,style:P}):B.text+=k,M+=T}}if(I(),x.length>0){const C=x[x.length-1];C.text=Xt(C.text),C.text.length===0&&x.pop()}(x.length>0||_.length===v)&&_.push(x)}return _}function sx(t){const e=[];let s=!1;for(const i of t){const r=Kf(i.text);let n=!0;for(const o of r){const a=Mt(o)||pn(o),l=n&&s&&!a;e.push({token:o,style:i.style,continuesFromPrevious:l}),s=!a,n=!1}}return e}const ix={willReadFrequently:!0};function Vc(t,e,s,i,r){let n=s[t];return typeof n!="number"&&(n=r(t,e,i)+e,s[t]=n),n}function rx(t,e,s,i,r,n,o){const a=s.getContext("2d",ix);a.font=e._fontString;let l=0,h="";const c=[],d=Object.create(null),{letterSpacing:u,whiteSpace:f}=e,p=Vf(f),_=Yf(f);let g=!p;const m=e.wordWrapWidth+u,y=Kf(t);for(let b=0;b<y.length;b++){let S=y[b];if(pn(S)){if(!_){c.push(Xt(h)),g=!p,h="",l=0;continue}S=" "}if(p){const M=Mt(S),O=Mt(h[h.length-1]);if(M&&O)continue}const x=Vc(S,u,d,a,i);if(x>m)if(h!==""&&(c.push(Xt(h)),h="",l=0),r(S,e.breakWords)){const M=jf(S,e.breakWords,o,n);for(const O of M){const B=Vc(O,u,d,a,i);B+l>m&&(c.push(Xt(h)),g=!1,h="",l=0),h+=O,l+=B}}else h.length>0&&(c.push(Xt(h)),h="",l=0),c.push(Xt(S)),g=!1,h="",l=0;else x+l>m&&(g=!1,c.push(Xt(h)),h="",l=0),(h.length>0||!Mt(S)||g)&&(h+=S,l+=x)}const v=Xt(h);return v.length>0&&c.push(v),c.join(`
338
+ `)}const Yc={willReadFrequently:!0},ns=class V{static get experimentalLetterSpacingSupported(){let e=V._experimentalLetterSpacingSupported;if(e===void 0){const s=Oe.get().getCanvasRenderingContext2D().prototype;e=V._experimentalLetterSpacingSupported="letterSpacing"in s||"textLetterSpacing"in s}return e}constructor(e,s,i,r,n,o,a,l,h,c){this.text=e,this.style=s,this.width=i,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(e=" ",s,i=V._canvas,r=s.wordWrap){var b;const n=`${e}-${s.styleKey}-wordWrap-${r}`;if(V._measurementCache.has(n))return V._measurementCache.get(n);if(Uf(s)&&qf(e)){const S=ex(e,s,r,V._context,V._measureText,V._measureTextAdvance,V.measureFont,V.canBreakChars,V.wordWrapSplit),x=new V(e,s,S.width,S.height,S.lines,S.lineWidths,S.lineHeight,S.maxLineWidth,S.fontProperties,{runsByLine:S.runsByLine,lineAscents:S.lineAscents,lineDescents:S.lineDescents,lineHeights:S.lineHeights,hasDropShadow:S.hasDropShadow});return V._measurementCache.set(n,x),x}const a=s._fontString,l=V.measureFont(a);l.fontSize===0&&(l.fontSize=s.fontSize,l.ascent=s.fontSize,l.descent=0);const h=V._context;h.font=a;const d=(r?V._wordWrap(e,s,i):e).split(Zw),u=new Array(d.length);let f=0;for(let S=0;S<d.length;S++){const x=V._measureText(d[S],s.letterSpacing,h);u[S]=x,f=Math.max(f,x)}const p=((b=s._stroke)==null?void 0:b.width)??0,_=s.lineHeight||l.fontSize,g=V._adjustWidthForStyle(f,s),m=Math.max(_,l.fontSize+p)+(d.length-1)*(_+s.leading),y=V._adjustHeightForStyle(m,s),v=new V(e,s,g,y,d,u,_+s.leading,f,l);return V._measurementCache.set(n,v),v}static _adjustWidthForStyle(e,s){var n;const i=((n=s._stroke)==null?void 0:n.width)||0;let r=e+i;return s.dropShadow&&(r+=s.dropShadow.distance),r}static _adjustHeightForStyle(e,s){let i=e;return s.dropShadow&&(i+=s.dropShadow.distance),i}static _measureText(e,s,i){const{metricWidth:r,metrics:n,letterSpacingVal:o}=V._measureTextCore(e,s,i),a=-(n.actualBoundingBoxLeft??0);let h=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(h+=o),Math.max(r,h)}static _measureTextAdvance(e,s,i){return V._measureTextCore(e,s,i).metricWidth}static _measureTextCore(e,s,i){let r=!1;V.experimentalLetterSpacingSupported&&(V.experimentalLetterSpacing?(i.letterSpacing=`${s}px`,i.textLetterSpacing=`${s}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(e);let o=n.width,a=0;return o>0&&(r?a=-s:a=(V.graphemeSegmenter(e).length-1)*s,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(e,s,i=V._canvas){return rx(e,s,i,V._measureTextAdvance,V.canBreakWords,V.canBreakChars,V.wordWrapSplit)}static isBreakingSpace(e,s){return Mt(e)}static canBreakWords(e,s){return s}static canBreakChars(e,s,i,r,n){return!0}static wordWrapSplit(e){return V.graphemeSegmenter(e)}static measureFont(e){if(V._fonts[e])return V._fonts[e];const s=V._context;s.font=e;const i=s.measureText(V.METRICS_STRING+V.BASELINE_SYMBOL),r=i.actualBoundingBoxAscent??0,n=i.actualBoundingBoxDescent??0,o={ascent:r,descent:n,fontSize:r+n};return V._fonts[e]=o,o}static clearMetrics(e=""){e?delete V._fonts[e]:V._fonts={}}static get _canvas(){if(!V.__canvas){let e;try{const s=new OffscreenCanvas(0,0),i=s.getContext("2d",Yc);if(i!=null&&i.measureText)return V.__canvas=s,s;e=Oe.get().createCanvas()}catch{e=Oe.get().createCanvas()}e.width=e.height=10,V.__canvas=e}return V.__canvas}static get _context(){return V.__context||(V.__context=V._canvas.getContext("2d",Yc)),V.__context}};ns.METRICS_STRING="|ÉqÅ";ns.BASELINE_SYMBOL="M";ns.BASELINE_MULTIPLIER=1.4;ns.HEIGHT_MULTIPLIER=2;ns.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const t=new Intl.Segmenter;return e=>{const s=t.segment(e),i=[];let r=0;for(const n of s)i[r++]=n.segment;return i}}return t=>[...t]})();ns.experimentalLetterSpacing=!1;ns._fonts={};ns._measurementCache=Hw(1e3);let ls=ns;const nx=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function $a(t){const e=typeof t.fontSize=="number"?`${t.fontSize}px`:t.fontSize;let s=t.fontFamily;Array.isArray(t.fontFamily)||(s=t.fontFamily.split(","));for(let i=s.length-1;i>=0;i--){let r=s[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!nx.includes(r)&&(r=`"${r}"`),s[i]=r}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${s.join(",")}`}const Kc=1e5;function $r(t,e,s,i=0,r=0,n=0){if(t.texture===ue.WHITE&&!t.fill)return Ce.shared.setValue(t.color).setAlpha(t.alpha??1).toHexa();if(t.fill){if(t.fill instanceof Tn){const o=t.fill,a=e.createPattern(o.texture.source.resource,"repeat");return ye.applyPatternTransform(a,o.transform,!1),a}else if(t.fill instanceof ss){const o=t.fill,a=o.type==="linear",l=o.textureSpace==="local";let h=1,c=1;l&&s&&(h=s.width+i,c=s.height+i);let d,u=!1;if(a){const{start:f,end:p}=o;d=e.createLinearGradient(f.x*h+r,f.y*c+n,p.x*h+r,p.y*c+n),u=Math.abs(p.x-f.x)<Math.abs((p.y-f.y)*.1)}else{const{center:f,innerRadius:p,outerCenter:_,outerRadius:g}=o;d=e.createRadialGradient(f.x*h+r,f.y*c+n,p*h,_.x*h+r,_.y*c+n,g*h)}if(u&&l&&s){const f=s.lineHeight/c;for(let p=0;p<s.lines.length;p++){const _=(p*s.lineHeight+i/2)/c;o.colorStops.forEach(g=>{let m=_+g.offset*f;m=Math.max(0,Math.min(1,m)),d.addColorStop(Math.floor(m*Kc)/Kc,Ce.shared.setValue(g.color).toHex())})}}else o.colorStops.forEach(f=>{d.addColorStop(f.offset,Ce.shared.setValue(f.color).toHex())});return d}}else{const o=e.createPattern(t.texture.source.resource,"repeat"),a=t.matrix.copyTo(re.shared);return a.scale(t.texture.source.pixelWidth,t.texture.source.pixelHeight),o.setTransform(a),o}return $e("FillStyle not recognised",t),"red"}const jc=new Ee;function ei(t){let e=0;for(let s=0;s<t.length;s++)t.charCodeAt(s)===32&&e++;return e}class ox{getCanvasAndContext(e){const{text:s,style:i,resolution:r=1}=e,n=i._getFinalPadding(),o=ls.measureText(s||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*r),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*r),h=Oa.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(i,n,r,h,o);const c=i.trim?$w({canvas:h.canvas,width:a,height:l,resolution:1,output:jc}):jc.set(0,0,a,l);return{canvasAndContext:h,frame:c}}returnCanvasAndContext(e){Oa.returnCanvasAndContext(e)}_renderTextToCanvas(e,s,i,r,n){var S,x,M;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,s,i,r);return}const{canvas:o,context:a}=r,l=$a(e),h=n.lines,c=n.lineHeight,d=n.lineWidths,u=n.maxLineWidth,f=n.fontProperties,p=o.height;if(a.resetTransform(),a.scale(i,i),a.textBaseline=e.textBaseline,(S=e._stroke)!=null&&S.width){const O=e._stroke;a.lineWidth=O.width,a.miterLimit=O.miterLimit,a.lineJoin=O.join,a.lineCap=O.cap}a.font=l;let _,g;const m=e.dropShadow?2:1,v=(((x=e._stroke)==null?void 0:x.width)??0)/2;let b=(c-f.fontSize)/2;c-f.fontSize<0&&(b=0);for(let O=0;O<m;++O){const B=e.dropShadow&&O===0,I=B?Math.ceil(Math.max(1,p)+s*2):0,L=I*i;if(B)this._setupDropShadow(a,e,i,L);else{const C=e._gradientBounds,k=e._gradientOffset;if(C){const P={width:C.width,height:C.height,lineHeight:C.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,P,s,v,(k==null?void 0:k.x)??0,(k==null?void 0:k.y)??0)}else k?this._setFillAndStrokeStyles(a,e,n,s,v,k.x,k.y):this._setFillAndStrokeStyles(a,e,n,s,v);a.shadowColor="rgba(0,0,0,0)"}for(let C=0;C<h.length;C++){_=v,g=v+C*c+f.ascent+b,_+=this._getAlignmentOffset(d[C],u,e.align);let k=0;if(e.align==="justify"&&e.wordWrap&&C<h.length-1){const P=ei(h[C]);P>0&&(k=(u-d[C])/P)}(M=e._stroke)!=null&&M.width&&this._drawLetterSpacing(h[C],e,r,_+s,g+s-I,!0,k),e._fill!==void 0&&this._drawLetterSpacing(h[C],e,r,_+s,g+s-I,!1,k)}}}_renderTaggedTextToCanvas(e,s,i,r,n){var v,b,S;const{canvas:o,context:a}=n,{runsByLine:l,lineWidths:h,maxLineWidth:c,lineAscents:d,lineHeights:u,hasDropShadow:f}=e,p=o.height;a.resetTransform(),a.scale(r,r),a.textBaseline=s.textBaseline;const _=f?2:1;let g=((v=s._stroke)==null?void 0:v.width)??0;for(const x of l)for(const M of x){const O=((b=M.style._stroke)==null?void 0:b.width)??0;O>g&&(g=O)}const m=g/2,y=[];for(let x=0;x<l.length;x++){const M=l[x],O=[];for(const B of M){const I=$a(B.style);a.font=I,O.push({width:ls._measureText(B.text,B.style.letterSpacing,a),font:I})}y.push(O)}for(let x=0;x<_;++x){const M=f&&x===0,O=M?Math.ceil(Math.max(1,p)+i*2):0,B=O*r;M||(a.shadowColor="rgba(0,0,0,0)");let I=m;for(let L=0;L<l.length;L++){const C=l[L],k=h[L],P=d[L],$=u[L],T=y[L];let R=m;R+=this._getAlignmentOffset(k,c,s.align);let F=0;if(s.align==="justify"&&s.wordWrap&&L<l.length-1){let Q=0;for(const U of C)Q+=ei(U.text);Q>0&&(F=(c-k)/Q)}const D=I+P;let G=R+i;for(let Q=0;Q<C.length;Q++){const U=C[Q],{width:te,font:ae}=T[Q];if(a.font=ae,a.textBaseline=U.style.textBaseline,(S=U.style._stroke)!=null&&S.width){const de=U.style._stroke;if(a.lineWidth=de.width,a.miterLimit=de.miterLimit,a.lineJoin=de.join,a.lineCap=de.cap,M)if(U.style.dropShadow)this._setupDropShadow(a,U.style,r,B);else{const z=ei(U.text);G+=te+z*F;continue}else{const z=ls.measureFont(ae),K=U.style.lineHeight||z.fontSize,he={width:te,height:K,lineHeight:K,lines:[U.text]};a.strokeStyle=$r(de,a,he,i*2,G-i,I)}this._drawLetterSpacing(U.text,U.style,n,G,D+i-O,!0,F)}const fe=ei(U.text);G+=te+fe*F}G=R+i;for(let Q=0;Q<C.length;Q++){const U=C[Q],{width:te,font:ae}=T[Q];if(a.font=ae,a.textBaseline=U.style.textBaseline,U.style._fill!==void 0){if(M)if(U.style.dropShadow)this._setupDropShadow(a,U.style,r,B);else{const de=ei(U.text);G+=te+de*F;continue}else{const de=ls.measureFont(ae),z=U.style.lineHeight||de.fontSize,K={width:te,height:z,lineHeight:z,lines:[U.text]};a.fillStyle=$r(U.style._fill,a,K,i*2,G-i,I)}this._drawLetterSpacing(U.text,U.style,n,G,D+i-O,!1,F)}const fe=ei(U.text);G+=te+fe*F}I+=$}}}_setFillAndStrokeStyles(e,s,i,r,n,o=0,a=0){var l;if(e.fillStyle=s._fill?$r(s._fill,e,i,r*2,o,a):null,(l=s._stroke)!=null&&l.width){const h=n+r*2;e.strokeStyle=$r(s._stroke,e,i,h,o,a)}}_setupDropShadow(e,s,i,r){e.fillStyle="black",e.strokeStyle="black";const n=s.dropShadow,o=n.color,a=n.alpha;e.shadowColor=Ce.shared.setValue(o).setAlpha(a).toRgbaString();const l=n.blur*i,h=n.distance*i;e.shadowBlur=l,e.shadowOffsetX=Math.cos(n.angle)*h,e.shadowOffsetY=Math.sin(n.angle)*h+r}_getAlignmentOffset(e,s,i){return i==="right"?s-e:i==="center"?(s-e)/2:0}_drawLetterSpacing(e,s,i,r,n,o=!1,a=0){const{context:l}=i,h=s.letterSpacing;let c=!1;if(ls.experimentalLetterSpacingSupported&&(ls.experimentalLetterSpacing?(l.letterSpacing=`${h}px`,l.textLetterSpacing=`${h}px`,c=!0):(l.letterSpacing="0px",l.textLetterSpacing="0px")),(h===0||c)&&a===0){o?l.strokeText(e,r,n):l.fillText(e,r,n);return}if(a!==0&&(h===0||c)){const _=e.split(" ");let g=r;const m=l.measureText(" ").width;for(let y=0;y<_.length;y++)o?l.strokeText(_[y],g,n):l.fillText(_[y],g,n),g+=l.measureText(_[y]).width+m+a;return}let d=r;const u=ls.graphemeSegmenter(e);let f=l.measureText(e).width,p=0;for(let _=0;_<u.length;++_){const g=u[_];o?l.strokeText(g,d,n):l.fillText(g,d,n);let m="";for(let y=_+1;y<u.length;++y)m+=u[y];p=l.measureText(m).width,d+=f-p+h,g===" "&&(d+=a),f=p}}}const oi=new ox,bh=class Os extends Dt{constructor(e={}){super(),this.uid=ve("textStyle"),this._tick=0,this._cachedFontString=null,ax(e),e instanceof Os&&(e=e._toObject());const r={...Os.defaultTextStyle,...e};for(const n in r){const o=n;this[o]=r[n]}this._tagStyles=e.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...Os.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...Os.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Lt.defaultFillStyle,...e},()=>{this._fill=Ns({...this._originalFill},Lt.defaultFillStyle)})),this._fill=Ns(e===0?"black":e,Lt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Lt.defaultStrokeStyle,...e},()=>{this._stroke=fn({...this._originalStroke},Lt.defaultStrokeStyle)})),this._stroke=fn(e,Lt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const e=Os.defaultTextStyle;for(const s in e)this[s]=e[s]}assign(e){for(const s in e){const i=s;this[i]=e[s]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=$a(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new Os(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let s=0;s<this._filters.length;s++)e+=this._filters[s].padding;return Math.max(this._padding,e)}destroy(e=!1){var i,r,n,o;if(this.removeAllListeners(),typeof e=="boolean"?e:e==null?void 0:e.texture){const a=typeof e=="boolean"?e:e==null?void 0:e.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(a),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(a),(o=this._originalStroke)!=null&&o.texture&&this._originalStroke.texture.destroy(a)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,s){return new Proxy(e,{set:(i,r,n)=>(i[r]===n||(i[r]=n,s==null||s(r,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(Ce.isColorLike(e)||e instanceof ss||e instanceof Tn)}};bh.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};bh.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let pt=bh;function ax(t){const e=t;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const s=pt.defaultDropShadow;t.dropShadow={alpha:e.dropShadowAlpha??s.alpha,angle:e.dropShadowAngle??s.angle,blur:e.dropShadowBlur??s.blur,color:e.dropShadowColor??s.color,distance:e.dropShadowDistance??s.distance}}if(e.strokeThickness!==void 0){j(Me,"strokeThickness is now a part of stroke");const s=e.stroke;let i={};if(Ce.isColorLike(s))i.color=s;else if(s instanceof ss||s instanceof Tn)i.fill=s;else if(Object.hasOwnProperty.call(s,"color")||Object.hasOwnProperty.call(s,"fill"))i=s;else throw new Error("Invalid stroke value.");t.stroke={...i,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(j(Me,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||e.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&$e("The number of fill colors must match the number of fill gradient stops.");const s=new ss({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=e.fillGradientStops.slice(),r=e.fill.map(n=>Ce.shared.setValue(n).toNumber());i.forEach((n,o)=>{s.addColorStop(n,r[o])}),t.fill={fill:s}}}let Xc=!1;function hx(t){if(Xc)return;const e=new Ws({scaleMode:t.scaleMode});t._resourceId!==e._resourceId&&(Xc=!0,$e("Text textureStyle: only scaleMode is applied to a text texture, the other fields are ignored"))}function lx(t,e){const{texture:s,bounds:i}=t,r=e._style._getFinalPadding();Tu(i,e._anchor,s);const n=e._anchor._x*r*2,o=e._anchor._y*r*2;i.minX-=r-n,i.minY-=r-o,i.maxX-=r-n,i.maxY-=r-o}class cx{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class dx extends cx{}class Xf{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),e.runners.contextChange.add(this),this._managedTexts=new dr({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const e in this._managedTexts.items){const s=this._managedTexts.items[e];s!=null&&s._autoResolution&&s.onViewUpdate()}}contextChange(){var e;for(const s in this._managedTexts.items)(e=this._managedTexts.items[s])==null||e.unload()}validateRenderable(e){const s=this._getGpuText(e),i=e.styleKey;return s.currentKey!==i?!0:e._didTextUpdate}addRenderable(e,s){const i=this._getGpuText(e);if(e._didTextUpdate||i.currentKey!==e.styleKey){const r=e._autoResolution?this._renderer.resolution:e.resolution;(i.currentKey!==e.styleKey||e._resolution!==r)&&this._updateGpuText(e),e._didTextUpdate=!1,lx(i,e)}this._renderer.renderPipes.batch.addToBatch(i,s)}updateRenderable(e){const s=this._getGpuText(e);s._batcher.updateElement(s)}_updateGpuText(e){const s=this._getGpuText(e);s.texture&&this._renderer.canvasText.decreaseReferenceCount(s.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,s.texture=this._renderer.canvasText.getManagedTexture(e),s.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){const s=new dx;return s.currentKey="--",s.renderable=e,s.transform=e.groupTransform,s.bounds={minX:0,maxX:1,minY:0,maxY:0},s.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=s,this._managedTexts.add(e),s}onTextUnload(e){const s=e._gpuData[this._renderer.uid];if(!s)return;const{canvasText:i}=this._renderer;i.getReferenceCount(s.currentKey)>0?i.decreaseReferenceCount(s.currentKey):s.texture&&i.returnTexture(s.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Xf.extension={type:[X.WebGLPipes,X.WebGPUPipes,X.CanvasPipes],name:"text"};class Zf{constructor(e,s){this._activeTextures={},this._renderer=e,this._retainCanvasContext=s}getTexture(e,s,i,r){typeof e=="string"&&(j("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:i,resolution:s}),e.style instanceof pt||(e.style=new pt(e.style)),typeof e.text!="string"&&(e.text=e.text.toString());const{text:n,style:o,textureStyle:a,autoGenerateMipmaps:l}=e,h=e.resolution??this._renderer.resolution,{frame:c,canvasAndContext:d}=oi.getCanvasAndContext({text:n,style:o,resolution:h}),u=Pw(d.canvas,c.width,c.height,h,l,a==null?void 0:a.scaleMode);if(o.trim&&(c.pad(o.padding),u.frame.copyFrom(c),u.frame.scale(1/h),u.updateUvs()),o.filters){const f=this._applyFilters(u,o.filters);return this.returnTexture(u),oi.returnCanvasAndContext(d),f}return this._renderer.texture.initSource(u._source),this._retainCanvasContext||oi.returnCanvasAndContext(d),u}returnTexture(e){const s=e.source,i=s.resource;if(this._retainCanvasContext&&(i!=null&&i.getContext)){const r=i.getContext("2d");r&&oi.returnCanvasAndContext({canvas:i,context:r})}s.resource=null,s.uploadMethodId="unknown",s.alphaMode="no-premultiply-alpha",xn.returnTexture(e)}renderTextToCanvas(){j("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;const s=e.styleKey;if(this._activeTextures[s])return this._increaseReferenceCount(s),this._activeTextures[s].texture;const i=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle,autoGenerateMipmaps:e.autoGenerateMipmaps});return this._activeTextures[s]={texture:i,usageCount:1},i}decreaseReferenceCount(e){const s=this._activeTextures[e];s&&(s.usageCount--,s.usageCount===0&&(this.returnTexture(s.texture),this._activeTextures[e]=null))}getReferenceCount(e){var s;return((s=this._activeTextures[e])==null?void 0:s.usageCount)??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,s){const i=this._renderer.renderTarget.renderTarget,r=this._renderer.filter.generateFilteredTexture({texture:e,filters:s});return this._renderer.renderTarget.bind({target:i,clear:!1}),r}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}class Jf extends Zf{constructor(e){super(e,!0)}}Jf.extension={type:[X.CanvasSystem],name:"canvasText"};class Qf extends Zf{constructor(e){super(e,!1)}}Qf.extension={type:[X.WebGLSystem,X.WebGPUSystem],name:"canvasText"};Re.add(Jf);Re.add(Qf);Re.add(Xf);let zt=class extends Dw{constructor(...e){const s=Ow(e,"Text");super(s,pt),this.renderPipeId="text",s.textureStyle&&(this.textureStyle=s.textureStyle instanceof Ws?s.textureStyle:new Ws(s.textureStyle),hx(this.textureStyle)),this.autoGenerateMipmaps=s.autoGenerateMipmaps??ut.defaultOptions.autoGenerateMipmaps}updateBounds(){const e=this._bounds,s=this._anchor;let i=0,r=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=oi.getCanvasAndContext({text:this.text,style:this._style,resolution:1});oi.returnCanvasAndContext(o),i=n.width,r=n.height}else{const n=ls.measureText(this._text,this._style);i=n.width,r=n.height}e.minX=-s._x*i,e.maxX=e.minX+i,e.minY=-s._y*r,e.maxY=e.minY+r}};Re.add(Cy,ky);const ep=64,ux=32;function E(t,e,s=0){return{x:(t-e)*(ep/2),y:(t+e)*(ux/2)-s}}function ms(t,e){return t+e}function H(t,e){const s=Math.min(255,Math.max(0,(t>>16&255)*e)),i=Math.min(255,Math.max(0,(t>>8&255)*e)),r=Math.min(255,Math.max(0,(t&255)*e));return s<<16|i<<8|r}function ur(t,e,s){const i=r=>Math.round((t>>r&255)*(1-s)+(e>>r&255)*s);return i(16)<<16|i(8)<<8|i(0)}function hi(t){let e=2166136261;for(let s=0;s<t.length;s++)e^=t.charCodeAt(s),e=Math.imul(e,16777619)>>>0;return e>>>0}function Nr(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let s=e;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}const Je=Object.fromEntries(Object.entries(yu.materials).map(([t,e])=>[t,le(e)]));function ie(t,e,s,i,r,n,o,a=0){const l=a+n,h=E(e,s,l),c=E(e+i,s,l),d=E(e+i,s+r,l),u=E(e,s+r,l),f=E(e,s+r,a),p=E(e+i,s+r,a),_=E(e+i,s,a);t.poly([u.x,u.y,d.x,d.y,p.x,p.y,f.x,f.y]).fill(H(o,.68)),t.poly([d.x,d.y,c.x,c.y,_.x,_.y,p.x,p.y]).fill(H(o,.84)),t.poly([h.x,h.y,c.x,c.y,d.x,d.y,u.x,u.y]).fill(o)}function bs(t,e,s,i,r,n){const o=E(e,i,r),a=E(s,i,r),l=E(s,i,n),h=E(e,i,n);return t.poly([o.x,o.y,a.x,a.y,l.x,l.y,h.x,h.y])}function Gt(t,e,s,i,r,n){const o=E(e,s,r),a=E(e,i,r),l=E(e,i,n),h=E(e,s,n);return t.poly([o.x,o.y,a.x,a.y,l.x,l.y,h.x,h.y])}function st(t,e,s,i,r,n=0){const o=E(e,s,n),a=E(e+i,s,n),l=E(e+i,s+r,n),h=E(e,s+r,n);return t.poly([o.x,o.y,a.x,a.y,l.x,l.y,h.x,h.y])}function Qe(t,e,s,i,r,n=.28){const o=E(e,s);t.ellipse(o.x,o.y,i,r).fill({color:0,alpha:n})}function fx(t,e,s,i,r=Je){Qe(t,e+.2,s+.2,11,5,.22),ie(t,e,s,.4,.4,9,r.pot);const n=E(e+.2,s+.2,9),o=4+i%3;for(let a=0;a<o;a++){const l=a/o*Math.PI*2+i,h=5+(i>>a+2&3),c=a%2?r.leaf:r.leafDark;t.circle(n.x+Math.cos(l)*6,n.y-8+Math.sin(l)*3.5,h).fill(c)}t.circle(n.x,n.y-12,6).fill(r.leaf)}function Zc(t,e,s,i=Je){Qe(t,e+.3,s+.3,14,7,.22),ie(t,e,s,.55,.45,24,i.metal);for(const r of[7,15]){const n=E(e+.06,s+.45,r),o=E(e+.49,s+.45,r);t.moveTo(n.x,n.y).lineTo(o.x,o.y).stroke({color:H(i.metal,.5),width:1});const a=E(e+.28,s+.45,r+3);t.circle(a.x,a.y,1.2).fill(13685986)}}function px(t,e,s){Qe(t,e+.18,s+.18,9,4.5,.22),ie(t,e,s,.36,.36,20,3883360);const i=E(e+.18,s+.18,20);t.ellipse(i.x,i.y-7,7,11).fill({color:9425919,alpha:.85}).stroke({color:5941462,width:1}),t.ellipse(i.x,i.y-12,5,4).fill({color:13233407,alpha:.5})}function _x(t,e,s,i,r=Je){Qe(t,e+.45,s+.25,22,8,.22),ie(t,e,s,.9,.3,30,r.woodDark);const n=[14711391,8499866,15912079,4020864,15625293,10011097,14263731];for(const o of[3,16]){let a=e+.06,l=i;for(;a<e+.84;){const h=.06+(l>>3&1)*.04,c=8+(l>>5&3);bs(t,a,a+h,s+.3,o,o+c).fill(n[l%n.length]),a+=h+.01,l=l*1103515245+12345>>>0}}}function mx(t,e,s,i){Qe(t,e+.6,s+.3,30,10,.24),ie(t,e,s,1.2,.55,10,i),ie(t,e,s,1.2,.14,20,H(i,.9)),ie(t,e,s,.14,.55,15,H(i,.95)),ie(t,e+1.06,s,.14,.55,15,H(i,.95));const r=E(e+.6,s+.3,10);t.moveTo(r.x-4,r.y+1).lineTo(r.x+4,r.y-1).stroke({color:H(i,.7),width:1})}function gx(t,e,s,i=Je){Qe(t,e+.3,s+.2,15,6,.18),ie(t,e,s,.6,.4,8,i.wood);const r=E(e+.3,s+.2,8);t.circle(r.x-4,r.y-1,2.2).fill(i.white),t.rect(r.x+1,r.y-4,7,4).fill(13085050)}function yx(t,e,s,i,r,n){const a=e+.5+.002;Qe(t,e+.3,s+.4,17,9,.25),ie(t,e,s,.5,.75,36,i),Gt(t,a,s+.07,s+.5,12,31).fill(1317932).stroke({color:H(i,.55),width:1}),Gt(t,a,s+.09,s+.48,13,30).fill({color:r,alpha:.16});const l=[14711391,15912079,8499866,10011097,15625293,14263731];for(let c=0;c<3;c++){const d=15+c*5.5,u=E(a,s+.09,d-.5),f=E(a,s+.48,d-.5);t.moveTo(u.x,u.y).lineTo(f.x,f.y).stroke({color:H(i,1.3),width:1,alpha:.5});for(let p=0;p<3;p++){const _=E(a,s+.16+p*.12,d);t.roundRect(_.x-1.6,_.y-4,3.2,4,.8).fill(l[(c*3+p*2)%l.length])}}Gt(t,a,s+.55,s+.69,17,31).fill(H(i,.6));for(let c=0;c<4;c++){const d=E(a,s+.62,20+c*2.6);t.circle(d.x,d.y,.9).fill(n)}const h=E(a,s+.62,15);t.rect(h.x-.6,h.y-2,1.2,2.5).fill(724501),Gt(t,a,s+.14,s+.46,3,8).fill(724501).stroke({color:H(i,.5),width:1}),Gt(t,a,s+.05,s+.7,32.5,35).fill({color:r,alpha:.9})}function vx(t,e,s,i,r=Je){Qe(t,e+i/2,s+.2,i*17,6,.2);for(const n of[e+.08,e+i-.16])ie(t,n,s+.06,.08,.22,5,r.metal);ie(t,e,s,i,.34,3,r.wood,5)}function bx(t,e,s,i,r,n){st(t,e,s,i,r,.5).fill({color:n,alpha:.32}),st(t,e+.12,s+.12,i-.24,r-.24,.5).stroke({color:n,alpha:.4,width:1})}function Jc(t,e,s,i,r,n=16773840,o=.105){const a=E(e,s,.5);for(let l=3;l>=1;l--)t.ellipse(a.x,a.y,i*(l/3),r*(l/3)).fill({color:n,alpha:o/3})}const us=[15234095,15909198,13124911,4030118],wx=16054266;function Qc(t,e,s,i,r=Je,n=!1){Qe(t,e+.22,s+.22,12,5.5,.24);const o=n?0:6;n||ie(t,e+.04,s+.04,.36,.36,6,r.pot);const a=E(e+.22,s+.22,o);t.rect(a.x-1.5,a.y-5,3,5).fill(r.woodDark);const l=.9+i%4*.08;let h=a.y-4;for(let c=0;c<3;c++){const d=(11-c*2.6)*l,u=(13-c*1.5)*l,f=h-u;t.poly([a.x,f,a.x-d,h,a.x,h+2]).fill(r.leafDark),t.poly([a.x,f,a.x+d,h,a.x,h+2]).fill(r.leaf),n&&t.poly([a.x,f,a.x-d*.45,f+u*.45,a.x-d*.15,f+u*.36,a.x,f+u*.48,a.x+d*.2,f+u*.38,a.x+d*.45,f+u*.45]).fill({color:r.white,alpha:.92}),h-=u*.55}}function xx(t,e,s,i,r=Je){Qe(t,e+.25,s+.25,14,6,.24);const n=E(e+.25,s+.25),o=.75+i%5*.09,a=l=>l.map((h,c)=>c%2?n.y+h*o:n.x+h*o);t.poly(a([-12,0,-10,-8,-4,-13,3,-12,9,-7,12,0,4,3,-6,3])).fill(H(r.pot,.78)),t.poly(a([-4,-13,3,-12,9,-7,12,0,4,3,2,-5,-5,-7])).fill(r.pot),t.poly(a([-10,-8,-4,-13,3,-12,9,-7,4,-8.5,0,-7,-5,-8.5])).fill(wx)}function Sx(t,e,s,i){Qe(t,e+.85/2,s+.6/2,24,10,.24);const a=E(e,s),l=E(e+.85,s),h=E(e+.85,s+.6),c=E(e,s+.6),d=E(e+.04,s+.6/2,17),u=E(e+.85-.04,s+.6/2,17);t.poly([a.x,a.y,l.x,l.y,u.x,u.y,d.x,d.y]).fill(H(i,.6)),t.poly([l.x,l.y,h.x,h.y,u.x,u.y]).fill(H(i,.8));const f=E(e+.85,s+.6/2),p=E(e+.85,s+.6*.3),_=E(e+.85,s+.6*.7),g=E(e+.85-.02,s+.6/2,17*.7);t.poly([p.x,p.y,g.x,g.y,_.x,_.y]).fill(H(i,.42)),t.moveTo(f.x,f.y).lineTo(g.x,g.y).stroke({color:H(i,.6),width:.8}),t.poly([d.x,d.y,u.x,u.y,h.x,h.y,c.x,c.y]).fill(i),t.moveTo(d.x,d.y).lineTo(u.x,u.y).stroke({color:H(i,1.25),width:1.2});for(const[m,y]of[[d,e-.18],[u,e+.85+.18]]){const v=E(y,s+.3);t.moveTo(m.x,m.y).lineTo(v.x,v.y).stroke({color:13685986,width:.6,alpha:.8})}}function Cx(t,e,s,i){Qe(t,e+.28,s+.24,15,7,.22);const r=(n,o,a,l,h,c,d=0)=>{ie(t,n,o,a,l,h,c,d);for(const p of[.28,.72]){const _=n+a*p,g=E(_,o+l,d),m=E(_,o+l,d+h),y=E(_,o,d+h);t.moveTo(g.x,g.y).lineTo(m.x,m.y).lineTo(y.x,y.y).stroke({color:H(c,.5),width:1.2})}const u=E(n+.05,o+l/2,d+h),f=E(n+a-.05,o+l/2,d+h);t.moveTo(u.x,u.y).lineTo(f.x,f.y).stroke({color:H(c,1.3),width:.8})};r(e,s+.02,.55,.21,8,us[i%us.length]),r(e,s+.24,.55,.21,8,us[(i+1)%us.length]),r(e+.05,s+.1,.45,.24,7,us[(i+2)%us.length],8)}function kx(t,e,s,i,r=Je){Qe(t,e+.45,s+.25,22,8,.22),ie(t,e,s,.9,.1,30,r.woodDark),ie(t,e+.04,s+.1,.82,.2,2,r.wood,13);const n=s+.12;for(const a of[e+.2,e+.55]){const l=E(a,s+.24,0),h=E(a+.08,n,12);t.moveTo(l.x,l.y).lineTo(h.x,h.y).stroke({color:H(r.metal,.75),width:1.6}),t.moveTo(h.x-4,h.y+1).lineTo(h.x+4,h.y-1.5).stroke({color:r.metal,width:1.8})}for(const[a,l]of[e+.28,e+.62].entries()){const h=E(l,s+.2,15),c=us[(i+a*3)%us.length];t.moveTo(h.x-4.5,h.y).arc(h.x,h.y,4.5,Math.PI,Math.PI*2).closePath().fill(c).stroke({color:H(c,.6),width:.8}),t.ellipse(h.x,h.y,5.2,1.2).fill(H(c,.75))}const o=[14701373,4171734,8115081,15909198];for(let a=0;a<3;a++){const l=E(e+.18+a*.27,n,23),h=o[(i+a)%o.length];t.ellipse(l.x,l.y+1,4.6,5.2).stroke({color:h,width:2.2}),t.ellipse(l.x,l.y+1,2.8,3.4).stroke({color:H(h,.8),width:1.2}),t.moveTo(l.x+1,l.y+5.5).lineTo(l.x+2,l.y+10).stroke({color:h,width:1.4}),t.circle(l.x,l.y-4.4,1).fill(r.metal)}ie(t,e,s,.06,.3,30,r.wood),ie(t,e+.84,s,.06,.3,30,r.wood)}function Mx(t,e,s,i,r=Je){Qe(t,e+.6,s+.3,28,9,.22),ie(t,e,s+.1,1.2,.4,9,r.woodDark);for(const l of[3,6]){const h=E(e+.05,s+.5,l),c=E(e+1.15,s+.5,l);t.moveTo(h.x,h.y).lineTo(c.x,c.y).stroke({color:H(r.woodDark,.7),width:.8})}const n=E(e+1.2,s+.3,4.5);t.ellipse(n.x,n.y,6,5.5).fill(r.wood).stroke({color:r.woodDark,width:1}),t.ellipse(n.x,n.y,3,2.7).stroke({color:H(r.wood,.75),width:.8}),st(t,e+.3,s+.1,.55,.4,9.05).fill(i),bs(t,e+.3,e+.85,s+.5,2,9.05).fill(H(i,.75));const o=E(e+.3,s+.5,4),a=E(e+.85,s+.5,4);t.moveTo(o.x,o.y).lineTo(a.x,a.y).stroke({color:H(i,1.3),width:1,alpha:.7})}function Tx(t,e,s,i,r=Je){const n=E(e+.3,s+.2);t.ellipse(n.x,n.y,30,15).fill({color:i,alpha:.08}),t.ellipse(n.x,n.y,18,9).fill({color:i,alpha:.12}),t.ellipse(n.x,n.y,9,4.5).fill(2761248);for(let o=0;o<10;o++){const a=o/10*Math.PI*2;t.ellipse(n.x+Math.cos(a)*11,n.y+Math.sin(a)*5.5-1.2,3.2,2.3).fill(o%2?r.pot:H(r.pot,.8))}t.moveTo(n.x-7,n.y+1).lineTo(n.x+6,n.y-3).stroke({color:r.woodDark,width:3,cap:"round"}),t.moveTo(n.x-6,n.y-2.5).lineTo(n.x+7,n.y+1.5).stroke({color:H(r.woodDark,1.2),width:3,cap:"round"})}function Ex(t){t.poly([-6,0,-5,-7,-2,-4,0,-15,2.5,-6,5,-9,6,0]).fill({color:16747586,alpha:.95}),t.poly([-3.5,0,-1.5,-6,.5,-9.5,2.5,-4,3.5,0]).fill(16765286),t.ellipse(0,-1,3,1.5).fill(16773840)}function Px(t,e,s,i,r,n,o,a=Je){Gt(t,e,s,i,r,n).fill(a.paper).stroke({color:a.woodDark,width:2});const l=i-s,h=n-r,c=(_,g)=>E(e,s+_*l,r+g*h),d=.55+(o>>3)%15/100,u=.66;for(let _=1;_<=4;_++){const g=[];for(let m=0;m<14;m++){const y=m/14*Math.PI*2,v=1+((o>>m+_&3)-1.5)*.06,b=c(d+Math.cos(y)*_*.09*v,u+Math.sin(y)*_*.14*v);g.push(b.x,b.y)}t.poly(g).stroke({color:10521194,width:.8,alpha:.75})}const f=[c(.1,.12),c(.3,.3),c(.22,.48),c(.42,.56),c(d,u)];f.forEach((_,g)=>{if(g){const m=f[g-1];t.moveTo(m.x,m.y).lineTo(_.x,_.y).stroke({color:14239759,width:1.2})}g<f.length-1&&t.circle(_.x,_.y,1.3).fill(2764351)});const p=f[f.length-1];t.moveTo(p.x,p.y).lineTo(p.x,p.y-6).stroke({color:2764351,width:.8}),t.poly([p.x,p.y-6,p.x-4,p.y-5,p.x,p.y-3.5]).fill(14239759)}function Ax(t,e,s,i,r,n,o,a=Je){Gt(t,e,s,i,r,n).fill(ur(o,1053210,.55)).stroke({color:a.woodDark,width:1.5});const l=i-s,h=n-r,c=(p,_)=>E(e,s+p*l,r+_*h),d=c(.3,.72);t.circle(d.x,d.y,2.4).fill({color:16767392,alpha:.9});const u=[c(.06,.1),c(.3,.45),c(.42,.36),c(.64,.82),c(.82,.5),c(.94,.4),c(.94,.1)];t.poly(u.flatMap(p=>[p.x,p.y])).fill(4016732);const f=[c(.64,.82),c(.56,.62),c(.6,.66),c(.66,.6),c(.73,.66)];t.poly(f.flatMap(p=>[p.x,p.y])).fill(a.white)}const Se={w:.6,d:.84,sheet:{x:.15,y:.47,w:.3,d:.33},slotY:.443,slotZ:16.2,trayZ:11.9,sheetH:.6,stackMax:6},Mo=14869997,_n=16513781,wh=11841700;function Rx(t,e,s,i=Je){Qe(t,e+.3,s+.42,18,9,.24),ie(t,e,s,.6,.46,11,i.metal);const r=E(e+.3,s+.46,2),n=E(e+.3,s+.46,9.5);t.moveTo(r.x,r.y).lineTo(n.x,n.y).stroke({color:H(i.metal,.55),width:1});for(const c of[.25,.35]){const d=E(e+c,s+.46,7);t.circle(d.x,d.y,.9).fill(13685986)}ie(t,e+.02,s+.02,.56,.42,9,Mo,11),st(t,e+.1,s+.05,.36,.16,20.02).fill(H(Mo,.72));const o=E(e+.13,s+.15,20),a=E(e+.43,s+.15,20),l=E(e+.43,s+.07,28),h=E(e+.13,s+.07,28);t.poly([o.x,o.y,a.x,a.y,l.x,l.y,h.x,h.y]).fill(_n).stroke({color:wh,width:.8}),st(t,e+.4,s+.27,.15,.14,20.02).fill(2764351),bs(t,e+.1,e+.5,s+Se.slotY,Se.slotZ-.9,Se.slotZ+.9).fill(1842987),ie(t,e+.1,s+.44,.4,.4,.7,H(Mo,.82),Se.trayZ-.7)}function ed(t,e,s,i,r){const n=E(e+.49,s+.34,20.3);r&&t.ellipse(n.x,n.y,5,2.8).fill({color:i,alpha:.28}),t.ellipse(n.x,n.y,2.2,1.3).fill(i)}function Na(t){return Se.trayZ+Math.min(t,Se.stackMax)*Se.sheetH}function Bx(t,e,s,i){const r=Se.sheet,n=Math.min(i,Se.stackMax);for(let o=0;o<n;o++){const a=(o*7919%5-2)*.01,l=(o*104729%5-2)*.008,h=Na(o+1);st(t,e+r.x+a,s+r.y+l,r.w,r.d,h).fill(o%2?_n:H(_n,.95)).stroke({color:wh,width:.6}),o===n-1&&tp(t,e+r.x+a,s+r.y+l,h,1)}}function Lx(t,e,s,i,r,n){const o=Se.sheet,a=s+Se.slotY+(o.y-Se.slotY)*r,l=Se.slotZ+(n-Se.slotZ)*r;st(t,e+o.x,a,o.w,o.d*i,l).fill(_n).stroke({color:wh,width:.6}),tp(t,e+o.x,a,l,i)}function tp(t,e,s,i,r){const n=[.17,.12,.2,.2,.09,.15],o=[4014678,9080734,3120708,14239759,9080734,9080734];n.forEach((a,l)=>{const h=s+.05+l*.045;if(h>s+Se.sheet.d*r-.02)return;const c=E(e+.04+(l===1||l===4?.03:0),h,i),d=E(e+.04+a,h,i);t.moveTo(c.x,c.y).lineTo(d.x,d.y).stroke({color:o[l],width:.8,alpha:.9})})}function Ix(t,e,s,i,r,n,o=!1){bs(t,e,s,i,r,n).fill(1910592).stroke({color:9344692,width:1.5});const a=(e+s)/2,l=(r+n)/2;if(bs(t,e+.05,s-.05,i,r+2,n-2).fill({color:7320575,alpha:.35}),bs(t,e+.05,s-.05,i,l+2,n-2).fill({color:11130367,alpha:.25}),o){const y=s-e-.1,v=n-r-4,b=(x,M)=>E(e+.05+x*y,i,r+2+M*v),S=[b(0,0),b(0,.3),b(.22,.62),b(.36,.44),b(.6,.86),b(.82,.5),b(1,.38),b(1,0)];t.poly(S.flatMap(x=>[x.x,x.y])).fill({color:4873592,alpha:.9});for(const[x,M]of[[.22,.62],[.6,.86]]){const O=[b(x,M),b(x-.09,M-.2),b(x-.02,M-.14),b(x+.04,M-.2),b(x+.1,M-.18)];t.poly(O.flatMap(B=>[B.x,B.y])).fill({color:16054266,alpha:.9})}}const h=E(a,i,r),c=E(a,i,n);t.moveTo(h.x,h.y).lineTo(c.x,c.y).stroke({color:9344692,width:1});const d=E(e,i,l),u=E(s,i,l);t.moveTo(d.x,d.y).lineTo(u.x,u.y).stroke({color:9344692,width:1});const f=s-e,p=E(e,i,0),_=E(s,i,0),g=E(s+f*.35,i+1.6,.4),m=E(e+f*.35,i+1.6,.4);t.poly([p.x,p.y,_.x,_.y,g.x,g.y,m.x,m.y]).fill({color:12574975,alpha:.05})}function Dx(t,e,s,i,r,n,o,a=Je){Gt(t,e,s,i,r,n).fill(a.white).stroke({color:10133684,width:1.5});const l=[4020864,14711391,2792847,2236962];let h=o;for(let u=0;u<5;u++){const f=s+.12+(h>>2)%60/100*(i-s-.3),p=.12+(h>>8)%40/100*(i-s-.4),_=n-3-u*((n-r-6)/5),g=E(e,f,_),m=E(e,f+p,_);t.moveTo(g.x,g.y).lineTo(m.x,m.y).stroke({color:l[h%l.length],width:1.2,alpha:.85}),h=h*1103515245+12345>>>0}const c=E(e,s,r-1),d=E(e,i,r-1);t.moveTo(c.x,c.y).lineTo(d.x,d.y).stroke({color:10133684,width:2})}function Ox(t,e,s,i,r,n,o){Gt(t,e,s,i,r,n).fill(ur(o,1053210,.5)).stroke({color:10133684,width:1}),Gt(t,e,s+.08,i-.08,r+3,n-3).fill({color:o,alpha:.6})}function Fx(t,e,s,i,r=Je){const n=E(e,s,i);t.circle(n.x,n.y,5).fill(r.white).stroke({color:5593712,width:1}),t.moveTo(n.x,n.y).lineTo(n.x,n.y-3.5).stroke({color:2236962,width:1}),t.moveTo(n.x,n.y).lineTo(n.x+2.5,n.y+1).stroke({color:2236962,width:1})}const Tt=.25,Hr=.15,$x=1.15,Nx=2.6,sp=2.8;function Hx(t,e,s,i,r,n,o){const a=Math.ceil(e/Tt),l=Math.ceil(s/Tt),h=new Uint8Array(a*l);for(let u=0;u<l;u++)for(let f=0;f<a;f++){const p=(f+.5)*Tt,_=(u+.5)*Tt;(p<.25||_<.25||p>e-.2||_>s-.2||i.some(m=>p>m.x-Hr&&p<m.x+m.w+Hr&&_>m.y-Hr&&_<m.y+m.d+Hr))&&(h[u*a+f]=1)}const c={key:t,cols:a,rows:l,blocked:h,machine:r,seats:n,spots:[],members:[]},d=[...r?[r]:[],...n.map(u=>u.stand)];for(let u=.75;u<s-.3;u+=.5)for(let f=.5;f<e-.3;f+=.5)Jx(c,{x:f,y:u},.3)&&(o.some(p=>f>p.x&&f<p.x+p.w&&u>p.y&&u<p.y+p.d)||d.some(p=>Math.hypot(p.x-f,p.y-u)<.6)||c.spots.push({x:f,y:u}));return c}function Wx(t,e){return{room:t,pos:{...e.seat},path:[],goal:{kind:"desk"},walking:!1,hurry:!1,clock:0,until:0,carrying:!1,heading:{x:1,y:0},idle:!1}}function zx(t,e,s){const i=Ha(t,e,!1);Wa(t,e,s,i),t.carrying=i.kind!=="machine"&&Math.random()<.8,t.until=t.clock+Math.random()*ap(i),t.idle=!0}function Gx(t,e,s){const i=t.goal;i.kind==="desk"||i.kind==="machine"&&e.machine||i.kind==="seat"&&i.seat<e.seats.length||i.kind==="spot"&&xh(e,i.at)?t.walking?jr(t,e,s,i,t.hurry):t.pos=mn(i,e,s):(t.goal={kind:"spot",at:{...t.pos}},t.walking=!1,t.path=[],t.until=t.clock)}function Ux(t,e,s,i,r){if(t.clock+=r,i&&!t.idle&&(t.until=t.clock+.7+Math.random()),t.idle=i,!i&&t.goal.kind!=="desk"?jr(t,e,s,{kind:"desk"},!0):i&&t.walking&&t.goal.kind==="desk"&&jr(t,e,s,Ha(t,e,!0),!1),t.walking){let n=(t.hurry?Nx:$x)*r;for(;n>0&&t.path.length;){const o=t.path[0],a=o.x-t.pos.x,l=o.y-t.pos.y,h=Math.hypot(a,l);h>1e-4&&(t.heading={x:a/h,y:l/h}),h<=n?(t.pos={...o},t.path.shift(),n-=h):(t.pos={x:t.pos.x+a/h*n,y:t.pos.y+l/h*n},n=0)}t.path.length||Xx(t);return}t.goal.kind==="desk"&&(t.pos={...s.seat}),t.goal.kind==="machine"&&ip(t)>.64&&(t.carrying=!0),i&&t.clock>=t.until&&jr(t,e,s,Ha(t,e,t.goal.kind==="desk"),!1)}function qx(t,e,s,i){i?(t.goal.kind==="desk"||t.walking)&&(Wa(t,e,s,jx(t,e)),t.carrying=!0):(t.goal.kind!=="desk"||t.walking)&&(Wa(t,e,s,{kind:"desk"}),t.carrying=!1)}function Vx(t){return t.walking?"walk":t.goal.kind==="desk"?"desk":t.goal.kind==="seat"?"sit":"stand"}function Yx(t){if(!t.walking)return t.goal.kind==="machine"?{back:!0,left:!0}:t.goal.kind==="spot"?{back:!1,left:Math.floor(t.clock/2.4)%2===0}:{back:!1,left:!1};if(t.path.length===1&&t.goal.kind!=="spot"&&t.goal.kind!=="machine")return{back:!1,left:t.heading.x-t.heading.y<0};const e=t.heading.x-t.heading.y;return{back:t.heading.x+t.heading.y<-.05,left:e<0}}function ip(t){return Math.min(1,Math.max(0,1-(t.until-t.clock)/sp))}function Kx(t){return!t||t.goal.kind==="desk"?t!=null&&t.walking?"heading back to the desk":null:"on a break"}function rp(t,e){return e.members.map(s=>s.roam).filter(s=>!!s&&s!==t&&s.room===e.key)}function Ha(t,e,s){const i=rp(t,e),r=!!e.machine&&!i.some(h=>h.goal.kind==="machine");if(s&&r)return{kind:"machine"};const n=[];r&&t.goal.kind!=="machine"&&n.push([{kind:"machine"},t.carrying?.6:4]);const o=t.goal.kind==="seat"?[]:np(t,e,i);o.length&&n.push([{kind:"seat",seat:o[Math.floor(Math.random()*o.length)]},t.carrying?3:1.5]);const a=op(t,e,i);a&&n.push([{kind:"spot",at:a},2]);let l=Math.random()*n.reduce((h,[,c])=>h+c,0);for(const[h,c]of n)if((l-=c)<=0)return h;return{kind:"spot",at:{...t.pos}}}function jx(t,e){const s=rp(t,e),i=np(t,e,s)[0];if(i!==void 0)return{kind:"seat",seat:i};if(e.machine&&!s.some(n=>n.goal.kind==="machine"))return{kind:"machine"};const r=op(t,e,s);return r?{kind:"spot",at:r}:{kind:"desk"}}function np(t,e,s){return e.seats.map((i,r)=>r).filter(i=>!s.some(r=>r.goal.kind==="seat"&&r.goal.seat===i))}function op(t,e,s){const i=(n,o,a)=>Math.hypot(n.x-o.x,n.y-o.y)>a,r=e.spots.filter(n=>i(n,t.pos,1.2)&&s.every(o=>i(o.pos,n,.9)&&(o.goal.kind!=="spot"||i(o.goal.at,n,.9))));return r.length?r[Math.floor(Math.random()*r.length)]:null}function ap(t){return t.kind==="machine"?sp:t.kind==="seat"?8+Math.random()*9:t.kind==="spot"?3+Math.random()*4:1}function mn(t,e,s){switch(t.kind){case"desk":return{...s.seat};case"machine":return{...e.machine};case"seat":return{...e.seats[t.seat].at};case"spot":return{...t.at}}}function Wa(t,e,s,i){t.goal=i,t.walking=!1,t.path=[],t.pos=mn(i,e,s),t.until=t.clock}function jr(t,e,s,i,r){var l;const n=t.walking?null:t.goal.kind==="desk"?s.stand:t.goal.kind==="seat"?((l=e.seats[t.goal.seat])==null?void 0:l.stand)??null:null,o=n??t.pos,a=i.kind==="desk"?s.stand:i.kind==="seat"?e.seats[i.seat].stand:mn(i,e,s);t.path=[...n?[n]:[],...eS(e,o,a)],(i.kind==="desk"||i.kind==="seat")&&t.path.push(mn(i,e,s)),t.goal=i,t.walking=!0,t.hurry=r}function Xx(t){t.walking=!1,t.until=t.clock+ap(t.goal),t.goal.kind==="desk"&&(t.carrying=!1)}function Zx(t,e){const s=Math.min(t.cols-1,Math.max(0,Math.floor(e.x/Tt)));return Math.min(t.rows-1,Math.max(0,Math.floor(e.y/Tt)))*t.cols+s}function hp(t,e){return{x:(e%t.cols+.5)*Tt,y:(Math.floor(e/t.cols)+.5)*Tt}}function xh(t,e){return!t.blocked[Zx(t,e)]}function Jx(t,e,s){const i=Math.max(1,Math.ceil(s/Tt));for(let r=-i;r<=i;r++)for(let n=-i;n<=i;n++)if(!xh(t,{x:e.x+n*s/i,y:e.y+r*s/i}))return!1;return!0}function td(t,e){const s=Math.floor(e.x/Tt),i=Math.floor(e.y/Tt);let r=-1,n=1/0;for(let o=0;o<=8&&r<0;o++)for(let a=i-o;a<=i+o;a++)for(let l=s-o;l<=s+o;l++){if(Math.max(Math.abs(l-s),Math.abs(a-i))!==o||l<0||a<0||l>=t.cols||a>=t.rows||t.blocked[a*t.cols+l])continue;const h=a*t.cols+l,c=hp(t,h),d=(c.x-e.x)**2+(c.y-e.y)**2;d<n&&(n=d,r=h)}return r}function Qx(t,e,s){const i=Math.ceil(Math.hypot(s.x-e.x,s.y-e.y)/(Tt/2));for(let r=1;r<i;r++)if(!xh(t,{x:e.x+(s.x-e.x)*r/i,y:e.y+(s.y-e.y)*r/i}))return!1;return!0}function eS(t,e,s){const i=td(t,e),r=td(t,s),n=i>=0&&r>=0?sS(t,i,r):null;if(!n)return[s];const o=[e,...n.map(l=>hp(t,l)),s],a=[];for(let l=0;l<o.length-1;){let h=o.length-1;for(;h>l+1&&!Qx(t,o[l],o[h]);)h--;a.push(o[h]),l=h}return a}const tS=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]];function sS(t,e,s){const{cols:i,rows:r,blocked:n}=t,o=new Float32Array(i*r).fill(1/0),a=new Int32Array(i*r).fill(-1),l=new Uint8Array(i*r),h=s%i,c=Math.floor(s/i),d=p=>{const _=Math.abs(p%i-h),g=Math.abs(Math.floor(p/i)-c);return _+g+(Math.SQRT2-2)*Math.min(_,g)},u=new iS;for(o[e]=0,u.push(d(e),e);u.size;){const p=u.pop();if(p===s)break;if(l[p])continue;l[p]=1;const _=p%i,g=(p-_)/i;for(const[m,y]of tS){const v=_+m,b=g+y;if(v<0||b<0||v>=i||b>=r||n[b*i+v]||m&&y&&(n[g*i+v]||n[b*i+_]))continue;const S=b*i+v,x=o[p]+(m&&y?Math.SQRT2:1);x<o[S]&&(o[S]=x,a[S]=p,u.push(x+d(S),S))}}if(e!==s&&a[s]===-1)return null;const f=[s];for(let p=s;p!==e;p=a[p])f.push(a[p]);return f.reverse()}class iS{constructor(){w(this,"keys",[]);w(this,"vals",[])}get size(){return this.vals.length}push(e,s){const{keys:i,vals:r}=this;let n=r.length;for(i.push(e),r.push(s);n>0;){const o=n-1>>1;if(i[o]<=e)break;i[n]=i[o],r[n]=r[o],n=o}i[n]=e,r[n]=s}pop(){const{keys:e,vals:s}=this,i=s[0],r=e.pop(),n=s.pop();if(s.length){let o=0;for(;;){const a=o*2+1,l=a+1;let h=o,c=r;if(a<s.length&&e[a]<c&&(h=a,c=e[a]),l<s.length&&e[l]<c&&(h=l),h===o)break;e[o]=e[h],s[o]=s[h],o=h}e[o]=r,s[o]=n}return i}}class rS{constructor(e){w(this,"runtime","");this.tip=e}hide(){this.tip.style.display="none"}pane(e,s,i,r){const n=e.agent?Kx(s):null,o=e.agent?`<b>${se(e.agent)}</b> · ${e.agent_status}${n?` · ${n}`:""}`:"<b>shell</b> · no agent",a=e.context?`
339
+ context: ${Va(e.context)}`:"";this.place(`${o}
340
+ ${se(e.title)}${a}
341
+ <span class="muted">${se(nS(e.cwd??""))}
342
+ ${e.pane_id}${e.focused?` · focused in ${se(this.runtime)}`:""}</span>`,e.agent_status,i,r)}printer(e,s,i,r){const n=(e==null?void 0:e.printedCount(s))??0,o=(e==null?void 0:e.unread(s))??0,a=e==null?void 0:e.latest(s),l=`<b>Printer</b> · ${n?`${n} sheet${n===1?"":"s"}`:"nothing printed yet"}${o?` · ${o} new`:""}`,h=a?`
343
+ latest: ${se(a.path)} <span class="add">+${a.added}</span> <span class="del">−${a.removed}</span>
344
+ <span class="muted">click to read, or to see everything uncommitted</span>`:`
345
+ Prints a sheet each time a file here changes.
346
+ <span class="muted">click to see everything uncommitted</span>`;this.place(l+h,"print",i,r)}build(e,s,i){this.place(e,"build",s,i)}place(e,s,i,r){this.tip.dataset.status=s,this.tip.innerHTML=e,this.tip.style.display="block";const n=14;this.tip.style.left=`${Math.min(i+n,innerWidth-this.tip.offsetWidth-n)}px`,this.tip.style.top=`${Math.min(r+n,innerHeight-this.tip.offsetHeight-n)}px`}}function nS(t){return t.replace(/^\/home\/[^/]+/,"~")}class oS{constructor(e,s,i,r){w(this,"camTarget",null);w(this,"fitted",!1);w(this,"arrival",null);this.app=e,this.lift=s,this.world=i,this.motion=r}attach(){const e=this.app.stage;e.eventMode="static",e.hitArea={contains:()=>!0};let s=null;e.on("pointerdown",i=>{s={x:i.global.x,y:i.global.y,wx:this.world.x,wy:this.world.y},this.camTarget=null}),e.on("pointerup",()=>s=null),e.on("pointerupoutside",()=>s=null),e.on("pointermove",i=>{if(!s)return;const r=i.global.x-s.x,n=i.global.y-s.y;this.world.x=s.wx+r,this.world.y=s.wy+n}),this.app.canvas.addEventListener("wheel",i=>{i.preventDefault(),this.camTarget=null,this.zoomAt(Math.exp(-i.deltaY*.001),i.offsetX,i.offsetY)},{passive:!1})}zoomAt(e,s=this.app.screen.width/2,i=this.app.screen.height/2){const r=Math.min(3,Math.max(.3,this.world.scale.x*e)),n=(s-this.world.x)/this.world.scale.x,o=(i-this.world.y)/this.world.scale.y;this.world.scale.set(r),this.world.x=s-n*r,this.world.y=i-o*r}fit(e){if(!e||e.w===0)return;const s=[E(-1,-1),E(e.w+1,-1),E(e.w+1,e.h+1),E(-1,e.h+1)],i=Math.min(...s.map(h=>h.x)),r=Math.max(...s.map(h=>h.x)),n=Math.min(...s.map(h=>h.y))-90,o=Math.max(...s.map(h=>h.y))+40,a=this.viewport(),l=Math.min(2,Math.max(.3,Math.min(a.w/(r-i+60),a.h/(o-n+60))));this.camTarget={scale:l,x:a.cx-(i+r)/2*l,y:a.cy-(n+o)/2*l}}viewport(){const e=this.app.screen.width,s=this.app.screen.height,i=u=>{const f=document.getElementById(u);return f&&getComputedStyle(f).opacity!=="0"&&getComputedStyle(f).display!=="none"?f.getBoundingClientRect():null},r=i("roster"),n=r&&r.right<e*.5?r.right+8:0,o=i("floors"),a=document.body.classList.contains("panel-open")?document.getElementById("panel").offsetWidth:o&&e>=900&&o.left>e*.5?e-o.left+8:0,l=52,h=40,c=Math.max(200,e-n-a),d=Math.max(200,s-l-h);return{w:c,h:d,cx:n+c/2,cy:l+d/2}}focus(e){const s=Math.max(this.world.scale.x,1.3),i=this.viewport();this.camTarget={scale:s,x:i.cx-e.x*s,y:i.cy-(e.y+20)*s}}lookAt(e){const s=this.viewport(),i=Math.max(1.3,this.world.scale.x);this.camTarget={scale:i,x:s.cx-e.x*i,y:s.cy-e.y*i}}newFloor(e){this.fitted=!1,this.camTarget=null,e!==0&&(this.arrival={at:performance.now(),dir:e})}settle(e){!this.fitted&&e.w>0&&(this.fit(e),this.camTarget&&(this.world.scale.set(this.camTarget.scale),this.world.position.set(this.camTarget.x,this.camTarget.y),this.camTarget=null),this.fitted=!0)}tick(e,s){if(this.arrival){const i=this.motion.reduced?1:Math.min(1,(s-this.arrival.at)/420),r=1-(1-i)**3;this.lift.alpha=r,this.lift.y=(1-r)*-60*this.arrival.dir,i>=1&&(this.arrival=null,this.lift.y=0,this.lift.alpha=1)}if(this.camTarget){const i=this.motion.reduced?1:1-Math.exp(-e*6),r=this.camTarget,n=this.world.scale.x+(r.scale-this.world.scale.x)*i;this.world.scale.set(n),this.world.x+=(r.x-this.world.x)*i,this.world.y+=(r.y-this.world.y)*i,Math.abs(r.x-this.world.x)<.5&&Math.abs(r.y-this.world.y)<.5&&Math.abs(r.scale-n)<.001&&(this.camTarget=null)}}}const aS=new pt({fill:1710618,fontSize:11,fontFamily:"ui-sans-serif, system-ui, sans-serif",fontWeight:"800"}),sd=1700,hS=3,lS=52,id={idle:4177770,printing:9306024,unread:16765286};class cS{constructor(e,s,i,r,n,o){w(this,"nodes",[]);w(this,"printJobs",new Map);this.app=e,this.world=s,this.objects=i,this.look=r,this.motion=n,this.prints=o}clear(){this.nodes=[]}add(e,s,i){const r=e.x+e.w-1.55,n=e.y+.2,o=new ce,a=new ce,l=new ee;Rx(l,r,n,this.look.materials);const h=new ee,c=new ee,d=new ee;a.addChild(l,h,c,d);const u=new ce,f=new ee,p=new zt({text:"",style:aS});p.anchor.set(0,.5),u.addChild(f,p);const _=E(r+Se.w/2,n+.3,44);u.position.set(_.x,_.y),u.visible=!1,o.addChild(a,u),o.zIndex=ms(r,n)*10,o.eventMode="static",o.interactiveChildren=!1,o.cursor="pointer",o.hitArea=dS(r,n);const g=e.workspace.label||e.workspace.workspace_id,m={key:s,room:e.workspace.workspace_id,label:g,at:{x:r,y:n},root:o,body:a,stack:h,sheet:c,light:d,badge:u,badgeBg:f,badgeText:p,badgeY:_.y,shown:-1,unread:-1,lit:""};this.objects.addChild(o),this.nodes.push(m),i.push({x:r-e.x,y:n-e.y,w:Se.w,d:Se.d}),this.paint(m,this.motion.reduced?0:performance.now())}tray(e,s){const i=this.nodes.find(a=>a.key===e&&a.room===s)??this.nodes.find(a=>a.key===e);if(!i)return null;const r=Se.sheet,n=this.world.toGlobal(E(i.at.x+r.x+r.w/2,i.at.y+r.y+r.d/2,Na(i.shown))),o=this.app.canvas.getBoundingClientRect();return{x:o.left+n.x,y:o.top+n.y,scale:this.world.scale.x}}tick(e){const s=this.prints();if(!s)return;const i=new Set;for(const r of this.nodes){if(i.has(r.key))continue;if(i.add(r.key),this.motion.reduced){this.printJobs.delete(r.key),s.done(r.key,!0);continue}const n=this.printJobs.get(r.key);if(n!==void 0&&e-n>=sd&&(s.done(r.key),this.printJobs.delete(r.key)),!this.printJobs.has(r.key)&&s.queuedCount(r.key)>0){for(;s.queuedCount(r.key)>hS;)s.done(r.key);this.printJobs.set(r.key,e)}}for(const r of this.nodes)this.paint(r,e)}paint(e,s){const i=this.prints(),r=(i==null?void 0:i.printedCount(e.key))??0;r!==e.shown&&(e.shown=r,e.stack.clear(),Bx(e.stack,e.at.x,e.at.y,r));const n=this.printJobs.get(e.key);if(e.sheet.clear(),e.body.x=0,n!==void 0){const l=Math.min(1,(s-n)/sd),h=Math.min(1,l/.75),c=l<=.75?0:((l-.75)/.25)**2;Lx(e.sheet,e.at.x,e.at.y,h,c,Na(r+1)),l<.75&&(e.body.x=Math.sin(s/18)*.5)}const o=(i==null?void 0:i.unread(e.key))??0,a=n!==void 0?Math.floor(s/160)%2?"printing":"idle":o>0?this.motion.reduced||Math.floor(s/700)%2?"unread":"dim":"idle";if(a!==e.lit&&(e.lit=a,e.light.clear(),a==="dim"?ed(e.light,e.at.x,e.at.y,H(id.unread,.55),!1):ed(e.light,e.at.x,e.at.y,id[a],a!=="idle")),o!==e.unread){e.unread=o,e.badge.visible=o>0,e.badgeText.text=String(o);const l=le(this.look.theme.palette.accent),h=25+e.badgeText.width;e.badgeBg.clear(),e.badgeBg.roundRect(-h/2,-10,h,20,6).fill(l).stroke({color:H(l,.6),width:1.5}),e.badgeBg.poly([-4,9,4,9,-1,15]).fill(l),e.badgeBg.rect(-h/2+6,-6.5,9,12).fill(16513781).stroke({color:H(l,.5),width:1});for(const[c,d]of[[-3.5,5],[-1,3.5],[1.5,5]])e.badgeBg.rect(-h/2+8,c,d,1).fill(6975360);e.badgeText.position.set(-h/2+18,.5)}e.badge.visible&&(e.badge.y=e.badgeY-Math.abs(Math.sin(s/320))*4)}}function dS(t,e){const s=t-.05,i=e-.05,r=t+Se.w+.05,n=e+Se.d+.05,o=lS,a=E(s,i),l=E(r,i),h=E(r,n),c=E(s,n);return new vs([a.x,a.y-o,l.x,l.y-o,l.x,l.y,h.x,h.y,c.x,c.y,c.x,c.y-o])}const nr={working:5953658,idle:9417983,blocked:16739179,done:16765286,unknown:8028051},rd={claude:14251863,codex:3065014,gemini:7306231,cursor:14737632,copilot:10189823,opencode:16032353,aider:8115081};function lp(t){return t?rd[t]?rd[t]:4210752+(hi(t)&12566463):10133684}const uS=new pt({fill:1118481,fontSize:9,fontWeight:"700",fontFamily:"ui-sans-serif, system-ui, sans-serif",letterSpacing:.5}),fS=new pt({fill:1118481,fontSize:13,fontWeight:"800",fontFamily:"ui-sans-serif, system-ui, sans-serif"}),pS=new pt({fill:5953658,fontSize:10,fontFamily:"ui-monospace, monospace"});function cp(t,e,s,i,r){const n=new ee;Qe(n,e.x+.5,e.y+.45,30,12,.22),ie(n,e.x,e.y,1,.7,14,i?r.wood:H(r.wood,.85)),ie(n,e.x+.44,e.y+.22,.12,.1,5,2764090,14);const o=e.x+.16,a=e.x+.84,l=e.y+.24,h=19,c=39;bs(n,o,a,l,h,c).fill(1119003).stroke({color:4475494,width:1}),ie(n,e.x+.28,e.y+.48,.44,.14,2,3817301,14),s&1&&ie(n,e.x+.86,e.y+.5,.11,.11,6,s&2?r.white:14251863,14),s&4&&ie(n,e.x+.04,e.y+.42,.22,.2,1,r.paper,14),t.addChild(n);const d=new ee;return t.addChild(d),{screen:d,palette:r,screenRect:{x0:o+.03,x1:a-.03,y:l-.01,z0:h+1.5,z1:c-1.5}}}function dp(t,e,s){const i=t.screen,r=t.screenRect;i.clear();const n=e==="off"?8028051:nr[e];bs(i,r.x0,r.x1,r.y,r.z0,r.z1).fill(ur(t.palette.screenOff,n,e==="off"?.06:.28));const o=r.z1-r.z0,a=r.x1-r.x0,l=(h,c,d)=>{const u=r.z0+2+h*(o-4),f=E(r.x0+.04,r.y,u),p=E(r.x0+.04+c*(a-.08),r.y,u);i.moveTo(f.x,f.y).lineTo(p.x,p.y).stroke({color:n,width:1.4,alpha:d})};if(e==="working"){for(let h=0;h<5;h++){const c=(h/5+s*.35)%1;l(1-c,.35+h*37%60/100,.9-c*.5)}i.alpha=.92+Math.sin(s*40)*.04}else if(e==="idle"||e==="done")l(.85,.6,.6),l(.65,.4,.5),l(.45,.7,.4),Math.floor(s*2)%2===0&&l(.2,.08,.9),i.alpha=1;else if(e==="blocked"){if(l(.8,.5,.5),l(.6,.65,.5),Math.floor(s*3)%2===0){const h=r.z0+o*.3,c=E(r.x0+.04,r.y,h),d=E(r.x1-.04,r.y,h);i.moveTo(c.x,c.y).lineTo(d.x,d.y).stroke({color:n,width:3,alpha:.9})}i.alpha=1}else Math.floor(s*1.5)%2===0&&l(.15,.08,.7),i.alpha=1}function _S(t,e,s=Je){const i=new ce,r=hi(t.pane.pane_id),n=cp(i,t,r,!1,s),o=new ee;ie(o,t.x+.25,t.y-.7,.5,.45,8,s.chair,4),ie(o,t.x+.25,t.y-.7,.5,.1,22,H(s.chair,1.15),4),i.addChildAt(o,0);const a=up("shell",10133684,t);i.addChild(a),i.zIndex=ms(t.x,t.y)*10,e.roam=void 0;const l=E(t.x+.5,t.y+.24,39);return{root:i,layers:[i],person:null,desk:t,state:e,anchor:{x:l.x,y:l.y-14},tick(h){e.phase+=h,dp(n,"off",e.phase)}}}function up(t,e,s,i=null){const r=new ce,n=new zt({text:t.toUpperCase(),style:uS});n.anchor.set(.5);const o=new ee,a=n.width+10;o.roundRect(-a/2,-8,a,16,4).fill({color:e,alpha:.95}).stroke({color:H(e,.6),width:1}),r.addChild(o,n),i&&r.addChild(mS(i,Math.max(a,36)));const l=E(s.x+.5,s.y+.95);return r.position.set(l.x,l.y),r}function mS(t,e){const s=new ee,i=11,r=5;s.roundRect(-e/2,i,e,r,2.5).fill({color:987416,alpha:.9}).stroke({color:3817301,width:1});const n=(e-2)*Ua(t);return n>0&&s.roundRect(-e/2+1,i+1,Math.max(2,n),r-2,1.5).fill(Ap[qa(t)]),s}const Es=6,nd=1908521,od=[14711391,8499866,10011097,15912079,15625293],ad=[4020864,3100495,7032634,4869737,8335151],hd=[14701373,4171734,15909198,8115081],gS=14257195,yS=3159103,vS=2829883,bS=15909198,To=15265522,wS=3107722,za=9147809;function xS(t,e,s,i,r,n,o,a,l){t.clear();const h=-o,c=l*1.2;e.model==="climber"?SS(t,e,s,i,r,n,h,a,c):e.model==="suit"?CS(t,e,s,i,r,h,a,c):e.model==="robot"?(t.roundRect(-9,h-26,18,22,4).fill(i).stroke({color:H(i,.6),width:1}),t.roundRect(-11,h-43,22,18,5).fill(i).stroke({color:H(i,.6),width:1}),a?t.roundRect(-6,h-38,12,7,2).fill(H(i,.85)):(t.roundRect(-8+c,h-39,16,9,3).fill(le(e.visor)),t.circle(-4+c,h-35,1.5).fill(s),t.circle(4+c,h-35,1.5).fill(s),t.roundRect(-5,h-20,10,7,2).fill(s)),t.moveTo(0,h-43).lineTo(0,h-48).stroke({color:i,width:2}),t.circle(0,h-49,2).fill(s)):(t.ellipse(0,h-15,9.5,12).fill(s).stroke({color:H(s,.6),width:1}),t.circle(0,h-33,7.5).fill(i).stroke({color:H(i,.7),width:1}),a?t.circle(0,h-33.5,7.7).fill(r):(t.moveTo(-8,h-34).arc(0,h-34,8,Math.PI,Math.PI*2).closePath().fill(r),t.circle(-2.6+c,h-33,1).fill(2236962),t.circle(2.6+c,h-33,1).fill(2236962)))}function SS(t,e,s,i,r,n,o,a,l){const h=le(e.shell),c=le(e.visor),d=()=>{t.ellipse(0,o-15,10.5,12.5).fill(s).stroke({color:H(s,.6),width:1});for(const f of[-19,-11])t.moveTo(-9.6,o+f).quadraticCurveTo(0,o+f+2.5,9.6,o+f).stroke({color:H(s,.78),width:1})},u=()=>{t.moveTo(-8.8,o-34.5).arc(0,o-34.5,8.8,Math.PI,Math.PI*2).closePath().fill(h).stroke({color:H(h,.6),width:1}),t.roundRect(-9.6,o-35.6,19.2,2.3,1).fill(H(h,.8))};if(a){d(),t.circle(0,o-33,7.5).fill(r),u(),t.moveTo(5,o-7).lineTo(8.5,o-37).stroke({color:za,width:1.6}),t.moveTo(4.5,o-37.5).lineTo(12,o-35.5).stroke({color:H(za,1.2),width:2}),t.roundRect(-9,o-28,18,23,4).fill(n.pack).stroke({color:H(n.pack,.6),width:1}),t.roundRect(-8,o-29.5,16,6.5,3).fill(H(n.pack,1.18)),t.ellipse(0,o-15,6.5,3.2).stroke({color:n.rope,width:2.2}),t.ellipse(0,o-15,4,1.8).stroke({color:H(n.rope,.8),width:1}),t.moveTo(-5,o-8).lineTo(5,o-8).stroke({color:H(n.pack,.6),width:1.4});return}t.roundRect(-10.5,o-30.5,21,16,4).fill(n.pack).stroke({color:H(n.pack,.6),width:1}),d(),t.moveTo(0,o-26).lineTo(0,o-6).stroke({color:H(s,.6),width:.8}),t.moveTo(-7.5,o-24).lineTo(6.5,o-8).stroke({color:n.rope,width:2.6,cap:"round"}),t.moveTo(-6.5,o-25).lineTo(7.5,o-9).stroke({color:H(n.rope,.75),width:.8}),t.roundRect(-7.5,o-7.5,15,2.6,1).fill(vS),t.ellipse(-4,o-3.4,1.5,2.2).stroke({color:bS,width:1}),t.circle(0,o-33,7.5).fill(i).stroke({color:H(i,.7),width:1}),t.ellipse(-7,o-31.5,1.6,2.6).fill(r),t.ellipse(7,o-31.5,1.6,2.6).fill(r),u(),t.moveTo(-8.6,o-38.4).lineTo(8.6,o-38.4).stroke({color:1776934,width:1.2}),t.roundRect(-6.4+l,o-40.2,5.6,3.6,1.5).fill(c).stroke({color:1776934,width:.8}),t.roundRect(.8+l,o-40.2,5.6,3.6,1.5).fill(c).stroke({color:1776934,width:.8}),t.circle(-2.6+l,o-31.6,1).fill(2236962),t.circle(2.6+l,o-31.6,1).fill(2236962)}function CS(t,e,s,i,r,n,o,a){const l=le(e.shell),h=le(e.visor),c=H(l,.6);if(t.ellipse(0,n-15,10,12).fill(l).stroke({color:c,width:1}),o){t.moveTo(-4.5,n-26.3).quadraticCurveTo(0,n-24.4,4.5,n-26.3).stroke({color:h,width:1.6}),t.moveTo(0,n-24).lineTo(0,n-3.4).stroke({color:c,width:.8}),t.circle(0,n-33,7.5).fill(i).stroke({color:H(i,.7),width:1}),t.circle(0,n-33.5,7.7).fill(r);return}t.poly([-4.2,n-26.2,4.2,n-26.2,0,n-13]).fill(h),t.poly([-1.3,n-24,1.3,n-24,1.9,n-14.6,0,n-12.4,-1.9,n-14.6]).fill(s).stroke({color:H(s,.6),width:.6}),t.poly([-1.6,n-25.9,1.6,n-25.9,1.1,n-23.7,-1.1,n-23.7]).fill(H(s,.8));for(const d of[-1,1])t.poly([d*4.2,n-26.2,d*6.9,n-20.4,0,n-12.8]).fill(H(l,1.18)).stroke({color:c,width:.8});for(const d of[-1,1])t.poly([d*4.3,n-26.4,d*.4,n-25.4,d*2.5,n-22.6]).fill(h).stroke({color:H(h,.7),width:.6});t.circle(0,n-10.2,.9).fill(c),t.circle(0,n-6.6,.9).fill(c),t.poly([4.4,n-18.6,7.4,n-19,6.2,n-20.8]).fill(s),t.moveTo(4,n-18.4).lineTo(7.9,n-18.9).stroke({color:c,width:.8}),t.circle(0,n-33,7.5).fill(i).stroke({color:H(i,.7),width:1}),t.moveTo(-8,n-34).arc(0,n-34,8,Math.PI,Math.PI*2).closePath().fill(r),t.circle(-2.6+a,n-33,1).fill(2236962),t.circle(2.6+a,n-33,1).fill(2236962)}function ld(t,e,s,i){if(!i){t.ellipse(e,s,2.6,1.5).fill(nd);return}t.ellipse(e-.3,s+.5,3.6,1.7).fill(nd),t.ellipse(e,s-.4,3.1,2).fill(gS)}function kS(t,e,s,i,r=!1){if(e==="sit"){for(const n of[-1,1])t.moveTo(n*3,-9).lineTo(n*3-7,-6).lineTo(n*3-7,2.5).stroke({color:i,width:4,cap:"round",join:"round"}),ld(t,n*3-8,3,r);return}t.ellipse(0,0,9,4).fill({color:0,alpha:.22});for(const n of[-1,1]){const o=s+(n>0?Math.PI:0),a=e==="walk"?Math.max(0,Math.sin(o))*2.5:0,l=n*3+(e==="walk"?Math.cos(o)*1.8:0);t.moveTo(n*3,-11).lineTo(l,-1.5-a).stroke({color:i,width:4,cap:"round"}),ld(t,l,-1-a,r)}}function MS(t,e,s=vu,i=Je,r=!1,n=null){const o=t.pane,a=new ce,l=hi(o.pane_id),h=lp(o.agent),c=s.model==="climber",d=s.model==="robot"?le(s.shell):le(s.skin[l%s.skin.length]),u=le(s.hair[(l>>>4)%s.hair.length]),f=s.model==="robot"?H(d,.72):c?ur(2830656,h,.15):s.model==="suit"?H(le(s.shell),.85):H(h,.42),p=od[(l>>>8)%od.length],_={pack:ad[(l>>>12)%ad.length],rope:hd[(l>>>16)%hd.length]},g=c?yS:d,m=ms(t.x,t.y)*10,y=new ce;y.zIndex=m-2,y.eventMode="none";const v=new ee;Qe(v,t.x+.5,t.y-.45,16,7,.25),ie(v,t.x+.25,t.y-.7,.5,.45,8,i.chair,4),ie(v,t.x+.25,t.y-.7,.5,.1,22,H(i.chair,1.15),4),y.addChild(v),a.zIndex=m;const b=(n==null?void 0:n.origin)??{x:0,y:0},S={seat:{x:t.x+.5-b.x,y:t.y-.48-b.y},stand:{x:t.x-.25-b.x,y:t.y-.45-b.y}};n&&(!e.roam||e.roam.room!==n.lounge.key?(e.roam=Wx(n.lounge.key,S),e.status==="idle"&&e.lastChange===0&&zx(e.roam,n.lounge,S)):Gx(e.roam,n.lounge,S));const x=new ce;x.hitArea=new Ee(-13,-60,26,62),x.eventMode="none";const M=new ee,O=new ee,B=new ee;x.addChild(M,O,B);const I=E(t.x+.5,t.y-.48),L=cp(a,t,l,!0,i);a.addChild(up(o.agent??"agent",h,t,o.context));const C=new ce,k=new ee,P=new zt({text:"",style:fS});P.anchor.set(.5),C.addChild(k,P),C.position.set(16,-54),x.addChild(C);const $=new ce;a.addChild($);const T=Array.from({length:3},()=>{const z=new zt({text:"",style:pS});return z.anchor.set(.5),$.addChild(z),z});let R=null;const F=()=>{const z=e.status,K=nr[z];k.clear(),k.roundRect(-11,-11,22,22,6).fill(K).stroke({color:H(K,.6),width:1.5}),k.poly([-4,10,4,10,-2,16]).fill(K),P.text=z==="blocked"?"?":z==="done"?"✓":z==="idle"?"☕":z==="unknown"?"~":"…",a.alpha=x.alpha=y.alpha=z==="unknown"?.6:1,R=z};F();const D=(z,K)=>B.circle(z,K,2.5).fill(g),G=(z,K)=>{c?(B.moveTo(z-1,K-8).quadraticCurveTo(z-2.6,K-10,z-1,K-12).stroke({color:16777215,width:.8,alpha:.55}),B.moveTo(z+1.2,K-8.5).quadraticCurveTo(z-.2,K-10.5,z+1.2,K-12.5).stroke({color:16777215,width:.8,alpha:.4}),B.circle(z+3.1,K-3.6,1.5).stroke({color:To,width:1}),B.roundRect(z-2.6,K-6.6,5.2,6,1).fill(To).stroke({color:H(To,.6),width:.8}),B.ellipse(z,K-6.6,2.6,.9).fill(5913122).stroke({color:wS,width:.8})):(B.roundRect(z-2,K-7,4,6.5,1).fill(p).stroke({color:H(p,.6),width:.8}),B.rect(z-2,K-7,4,1.2).fill(13685986)),D(z,K-1.5)},Q=(z,K)=>{switch(e.status){case"working":{const he=Math.sin(z*14)*1.5*K,Be=Math.sin(z*14+Math.PI)*1.5*K;D(-6,-5+he),D(6,-5+Be),O.y=Math.sin(z*3)*.6*K;const _e=z*.9%1;T.forEach((ne,q)=>{const me=(_e+q/T.length)%1;ne.visible=!r,ne.text=s.animation.glyphs[(Math.floor(z*.9)+q*5)%s.animation.glyphs.length],ne.position.set(I.x+20+Math.sin(me*6)*4+q*5,I.y-14-me*36),ne.alpha=1-me}),C.visible=!1;break}case"idle":{O.y=Math.sin(z*1.4)*1.2*K,D(7,-13+Math.sin(z*1.4)*1.2),C.visible=!0,C.alpha=.9,C.scale.set(1);break}case"blocked":{C.visible=!0,C.alpha=1,C.scale.set(1+Math.sin(z*5)*.12*K),D(11,-31+Math.sin(z*5)*1.5),O.y=0;break}case"done":{if(C.visible=!0,C.alpha=1,C.scale.set(1),C.y=-54-Math.abs(Math.sin(z*3))*5*K,O.y=-Math.abs(Math.sin(z*3))*2*K,c){const he=O.y,Be=Math.sin(z*6)*1.5*K;B.moveTo(-11,-24+he).lineTo(-11,-46+he).stroke({color:za,width:1.2}),B.poly([-11,-46+he,-20,-43+he+Be*.5,-11,-39+he]).fill(h).stroke({color:H(h,.6),width:.8}),D(-11,-25+he)}break}default:C.visible=!0,C.alpha=.8,C.scale.set(1),O.y=0}},U=(z,K,he,Be)=>{const _e=K==="walk",ne=z.clock*(z.hurry?17:10),q=_e?Math.sin(ne)*2:0,me=_e?-Math.abs(Math.sin(ne))*1.4:K==="sit"?Math.sin(he*1.4)*.6*Be:0;kS(M,K,ne,f,c),O.y=me;const Le=-13-Es+me;if(e.status==="blocked")D(-9.5,Le-q),D(11,-31-Es+me+Math.sin(he*5)*1.5);else if(!_e&&z.goal.kind==="machine"){const ws=ip(z);ws<.45?(D(-7,-27-Es),D(9.5,Le)):ws<.7?(O.y=3,D(-6,-5-Es),D(9.5,Le+3)):(D(-9.5,Le),G(9.5,Le))}else z.carrying?(D(-9.5,Le-q),!_e&&z.clock%6>5?G(4,-28-Es+me):G(9.5,Le+q)):(D(-9.5,Le-q),D(9.5,Le+q));C.visible=e.status!=="working",C.alpha=e.status==="idle"?.9:e.status==="unknown"?.8:1,C.scale.set(e.status==="blocked"?1+Math.sin(he*5)*.12*Be:1),C.y=-54-Es+me-(e.status==="done"?Math.abs(Math.sin(he*3))*5*Be:0)},te={x:I.x,y:I.y-46};let ae="",fe=!1;return{root:a,layers:[y,x,a],person:x,desk:t,state:e,anchor:te,tick:(z,K)=>{e.phase+=r?0:z*s.animation.tempo[e.status];const he=e.phase,Be=r?0:s.animation.amplitude;R!==e.status&&F();const _e=e.roam;if(_e&&n){const fr=e.status==="idle";r?qx(_e,n.lounge,S,fr):Ux(_e,n.lounge,S,fr,z)}const ne=_e&&n?Vx(_e):"desk",q=ne==="desk"?0:Es,me=_e&&ne!=="desk"?Yx(_e):{back:!1,left:!1},Le=`${ne}:${me.back}:${me.left}`;Le!==ae&&(xS(O,s,h,d,u,_,q,me.back,ne==="stand"||ne==="walk"?me.left?-1:1:0),ae=Le);const ws=_e&&n?_e.pos:S.seat,xs=b.x+ws.x,Vs=b.y+ws.y,vi=E(xs,Vs);x.position.set(vi.x,vi.y);const fp=ne==="desk"||xs>t.x-.45&&xs<t.x+1.1&&Vs>t.y-.75&&Vs<t.y;x.zIndex=fp?m-1:ms(xs,Vs)*10+1,fe!==(ne!=="desk")&&(fe=ne!=="desk",x.eventMode=fe?"static":"none"),te.x=vi.x,te.y=vi.y-46-q,B.clear(),M.clear();for(const fr of T)fr.visible=!1;dp(L,e.status,he),C.y=-54,ne==="desk"?Q(he,Be):U(_e,ne,he,Be);const Sh=K-e.lastChange;!r&&Sh<600&&C.scale.set(1+(1-Sh/600)*.6)}}}const TS=new pt({fill:15264240,fontSize:13,fontFamily:"ui-sans-serif, system-ui, sans-serif",fontWeight:"600"}),ES=new pt({fill:11186376,fontSize:11,fontFamily:"ui-sans-serif, system-ui, sans-serif"}),PS=new pt({fill:16765286,fontSize:15,fontFamily:"ui-sans-serif, system-ui, sans-serif",fontWeight:"700",letterSpacing:1.5}),AS=new pt({fill:11186376,fontSize:11,fontFamily:"ui-sans-serif, system-ui, sans-serif"}),RS=new pt({fill:16765286,fontSize:12,fontFamily:"ui-sans-serif, system-ui, sans-serif",fontWeight:"700",letterSpacing:.5}),BS=new pt({fill:1710618,fontSize:16,fontFamily:"ui-sans-serif, system-ui, sans-serif",fontWeight:"800"}),Fs=16765286,LS=12075834,cd=[11879727,3107722,13214247],dd=[15234095,15909198,13124911],Xe={dx:-.35,dy:-1,w:1.7,d:2},IS=60;function DS(t,e,s,i){st(t,e,s,1,1).fill(i).stroke({color:H(i,.82),width:1})}function OS(t,e,s,i){const r=H(i,.72);for(let n=0;n<4;n++){const o=s+n/4,a=s*4+n,l=((e+a)%3+3)%3;st(t,e,o,1,.25).fill(H(i,.95+(a*7%5+5)%5*.025));const h=E(e,o),c=E(e+1,o);if(t.moveTo(h.x,h.y).lineTo(c.x,c.y).stroke({color:r,width:1}),l===0){const d=e+.2+(a*5%3+3)%3*.3,u=E(d,o),f=E(d,o+.25);t.moveTo(u.x,u.y).lineTo(f.x,f.y).stroke({color:r,width:1})}}}function Ga(t,e,s=0){return st(t,e.x+Xe.dx,e.y+Xe.dy,Xe.w,Xe.d,s)}function ud(t){const e=t.x+Xe.dx,s=t.y+Xe.dy,i=IS,r=E(e,s),n=E(e+Xe.w,s),o=E(e+Xe.w,s+Xe.d),a=E(e,s+Xe.d);return new vs([r.x,r.y-i,n.x,n.y-i,n.x,n.y,o.x,o.y,a.x,a.y,a.x,a.y-i])}function fd(t,e=0){return[E(t.x,t.y,e),E(t.x+t.w,t.y,e),E(t.x+t.w,t.y+t.h,e),E(t.x,t.y+t.h,e)]}function pd(t,e,s=7,i=5){return e.forEach((r,n)=>{const o=e[(n+1)%e.length],a=Math.hypot(o.x-r.x,o.y-r.y),l=h=>({x:r.x+(o.x-r.x)*h/a,y:r.y+(o.y-r.y)*h/a});for(let h=0;h<a;h+=s+i){const c=l(h),d=l(Math.min(a,h+s));t.moveTo(c.x,c.y).lineTo(d.x,d.y)}}),t.stroke({color:Fs,width:1.5,alpha:.85})}class FS{constructor(e,s,i,r){w(this,"nodes",[]);w(this,"slots",[]);w(this,"brandPoint",null);w(this,"ground");w(this,"platforms");w(this,"floor");w(this,"objects");w(this,"labels");w(this,"motes");w(this,"states",new Map);w(this,"blockedRooms",[]);w(this,"fires",[]);w(this,"moteList",[]);w(this,"bounds",{minX:-200,maxX:200,minY:-200,maxY:200});w(this,"brand",null);w(this,"brandImage",null);w(this,"brandTexture",null);this.look=s,this.motion=i,this.addPrinter=r,this.ground=e.ground,this.platforms=e.platforms,this.floor=e.floor,this.objects=e.objects,this.labels=e.labels,this.motes=e.motes}setBanner(e,s){const i=this.brandTexture;return this.brand=e,s!==this.brandImage&&(this.brandImage=s,this.brandTexture=s?ue.from(s):null),i!==this.brandTexture?i:null}clear(){for(const e of[this.ground,this.platforms,this.floor,this.objects,this.labels])for(const s of e.removeChildren())s.destroy({children:!0});this.nodes=[],this.slots=[],this.blockedRooms=[],this.fires=[]}draw(e,s,i){this.drawGround(e),e.wings.forEach((n,o)=>{this.drawWing(n,o,i)}),this.drawBrand(e),e.slot&&this.drawRoomSlot(e.slot,"+room",{kind:"room",wing:null},"Room in another folder",`<b>New room</b>
347
+ in any folder or repository on this floor`);const r=new Set(s.panes.map(n=>n.pane_id));for(const n of[...this.states.keys()])r.has(n)||this.states.delete(n)}drawGround(e){const s=le(this.look.theme.palette.ground),i=le(this.look.theme.palette.groundLine),r=le(this.look.theme.palette.path),n=new ee,o=3;st(n,-o,-o,e.w+o*2,e.h+o*2).fill(s).stroke({color:i,width:2});for(let h=-o;h<=e.w+o;h++){const c=E(h,-o),d=E(h,e.h+o);n.moveTo(c.x,c.y).lineTo(d.x,d.y).stroke({color:16777215,width:1,alpha:.025})}for(let h=-o;h<=e.h+o;h++){const c=E(-o,h),d=E(e.w+o,h);n.moveTo(c.x,c.y).lineTo(d.x,d.y).stroke({color:16777215,width:1,alpha:.025})}st(n,-2,-2,1.2,e.h+4).fill(r).stroke({color:H(r,1.25),width:1});for(const h of e.wings){const c=h.y+Math.floor(h.h/2);st(n,-2,c,h.w+2,1.2).fill(r).stroke({color:H(r,1.25),width:1})}const a=Nr(hi("campus"));for(let h=-1;h<e.h+1;h+=4)if(a()<.6){const c=Math.floor(a()*1e3);this.addProp(d=>this.decorPlant(d,-2.9,h,c,!0),-2.9,h)}this.look.theme.architecture.decor==="alpine"&&this.drawWilds(e,o),this.ground.addChild(n);const l=[E(-o,-o),E(e.w+o,-o),E(e.w+o,e.h+o),E(-o,e.h+o)];this.bounds={minX:Math.min(...l.map(h=>h.x)),maxX:Math.max(...l.map(h=>h.x)),minY:Math.min(...l.map(h=>h.y))-120,maxY:Math.max(...l.map(h=>h.y))}}drawWilds(e,s){const i=Nr(hi("wilds"));for(let n=1;n<e.h;n+=4)if(i()<.55){const o=dd[Math.floor(i()*dd.length)];this.addProp(a=>Sx(a,-3.05,n,o),-3.05,n)}const r=(n,o)=>{const a=Math.floor(i()*1e3);this.addProp(l=>a%3?Qc(l,n,o,a,this.look.materials,!0):xx(l,n,o,a,this.look.materials),n,o)};for(let n=-s+.6;n<e.h+s-1;n+=1.6+i()*1.4)i()<.6&&r(e.w+.9+i()*(s-1.6),n);for(let n=-s+.6;n<e.w+.6;n+=1.6+i()*1.4)i()<.6&&r(n,e.h+1.2+i()*(s-1.9))}drawWing(e,s,i){const r=this.look.theme.palette.wings,n=le(r[s%r.length]),o=e.rooms.flatMap(_=>_.desks).filter(_=>_.pane.agent).length,a=e.rooms.reduce((_,g)=>_+g.desks.length,0),l=new ce,h=new zt({text:e.name.toUpperCase(),style:PS}),c=new zt({text:`${e.rooms.length} room${e.rooms.length===1?"":"s"} · ${a} desk${a===1?"":"s"} · ${o} agent${o===1?"":"s"}`,style:AS}),d=Math.max(h.width,c.width)+24,u=new ee;u.roundRect(0,0,d,44,8).fill({color:987416,alpha:.85}).stroke({color:3817301,width:1}),u.roundRect(0,0,4,44,2).fill(le(this.look.theme.palette.accent)),h.position.set(12,6),c.position.set(12,26),l.addChild(u,h,c);const f=E(e.x-.6,e.y+e.h*.5,0);l.position.set(f.x-d-14,f.y-22-40);const p=new ee;p.moveTo(f.x-14,f.y-18).lineTo(f.x-14,f.y+4).stroke({color:6975632,width:2}),this.labels.addChild(p,l);for(const _ of e.rooms)this.drawRoom(_,n,i);e.slot&&this.drawRoomSlot(e.slot,`+room:${e.key}`,{kind:"room",wing:e},"New room",`<b>New room</b>
348
+ in ${se(e.name)}`)}drawRoom(e,s,i){var L;const r=hi(e.workspace.workspace_id),n=Nr(r),o=e.desks.some(C=>C.pane.agent_status==="blocked"),a=ur(s,le(this.look.theme.palette.focus),.45),l=new ee;st(l,e.x+.15,e.y+.15,e.w,e.h,-8).fill({color:0,alpha:.35}),ie(l,e.x,e.y,e.w,e.h,6,H(s,.55),-6),this.platforms.addChild(l);const h=new ee,c=this.look.theme.architecture.floorPattern;for(let C=e.x;C<e.x+e.w;C++)for(let k=e.y;k<e.y+e.h;k++){const P=e.focused?a:s;if(c==="planks"){OS(h,C,k,P);continue}DS(h,C,k,(C+k)%2===0?P:H(P,.93)),c==="inset"&&st(h,C+.09,k+.09,.82,.82).stroke({color:le(this.look.theme.palette.accent),alpha:.23,width:1})}const d=this.look.theme.palette.rugs;bx(h,e.x+yt,e.y+yt,e.w-yt*2,e.h-yt*2,le(d[Math.floor(n()*d.length)])),Jc(h,e.x+e.w/2,e.y+e.h/2,e.w*22,e.h*11,le(this.look.theme.palette.light),this.look.theme.architecture.lightIntensity);const u=new ee,f=this.look.theme.architecture.wallHeight,p=le(this.look.theme.palette.wall);ie(u,e.x,e.y-.18,e.w,.18,f,p),ie(u,e.x-.18,e.y,.18,e.h,f,p);const _=e.y+.005,g=e.x+.005,m=this.look.theme.architecture.decor==="alpine";for(let C=e.x+.6;C+1.4<=e.x+e.w;C+=2.2)Ix(u,C,C+1.4,_,9,24,m);if(Fx(u,e.x+e.w-.35,_,22,this.look.materials),e.h>=3){const C=e.y+Math.min(e.h-.4,2.2),k=lp((L=e.desks[0])==null?void 0:L.pane.agent);n()<.6?m?Px(u,g,e.y+.4,C,8,24,r,this.look.materials):Dx(u,g,e.y+.4,C,8,24,r,this.look.materials):m?Ax(u,g,e.y+.5,e.y+1.3,10,24,k,this.look.materials):Ox(u,g,e.y+.5,e.y+1.3,10,24,k)}const y=new ee;st(y,e.x,e.y,e.w,e.h,.5).stroke({color:o?nr.blocked:e.focused?le(this.look.theme.palette.accent):8028840,width:o?3:1.5,alpha:o?.9:.6}),o&&this.blockedRooms.push({g:y,base:Math.random()*6}),this.floor.addChild(h,u,y);const v=[],b=[],S=[];for(const C of[...e.desks,...e.slot?[e.slot]:[]]){const k=C.x-e.x,P=C.y-e.y;v.push({x:k,y:P,w:1,d:.7},{x:k+.25,y:P-.7,w:.5,d:.45}),b.push({x:k+Xe.dx,y:P+Xe.dy,w:Xe.w,d:Xe.d+.4})}this.drawRoomProps(e,n,v,S);const x=_0(e.workspace);x&&this.addPrinter(e,x,v);const M=this.drawBreakArea(e,h,v,S),O=Hx(e.workspace.workspace_id,e.w,e.h,v,M,S,b);this.drawRoomPlaque(e);const B=e.desks.map(C=>this.stateFor(C.pane,i));O.members=B.filter((C,k)=>e.desks[k].pane.agent);const I={lounge:O,origin:{x:e.x,y:e.y}};e.desks.forEach((C,k)=>{this.drawDesk(C,B[k],I)}),e.slot&&this.drawDeskSlot(e,e.slot)}addProp(e,s,i,r){const n=new ee;e(n),n.zIndex=ms(s,i)*10,n.eventMode="none",this.objects.addChild(n),r&&r.blocks.push({x:s-r.room.x,y:i-r.room.y,w:r.w,d:r.d})}drawRoomProps(e,s,i,r){const n=(d,u,f,p,_)=>this.addProp(d,u,f,{room:e,blocks:i,w:p,d:_}),o=Math.floor(s()*1e6),a=this.look.theme.architecture.decor;if(n(d=>this.decorPlant(d,e.x+.3,e.y+.3,o),e.x+.3,e.y+.3,.45,.45),s()<.7){const d=s()<.5,u=e.x+e.w-.8,f=e.y+.25;n(p=>a==="alpine"?Cx(p,u,f,o):d?px(p,e.x+e.w-.7,e.y+.3):Zc(p,u,f,this.look.materials),u,f,.55,.45)}if(e.h>3&&s()<.6&&n(d=>this.decorPlant(d,e.x+.3,e.y+e.h-.7,o>>3),e.x+.3,e.y+e.h-.7,.45,.45),e.w>=5&&s()<.7){const d=e.x+e.w-1.2,u=e.y+e.h-.6;n(f=>a==="technical"?Zc(f,d,u,this.look.materials):a==="alpine"?kx(f,d,u,o,this.look.materials):_x(f,d,u,o,this.look.materials),d,u,.9,.45)}const l=Math.round((e.w-yt*2)/Jt),h=Math.round((e.h-yt*2)/Jt),c=e.desks.length+(e.slot?1:0);for(let d=c;d<l*h;d++){const u=e.x+yt+d%l*Jt,f=e.y+yt+Math.floor(d/l)*Jt;if(a==="alpine"){const p=cd[d%cd.length];n(_=>Mx(_,u+.9,f+.3,p,this.look.materials),u+.9,f+.3,1.2,.55),n(_=>Tx(_,u+1.2,f+1.3,le(this.look.theme.palette.light),this.look.materials),u+1.2,f+1.3,.6,.4),this.addFire(u+1.5,f+1.5)}else{const p=[5992102,8018830,5209975][d%3];n(_=>mx(_,u+.9,f+.3,p),u+.9,f+.3,1.2,.55),n(_=>gx(_,u+1.2,f+1.3,this.look.materials),u+1.2,f+1.3,.6,.4)}n(p=>this.decorPlant(p,u+.2,f+1.4,o+d),u+.2,f+1.4,.45,.45);for(const p of[u+1.25,u+1.75])r.push({at:{x:p-e.x,y:f+.63-e.y},stand:{x:p-e.x,y:f+1.1-e.y}})}}addFire(e,s){const i=new ee;Ex(i);const r=E(e,s);i.position.set(r.x,r.y+.5),i.zIndex=ms(e,s)*10+1,i.eventMode="none",this.objects.addChild(i),this.fires.push({g:i,base:Math.random()*10})}drawBreakArea(e,s,i,r){const n=this.look.theme.architecture.decor,o=e.x+.04,a=e.y+e.h-1.65;Jc(s,o+.9,a+.38,30,15,le(this.look.theme.palette.light),this.look.theme.architecture.lightIntensity*1.4),this.addProp(d=>yx(d,o,a,n==="technical"?this.look.materials.metal:n==="alpine"?this.look.materials.woodDark:LS,le(this.look.theme.palette.light),le(this.look.theme.palette.accent)),o,a,{room:e,blocks:i,w:.5,d:.75});const l=e.w>=8?2.4:1.6,h=e.x+.95,c=e.y+.06;this.addProp(d=>vx(d,h,c,l,this.look.materials),h,c,{room:e,blocks:i,w:l,d:.34});for(let d=h+.4;d<h+l;d+=.8)r.push({at:{x:d-e.x,y:.27},stand:{x:d-e.x,y:.85}});return{x:o+.92-e.x,y:a+.38-e.y}}decorPlant(e,s,i,r,n=!1){if(this.look.theme.architecture.decor==="botanical"){fx(e,s,i,r,this.look.materials);return}if(this.look.theme.architecture.decor==="alpine"){Qc(e,s,i,r,this.look.materials,n);return}ie(e,s,i,.45,.45,12,this.look.materials.metal);const o=E(s+.22,i+.22,12);e.moveTo(o.x,o.y).lineTo(o.x,o.y-15).stroke({color:this.look.materials.metal,width:3}),e.circle(o.x,o.y-16,4).fill(le(this.look.theme.palette.accent)),e.ellipse(o.x,o.y-13,9,3).stroke({color:le(this.look.theme.palette.accent),width:1.5})}drawBrand(e){var _;if(this.brandPoint=null,!((_=this.brand)!=null&&_.visible)||!this.brandTexture||!e.wings.length)return;const s=mu(this.look.theme,this.brand.anchorId),i=e.wings[0].rooms[0],r=s.x+(s.origin==="first-room"?i.x:0),n=s.y+(s.origin==="first-room"?i.y:0),o=s.width*ep/2,a=s.height,l=s.facing==="x"?E(r,n,s.z+a):E(r,n+s.width,s.z+a),h=new ce;h.eventMode="none";const c=new ee;for(const g of[.15,s.width-.15]){const m=s.facing==="x"?r+g:r,y=s.facing==="x"?n:n+g,v=E(m,y,s.origin==="first-room"?this.look.theme.architecture.wallHeight:0),b=E(m,y,s.z+a-4);c.moveTo(v.x,v.y).lineTo(b.x,b.y).stroke({color:this.look.materials.metal,width:3}),s.origin==="campus"&&Qe(c,m,y,6,3,.25)}this.floor.addChild(c),h.setFromMatrix(new re(1,s.facing==="x"?.5:-.5,0,1,l.x,l.y));const d=new ee;d.roundRect(-3,-3,o+6,a+6,3).fill(this.look.materials.metal),d.rect(0,0,o,a).fill(this.brand.background==="dark"?1517112:16054008);const u=new mi(this.brandTexture),f=6,p=Math.min((o-f*2)/this.brand.width,(a-f*2)/this.brand.height);u.scale.set(p),u.position.set((o-u.width)/2,(a-u.height)/2),h.addChild(d,u),this.floor.addChild(h),this.brandPoint={x:l.x+o/2,y:l.y+a/2+(s.facing==="x"?.25:-.25)*o}}drawRoomPlaque(e){const s=e.workspace.repo,i=s?s.linked?`worktree · ${s.checkout.split("/").pop()}`:"main checkout":`workspace ${e.workspace.number}`,r=new zt({text:e.workspace.label||e.workspace.workspace_id,style:TS}),n=new zt({text:i,style:ES}),o=new ee,a=Math.max(r.width,n.width)+24+e.desks.length*10,l=new ee;l.roundRect(-a/2,0,a,40,7).fill({color:987416,alpha:.82}).stroke({color:e.focused?16765286:3817301,width:1}),r.anchor.set(0,0),r.position.set(-a/2+10,5),n.anchor.set(0,0),n.position.set(-a/2+10,22),e.desks.forEach((d,u)=>{o.circle(a/2-12-u*10,20,3.5).fill(nr[d.pane.agent_status])});const h=new ce;h.addChild(l,r,n,o);const c=E(e.x+e.w/2,e.y+e.h+.1);h.position.set(c.x,c.y+2),this.labels.addChild(h)}stateFor(e,s){const i=this.states.get(e.pane_id),r=i?i.status===e.agent_status?i:{...i,status:e.agent_status,lastChange:s}:{phase:Math.random()*10,status:e.agent_status,lastChange:0};return this.states.set(e.pane_id,r),r}drawDesk(e,s,i){const n=e.pane.agent?MS(e,s,this.look.characters,this.look.materials,this.motion.reduced,i):_S(e,s,this.look.materials);this.nodes.push(n),n.root.eventMode="static",n.root.hitArea=ud(e);for(const o of[n.root,n.person])o&&(o.interactiveChildren=!1,o.cursor="pointer");for(const o of n.layers)this.objects.addChild(o)}drawDeskSlot(e,s){const i=new ee;Ga(i,s,.5).fill({color:Fs,alpha:.07});const r={x:s.x+Xe.dx,y:s.y+Xe.dy,w:Xe.w,h:Xe.d};pd(i,fd(r,.5));const n=new ee;ie(n,s.x+.25,s.y-.7,.5,.1,22,Fs,4),ie(n,s.x,s.y,1,.7,14,Fs),n.alpha=.22;const o=E(s.x+.5,s.y-.1,44),a=e.workspace.label||e.workspace.workspace_id;this.addSlot([i,n],ud(s),ms(s.x,s.y)*10,o,`+desk:${e.workspace.workspace_id}`,{kind:"desk",room:e},`<b>New desk</b>
349
+ in ${se(a)}`)}drawRoomSlot(e,s,i,r,n){const o=new ee,a=fd(e),l=new vs(a.flatMap(d=>[d.x,d.y]));o.poly(l.points).fill({color:Fs,alpha:.05}),pd(o,a);const h=new zt({text:r.toUpperCase(),style:RS});h.anchor.set(.5);const c=E(e.x+e.w/2,e.y+e.h/2);h.position.set(c.x,c.y+18),this.addSlot([o,h],l,ms(e.x,e.y)*10,{x:c.x,y:c.y-8},s,i,n)}addSlot(e,s,i,r,n,o,a){const l=new ce;l.addChild(...e);const h=new ce,c=new ee().circle(0,0,12).fill(Fs).stroke({color:H(Fs,.6),width:1.5}),d=new zt({text:"+",style:BS});d.anchor.set(.5,.55),h.addChild(c,d),h.position.set(r.x,r.y),l.addChild(h),l.zIndex=i,l.eventMode="static",l.hitArea=s,l.interactiveChildren=!1,l.cursor="pointer",l.alpha=.85;const u=p=>{l.alpha=p?1:.85,h.scale.set(p?1.15:1)},f={root:l,key:n,target:o,badge:h,badgeY:r.y,tip:a,hover:u};this.slots.push(f),this.objects.addChild(l)}buildMotes(e){for(const n of this.motes.removeChildren())n.destroy();this.moteList=[];const s=Nr(7),i=this.look.theme.architecture.decor==="alpine",r=Math.min(i?140:80,20+e.w*e.h/3);for(let n=0;n<r;n++){const o=new ee;i?o.circle(0,0,.9+s()*1.4).fill({color:16777215,alpha:.35+s()*.4}):o.circle(0,0,.8+s()*1.2).fill({color:le(this.look.theme.palette.light),alpha:.1+s()*.12}),o.position.set(this.bounds.minX+s()*(this.bounds.maxX-this.bounds.minX),this.bounds.minY+s()*(this.bounds.maxY-this.bounds.minY)),this.motes.addChild(o),this.moteList.push(i?{g:o,vx:-4-s()*8,vy:9+s()*14}:{g:o,vx:(s()-.5)*4,vy:-3-s()*5})}}tickDesks(e,s){for(const i of this.nodes)i.tick(e,s)}tickRooms(e){for(const s of this.slots)s.badge.y=s.badgeY+Math.sin(e/300)*2;for(const s of this.blockedRooms)s.g.alpha=.6+Math.sin(e/180+s.base)*.4;for(const s of this.fires)s.g.scale.set(1+Math.sin(e/130+s.base)*.05,1+Math.sin(e/90+s.base)*.1+Math.sin(e/53+s.base*2)*.06)}tickMotes(e){for(const s of this.moteList)s.g.x+=s.vx*e,s.g.y+=s.vy*e,s.g.y<this.bounds.minY?(s.g.y=this.bounds.maxY,s.g.x=this.bounds.minX+Math.random()*(this.bounds.maxX-this.bounds.minX)):s.g.y>this.bounds.maxY&&(s.g.y=this.bounds.minY,s.g.x=this.bounds.minX+Math.random()*(this.bounds.maxX-this.bounds.minX)),s.g.x<this.bounds.minX&&(s.g.x=this.bounds.maxX)}}const $S=4;class NS{constructor(e,s,i,r,n){w(this,"plumbob",new ce);w(this,"hoverRing",new ee);w(this,"selectedId",null);w(this,"hoveredId",null);w(this,"nodes",[]);w(this,"printers",[]);w(this,"slots",[]);this.tooltip=s,this.look=i,this.prints=r,this.h=n,e.addChild(this.hoverRing,this.plumbob),this.drawPlumbob()}attach(e){let s=null;e.on("pointerdown",i=>{var r;s={x:i.global.x,y:i.global.y,hit:((r=this.hitOf(i.target))==null?void 0:r.key)??null,moved:!1}}),e.on("pointerup",i=>{const r=s;if(s=null,!r||r.moved||i.button!==0)return;const n=this.hitOf(i.target);if(!n){r.hit===null&&this.h.onEmptyClick();return}n.key===r.hit&&(this.tooltip.hide(),"pane"in n?this.h.onSelectPane(n.pane):"printer"in n?this.h.onOpenPrinter(n.printer.key,n.printer.room,n.printer.label):this.h.onBuild(n.slot.target,i.global.x,i.global.y))}),e.on("pointerupoutside",()=>s=null),e.on("pointermove",i=>{if(!s)return;const r=i.global.x-s.x,n=i.global.y-s.y;Math.hypot(r,n)>$S&&(s.moved=!0)})}track(e,s,i){this.nodes=e,this.printers=s,this.slots=i;for(const r of e){const n=r.desk.pane;for(const o of[r.root,r.person])o&&(o.on("pointerover",a=>{this.setHover(n.pane_id),this.tooltip.pane(n,r.state.roam,a.global.x,a.global.y)}),o.on("pointermove",a=>this.tooltip.pane(n,r.state.roam,a.global.x,a.global.y)),o.on("pointerout",()=>{this.setHover(null),this.tooltip.hide()}))}for(const r of s)r.root.on("pointerover",n=>{this.ringPrinter(r),this.tooltip.printer(this.prints(),r.key,n.global.x,n.global.y)}),r.root.on("pointermove",n=>this.tooltip.printer(this.prints(),r.key,n.global.x,n.global.y)),r.root.on("pointerout",()=>{this.hoverRing.clear(),this.hoveredId=null,this.tooltip.hide()});for(const r of i)r.root.on("pointerover",n=>{r.hover(!0),this.tooltip.build(r.tip,n.global.x,n.global.y)}),r.root.on("pointermove",n=>this.tooltip.build(r.tip,n.global.x,n.global.y)),r.root.on("pointerout",()=>{r.hover(!1),this.tooltip.hide()});this.updatePlumbob(),this.setHover(null)}select(e){this.selectedId=e,this.updatePlumbob()}drawPlumbob(){const e=new ee;e.poly([0,-22,8,-8,0,8]).fill(8126331),e.poly([0,-22,-8,-8,0,8]).fill(3721562),e.poly([0,-22,8,-8,0,-8]).stroke({color:14155735,width:1,alpha:.7}),this.plumbob.addChild(e),this.plumbob.visible=!1}updatePlumbob(){const e=this.nodes.find(s=>s.desk.pane.pane_id===this.selectedId);this.plumbob.visible=!!e,e&&this.plumbob.position.set(e.anchor.x,e.anchor.y-22)}setHover(e){if(e===this.hoveredId)return;this.hoveredId=e,this.hoverRing.clear();const s=this.nodes.find(i=>i.desk.pane.pane_id===e);if(s){const i=s.desk,r=nr[i.pane.agent_status];Ga(this.hoverRing,i,.5).stroke({color:r,width:2,alpha:.9}),Ga(this.hoverRing,i,.5).fill({color:r,alpha:.08})}this.h.onHoverPane(e)}ringPrinter(e){this.hoveredId=null,this.hoverRing.clear();const s=le(this.look.theme.palette.accent);st(this.hoverRing,e.at.x-.08,e.at.y-.06,Se.w+.16,Se.d+.12,.5).fill({color:s,alpha:.08}).stroke({color:s,width:2,alpha:.9})}hitOf(e){const s=this.nodes.find(n=>n.root===e||n.person===e);if(s)return{key:s.desk.pane.pane_id,pane:s.desk.pane};const i=this.printers.find(n=>n.root===e);if(i)return{key:`printer:${i.room}`,printer:i};const r=this.slots.find(n=>n.root===e);return r?{key:r.key,slot:r}:null}tick(e){if(this.plumbob.visible){const s=e/1e3;this.plumbob.scale.x=.55+Math.abs(Math.cos(s*2.2))*.45,this.plumbob.y+=0;const i=this.nodes.find(r=>r.desk.pane.pane_id===this.selectedId);i&&this.plumbob.position.set(i.anchor.x,i.anchor.y-22+Math.sin(s*3)*3)}}}class HS{constructor(){w(this,"app",new Sf);w(this,"lift",new ce);w(this,"world",new ce);w(this,"layers",{ground:new ce,platforms:new ce,floor:new ce,objects:new ce,overlay:new ce,labels:new ce,motes:new ce});w(this,"office",null);w(this,"tooltip",new rS(document.getElementById("tip")));w(this,"floorId",null);w(this,"snapshot",null);w(this,"look",{theme:yu,characters:vu,materials:{...Je}});w(this,"motion",{reduced:matchMedia("(prefers-reduced-motion: reduce)").matches});w(this,"renderer",new FS(this.layers,this.look,this.motion,(e,s,i)=>this.printers.add(e,s,i)));w(this,"camera",new oS(this.app,this.lift,this.world,this.motion));w(this,"printers",new cS(this.app,this.world,this.layers.objects,this.look,this.motion,()=>this.prints));w(this,"picker",new NS(this.layers.overlay,this.tooltip,this.look,()=>this.prints,{onSelectPane:e=>this.onSelectPane(e),onHoverPane:e=>this.onHoverPane(e),onEmptyClick:()=>this.onEmptyClick(),onBuild:(e,s,i)=>this.onBuild(e,s,i),onOpenPrinter:(e,s,i)=>this.onOpenPrinter(e,s,i)}));w(this,"building",!1);w(this,"prints",null);w(this,"onSelectPane",()=>{});w(this,"onHoverPane",()=>{});w(this,"onEmptyClick",()=>{});w(this,"onBuild",()=>{});w(this,"onOpenPrinter",()=>{})}async init(e){await this.app.init({resizeTo:e,antialias:!0,background:le(this.look.theme.palette.background),backgroundAlpha:0,resolution:devicePixelRatio,autoDensity:!0}),e.appendChild(this.app.canvas);const{ground:s,platforms:i,floor:r,objects:n,overlay:o,labels:a,motes:l}=this.layers;n.sortableChildren=!0,this.world.addChild(s,i,r,n,o,a,l);for(const h of[s,i,r,o,a,l])h.eventMode="none";this.lift.addChild(this.world),this.app.stage.addChild(this.lift),this.camera.attach(),this.picker.attach(this.app.stage),this.app.ticker.add(h=>this.tick(h.deltaMS/1e3)),matchMedia("(prefers-reduced-motion: reduce)").addEventListener("change",h=>{this.motion.reduced=h.matches,this.snapshot&&this.setSnapshot(this.snapshot)})}setAppearance(e,s){this.look.theme=e,this.look.characters=s,this.look.materials=Object.fromEntries(Object.entries(e.materials).map(([i,r])=>[i,le(r)])),this.app.renderer.background.color=le(e.palette.background),this.app.renderer.background.alpha=0,document.documentElement.style.setProperty("--bg",e.palette.background),document.documentElement.style.setProperty("--accent",e.palette.accent),this.snapshot&&this.setSnapshot(this.snapshot)}setBanner(e,s){const i=this.renderer.setBanner(e,s);this.snapshot&&this.setSnapshot(this.snapshot),i&&i.destroy(!0)}previewBanner(){const e=this.renderer.brandPoint;e&&this.camera.lookAt(e)}zoomAt(e,s,i){this.camera.zoomAt(e,s,i)}fit(){this.camera.fit(this.office)}focusPane(e){const s=this.renderer.nodes.find(i=>i.desk.pane.pane_id===e);s&&this.camera.focus(s.anchor)}setSelected(e){this.picker.select(e)}showFloor(e,s,i=0,r=""){this.tooltip.runtime=r,e!==this.floorId&&(this.floorId=e,this.camera.newFloor(i)),this.setSnapshot(s)}setBuildMode(e){e!==this.building&&(this.building=e,this.snapshot&&this.setSnapshot(this.snapshot))}setSnapshot(e){this.snapshot=e;const s=Bp(e,this.building);this.office=s;const i=performance.now();this.renderer.clear(),this.printers.clear(),this.tooltip.hide(),this.renderer.draw(s,e,i),this.camera.settle(s),this.renderer.buildMotes(s),this.picker.track(this.renderer.nodes,this.printers.nodes,this.renderer.slots)}printerTray(e,s){return this.printers.tray(e,s)}tick(e){this.motion.reduced&&(e=0);const s=this.motion.reduced?0:performance.now();this.renderer.tickDesks(e,s),this.printers.tick(s),this.renderer.tickRooms(s),this.picker.tick(s),this.renderer.tickMotes(e),this.camera.tick(e,s)}}const WS=["localhost","::1","[::1]"].includes(location.hostname)?"127.0.0.1":location.hostname,zS=location.port,GS=`ws://${WS}:${zS}`;class US{constructor(e){w(this,"ws",null);this.handlers=e,this.connect()}connect(){this.handlers.onStatus(!1);const e=new WebSocket(GS);this.ws=e,e.onopen=()=>this.handlers.onStatus(!0),e.onmessage=s=>{var r,n,o,a,l,h,c,d,u,f,p,_,g,m,y,v,b,S,x,M;const i=JSON.parse(s.data);if(i.type==="machines")this.handlers.onMachines(i.machines);else if(i.type==="snapshot")this.handlers.onSnapshot(i.machine,i.snapshot);else if(i.type==="pane_output")this.handlers.onPaneOutput(St(i.machine,i.pane_id),i.text,i.seq??0);else if(i.type==="input_ack")(n=(r=this.handlers).onInputAck)==null||n.call(r,St(i.machine,i.pane_id),i.id);else if(i.type==="commands")(a=(o=this.handlers).onCommands)==null||a.call(o,St(i.machine,i.pane_id),i.commands);else if(i.type==="machine_added")(h=(l=this.handlers).onMachineAdded)==null||h.call(l,i.machine);else if(i.type==="machine_error")(d=(c=this.handlers).onMachineError)==null||d.call(c,i.message);else if(i.type==="created")(f=(u=this.handlers).onCreated)==null||f.call(u,St(i.machine,i.pane_id),i.id);else if(i.type==="create_error")(_=(p=this.handlers).onCreateError)==null||_.call(p,i.message,i.id,i.pane_id?St(i.machine,i.pane_id):void 0);else if(i.type==="prints")(m=(g=this.handlers).onPrints)==null||m.call(g,i.machine,i.sheets);else if(i.type==="print")(v=(y=this.handlers).onPrint)==null||v.call(y,i.machine,i.sheet);else if(i.type==="uncommitted"){const{files:O,incomplete:B,error:I}=i;(S=(b=this.handlers).onUncommitted)==null||S.call(b,St(i.machine,i.root),i.id,{files:O,incomplete:B,error:I})}else if(i.type==="error"){console.warn("[bridge]",i.message);const O=i.machine&&i.pane_id?St(i.machine,i.pane_id):void 0;(M=(x=this.handlers).onError)==null||M.call(x,i.message,O,i.id)}},e.onclose=()=>{this.handlers.onStatus(!1),setTimeout(()=>this.connect(),1500)},e.onerror=()=>e.close()}send(e){var s;return((s=this.ws)==null?void 0:s.readyState)!==WebSocket.OPEN?!1:(this.ws.send(JSON.stringify(e)),!0)}focusPane(e){const{machine:s,id:i}=Ps(e);this.send({type:"focus",machine:s,pane_id:i})}readPane(e,s,i){const{machine:r,id:n}=Ps(e);this.send({type:"read",machine:r,pane_id:n,lines:i,seq:s})}sendInput(e,s,i){if(s.length===0)return!1;const{machine:r,id:n}=Ps(e);return this.send({type:"input",machine:r,pane_id:n,ops:s,id:i})}listCommands(e){const{machine:s,id:i}=Ps(e);this.send({type:"commands",machine:s,pane_id:i})}addMachine(e,s){return this.send({type:"add_machine",ssh:e,label:s})}removeMachine(e){this.send({type:"remove_machine",machine:e})}createDesk(e,s,i){const{machine:r,id:n}=Ps(e);return this.send({type:"create_desk",machine:r,workspace_id:n,agent:s,id:i})}createRoom(e,s,i,r){return this.send({type:"create_room",machine:e,room:s,agent:i,id:r})}requestUncommitted(e,s){const{machine:i,id:r}=Ps(e);return this.send({type:"uncommitted",machine:i,root:r,id:s})}}async function qS(){const t=new HS;await t.init(document.getElementById("app"));const e=new gy(document.getElementById("app")),s=new Sy(t,e);await s.loadInstalled(),await s.restoreBanner();const i=new URLSearchParams(location.search),r=i.has("demo"),n=new Tp(i),o=document.getElementById("floor-banner");n.subscribe(m=>{if(m.type==="selection"||m.type==="floors"&&!m.current)return;const y=m.type==="floor"?m.dir:0,v=n.floors().find(b=>b.info.id===n.current);t.showFloor(n.current,n.snapshot(n.current)??Sp,y,v==null?void 0:v.info.runtime.name),y!==0&&v&&(o.innerHTML=`<b>${v.number}F</b>${se(v.info.label)}`,o.classList.remove("show"),o.offsetWidth,o.classList.add("show"))});const a=new c0(n),l=new m0;t.prints=l;const h=new w0(l);t.onOpenPrinter=(m,y,v)=>h.open(m,v,()=>t.printerTray(m,y)),h.request=(m,y)=>f.requestUncommitted(m,y);const c=new Ip(n,{onFit:()=>t.fit(),onZoom:m=>t.zoomAt(m)}),d=new Mp(n,{onAdd:(m,y)=>f.addMachine(m,y),onRemove:m=>f.removeMachine(m)}),u={onMachines:m=>n.setMachines(m),onSnapshot:(m,y)=>n.setSnapshot(m,y),onStatus:m=>c.setBridge(m),onPaneOutput:(m,y,v)=>a.receive(m,y,v),onInputAck:(m,y)=>a.inputAcked(m,y),onCommands:(m,y)=>a.setCommands(m,y),onError:(m,y,v)=>{y&&a.inputFailed(y,m,v)},onMachineAdded:m=>{d.added(),n.goToFloor(m)},onMachineError:m=>d.showError(m),onCreated:(m,y)=>p.created(m,y),onCreateError:(m,y,v)=>p.failed(m,y,v),onPrints:(m,y)=>l.reset(m,y),onPrint:(m,y)=>l.add(m,y),onUncommitted:(m,y,v)=>h.receive(m,y,v)},f=r?new(await ai(async()=>{const{DemoBridge:m}=await import("./demo-mFndvU9t.js");return{DemoBridge:m}},__vite__mapDeps([8,9]))).DemoBridge(u):new US(u),p=new xp({onToggle:m=>t.setBuildMode(m),createDesk:(m,y,v)=>f.createDesk(m,y,v),createRoom:(m,y,v,b)=>f.createRoom(m,y,v,b),onCreated:m=>n.select(m)});t.onBuild=(m,y,v)=>{var S;const b=(S=n.floors().find(x=>x.info.id===n.current))==null?void 0:S.info;b&&p.open(m,{id:b.id,label:b.label,remote:b.ssh!==null,runtime:b.runtime.name},y,v)},t.onSelectPane=m=>n.select(m.pane_id),t.onEmptyClick=()=>{a.close(),p.close()},a.onRead=(m,y,v)=>f.readPane(m,y,v),a.onInput=(m,y,v)=>f.sendInput(m,y,v),a.onListCommands=m=>f.listCommands(m);const _=()=>a.isTyping()||p.hasFocus()||s.isOpen()||h.isOpen();c.isTyping=_,d.isTyping=_,p.isTyping=()=>a.isTyping()||s.isOpen()||h.isOpen();const g=new E0;g.isTyping=_,a.onFocus=m=>f.focusPane(m),a.onResize=()=>{n.selected&&t.focusPane(n.selected)},n.subscribe(m=>{m.type==="selection"&&(t.setSelected(n.selected),n.selected&&t.focusPane(n.selected))})}qS();export{v1 as $,gf as A,ir as B,Ce as C,Oe as D,Dt as E,ss as F,kn as G,ce as H,Ob as I,dr as J,fc as K,Kr as L,re as M,Cn as N,ln as O,nt as P,pf as Q,wa as R,ch as S,ue as T,hn as U,ut as V,of as W,Oa as X,f1 as Y,_1 as Z,x1 as _,hf as a,Fy as a0,k1 as a1,ft as a2,Ru as a3,Pt as a4,xn as a5,Kl as a6,mi as a7,cx as a8,vv as a9,Xl as aa,oo as ab,Jl as ac,wv as ad,Ee as ae,Iu as af,Lw as ag,yf as ah,j as ai,cr as aj,Me as ak,Tb as al,xb as am,ds as an,jb as ao,zb as ap,eb as aq,p1 as ar,m1 as as,S1 as at,w1 as au,C1 as av,Pw as aw,tf as b,lp as c,Nb as d,dt as e,ve as f,Uv as g,ye as h,oe as i,Yr as j,St as k,X as l,Lu as m,ee as n,Mn as o,R1 as p,Mw as q,W1 as r,Ps as s,Tn as t,sb as u,Uu as v,$e as w,Re as x,ni as y,Zy as z};