claude-remote-cli 3.9.3 → 3.9.4

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.
@@ -1,5 +1,5 @@
1
- var mg=Object.defineProperty;var Qu=e=>{throw TypeError(e)};var bg=(e,t,i)=>t in e?mg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Vi=(e,t,i)=>bg(e,typeof t!="symbol"?t+"":t,i),Gl=(e,t,i)=>t.has(e)||Qu("Cannot "+i);var v=(e,t,i)=>(Gl(e,t,"read from private field"),i?i.call(e):t.get(e)),ee=(e,t,i)=>t.has(e)?Qu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),j=(e,t,i,r)=>(Gl(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),xe=(e,t,i)=>(Gl(e,t,"access private method"),i);var Ca=(e,t,i,r)=>({set _(s){j(e,t,s,i)},get _(){return v(e,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function i(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function r(s){if(s.ep)return;s.ep=!0;const n=i(s);fetch(s.href,n)}})();const yh=!1;var su=Array.isArray,yg=Array.prototype.indexOf,io=Array.prototype.includes,xl=Array.from,Sg=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,r_=Object.getOwnPropertyDescriptors,wg=Object.prototype,Cg=Array.prototype,nu=Object.getPrototypeOf,Zu=Object.isExtensible;const kg=()=>{};function xg(e){for(var t=0;t<e.length;t++)e[t]()}function s_(){var e,t,i=new Promise((r,s)=>{e=r,t=s});return{promise:i,resolve:e,reject:t}}function Eg(e,t){if(Array.isArray(e))return e;if(!(Symbol.iterator in e))return Array.from(e);const i=[];for(const r of e)if(i.push(r),i.length===t)break;return i}const Zt=2,ha=4,ca=8,n_=1<<24,$r=16,cr=32,Sn=64,Sh=128,Hi=512,Ut=1024,Jt=2048,hr=4096,xi=8192,qr=16384,_n=32768,vn=65536,Ju=1<<17,o_=1<<18,fo=1<<19,a_=1<<20,Ur=1<<25,pn=65536,wh=1<<21,ou=1<<22,ys=1<<23,jr=Symbol("$state"),Dg=Symbol("legacy props"),Tg=Symbol(""),Fs=new class extends Error{constructor(){super(...arguments);Vi(this,"name","StaleReactionError");Vi(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var zf;const Rg=!!((zf=globalThis.document)!=null&&zf.contentType)&&globalThis.document.contentType.includes("xml");function au(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Pg(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Ag(e,t,i){throw new Error("https://svelte.dev/e/each_key_duplicate")}function Mg(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Og(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Lg(e){throw new Error("https://svelte.dev/e/effect_orphan")}function Ig(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Bg(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function Ng(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Fg(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Wg(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Hg(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const zg=1,Ug=2,l_=4,Kg=8,qg=16,jg=1,Yg=4,Vg=8,Gg=16,Xg=1,$g=2,Yt=Symbol(),h_="http://www.w3.org/1999/xhtml",Qg="http://www.w3.org/2000/svg",Zg="http://www.w3.org/1998/Math/MathML";function Jg(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function em(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function c_(e){return e===this.v}function u_(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function d_(e){return!u_(e,this.v)}let tm=!1,Rt=null;function ro(e){Rt=e}function f_(e){return v_().get(e)}function im(e,t){return v_().set(e,t),t}function dt(e,t=!1,i){Rt={p:Rt,i:!1,c:null,e:null,s:e,x:null,l:null}}function ft(e){var t=Rt,i=t.e;if(i!==null){t.e=null;for(var r of i)N_(r)}return e!==void 0&&(t.x=e),t.i=!0,Rt=t.p,e??{}}function __(){return!0}function v_(e){return Rt===null&&au(),Rt.c??(Rt.c=new Map(rm(Rt)||void 0))}function rm(e){let t=e.p;for(;t!==null;){const i=t.c;if(i!==null)return i;t=t.p}return null}let Ws=[];function p_(){var e=Ws;Ws=[],xg(e)}function Dr(e){if(Ws.length===0&&!Io){var t=Ws;queueMicrotask(()=>{t===Ws&&p_()})}Ws.push(e)}function sm(){for(;Ws.length>0;)p_()}function g_(e){var t=Ve;if(t===null)return Ue.f|=ys,e;if((t.f&_n)===0&&(t.f&ha)===0)throw e;gs(e,t)}function gs(e,t){for(;t!==null;){if((t.f&Sh)!==0){if((t.f&_n)===0)throw e;try{t.b.error(e);return}catch(i){e=i}}t=t.parent}throw e}const nm=-7169;function bt(e,t){e.f=e.f&nm|t}function lu(e){(e.f&Hi)!==0||e.deps===null?bt(e,Ut):bt(e,hr)}function m_(e){if(e!==null)for(const t of e)(t.f&Zt)===0||(t.f&pn)===0||(t.f^=pn,m_(t.deps))}function b_(e,t,i){(e.f&Jt)!==0?t.add(e):(e.f&hr)!==0&&i.add(e),m_(e.deps),bt(e,Ut)}const ka=new Set;let Oe=null,Za=null,$t=null,_i=[],El=null,Ch=!1,Io=!1;var Bn,Nn,Ys,Fn,ea,ta,Vs,Nr,Wn,Ei,kh,xh,Eh,y_;const Yu=class Yu{constructor(){ee(this,Ei);Vi(this,"current",new Map);Vi(this,"previous",new Map);ee(this,Bn,new Set);ee(this,Nn,new Set);ee(this,Ys,0);ee(this,Fn,0);ee(this,ea,null);ee(this,ta,new Set);ee(this,Vs,new Set);ee(this,Nr,new Map);Vi(this,"is_fork",!1);ee(this,Wn,!1)}skip_effect(t){v(this,Nr).has(t)||v(this,Nr).set(t,{d:[],m:[]})}unskip_effect(t){var i=v(this,Nr).get(t);if(i){v(this,Nr).delete(t);for(var r of i.d)bt(r,Jt),or(r);for(r of i.m)bt(r,hr),or(r)}}process(t){var s;_i=[],this.apply();var i=[],r=[];for(const n of t)xe(this,Ei,xh).call(this,n,i,r);if(xe(this,Ei,kh).call(this)){xe(this,Ei,Eh).call(this,r),xe(this,Ei,Eh).call(this,i);for(const[n,o]of v(this,Nr))k_(n,o)}else{for(const n of v(this,Bn))n();v(this,Bn).clear(),v(this,Ys)===0&&xe(this,Ei,y_).call(this),Za=this,Oe=null,ed(r),ed(i),Za=null,(s=v(this,ea))==null||s.resolve()}$t=null}capture(t,i){i!==Yt&&!this.previous.has(t)&&this.previous.set(t,i),(t.f&ys)===0&&(this.current.set(t,t.v),$t==null||$t.set(t,t.v))}activate(){Oe=this,this.apply()}deactivate(){Oe===this&&(Oe=null,$t=null)}flush(){if(this.activate(),_i.length>0){if(S_(),Oe!==null&&Oe!==this)return}else v(this,Ys)===0&&this.process([]);this.deactivate()}discard(){for(const t of v(this,Nn))t(this);v(this,Nn).clear()}increment(t){j(this,Ys,v(this,Ys)+1),t&&j(this,Fn,v(this,Fn)+1)}decrement(t){j(this,Ys,v(this,Ys)-1),t&&j(this,Fn,v(this,Fn)-1),!v(this,Wn)&&(j(this,Wn,!0),Dr(()=>{j(this,Wn,!1),xe(this,Ei,kh).call(this)?_i.length>0&&this.flush():this.revive()}))}revive(){for(const t of v(this,ta))v(this,Vs).delete(t),bt(t,Jt),or(t);for(const t of v(this,Vs))bt(t,hr),or(t);this.flush()}oncommit(t){v(this,Bn).add(t)}ondiscard(t){v(this,Nn).add(t)}settled(){return(v(this,ea)??j(this,ea,s_())).promise}static ensure(){if(Oe===null){const t=Oe=new Yu;ka.add(Oe),Io||Dr(()=>{Oe===t&&t.flush()})}return Oe}apply(){}};Bn=new WeakMap,Nn=new WeakMap,Ys=new WeakMap,Fn=new WeakMap,ea=new WeakMap,ta=new WeakMap,Vs=new WeakMap,Nr=new WeakMap,Wn=new WeakMap,Ei=new WeakSet,kh=function(){return this.is_fork||v(this,Fn)>0},xh=function(t,i,r){t.f^=Ut;for(var s=t.first;s!==null;){var n=s.f,o=(n&(cr|Sn))!==0,a=o&&(n&Ut)!==0,c=a||(n&xi)!==0||v(this,Nr).has(s);if(!c&&s.fn!==null){o?s.f^=Ut:(n&ha)!==0?i.push(s):fa(s)&&((n&$r)!==0&&v(this,Vs).add(s),no(s));var h=s.first;if(h!==null){s=h;continue}}for(;s!==null;){var d=s.next;if(d!==null){s=d;break}s=s.parent}}},Eh=function(t){for(var i=0;i<t.length;i+=1)b_(t[i],v(this,ta),v(this,Vs))},y_=function(){var s;if(ka.size>1){this.previous.clear();var t=$t,i=!0;for(const n of ka){if(n===this){i=!1;continue}const o=[];for(const[c,h]of this.current){if(n.current.has(c))if(i&&h!==n.current.get(c))n.current.set(c,h);else continue;o.push(c)}if(o.length===0)continue;const a=[...n.current.keys()].filter(c=>!this.current.has(c));if(a.length>0){var r=_i;_i=[];const c=new Set,h=new Map;for(const d of o)w_(d,a,c,h);if(_i.length>0){Oe=n,n.apply();for(const d of _i)xe(s=n,Ei,xh).call(s,d,[],[]);n.deactivate()}_i=r}}Oe=null,$t=t}ka.delete(this)};let Ss=Yu;function om(e){var t=Io;Io=!0;try{for(var i;;){if(sm(),_i.length===0&&(Oe==null||Oe.flush(),_i.length===0))return El=null,i;S_()}}finally{Io=t}}function S_(){Ch=!0;var e=null;try{for(var t=0;_i.length>0;){var i=Ss.ensure();if(t++>1e3){var r,s;am()}i.process(_i),ws.clear()}}finally{_i=[],Ch=!1,El=null}}function am(){try{Ig()}catch(e){gs(e,El)}}let $i=null;function ed(e){var t=e.length;if(t!==0){for(var i=0;i<t;){var r=e[i++];if((r.f&(qr|xi))===0&&fa(r)&&($i=new Set,no(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&H_(r),($i==null?void 0:$i.size)>0)){ws.clear();for(const s of $i){if((s.f&(qr|xi))!==0)continue;const n=[s];let o=s.parent;for(;o!==null;)$i.has(o)&&($i.delete(o),n.push(o)),o=o.parent;for(let a=n.length-1;a>=0;a--){const c=n[a];(c.f&(qr|xi))===0&&no(c)}}$i.clear()}}$i=null}}function w_(e,t,i,r){if(!i.has(e)&&(i.add(e),e.reactions!==null))for(const s of e.reactions){const n=s.f;(n&Zt)!==0?w_(s,t,i,r):(n&(ou|$r))!==0&&(n&Jt)===0&&C_(s,t,r)&&(bt(s,Jt),or(s))}}function C_(e,t,i){const r=i.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const s of e.deps){if(io.call(t,s))return!0;if((s.f&Zt)!==0&&C_(s,t,i))return i.set(s,!0),!0}return i.set(e,!1),!1}function or(e){var t=El=e,i=t.b;if(i!=null&&i.is_pending&&(e.f&(ha|ca|n_))!==0&&(e.f&_n)===0){i.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var r=t.f;if(Ch&&t===Ve&&(r&$r)!==0&&(r&o_)===0&&(r&_n)!==0)return;if((r&(Sn|cr))!==0){if((r&Ut)===0)return;t.f^=Ut}}_i.push(t)}function k_(e,t){if(!((e.f&cr)!==0&&(e.f&Ut)!==0)){(e.f&Jt)!==0?t.d.push(e):(e.f&hr)!==0&&t.m.push(e),bt(e,Ut);for(var i=e.first;i!==null;)k_(i,t),i=i.next}}function lm(e){let t=0,i=Ds(0),r;return()=>{uu()&&(l(i),da(()=>(t===0&&(r=Qr(()=>e(()=>Cs(i)))),t+=1,()=>{Dr(()=>{t-=1,t===0&&(r==null||r(),r=void 0,Cs(i))})})))}}var hm=vn|fo;function cm(e,t,i,r){new um(e,t,i,r)}var Mi,iu,gr,Gs,ui,mr,wi,Zi,Fr,Xs,as,Hn,zn,Un,Wr,Sl,At,dm,fm,_m,Dh,Ba,Na,Th;class um{constructor(t,i,r,s){ee(this,At);Vi(this,"parent");Vi(this,"is_pending",!1);Vi(this,"transform_error");ee(this,Mi);ee(this,iu,null);ee(this,gr);ee(this,Gs);ee(this,ui);ee(this,mr,null);ee(this,wi,null);ee(this,Zi,null);ee(this,Fr,null);ee(this,Xs,0);ee(this,as,0);ee(this,Hn,!1);ee(this,zn,new Set);ee(this,Un,new Set);ee(this,Wr,null);ee(this,Sl,lm(()=>(j(this,Wr,Ds(v(this,Xs))),()=>{j(this,Wr,null)})));var n;j(this,Mi,t),j(this,gr,i),j(this,Gs,o=>{var a=Ve;a.b=this,a.f|=Sh,r(o)}),this.parent=Ve.b,this.transform_error=s??((n=this.parent)==null?void 0:n.transform_error)??(o=>o),j(this,ui,Rl(()=>{xe(this,At,Dh).call(this)},hm))}defer_effect(t){b_(t,v(this,zn),v(this,Un))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!v(this,gr).pending}update_pending_count(t){xe(this,At,Th).call(this,t),j(this,Xs,v(this,Xs)+t),!(!v(this,Wr)||v(this,Hn))&&(j(this,Hn,!0),Dr(()=>{j(this,Hn,!1),v(this,Wr)&&so(v(this,Wr),v(this,Xs))}))}get_effect_pending(){return v(this,Sl).call(this),l(v(this,Wr))}error(t){var i=v(this,gr).onerror;let r=v(this,gr).failed;if(!i&&!r)throw t;v(this,mr)&&(gi(v(this,mr)),j(this,mr,null)),v(this,wi)&&(gi(v(this,wi)),j(this,wi,null)),v(this,Zi)&&(gi(v(this,Zi)),j(this,Zi,null));var s=!1,n=!1;const o=()=>{if(s){em();return}s=!0,n&&Hg(),v(this,Zi)!==null&&ln(v(this,Zi),()=>{j(this,Zi,null)}),xe(this,At,Na).call(this,()=>{Ss.ensure(),xe(this,At,Dh).call(this)})},a=c=>{try{n=!0,i==null||i(c,o),n=!1}catch(h){gs(h,v(this,ui)&&v(this,ui).parent)}r&&j(this,Zi,xe(this,At,Na).call(this,()=>{Ss.ensure();try{return Bi(()=>{var h=Ve;h.b=this,h.f|=Sh,r(v(this,Mi),()=>c,()=>o)})}catch(h){return gs(h,v(this,ui).parent),null}}))};Dr(()=>{var c;try{c=this.transform_error(t)}catch(h){gs(h,v(this,ui)&&v(this,ui).parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(a,h=>gs(h,v(this,ui)&&v(this,ui).parent)):a(c)})}}Mi=new WeakMap,iu=new WeakMap,gr=new WeakMap,Gs=new WeakMap,ui=new WeakMap,mr=new WeakMap,wi=new WeakMap,Zi=new WeakMap,Fr=new WeakMap,Xs=new WeakMap,as=new WeakMap,Hn=new WeakMap,zn=new WeakMap,Un=new WeakMap,Wr=new WeakMap,Sl=new WeakMap,At=new WeakSet,dm=function(){try{j(this,mr,Bi(()=>v(this,Gs).call(this,v(this,Mi))))}catch(t){this.error(t)}},fm=function(t){const i=v(this,gr).failed;i&&j(this,Zi,Bi(()=>{i(v(this,Mi),()=>t,()=>()=>{})}))},_m=function(){const t=v(this,gr).pending;t&&(this.is_pending=!0,j(this,wi,Bi(()=>t(v(this,Mi)))),Dr(()=>{var i=j(this,Fr,document.createDocumentFragment()),r=Yr();i.append(r),j(this,mr,xe(this,At,Na).call(this,()=>(Ss.ensure(),Bi(()=>v(this,Gs).call(this,r))))),v(this,as)===0&&(v(this,Mi).before(i),j(this,Fr,null),ln(v(this,wi),()=>{j(this,wi,null)}),xe(this,At,Ba).call(this))}))},Dh=function(){try{if(this.is_pending=this.has_pending_snippet(),j(this,as,0),j(this,Xs,0),j(this,mr,Bi(()=>{v(this,Gs).call(this,v(this,Mi))})),v(this,as)>0){var t=j(this,Fr,document.createDocumentFragment());K_(v(this,mr),t);const i=v(this,gr).pending;j(this,wi,Bi(()=>i(v(this,Mi))))}else xe(this,At,Ba).call(this)}catch(i){this.error(i)}},Ba=function(){this.is_pending=!1;for(const t of v(this,zn))bt(t,Jt),or(t);for(const t of v(this,Un))bt(t,hr),or(t);v(this,zn).clear(),v(this,Un).clear()},Na=function(t){var i=Ve,r=Ue,s=Rt;Rr(v(this,ui)),qi(v(this,ui)),ro(v(this,ui).ctx);try{return t()}catch(n){return g_(n),null}finally{Rr(i),qi(r),ro(s)}},Th=function(t){var i;if(!this.has_pending_snippet()){this.parent&&xe(i=this.parent,At,Th).call(i,t);return}j(this,as,v(this,as)+t),v(this,as)===0&&(xe(this,At,Ba).call(this),v(this,wi)&&ln(v(this,wi),()=>{j(this,wi,null)}),v(this,Fr)&&(v(this,Mi).before(v(this,Fr)),j(this,Fr,null)))};function vm(e,t,i,r){const s=Dl;var n=e.filter(u=>!u.settled);if(i.length===0&&n.length===0){r(t.map(s));return}var o=Ve,a=pm(),c=n.length===1?n[0].promise:n.length>1?Promise.all(n.map(u=>u.promise)):null;function h(u){a();try{r(u)}catch(f){(o.f&qr)===0&&gs(f,o)}Rh()}if(i.length===0){c.then(()=>h(t.map(s)));return}function d(){a(),Promise.all(i.map(u=>mm(u))).then(u=>h([...t.map(s),...u])).catch(u=>gs(u,o))}c?c.then(d):d()}function pm(){var e=Ve,t=Ue,i=Rt,r=Oe;return function(n=!0){Rr(e),qi(t),ro(i),n&&(r==null||r.activate())}}function Rh(e=!0){Rr(null),qi(null),ro(null),e&&(Oe==null||Oe.deactivate())}function gm(){var e=Ve.b,t=Oe,i=e.is_rendered();return e.update_pending_count(1),t.increment(i),()=>{e.update_pending_count(-1),t.decrement(i)}}function Dl(e){var t=Zt|Jt,i=Ue!==null&&(Ue.f&Zt)!==0?Ue:null;return Ve!==null&&(Ve.f|=fo),{ctx:Rt,deps:null,effects:null,equals:c_,f:t,fn:e,reactions:null,rv:0,v:Yt,wv:0,parent:i??Ve,ac:null}}function mm(e,t,i){Ve===null&&Pg();var s=void 0,n=Ds(Yt),o=!Ue,a=new Map;return Om(()=>{var f;var c=s_();s=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(Rh)}catch(_){c.reject(_),Rh()}var h=Oe;if(o){var d=gm();(f=a.get(h))==null||f.reject(Fs),a.delete(h),a.set(h,c)}const u=(_,p=void 0)=>{if(h.activate(),p)p!==Fs&&(n.f|=ys,so(n,p));else{(n.f&ys)!==0&&(n.f^=ys),so(n,_);for(const[b,g]of a){if(a.delete(b),b===h)break;g.reject(Fs)}}d&&d()};c.promise.then(u,_=>u(null,_||"unknown"))}),du(()=>{for(const c of a.values())c.reject(Fs)}),new Promise(c=>{function h(d){function u(){d===s?c(n):h(s)}d.then(u,u)}h(s)})}function me(e){const t=Dl(e);return q_(t),t}function x_(e){const t=Dl(e);return t.equals=d_,t}function bm(e){var t=e.effects;if(t!==null){e.effects=null;for(var i=0;i<t.length;i+=1)gi(t[i])}}function ym(e){for(var t=e.parent;t!==null;){if((t.f&Zt)===0)return(t.f&qr)===0?t:null;t=t.parent}return null}function hu(e){var t,i=Ve;Rr(ym(e));try{e.f&=~pn,bm(e),t=G_(e)}finally{Rr(i)}return t}function E_(e){var t=hu(e);if(!e.equals(t)&&(e.wv=Y_(),(!(Oe!=null&&Oe.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){bt(e,Ut);return}Ts||($t!==null?(uu()||Oe!=null&&Oe.is_fork)&&$t.set(e,t):lu(e))}function Sm(e){var t,i;if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&((t=r.teardown)==null||t.call(r),(i=r.ac)==null||i.abort(Fs),r.teardown=kg,r.ac=null,qo(r,0),_u(r))}function D_(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&no(t)}let Ph=new Set;const ws=new Map;let T_=!1;function Ds(e,t){var i={f:0,v:e,reactions:null,equals:c_,rv:0,wv:0};return i}function F(e,t){const i=Ds(e);return q_(i),i}function wm(e,t=!1,i=!0){const r=Ds(e);return t||(r.equals=d_),r}function m(e,t,i=!1){Ue!==null&&(!ar||(Ue.f&Ju)!==0)&&__()&&(Ue.f&(Zt|$r|ou|Ju))!==0&&(Ui===null||!io.call(Ui,e))&&Wg();let r=i?$e(t):t;return so(e,r)}function so(e,t){if(!e.equals(t)){var i=e.v;Ts?ws.set(e,t):ws.set(e,i),e.v=t;var r=Ss.ensure();if(r.capture(e,i),(e.f&Zt)!==0){const s=e;(e.f&Jt)!==0&&hu(s),lu(s)}e.wv=Y_(),R_(e,Jt),Ve!==null&&(Ve.f&Ut)!==0&&(Ve.f&(cr|Sn))===0&&(Ai===null?Im([e]):Ai.push(e)),!r.is_fork&&Ph.size>0&&!T_&&Cm()}return t}function Cm(){T_=!1;for(const e of Ph)(e.f&Ut)!==0&&bt(e,hr),fa(e)&&no(e);Ph.clear()}function km(e,t=1){var i=l(e),r=t===1?i++:i--;return m(e,i),r}function Cs(e){m(e,e.v+1)}function R_(e,t){var i=e.reactions;if(i!==null)for(var r=i.length,s=0;s<r;s++){var n=i[s],o=n.f,a=(o&Jt)===0;if(a&&bt(n,t),(o&Zt)!==0){var c=n;$t==null||$t.delete(c),(o&pn)===0&&(o&Hi&&(n.f|=pn),R_(c,hr))}else a&&((o&$r)!==0&&$i!==null&&$i.add(n),or(n))}}function $e(e){if(typeof e!="object"||e===null||jr in e)return e;const t=nu(e);if(t!==wg&&t!==Cg)return e;var i=new Map,r=su(e),s=F(0),n=Vr,o=a=>{if(Vr===n)return a();var c=Ue,h=Vr;qi(null),sd(n);var d=a();return qi(c),sd(h),d};return r&&i.set("length",F(e.length)),new Proxy(e,{defineProperty(a,c,h){(!("value"in h)||h.configurable===!1||h.enumerable===!1||h.writable===!1)&&Ng();var d=i.get(c);return d===void 0?o(()=>{var u=F(h.value);return i.set(c,u),u}):m(d,h.value,!0),!0},deleteProperty(a,c){var h=i.get(c);if(h===void 0){if(c in a){const d=o(()=>F(Yt));i.set(c,d),Cs(s)}}else m(h,Yt),Cs(s);return!0},get(a,c,h){var _;if(c===jr)return e;var d=i.get(c),u=c in a;if(d===void 0&&(!u||(_=Mn(a,c))!=null&&_.writable)&&(d=o(()=>{var p=$e(u?a[c]:Yt),b=F(p);return b}),i.set(c,d)),d!==void 0){var f=l(d);return f===Yt?void 0:f}return Reflect.get(a,c,h)},getOwnPropertyDescriptor(a,c){var h=Reflect.getOwnPropertyDescriptor(a,c);if(h&&"value"in h){var d=i.get(c);d&&(h.value=l(d))}else if(h===void 0){var u=i.get(c),f=u==null?void 0:u.v;if(u!==void 0&&f!==Yt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return h},has(a,c){var f;if(c===jr)return!0;var h=i.get(c),d=h!==void 0&&h.v!==Yt||Reflect.has(a,c);if(h!==void 0||Ve!==null&&(!d||(f=Mn(a,c))!=null&&f.writable)){h===void 0&&(h=o(()=>{var _=d?$e(a[c]):Yt,p=F(_);return p}),i.set(c,h));var u=l(h);if(u===Yt)return!1}return d},set(a,c,h,d){var C;var u=i.get(c),f=c in a;if(r&&c==="length")for(var _=h;_<u.v;_+=1){var p=i.get(_+"");p!==void 0?m(p,Yt):_ in a&&(p=o(()=>F(Yt)),i.set(_+"",p))}if(u===void 0)(!f||(C=Mn(a,c))!=null&&C.writable)&&(u=o(()=>F(void 0)),m(u,$e(h)),i.set(c,u));else{f=u.v!==Yt;var b=o(()=>$e(h));m(u,b)}var g=Reflect.getOwnPropertyDescriptor(a,c);if(g!=null&&g.set&&g.set.call(d,h),!f){if(r&&typeof c=="string"){var S=i.get("length"),O=Number(c);Number.isInteger(O)&&O>=S.v&&m(S,O+1)}Cs(s)}return!0},ownKeys(a){l(s);var c=Reflect.ownKeys(a).filter(u=>{var f=i.get(u);return f===void 0||f.v!==Yt});for(var[h,d]of i)d.v!==Yt&&!(h in a)&&c.push(h);return c},setPrototypeOf(){Fg()}})}function td(e){try{if(e!==null&&typeof e=="object"&&jr in e)return e[jr]}catch{}return e}function xm(e,t){return Object.is(td(e),td(t))}var Ja,P_,A_,M_,O_;function Em(){if(Ja===void 0){Ja=window,P_=document,A_=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,i=Text.prototype;M_=Mn(t,"firstChild").get,O_=Mn(t,"nextSibling").get,Zu(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Zu(i)&&(i.__t=void 0)}}function Yr(e=""){return document.createTextNode(e)}function an(e){return M_.call(e)}function ua(e){return O_.call(e)}function w(e,t){return an(e)}function Ct(e,t=!1){{var i=an(e);return i instanceof Comment&&i.data===""?ua(i):i}}function R(e,t=1,i=!1){let r=e;for(;t--;)r=ua(r);return r}function Dm(e){e.textContent=""}function L_(){return!1}function I_(e,t,i){return document.createElementNS(t??h_,e,void 0)}function Tm(e,t){{const i=document.body;e.autofocus=!0,Dr(()=>{document.activeElement===i&&e.focus()})}}let id=!1;function Rm(){id||(id=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const i of e.target.elements)(t=i.__on_r)==null||t.call(i)})},{capture:!0}))}function Tl(e){var t=Ue,i=Ve;qi(null),Rr(null);try{return e()}finally{qi(t),Rr(i)}}function cu(e,t,i,r=i){e.addEventListener(t,()=>Tl(i));const s=e.__on_r;s?e.__on_r=()=>{s(),r(!0)}:e.__on_r=()=>r(!0),Rm()}function B_(e){Ve===null&&(Ue===null&&Lg(),Og()),Ts&&Mg()}function Pm(e,t){var i=t.last;i===null?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}function Or(e,t,i){var r=Ve;r!==null&&(r.f&xi)!==0&&(e|=xi);var s={ctx:Rt,deps:null,nodes:null,f:e|Jt|Hi,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(i)try{no(s)}catch(a){throw gi(s),a}else t!==null&&or(s);var n=s;if(i&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&fo)===0&&(n=n.first,(e&$r)!==0&&(e&vn)!==0&&n!==null&&(n.f|=vn)),n!==null&&(n.parent=r,r!==null&&Pm(n,r),Ue!==null&&(Ue.f&Zt)!==0&&(e&Sn)===0)){var o=Ue;(o.effects??(o.effects=[])).push(n)}return s}function uu(){return Ue!==null&&!ar}function du(e){const t=Or(ca,null,!1);return bt(t,Ut),t.teardown=e,t}function zi(e){B_();var t=Ve.f,i=!Ue&&(t&cr)!==0&&(t&_n)===0;if(i){var r=Rt;(r.e??(r.e=[])).push(e)}else return N_(e)}function N_(e){return Or(ha|a_,e,!1)}function Am(e){return B_(),Or(ca|a_,e,!0)}function Mm(e){Ss.ensure();const t=Or(Sn|fo,e,!0);return(i={})=>new Promise(r=>{i.outro?ln(t,()=>{gi(t),r(void 0)}):(gi(t),r(void 0))})}function fu(e){return Or(ha,e,!1)}function Om(e){return Or(ou|fo,e,!0)}function da(e,t=0){return Or(ca|t,e,!0)}function he(e,t=[],i=[],r=[]){vm(r,t,i,s=>{Or(ca,()=>e(...s.map(l)),!0)})}function Rl(e,t=0){var i=Or($r|t,e,!0);return i}function Bi(e){return Or(cr|fo,e,!0)}function F_(e){var t=e.teardown;if(t!==null){const i=Ts,r=Ue;rd(!0),qi(null);try{t.call(null)}finally{rd(i),qi(r)}}}function _u(e,t=!1){var i=e.first;for(e.first=e.last=null;i!==null;){const s=i.ac;s!==null&&Tl(()=>{s.abort(Fs)});var r=i.next;(i.f&Sn)!==0?i.parent=null:gi(i,t),i=r}}function Lm(e){for(var t=e.first;t!==null;){var i=t.next;(t.f&cr)===0&&gi(t),t=i}}function gi(e,t=!0){var i=!1;(t||(e.f&o_)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(W_(e.nodes.start,e.nodes.end),i=!0),_u(e,t&&!i),qo(e,0),bt(e,qr);var r=e.nodes&&e.nodes.t;if(r!==null)for(const n of r)n.stop();F_(e);var s=e.parent;s!==null&&s.first!==null&&H_(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function W_(e,t){for(;e!==null;){var i=e===t?null:ua(e);e.remove(),e=i}}function H_(e){var t=e.parent,i=e.prev,r=e.next;i!==null&&(i.next=r),r!==null&&(r.prev=i),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=i))}function ln(e,t,i=!0){var r=[];z_(e,r,!0);var s=()=>{i&&gi(e),t&&t()},n=r.length;if(n>0){var o=()=>--n||s();for(var a of r)a.out(o)}else s()}function z_(e,t,i){if((e.f&xi)===0){e.f^=xi;var r=e.nodes&&e.nodes.t;if(r!==null)for(const a of r)(a.is_global||i)&&t.push(a);for(var s=e.first;s!==null;){var n=s.next,o=(s.f&vn)!==0||(s.f&cr)!==0&&(e.f&$r)!==0;z_(s,t,o?i:!1),s=n}}}function vu(e){U_(e,!0)}function U_(e,t){if((e.f&xi)!==0){e.f^=xi,(e.f&Ut)===0&&(bt(e,Jt),or(e));for(var i=e.first;i!==null;){var r=i.next,s=(i.f&vn)!==0||(i.f&cr)!==0;U_(i,s?t:!1),i=r}var n=e.nodes&&e.nodes.t;if(n!==null)for(const o of n)(o.is_global||t)&&o.in()}}function K_(e,t){if(e.nodes)for(var i=e.nodes.start,r=e.nodes.end;i!==null;){var s=i===r?null:ua(i);t.append(i),i=s}}let Fa=!1,Ts=!1;function rd(e){Ts=e}let Ue=null,ar=!1;function qi(e){Ue=e}let Ve=null;function Rr(e){Ve=e}let Ui=null;function q_(e){Ue!==null&&(Ui===null?Ui=[e]:Ui.push(e))}let vi=null,Si=0,Ai=null;function Im(e){Ai=e}let j_=1,Hs=0,Vr=Hs;function sd(e){Vr=e}function Y_(){return++j_}function fa(e){var t=e.f;if((t&Jt)!==0)return!0;if(t&Zt&&(e.f&=~pn),(t&hr)!==0){for(var i=e.deps,r=i.length,s=0;s<r;s++){var n=i[s];if(fa(n)&&E_(n),n.wv>e.wv)return!0}(t&Hi)!==0&&$t===null&&bt(e,Ut)}return!1}function V_(e,t,i=!0){var r=e.reactions;if(r!==null&&!(Ui!==null&&io.call(Ui,e)))for(var s=0;s<r.length;s++){var n=r[s];(n.f&Zt)!==0?V_(n,t,!1):t===n&&(i?bt(n,Jt):(n.f&Ut)!==0&&bt(n,hr),or(n))}}function G_(e){var b;var t=vi,i=Si,r=Ai,s=Ue,n=Ui,o=Rt,a=ar,c=Vr,h=e.f;vi=null,Si=0,Ai=null,Ue=(h&(cr|Sn))===0?e:null,Ui=null,ro(e.ctx),ar=!1,Vr=++Hs,e.ac!==null&&(Tl(()=>{e.ac.abort(Fs)}),e.ac=null);try{e.f|=wh;var d=e.fn,u=d();e.f|=_n;var f=e.deps,_=Oe==null?void 0:Oe.is_fork;if(vi!==null){var p;if(_||qo(e,Si),f!==null&&Si>0)for(f.length=Si+vi.length,p=0;p<vi.length;p++)f[Si+p]=vi[p];else e.deps=f=vi;if(uu()&&(e.f&Hi)!==0)for(p=Si;p<f.length;p++)((b=f[p]).reactions??(b.reactions=[])).push(e)}else!_&&f!==null&&Si<f.length&&(qo(e,Si),f.length=Si);if(__()&&Ai!==null&&!ar&&f!==null&&(e.f&(Zt|hr|Jt))===0)for(p=0;p<Ai.length;p++)V_(Ai[p],e);if(s!==null&&s!==e){if(Hs++,s.deps!==null)for(let g=0;g<i;g+=1)s.deps[g].rv=Hs;if(t!==null)for(const g of t)g.rv=Hs;Ai!==null&&(r===null?r=Ai:r.push(...Ai))}return(e.f&ys)!==0&&(e.f^=ys),u}catch(g){return g_(g)}finally{e.f^=wh,vi=t,Si=i,Ai=r,Ue=s,Ui=n,ro(o),ar=a,Vr=c}}function Bm(e,t){let i=t.reactions;if(i!==null){var r=yg.call(i,e);if(r!==-1){var s=i.length-1;s===0?i=t.reactions=null:(i[r]=i[s],i.pop())}}if(i===null&&(t.f&Zt)!==0&&(vi===null||!io.call(vi,t))){var n=t;(n.f&Hi)!==0&&(n.f^=Hi,n.f&=~pn),lu(n),Sm(n),qo(n,0)}}function qo(e,t){var i=e.deps;if(i!==null)for(var r=t;r<i.length;r++)Bm(e,i[r])}function no(e){var t=e.f;if((t&qr)===0){bt(e,Ut);var i=Ve,r=Fa;Ve=e,Fa=!0;try{(t&($r|n_))!==0?Lm(e):_u(e),F_(e);var s=G_(e);e.teardown=typeof s=="function"?s:null,e.wv=j_;var n;yh&&tm&&(e.f&Jt)!==0&&e.deps}finally{Fa=r,Ve=i}}}async function Nm(){await Promise.resolve(),om()}function l(e){var t=e.f,i=(t&Zt)!==0;if(Ue!==null&&!ar){var r=Ve!==null&&(Ve.f&qr)!==0;if(!r&&(Ui===null||!io.call(Ui,e))){var s=Ue.deps;if((Ue.f&wh)!==0)e.rv<Hs&&(e.rv=Hs,vi===null&&s!==null&&s[Si]===e?Si++:vi===null?vi=[e]:vi.push(e));else{(Ue.deps??(Ue.deps=[])).push(e);var n=e.reactions;n===null?e.reactions=[Ue]:io.call(n,Ue)||n.push(Ue)}}}if(Ts&&ws.has(e))return ws.get(e);if(i){var o=e;if(Ts){var a=o.v;return((o.f&Ut)===0&&o.reactions!==null||$_(o))&&(a=hu(o)),ws.set(o,a),a}var c=(o.f&Hi)===0&&!ar&&Ue!==null&&(Fa||(Ue.f&Hi)!==0),h=(o.f&_n)===0;fa(o)&&(c&&(o.f|=Hi),E_(o)),c&&!h&&(D_(o),X_(o))}if($t!=null&&$t.has(e))return $t.get(e);if((e.f&ys)!==0)throw e.v;return e.v}function X_(e){if(e.f|=Hi,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&Zt)!==0&&(t.f&Hi)===0&&(D_(t),X_(t))}function $_(e){if(e.v===Yt)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(ws.has(t)||(t.f&Zt)!==0&&$_(t))return!0;return!1}function Qr(e){var t=ar;try{return ar=!0,e()}finally{ar=t}}function Fm(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(jr in e)Ah(e);else if(!Array.isArray(e))for(let t in e){const i=e[t];typeof i=="object"&&i&&jr in i&&Ah(i)}}}function Ah(e,t=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let r in e)try{Ah(e[r],t)}catch{}const i=nu(e);if(i!==Object.prototype&&i!==Array.prototype&&i!==Map.prototype&&i!==Set.prototype&&i!==Date.prototype){const r=r_(i);for(let s in r){const n=r[s].get;if(n)try{n.call(e)}catch{}}}}}const Wm=["touchstart","touchmove"];function Hm(e){return Wm.includes(e)}const zs=Symbol("events"),Q_=new Set,Mh=new Set;function zm(e,t,i,r={}){function s(n){if(r.capture||Oh.call(t,n),!n.cancelBubble)return Tl(()=>i==null?void 0:i.call(this,n))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?Dr(()=>{t.addEventListener(e,s,r)}):t.addEventListener(e,s,r),s}function xr(e,t,i,r,s){var n={capture:r,passive:s},o=zm(e,t,i,n);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&du(()=>{t.removeEventListener(e,o,n)})}function G(e,t,i){(t[zs]??(t[zs]={}))[e]=i}function _t(e){for(var t=0;t<e.length;t++)Q_.add(e[t]);for(var i of Mh)i(e)}let nd=null;function Oh(e){var g,S;var t=this,i=t.ownerDocument,r=e.type,s=((g=e.composedPath)==null?void 0:g.call(e))||[],n=s[0]||e.target;nd=e;var o=0,a=nd===e&&e[zs];if(a){var c=s.indexOf(a);if(c!==-1&&(t===document||t===window)){e[zs]=t;return}var h=s.indexOf(t);if(h===-1)return;c<=h&&(o=c)}if(n=s[o]||e.target,n!==t){Sg(e,"currentTarget",{configurable:!0,get(){return n||i}});var d=Ue,u=Ve;qi(null),Rr(null);try{for(var f,_=[];n!==null;){var p=n.assignedSlot||n.parentNode||n.host||null;try{var b=(S=n[zs])==null?void 0:S[r];b!=null&&(!n.disabled||e.target===n)&&b.call(n,e)}catch(O){f?_.push(O):f=O}if(e.cancelBubble||p===t||p===null)break;n=p}if(f){for(let O of _)queueMicrotask(()=>{throw O});throw f}}finally{e[zs]=t,delete e.currentTarget,qi(d),Rr(u)}}}var Uf;const Xl=((Uf=globalThis==null?void 0:globalThis.window)==null?void 0:Uf.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Um(e){return(Xl==null?void 0:Xl.createHTML(e))??e}function Km(e){var t=I_("template");return t.innerHTML=Um(e.replaceAll("<!>","<!---->")),t.content}function jo(e,t){var i=Ve;i.nodes===null&&(i.nodes={start:e,end:t,a:null,t:null})}function W(e,t){var i=(t&Xg)!==0,r=(t&$g)!==0,s,n=!e.startsWith("<!>");return()=>{s===void 0&&(s=Km(n?e:"<!>"+e),i||(s=an(s)));var o=r||A_?document.importNode(s,!0):s.cloneNode(!0);if(i){var a=an(o),c=o.lastChild;jo(a,c)}else jo(o,o);return o}}function hn(e=""){{var t=Yr(e+"");return jo(t,t),t}}function Gr(){var e=document.createDocumentFragment(),t=document.createComment(""),i=Yr();return e.append(t,i),jo(t,i),e}function B(e,t){e!==null&&e.before(t)}function ne(e,t){var i=t==null?"":typeof t=="object"?`${t}`:t;i!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=i,e.nodeValue=`${i}`)}function qm(e,t){return jm(e,t)}const xa=new Map;function jm(e,{target:t,anchor:i,props:r={},events:s,context:n,intro:o=!0,transformError:a}){Em();var c=void 0,h=Mm(()=>{var d=i??t.appendChild(Yr());cm(d,{pending:()=>{}},_=>{dt({});var p=Rt;n&&(p.c=n),s&&(r.$$events=s),c=e(_,r)||{},ft()},a);var u=new Set,f=_=>{for(var p=0;p<_.length;p++){var b=_[p];if(!u.has(b)){u.add(b);var g=Hm(b);for(const C of[t,document]){var S=xa.get(C);S===void 0&&(S=new Map,xa.set(C,S));var O=S.get(b);O===void 0?(C.addEventListener(b,Oh,{passive:g}),S.set(b,1)):S.set(b,O+1)}}}};return f(xl(Q_)),Mh.add(f),()=>{var g;for(var _ of u)for(const S of[t,document]){var p=xa.get(S),b=p.get(_);--b==0?(S.removeEventListener(_,Oh),p.delete(_),p.size===0&&xa.delete(S)):p.set(_,b)}Mh.delete(f),d!==i&&((g=d.parentNode)==null||g.removeChild(d))}});return Ym.set(c,h),c}let Ym=new WeakMap;var Ji,br,Ci,$s,ia,ra,wl;class Z_{constructor(t,i=!0){Vi(this,"anchor");ee(this,Ji,new Map);ee(this,br,new Map);ee(this,Ci,new Map);ee(this,$s,new Set);ee(this,ia,!0);ee(this,ra,()=>{var t=Oe;if(v(this,Ji).has(t)){var i=v(this,Ji).get(t),r=v(this,br).get(i);if(r)vu(r),v(this,$s).delete(i);else{var s=v(this,Ci).get(i);s&&(v(this,br).set(i,s.effect),v(this,Ci).delete(i),s.fragment.lastChild.remove(),this.anchor.before(s.fragment),r=s.effect)}for(const[n,o]of v(this,Ji)){if(v(this,Ji).delete(n),n===t)break;const a=v(this,Ci).get(o);a&&(gi(a.effect),v(this,Ci).delete(o))}for(const[n,o]of v(this,br)){if(n===i||v(this,$s).has(n))continue;const a=()=>{if(Array.from(v(this,Ji).values()).includes(n)){var h=document.createDocumentFragment();K_(o,h),h.append(Yr()),v(this,Ci).set(n,{effect:o,fragment:h})}else gi(o);v(this,$s).delete(n),v(this,br).delete(n)};v(this,ia)||!r?(v(this,$s).add(n),ln(o,a,!1)):a()}}});ee(this,wl,t=>{v(this,Ji).delete(t);const i=Array.from(v(this,Ji).values());for(const[r,s]of v(this,Ci))i.includes(r)||(gi(s.effect),v(this,Ci).delete(r))});this.anchor=t,j(this,ia,i)}ensure(t,i){var r=Oe,s=L_();if(i&&!v(this,br).has(t)&&!v(this,Ci).has(t))if(s){var n=document.createDocumentFragment(),o=Yr();n.append(o),v(this,Ci).set(t,{effect:Bi(()=>i(o)),fragment:n})}else v(this,br).set(t,Bi(()=>i(this.anchor)));if(v(this,Ji).set(r,t),s){for(const[a,c]of v(this,br))a===t?r.unskip_effect(c):r.skip_effect(c);for(const[a,c]of v(this,Ci))a===t?r.unskip_effect(c.effect):r.skip_effect(c.effect);r.oncommit(v(this,ra)),r.ondiscard(v(this,wl))}else v(this,ra).call(this)}}Ji=new WeakMap,br=new WeakMap,Ci=new WeakMap,$s=new WeakMap,ia=new WeakMap,ra=new WeakMap,wl=new WeakMap;function ie(e,t,i=!1){var r=new Z_(e),s=i?vn:0;function n(o,a){r.ensure(o,a)}Rl(()=>{var o=!1;t((a,c=0)=>{o=!0,n(c,a)}),o||n(!1,null)},s)}function Yo(e,t){return t}function Vm(e,t,i){for(var r=[],s=t.length,n,o=t.length,a=0;a<s;a++){let u=t[a];ln(u,()=>{if(n){if(n.pending.delete(u),n.done.add(u),n.pending.size===0){var f=e.outrogroups;Lh(xl(n.done)),f.delete(n),f.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var c=r.length===0&&i!==null;if(c){var h=i,d=h.parentNode;Dm(d),d.append(h),e.items.clear()}Lh(t,!c)}else n={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(n)}function Lh(e,t=!0){for(var i=0;i<e.length;i++)gi(e[i],t)}var od;function si(e,t,i,r,s,n=null){var o=e,a=new Map,c=(t&l_)!==0;if(c){var h=e;o=h.appendChild(Yr())}var d=null,u=x_(()=>{var S=i();return su(S)?S:S==null?[]:xl(S)}),f,_=!0;function p(){g.fallback=d,Gm(g,f,o,t,r),d!==null&&(f.length===0?(d.f&Ur)===0?vu(d):(d.f^=Ur,Do(d,null,o)):ln(d,()=>{d=null}))}var b=Rl(()=>{f=l(u);for(var S=f.length,O=new Set,C=Oe,y=L_(),x=0;x<S;x+=1){var P=f[x],I=r(P,x),z=_?null:a.get(I);z?(z.v&&so(z.v,P),z.i&&so(z.i,x),y&&C.unskip_effect(z.e)):(z=Xm(a,_?o:od??(od=Yr()),P,I,x,s,t,i),_||(z.e.f|=Ur),a.set(I,z)),O.add(I)}if(S===0&&n&&!d&&(_?d=Bi(()=>n(o)):(d=Bi(()=>n(od??(od=Yr()))),d.f|=Ur)),S>O.size&&Ag(),!_)if(y){for(const[q,J]of a)O.has(q)||C.skip_effect(J.e);C.oncommit(p),C.ondiscard(()=>{})}else p();l(u)}),g={effect:b,items:a,outrogroups:null,fallback:d};_=!1}function mo(e){for(;e!==null&&(e.f&cr)===0;)e=e.next;return e}function Gm(e,t,i,r,s){var J,K,N,A,T,L,H,D,E;var n=(r&Kg)!==0,o=t.length,a=e.items,c=mo(e.effect.first),h,d=null,u,f=[],_=[],p,b,g,S;if(n)for(S=0;S<o;S+=1)p=t[S],b=s(p,S),g=a.get(b).e,(g.f&Ur)===0&&((K=(J=g.nodes)==null?void 0:J.a)==null||K.measure(),(u??(u=new Set)).add(g));for(S=0;S<o;S+=1){if(p=t[S],b=s(p,S),g=a.get(b).e,e.outrogroups!==null)for(const $ of e.outrogroups)$.pending.delete(g),$.done.delete(g);if((g.f&Ur)!==0)if(g.f^=Ur,g===c)Do(g,null,i);else{var O=d?d.next:c;g===e.effect.last&&(e.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),es(e,d,g),es(e,g,O),Do(g,O,i),d=g,f=[],_=[],c=mo(d.next);continue}if((g.f&xi)!==0&&(vu(g),n&&((A=(N=g.nodes)==null?void 0:N.a)==null||A.unfix(),(u??(u=new Set)).delete(g))),g!==c){if(h!==void 0&&h.has(g)){if(f.length<_.length){var C=_[0],y;d=C.prev;var x=f[0],P=f[f.length-1];for(y=0;y<f.length;y+=1)Do(f[y],C,i);for(y=0;y<_.length;y+=1)h.delete(_[y]);es(e,x.prev,P.next),es(e,d,x),es(e,P,C),c=C,d=P,S-=1,f=[],_=[]}else h.delete(g),Do(g,c,i),es(e,g.prev,g.next),es(e,g,d===null?e.effect.first:d.next),es(e,d,g),d=g;continue}for(f=[],_=[];c!==null&&c!==g;)(h??(h=new Set)).add(c),_.push(c),c=mo(c.next);if(c===null)continue}(g.f&Ur)===0&&f.push(g),d=g,c=mo(g.next)}if(e.outrogroups!==null){for(const $ of e.outrogroups)$.pending.size===0&&(Lh(xl($.done)),(T=e.outrogroups)==null||T.delete($));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||h!==void 0){var I=[];if(h!==void 0)for(g of h)(g.f&xi)===0&&I.push(g);for(;c!==null;)(c.f&xi)===0&&c!==e.fallback&&I.push(c),c=mo(c.next);var z=I.length;if(z>0){var q=(r&l_)!==0&&o===0?i:null;if(n){for(S=0;S<z;S+=1)(H=(L=I[S].nodes)==null?void 0:L.a)==null||H.measure();for(S=0;S<z;S+=1)(E=(D=I[S].nodes)==null?void 0:D.a)==null||E.fix()}Vm(e,I,q)}}n&&Dr(()=>{var $,Q;if(u!==void 0)for(g of u)(Q=($=g.nodes)==null?void 0:$.a)==null||Q.apply()})}function Xm(e,t,i,r,s,n,o,a){var c=(o&zg)!==0?(o&qg)===0?wm(i,!1,!1):Ds(i):null,h=(o&Ug)!==0?Ds(s):null;return{v:c,i:h,e:Bi(()=>(n(t,c??i,h??s,a),()=>{e.delete(r)}))}}function Do(e,t,i){if(e.nodes)for(var r=e.nodes.start,s=e.nodes.end,n=t&&(t.f&Ur)===0?t.nodes.start:i;r!==null;){var o=ua(r);if(n.before(r),r===s)return;r=o}}function es(e,t,i){t===null?e.effect.first=i:t.next=i,i===null?e.effect.last=t:i.prev=t}function ad(e,t,i=!1,r=!1,s=!1){var n=e,o="";he(()=>{var a=Ve;if(o!==(o=t()??"")&&(a.nodes!==null&&(W_(a.nodes.start,a.nodes.end),a.nodes=null),o!=="")){var c=i?Qg:r?Zg:void 0,h=I_(i?"svg":r?"math":"template",c);h.innerHTML=o;var d=i||r?h:h.content;if(jo(an(d),d.lastChild),i||r)for(;an(d);)n.before(an(d));else n.before(d)}})}function $m(e,t,...i){var r=new Z_(e);Rl(()=>{const s=t()??null;r.ensure(s,s&&(n=>s(n,...i)))},vn)}function Qm(e,t,i){fu(()=>{var r=Qr(()=>t(e,i==null?void 0:i())||{});if(i&&(r!=null&&r.update)){var s=!1,n={};da(()=>{var o=i();Fm(o),s&&u_(n,o)&&(n=o,r.update(o))}),s=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function J_(e){var t,i,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(i=J_(e[t]))&&(r&&(r+=" "),r+=i)}else for(i in e)e[i]&&(r&&(r+=" "),r+=i);return r}function Zm(){for(var e,t,i=0,r="",s=arguments.length;i<s;i++)(e=arguments[i])&&(t=J_(e))&&(r&&(r+=" "),r+=t);return r}function ev(e){return typeof e=="object"?Zm(e):e??""}const ld=[...`
2
- \r\f \v\uFEFF`];function Jm(e,t,i){var r=e==null?"":""+e;if(t&&(r=r?r+" "+t:t),i){for(var s of Object.keys(i))if(i[s])r=r?r+" "+s:s;else if(r.length)for(var n=s.length,o=0;(o=r.indexOf(s,o))>=0;){var a=o+n;(o===0||ld.includes(r[o-1]))&&(a===r.length||ld.includes(r[a]))?r=(o===0?"":r.substring(0,o))+r.substring(a+1):o=a}}return r===""?null:r}function hd(e,t=!1){var i=t?" !important;":";",r="";for(var s of Object.keys(e)){var n=e[s];n!=null&&n!==""&&(r+=" "+s+": "+n+i)}return r}function $l(e){return e[0]!=="-"||e[1]!=="-"?e.toLowerCase():e}function eb(e,t){if(t){var i="",r,s;if(Array.isArray(t)?(r=t[0],s=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,a=!1,c=[];r&&c.push(...Object.keys(r).map($l)),s&&c.push(...Object.keys(s).map($l));var h=0,d=-1;const b=e.length;for(var u=0;u<b;u++){var f=e[u];if(a?f==="/"&&e[u-1]==="*"&&(a=!1):n?n===f&&(n=!1):f==="/"&&e[u+1]==="*"?a=!0:f==='"'||f==="'"?n=f:f==="("?o++:f===")"&&o--,!a&&n===!1&&o===0){if(f===":"&&d===-1)d=u;else if(f===";"||u===b-1){if(d!==-1){var _=$l(e.substring(h,d).trim());if(!c.includes(_)){f!==";"&&u++;var p=e.substring(h,u).trim();i+=" "+p+";"}}h=u+1,d=-1}}}}return r&&(i+=hd(r)),s&&(i+=hd(s,!0)),i=i.trim(),i===""?null:i}return e==null?null:String(e)}function it(e,t,i,r,s,n){var o=e.__className;if(o!==i||o===void 0){var a=Jm(i,r,n);a==null?e.removeAttribute("class"):e.className=a,e.__className=i}else if(n&&s!==n)for(var c in n){var h=!!n[c];(s==null||h!==!!s[c])&&e.classList.toggle(c,h)}return n}function Ql(e,t={},i,r){for(var s in i){var n=i[s];t[s]!==n&&(i[s]==null?e.style.removeProperty(s):e.style.setProperty(s,n,r))}}function _o(e,t,i,r){var s=e.__style;if(s!==t){var n=eb(t,r);n==null?e.removeAttribute("style"):e.style.cssText=n,e.__style=t}else r&&(Array.isArray(r)?(Ql(e,i==null?void 0:i[0],r[0]),Ql(e,i==null?void 0:i[1],r[1],"important")):Ql(e,i,r));return r}function tv(e,t,i=!1){if(e.multiple){if(t==null)return;if(!su(t))return Jg();for(var r of e.options)r.selected=t.includes(Bo(r));return}for(r of e.options){var s=Bo(r);if(xm(s,t)){r.selected=!0;return}}(!i||t!==void 0)&&(e.selectedIndex=-1)}function tb(e){var t=new MutationObserver(()=>{tv(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),du(()=>{t.disconnect()})}function el(e,t,i=t){var r=new WeakSet,s=!0;cu(e,"change",n=>{var o=n?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(o),Bo);else{var c=e.querySelector(o)??e.querySelector("option:not([disabled])");a=c&&Bo(c)}i(a),Oe!==null&&r.add(Oe)}),fu(()=>{var n=t();if(e===document.activeElement){var o=Za??Oe;if(r.has(o))return}if(tv(e,n,s),s&&n===void 0){var a=e.querySelector(":checked");a!==null&&(n=Bo(a),i(n))}e.__value=n,s=!1}),tb(e)}function Bo(e){return"__value"in e?e.__value:e.value}const ib=Symbol("is custom element"),rb=Symbol("is html"),sb=Rg?"progress":"PROGRESS";function nb(e,t){var i=pu(e);i.value===(i.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==sb)||(e.value=t??"")}function ob(e,t){var i=pu(e);i.checked!==(i.checked=t??void 0)&&(e.checked=t)}function Ie(e,t,i,r){var s=pu(e);s[t]!==(s[t]=i)&&(t==="loading"&&(e[Tg]=i),i==null?e.removeAttribute(t):typeof i!="string"&&ab(e).includes(t)?e[t]=i:e.setAttribute(t,i))}function pu(e){return e.__attributes??(e.__attributes={[ib]:e.nodeName.includes("-"),[rb]:e.namespaceURI===h_})}var cd=new Map;function ab(e){var t=e.getAttribute("is")||e.nodeName,i=cd.get(t);if(i)return i;cd.set(t,i=[]);for(var r,s=e,n=Element.prototype;n!==s;){r=r_(s);for(var o in r)r[o].set&&i.push(o);s=nu(s)}return i}function rr(e,t,i=t){var r=new WeakSet;cu(e,"input",async s=>{var n=s?e.defaultValue:e.value;if(n=Zl(e)?Jl(n):n,i(n),Oe!==null&&r.add(Oe),await Nm(),n!==(n=t())){var o=e.selectionStart,a=e.selectionEnd,c=e.value.length;if(e.value=n??"",a!==null){var h=e.value.length;o===a&&a===c&&h>c?(e.selectionStart=h,e.selectionEnd=h):(e.selectionStart=o,e.selectionEnd=Math.min(a,h))}}}),Qr(t)==null&&e.value&&(i(Zl(e)?Jl(e.value):e.value),Oe!==null&&r.add(Oe)),da(()=>{var s=t();if(e===document.activeElement){var n=Za??Oe;if(r.has(n))return}Zl(e)&&s===Jl(e.value)||e.type==="date"&&!s&&!e.value||s!==e.value&&(e.value=s??"")})}function sr(e,t,i=t){cu(e,"change",r=>{var s=r?e.defaultChecked:e.checked;i(s)}),Qr(t)==null&&i(e.checked),da(()=>{var r=t();e.checked=!!r})}function Zl(e){var t=e.type;return t==="number"||t==="range"}function Jl(e){return e===""?null:+e}function ud(e,t){return e===t||(e==null?void 0:e[jr])===t}function Ze(e={},t,i,r){return fu(()=>{var s,n;return da(()=>{s=n,n=(r==null?void 0:r())||[],Qr(()=>{e!==i(...n)&&(t(e,...n),s&&ud(i(...s),e)&&t(null,...s))})}),()=>{Dr(()=>{n&&ud(i(...n),e)&&t(null,...n)})}}),e}let Ea=!1;function lb(e){var t=Ea;try{return Ea=!1,[e(),Ea]}finally{Ea=t}}function Pr(e,t,i,r){var O;var s=(i&Vg)!==0,n=(i&Gg)!==0,o=r,a=!0,c=()=>(a&&(a=!1,o=n?Qr(r):r),o),h;if(s){var d=jr in e||Dg in e;h=((O=Mn(e,t))==null?void 0:O.set)??(d&&t in e?C=>e[t]=C:void 0)}var u,f=!1;s?[u,f]=lb(()=>e[t]):u=e[t],u===void 0&&r!==void 0&&(u=c(),h&&(Bg(),h(u)));var _;if(_=()=>{var C=e[t];return C===void 0?c():(a=!0,C)},(i&Yg)===0)return _;if(h){var p=e.$$legacy;return(function(C,y){return arguments.length>0?((!y||p||f)&&h(y?_():C),C):_()})}var b=!1,g=((i&jg)!==0?Dl:x_)(()=>(b=!1,_()));s&&l(g);var S=Ve;return(function(C,y){if(arguments.length>0){const x=y?l(g):s?$e(C):C;return m(g,x),b=!0,o!==void 0&&(o=x),C}return Ts&&b||(S.f&qr)!==0?g.v:l(g)})}function vo(e){Rt===null&&au(),zi(()=>{const t=Qr(e);if(typeof t=="function")return t})}function hb(e){Rt===null&&au(),vo(()=>()=>Qr(e))}const cb="5";var Kf;typeof window<"u"&&((Kf=window.__svelte??(window.__svelte={})).v??(Kf.v=new Set)).add(cb);class iv extends Error{constructor(i){super("conflict");Vi(this,"sessionId");this.name="ConflictError",this.sessionId=i}}async function kt(e){if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function ub(e){const t=await fetch("/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pin:e})});if(!t.ok){const i=await t.json();throw new Error(i.error||"Authentication failed")}}async function db(){return(await fetch("/sessions")).ok}async function fb(){return kt(await fetch("/sessions"))}async function _b(){return kt(await fetch("/worktrees"))}async function vb(){return(await kt(await fetch("/workspaces"))).workspaces}async function pb(e){return(await kt(await fetch("/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))).workspaces}async function dd(e,t){const i=new URLSearchParams;return e&&i.set("path",e),kt(await fetch("/workspaces/browse?"+i.toString()))}async function gb(e){return kt(await fetch("/workspaces/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))}async function mb(e){var i,r;const t=await kt(await fetch("/workspaces/dashboard?path="+encodeURIComponent(e)));return{prs:((i=t.pullRequests)==null?void 0:i.prs)??[],activity:t.activity??[],isGitRepo:!0,defaultBranch:null,hasGhCli:!((r=t.pullRequests)!=null&&r.error)}}async function bb(e,t){const i=await fetch("/workspaces/ci-status?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function yb(e,t){const i=await fetch("/workspaces/pr?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function Sb(e){return(await kt(await fetch("/workspaces/current-branch?path="+encodeURIComponent(e)))).branch}async function eh(e,t){const i=await fetch("/workspaces/worktree?path="+encodeURIComponent(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!i.ok){const r=await i.json();throw new Error(r.error||"Failed to create worktree")}return i.json()}async function wb(e,t){return(await fetch("/workspaces/branch?path="+encodeURIComponent(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})})).json()}async function rv(e,t={}){const i=new URLSearchParams({repo:e});return t.refresh&&i.set("refresh","1"),kt(await fetch("/branches?"+i.toString()))}async function On(e){const t=await fetch("/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.status===409){const i=await t.json();throw new iv(i.sessionId??"")}return kt(t)}async function gu(e){const t=await fetch("/sessions/repo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.status===409){const i=await t.json();throw new iv(i.sessionId??"")}return kt(t)}async function Cb(e){const t=await fetch("/sessions/terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})});return kt(t)}async function kb(e){await fetch("/sessions/"+e,{method:"DELETE"})}async function sv(e,t){const i=await fetch("/worktrees",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreePath:e,repoPath:t})});if(!i.ok){const r=await i.json();throw new Error(r.error||"Failed to delete worktree")}}async function xb(e,t,i){return kt(await fetch("/sessions/"+e+"/image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t,mimeType:i})}))}async function nv(){return kt(await fetch("/version"))}async function ov(){return kt(await fetch("/update",{method:"POST"}))}async function Eb(){return(await kt(await fetch("/config/defaultAgent"))).defaultAgent}async function Db(e){if(!(await fetch("/config/defaultAgent",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultAgent:e})})).ok)throw new Error("Failed to update default agent")}async function Pl(e){return(await kt(await fetch(`/config/${e}`)))[e]}async function Al(e,t){const i=await fetch(`/config/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(!i.ok){const r=await i.json();throw new Error(r.error||`Failed to update ${e}`)}}const Tb=()=>Pl("defaultContinue"),Rb=e=>Al("defaultContinue",e),Pb=()=>Pl("defaultYolo"),Ab=e=>Al("defaultYolo",e),Mb=()=>Pl("launchInTmux"),Ob=e=>Al("launchInTmux",e),Lb=()=>Pl("defaultNotifications"),Ib=e=>Al("defaultNotifications",e);async function Bb(e,t){if(!(await fetch("/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscription:e,sessionIds:t})})).ok)throw new Error("Push subscribe failed")}async function Nb(e){return kt(await fetch("/workspaces/settings?path="+encodeURIComponent(e)))}async function fd(e){return kt(await fetch("/workspaces/settings/merged?path="+encodeURIComponent(e)))}async function _d(e,t){const i=await fetch("/workspaces/settings?path="+encodeURIComponent(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok){const r=await i.json();throw new Error(r.error||"Failed to update workspace settings")}}async function Fb(){return kt(await fetch("/analytics/size"))}async function Wb(){if(!(await fetch("/analytics/events",{method:"DELETE"})).ok)throw new Error("Failed to clear analytics")}let tl=F(!1),Ih=F(null),Bh=F(!0);function av(){return{get authenticated(){return l(tl)},get pinError(){return l(Ih)},get checking(){return l(Bh)}}}async function Hb(){m(Bh,!0);try{m(tl,await db(),!0)}catch{m(tl,!1)}finally{m(Bh,!1)}}async function zb(e){m(Ih,null);try{await ub(e),m(tl,!0)}catch(t){m(Ih,t instanceof Error?t.message:"Authentication failed",!0)}}const lv="claude-remote-sidebar-width",hv="claude-remote-sidebar-collapsed",Nh="claude-remote-active-workspace",cv=240,uv=180,dv=500,Ub=44;function Kb(){try{const e=localStorage.getItem(lv);if(e){const t=parseInt(e,10);if(t>=uv&&t<=dv)return t}}catch{}return cv}function qb(){try{return localStorage.getItem(hv)==="true"}catch{return!1}}function jb(){try{return localStorage.getItem(Nh)}catch{return null}}let il=F(!1),Fh=F($e(Kb())),No=F($e(qb())),vd=F(""),pd=F($e(jb())),rl=F(!1);function mu(){return{get sidebarOpen(){return l(il)},set sidebarOpen(e){m(il,e,!0)},get sidebarWidth(){return l(Fh)},set sidebarWidth(e){m(Fh,e,!0)},get sidebarCollapsed(){return l(No)},set sidebarCollapsed(e){m(No,e,!0)},get searchQuery(){return l(vd)},set searchQuery(e){m(vd,e,!0)},get activeWorkspacePath(){return l(pd)},set activeWorkspacePath(e){m(pd,e,!0);try{e===null?localStorage.removeItem(Nh):localStorage.setItem(Nh,e)}catch{}},get reorderMode(){return l(rl)},set reorderMode(e){m(rl,e,!0)}}}function gd(){m(il,!0)}function ki(){m(il,!1)}function Yb(){m(rl,!0)}function Vb(){m(rl,!1)}function md(){try{localStorage.setItem(lv,String(l(Fh)))}catch{}}function th(){m(No,!l(No));try{localStorage.setItem(hv,String(l(No)))}catch{}}const fv="claude-remote-collapsed-workspaces";function Gb(){try{const e=localStorage.getItem(fv);if(e)return new Set(JSON.parse(e))}catch{}return new Set}let Ns=F($e(Gb()));function Xb(){try{localStorage.setItem(fv,JSON.stringify([...l(Ns)]))}catch{}}function $b(e){l(Ns).has(e)?l(Ns).delete(e):l(Ns).add(e),m(Ns,new Set(l(Ns)),!0),Xb()}function Qb(e){return l(Ns).has(e)}let _v=F(0);setInterval(()=>{km(_v)},3e4);function Zb(){return l(_v)}let Fo=null,Jb=null;function ey(e){Fo=e,"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const i=t.data;i.type==="notification-click"&&i.sessionId&&Fo&&Fo(i.sessionId,i.sessionType||"repo")})}function vv(){return document.hidden||!document.hasFocus()}function pv(e){if(typeof Notification>"u"||Notification.permission!=="granted")return;const t=new Notification(e.displayName||"Claude Remote CLI",{body:"Session needs your input",tag:"session-"+e.id,data:{sessionId:e.id,sessionType:e.type}});t.onclick=()=>{window.focus(),Fo&&Fo(e.id,e.type),t.close()}}function gv(){return"serviceWorker"in navigator&&"PushManager"in window}async function ty(){if(gv())try{Jb=await navigator.serviceWorker.register("/sw.js")}catch{return}}async function iy(e){if(gv())try{const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();i&&await Bb(i.toJSON(),e)}catch{}}const mv="claude-remote-notifications",Wh="claude-remote-active-session";function ry(){try{return localStorage.getItem(Wh)}catch{return null}}function bv(e){try{e===null?localStorage.removeItem(Wh):localStorage.setItem(Wh,e)}catch{}}let gn=F($e([])),yv=F($e([])),bu=F($e([])),cn=F($e(ry())),Xr=$e({}),mn=$e({}),Ml=$e({}),Ar=F($e({}));function sy(){try{const e=localStorage.getItem(mv);e&&m(Ar,JSON.parse(e),!0)}catch{}}sy();function Sv(){try{localStorage.setItem(mv,JSON.stringify(l(Ar)))}catch{}}function yu(){return{get sessions(){return l(gn)},get worktrees(){return l(yv)},get workspaces(){return l(bu)},get activeSessionId(){return l(cn)},set activeSessionId(e){m(cn,e,!0),bv(e)},get attentionSessions(){return Xr},get loadingItems(){return Ml},get notificationSessions(){return l(Ar)}}}async function gt(){try{const[e,t,i]=await Promise.all([fb(),_b(),vb()]);m(gn,e,!0),m(yv,t,!0),m(bu,i,!0);const r=new Set(l(gn).map(n=>n.id));l(cn)!==null&&!r.has(l(cn))&&(m(cn,null),bv(null));let s=!1;for(const n of Object.keys(Xr))r.has(n)||delete Xr[n];for(const n of Object.keys(mn))r.has(n)||delete mn[n];for(const n of Object.keys(l(Ar)))r.has(n)||(delete l(Ar)[n],s=!0);s&&Sv()}catch{}}function wv(e){return l(gn).filter(t=>t.repoPath===e||t.repoPath.startsWith(e+"/"))}const Cv=3e4;function ny(e,t,i){const r=l(gn).find(s=>s.id===e);r&&(r.branchName=t,r.displayName=i)}function oy(e,t){const i=l(gn).find(r=>r.id===e);if(i&&(i.agentState=t),t==="waiting-for-input"&&e!==l(cn)&&(i==null?void 0:i.type)!=="terminal"){const r=mn[e];if(r&&Date.now()-r<Cv)return;delete mn[e],Xr[e]=!0,i&&l(Ar)[e]&&vv()&&pv(i)}else(t==="processing"||t==="initializing")&&delete Xr[e]}function ay(e,t){const i=l(gn).find(r=>r.id===e);if(i&&(i.idle=t),!(i!=null&&i.agentState&&i.agentState!=="idle"))if(t&&e!==l(cn)&&(i==null?void 0:i.type)!=="terminal"){const r=mn[e];if(r&&Date.now()-r<Cv)return;delete mn[e],Xr[e]=!0,i&&l(Ar)[e]&&vv()&&pv(i)}else delete Xr[e]}function bd(e){delete Xr[e],mn[e]=Date.now()}function As(e,t){e in l(Ar)||(l(Ar)[e]=t,Sv())}function ly(){return Object.entries(l(Ar)).filter(([,e])=>e).map(([e])=>e)}function ih(e){return Xr[e.id]?"attention":e.agentState==="permission-prompt"?"permission-prompt":e.idle?"idle":"running"}function Tn(e){Ml[e]=!0}function Rn(e){delete Ml[e]}function Qi(e){return!!Ml[e]}async function hy(e){const t=await pb(e);m(bu,t,!0)}const kv=location.protocol==="https:"?"wss:":"ws:";let Dt=null,rt=null,Ti=null;const yd=30;let Wo=null,un=0,Wa=null,sl=!1,Us=null,Ha=null,nl=!1,Ks=null,Hh=null,za=null,zh=null,Uh=null,Kh=null;const xv=3e4,Ev=5e3,Dv='{"type":"ping"}',Tv='{"type":"pong"}';function Su(e){Dt&&(Dt.onclose=null,Dt.close(),Dt=null),Kh=e,Vh();const t=kv+"//"+location.host+"/ws/events";Dt=new WebSocket(t),Dt.onopen=()=>{uy()},Dt.onmessage=i=>{const r=i.data;if(nl&&Ov(),r!==Tv)try{e(JSON.parse(r))}catch{}},Dt.onclose=()=>{Vh(),setTimeout(()=>Su(e),3e3)},Dt.onerror=()=>{}}function Rv(e,t,i,r){Wo&&(clearTimeout(Wo),Wo=null),un=0,qh(),Hh=e,za=t,zh=i,Uh=r,Ti&&(Ti.onopen=null,Ti.onmessage=null,Ti.onclose=null,Ti.onerror=null,Ti.close(),Ti=null),rt&&(rt.onclose=null,rt.close(),rt=null);const s=kv+"//"+location.host+"/ws/"+e,n=new WebSocket(s);Ti=n,n.onopen=()=>{Ti=null,rt=n,un=0,i(),cy()},n.onmessage=o=>{const a=o.data;sl&&Av(),a!==Tv&&t.write(a)},n.onclose=o=>{if(qh(),Ti===n&&(Ti=null),!(Ti!==n&&rt!==n)){if(o.code===1e3){t.write(`\r
1
+ var mg=Object.defineProperty;var Qu=e=>{throw TypeError(e)};var bg=(e,t,i)=>t in e?mg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Vi=(e,t,i)=>bg(e,typeof t!="symbol"?t+"":t,i),Gl=(e,t,i)=>t.has(e)||Qu("Cannot "+i);var v=(e,t,i)=>(Gl(e,t,"read from private field"),i?i.call(e):t.get(e)),ee=(e,t,i)=>t.has(e)?Qu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),j=(e,t,i,r)=>(Gl(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),xe=(e,t,i)=>(Gl(e,t,"access private method"),i);var Ca=(e,t,i,r)=>({set _(s){j(e,t,s,i)},get _(){return v(e,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function i(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function r(s){if(s.ep)return;s.ep=!0;const n=i(s);fetch(s.href,n)}})();const yh=!1;var su=Array.isArray,yg=Array.prototype.indexOf,io=Array.prototype.includes,xl=Array.from,Sg=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,r_=Object.getOwnPropertyDescriptors,wg=Object.prototype,Cg=Array.prototype,nu=Object.getPrototypeOf,Zu=Object.isExtensible;const kg=()=>{};function xg(e){for(var t=0;t<e.length;t++)e[t]()}function s_(){var e,t,i=new Promise((r,s)=>{e=r,t=s});return{promise:i,resolve:e,reject:t}}function Eg(e,t){if(Array.isArray(e))return e;if(!(Symbol.iterator in e))return Array.from(e);const i=[];for(const r of e)if(i.push(r),i.length===t)break;return i}const Zt=2,ha=4,ca=8,n_=1<<24,$r=16,cr=32,Sn=64,Sh=128,zi=512,Ut=1024,Jt=2048,hr=4096,xi=8192,qr=16384,_n=32768,vn=65536,Ju=1<<17,o_=1<<18,fo=1<<19,a_=1<<20,Ur=1<<25,pn=65536,wh=1<<21,ou=1<<22,ys=1<<23,jr=Symbol("$state"),Dg=Symbol("legacy props"),Tg=Symbol(""),Fs=new class extends Error{constructor(){super(...arguments);Vi(this,"name","StaleReactionError");Vi(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var zf;const Rg=!!((zf=globalThis.document)!=null&&zf.contentType)&&globalThis.document.contentType.includes("xml");function au(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Pg(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Ag(e,t,i){throw new Error("https://svelte.dev/e/each_key_duplicate")}function Mg(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Og(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Lg(e){throw new Error("https://svelte.dev/e/effect_orphan")}function Ig(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Bg(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function Ng(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Fg(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Wg(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Hg(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const zg=1,Ug=2,l_=4,Kg=8,qg=16,jg=1,Yg=4,Vg=8,Gg=16,Xg=1,$g=2,Yt=Symbol(),h_="http://www.w3.org/1999/xhtml",Qg="http://www.w3.org/2000/svg",Zg="http://www.w3.org/1998/Math/MathML";function Jg(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function em(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function c_(e){return e===this.v}function u_(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function d_(e){return!u_(e,this.v)}let tm=!1,Rt=null;function ro(e){Rt=e}function f_(e){return v_().get(e)}function im(e,t){return v_().set(e,t),t}function dt(e,t=!1,i){Rt={p:Rt,i:!1,c:null,e:null,s:e,x:null,l:null}}function ft(e){var t=Rt,i=t.e;if(i!==null){t.e=null;for(var r of i)N_(r)}return e!==void 0&&(t.x=e),t.i=!0,Rt=t.p,e??{}}function __(){return!0}function v_(e){return Rt===null&&au(),Rt.c??(Rt.c=new Map(rm(Rt)||void 0))}function rm(e){let t=e.p;for(;t!==null;){const i=t.c;if(i!==null)return i;t=t.p}return null}let Ws=[];function p_(){var e=Ws;Ws=[],xg(e)}function Dr(e){if(Ws.length===0&&!Io){var t=Ws;queueMicrotask(()=>{t===Ws&&p_()})}Ws.push(e)}function sm(){for(;Ws.length>0;)p_()}function g_(e){var t=Ve;if(t===null)return Ue.f|=ys,e;if((t.f&_n)===0&&(t.f&ha)===0)throw e;gs(e,t)}function gs(e,t){for(;t!==null;){if((t.f&Sh)!==0){if((t.f&_n)===0)throw e;try{t.b.error(e);return}catch(i){e=i}}t=t.parent}throw e}const nm=-7169;function bt(e,t){e.f=e.f&nm|t}function lu(e){(e.f&zi)!==0||e.deps===null?bt(e,Ut):bt(e,hr)}function m_(e){if(e!==null)for(const t of e)(t.f&Zt)===0||(t.f&pn)===0||(t.f^=pn,m_(t.deps))}function b_(e,t,i){(e.f&Jt)!==0?t.add(e):(e.f&hr)!==0&&i.add(e),m_(e.deps),bt(e,Ut)}const ka=new Set;let Oe=null,Za=null,$t=null,_i=[],El=null,Ch=!1,Io=!1;var Bn,Nn,Ys,Fn,ea,ta,Vs,Nr,Wn,Di,kh,xh,Eh,y_;const Yu=class Yu{constructor(){ee(this,Di);Vi(this,"current",new Map);Vi(this,"previous",new Map);ee(this,Bn,new Set);ee(this,Nn,new Set);ee(this,Ys,0);ee(this,Fn,0);ee(this,ea,null);ee(this,ta,new Set);ee(this,Vs,new Set);ee(this,Nr,new Map);Vi(this,"is_fork",!1);ee(this,Wn,!1)}skip_effect(t){v(this,Nr).has(t)||v(this,Nr).set(t,{d:[],m:[]})}unskip_effect(t){var i=v(this,Nr).get(t);if(i){v(this,Nr).delete(t);for(var r of i.d)bt(r,Jt),or(r);for(r of i.m)bt(r,hr),or(r)}}process(t){var s;_i=[],this.apply();var i=[],r=[];for(const n of t)xe(this,Di,xh).call(this,n,i,r);if(xe(this,Di,kh).call(this)){xe(this,Di,Eh).call(this,r),xe(this,Di,Eh).call(this,i);for(const[n,o]of v(this,Nr))k_(n,o)}else{for(const n of v(this,Bn))n();v(this,Bn).clear(),v(this,Ys)===0&&xe(this,Di,y_).call(this),Za=this,Oe=null,ed(r),ed(i),Za=null,(s=v(this,ea))==null||s.resolve()}$t=null}capture(t,i){i!==Yt&&!this.previous.has(t)&&this.previous.set(t,i),(t.f&ys)===0&&(this.current.set(t,t.v),$t==null||$t.set(t,t.v))}activate(){Oe=this,this.apply()}deactivate(){Oe===this&&(Oe=null,$t=null)}flush(){if(this.activate(),_i.length>0){if(S_(),Oe!==null&&Oe!==this)return}else v(this,Ys)===0&&this.process([]);this.deactivate()}discard(){for(const t of v(this,Nn))t(this);v(this,Nn).clear()}increment(t){j(this,Ys,v(this,Ys)+1),t&&j(this,Fn,v(this,Fn)+1)}decrement(t){j(this,Ys,v(this,Ys)-1),t&&j(this,Fn,v(this,Fn)-1),!v(this,Wn)&&(j(this,Wn,!0),Dr(()=>{j(this,Wn,!1),xe(this,Di,kh).call(this)?_i.length>0&&this.flush():this.revive()}))}revive(){for(const t of v(this,ta))v(this,Vs).delete(t),bt(t,Jt),or(t);for(const t of v(this,Vs))bt(t,hr),or(t);this.flush()}oncommit(t){v(this,Bn).add(t)}ondiscard(t){v(this,Nn).add(t)}settled(){return(v(this,ea)??j(this,ea,s_())).promise}static ensure(){if(Oe===null){const t=Oe=new Yu;ka.add(Oe),Io||Dr(()=>{Oe===t&&t.flush()})}return Oe}apply(){}};Bn=new WeakMap,Nn=new WeakMap,Ys=new WeakMap,Fn=new WeakMap,ea=new WeakMap,ta=new WeakMap,Vs=new WeakMap,Nr=new WeakMap,Wn=new WeakMap,Di=new WeakSet,kh=function(){return this.is_fork||v(this,Fn)>0},xh=function(t,i,r){t.f^=Ut;for(var s=t.first;s!==null;){var n=s.f,o=(n&(cr|Sn))!==0,a=o&&(n&Ut)!==0,c=a||(n&xi)!==0||v(this,Nr).has(s);if(!c&&s.fn!==null){o?s.f^=Ut:(n&ha)!==0?i.push(s):fa(s)&&((n&$r)!==0&&v(this,Vs).add(s),no(s));var h=s.first;if(h!==null){s=h;continue}}for(;s!==null;){var d=s.next;if(d!==null){s=d;break}s=s.parent}}},Eh=function(t){for(var i=0;i<t.length;i+=1)b_(t[i],v(this,ta),v(this,Vs))},y_=function(){var s;if(ka.size>1){this.previous.clear();var t=$t,i=!0;for(const n of ka){if(n===this){i=!1;continue}const o=[];for(const[c,h]of this.current){if(n.current.has(c))if(i&&h!==n.current.get(c))n.current.set(c,h);else continue;o.push(c)}if(o.length===0)continue;const a=[...n.current.keys()].filter(c=>!this.current.has(c));if(a.length>0){var r=_i;_i=[];const c=new Set,h=new Map;for(const d of o)w_(d,a,c,h);if(_i.length>0){Oe=n,n.apply();for(const d of _i)xe(s=n,Di,xh).call(s,d,[],[]);n.deactivate()}_i=r}}Oe=null,$t=t}ka.delete(this)};let Ss=Yu;function om(e){var t=Io;Io=!0;try{for(var i;;){if(sm(),_i.length===0&&(Oe==null||Oe.flush(),_i.length===0))return El=null,i;S_()}}finally{Io=t}}function S_(){Ch=!0;var e=null;try{for(var t=0;_i.length>0;){var i=Ss.ensure();if(t++>1e3){var r,s;am()}i.process(_i),ws.clear()}}finally{_i=[],Ch=!1,El=null}}function am(){try{Ig()}catch(e){gs(e,El)}}let $i=null;function ed(e){var t=e.length;if(t!==0){for(var i=0;i<t;){var r=e[i++];if((r.f&(qr|xi))===0&&fa(r)&&($i=new Set,no(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&H_(r),($i==null?void 0:$i.size)>0)){ws.clear();for(const s of $i){if((s.f&(qr|xi))!==0)continue;const n=[s];let o=s.parent;for(;o!==null;)$i.has(o)&&($i.delete(o),n.push(o)),o=o.parent;for(let a=n.length-1;a>=0;a--){const c=n[a];(c.f&(qr|xi))===0&&no(c)}}$i.clear()}}$i=null}}function w_(e,t,i,r){if(!i.has(e)&&(i.add(e),e.reactions!==null))for(const s of e.reactions){const n=s.f;(n&Zt)!==0?w_(s,t,i,r):(n&(ou|$r))!==0&&(n&Jt)===0&&C_(s,t,r)&&(bt(s,Jt),or(s))}}function C_(e,t,i){const r=i.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const s of e.deps){if(io.call(t,s))return!0;if((s.f&Zt)!==0&&C_(s,t,i))return i.set(s,!0),!0}return i.set(e,!1),!1}function or(e){var t=El=e,i=t.b;if(i!=null&&i.is_pending&&(e.f&(ha|ca|n_))!==0&&(e.f&_n)===0){i.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var r=t.f;if(Ch&&t===Ve&&(r&$r)!==0&&(r&o_)===0&&(r&_n)!==0)return;if((r&(Sn|cr))!==0){if((r&Ut)===0)return;t.f^=Ut}}_i.push(t)}function k_(e,t){if(!((e.f&cr)!==0&&(e.f&Ut)!==0)){(e.f&Jt)!==0?t.d.push(e):(e.f&hr)!==0&&t.m.push(e),bt(e,Ut);for(var i=e.first;i!==null;)k_(i,t),i=i.next}}function lm(e){let t=0,i=Ds(0),r;return()=>{uu()&&(l(i),da(()=>(t===0&&(r=Qr(()=>e(()=>Cs(i)))),t+=1,()=>{Dr(()=>{t-=1,t===0&&(r==null||r(),r=void 0,Cs(i))})})))}}var hm=vn|fo;function cm(e,t,i,r){new um(e,t,i,r)}var Oi,iu,gr,Gs,ui,mr,wi,Zi,Fr,Xs,as,Hn,zn,Un,Wr,Sl,At,dm,fm,_m,Dh,Ba,Na,Th;class um{constructor(t,i,r,s){ee(this,At);Vi(this,"parent");Vi(this,"is_pending",!1);Vi(this,"transform_error");ee(this,Oi);ee(this,iu,null);ee(this,gr);ee(this,Gs);ee(this,ui);ee(this,mr,null);ee(this,wi,null);ee(this,Zi,null);ee(this,Fr,null);ee(this,Xs,0);ee(this,as,0);ee(this,Hn,!1);ee(this,zn,new Set);ee(this,Un,new Set);ee(this,Wr,null);ee(this,Sl,lm(()=>(j(this,Wr,Ds(v(this,Xs))),()=>{j(this,Wr,null)})));var n;j(this,Oi,t),j(this,gr,i),j(this,Gs,o=>{var a=Ve;a.b=this,a.f|=Sh,r(o)}),this.parent=Ve.b,this.transform_error=s??((n=this.parent)==null?void 0:n.transform_error)??(o=>o),j(this,ui,Rl(()=>{xe(this,At,Dh).call(this)},hm))}defer_effect(t){b_(t,v(this,zn),v(this,Un))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!v(this,gr).pending}update_pending_count(t){xe(this,At,Th).call(this,t),j(this,Xs,v(this,Xs)+t),!(!v(this,Wr)||v(this,Hn))&&(j(this,Hn,!0),Dr(()=>{j(this,Hn,!1),v(this,Wr)&&so(v(this,Wr),v(this,Xs))}))}get_effect_pending(){return v(this,Sl).call(this),l(v(this,Wr))}error(t){var i=v(this,gr).onerror;let r=v(this,gr).failed;if(!i&&!r)throw t;v(this,mr)&&(gi(v(this,mr)),j(this,mr,null)),v(this,wi)&&(gi(v(this,wi)),j(this,wi,null)),v(this,Zi)&&(gi(v(this,Zi)),j(this,Zi,null));var s=!1,n=!1;const o=()=>{if(s){em();return}s=!0,n&&Hg(),v(this,Zi)!==null&&ln(v(this,Zi),()=>{j(this,Zi,null)}),xe(this,At,Na).call(this,()=>{Ss.ensure(),xe(this,At,Dh).call(this)})},a=c=>{try{n=!0,i==null||i(c,o),n=!1}catch(h){gs(h,v(this,ui)&&v(this,ui).parent)}r&&j(this,Zi,xe(this,At,Na).call(this,()=>{Ss.ensure();try{return Ni(()=>{var h=Ve;h.b=this,h.f|=Sh,r(v(this,Oi),()=>c,()=>o)})}catch(h){return gs(h,v(this,ui).parent),null}}))};Dr(()=>{var c;try{c=this.transform_error(t)}catch(h){gs(h,v(this,ui)&&v(this,ui).parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(a,h=>gs(h,v(this,ui)&&v(this,ui).parent)):a(c)})}}Oi=new WeakMap,iu=new WeakMap,gr=new WeakMap,Gs=new WeakMap,ui=new WeakMap,mr=new WeakMap,wi=new WeakMap,Zi=new WeakMap,Fr=new WeakMap,Xs=new WeakMap,as=new WeakMap,Hn=new WeakMap,zn=new WeakMap,Un=new WeakMap,Wr=new WeakMap,Sl=new WeakMap,At=new WeakSet,dm=function(){try{j(this,mr,Ni(()=>v(this,Gs).call(this,v(this,Oi))))}catch(t){this.error(t)}},fm=function(t){const i=v(this,gr).failed;i&&j(this,Zi,Ni(()=>{i(v(this,Oi),()=>t,()=>()=>{})}))},_m=function(){const t=v(this,gr).pending;t&&(this.is_pending=!0,j(this,wi,Ni(()=>t(v(this,Oi)))),Dr(()=>{var i=j(this,Fr,document.createDocumentFragment()),r=Yr();i.append(r),j(this,mr,xe(this,At,Na).call(this,()=>(Ss.ensure(),Ni(()=>v(this,Gs).call(this,r))))),v(this,as)===0&&(v(this,Oi).before(i),j(this,Fr,null),ln(v(this,wi),()=>{j(this,wi,null)}),xe(this,At,Ba).call(this))}))},Dh=function(){try{if(this.is_pending=this.has_pending_snippet(),j(this,as,0),j(this,Xs,0),j(this,mr,Ni(()=>{v(this,Gs).call(this,v(this,Oi))})),v(this,as)>0){var t=j(this,Fr,document.createDocumentFragment());K_(v(this,mr),t);const i=v(this,gr).pending;j(this,wi,Ni(()=>i(v(this,Oi))))}else xe(this,At,Ba).call(this)}catch(i){this.error(i)}},Ba=function(){this.is_pending=!1;for(const t of v(this,zn))bt(t,Jt),or(t);for(const t of v(this,Un))bt(t,hr),or(t);v(this,zn).clear(),v(this,Un).clear()},Na=function(t){var i=Ve,r=Ue,s=Rt;Rr(v(this,ui)),qi(v(this,ui)),ro(v(this,ui).ctx);try{return t()}catch(n){return g_(n),null}finally{Rr(i),qi(r),ro(s)}},Th=function(t){var i;if(!this.has_pending_snippet()){this.parent&&xe(i=this.parent,At,Th).call(i,t);return}j(this,as,v(this,as)+t),v(this,as)===0&&(xe(this,At,Ba).call(this),v(this,wi)&&ln(v(this,wi),()=>{j(this,wi,null)}),v(this,Fr)&&(v(this,Oi).before(v(this,Fr)),j(this,Fr,null)))};function vm(e,t,i,r){const s=Dl;var n=e.filter(u=>!u.settled);if(i.length===0&&n.length===0){r(t.map(s));return}var o=Ve,a=pm(),c=n.length===1?n[0].promise:n.length>1?Promise.all(n.map(u=>u.promise)):null;function h(u){a();try{r(u)}catch(f){(o.f&qr)===0&&gs(f,o)}Rh()}if(i.length===0){c.then(()=>h(t.map(s)));return}function d(){a(),Promise.all(i.map(u=>mm(u))).then(u=>h([...t.map(s),...u])).catch(u=>gs(u,o))}c?c.then(d):d()}function pm(){var e=Ve,t=Ue,i=Rt,r=Oe;return function(n=!0){Rr(e),qi(t),ro(i),n&&(r==null||r.activate())}}function Rh(e=!0){Rr(null),qi(null),ro(null),e&&(Oe==null||Oe.deactivate())}function gm(){var e=Ve.b,t=Oe,i=e.is_rendered();return e.update_pending_count(1),t.increment(i),()=>{e.update_pending_count(-1),t.decrement(i)}}function Dl(e){var t=Zt|Jt,i=Ue!==null&&(Ue.f&Zt)!==0?Ue:null;return Ve!==null&&(Ve.f|=fo),{ctx:Rt,deps:null,effects:null,equals:c_,f:t,fn:e,reactions:null,rv:0,v:Yt,wv:0,parent:i??Ve,ac:null}}function mm(e,t,i){Ve===null&&Pg();var s=void 0,n=Ds(Yt),o=!Ue,a=new Map;return Om(()=>{var f;var c=s_();s=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(Rh)}catch(_){c.reject(_),Rh()}var h=Oe;if(o){var d=gm();(f=a.get(h))==null||f.reject(Fs),a.delete(h),a.set(h,c)}const u=(_,p=void 0)=>{if(h.activate(),p)p!==Fs&&(n.f|=ys,so(n,p));else{(n.f&ys)!==0&&(n.f^=ys),so(n,_);for(const[b,g]of a){if(a.delete(b),b===h)break;g.reject(Fs)}}d&&d()};c.promise.then(u,_=>u(null,_||"unknown"))}),du(()=>{for(const c of a.values())c.reject(Fs)}),new Promise(c=>{function h(d){function u(){d===s?c(n):h(s)}d.then(u,u)}h(s)})}function me(e){const t=Dl(e);return q_(t),t}function x_(e){const t=Dl(e);return t.equals=d_,t}function bm(e){var t=e.effects;if(t!==null){e.effects=null;for(var i=0;i<t.length;i+=1)gi(t[i])}}function ym(e){for(var t=e.parent;t!==null;){if((t.f&Zt)===0)return(t.f&qr)===0?t:null;t=t.parent}return null}function hu(e){var t,i=Ve;Rr(ym(e));try{e.f&=~pn,bm(e),t=G_(e)}finally{Rr(i)}return t}function E_(e){var t=hu(e);if(!e.equals(t)&&(e.wv=Y_(),(!(Oe!=null&&Oe.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){bt(e,Ut);return}Ts||($t!==null?(uu()||Oe!=null&&Oe.is_fork)&&$t.set(e,t):lu(e))}function Sm(e){var t,i;if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&((t=r.teardown)==null||t.call(r),(i=r.ac)==null||i.abort(Fs),r.teardown=kg,r.ac=null,qo(r,0),_u(r))}function D_(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&no(t)}let Ph=new Set;const ws=new Map;let T_=!1;function Ds(e,t){var i={f:0,v:e,reactions:null,equals:c_,rv:0,wv:0};return i}function W(e,t){const i=Ds(e);return q_(i),i}function wm(e,t=!1,i=!0){const r=Ds(e);return t||(r.equals=d_),r}function m(e,t,i=!1){Ue!==null&&(!ar||(Ue.f&Ju)!==0)&&__()&&(Ue.f&(Zt|$r|ou|Ju))!==0&&(Ui===null||!io.call(Ui,e))&&Wg();let r=i?Xe(t):t;return so(e,r)}function so(e,t){if(!e.equals(t)){var i=e.v;Ts?ws.set(e,t):ws.set(e,i),e.v=t;var r=Ss.ensure();if(r.capture(e,i),(e.f&Zt)!==0){const s=e;(e.f&Jt)!==0&&hu(s),lu(s)}e.wv=Y_(),R_(e,Jt),Ve!==null&&(Ve.f&Ut)!==0&&(Ve.f&(cr|Sn))===0&&(Mi===null?Im([e]):Mi.push(e)),!r.is_fork&&Ph.size>0&&!T_&&Cm()}return t}function Cm(){T_=!1;for(const e of Ph)(e.f&Ut)!==0&&bt(e,hr),fa(e)&&no(e);Ph.clear()}function km(e,t=1){var i=l(e),r=t===1?i++:i--;return m(e,i),r}function Cs(e){m(e,e.v+1)}function R_(e,t){var i=e.reactions;if(i!==null)for(var r=i.length,s=0;s<r;s++){var n=i[s],o=n.f,a=(o&Jt)===0;if(a&&bt(n,t),(o&Zt)!==0){var c=n;$t==null||$t.delete(c),(o&pn)===0&&(o&zi&&(n.f|=pn),R_(c,hr))}else a&&((o&$r)!==0&&$i!==null&&$i.add(n),or(n))}}function Xe(e){if(typeof e!="object"||e===null||jr in e)return e;const t=nu(e);if(t!==wg&&t!==Cg)return e;var i=new Map,r=su(e),s=W(0),n=Vr,o=a=>{if(Vr===n)return a();var c=Ue,h=Vr;qi(null),sd(n);var d=a();return qi(c),sd(h),d};return r&&i.set("length",W(e.length)),new Proxy(e,{defineProperty(a,c,h){(!("value"in h)||h.configurable===!1||h.enumerable===!1||h.writable===!1)&&Ng();var d=i.get(c);return d===void 0?o(()=>{var u=W(h.value);return i.set(c,u),u}):m(d,h.value,!0),!0},deleteProperty(a,c){var h=i.get(c);if(h===void 0){if(c in a){const d=o(()=>W(Yt));i.set(c,d),Cs(s)}}else m(h,Yt),Cs(s);return!0},get(a,c,h){var _;if(c===jr)return e;var d=i.get(c),u=c in a;if(d===void 0&&(!u||(_=Mn(a,c))!=null&&_.writable)&&(d=o(()=>{var p=Xe(u?a[c]:Yt),b=W(p);return b}),i.set(c,d)),d!==void 0){var f=l(d);return f===Yt?void 0:f}return Reflect.get(a,c,h)},getOwnPropertyDescriptor(a,c){var h=Reflect.getOwnPropertyDescriptor(a,c);if(h&&"value"in h){var d=i.get(c);d&&(h.value=l(d))}else if(h===void 0){var u=i.get(c),f=u==null?void 0:u.v;if(u!==void 0&&f!==Yt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return h},has(a,c){var f;if(c===jr)return!0;var h=i.get(c),d=h!==void 0&&h.v!==Yt||Reflect.has(a,c);if(h!==void 0||Ve!==null&&(!d||(f=Mn(a,c))!=null&&f.writable)){h===void 0&&(h=o(()=>{var _=d?Xe(a[c]):Yt,p=W(_);return p}),i.set(c,h));var u=l(h);if(u===Yt)return!1}return d},set(a,c,h,d){var R;var u=i.get(c),f=c in a;if(r&&c==="length")for(var _=h;_<u.v;_+=1){var p=i.get(_+"");p!==void 0?m(p,Yt):_ in a&&(p=o(()=>W(Yt)),i.set(_+"",p))}if(u===void 0)(!f||(R=Mn(a,c))!=null&&R.writable)&&(u=o(()=>W(void 0)),m(u,Xe(h)),i.set(c,u));else{f=u.v!==Yt;var b=o(()=>Xe(h));m(u,b)}var g=Reflect.getOwnPropertyDescriptor(a,c);if(g!=null&&g.set&&g.set.call(d,h),!f){if(r&&typeof c=="string"){var y=i.get("length"),O=Number(c);Number.isInteger(O)&&O>=y.v&&m(y,O+1)}Cs(s)}return!0},ownKeys(a){l(s);var c=Reflect.ownKeys(a).filter(u=>{var f=i.get(u);return f===void 0||f.v!==Yt});for(var[h,d]of i)d.v!==Yt&&!(h in a)&&c.push(h);return c},setPrototypeOf(){Fg()}})}function td(e){try{if(e!==null&&typeof e=="object"&&jr in e)return e[jr]}catch{}return e}function xm(e,t){return Object.is(td(e),td(t))}var Ja,P_,A_,M_,O_;function Em(){if(Ja===void 0){Ja=window,P_=document,A_=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,i=Text.prototype;M_=Mn(t,"firstChild").get,O_=Mn(t,"nextSibling").get,Zu(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Zu(i)&&(i.__t=void 0)}}function Yr(e=""){return document.createTextNode(e)}function an(e){return M_.call(e)}function ua(e){return O_.call(e)}function w(e,t){return an(e)}function Ct(e,t=!1){{var i=an(e);return i instanceof Comment&&i.data===""?ua(i):i}}function T(e,t=1,i=!1){let r=e;for(;t--;)r=ua(r);return r}function Dm(e){e.textContent=""}function L_(){return!1}function I_(e,t,i){return document.createElementNS(t??h_,e,void 0)}function Tm(e,t){{const i=document.body;e.autofocus=!0,Dr(()=>{document.activeElement===i&&e.focus()})}}let id=!1;function Rm(){id||(id=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const i of e.target.elements)(t=i.__on_r)==null||t.call(i)})},{capture:!0}))}function Tl(e){var t=Ue,i=Ve;qi(null),Rr(null);try{return e()}finally{qi(t),Rr(i)}}function cu(e,t,i,r=i){e.addEventListener(t,()=>Tl(i));const s=e.__on_r;s?e.__on_r=()=>{s(),r(!0)}:e.__on_r=()=>r(!0),Rm()}function B_(e){Ve===null&&(Ue===null&&Lg(),Og()),Ts&&Mg()}function Pm(e,t){var i=t.last;i===null?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}function Or(e,t,i){var r=Ve;r!==null&&(r.f&xi)!==0&&(e|=xi);var s={ctx:Rt,deps:null,nodes:null,f:e|Jt|zi,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(i)try{no(s)}catch(a){throw gi(s),a}else t!==null&&or(s);var n=s;if(i&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&fo)===0&&(n=n.first,(e&$r)!==0&&(e&vn)!==0&&n!==null&&(n.f|=vn)),n!==null&&(n.parent=r,r!==null&&Pm(n,r),Ue!==null&&(Ue.f&Zt)!==0&&(e&Sn)===0)){var o=Ue;(o.effects??(o.effects=[])).push(n)}return s}function uu(){return Ue!==null&&!ar}function du(e){const t=Or(ca,null,!1);return bt(t,Ut),t.teardown=e,t}function Ei(e){B_();var t=Ve.f,i=!Ue&&(t&cr)!==0&&(t&_n)===0;if(i){var r=Rt;(r.e??(r.e=[])).push(e)}else return N_(e)}function N_(e){return Or(ha|a_,e,!1)}function Am(e){return B_(),Or(ca|a_,e,!0)}function Mm(e){Ss.ensure();const t=Or(Sn|fo,e,!0);return(i={})=>new Promise(r=>{i.outro?ln(t,()=>{gi(t),r(void 0)}):(gi(t),r(void 0))})}function fu(e){return Or(ha,e,!1)}function Om(e){return Or(ou|fo,e,!0)}function da(e,t=0){return Or(ca|t,e,!0)}function he(e,t=[],i=[],r=[]){vm(r,t,i,s=>{Or(ca,()=>e(...s.map(l)),!0)})}function Rl(e,t=0){var i=Or($r|t,e,!0);return i}function Ni(e){return Or(cr|fo,e,!0)}function F_(e){var t=e.teardown;if(t!==null){const i=Ts,r=Ue;rd(!0),qi(null);try{t.call(null)}finally{rd(i),qi(r)}}}function _u(e,t=!1){var i=e.first;for(e.first=e.last=null;i!==null;){const s=i.ac;s!==null&&Tl(()=>{s.abort(Fs)});var r=i.next;(i.f&Sn)!==0?i.parent=null:gi(i,t),i=r}}function Lm(e){for(var t=e.first;t!==null;){var i=t.next;(t.f&cr)===0&&gi(t),t=i}}function gi(e,t=!0){var i=!1;(t||(e.f&o_)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(W_(e.nodes.start,e.nodes.end),i=!0),_u(e,t&&!i),qo(e,0),bt(e,qr);var r=e.nodes&&e.nodes.t;if(r!==null)for(const n of r)n.stop();F_(e);var s=e.parent;s!==null&&s.first!==null&&H_(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function W_(e,t){for(;e!==null;){var i=e===t?null:ua(e);e.remove(),e=i}}function H_(e){var t=e.parent,i=e.prev,r=e.next;i!==null&&(i.next=r),r!==null&&(r.prev=i),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=i))}function ln(e,t,i=!0){var r=[];z_(e,r,!0);var s=()=>{i&&gi(e),t&&t()},n=r.length;if(n>0){var o=()=>--n||s();for(var a of r)a.out(o)}else s()}function z_(e,t,i){if((e.f&xi)===0){e.f^=xi;var r=e.nodes&&e.nodes.t;if(r!==null)for(const a of r)(a.is_global||i)&&t.push(a);for(var s=e.first;s!==null;){var n=s.next,o=(s.f&vn)!==0||(s.f&cr)!==0&&(e.f&$r)!==0;z_(s,t,o?i:!1),s=n}}}function vu(e){U_(e,!0)}function U_(e,t){if((e.f&xi)!==0){e.f^=xi,(e.f&Ut)===0&&(bt(e,Jt),or(e));for(var i=e.first;i!==null;){var r=i.next,s=(i.f&vn)!==0||(i.f&cr)!==0;U_(i,s?t:!1),i=r}var n=e.nodes&&e.nodes.t;if(n!==null)for(const o of n)(o.is_global||t)&&o.in()}}function K_(e,t){if(e.nodes)for(var i=e.nodes.start,r=e.nodes.end;i!==null;){var s=i===r?null:ua(i);t.append(i),i=s}}let Fa=!1,Ts=!1;function rd(e){Ts=e}let Ue=null,ar=!1;function qi(e){Ue=e}let Ve=null;function Rr(e){Ve=e}let Ui=null;function q_(e){Ue!==null&&(Ui===null?Ui=[e]:Ui.push(e))}let vi=null,Si=0,Mi=null;function Im(e){Mi=e}let j_=1,Hs=0,Vr=Hs;function sd(e){Vr=e}function Y_(){return++j_}function fa(e){var t=e.f;if((t&Jt)!==0)return!0;if(t&Zt&&(e.f&=~pn),(t&hr)!==0){for(var i=e.deps,r=i.length,s=0;s<r;s++){var n=i[s];if(fa(n)&&E_(n),n.wv>e.wv)return!0}(t&zi)!==0&&$t===null&&bt(e,Ut)}return!1}function V_(e,t,i=!0){var r=e.reactions;if(r!==null&&!(Ui!==null&&io.call(Ui,e)))for(var s=0;s<r.length;s++){var n=r[s];(n.f&Zt)!==0?V_(n,t,!1):t===n&&(i?bt(n,Jt):(n.f&Ut)!==0&&bt(n,hr),or(n))}}function G_(e){var b;var t=vi,i=Si,r=Mi,s=Ue,n=Ui,o=Rt,a=ar,c=Vr,h=e.f;vi=null,Si=0,Mi=null,Ue=(h&(cr|Sn))===0?e:null,Ui=null,ro(e.ctx),ar=!1,Vr=++Hs,e.ac!==null&&(Tl(()=>{e.ac.abort(Fs)}),e.ac=null);try{e.f|=wh;var d=e.fn,u=d();e.f|=_n;var f=e.deps,_=Oe==null?void 0:Oe.is_fork;if(vi!==null){var p;if(_||qo(e,Si),f!==null&&Si>0)for(f.length=Si+vi.length,p=0;p<vi.length;p++)f[Si+p]=vi[p];else e.deps=f=vi;if(uu()&&(e.f&zi)!==0)for(p=Si;p<f.length;p++)((b=f[p]).reactions??(b.reactions=[])).push(e)}else!_&&f!==null&&Si<f.length&&(qo(e,Si),f.length=Si);if(__()&&Mi!==null&&!ar&&f!==null&&(e.f&(Zt|hr|Jt))===0)for(p=0;p<Mi.length;p++)V_(Mi[p],e);if(s!==null&&s!==e){if(Hs++,s.deps!==null)for(let g=0;g<i;g+=1)s.deps[g].rv=Hs;if(t!==null)for(const g of t)g.rv=Hs;Mi!==null&&(r===null?r=Mi:r.push(...Mi))}return(e.f&ys)!==0&&(e.f^=ys),u}catch(g){return g_(g)}finally{e.f^=wh,vi=t,Si=i,Mi=r,Ue=s,Ui=n,ro(o),ar=a,Vr=c}}function Bm(e,t){let i=t.reactions;if(i!==null){var r=yg.call(i,e);if(r!==-1){var s=i.length-1;s===0?i=t.reactions=null:(i[r]=i[s],i.pop())}}if(i===null&&(t.f&Zt)!==0&&(vi===null||!io.call(vi,t))){var n=t;(n.f&zi)!==0&&(n.f^=zi,n.f&=~pn),lu(n),Sm(n),qo(n,0)}}function qo(e,t){var i=e.deps;if(i!==null)for(var r=t;r<i.length;r++)Bm(e,i[r])}function no(e){var t=e.f;if((t&qr)===0){bt(e,Ut);var i=Ve,r=Fa;Ve=e,Fa=!0;try{(t&($r|n_))!==0?Lm(e):_u(e),F_(e);var s=G_(e);e.teardown=typeof s=="function"?s:null,e.wv=j_;var n;yh&&tm&&(e.f&Jt)!==0&&e.deps}finally{Fa=r,Ve=i}}}async function Nm(){await Promise.resolve(),om()}function l(e){var t=e.f,i=(t&Zt)!==0;if(Ue!==null&&!ar){var r=Ve!==null&&(Ve.f&qr)!==0;if(!r&&(Ui===null||!io.call(Ui,e))){var s=Ue.deps;if((Ue.f&wh)!==0)e.rv<Hs&&(e.rv=Hs,vi===null&&s!==null&&s[Si]===e?Si++:vi===null?vi=[e]:vi.push(e));else{(Ue.deps??(Ue.deps=[])).push(e);var n=e.reactions;n===null?e.reactions=[Ue]:io.call(n,Ue)||n.push(Ue)}}}if(Ts&&ws.has(e))return ws.get(e);if(i){var o=e;if(Ts){var a=o.v;return((o.f&Ut)===0&&o.reactions!==null||$_(o))&&(a=hu(o)),ws.set(o,a),a}var c=(o.f&zi)===0&&!ar&&Ue!==null&&(Fa||(Ue.f&zi)!==0),h=(o.f&_n)===0;fa(o)&&(c&&(o.f|=zi),E_(o)),c&&!h&&(D_(o),X_(o))}if($t!=null&&$t.has(e))return $t.get(e);if((e.f&ys)!==0)throw e.v;return e.v}function X_(e){if(e.f|=zi,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&Zt)!==0&&(t.f&zi)===0&&(D_(t),X_(t))}function $_(e){if(e.v===Yt)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(ws.has(t)||(t.f&Zt)!==0&&$_(t))return!0;return!1}function Qr(e){var t=ar;try{return ar=!0,e()}finally{ar=t}}function Fm(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(jr in e)Ah(e);else if(!Array.isArray(e))for(let t in e){const i=e[t];typeof i=="object"&&i&&jr in i&&Ah(i)}}}function Ah(e,t=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let r in e)try{Ah(e[r],t)}catch{}const i=nu(e);if(i!==Object.prototype&&i!==Array.prototype&&i!==Map.prototype&&i!==Set.prototype&&i!==Date.prototype){const r=r_(i);for(let s in r){const n=r[s].get;if(n)try{n.call(e)}catch{}}}}}const Wm=["touchstart","touchmove"];function Hm(e){return Wm.includes(e)}const zs=Symbol("events"),Q_=new Set,Mh=new Set;function zm(e,t,i,r={}){function s(n){if(r.capture||Oh.call(t,n),!n.cancelBubble)return Tl(()=>i==null?void 0:i.call(this,n))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?Dr(()=>{t.addEventListener(e,s,r)}):t.addEventListener(e,s,r),s}function xr(e,t,i,r,s){var n={capture:r,passive:s},o=zm(e,t,i,n);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&du(()=>{t.removeEventListener(e,o,n)})}function G(e,t,i){(t[zs]??(t[zs]={}))[e]=i}function _t(e){for(var t=0;t<e.length;t++)Q_.add(e[t]);for(var i of Mh)i(e)}let nd=null;function Oh(e){var g,y;var t=this,i=t.ownerDocument,r=e.type,s=((g=e.composedPath)==null?void 0:g.call(e))||[],n=s[0]||e.target;nd=e;var o=0,a=nd===e&&e[zs];if(a){var c=s.indexOf(a);if(c!==-1&&(t===document||t===window)){e[zs]=t;return}var h=s.indexOf(t);if(h===-1)return;c<=h&&(o=c)}if(n=s[o]||e.target,n!==t){Sg(e,"currentTarget",{configurable:!0,get(){return n||i}});var d=Ue,u=Ve;qi(null),Rr(null);try{for(var f,_=[];n!==null;){var p=n.assignedSlot||n.parentNode||n.host||null;try{var b=(y=n[zs])==null?void 0:y[r];b!=null&&(!n.disabled||e.target===n)&&b.call(n,e)}catch(O){f?_.push(O):f=O}if(e.cancelBubble||p===t||p===null)break;n=p}if(f){for(let O of _)queueMicrotask(()=>{throw O});throw f}}finally{e[zs]=t,delete e.currentTarget,qi(d),Rr(u)}}}var Uf;const Xl=((Uf=globalThis==null?void 0:globalThis.window)==null?void 0:Uf.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Um(e){return(Xl==null?void 0:Xl.createHTML(e))??e}function Km(e){var t=I_("template");return t.innerHTML=Um(e.replaceAll("<!>","<!---->")),t.content}function jo(e,t){var i=Ve;i.nodes===null&&(i.nodes={start:e,end:t,a:null,t:null})}function z(e,t){var i=(t&Xg)!==0,r=(t&$g)!==0,s,n=!e.startsWith("<!>");return()=>{s===void 0&&(s=Km(n?e:"<!>"+e),i||(s=an(s)));var o=r||A_?document.importNode(s,!0):s.cloneNode(!0);if(i){var a=an(o),c=o.lastChild;jo(a,c)}else jo(o,o);return o}}function hn(e=""){{var t=Yr(e+"");return jo(t,t),t}}function Gr(){var e=document.createDocumentFragment(),t=document.createComment(""),i=Yr();return e.append(t,i),jo(t,i),e}function N(e,t){e!==null&&e.before(t)}function ne(e,t){var i=t==null?"":typeof t=="object"?`${t}`:t;i!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=i,e.nodeValue=`${i}`)}function qm(e,t){return jm(e,t)}const xa=new Map;function jm(e,{target:t,anchor:i,props:r={},events:s,context:n,intro:o=!0,transformError:a}){Em();var c=void 0,h=Mm(()=>{var d=i??t.appendChild(Yr());cm(d,{pending:()=>{}},_=>{dt({});var p=Rt;n&&(p.c=n),s&&(r.$$events=s),c=e(_,r)||{},ft()},a);var u=new Set,f=_=>{for(var p=0;p<_.length;p++){var b=_[p];if(!u.has(b)){u.add(b);var g=Hm(b);for(const R of[t,document]){var y=xa.get(R);y===void 0&&(y=new Map,xa.set(R,y));var O=y.get(b);O===void 0?(R.addEventListener(b,Oh,{passive:g}),y.set(b,1)):y.set(b,O+1)}}}};return f(xl(Q_)),Mh.add(f),()=>{var g;for(var _ of u)for(const y of[t,document]){var p=xa.get(y),b=p.get(_);--b==0?(y.removeEventListener(_,Oh),p.delete(_),p.size===0&&xa.delete(y)):p.set(_,b)}Mh.delete(f),d!==i&&((g=d.parentNode)==null||g.removeChild(d))}});return Ym.set(c,h),c}let Ym=new WeakMap;var Ji,br,Ci,$s,ia,ra,wl;class Z_{constructor(t,i=!0){Vi(this,"anchor");ee(this,Ji,new Map);ee(this,br,new Map);ee(this,Ci,new Map);ee(this,$s,new Set);ee(this,ia,!0);ee(this,ra,()=>{var t=Oe;if(v(this,Ji).has(t)){var i=v(this,Ji).get(t),r=v(this,br).get(i);if(r)vu(r),v(this,$s).delete(i);else{var s=v(this,Ci).get(i);s&&(v(this,br).set(i,s.effect),v(this,Ci).delete(i),s.fragment.lastChild.remove(),this.anchor.before(s.fragment),r=s.effect)}for(const[n,o]of v(this,Ji)){if(v(this,Ji).delete(n),n===t)break;const a=v(this,Ci).get(o);a&&(gi(a.effect),v(this,Ci).delete(o))}for(const[n,o]of v(this,br)){if(n===i||v(this,$s).has(n))continue;const a=()=>{if(Array.from(v(this,Ji).values()).includes(n)){var h=document.createDocumentFragment();K_(o,h),h.append(Yr()),v(this,Ci).set(n,{effect:o,fragment:h})}else gi(o);v(this,$s).delete(n),v(this,br).delete(n)};v(this,ia)||!r?(v(this,$s).add(n),ln(o,a,!1)):a()}}});ee(this,wl,t=>{v(this,Ji).delete(t);const i=Array.from(v(this,Ji).values());for(const[r,s]of v(this,Ci))i.includes(r)||(gi(s.effect),v(this,Ci).delete(r))});this.anchor=t,j(this,ia,i)}ensure(t,i){var r=Oe,s=L_();if(i&&!v(this,br).has(t)&&!v(this,Ci).has(t))if(s){var n=document.createDocumentFragment(),o=Yr();n.append(o),v(this,Ci).set(t,{effect:Ni(()=>i(o)),fragment:n})}else v(this,br).set(t,Ni(()=>i(this.anchor)));if(v(this,Ji).set(r,t),s){for(const[a,c]of v(this,br))a===t?r.unskip_effect(c):r.skip_effect(c);for(const[a,c]of v(this,Ci))a===t?r.unskip_effect(c.effect):r.skip_effect(c.effect);r.oncommit(v(this,ra)),r.ondiscard(v(this,wl))}else v(this,ra).call(this)}}Ji=new WeakMap,br=new WeakMap,Ci=new WeakMap,$s=new WeakMap,ia=new WeakMap,ra=new WeakMap,wl=new WeakMap;function ie(e,t,i=!1){var r=new Z_(e),s=i?vn:0;function n(o,a){r.ensure(o,a)}Rl(()=>{var o=!1;t((a,c=0)=>{o=!0,n(c,a)}),o||n(!1,null)},s)}function Yo(e,t){return t}function Vm(e,t,i){for(var r=[],s=t.length,n,o=t.length,a=0;a<s;a++){let u=t[a];ln(u,()=>{if(n){if(n.pending.delete(u),n.done.add(u),n.pending.size===0){var f=e.outrogroups;Lh(xl(n.done)),f.delete(n),f.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var c=r.length===0&&i!==null;if(c){var h=i,d=h.parentNode;Dm(d),d.append(h),e.items.clear()}Lh(t,!c)}else n={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(n)}function Lh(e,t=!0){for(var i=0;i<e.length;i++)gi(e[i],t)}var od;function si(e,t,i,r,s,n=null){var o=e,a=new Map,c=(t&l_)!==0;if(c){var h=e;o=h.appendChild(Yr())}var d=null,u=x_(()=>{var y=i();return su(y)?y:y==null?[]:xl(y)}),f,_=!0;function p(){g.fallback=d,Gm(g,f,o,t,r),d!==null&&(f.length===0?(d.f&Ur)===0?vu(d):(d.f^=Ur,Do(d,null,o)):ln(d,()=>{d=null}))}var b=Rl(()=>{f=l(u);for(var y=f.length,O=new Set,R=Oe,S=L_(),E=0;E<y;E+=1){var A=f[E],P=r(A,E),B=_?null:a.get(P);B?(B.v&&so(B.v,A),B.i&&so(B.i,E),S&&R.unskip_effect(B.e)):(B=Xm(a,_?o:od??(od=Yr()),A,P,E,s,t,i),_||(B.e.f|=Ur),a.set(P,B)),O.add(P)}if(y===0&&n&&!d&&(_?d=Ni(()=>n(o)):(d=Ni(()=>n(od??(od=Yr()))),d.f|=Ur)),y>O.size&&Ag(),!_)if(S){for(const[U,$]of a)O.has(U)||R.skip_effect($.e);R.oncommit(p),R.ondiscard(()=>{})}else p();l(u)}),g={effect:b,items:a,outrogroups:null,fallback:d};_=!1}function mo(e){for(;e!==null&&(e.f&cr)===0;)e=e.next;return e}function Gm(e,t,i,r,s){var $,q,F,L,D,I,H,k,x;var n=(r&Kg)!==0,o=t.length,a=e.items,c=mo(e.effect.first),h,d=null,u,f=[],_=[],p,b,g,y;if(n)for(y=0;y<o;y+=1)p=t[y],b=s(p,y),g=a.get(b).e,(g.f&Ur)===0&&((q=($=g.nodes)==null?void 0:$.a)==null||q.measure(),(u??(u=new Set)).add(g));for(y=0;y<o;y+=1){if(p=t[y],b=s(p,y),g=a.get(b).e,e.outrogroups!==null)for(const Q of e.outrogroups)Q.pending.delete(g),Q.done.delete(g);if((g.f&Ur)!==0)if(g.f^=Ur,g===c)Do(g,null,i);else{var O=d?d.next:c;g===e.effect.last&&(e.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),es(e,d,g),es(e,g,O),Do(g,O,i),d=g,f=[],_=[],c=mo(d.next);continue}if((g.f&xi)!==0&&(vu(g),n&&((L=(F=g.nodes)==null?void 0:F.a)==null||L.unfix(),(u??(u=new Set)).delete(g))),g!==c){if(h!==void 0&&h.has(g)){if(f.length<_.length){var R=_[0],S;d=R.prev;var E=f[0],A=f[f.length-1];for(S=0;S<f.length;S+=1)Do(f[S],R,i);for(S=0;S<_.length;S+=1)h.delete(_[S]);es(e,E.prev,A.next),es(e,d,E),es(e,A,R),c=R,d=A,y-=1,f=[],_=[]}else h.delete(g),Do(g,c,i),es(e,g.prev,g.next),es(e,g,d===null?e.effect.first:d.next),es(e,d,g),d=g;continue}for(f=[],_=[];c!==null&&c!==g;)(h??(h=new Set)).add(c),_.push(c),c=mo(c.next);if(c===null)continue}(g.f&Ur)===0&&f.push(g),d=g,c=mo(g.next)}if(e.outrogroups!==null){for(const Q of e.outrogroups)Q.pending.size===0&&(Lh(xl(Q.done)),(D=e.outrogroups)==null||D.delete(Q));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||h!==void 0){var P=[];if(h!==void 0)for(g of h)(g.f&xi)===0&&P.push(g);for(;c!==null;)(c.f&xi)===0&&c!==e.fallback&&P.push(c),c=mo(c.next);var B=P.length;if(B>0){var U=(r&l_)!==0&&o===0?i:null;if(n){for(y=0;y<B;y+=1)(H=(I=P[y].nodes)==null?void 0:I.a)==null||H.measure();for(y=0;y<B;y+=1)(x=(k=P[y].nodes)==null?void 0:k.a)==null||x.fix()}Vm(e,P,U)}}n&&Dr(()=>{var Q,Z;if(u!==void 0)for(g of u)(Z=(Q=g.nodes)==null?void 0:Q.a)==null||Z.apply()})}function Xm(e,t,i,r,s,n,o,a){var c=(o&zg)!==0?(o&qg)===0?wm(i,!1,!1):Ds(i):null,h=(o&Ug)!==0?Ds(s):null;return{v:c,i:h,e:Ni(()=>(n(t,c??i,h??s,a),()=>{e.delete(r)}))}}function Do(e,t,i){if(e.nodes)for(var r=e.nodes.start,s=e.nodes.end,n=t&&(t.f&Ur)===0?t.nodes.start:i;r!==null;){var o=ua(r);if(n.before(r),r===s)return;r=o}}function es(e,t,i){t===null?e.effect.first=i:t.next=i,i===null?e.effect.last=t:i.prev=t}function ad(e,t,i=!1,r=!1,s=!1){var n=e,o="";he(()=>{var a=Ve;if(o!==(o=t()??"")&&(a.nodes!==null&&(W_(a.nodes.start,a.nodes.end),a.nodes=null),o!=="")){var c=i?Qg:r?Zg:void 0,h=I_(i?"svg":r?"math":"template",c);h.innerHTML=o;var d=i||r?h:h.content;if(jo(an(d),d.lastChild),i||r)for(;an(d);)n.before(an(d));else n.before(d)}})}function $m(e,t,...i){var r=new Z_(e);Rl(()=>{const s=t()??null;r.ensure(s,s&&(n=>s(n,...i)))},vn)}function Qm(e,t,i){fu(()=>{var r=Qr(()=>t(e,i==null?void 0:i())||{});if(i&&(r!=null&&r.update)){var s=!1,n={};da(()=>{var o=i();Fm(o),s&&u_(n,o)&&(n=o,r.update(o))}),s=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function J_(e){var t,i,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(i=J_(e[t]))&&(r&&(r+=" "),r+=i)}else for(i in e)e[i]&&(r&&(r+=" "),r+=i);return r}function Zm(){for(var e,t,i=0,r="",s=arguments.length;i<s;i++)(e=arguments[i])&&(t=J_(e))&&(r&&(r+=" "),r+=t);return r}function ev(e){return typeof e=="object"?Zm(e):e??""}const ld=[...`
2
+ \r\f \v\uFEFF`];function Jm(e,t,i){var r=e==null?"":""+e;if(t&&(r=r?r+" "+t:t),i){for(var s of Object.keys(i))if(i[s])r=r?r+" "+s:s;else if(r.length)for(var n=s.length,o=0;(o=r.indexOf(s,o))>=0;){var a=o+n;(o===0||ld.includes(r[o-1]))&&(a===r.length||ld.includes(r[a]))?r=(o===0?"":r.substring(0,o))+r.substring(a+1):o=a}}return r===""?null:r}function hd(e,t=!1){var i=t?" !important;":";",r="";for(var s of Object.keys(e)){var n=e[s];n!=null&&n!==""&&(r+=" "+s+": "+n+i)}return r}function $l(e){return e[0]!=="-"||e[1]!=="-"?e.toLowerCase():e}function eb(e,t){if(t){var i="",r,s;if(Array.isArray(t)?(r=t[0],s=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,a=!1,c=[];r&&c.push(...Object.keys(r).map($l)),s&&c.push(...Object.keys(s).map($l));var h=0,d=-1;const b=e.length;for(var u=0;u<b;u++){var f=e[u];if(a?f==="/"&&e[u-1]==="*"&&(a=!1):n?n===f&&(n=!1):f==="/"&&e[u+1]==="*"?a=!0:f==='"'||f==="'"?n=f:f==="("?o++:f===")"&&o--,!a&&n===!1&&o===0){if(f===":"&&d===-1)d=u;else if(f===";"||u===b-1){if(d!==-1){var _=$l(e.substring(h,d).trim());if(!c.includes(_)){f!==";"&&u++;var p=e.substring(h,u).trim();i+=" "+p+";"}}h=u+1,d=-1}}}}return r&&(i+=hd(r)),s&&(i+=hd(s,!0)),i=i.trim(),i===""?null:i}return e==null?null:String(e)}function it(e,t,i,r,s,n){var o=e.__className;if(o!==i||o===void 0){var a=Jm(i,r,n);a==null?e.removeAttribute("class"):e.className=a,e.__className=i}else if(n&&s!==n)for(var c in n){var h=!!n[c];(s==null||h!==!!s[c])&&e.classList.toggle(c,h)}return n}function Ql(e,t={},i,r){for(var s in i){var n=i[s];t[s]!==n&&(i[s]==null?e.style.removeProperty(s):e.style.setProperty(s,n,r))}}function _o(e,t,i,r){var s=e.__style;if(s!==t){var n=eb(t,r);n==null?e.removeAttribute("style"):e.style.cssText=n,e.__style=t}else r&&(Array.isArray(r)?(Ql(e,i==null?void 0:i[0],r[0]),Ql(e,i==null?void 0:i[1],r[1],"important")):Ql(e,i,r));return r}function tv(e,t,i=!1){if(e.multiple){if(t==null)return;if(!su(t))return Jg();for(var r of e.options)r.selected=t.includes(Bo(r));return}for(r of e.options){var s=Bo(r);if(xm(s,t)){r.selected=!0;return}}(!i||t!==void 0)&&(e.selectedIndex=-1)}function tb(e){var t=new MutationObserver(()=>{tv(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),du(()=>{t.disconnect()})}function el(e,t,i=t){var r=new WeakSet,s=!0;cu(e,"change",n=>{var o=n?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(o),Bo);else{var c=e.querySelector(o)??e.querySelector("option:not([disabled])");a=c&&Bo(c)}i(a),Oe!==null&&r.add(Oe)}),fu(()=>{var n=t();if(e===document.activeElement){var o=Za??Oe;if(r.has(o))return}if(tv(e,n,s),s&&n===void 0){var a=e.querySelector(":checked");a!==null&&(n=Bo(a),i(n))}e.__value=n,s=!1}),tb(e)}function Bo(e){return"__value"in e?e.__value:e.value}const ib=Symbol("is custom element"),rb=Symbol("is html"),sb=Rg?"progress":"PROGRESS";function nb(e,t){var i=pu(e);i.value===(i.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==sb)||(e.value=t??"")}function ob(e,t){var i=pu(e);i.checked!==(i.checked=t??void 0)&&(e.checked=t)}function Ie(e,t,i,r){var s=pu(e);s[t]!==(s[t]=i)&&(t==="loading"&&(e[Tg]=i),i==null?e.removeAttribute(t):typeof i!="string"&&ab(e).includes(t)?e[t]=i:e.setAttribute(t,i))}function pu(e){return e.__attributes??(e.__attributes={[ib]:e.nodeName.includes("-"),[rb]:e.namespaceURI===h_})}var cd=new Map;function ab(e){var t=e.getAttribute("is")||e.nodeName,i=cd.get(t);if(i)return i;cd.set(t,i=[]);for(var r,s=e,n=Element.prototype;n!==s;){r=r_(s);for(var o in r)r[o].set&&i.push(o);s=nu(s)}return i}function rr(e,t,i=t){var r=new WeakSet;cu(e,"input",async s=>{var n=s?e.defaultValue:e.value;if(n=Zl(e)?Jl(n):n,i(n),Oe!==null&&r.add(Oe),await Nm(),n!==(n=t())){var o=e.selectionStart,a=e.selectionEnd,c=e.value.length;if(e.value=n??"",a!==null){var h=e.value.length;o===a&&a===c&&h>c?(e.selectionStart=h,e.selectionEnd=h):(e.selectionStart=o,e.selectionEnd=Math.min(a,h))}}}),Qr(t)==null&&e.value&&(i(Zl(e)?Jl(e.value):e.value),Oe!==null&&r.add(Oe)),da(()=>{var s=t();if(e===document.activeElement){var n=Za??Oe;if(r.has(n))return}Zl(e)&&s===Jl(e.value)||e.type==="date"&&!s&&!e.value||s!==e.value&&(e.value=s??"")})}function sr(e,t,i=t){cu(e,"change",r=>{var s=r?e.defaultChecked:e.checked;i(s)}),Qr(t)==null&&i(e.checked),da(()=>{var r=t();e.checked=!!r})}function Zl(e){var t=e.type;return t==="number"||t==="range"}function Jl(e){return e===""?null:+e}function ud(e,t){return e===t||(e==null?void 0:e[jr])===t}function Ze(e={},t,i,r){return fu(()=>{var s,n;return da(()=>{s=n,n=(r==null?void 0:r())||[],Qr(()=>{e!==i(...n)&&(t(e,...n),s&&ud(i(...s),e)&&t(null,...s))})}),()=>{Dr(()=>{n&&ud(i(...n),e)&&t(null,...n)})}}),e}let Ea=!1;function lb(e){var t=Ea;try{return Ea=!1,[e(),Ea]}finally{Ea=t}}function Pr(e,t,i,r){var O;var s=(i&Vg)!==0,n=(i&Gg)!==0,o=r,a=!0,c=()=>(a&&(a=!1,o=n?Qr(r):r),o),h;if(s){var d=jr in e||Dg in e;h=((O=Mn(e,t))==null?void 0:O.set)??(d&&t in e?R=>e[t]=R:void 0)}var u,f=!1;s?[u,f]=lb(()=>e[t]):u=e[t],u===void 0&&r!==void 0&&(u=c(),h&&(Bg(),h(u)));var _;if(_=()=>{var R=e[t];return R===void 0?c():(a=!0,R)},(i&Yg)===0)return _;if(h){var p=e.$$legacy;return(function(R,S){return arguments.length>0?((!S||p||f)&&h(S?_():R),R):_()})}var b=!1,g=((i&jg)!==0?Dl:x_)(()=>(b=!1,_()));s&&l(g);var y=Ve;return(function(R,S){if(arguments.length>0){const E=S?l(g):s?Xe(R):R;return m(g,E),b=!0,o!==void 0&&(o=E),R}return Ts&&b||(y.f&qr)!==0?g.v:l(g)})}function vo(e){Rt===null&&au(),Ei(()=>{const t=Qr(e);if(typeof t=="function")return t})}function hb(e){Rt===null&&au(),vo(()=>()=>Qr(e))}const cb="5";var Kf;typeof window<"u"&&((Kf=window.__svelte??(window.__svelte={})).v??(Kf.v=new Set)).add(cb);class iv extends Error{constructor(i){super("conflict");Vi(this,"sessionId");this.name="ConflictError",this.sessionId=i}}async function kt(e){if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function ub(e){const t=await fetch("/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pin:e})});if(!t.ok){const i=await t.json();throw new Error(i.error||"Authentication failed")}}async function db(){return(await fetch("/sessions")).ok}async function fb(){return kt(await fetch("/sessions"))}async function _b(){return kt(await fetch("/worktrees"))}async function vb(){return(await kt(await fetch("/workspaces"))).workspaces}async function pb(e){return(await kt(await fetch("/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))).workspaces}async function dd(e,t){const i=new URLSearchParams;return e&&i.set("path",e),kt(await fetch("/workspaces/browse?"+i.toString()))}async function gb(e){return kt(await fetch("/workspaces/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))}async function mb(e){var i,r;const t=await kt(await fetch("/workspaces/dashboard?path="+encodeURIComponent(e)));return{prs:((i=t.pullRequests)==null?void 0:i.prs)??[],activity:t.activity??[],isGitRepo:!0,defaultBranch:null,hasGhCli:!((r=t.pullRequests)!=null&&r.error)}}async function bb(e,t){const i=await fetch("/workspaces/ci-status?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function yb(e,t){const i=await fetch("/workspaces/pr?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function Sb(e){return(await kt(await fetch("/workspaces/current-branch?path="+encodeURIComponent(e)))).branch}async function eh(e,t){const i=await fetch("/workspaces/worktree?path="+encodeURIComponent(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!i.ok){const r=await i.json();throw new Error(r.error||"Failed to create worktree")}return i.json()}async function wb(e,t){return(await fetch("/workspaces/branch?path="+encodeURIComponent(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})})).json()}async function rv(e,t={}){const i=new URLSearchParams({repo:e});return t.refresh&&i.set("refresh","1"),kt(await fetch("/branches?"+i.toString()))}async function On(e){const t=await fetch("/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.status===409){const i=await t.json();throw new iv(i.sessionId??"")}return kt(t)}async function gu(e){const t=await fetch("/sessions/repo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.status===409){const i=await t.json();throw new iv(i.sessionId??"")}return kt(t)}async function Cb(e){const t=await fetch("/sessions/terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})});return kt(t)}async function kb(e){await fetch("/sessions/"+e,{method:"DELETE"})}async function sv(e,t){const i=await fetch("/worktrees",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreePath:e,repoPath:t})});if(!i.ok){const r=await i.json();throw new Error(r.error||"Failed to delete worktree")}}async function xb(e,t,i){return kt(await fetch("/sessions/"+e+"/image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t,mimeType:i})}))}async function nv(){return kt(await fetch("/version"))}async function ov(){return kt(await fetch("/update",{method:"POST"}))}async function Eb(){return(await kt(await fetch("/config/defaultAgent"))).defaultAgent}async function Db(e){if(!(await fetch("/config/defaultAgent",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultAgent:e})})).ok)throw new Error("Failed to update default agent")}async function Pl(e){return(await kt(await fetch(`/config/${e}`)))[e]}async function Al(e,t){const i=await fetch(`/config/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(!i.ok){const r=await i.json();throw new Error(r.error||`Failed to update ${e}`)}}const Tb=()=>Pl("defaultContinue"),Rb=e=>Al("defaultContinue",e),Pb=()=>Pl("defaultYolo"),Ab=e=>Al("defaultYolo",e),Mb=()=>Pl("launchInTmux"),Ob=e=>Al("launchInTmux",e),Lb=()=>Pl("defaultNotifications"),Ib=e=>Al("defaultNotifications",e);async function Bb(e,t){if(!(await fetch("/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscription:e,sessionIds:t})})).ok)throw new Error("Push subscribe failed")}async function Nb(e){return kt(await fetch("/workspaces/settings?path="+encodeURIComponent(e)))}async function fd(e){return kt(await fetch("/workspaces/settings/merged?path="+encodeURIComponent(e)))}async function _d(e,t){const i=await fetch("/workspaces/settings?path="+encodeURIComponent(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok){const r=await i.json();throw new Error(r.error||"Failed to update workspace settings")}}async function Fb(){return kt(await fetch("/analytics/size"))}async function Wb(){if(!(await fetch("/analytics/events",{method:"DELETE"})).ok)throw new Error("Failed to clear analytics")}let tl=W(!1),Ih=W(null),Bh=W(!0);function av(){return{get authenticated(){return l(tl)},get pinError(){return l(Ih)},get checking(){return l(Bh)}}}async function Hb(){m(Bh,!0);try{m(tl,await db(),!0)}catch{m(tl,!1)}finally{m(Bh,!1)}}async function zb(e){m(Ih,null);try{await ub(e),m(tl,!0)}catch(t){m(Ih,t instanceof Error?t.message:"Authentication failed",!0)}}const lv="claude-remote-sidebar-width",hv="claude-remote-sidebar-collapsed",Nh="claude-remote-active-workspace",cv=240,uv=180,dv=500,Ub=44;function Kb(){try{const e=localStorage.getItem(lv);if(e){const t=parseInt(e,10);if(t>=uv&&t<=dv)return t}}catch{}return cv}function qb(){try{return localStorage.getItem(hv)==="true"}catch{return!1}}function jb(){try{return localStorage.getItem(Nh)}catch{return null}}let il=W(!1),Fh=W(Xe(Kb())),No=W(Xe(qb())),vd=W(""),pd=W(Xe(jb())),rl=W(!1);function mu(){return{get sidebarOpen(){return l(il)},set sidebarOpen(e){m(il,e,!0)},get sidebarWidth(){return l(Fh)},set sidebarWidth(e){m(Fh,e,!0)},get sidebarCollapsed(){return l(No)},set sidebarCollapsed(e){m(No,e,!0)},get searchQuery(){return l(vd)},set searchQuery(e){m(vd,e,!0)},get activeWorkspacePath(){return l(pd)},set activeWorkspacePath(e){m(pd,e,!0);try{e===null?localStorage.removeItem(Nh):localStorage.setItem(Nh,e)}catch{}},get reorderMode(){return l(rl)},set reorderMode(e){m(rl,e,!0)}}}function gd(){m(il,!0)}function ki(){m(il,!1)}function Yb(){m(rl,!0)}function Vb(){m(rl,!1)}function md(){try{localStorage.setItem(lv,String(l(Fh)))}catch{}}function th(){m(No,!l(No));try{localStorage.setItem(hv,String(l(No)))}catch{}}const fv="claude-remote-collapsed-workspaces";function Gb(){try{const e=localStorage.getItem(fv);if(e)return new Set(JSON.parse(e))}catch{}return new Set}let Ns=W(Xe(Gb()));function Xb(){try{localStorage.setItem(fv,JSON.stringify([...l(Ns)]))}catch{}}function $b(e){l(Ns).has(e)?l(Ns).delete(e):l(Ns).add(e),m(Ns,new Set(l(Ns)),!0),Xb()}function Qb(e){return l(Ns).has(e)}let _v=W(0);setInterval(()=>{km(_v)},3e4);function Zb(){return l(_v)}let Fo=null,Jb=null;function ey(e){Fo=e,"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const i=t.data;i.type==="notification-click"&&i.sessionId&&Fo&&Fo(i.sessionId,i.sessionType||"repo")})}function vv(){return document.hidden||!document.hasFocus()}function pv(e){if(typeof Notification>"u"||Notification.permission!=="granted")return;const t=new Notification(e.displayName||"Claude Remote CLI",{body:"Session needs your input",tag:"session-"+e.id,data:{sessionId:e.id,sessionType:e.type}});t.onclick=()=>{window.focus(),Fo&&Fo(e.id,e.type),t.close()}}function gv(){return"serviceWorker"in navigator&&"PushManager"in window}async function ty(){if(gv())try{Jb=await navigator.serviceWorker.register("/sw.js")}catch{return}}async function iy(e){if(gv())try{const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();i&&await Bb(i.toJSON(),e)}catch{}}const mv="claude-remote-notifications",Wh="claude-remote-active-session";function ry(){try{return localStorage.getItem(Wh)}catch{return null}}function bv(e){try{e===null?localStorage.removeItem(Wh):localStorage.setItem(Wh,e)}catch{}}let gn=W(Xe([])),yv=W(Xe([])),bu=W(Xe([])),cn=W(Xe(ry())),Xr=Xe({}),mn=Xe({}),Ml=Xe({}),Ar=W(Xe({}));function sy(){try{const e=localStorage.getItem(mv);e&&m(Ar,JSON.parse(e),!0)}catch{}}sy();function Sv(){try{localStorage.setItem(mv,JSON.stringify(l(Ar)))}catch{}}function yu(){return{get sessions(){return l(gn)},get worktrees(){return l(yv)},get workspaces(){return l(bu)},get activeSessionId(){return l(cn)},set activeSessionId(e){m(cn,e,!0),bv(e)},get attentionSessions(){return Xr},get loadingItems(){return Ml},get notificationSessions(){return l(Ar)}}}async function gt(){try{const[e,t,i]=await Promise.all([fb(),_b(),vb()]);m(gn,e,!0),m(yv,t,!0),m(bu,i,!0);const r=new Set(l(gn).map(n=>n.id));l(cn)!==null&&!r.has(l(cn))&&(m(cn,null),bv(null));let s=!1;for(const n of Object.keys(Xr))r.has(n)||delete Xr[n];for(const n of Object.keys(mn))r.has(n)||delete mn[n];for(const n of Object.keys(l(Ar)))r.has(n)||(delete l(Ar)[n],s=!0);s&&Sv()}catch{}}function wv(e){return l(gn).filter(t=>t.repoPath===e||t.repoPath.startsWith(e+"/"))}const Cv=3e4;function ny(e,t,i){const r=l(gn).find(s=>s.id===e);r&&(r.branchName=t,r.displayName=i)}function oy(e,t){const i=l(gn).find(r=>r.id===e);if(i&&(i.agentState=t),t==="waiting-for-input"&&e!==l(cn)&&(i==null?void 0:i.type)!=="terminal"){const r=mn[e];if(r&&Date.now()-r<Cv)return;delete mn[e],Xr[e]=!0,i&&l(Ar)[e]&&vv()&&pv(i)}else(t==="processing"||t==="initializing")&&delete Xr[e]}function ay(e,t){const i=l(gn).find(r=>r.id===e);if(i&&(i.idle=t),!(i!=null&&i.agentState&&i.agentState!=="idle"))if(t&&e!==l(cn)&&(i==null?void 0:i.type)!=="terminal"){const r=mn[e];if(r&&Date.now()-r<Cv)return;delete mn[e],Xr[e]=!0,i&&l(Ar)[e]&&vv()&&pv(i)}else delete Xr[e]}function bd(e){delete Xr[e],mn[e]=Date.now()}function As(e,t){e in l(Ar)||(l(Ar)[e]=t,Sv())}function ly(){return Object.entries(l(Ar)).filter(([,e])=>e).map(([e])=>e)}function ih(e){return Xr[e.id]?"attention":e.agentState==="permission-prompt"?"permission-prompt":e.idle?"idle":"running"}function Tn(e){Ml[e]=!0}function Rn(e){delete Ml[e]}function Qi(e){return!!Ml[e]}async function hy(e){const t=await pb(e);m(bu,t,!0)}const kv=location.protocol==="https:"?"wss:":"ws:";let Dt=null,rt=null,Ri=null;const yd=30;let Wo=null,un=0,Wa=null,sl=!1,Us=null,Ha=null,nl=!1,Ks=null,Hh=null,za=null,zh=null,Uh=null,Kh=null;const xv=3e4,Ev=5e3,Dv='{"type":"ping"}',Tv='{"type":"pong"}';function Su(e){Dt&&(Dt.onclose=null,Dt.close(),Dt=null),Kh=e,Vh();const t=kv+"//"+location.host+"/ws/events";Dt=new WebSocket(t),Dt.onopen=()=>{uy()},Dt.onmessage=i=>{const r=i.data;if(nl&&Ov(),r!==Tv)try{e(JSON.parse(r))}catch{}},Dt.onclose=()=>{Vh(),setTimeout(()=>Su(e),3e3)},Dt.onerror=()=>{}}function Rv(e,t,i,r){Wo&&(clearTimeout(Wo),Wo=null),un=0,qh(),Hh=e,za=t,zh=i,Uh=r,Ri&&(Ri.onopen=null,Ri.onmessage=null,Ri.onclose=null,Ri.onerror=null,Ri.close(),Ri=null),rt&&(rt.onclose=null,rt.close(),rt=null);const s=kv+"//"+location.host+"/ws/"+e,n=new WebSocket(s);Ri=n,n.onopen=()=>{Ri=null,rt=n,un=0,i(),cy()},n.onmessage=o=>{const a=o.data;sl&&Av(),a!==Tv&&t.write(a)},n.onclose=o=>{if(qh(),Ri===n&&(Ri=null),!(Ri!==n&&rt!==n)){if(o.code===1e3){t.write(`\r
3
3
  [Session ended]\r
4
4
  `),rt=null,r();return}rt=null,un===0&&t.write(`\r
5
5
  [Reconnecting...]\r
@@ -9,10 +9,10 @@ var mg=Object.defineProperty;var Qu=e=>{throw TypeError(e)};var bg=(e,t,i)=>t in
9
9
  [Session ended]\r
10
10
  `),r();return}t.clear(),Rv(e,t,i,r)}catch{wu(e,t,i,r)}},s)}function Pv(){if(!(!rt||rt.readyState!==WebSocket.OPEN)){sl=!0;try{rt.send(Dv)}catch{jh();return}Us&&(clearTimeout(Us),Us=null),Us=setTimeout(()=>{sl=!1,jh()},Ev)}}function cy(){Wa=setInterval(Pv,xv)}function qh(){Wa&&(clearInterval(Wa),Wa=null),Av()}function Av(){sl=!1,Us&&(clearTimeout(Us),Us=null)}function jh(){qh(),rt&&(rt.onclose=null,rt.close(),rt=null),Hh&&za&&zh&&Uh&&(un===0&&za.write(`\r
11
11
  [Reconnecting...]\r
12
- `),wu(Hh,za,zh,Uh))}function Mv(){if(!(!Dt||Dt.readyState!==WebSocket.OPEN)){nl=!0;try{Dt.send(Dv)}catch{Yh();return}Ks&&(clearTimeout(Ks),Ks=null),Ks=setTimeout(()=>{nl=!1,Yh()},Ev)}}function Yh(){Vh(),Dt&&(Dt.onclose=null,Dt.close(),Dt=null),Kh&&Su(Kh)}function uy(){Ha=setInterval(Mv,xv)}function Vh(){Ha&&(clearInterval(Ha),Ha=null),Ov()}function Ov(){nl=!1,Ks&&(clearTimeout(Ks),Ks=null)}document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(rt&&rt.readyState!==WebSocket.OPEN?jh():rt&&Pv(),Dt&&Dt.readyState!==WebSocket.OPEN?Yh():Dt&&Mv())});function Cr(e){rt&&rt.readyState===WebSocket.OPEN&&rt.send(e)}function rh(e,t){rt&&rt.readyState===WebSocket.OPEN&&rt.send(JSON.stringify({type:"resize",cols:e,rows:t}))}const Gi=$e({defaultContinue:!0,defaultYolo:!1,launchInTmux:!1,defaultAgent:"claude",defaultNotifications:!0});function Cu(){return Gi}async function Lv(){const[e,t,i,r,s]=await Promise.all([Tb().catch(()=>Gi.defaultContinue),Pb().catch(()=>Gi.defaultYolo),Mb().catch(()=>Gi.launchInTmux),Eb().catch(()=>Gi.defaultAgent),Lb().catch(()=>Gi.defaultNotifications)]);Gi.defaultContinue=e,Gi.defaultYolo=t,Gi.launchInTmux=i,Gi.defaultAgent=r,Gi.defaultNotifications=s}function dy(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),r=Math.floor((t-i)/1e3);if(r<60)return"just now";const s=Math.floor(r/60);if(s<60)return s+"m ago";const n=Math.floor(s/60);if(n<24)return n+"h ago";const o=Math.floor(n/24);if(o===1)return"yesterday";if(o<7)return o+"d ago";const a=new Date(e);return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a.getMonth()]+" "+a.getDate()}function Sd(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),r=Math.floor((t-i)/1e3);if(r<60)return r+"s";const s=Math.floor(r/60);if(s<60)return s+"m";const n=Math.floor(s/60);if(n<24)return n+"h";const o=new Date(e),a=String(o.getDate()).padStart(2,"0"),c=String(o.getMonth()+1).padStart(2,"0"),h=o.getFullYear();return`${a}/${c}/${h}`}const Nt=typeof window<"u"&&"ontouchstart"in window&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);function Iv(){return{cols:Math.max(80,Math.floor((window.innerWidth-60)/8)),rows:Math.max(24,Math.floor((window.innerHeight-120)/17))}}function ku(e){const{commitsAhead:t,prState:i,ciFailing:r,ciPending:s,ciTotal:n,mergeable:o,unresolvedCommentCount:a}=e;return t<=0&&i===null?{type:"none",color:"none",label:""}:i===null?{type:"create-pr",color:"accent",label:"Create PR"}:i==="DRAFT"?{type:"ready-for-review",color:"muted",label:"Ready for Review"}:i==="MERGED"?{type:"archive-merged",color:"merged",label:"Archive"}:i==="CLOSED"?{type:"archive-closed",color:"muted",label:"Archive"}:i==="OPEN"?o==="CONFLICTING"?{type:"fix-conflicts",color:"error",label:"Fix Conflicts"}:r>0?{type:"fix-errors",color:"error",label:`Fix Errors ${r}/${n}`}:s>0?{type:"checks-running",color:"warning",label:"Checks Running..."}:a>0?{type:"resolve-comments",color:"accent",label:`Resolve Comments (${a})`}:{type:"review-pr",color:"success",label:"Review PR"}:{type:"none",color:"none",label:""}}function fy(e,t){return e.type==="resolve-comments"?{type:"review-pr",color:"muted",label:"Review PR"}:null}function Bv(e,t){switch(e.type){case"create-pr":return`Create a pull request for the branch "${t.branchName}". Write a clear title and description based on the changes.`;case"ready-for-review":return`Mark the draft PR for branch "${t.branchName}" as ready for review using: gh pr ready`;case"review-pr":return`Review the pull request #${t.prNumber} for branch "${t.branchName}". Read the diff, check for bugs and code quality.`;case"fix-conflicts":return`There are merge conflicts with the base branch "${t.baseBranch}". Run \`git merge ${t.baseBranch}\` and resolve all conflicts.`;case"resolve-comments":return`There are ${t.unresolvedCommentCount} unresolved review comments on PR #${t.prNumber}. Read each comment thread, triage them, and address the feedback.`;case"fix-errors":return`The CI checks are failing on branch "${t.branchName}". Investigate the failing checks and fix the errors.`;case"archive-merged":case"archive-closed":return null;case"checks-running":case"none":return null}}function Nv(e){switch(e){case"accent":return"var(--accent)";case"success":return"var(--status-success)";case"error":return"var(--status-error)";case"warning":return"var(--status-warning)";case"merged":return"var(--status-merged)";case"muted":return"var(--border)";case"none":return"transparent"}}function Fv(e){return e==="success"||e==="warning"}const _y=5e3,vy=20,py=["terminal.","session-tab."];let Ho=[],Ua=null,Wv="desktop",Ka=null;function Ol(){if(Ho.length===0)return;const e=Ho;Ho=[];const t=JSON.stringify({events:e});if(navigator.sendBeacon){const i=new Blob([t],{type:"application/json"});navigator.sendBeacon("/analytics/events",i)}else fetch("/analytics/events",{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0}).catch(()=>{})}function Gh(e,t,i,r,s){Ho.push({category:e,action:t,target:i??null,properties:r??null,session_id:s??null,device:Wv}),Ho.length>=vy&&Ol()}function gy(e){let t=e;for(;t;){const i=t.getAttribute("data-track");if(i)return i;t=t.parentElement}return null}function my(e){const t=e.tagName.toLowerCase(),i=e.className&&typeof e.className=="string"?"."+e.className.trim().split(/\s+/).slice(0,2).join("."):"";return t+i}function Hv(e){const t=e.target;if(!t)return;const i=gy(t),r=i||my(t),s=(t.textContent||"").trim().slice(0,50)||null,o=i!=null&&py.some(a=>i.startsWith(a))?(Ka==null?void 0:Ka())??null:null;Gh("ui","click",r,s?{text:s}:void 0,o)}function by(e){Wv=Nt?"mobile":"desktop",Ka=e,document.addEventListener("click",Hv,{capture:!0,passive:!0}),Ua=setInterval(Ol,_y),document.addEventListener("visibilitychange",zv)}function zv(){document.visibilityState==="hidden"&&Ol()}function yy(){Ol(),Ua&&(clearInterval(Ua),Ua=null),document.removeEventListener("click",Hv,{capture:!0}),document.removeEventListener("visibilitychange",zv)}var Sy=W('<p class="error svelte-1qp96yb"> </p>'),wy=W('<div class="pin-gate svelte-1qp96yb"><div class="pin-container svelte-1qp96yb"><h1 class="svelte-1qp96yb">Claude Remote CLI</h1> <p class="svelte-1qp96yb">Enter PIN to continue</p> <input type="password" inputmode="numeric" maxlength="20" placeholder="PIN" class="svelte-1qp96yb"/> <button class="svelte-1qp96yb">Unlock</button> <!></div></div>');function Cy(e,t){dt(t,!0);const i=av();let r=F("");async function s(){const f=l(r).trim();f&&(await zb(f),i.pinError&&m(r,""))}function n(f){f.key==="Enter"&&s()}var o=wy(),a=w(o),c=R(w(a),4);Tm(c);var h=R(c,2),d=R(h,2);{var u=f=>{var _=Sy(),p=w(_);he(()=>ne(p,i.pinError)),B(f,_)};ie(d,f=>{i.pinError&&f(u)})}G("keydown",c,n),rr(c,()=>l(r),f=>m(r,f)),G("click",h,s),B(e,o),ft()}_t(["keydown","click"]);function wd(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),i.push.apply(i,r)}return i}function ol(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?wd(Object(i),!0).forEach(function(r){oo(e,r,i[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):wd(Object(i)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(i,r))})}return e}function Pn(e){"@babel/helpers - typeof";return Pn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pn(e)}function oo(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ky(e,t){if(e==null)return{};var i={},r=Object.keys(e),s,n;for(n=0;n<r.length;n++)s=r[n],!(t.indexOf(s)>=0)&&(i[s]=e[s]);return i}function xy(e,t){if(e==null)return{};var i=ky(e,t),r,s;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)r=n[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function Ey(e,t){return Ty(e)||Py(e,t)||xu(e,t)||My()}function Wi(e){return Dy(e)||Ry(e)||xu(e)||Ay()}function Dy(e){if(Array.isArray(e))return Xh(e)}function Ty(e){if(Array.isArray(e))return e}function Ry(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Py(e,t){var i=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(i!=null){var r=[],s=!0,n=!1,o,a;try{for(i=i.call(e);!(s=(o=i.next()).done)&&(r.push(o.value),!(t&&r.length===t));s=!0);}catch(c){n=!0,a=c}finally{try{!s&&i.return!=null&&i.return()}finally{if(n)throw a}}return r}}function xu(e,t){if(e){if(typeof e=="string")return Xh(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);if(i==="Object"&&e.constructor&&(i=e.constructor.name),i==="Map"||i==="Set")return Array.from(e);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Xh(e,t)}}function Xh(e,t){(t==null||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function Ay(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
12
+ `),wu(Hh,za,zh,Uh))}function Mv(){if(!(!Dt||Dt.readyState!==WebSocket.OPEN)){nl=!0;try{Dt.send(Dv)}catch{Yh();return}Ks&&(clearTimeout(Ks),Ks=null),Ks=setTimeout(()=>{nl=!1,Yh()},Ev)}}function Yh(){Vh(),Dt&&(Dt.onclose=null,Dt.close(),Dt=null),Kh&&Su(Kh)}function uy(){Ha=setInterval(Mv,xv)}function Vh(){Ha&&(clearInterval(Ha),Ha=null),Ov()}function Ov(){nl=!1,Ks&&(clearTimeout(Ks),Ks=null)}document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(rt&&rt.readyState!==WebSocket.OPEN?jh():rt&&Pv(),Dt&&Dt.readyState!==WebSocket.OPEN?Yh():Dt&&Mv())});function Cr(e){rt&&rt.readyState===WebSocket.OPEN&&rt.send(e)}function rh(e,t){rt&&rt.readyState===WebSocket.OPEN&&rt.send(JSON.stringify({type:"resize",cols:e,rows:t}))}const Gi=Xe({defaultContinue:!0,defaultYolo:!1,launchInTmux:!1,defaultAgent:"claude",defaultNotifications:!0});function Cu(){return Gi}async function Lv(){const[e,t,i,r,s]=await Promise.all([Tb().catch(()=>Gi.defaultContinue),Pb().catch(()=>Gi.defaultYolo),Mb().catch(()=>Gi.launchInTmux),Eb().catch(()=>Gi.defaultAgent),Lb().catch(()=>Gi.defaultNotifications)]);Gi.defaultContinue=e,Gi.defaultYolo=t,Gi.launchInTmux=i,Gi.defaultAgent=r,Gi.defaultNotifications=s}function dy(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),r=Math.floor((t-i)/1e3);if(r<60)return"just now";const s=Math.floor(r/60);if(s<60)return s+"m ago";const n=Math.floor(s/60);if(n<24)return n+"h ago";const o=Math.floor(n/24);if(o===1)return"yesterday";if(o<7)return o+"d ago";const a=new Date(e);return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a.getMonth()]+" "+a.getDate()}function Sd(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),r=Math.floor((t-i)/1e3);if(r<60)return r+"s";const s=Math.floor(r/60);if(s<60)return s+"m";const n=Math.floor(s/60);if(n<24)return n+"h";const o=new Date(e),a=String(o.getDate()).padStart(2,"0"),c=String(o.getMonth()+1).padStart(2,"0"),h=o.getFullYear();return`${a}/${c}/${h}`}const Nt=typeof window<"u"&&"ontouchstart"in window&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);function Iv(){return{cols:Math.max(80,Math.floor((window.innerWidth-60)/8)),rows:Math.max(24,Math.floor((window.innerHeight-120)/17))}}function ku(e){const{commitsAhead:t,prState:i,ciFailing:r,ciPending:s,ciTotal:n,mergeable:o,unresolvedCommentCount:a}=e;return t<=0&&i===null?{type:"none",color:"none",label:""}:i===null?{type:"create-pr",color:"accent",label:"Create PR"}:i==="DRAFT"?{type:"ready-for-review",color:"muted",label:"Ready for Review"}:i==="MERGED"?{type:"archive-merged",color:"merged",label:"Archive"}:i==="CLOSED"?{type:"archive-closed",color:"muted",label:"Archive"}:i==="OPEN"?o==="CONFLICTING"?{type:"fix-conflicts",color:"error",label:"Fix Conflicts"}:r>0?{type:"fix-errors",color:"error",label:`Fix Errors ${r}/${n}`}:s>0?{type:"checks-running",color:"warning",label:"Checks Running..."}:a>0?{type:"resolve-comments",color:"accent",label:`Resolve Comments (${a})`}:{type:"review-pr",color:"success",label:"Review PR"}:{type:"none",color:"none",label:""}}function fy(e,t){return e.type==="resolve-comments"?{type:"review-pr",color:"muted",label:"Review PR"}:null}function Bv(e,t){switch(e.type){case"create-pr":return`Create a pull request for the branch "${t.branchName}". Write a clear title and description based on the changes.`;case"ready-for-review":return`Mark the draft PR for branch "${t.branchName}" as ready for review using: gh pr ready`;case"review-pr":return`Review the pull request #${t.prNumber} for branch "${t.branchName}". Read the diff, check for bugs and code quality.`;case"fix-conflicts":return`There are merge conflicts with the base branch "${t.baseBranch}". Run \`git merge ${t.baseBranch}\` and resolve all conflicts.`;case"resolve-comments":return`There are ${t.unresolvedCommentCount} unresolved review comments on PR #${t.prNumber}. Read each comment thread, triage them, and address the feedback.`;case"fix-errors":return`The CI checks are failing on branch "${t.branchName}". Investigate the failing checks and fix the errors.`;case"archive-merged":case"archive-closed":return null;case"checks-running":case"none":return null}}function Nv(e){switch(e){case"accent":return"var(--accent)";case"success":return"var(--status-success)";case"error":return"var(--status-error)";case"warning":return"var(--status-warning)";case"merged":return"var(--status-merged)";case"muted":return"var(--border)";case"none":return"transparent"}}function Fv(e){return e==="success"||e==="warning"}const _y=5e3,vy=20,py=["terminal.","session-tab."];let Ho=[],Ua=null,Wv="desktop",Ka=null;function Ol(){if(Ho.length===0)return;const e=Ho;Ho=[];const t=JSON.stringify({events:e});if(navigator.sendBeacon){const i=new Blob([t],{type:"application/json"});navigator.sendBeacon("/analytics/events",i)}else fetch("/analytics/events",{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0}).catch(()=>{})}function Gh(e,t,i,r,s){Ho.push({category:e,action:t,target:i??null,properties:r??null,session_id:s??null,device:Wv}),Ho.length>=vy&&Ol()}function gy(e){let t=e;for(;t;){const i=t.getAttribute("data-track");if(i)return i;t=t.parentElement}return null}function my(e){const t=e.tagName.toLowerCase(),i=e.className&&typeof e.className=="string"?"."+e.className.trim().split(/\s+/).slice(0,2).join("."):"";return t+i}function Hv(e){const t=e.target;if(!t)return;const i=gy(t),r=i||my(t),s=(t.textContent||"").trim().slice(0,50)||null,o=i!=null&&py.some(a=>i.startsWith(a))?(Ka==null?void 0:Ka())??null:null;Gh("ui","click",r,s?{text:s}:void 0,o)}function by(e){Wv=Nt?"mobile":"desktop",Ka=e,document.addEventListener("click",Hv,{capture:!0,passive:!0}),Ua=setInterval(Ol,_y),document.addEventListener("visibilitychange",zv)}function zv(){document.visibilityState==="hidden"&&Ol()}function yy(){Ol(),Ua&&(clearInterval(Ua),Ua=null),document.removeEventListener("click",Hv,{capture:!0}),document.removeEventListener("visibilitychange",zv)}var Sy=z('<p class="error svelte-1qp96yb"> </p>'),wy=z('<div class="pin-gate svelte-1qp96yb"><div class="pin-container svelte-1qp96yb"><h1 class="svelte-1qp96yb">Claude Remote CLI</h1> <p class="svelte-1qp96yb">Enter PIN to continue</p> <input type="password" inputmode="numeric" maxlength="20" placeholder="PIN" class="svelte-1qp96yb"/> <button class="svelte-1qp96yb">Unlock</button> <!></div></div>');function Cy(e,t){dt(t,!0);const i=av();let r=W("");async function s(){const f=l(r).trim();f&&(await zb(f),i.pinError&&m(r,""))}function n(f){f.key==="Enter"&&s()}var o=wy(),a=w(o),c=T(w(a),4);Tm(c);var h=T(c,2),d=T(h,2);{var u=f=>{var _=Sy(),p=w(_);he(()=>ne(p,i.pinError)),N(f,_)};ie(d,f=>{i.pinError&&f(u)})}G("keydown",c,n),rr(c,()=>l(r),f=>m(r,f)),G("click",h,s),N(e,o),ft()}_t(["keydown","click"]);function wd(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),i.push.apply(i,r)}return i}function ol(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?wd(Object(i),!0).forEach(function(r){oo(e,r,i[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):wd(Object(i)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(i,r))})}return e}function Pn(e){"@babel/helpers - typeof";return Pn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pn(e)}function oo(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ky(e,t){if(e==null)return{};var i={},r=Object.keys(e),s,n;for(n=0;n<r.length;n++)s=r[n],!(t.indexOf(s)>=0)&&(i[s]=e[s]);return i}function xy(e,t){if(e==null)return{};var i=ky(e,t),r,s;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)r=n[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function Ey(e,t){return Ty(e)||Py(e,t)||xu(e,t)||My()}function Hi(e){return Dy(e)||Ry(e)||xu(e)||Ay()}function Dy(e){if(Array.isArray(e))return Xh(e)}function Ty(e){if(Array.isArray(e))return e}function Ry(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Py(e,t){var i=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(i!=null){var r=[],s=!0,n=!1,o,a;try{for(i=i.call(e);!(s=(o=i.next()).done)&&(r.push(o.value),!(t&&r.length===t));s=!0);}catch(c){n=!0,a=c}finally{try{!s&&i.return!=null&&i.return()}finally{if(n)throw a}}return r}}function xu(e,t){if(e){if(typeof e=="string")return Xh(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);if(i==="Object"&&e.constructor&&(i=e.constructor.name),i==="Map"||i==="Set")return Array.from(e);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Xh(e,t)}}function Xh(e,t){(t==null||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function Ay(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
13
13
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function My(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
14
14
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _a(e,t){var i=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=xu(e))||t){i&&(e=i);var r=0,s=function(){};return{s,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(c){throw c},f:s}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
15
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,a;return{s:function(){i=i.call(e)},n:function(){var c=i.next();return n=c.done,c},e:function(c){o=!0,a=c},f:function(){try{!n&&i.return!=null&&i.return()}finally{if(o)throw a}}}}var Oy="finalize",Ly="consider";function ao(e,t,i){e.dispatchEvent(new CustomEvent(Oy,{detail:{items:t,info:i}}))}function Rs(e,t,i){e.dispatchEvent(new CustomEvent(Ly,{detail:{items:t,info:i}}))}var Ll="draggedEntered",va="draggedLeft",Il="draggedOverIndex",Eu="draggedLeftDocument",al={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function Iy(e,t,i){e.dispatchEvent(new CustomEvent(Ll,{detail:{indexObj:t,draggedEl:i}}))}function By(e,t,i){e.dispatchEvent(new CustomEvent(va,{detail:{draggedEl:t,type:al.LEFT_FOR_ANOTHER,theOtherDz:i}}))}function Ny(e,t){e.dispatchEvent(new CustomEvent(va,{detail:{draggedEl:t,type:al.OUTSIDE_OF_ANY}}))}function Fy(e,t,i){e.dispatchEvent(new CustomEvent(Il,{detail:{indexObj:t,draggedEl:i}}))}function Wy(e){window.dispatchEvent(new CustomEvent(Eu,{detail:{draggedEl:e}}))}var ai={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:Ll,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:Il,DRAGGED_LEFT:va,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},mi={POINTER:"pointer",KEYBOARD:"keyboard"},Bl="isDndShadowItem",Nl="data-is-dnd-shadow-item-internal",Hy="data-is-dnd-shadow-item-hint",Uv="id:dnd-shadow-placeholder-0000",zy="dnd-action-dragged-el",Pt="id",$h=0;function Kv(){$h++}function qv(){if($h===0)throw new Error("Bug! trying to decrement when there are no dropzones");$h--}var Du=typeof window>"u";function Qh(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,i,r=t?qy(e):e.getBoundingClientRect(),s=getComputedStyle(e),n=s.transform;if(n){var o,a,c,h;if(n.startsWith("matrix3d("))i=n.slice(9,-1).split(/, /),o=+i[0],a=+i[5],c=+i[12],h=+i[13];else if(n.startsWith("matrix("))i=n.slice(7,-1).split(/, /),o=+i[0],a=+i[3],c=+i[4],h=+i[5];else return r;var d=s.transformOrigin,u=r.x-c-(1-o)*parseFloat(d),f=r.y-h-(1-a)*parseFloat(d.slice(d.indexOf(" ")+1)),_=o?r.width/o:e.offsetWidth,p=a?r.height/a:e.offsetHeight;return{x:u,y:f,width:_,height:p,top:f,right:u+_,bottom:f+p,left:u}}else return r}function Zh(e){var t=Qh(e);return{top:t.top+window.scrollY,bottom:t.bottom+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX}}function jv(e){var t=e.getBoundingClientRect();return{top:t.top+window.scrollY,bottom:t.bottom+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX}}function Yv(e){return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}function Uy(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function zo(e,t){return e.y<=t.bottom&&e.y>=t.top&&e.x>=t.left&&e.x<=t.right}function Vv(e){return Yv(jv(e))}function Cd(e,t){var i=Vv(t);return Uy(e,i)}function Ky(e){var t=jv(e);return t.right<0||t.left>document.documentElement.scrollWidth||t.bottom<0||t.top>document.documentElement.scrollHeight}function qy(e){for(var t=e.getBoundingClientRect(),i={top:t.top,bottom:t.bottom,left:t.left,right:t.right},r=!1,s=!1,n=e.parentElement;n&&n!==document.body;){var o=window.getComputedStyle(n),a=o.overflowY,c=o.overflowX,h=a==="scroll"||a==="auto",d=c==="scroll"||c==="auto";if(h||d){var u=n.getBoundingClientRect();if(h){var f=Math.max(i.top,u.top),_=Math.min(i.bottom,u.bottom);(f!==i.top||_!==i.bottom)&&(r=!0),i.top=f,i.bottom=_}if(d){var p=Math.max(i.left,u.left),b=Math.min(i.right,u.right);(p!==i.left||b!==i.right)&&(s=!0),i.left=p,i.right=b}}n=n.parentElement}return r||s?{top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:Math.max(0,i.right-i.left),height:Math.max(0,i.bottom-i.top)}:{top:t.top,bottom:t.bottom,left:t.left,right:t.right,width:Math.max(0,t.right-t.left),height:Math.max(0,t.bottom-t.top)}}var Ln;function Tu(){Ln=new Map}Tu();function jy(e){var t=Array.from(e.children).findIndex(function(i){return i.getAttribute(Nl)});if(t>=0)return Ln.has(e)||Ln.set(e,new Map),Ln.get(e).set(t,Zh(e.children[t])),t}function Yy(e,t){var i=Zh(t);if(!zo(e,i))return null;var r=t.children;if(r.length===0)return{index:0,isProximityBased:!0};for(var s=jy(t),n=0;n<r.length;n++){var o=Zh(r[n]);if(zo(e,o)){var a=Ln.has(t)&&Ln.get(t).get(n);return a&&!zo(e,a)?{index:s,isProximityBased:!1}:{index:n,isProximityBased:!1}}}for(var c=Number.MAX_VALUE,h=void 0,d=0;d<r.length;d++){var u=Cd(e,r[d]);u<c&&(c=u,h=d)}if(r.length>0){var f=r.length,_=r[f-1],p=_.cloneNode(!1);p.style.visibility="hidden",p.style.pointerEvents="none",t.appendChild(p);var b=Cd(e,p);b<c&&(h=f),t.removeChild(p)}return{index:h,isProximityBased:!0}}function bo(e){return JSON.stringify(e,null,2)}function ll(e){if(!e)throw new Error("cannot get depth of a falsy node");return Gv(e,0)}function Gv(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.parentElement?Gv(e.parentElement,t+1):t-1}function Vy(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var i in e)if(!{}.hasOwnProperty.call(t,i)||t[i]!==e[i])return!1;return!0}function Gy(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}var Xy=200,kd=10,Jh;function $y(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xy,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,n,o,a=!1,c,h=Array.from(t).sort(function(u,f){return ll(f)-ll(u)});function d(){var u=s(),f=r.multiScrollIfNeeded();if(!f&&c&&Math.abs(c.x-u.x)<kd&&Math.abs(c.y-u.y)<kd){Jh=window.setTimeout(d,i);return}if(Ky(e)){Wy(e);return}c=u;var _=!1,p=_a(h),b;try{for(p.s();!(b=p.n()).done;){var g=b.value;f&&Tu();var S=Yy(u,g);if(S!==null){var O=S.index;_=!0,g!==n?(n&&By(n,e,g),Iy(g,S,e),n=g):O!==o&&(Fy(g,S,e),o=O);break}}}catch(C){p.e(C)}finally{p.f()}!_&&a&&n?(Ny(n,e),n=void 0,o=void 0,a=!1):a=!0,Jh=window.setTimeout(d,i)}d()}function Qy(){clearTimeout(Jh),Tu()}var yo=30;function Zy(){var e;function t(){e={directionObj:void 0,stepPx:0}}t();function i(n){var o=e,a=o.directionObj,c=o.stepPx;a&&(n.scrollBy(a.x*c,a.y*c),window.requestAnimationFrame(function(){return i(n)}))}function r(n){return yo-n}function s(n,o){if(!o)return!1;var a=Jy(n,o),c=!!e.directionObj;if(a===null)return c&&t(),!1;var h=!1,d=!1;return o.scrollHeight>o.clientHeight&&(a.bottom<yo?(h=!0,e.directionObj={x:0,y:1},e.stepPx=r(a.bottom)):a.top<yo&&(h=!0,e.directionObj={x:0,y:-1},e.stepPx=r(a.top)),!c&&h)||o.scrollWidth>o.clientWidth&&(a.right<yo?(d=!0,e.directionObj={x:1,y:0},e.stepPx=r(a.right)):a.left<yo&&(d=!0,e.directionObj={x:-1,y:0},e.stepPx=r(a.left)),!c&&d)?(i(o),!0):(t(),!1)}return{scrollIfNeeded:s,resetScrolling:t}}function Jy(e,t){var i=t===document.scrollingElement?{top:0,bottom:window.innerHeight,left:0,right:window.innerWidth}:t.getBoundingClientRect();return zo(e,i)?{top:e.y-i.top,bottom:i.bottom-e.y,left:e.x-i.left,right:i.right-e.x}:null}function eS(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,i=iS(e),r=Array.from(i).sort(function(c,h){return ll(h)-ll(c)}),s=Zy(),n=s.scrollIfNeeded,o=s.resetScrolling;function a(){var c=t();if(!c||!r)return!1;for(var h=r.filter(function(f){return zo(c,f.getBoundingClientRect())||f===document.scrollingElement}),d=0;d<h.length;d++){var u=n(c,h[d]);if(u)return!0}return!1}return{multiScrollIfNeeded:i.size>0?a:function(){return!1},destroy:function(){return o()}}}function tS(e){if(!e)return[];for(var t=[],i=e;i;){var r=window.getComputedStyle(i),s=r.overflow;s.split(" ").some(function(n){return n.includes("auto")||n.includes("scroll")})&&t.push(i),i=i.parentElement}return t}function iS(e){var t=new Set,i=_a(e),r;try{for(i.s();!(r=i.n()).done;){var s=r.value;tS(s).forEach(function(n){return t.add(n)})}}catch(n){i.e(n)}finally{i.f()}return(document.scrollingElement.scrollHeight>document.scrollingElement.clientHeight||document.scrollingElement.scrollWidth>document.scrollingElement.clientHeight)&&t.add(document.scrollingElement),t}function rS(e){var t=e.cloneNode(!0),i=[],r=e.tagName==="SELECT",s=r?[e]:Wi(e.querySelectorAll("select")),n=_a(s),o;try{for(n.s();!(o=n.n()).done;){var a=o.value;i.push(a.value)}}catch(C){n.e(C)}finally{n.f()}if(s.length>0)for(var c=r?[t]:Wi(t.querySelectorAll("select")),h=0;h<c.length;h++){var d=c[h],u=i[h],f=d.querySelector('option[value="'.concat(u,'"'));f&&f.setAttribute("selected",!0)}var _=e.tagName==="CANVAS",p=_?[e]:Wi(e.querySelectorAll("canvas"));if(p.length>0)for(var b=_?[t]:Wi(t.querySelectorAll("canvas")),g=0;g<b.length;g++){var S=p[g],O=b[g];O.width=S.width,O.height=S.height,S.width>0&&S.height>0&&O.getContext("2d").drawImage(S,0,0)}return t}var Vo=Object.freeze({USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT:"USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT"}),sS=oo({},Vo.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT,!1);function Xv(e){if(!Vo[e])throw new Error("Can't get non existing feature flag ".concat(e,"! Supported flags: ").concat(Object.keys(Vo)));return sS[e]}var nS=.2;function Ms(e){return"".concat(e," ").concat(nS,"s ease")}function oS(e,t){var i=e.getBoundingClientRect(),r=rS(e);$v(e,r),r.id=zy,r.style.position="fixed";var s=i.top,n=i.left;if(r.style.top="".concat(s,"px"),r.style.left="".concat(n,"px"),t){var o=Yv(i);s-=o.y-t.y,n-=o.x-t.x,window.setTimeout(function(){r.style.top="".concat(s,"px"),r.style.left="".concat(n,"px")},0)}return r.style.margin="0",r.style.boxSizing="border-box",r.style.height="".concat(i.height,"px"),r.style.width="".concat(i.width,"px"),r.style.transition="".concat(Ms("top"),", ").concat(Ms("left"),", ").concat(Ms("background-color"),", ").concat(Ms("opacity"),", ").concat(Ms("color")," "),window.setTimeout(function(){return r.style.transition+=", ".concat(Ms("width"),", ").concat(Ms("height"))},0),r.style.zIndex="9999",r.style.cursor="grabbing",r}function aS(e){e.style.cursor="grab"}function lS(e,t,i,r){$v(t,e);var s=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=s.width-n.width,a=s.height-n.height;if(o||a){var c={left:(i-n.left)/n.width,top:(r-n.top)/n.height};Xv(Vo.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)||(e.style.height="".concat(s.height,"px"),e.style.width="".concat(s.width,"px")),e.style.left="".concat(parseFloat(e.style.left)-c.left*o,"px"),e.style.top="".concat(parseFloat(e.style.top)-c.top*a,"px")}}function $v(e,t){var i=window.getComputedStyle(e);Array.from(i).filter(function(r){return r.startsWith("background")||r.startsWith("padding")||r.startsWith("font")||r.startsWith("text")||r.startsWith("align")||r.startsWith("justify")||r.startsWith("display")||r.startsWith("flex")||r.startsWith("border")||r==="opacity"||r==="color"||r==="list-style-type"||Xv(Vo.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)&&(r==="width"||r==="height")}).forEach(function(r){return t.style.setProperty(r,i.getPropertyValue(r),i.getPropertyPriority(r))})}function hS(e,t){e.draggable=!1,e.ondragstart=function(){return!1},t?(e.style.userSelect="",e.style.WebkitUserSelect="",e.style.cursor=""):(e.style.userSelect="none",e.style.WebkitUserSelect="none",e.style.cursor="grab")}function Qv(e){e.style.display="none",e.style.position="fixed",e.style.zIndex="-5"}function cS(e){e.style.visibility="hidden",e.setAttribute(Nl,"true")}function uS(e){e.style.visibility="",e.removeAttribute(Nl)}function qa(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};e.forEach(function(r){var s=t(r);Object.keys(s).forEach(function(n){r.style[n]=s[n]}),i(r).forEach(function(n){return r.classList.add(n)})})}function hl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};e.forEach(function(r){var s=t(r);Object.keys(s).forEach(function(n){r.style[n]=""}),i(r).forEach(function(n){return r.classList.contains(n)&&r.classList.remove(n)})})}function dS(e){var t=e.style.minHeight;e.style.minHeight=window.getComputedStyle(e).getPropertyValue("height");var i=e.style.minWidth;return e.style.minWidth=window.getComputedStyle(e).getPropertyValue("width"),function(){e.style.minHeight=t,e.style.minWidth=i}}var fS="--any--",_S=100,vS=20,Da=3,pS=80,xd={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Ed="data-is-dnd-original-dragged-item",fi,Tt,pi,Fl,st,Wl,ks,Xt,vr,Bt,ns=!1,Ru=!1,Pu,pa=!1,ja=[],Uo,pr,To=!1,Au=!1,lr=new Map,mt=new Map,sh=new WeakMap;function gS(e,t){lr.has(t)||lr.set(t,new Set),lr.get(t).has(e)||(lr.get(t).add(e),Kv())}function Dd(e,t){lr.get(t).delete(e),qv(),lr.get(t).size===0&&lr.delete(t)}function mS(){var e=lr.get(Fl),t=_a(e),i;try{for(t.s();!(i=t.n()).done;){var r=i.value;r.addEventListener(Ll,Zv),r.addEventListener(va,Jv),r.addEventListener(Il,ep)}}catch(a){t.e(a)}finally{t.f()}window.addEventListener(Eu,lo);var s=Math.max.apply(Math,Wi(Array.from(e.keys()).map(function(a){return mt.get(a).dropAnimationDurationMs}))),n=s===0?vS:Math.max(s,_S);Uo=eS(e,function(){return Bt});var o=Au?function(){return{x:Bt.x+window.scrollX,y:Bt.y+window.scrollY}}:function(){return Vv(Tt)};$y(Tt,e,n*1.07,Uo,o)}function bS(){var e=lr.get(Fl),t=_a(e),i;try{for(t.s();!(i=t.n()).done;){var r=i.value;r.removeEventListener(Ll,Zv),r.removeEventListener(va,Jv),r.removeEventListener(Il,ep)}}catch(s){t.e(s)}finally{t.f()}window.removeEventListener(Eu,lo),Uo&&(Uo.destroy(),Uo=void 0),Qy()}function Hl(e){return e.findIndex(function(t){return!!t[Bl]})}function yS(e){var t;return ol(ol({},e),{},(t={},oo(t,Bl,!0),oo(t,Pt,Uv),t))}function Zv(e){var t=mt.get(e.currentTarget),i=t.items,r=t.dropFromOthersDisabled;if(!(r&&e.currentTarget!==st)){if(pa=!1,i=i.filter(function(a){return a[Pt]!==ks[Pt]&&a[Pt]!==Uv}),st!==e.currentTarget){var s=mt.get(st).items,n=s.filter(function(a){return!a[Bl]});Rs(st,n,{trigger:ai.DRAGGED_ENTERED_ANOTHER,id:pi[Pt],source:mi.POINTER})}var o=e.detail.indexObj.index;Xt=e.currentTarget,i.splice(o,0,ks),Rs(e.currentTarget,i,{trigger:ai.DRAGGED_ENTERED,id:pi[Pt],source:mi.POINTER})}}function Jv(e){if(ns){var t=mt.get(e.currentTarget),i=t.items,r=t.dropFromOthersDisabled;if(!(r&&e.currentTarget!==st&&e.currentTarget!==Xt)){var s=Wi(i),n=Hl(s);n!==-1&&s.splice(n,1);var o=Xt;Xt=void 0;var a=e.detail,c=a.type,h=a.theOtherDz;if(c===al.OUTSIDE_OF_ANY||c===al.LEFT_FOR_ANOTHER&&h!==st&&mt.get(h).dropFromOthersDisabled){pa=!0,Xt=st;var d=o===st?s:Wi(mt.get(st).items);d.splice(Wl,0,ks),Rs(st,d,{trigger:ai.DRAGGED_LEFT_ALL,id:pi[Pt],source:mi.POINTER})}Rs(e.currentTarget,s,{trigger:ai.DRAGGED_LEFT,id:pi[Pt],source:mi.POINTER})}}}function ep(e){var t=mt.get(e.currentTarget),i=t.items,r=t.dropFromOthersDisabled;if(!(r&&e.currentTarget!==st)){var s=Wi(i);pa=!1;var n=e.detail.indexObj.index,o=Hl(s);o!==-1&&s.splice(o,1),s.splice(n,0,ks),Rs(e.currentTarget,s,{trigger:ai.DRAGGED_OVER_INDEX,id:pi[Pt],source:mi.POINTER})}}function cl(e){e.preventDefault();var t=e.touches?e.touches[0]:e;Bt={x:t.clientX,y:t.clientY},Tt.style.transform="translate3d(".concat(Bt.x-vr.x,"px, ").concat(Bt.y-vr.y,"px, 0)")}function lo(){Ru=!0,window.removeEventListener("mousemove",cl),window.removeEventListener("touchmove",cl),window.removeEventListener("mouseup",lo),window.removeEventListener("touchend",lo),bS(),aS(Tt),Xt||(Xt=st);var e=mt.get(Xt),t=e.items,i=e.type;hl(lr.get(i),function(n){return mt.get(n).dropTargetStyle},function(n){return mt.get(n).dropTargetClasses});var r=Hl(t);r===-1&&Xt===st&&(r=Wl),t=t.map(function(n){return n[Bl]?pi:n});function s(){Pu(),ao(Xt,t,{trigger:pa?ai.DROPPED_OUTSIDE_OF_ANY:ai.DROPPED_INTO_ZONE,id:pi[Pt],source:mi.POINTER}),Xt!==st&&ao(st,mt.get(st).items,{trigger:ai.DROPPED_INTO_ANOTHER,id:pi[Pt],source:mi.POINTER});var n=Array.from(Xt.children).find(function(o){return o.getAttribute(Nl)});n&&uS(n),CS()}mt.get(Xt).dropAnimationDisabled?s():SS(r,s)}function SS(e,t){var i=e>-1?Qh(Xt.children[e],!1):Qh(Xt,!1),r={x:i.left-parseFloat(Tt.style.left),y:i.top-parseFloat(Tt.style.top)},s=mt.get(Xt),n=s.dropAnimationDurationMs,o="transform ".concat(n,"ms ease");Tt.style.transition=Tt.style.transition?Tt.style.transition+","+o:o,Tt.style.transform="translate3d(".concat(r.x,"px, ").concat(r.y,"px, 0)"),window.setTimeout(t,n)}function wS(e,t){ja.push({dz:e,destroy:t}),window.requestAnimationFrame(function(){Qv(e),document.body.appendChild(e)})}function CS(){Tt&&Tt.remove&&Tt.remove(),fi&&fi.remove&&fi.remove(),Tt=void 0,fi=void 0,pi=void 0,Fl=void 0,st=void 0,Wl=void 0,ks=void 0,Xt=void 0,vr=void 0,Bt=void 0,ns=!1,Ru=!1,Pu=void 0,pa=!1,pr&&clearTimeout(pr),pr=void 0,To=!1,Au=!1,ja.length&&(ja.forEach(function(e){var t=e.dz,i=e.destroy;i(),t.remove()}),ja=[])}function kS(e,t){var i=!1,r={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:xd,dropTargetClasses:[],transformDraggedElement:function(){},centreDraggedOnCursor:!1,useCursorForDetection:!1,dropAnimationDisabled:!1,delayTouchStartMs:0},s=new Map;function n(){window.addEventListener("mousemove",c,{passive:!1}),window.addEventListener("touchmove",c,{passive:!1,capture:!1}),window.addEventListener("mouseup",a,{passive:!1}),window.addEventListener("touchend",a,{passive:!1})}function o(){window.removeEventListener("mousemove",c),window.removeEventListener("touchmove",c),window.removeEventListener("mouseup",a),window.removeEventListener("touchend",a),pr&&(clearTimeout(pr),pr=void 0,To=!1)}function a(f){if(o(),fi=void 0,vr=void 0,Bt=void 0,f.type==="touchend"){var _=new Event("click",{bubbles:!0,cancelable:!0});f.target.dispatchEvent(_)}}function c(f){var _=!!f.touches,p=_?f.touches[0]:f;if(_&&r.delayTouchStartMs>0&&!To){Bt={x:p.clientX,y:p.clientY},(Math.abs(Bt.x-vr.x)>=Da||Math.abs(Bt.y-vr.y)>=Da)&&(pr&&(clearTimeout(pr),pr=void 0),a(f));return}f.preventDefault(),Bt={x:p.clientX,y:p.clientY},(Math.abs(Bt.x-vr.x)>=Da||Math.abs(Bt.y-vr.y)>=Da)&&(o(),d())}function h(f){if(!(f.target!==f.currentTarget&&(f.target.value!==void 0||f.target.isContentEditable))&&!f.button&&!ns){var _=!!f.touches,p=_&&r.delayTouchStartMs>0;p||f.preventDefault(),f.stopPropagation();var b=_?f.touches[0]:f;vr={x:b.clientX,y:b.clientY},Bt=ol({},vr),fi=f.currentTarget,p&&(To=!1,pr=window.setTimeout(function(){fi&&(To=!0,o(),d())},r.delayTouchStartMs)),n()}}function d(){ns=!0;var f=s.get(fi);Wl=f,st=fi.parentElement;var _=st.closest("dialog")||st.closest("[popover]")||st.getRootNode(),p=_.body||_,b=r.items,g=r.type,S=r.centreDraggedOnCursor,O=r.useCursorForDetection,C=Wi(b);pi=C[f],Fl=g,ks=yS(pi),Au=O,Tt=oS(fi,S&&Bt),p.appendChild(Tt);function y(){fi.parentElement?window.requestAnimationFrame(y):(fi.setAttribute(Ed,!0),p.appendChild(fi),mS(),Qv(fi),ks[Pt]=pi[Pt],Tt.focus())}window.requestAnimationFrame(y),qa(Array.from(lr.get(r.type)).filter(function(x){return x===st||!mt.get(x).dropFromOthersDisabled}),function(x){return mt.get(x).dropTargetStyle},function(x){return mt.get(x).dropTargetClasses}),C.splice(f,1,ks),Pu=dS(st),Rs(st,C,{trigger:ai.DRAG_STARTED,id:pi[Pt],source:mi.POINTER}),window.addEventListener("mousemove",cl,{passive:!1}),window.addEventListener("touchmove",cl,{passive:!1,capture:!1}),window.addEventListener("mouseup",lo,{passive:!1}),window.addEventListener("touchend",lo,{passive:!1})}function u(f){var _=f.items,p=_===void 0?void 0:_,b=f.flipDurationMs,g=b===void 0?0:b,S=f.type,O=S===void 0?fS:S,C=f.dragDisabled,y=C===void 0?!1:C,x=f.morphDisabled,P=x===void 0?!1:x,I=f.dropFromOthersDisabled,z=I===void 0?!1:I,q=f.dropTargetStyle,J=q===void 0?xd:q,K=f.dropTargetClasses,N=K===void 0?[]:K,A=f.transformDraggedElement,T=A===void 0?function(){}:A,L=f.centreDraggedOnCursor,H=L===void 0?!1:L,D=f.useCursorForDetection,E=D===void 0?!1:D,$=f.dropAnimationDisabled,Q=$===void 0?!1:$,pe=f.delayTouchStart,be=pe===void 0?!1:pe;r.dropAnimationDurationMs=g;var ce=0;be===!0?ce=pS:typeof be=="number"&&isFinite(be)&&be>=0&&(ce=be),r.delayTouchStartMs=ce,r.type&&O!==r.type&&Dd(e,r.type),r.type=O,r.items=Wi(p),r.dragDisabled=y,r.morphDisabled=P,r.transformDraggedElement=T,r.centreDraggedOnCursor=H,r.useCursorForDetection=E,r.dropAnimationDisabled=Q,i&&ns&&!Ru&&(!Vy(J,r.dropTargetStyle)||!Gy(N,r.dropTargetClasses))&&(hl([e],function(){return r.dropTargetStyle},function(){return N}),qa([e],function(){return J},function(){return N})),r.dropTargetStyle=J,r.dropTargetClasses=Wi(N);function se(Se,de){return mt.get(Se)?mt.get(Se)[de]:r[de]}i&&ns&&r.dropFromOthersDisabled!==z&&(z?hl([e],function(Se){return se(Se,"dropTargetStyle")},function(Se){return se(Se,"dropTargetClasses")}):qa([e],function(Se){return se(Se,"dropTargetStyle")},function(Se){return se(Se,"dropTargetClasses")})),r.dropFromOthersDisabled=z,mt.set(e,r),gS(e,O);for(var De=ns?Hl(r.items):-1,Te=0;Te<e.children.length;Te++){var _e=e.children[Te];if(hS(_e,y),Te===De){P||lS(Tt,_e,Bt.x,Bt.y),r.transformDraggedElement(Tt,pi,Te),cS(_e);continue}_e.removeEventListener("mousedown",sh.get(_e)),_e.removeEventListener("touchstart",sh.get(_e)),y||(_e.addEventListener("mousedown",h),_e.addEventListener("touchstart",h),sh.set(_e,h)),s.set(_e,Te),i||(i=!0)}}return u(t),{update:function(_){u(_)},destroy:function(){function _(){Dd(e,mt.get(e).type),mt.delete(e)}ns&&!e.closest("[".concat(Ed,"]"))?wS(e,_):_()}}}var Ta,ec={DND_ZONE_ACTIVE:"dnd-zone-active",DND_ZONE_DRAG_DISABLED:"dnd-zone-drag-disabled"},tp=(Ta={},oo(Ta,ec.DND_ZONE_ACTIVE,"Tab to one the items and press space-bar or enter to start dragging it"),oo(Ta,ec.DND_ZONE_DRAG_DISABLED,"This is a disabled drag and drop list"),Ta),xS="dnd-action-aria-alert",yt;function tc(){yt||(yt=document.createElement("div"),(function(){yt.id=xS,yt.style.position="fixed",yt.style.bottom="0",yt.style.left="0",yt.style.zIndex="-5",yt.style.opacity="0",yt.style.height="0",yt.style.width="0",yt.setAttribute("role","alert")})(),document.body.prepend(yt),Object.entries(tp).forEach(function(e){var t=Ey(e,2),i=t[0],r=t[1];return document.body.prepend(TS(i,r))}))}function ES(){return Du?null:(document.readyState==="complete"?tc():window.addEventListener("DOMContentLoaded",tc),ol({},ec))}function DS(){Du||!yt||(Object.keys(tp).forEach(function(e){var t;return(t=document.getElementById(e))===null||t===void 0?void 0:t.remove()}),yt.remove(),yt=void 0)}function TS(e,t){var i=document.createElement("div");return i.id=e,i.innerHTML="<p>".concat(t,"</p>"),i.style.display="none",i.style.position="fixed",i.style.zIndex="-5",i}function In(e){if(!Du){yt||tc(),yt.innerHTML="";var t=document.createTextNode(e);yt.appendChild(t),yt.style.display="none",yt.style.display="inline"}}var RS="--any--",Td={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Li=!1,ic,ii,dn="",Ls,kr,ms="",ul=new WeakSet,Rd=new WeakMap,Pd=new WeakMap,rc=new Map,Vt=new Map,nr=new Map,dl;function PS(e,t){nr.size===0&&(dl=ES(),window.addEventListener("keydown",ip),window.addEventListener("click",rp)),nr.has(t)||nr.set(t,new Set),nr.get(t).has(e)||(nr.get(t).add(e),Kv())}function Ad(e,t){ii===e&&Go(),nr.get(t).delete(e),qv(),nr.get(t).size===0&&nr.delete(t),nr.size===0&&(window.removeEventListener("keydown",ip),window.removeEventListener("click",rp),dl=void 0,DS())}function ip(e){if(Li)switch(e.key){case"Escape":{Go();break}}}function rp(){Li&&(ul.has(document.activeElement)||Go())}function AS(e){if(Li){var t=e.currentTarget;if(t!==ii){dn=t.getAttribute("aria-label")||"";var i=Vt.get(ii),r=i.items,s=r.find(function(u){return u[Pt]===kr}),n=r.indexOf(s),o=r.splice(n,1)[0],a=Vt.get(t),c=a.items,h=a.autoAriaDisabled;t.getBoundingClientRect().top<ii.getBoundingClientRect().top||t.getBoundingClientRect().left<ii.getBoundingClientRect().left?(c.push(o),h||In("Moved item ".concat(ms," to the end of the list ").concat(dn))):(c.unshift(o),h||In("Moved item ".concat(ms," to the beginning of the list ").concat(dn)));var d=ii;ao(d,r,{trigger:ai.DROPPED_INTO_ANOTHER,id:kr,source:mi.KEYBOARD}),ao(t,c,{trigger:ai.DROPPED_INTO_ZONE,id:kr,source:mi.KEYBOARD}),ii=t}}}function sp(){rc.forEach(function(e,t){var i=e.update;return i(Vt.get(t))})}function Go(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;Vt.get(ii).autoAriaDisabled||In("Stopped dragging item ".concat(ms)),ul.has(document.activeElement)&&document.activeElement.blur(),e&&Rs(ii,Vt.get(ii).items,{trigger:ai.DRAG_STOPPED,id:kr,source:mi.KEYBOARD}),hl(nr.get(ic),function(t){return Vt.get(t).dropTargetStyle},function(t){return Vt.get(t).dropTargetClasses}),Ls=null,kr=null,ms="",ic=null,ii=null,dn="",Li=!1,sp()}function MS(e,t){var i={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Td,dropTargetClasses:[],autoAriaDisabled:!1};function r(d,u,f){d.length<=1||d.splice(f,1,d.splice(u,1,d[f])[0])}function s(d){switch(d.key){case"Enter":case" ":{if((d.target.disabled!==void 0||d.target.href||d.target.isContentEditable)&&!ul.has(d.target))return;d.preventDefault(),d.stopPropagation(),Li?Go():n(d);break}case"ArrowDown":case"ArrowRight":{if(!Li)return;d.preventDefault(),d.stopPropagation();var u=Vt.get(e),f=u.items,_=Array.from(e.children),p=_.indexOf(d.currentTarget);p<_.length-1&&(i.autoAriaDisabled||In("Moved item ".concat(ms," to position ").concat(p+2," in the list ").concat(dn)),r(f,p,p+1),ao(e,f,{trigger:ai.DROPPED_INTO_ZONE,id:kr,source:mi.KEYBOARD}));break}case"ArrowUp":case"ArrowLeft":{if(!Li)return;d.preventDefault(),d.stopPropagation();var b=Vt.get(e),g=b.items,S=Array.from(e.children),O=S.indexOf(d.currentTarget);O>0&&(i.autoAriaDisabled||In("Moved item ".concat(ms," to position ").concat(O," in the list ").concat(dn)),r(g,O,O-1),ao(e,g,{trigger:ai.DROPPED_INTO_ZONE,id:kr,source:mi.KEYBOARD}));break}}}function n(d){a(d.currentTarget),ii=e,ic=i.type,Li=!0;var u=Array.from(nr.get(i.type)).filter(function(_){return _===ii||!Vt.get(_).dropFromOthersDisabled});if(qa(u,function(_){return Vt.get(_).dropTargetStyle},function(_){return Vt.get(_).dropTargetClasses}),!i.autoAriaDisabled){var f="Started dragging item ".concat(ms,". Use the arrow keys to move it within its list ").concat(dn);u.length>1&&(f+=", or tab to another list in order to move the item into it"),In(f)}Rs(e,Vt.get(e).items,{trigger:ai.DRAG_STARTED,id:kr,source:mi.KEYBOARD}),sp()}function o(d){Li&&d.currentTarget!==Ls&&(d.stopPropagation(),Go(!1),n(d))}function a(d){var u=Vt.get(e),f=u.items,_=Array.from(e.children),p=_.indexOf(d);Ls=d,Ls.tabIndex=i.zoneItemTabIndex,kr=f[p][Pt],ms=_[p].getAttribute("aria-label")||""}function c(d){var u=d.items,f=u===void 0?[]:u,_=d.type,p=_===void 0?RS:_,b=d.dragDisabled,g=b===void 0?!1:b,S=d.zoneTabIndex,O=S===void 0?0:S,C=d.zoneItemTabIndex,y=C===void 0?0:C,x=d.dropFromOthersDisabled,P=x===void 0?!1:x,I=d.dropTargetStyle,z=I===void 0?Td:I,q=d.dropTargetClasses,J=q===void 0?[]:q,K=d.autoAriaDisabled,N=K===void 0?!1:K;i.items=Wi(f),i.dragDisabled=g,i.dropFromOthersDisabled=P,i.zoneTabIndex=O,i.zoneItemTabIndex=y,i.dropTargetStyle=z,i.dropTargetClasses=J,i.autoAriaDisabled=N,i.type&&p!==i.type&&Ad(e,i.type),i.type=p,PS(e,p),N||(e.setAttribute("role","list"),e.setAttribute("aria-describedby",g?dl.DND_ZONE_DRAG_DISABLED:dl.DND_ZONE_ACTIVE)),Vt.set(e,i),Li?e.tabIndex=e===ii||Ls.contains(e)||i.dropFromOthersDisabled||ii&&i.type!==Vt.get(ii).type?-1:0:e.tabIndex=i.zoneTabIndex,e.addEventListener("focus",AS);for(var A=function(H){var D=e.children[H];ul.add(D),D.tabIndex=Li?-1:i.zoneItemTabIndex,N||D.setAttribute("role","listitem"),D.removeEventListener("keydown",Rd.get(D)),D.removeEventListener("click",Pd.get(D)),g||(D.addEventListener("keydown",s),Rd.set(D,s),D.addEventListener("click",o),Pd.set(D,o)),Li&&i.items[H][Pt]===kr&&(Ls=D,Ls.tabIndex=i.zoneItemTabIndex,D.focus())},T=0;T<e.children.length;T++)A(T)}c(t);var h={update:function(u){c(u)},destroy:function(){Ad(e,i.type),Vt.delete(e),rc.delete(e)}};return rc.set(e,h),h}var OS=["items","flipDurationMs","type","dragDisabled","morphDisabled","dropFromOthersDisabled","zoneTabIndex","zoneItemTabIndex","dropTargetStyle","dropTargetClasses","transformDraggedElement","autoAriaDisabled","centreDraggedOnCursor","useCursorForDetection","delayTouchStart","dropAnimationDisabled"];function nh(e,t){if(LS(e))return{update:function(){},destroy:function(){}};Md(t);var i=kS(e,t),r=MS(e,t);return{update:function(n){Md(n),i.update(n),r.update(n)},destroy:function(){i.destroy(),r.destroy()}}}function LS(e){return!!e.closest("[".concat(Hy,'="true"]'))}function Md(e){var t=e.items;e.flipDurationMs,e.type,e.dragDisabled,e.morphDisabled,e.dropFromOthersDisabled;var i=e.zoneTabIndex,r=e.zoneItemTabIndex;e.dropTargetStyle;var s=e.dropTargetClasses;e.transformDraggedElement,e.autoAriaDisabled,e.centreDraggedOnCursor,e.useCursorForDetection;var n=e.delayTouchStart;e.dropAnimationDisabled;var o=xy(e,OS);if(Object.keys(o).length>0&&console.warn("dndzone will ignore unknown options",o),!t)throw new Error("no 'items' key provided to dndzone");var a=t.find(function(d){return!{}.hasOwnProperty.call(d,Pt)});if(a)throw new Error("missing '".concat(Pt,"' property for item ").concat(bo(a)));if(s&&!Array.isArray(s))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(Pn(s),", ").concat(bo(s)));if(i&&!Od(i))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(Pn(i),", ").concat(bo(i)));if(r&&!Od(r))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(Pn(r),", ").concat(bo(r)));if(n!==void 0&&n!==!1){var c=n===!0,h=typeof n=="number"&&isFinite(n)&&n>=0;if(!c&&!h)throw new Error("delayTouchStart should be a boolean (true/false) or a non-negative number but instead it is a ".concat(Pn(n),", ").concat(bo(n)))}}function Od(e){return!isNaN(e)&&(function(t){return(t|0)===t})(parseFloat(e))}var IS=W('<button class="context-menu-trigger svelte-1nmhce7" data-track="context-menu.open" aria-label="Actions" aria-haspopup="true">&middot;&middot;&middot;</button>'),BS=W('<li role="menuitem"> </li>'),NS=W('<div class="context-menu-backdrop svelte-1nmhce7"></div> <ul class="context-menu svelte-1nmhce7" role="menu"></ul>',1),FS=W("<!> <!>",1);function Ld(e,t){dt(t,!0);let i=Pr(t,"hideTrigger",3,!1),r=F(!1),s=F(null),n=F(null),o=F(null);function a(y){y.stopPropagation(),l(r)?c():(m(r,!0),requestAnimationFrame(d))}function c(){m(r,!1),m(o,null)}function h(y){m(o,y.getBoundingClientRect(),!0),m(r,!0),requestAnimationFrame(d)}function d(){var z;if(!l(n))return;const y=l(o)||((z=l(s))==null?void 0:z.getBoundingClientRect());if(!y)return;const x=l(n).getBoundingClientRect();let P=y.bottom+4,I=y.right-x.width;P+x.height>window.innerHeight-8&&(P=y.top-x.height-4),I<8&&(I=8),l(n).style.top=P+"px",l(n).style.left=I+"px"}function u(y,x){x.stopPropagation(),!y.disabled&&(c(),y.action())}function f(y){!l(r)||y.key!=="Escape"||(y.stopPropagation(),c())}function _(y){y.stopPropagation(),c()}var p={openAt:h},b=FS();xr("keydown",P_,f);var g=Ct(b);{var S=y=>{var x=IS();Ze(x,P=>m(s,P),()=>l(s)),he(()=>Ie(x,"aria-expanded",l(r))),G("click",x,a),B(y,x)};ie(g,y=>{i()||y(S)})}var O=R(g,2);{var C=y=>{var x=NS(),P=Ct(x),I=R(P,2);si(I,21,()=>t.items,Yo,(z,q)=>{var J=BS();let K;var N=w(J);he(A=>{K=it(J,1,"context-menu-item svelte-1nmhce7",null,K,{"context-menu-item--danger":l(q).danger,"context-menu-item--disabled":l(q).disabled}),Ie(J,"tabindex",l(q).disabled?-1:0),Ie(J,"data-track",`context-menu.${A??""}`),ne(N,l(q).label)},[()=>l(q).label.toLowerCase().replace(/\s+/g,"-")]),G("click",J,A=>u(l(q),A)),G("keydown",J,A=>A.key==="Enter"&&u(l(q),A)),B(z,J)}),Ze(I,z=>m(n,z),()=>l(n)),G("click",P,_),G("click",I,z=>z.stopPropagation()),B(y,x)};ie(O,y=>{l(r)&&y(C)})}return B(e,b),ft(p)}_t(["click","keydown"]);var WS=W("<span> </span>"),HS=W('<span class="collapse-count svelte-168i8d5"> </span>'),zS=W('<div class="workspace-actions svelte-168i8d5"><span class="action-btn svelte-168i8d5" title="Settings">⚙</span></div>'),US=W('<span class="terminal-icon svelte-168i8d5">&gt;_</span>'),KS=W("<span></span>"),qS=W('<span class="session-count-badge svelte-168i8d5"> </span>'),jS=W('<span class="secondary-branch svelte-168i8d5"> </span>'),YS=W('<li data-track="sidebar.session.click"><div class="session-row-primary svelte-168i8d5"><!> <span> </span> <!></div> <div class="session-row-secondary svelte-168i8d5"><span class="secondary-time svelte-168i8d5"> </span> <!></div> <div class="row-menu-overlay svelte-168i8d5"><!></div></li>'),VS=W('<div class="session-row-secondary svelte-168i8d5"><span class="secondary-branch svelte-168i8d5"> </span></div>'),GS=W('<li data-track="sidebar.repo.click"><div class="session-row-primary svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span></div> <!></li>'),XS=W('<span class="secondary-branch svelte-168i8d5"> </span>'),$S=W('<li data-track="sidebar.worktree.click"><div class="session-row-primary svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span></div> <div class="session-row-secondary svelte-168i8d5"><span class="secondary-time svelte-168i8d5"> </span> <!></div> <div class="row-menu-overlay svelte-168i8d5"><!></div></li>'),QS=W('<ul class="session-list svelte-168i8d5"><!> <!></ul>'),ZS=W('<div data-track="sidebar.new-worktree"><span class="add-worktree-btn svelte-168i8d5"> </span></div>'),JS=W('<div class="workspace-divider svelte-168i8d5"></div>'),ew=W('<div><div data-track="sidebar.workspace.click"><div class="workspace-left svelte-168i8d5"><!> <span class="initial-block svelte-168i8d5"> </span> <span class="workspace-name svelte-168i8d5"> </span> <!></div> <!></div> <!> <!> <!></div>');function tw(e,t){dt(t,!0);const i=yu(),r=mu();let s=Pr(t,"inactiveWorktrees",19,()=>[]),n=me(()=>[...t.sessionGroups.values()].flat());const o=["#d97757","#4ade80","#60a5fa","#a78bfa","#f472b6","#fb923c","#34d399","#f87171"];function a(X){let ve=0;for(let Fe=0;Fe<X.length;Fe++)ve=(ve<<5)-ve+X.charCodeAt(Fe)|0;return o[Math.abs(ve)%o.length]??"#d97757"}let c=me(()=>a(t.workspace.name)),h=me(()=>t.workspace.name.charAt(0).toUpperCase()),d=me(()=>Qb(t.workspace.path)),u=me(()=>l(n).length+s().length);function f(X){return"status-dot status-dot--"+ih(X)}function _(X){return X.type==="repo"?X.displayName&&X.displayName!==X.repoName?X.displayName:"default":X.displayName||X.branchName||X.repoName||X.id}let p=me(()=>l(n).some(X=>ih(X)==="attention")),b=me(()=>Qi(`new-worktree:${t.workspace.path}`)),g=me(()=>r.reorderMode),S=$e(typeof window<"u"&&window.matchMedia("(max-width: 600px)").matches),O={},C=null;function y(X,ve){C=setTimeout(()=>{C=null;const Fe=O[X];Fe&&Fe.openAt(ve)},500)}function x(){C&&(clearTimeout(C),C=null)}function P(){C&&(clearTimeout(C),C=null)}let I=me(Zb);function z(X){return l(I),Sd(X.lastActivity)}function q(X){return l(I),Sd(X.lastActivity)}async function J(X){const ve=prompt("Rename session:",_(X));ve&&ve.trim()&&(await fetch(`/sessions/${X.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:ve.trim()})}),await gt())}function K(X){return[{label:"Rename",action:()=>J(X)},{label:"Kill",action:()=>{var ve;return(ve=t.onDeleteSession)==null?void 0:ve.call(t,X.id)},danger:!0}]}function N(X){return[{label:"Resume",action:async()=>{if(!Qi(X.path)){Tn(X.path);try{const ve=await On({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:X.path,branchName:X.branchName||X.name});await gt(),t.onSelectSession(ve.id)}catch{}finally{Rn(X.path)}}}},{label:"Resume (YOLO)",action:async()=>{if(!Qi(X.path)){Tn(X.path);try{const ve=await On({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:X.path,branchName:X.branchName||X.name,yolo:!0});await gt(),t.onSelectSession(ve.id)}catch{}finally{Rn(X.path)}}}},{label:"Delete Worktree",action:()=>{var ve;return(ve=t.onDeleteWorktree)==null?void 0:ve.call(t,X)},danger:!0}]}var A=ew();let T;var L=w(A);let H;var D=w(L),E=w(D);{var $=X=>{var ve=WS();let Fe;var Ke=w(ve);he(()=>{Fe=it(ve,1,"collapse-chevron svelte-168i8d5",null,Fe,{collapsed:l(d)}),ne(Ke,l(d)?"›":"⌄")}),G("click",ve,Be=>{Be.stopPropagation(),$b(t.workspace.path)}),B(X,ve)};ie(E,X=>{l(g)||X($)})}var Q=R(E,2);let pe;var be=w(Q),ce=R(Q,2),se=w(ce),De=R(ce,2);{var Te=X=>{var ve=HS(),Fe=w(ve);he(()=>ne(Fe,l(u))),B(X,ve)};ie(De,X=>{l(d)&&l(u)>0&&!l(g)&&X(Te)})}var _e=R(D,2);{var Se=X=>{var ve=zS(),Fe=w(ve);G("click",Fe,Ke=>{Ke.stopPropagation(),t.onOpenSettings(t.workspace)}),B(X,ve)};ie(_e,X=>{l(g)||X(Se)})}var de=R(L,2);{var Me=X=>{var ve=QS(),Fe=w(ve);si(Fe,17,()=>[...t.sessionGroups.entries()],([Be,k])=>Be,(Be,k)=>{var Z=me(()=>Eg(l(k),2));let fe=()=>l(Z)[0],ye=()=>l(Z)[1];const Ce=me(()=>ye().sort((oe,Ee)=>Ee.lastActivity.localeCompare(oe.lastActivity))[0]),M=me(()=>ye().length),Y=me(()=>fe()===t.workspace.path),ge=me(()=>l(M)>0),le=me(()=>ye().some(oe=>ih(oe)==="attention"));var re=Gr(),ke=Ct(re);{var we=oe=>{var Ee=YS();let Ge;var qt=w(Ee),ae=w(qt);{var Ye=tt=>{var Lt=US();B(tt,Lt)},jt=tt=>{var Lt=KS();he(Yi=>it(Lt,1,Yi,"svelte-168i8d5"),[()=>ev(f(l(Ce)))]),B(tt,Lt)};ie(ae,tt=>{l(Ce).type==="terminal"?tt(Ye):tt(jt,!1)})}var ji=R(ae,2);let Le;var ht=w(ji),Ot=R(ji,2);{var ur=tt=>{var Lt=qS(),Yi=w(Lt);he(()=>ne(Yi,l(M))),B(tt,Lt)};ie(Ot,tt=>{l(M)>1&&tt(ur)})}var Di=R(qt,2),Cn=w(Di),Ps=w(Cn),kn=R(Cn,2);{var Lr=tt=>{var Lt=jS(),Yi=w(Lt);he(()=>ne(Yi,l(Ce).branchName)),B(tt,Lt)};ie(kn,tt=>{l(Ce).branchName&&tt(Lr)})}var jl=R(Di,2),Yl=w(jl);{let tt=me(()=>K(l(Ce)));Ze(Ld(Yl,{get items(){return l(tt)},get hideTrigger(){return S}}),(Lt,Yi)=>O[Yi.id]=Lt,Lt=>O==null?void 0:O[Lt.id],()=>[l(Ce)])}he((tt,Lt,Yi)=>{Ge=it(Ee,1,"session-row svelte-168i8d5",null,Ge,tt),Le=it(ji,1,"session-name svelte-168i8d5",null,Le,{bold:l(le)}),ne(ht,Lt),ne(Ps,Yi)},[()=>({terminal:l(Ce).type==="terminal",selected:ye().some(tt=>i.activeSessionId===tt.id),attention:l(le)}),()=>_(l(Ce)),()=>z(l(Ce))]),G("click",Ee,()=>t.onSelectSession(l(Ce).id)),G("touchstart",Ee,tt=>y(l(Ce).id,tt.currentTarget)),G("touchend",Ee,x),G("touchmove",Ee,P),B(oe,Ee)},Re=oe=>{const Ee=me(()=>`repo-session:${t.workspace.path}`);var Ge=GS();let qt;var ae=w(Ge),Ye=R(w(ae),2),jt=w(Ye),ji=R(ae,2);{var Le=ht=>{var Ot=VS(),ur=w(Ot),Di=w(ur);he(()=>ne(Di,t.workspace.defaultBranch)),B(ht,Ot)};ie(ji,ht=>{t.workspace.defaultBranch&&ht(Le)})}he((ht,Ot)=>{qt=it(Ge,1,"session-row inactive svelte-168i8d5",null,qt,ht),ne(jt,Ot)},[()=>({loading:Qi(l(Ee))}),()=>Qi(l(Ee))?"starting...":"default"]),G("click",Ge,async()=>{if(!Qi(l(Ee))){Tn(l(Ee));try{const ht=await gu({repoPath:t.workspace.path,repoName:t.workspace.name});await gt(),t.onSelectSession(ht.id)}catch{}finally{Rn(l(Ee))}}}),B(oe,Ge)};ie(ke,oe=>{l(ge)&&l(Ce)?oe(we):l(Y)&&oe(Re,1)})}B(Be,re)});var Ke=R(Fe,2);si(Ke,17,s,Be=>Be.path,(Be,k)=>{var Z=$S();let fe;var ye=w(Z),Ce=R(w(ye),2),M=w(Ce),Y=R(ye,2),ge=w(Y),le=w(ge),re=R(ge,2);{var ke=oe=>{var Ee=XS(),Ge=w(Ee);he(()=>ne(Ge,l(k).branchName)),B(oe,Ee)};ie(re,oe=>{l(k).branchName&&oe(ke)})}var we=R(Y,2),Re=w(we);{let oe=me(()=>N(l(k)));Ze(Ld(Re,{get items(){return l(oe)},get hideTrigger(){return S}}),(Ee,Ge)=>O[Ge.path]=Ee,Ee=>O==null?void 0:O[Ee.path],()=>[l(k)])}he((oe,Ee,Ge)=>{fe=it(Z,1,"session-row inactive svelte-168i8d5",null,fe,oe),ne(M,Ee),ne(le,Ge)},[()=>({loading:Qi(l(k).path)}),()=>Qi(l(k).path)?"resuming...":l(k).branchName||l(k).displayName||l(k).name,()=>q(l(k))]),G("click",Z,async()=>{if(!Qi(l(k).path)){Tn(l(k).path);try{const oe=await On({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:l(k).path,branchName:l(k).branchName||l(k).name});await gt(),t.onSelectSession(oe.id)}catch{}finally{Rn(l(k).path)}}}),G("touchstart",Z,oe=>y(l(k).path,oe.currentTarget)),G("touchend",Z,x),G("touchmove",Z,P),B(Be,Z)}),B(X,ve)};ie(de,X=>{!l(d)&&!l(g)&&X(Me)})}var Ne=R(de,2);{var je=X=>{var ve=ZS();let Fe;var Ke=w(ve),Be=w(Ke);he(()=>{Fe=it(ve,1,"add-worktree-row svelte-168i8d5",null,Fe,{disabled:l(b)}),ne(Be,l(b)?"creating...":"+ new worktree")}),G("click",ve,()=>{l(b)||t.onNewWorktree(t.workspace)}),B(X,ve)};ie(Ne,X=>{!l(d)&&!l(g)&&X(je)})}var Pe=R(Ne,2);{var et=X=>{var ve=JS();B(X,ve)};ie(Pe,X=>{l(g)||X(et)})}he(()=>{T=it(A,1,"workspace-item svelte-168i8d5",null,T,{active:t.isActive}),H=it(L,1,"workspace-header svelte-168i8d5",null,H,{attention:l(p),"reorder-mode":l(g)}),pe=_o(Q,"",pe,{background:l(c)}),ne(be,l(h)),ne(se,t.workspace.name)}),G("click",L,()=>{l(g)||t.onSelectWorkspace(t.workspace.path)}),B(e,A),ft()}_t(["click","touchstart","touchend","touchmove"]);var iw=W('<strong class="svelte-itm1qs"> </strong>'),rw=W("<span> </span>"),sw=W('<li role="option" data-track="search.select"><!> <span class="dropdown-path svelte-itm1qs"> </span></li>'),nw=W('<ul class="dropdown svelte-itm1qs" role="listbox"></ul>'),ow=W('<div class="smart-search svelte-itm1qs"><div class="input-row svelte-itm1qs"><span class="prompt svelte-itm1qs">&gt;</span> <input type="text" class="search-input svelte-itm1qs" data-track="search.input" placeholder="search workspaces..." autocomplete="off"/></div> <!></div>');function aw(e,t){dt(t,!0);let i=F(""),r=F(0),s=F(void 0),n=me(()=>{if(!l(i).trim())return[];const g=l(i).toLowerCase();return t.workspaces.filter(S=>S.name.toLowerCase().includes(g))}),o=me(()=>l(i).trim().length>0&&l(n).length>0);zi(()=>{l(n).length,m(r,0)});function a(g){m(i,g.target.value,!0)}function c(g){var S;if(g.key==="Escape"){m(i,""),(S=l(s))==null||S.blur();return}if(l(o)){if(g.key==="ArrowDown")g.preventDefault(),m(r,Math.min(l(r)+1,l(n).length-1),!0);else if(g.key==="ArrowUp")g.preventDefault(),m(r,Math.max(l(r)-1,0),!0);else if(g.key==="Enter"){g.preventDefault();const O=l(n)[l(r)];O&&h(O)}}}function h(g){var S;t.onSelect(g.path),m(i,""),(S=l(s))==null||S.blur()}function d(g,S){if(!S)return[{text:g,bold:!1}];const O=g.toLowerCase(),C=S.toLowerCase(),y=O.indexOf(C);return y===-1?[{text:g,bold:!1}]:[{text:g.slice(0,y),bold:!1},{text:g.slice(y,y+C.length),bold:!0},{text:g.slice(y+C.length),bold:!1}].filter(x=>x.text.length>0)}var u=ow(),f=w(u),_=R(w(f),2);Ie(_,"spellcheck",!1),Ze(_,g=>m(s,g),()=>l(s));var p=R(f,2);{var b=g=>{var S=nw();si(S,23,()=>l(n),O=>O.path,(O,C,y)=>{var x=sw();let P;var I=w(x);si(I,17,()=>d(l(C).name,l(i)),Yo,(J,K)=>{var N=Gr(),A=Ct(N);{var T=H=>{var D=iw(),E=w(D);he(()=>ne(E,l(K).text)),B(H,D)},L=H=>{var D=rw(),E=w(D);he(()=>ne(E,l(K).text)),B(H,D)};ie(A,H=>{l(K).bold?H(T):H(L,!1)})}B(J,N)});var z=R(I,2),q=w(z);he(()=>{P=it(x,1,"dropdown-item svelte-itm1qs",null,P,{focused:l(y)===l(r)}),Ie(x,"aria-selected",l(y)===l(r)),ne(q,l(C).path)}),G("click",x,()=>h(l(C))),xr("mouseenter",x,()=>{m(r,l(y),!0)}),B(O,x)}),B(g,S)};ie(p,g=>{l(o)&&g(b)})}he(()=>nb(_,l(i))),G("input",_,a),G("keydown",_,c),B(e,u),ft()}_t(["input","keydown","click"]);var lw=W('<span class="sidebar-label svelte-owj5vn">Workspaces</span>'),hw=W("<div><!></div>"),cw=W('<div class="empty-state svelte-owj5vn"><span>No workspaces</span></div>'),uw=W('<button class="done-reorder-btn svelte-owj5vn">Done reordering</button>'),dw=W('<button class="add-workspace-btn svelte-owj5vn" data-track="sidebar.add-workspace">+ Add Workspace</button>'),fw=W('<!> <div class="workspace-list svelte-owj5vn"><!> <!></div> <!> <div class="sidebar-footer-row svelte-owj5vn"><!> <button class="settings-icon-btn svelte-owj5vn" data-track="sidebar.settings" aria-label="Settings">⚙</button></div> <div class="resize-handle svelte-owj5vn"></div>',1),_w=W('<aside><div class="sidebar-header svelte-owj5vn"><button class="collapse-btn svelte-owj5vn"> </button> <!> <button class="icon-btn svelte-owj5vn" aria-label="Close sidebar">✕</button></div> <!></aside>');function vw(e,t){dt(t,!0);const i=mu(),r=yu();let s=me(()=>i.sidebarCollapsed?Ub:i.sidebarWidth);function n(T){i.activeWorkspacePath=T,r.activeSessionId=null}function o(T){i.activeWorkspacePath=T,ki()}function a(T){T.preventDefault();const L=T.clientX,H=i.sidebarWidth,D=$=>{const Q=Math.min(dv,Math.max(uv,H+($.clientX-L)));i.sidebarWidth=Q},E=()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",E),document.body.style.cursor="",document.body.style.userSelect="",md()};document.addEventListener("mousemove",D),document.addEventListener("mouseup",E),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function c(T){T.preventDefault(),i.sidebarWidth=cv,md()}const h=200;let d=me(()=>r.workspaces.map(T=>({id:T.path,workspace:T}))),u=F($e([]));zi(()=>{m(u,l(d),!0)});function f(T){m(u,T.detail.items,!0)}function _(T){m(u,T.detail.items,!0);const L=l(u).map(H=>H.id);hy(L)}function p(){Vb()}let b=null;function g(){b=setTimeout(()=>{Yb(),b=null},500)}function S(){b&&(clearTimeout(b),b=null)}function O(){b&&(clearTimeout(b),b=null)}var C=_w();let y,x;var P=w(C),I=w(P),z=w(I),q=R(I,2);{var J=T=>{var L=lw();B(T,L)};ie(q,T=>{i.sidebarCollapsed||T(J)})}var K=R(q,2),N=R(P,2);{var A=T=>{var L=fw(),H=Ct(L);{var D=de=>{aw(de,{get workspaces(){return r.workspaces},onSelect:o})};ie(H,de=>{i.reorderMode||de(D)})}var E=R(H,2),$=w(E);si($,17,()=>l(u),de=>de.id,(de,Me)=>{const Ne=me(()=>l(Me).workspace),je=me(()=>wv(l(Ne).path)),Pe=me(()=>new Set(l(je).map(Ke=>Ke.repoPath))),et=me(()=>r.worktrees.filter(Ke=>Ke.repoPath===l(Ne).path&&Ke.path.startsWith(l(Ne).path+"/")&&!l(Pe).has(Ke.path))),X=me(()=>(()=>{const Ke=new Map;Ke.set(l(Ne).path,[]);for(const Be of l(je)){const k=Ke.get(Be.repoPath);k?k.push(Be):Ke.set(Be.repoPath,[Be])}return Ke})());var ve=hw(),Fe=w(ve);{let Ke=me(()=>i.activeWorkspacePath===l(Ne).path&&!r.activeSessionId);tw(Fe,{get workspace(){return l(Ne)},get sessionGroups(){return l(X)},get inactiveWorktrees(){return l(et)},get isActive(){return l(Ke)},onSelectWorkspace:n,get onSelectSession(){return t.onSelectSession},get onNewWorktree(){return t.onNewWorktree},onOpenSettings:Be=>t.onOpenSettings(Be),onDeleteSession:Be=>{var k;return(k=t.onDeleteSession)==null?void 0:k.call(t,Be)},onDeleteWorktree:Be=>{var k;return(k=t.onDeleteWorktree)==null?void 0:k.call(t,Be)}})}B(de,ve)});var Q=R($,2);{var pe=de=>{var Me=cw();B(de,Me)};ie(Q,de=>{r.workspaces.length===0&&de(pe)})}Qm(E,(de,Me)=>nh==null?void 0:nh(de,Me),()=>({items:l(u),flipDurationMs:h,type:"workspaces",dropTargetStyle:{}}));var be=R(E,2);{var ce=de=>{var Me=uw();G("click",Me,p),B(de,Me)};ie(be,de=>{i.reorderMode&&de(ce)})}var se=R(be,2),De=w(se);{var Te=de=>{var Me=dw();G("click",Me,function(...Ne){var je;(je=t.onAddWorkspace)==null||je.apply(this,Ne)}),B(de,Me)};ie(De,de=>{i.reorderMode||de(Te)})}var _e=R(De,2),Se=R(se,2);xr("consider",E,f),xr("finalize",E,_),G("touchstart",E,g),G("touchend",E,S),G("touchmove",E,O),G("click",_e,()=>t.onOpenSettings()),G("mousedown",Se,a),G("dblclick",Se,c),B(T,L)};ie(N,T=>{i.sidebarCollapsed||T(A)})}he(()=>{y=it(C,1,"sidebar svelte-owj5vn",null,y,{open:i.sidebarOpen,collapsed:i.sidebarCollapsed}),x=_o(C,"",x,{width:`${l(s)??""}px`,"min-width":`${l(s)??""}px`}),Ie(I,"aria-label",i.sidebarCollapsed?"Expand sidebar":"Collapse sidebar"),ne(z,i.sidebarCollapsed?"»":"«")}),G("click",I,function(...T){th==null||th.apply(this,T)}),G("click",K,function(...T){ki==null||ki.apply(this,T)}),B(e,C),ft()}_t(["click","touchstart","touchend","touchmove","mousedown","dblclick"]);/**
15
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,a;return{s:function(){i=i.call(e)},n:function(){var c=i.next();return n=c.done,c},e:function(c){o=!0,a=c},f:function(){try{!n&&i.return!=null&&i.return()}finally{if(o)throw a}}}}var Oy="finalize",Ly="consider";function ao(e,t,i){e.dispatchEvent(new CustomEvent(Oy,{detail:{items:t,info:i}}))}function Rs(e,t,i){e.dispatchEvent(new CustomEvent(Ly,{detail:{items:t,info:i}}))}var Ll="draggedEntered",va="draggedLeft",Il="draggedOverIndex",Eu="draggedLeftDocument",al={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function Iy(e,t,i){e.dispatchEvent(new CustomEvent(Ll,{detail:{indexObj:t,draggedEl:i}}))}function By(e,t,i){e.dispatchEvent(new CustomEvent(va,{detail:{draggedEl:t,type:al.LEFT_FOR_ANOTHER,theOtherDz:i}}))}function Ny(e,t){e.dispatchEvent(new CustomEvent(va,{detail:{draggedEl:t,type:al.OUTSIDE_OF_ANY}}))}function Fy(e,t,i){e.dispatchEvent(new CustomEvent(Il,{detail:{indexObj:t,draggedEl:i}}))}function Wy(e){window.dispatchEvent(new CustomEvent(Eu,{detail:{draggedEl:e}}))}var ai={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:Ll,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:Il,DRAGGED_LEFT:va,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},mi={POINTER:"pointer",KEYBOARD:"keyboard"},Bl="isDndShadowItem",Nl="data-is-dnd-shadow-item-internal",Hy="data-is-dnd-shadow-item-hint",Uv="id:dnd-shadow-placeholder-0000",zy="dnd-action-dragged-el",Pt="id",$h=0;function Kv(){$h++}function qv(){if($h===0)throw new Error("Bug! trying to decrement when there are no dropzones");$h--}var Du=typeof window>"u";function Qh(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,i,r=t?qy(e):e.getBoundingClientRect(),s=getComputedStyle(e),n=s.transform;if(n){var o,a,c,h;if(n.startsWith("matrix3d("))i=n.slice(9,-1).split(/, /),o=+i[0],a=+i[5],c=+i[12],h=+i[13];else if(n.startsWith("matrix("))i=n.slice(7,-1).split(/, /),o=+i[0],a=+i[3],c=+i[4],h=+i[5];else return r;var d=s.transformOrigin,u=r.x-c-(1-o)*parseFloat(d),f=r.y-h-(1-a)*parseFloat(d.slice(d.indexOf(" ")+1)),_=o?r.width/o:e.offsetWidth,p=a?r.height/a:e.offsetHeight;return{x:u,y:f,width:_,height:p,top:f,right:u+_,bottom:f+p,left:u}}else return r}function Zh(e){var t=Qh(e);return{top:t.top+window.scrollY,bottom:t.bottom+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX}}function jv(e){var t=e.getBoundingClientRect();return{top:t.top+window.scrollY,bottom:t.bottom+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX}}function Yv(e){return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}function Uy(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function zo(e,t){return e.y<=t.bottom&&e.y>=t.top&&e.x>=t.left&&e.x<=t.right}function Vv(e){return Yv(jv(e))}function Cd(e,t){var i=Vv(t);return Uy(e,i)}function Ky(e){var t=jv(e);return t.right<0||t.left>document.documentElement.scrollWidth||t.bottom<0||t.top>document.documentElement.scrollHeight}function qy(e){for(var t=e.getBoundingClientRect(),i={top:t.top,bottom:t.bottom,left:t.left,right:t.right},r=!1,s=!1,n=e.parentElement;n&&n!==document.body;){var o=window.getComputedStyle(n),a=o.overflowY,c=o.overflowX,h=a==="scroll"||a==="auto",d=c==="scroll"||c==="auto";if(h||d){var u=n.getBoundingClientRect();if(h){var f=Math.max(i.top,u.top),_=Math.min(i.bottom,u.bottom);(f!==i.top||_!==i.bottom)&&(r=!0),i.top=f,i.bottom=_}if(d){var p=Math.max(i.left,u.left),b=Math.min(i.right,u.right);(p!==i.left||b!==i.right)&&(s=!0),i.left=p,i.right=b}}n=n.parentElement}return r||s?{top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:Math.max(0,i.right-i.left),height:Math.max(0,i.bottom-i.top)}:{top:t.top,bottom:t.bottom,left:t.left,right:t.right,width:Math.max(0,t.right-t.left),height:Math.max(0,t.bottom-t.top)}}var Ln;function Tu(){Ln=new Map}Tu();function jy(e){var t=Array.from(e.children).findIndex(function(i){return i.getAttribute(Nl)});if(t>=0)return Ln.has(e)||Ln.set(e,new Map),Ln.get(e).set(t,Zh(e.children[t])),t}function Yy(e,t){var i=Zh(t);if(!zo(e,i))return null;var r=t.children;if(r.length===0)return{index:0,isProximityBased:!0};for(var s=jy(t),n=0;n<r.length;n++){var o=Zh(r[n]);if(zo(e,o)){var a=Ln.has(t)&&Ln.get(t).get(n);return a&&!zo(e,a)?{index:s,isProximityBased:!1}:{index:n,isProximityBased:!1}}}for(var c=Number.MAX_VALUE,h=void 0,d=0;d<r.length;d++){var u=Cd(e,r[d]);u<c&&(c=u,h=d)}if(r.length>0){var f=r.length,_=r[f-1],p=_.cloneNode(!1);p.style.visibility="hidden",p.style.pointerEvents="none",t.appendChild(p);var b=Cd(e,p);b<c&&(h=f),t.removeChild(p)}return{index:h,isProximityBased:!0}}function bo(e){return JSON.stringify(e,null,2)}function ll(e){if(!e)throw new Error("cannot get depth of a falsy node");return Gv(e,0)}function Gv(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.parentElement?Gv(e.parentElement,t+1):t-1}function Vy(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var i in e)if(!{}.hasOwnProperty.call(t,i)||t[i]!==e[i])return!1;return!0}function Gy(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}var Xy=200,kd=10,Jh;function $y(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xy,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,n,o,a=!1,c,h=Array.from(t).sort(function(u,f){return ll(f)-ll(u)});function d(){var u=s(),f=r.multiScrollIfNeeded();if(!f&&c&&Math.abs(c.x-u.x)<kd&&Math.abs(c.y-u.y)<kd){Jh=window.setTimeout(d,i);return}if(Ky(e)){Wy(e);return}c=u;var _=!1,p=_a(h),b;try{for(p.s();!(b=p.n()).done;){var g=b.value;f&&Tu();var y=Yy(u,g);if(y!==null){var O=y.index;_=!0,g!==n?(n&&By(n,e,g),Iy(g,y,e),n=g):O!==o&&(Fy(g,y,e),o=O);break}}}catch(R){p.e(R)}finally{p.f()}!_&&a&&n?(Ny(n,e),n=void 0,o=void 0,a=!1):a=!0,Jh=window.setTimeout(d,i)}d()}function Qy(){clearTimeout(Jh),Tu()}var yo=30;function Zy(){var e;function t(){e={directionObj:void 0,stepPx:0}}t();function i(n){var o=e,a=o.directionObj,c=o.stepPx;a&&(n.scrollBy(a.x*c,a.y*c),window.requestAnimationFrame(function(){return i(n)}))}function r(n){return yo-n}function s(n,o){if(!o)return!1;var a=Jy(n,o),c=!!e.directionObj;if(a===null)return c&&t(),!1;var h=!1,d=!1;return o.scrollHeight>o.clientHeight&&(a.bottom<yo?(h=!0,e.directionObj={x:0,y:1},e.stepPx=r(a.bottom)):a.top<yo&&(h=!0,e.directionObj={x:0,y:-1},e.stepPx=r(a.top)),!c&&h)||o.scrollWidth>o.clientWidth&&(a.right<yo?(d=!0,e.directionObj={x:1,y:0},e.stepPx=r(a.right)):a.left<yo&&(d=!0,e.directionObj={x:-1,y:0},e.stepPx=r(a.left)),!c&&d)?(i(o),!0):(t(),!1)}return{scrollIfNeeded:s,resetScrolling:t}}function Jy(e,t){var i=t===document.scrollingElement?{top:0,bottom:window.innerHeight,left:0,right:window.innerWidth}:t.getBoundingClientRect();return zo(e,i)?{top:e.y-i.top,bottom:i.bottom-e.y,left:e.x-i.left,right:i.right-e.x}:null}function eS(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,i=iS(e),r=Array.from(i).sort(function(c,h){return ll(h)-ll(c)}),s=Zy(),n=s.scrollIfNeeded,o=s.resetScrolling;function a(){var c=t();if(!c||!r)return!1;for(var h=r.filter(function(f){return zo(c,f.getBoundingClientRect())||f===document.scrollingElement}),d=0;d<h.length;d++){var u=n(c,h[d]);if(u)return!0}return!1}return{multiScrollIfNeeded:i.size>0?a:function(){return!1},destroy:function(){return o()}}}function tS(e){if(!e)return[];for(var t=[],i=e;i;){var r=window.getComputedStyle(i),s=r.overflow;s.split(" ").some(function(n){return n.includes("auto")||n.includes("scroll")})&&t.push(i),i=i.parentElement}return t}function iS(e){var t=new Set,i=_a(e),r;try{for(i.s();!(r=i.n()).done;){var s=r.value;tS(s).forEach(function(n){return t.add(n)})}}catch(n){i.e(n)}finally{i.f()}return(document.scrollingElement.scrollHeight>document.scrollingElement.clientHeight||document.scrollingElement.scrollWidth>document.scrollingElement.clientHeight)&&t.add(document.scrollingElement),t}function rS(e){var t=e.cloneNode(!0),i=[],r=e.tagName==="SELECT",s=r?[e]:Hi(e.querySelectorAll("select")),n=_a(s),o;try{for(n.s();!(o=n.n()).done;){var a=o.value;i.push(a.value)}}catch(R){n.e(R)}finally{n.f()}if(s.length>0)for(var c=r?[t]:Hi(t.querySelectorAll("select")),h=0;h<c.length;h++){var d=c[h],u=i[h],f=d.querySelector('option[value="'.concat(u,'"'));f&&f.setAttribute("selected",!0)}var _=e.tagName==="CANVAS",p=_?[e]:Hi(e.querySelectorAll("canvas"));if(p.length>0)for(var b=_?[t]:Hi(t.querySelectorAll("canvas")),g=0;g<b.length;g++){var y=p[g],O=b[g];O.width=y.width,O.height=y.height,y.width>0&&y.height>0&&O.getContext("2d").drawImage(y,0,0)}return t}var Vo=Object.freeze({USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT:"USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT"}),sS=oo({},Vo.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT,!1);function Xv(e){if(!Vo[e])throw new Error("Can't get non existing feature flag ".concat(e,"! Supported flags: ").concat(Object.keys(Vo)));return sS[e]}var nS=.2;function Ms(e){return"".concat(e," ").concat(nS,"s ease")}function oS(e,t){var i=e.getBoundingClientRect(),r=rS(e);$v(e,r),r.id=zy,r.style.position="fixed";var s=i.top,n=i.left;if(r.style.top="".concat(s,"px"),r.style.left="".concat(n,"px"),t){var o=Yv(i);s-=o.y-t.y,n-=o.x-t.x,window.setTimeout(function(){r.style.top="".concat(s,"px"),r.style.left="".concat(n,"px")},0)}return r.style.margin="0",r.style.boxSizing="border-box",r.style.height="".concat(i.height,"px"),r.style.width="".concat(i.width,"px"),r.style.transition="".concat(Ms("top"),", ").concat(Ms("left"),", ").concat(Ms("background-color"),", ").concat(Ms("opacity"),", ").concat(Ms("color")," "),window.setTimeout(function(){return r.style.transition+=", ".concat(Ms("width"),", ").concat(Ms("height"))},0),r.style.zIndex="9999",r.style.cursor="grabbing",r}function aS(e){e.style.cursor="grab"}function lS(e,t,i,r){$v(t,e);var s=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=s.width-n.width,a=s.height-n.height;if(o||a){var c={left:(i-n.left)/n.width,top:(r-n.top)/n.height};Xv(Vo.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)||(e.style.height="".concat(s.height,"px"),e.style.width="".concat(s.width,"px")),e.style.left="".concat(parseFloat(e.style.left)-c.left*o,"px"),e.style.top="".concat(parseFloat(e.style.top)-c.top*a,"px")}}function $v(e,t){var i=window.getComputedStyle(e);Array.from(i).filter(function(r){return r.startsWith("background")||r.startsWith("padding")||r.startsWith("font")||r.startsWith("text")||r.startsWith("align")||r.startsWith("justify")||r.startsWith("display")||r.startsWith("flex")||r.startsWith("border")||r==="opacity"||r==="color"||r==="list-style-type"||Xv(Vo.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)&&(r==="width"||r==="height")}).forEach(function(r){return t.style.setProperty(r,i.getPropertyValue(r),i.getPropertyPriority(r))})}function hS(e,t){e.draggable=!1,e.ondragstart=function(){return!1},t?(e.style.userSelect="",e.style.WebkitUserSelect="",e.style.cursor=""):(e.style.userSelect="none",e.style.WebkitUserSelect="none",e.style.cursor="grab")}function Qv(e){e.style.display="none",e.style.position="fixed",e.style.zIndex="-5"}function cS(e){e.style.visibility="hidden",e.setAttribute(Nl,"true")}function uS(e){e.style.visibility="",e.removeAttribute(Nl)}function qa(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};e.forEach(function(r){var s=t(r);Object.keys(s).forEach(function(n){r.style[n]=s[n]}),i(r).forEach(function(n){return r.classList.add(n)})})}function hl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};e.forEach(function(r){var s=t(r);Object.keys(s).forEach(function(n){r.style[n]=""}),i(r).forEach(function(n){return r.classList.contains(n)&&r.classList.remove(n)})})}function dS(e){var t=e.style.minHeight;e.style.minHeight=window.getComputedStyle(e).getPropertyValue("height");var i=e.style.minWidth;return e.style.minWidth=window.getComputedStyle(e).getPropertyValue("width"),function(){e.style.minHeight=t,e.style.minWidth=i}}var fS="--any--",_S=100,vS=20,Da=3,pS=80,xd={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Ed="data-is-dnd-original-dragged-item",fi,Tt,pi,Fl,st,Wl,ks,Xt,vr,Bt,ns=!1,Ru=!1,Pu,pa=!1,ja=[],Uo,pr,To=!1,Au=!1,lr=new Map,mt=new Map,sh=new WeakMap;function gS(e,t){lr.has(t)||lr.set(t,new Set),lr.get(t).has(e)||(lr.get(t).add(e),Kv())}function Dd(e,t){lr.get(t).delete(e),qv(),lr.get(t).size===0&&lr.delete(t)}function mS(){var e=lr.get(Fl),t=_a(e),i;try{for(t.s();!(i=t.n()).done;){var r=i.value;r.addEventListener(Ll,Zv),r.addEventListener(va,Jv),r.addEventListener(Il,ep)}}catch(a){t.e(a)}finally{t.f()}window.addEventListener(Eu,lo);var s=Math.max.apply(Math,Hi(Array.from(e.keys()).map(function(a){return mt.get(a).dropAnimationDurationMs}))),n=s===0?vS:Math.max(s,_S);Uo=eS(e,function(){return Bt});var o=Au?function(){return{x:Bt.x+window.scrollX,y:Bt.y+window.scrollY}}:function(){return Vv(Tt)};$y(Tt,e,n*1.07,Uo,o)}function bS(){var e=lr.get(Fl),t=_a(e),i;try{for(t.s();!(i=t.n()).done;){var r=i.value;r.removeEventListener(Ll,Zv),r.removeEventListener(va,Jv),r.removeEventListener(Il,ep)}}catch(s){t.e(s)}finally{t.f()}window.removeEventListener(Eu,lo),Uo&&(Uo.destroy(),Uo=void 0),Qy()}function Hl(e){return e.findIndex(function(t){return!!t[Bl]})}function yS(e){var t;return ol(ol({},e),{},(t={},oo(t,Bl,!0),oo(t,Pt,Uv),t))}function Zv(e){var t=mt.get(e.currentTarget),i=t.items,r=t.dropFromOthersDisabled;if(!(r&&e.currentTarget!==st)){if(pa=!1,i=i.filter(function(a){return a[Pt]!==ks[Pt]&&a[Pt]!==Uv}),st!==e.currentTarget){var s=mt.get(st).items,n=s.filter(function(a){return!a[Bl]});Rs(st,n,{trigger:ai.DRAGGED_ENTERED_ANOTHER,id:pi[Pt],source:mi.POINTER})}var o=e.detail.indexObj.index;Xt=e.currentTarget,i.splice(o,0,ks),Rs(e.currentTarget,i,{trigger:ai.DRAGGED_ENTERED,id:pi[Pt],source:mi.POINTER})}}function Jv(e){if(ns){var t=mt.get(e.currentTarget),i=t.items,r=t.dropFromOthersDisabled;if(!(r&&e.currentTarget!==st&&e.currentTarget!==Xt)){var s=Hi(i),n=Hl(s);n!==-1&&s.splice(n,1);var o=Xt;Xt=void 0;var a=e.detail,c=a.type,h=a.theOtherDz;if(c===al.OUTSIDE_OF_ANY||c===al.LEFT_FOR_ANOTHER&&h!==st&&mt.get(h).dropFromOthersDisabled){pa=!0,Xt=st;var d=o===st?s:Hi(mt.get(st).items);d.splice(Wl,0,ks),Rs(st,d,{trigger:ai.DRAGGED_LEFT_ALL,id:pi[Pt],source:mi.POINTER})}Rs(e.currentTarget,s,{trigger:ai.DRAGGED_LEFT,id:pi[Pt],source:mi.POINTER})}}}function ep(e){var t=mt.get(e.currentTarget),i=t.items,r=t.dropFromOthersDisabled;if(!(r&&e.currentTarget!==st)){var s=Hi(i);pa=!1;var n=e.detail.indexObj.index,o=Hl(s);o!==-1&&s.splice(o,1),s.splice(n,0,ks),Rs(e.currentTarget,s,{trigger:ai.DRAGGED_OVER_INDEX,id:pi[Pt],source:mi.POINTER})}}function cl(e){e.preventDefault();var t=e.touches?e.touches[0]:e;Bt={x:t.clientX,y:t.clientY},Tt.style.transform="translate3d(".concat(Bt.x-vr.x,"px, ").concat(Bt.y-vr.y,"px, 0)")}function lo(){Ru=!0,window.removeEventListener("mousemove",cl),window.removeEventListener("touchmove",cl),window.removeEventListener("mouseup",lo),window.removeEventListener("touchend",lo),bS(),aS(Tt),Xt||(Xt=st);var e=mt.get(Xt),t=e.items,i=e.type;hl(lr.get(i),function(n){return mt.get(n).dropTargetStyle},function(n){return mt.get(n).dropTargetClasses});var r=Hl(t);r===-1&&Xt===st&&(r=Wl),t=t.map(function(n){return n[Bl]?pi:n});function s(){Pu(),ao(Xt,t,{trigger:pa?ai.DROPPED_OUTSIDE_OF_ANY:ai.DROPPED_INTO_ZONE,id:pi[Pt],source:mi.POINTER}),Xt!==st&&ao(st,mt.get(st).items,{trigger:ai.DROPPED_INTO_ANOTHER,id:pi[Pt],source:mi.POINTER});var n=Array.from(Xt.children).find(function(o){return o.getAttribute(Nl)});n&&uS(n),CS()}mt.get(Xt).dropAnimationDisabled?s():SS(r,s)}function SS(e,t){var i=e>-1?Qh(Xt.children[e],!1):Qh(Xt,!1),r={x:i.left-parseFloat(Tt.style.left),y:i.top-parseFloat(Tt.style.top)},s=mt.get(Xt),n=s.dropAnimationDurationMs,o="transform ".concat(n,"ms ease");Tt.style.transition=Tt.style.transition?Tt.style.transition+","+o:o,Tt.style.transform="translate3d(".concat(r.x,"px, ").concat(r.y,"px, 0)"),window.setTimeout(t,n)}function wS(e,t){ja.push({dz:e,destroy:t}),window.requestAnimationFrame(function(){Qv(e),document.body.appendChild(e)})}function CS(){Tt&&Tt.remove&&Tt.remove(),fi&&fi.remove&&fi.remove(),Tt=void 0,fi=void 0,pi=void 0,Fl=void 0,st=void 0,Wl=void 0,ks=void 0,Xt=void 0,vr=void 0,Bt=void 0,ns=!1,Ru=!1,Pu=void 0,pa=!1,pr&&clearTimeout(pr),pr=void 0,To=!1,Au=!1,ja.length&&(ja.forEach(function(e){var t=e.dz,i=e.destroy;i(),t.remove()}),ja=[])}function kS(e,t){var i=!1,r={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:xd,dropTargetClasses:[],transformDraggedElement:function(){},centreDraggedOnCursor:!1,useCursorForDetection:!1,dropAnimationDisabled:!1,delayTouchStartMs:0},s=new Map;function n(){window.addEventListener("mousemove",c,{passive:!1}),window.addEventListener("touchmove",c,{passive:!1,capture:!1}),window.addEventListener("mouseup",a,{passive:!1}),window.addEventListener("touchend",a,{passive:!1})}function o(){window.removeEventListener("mousemove",c),window.removeEventListener("touchmove",c),window.removeEventListener("mouseup",a),window.removeEventListener("touchend",a),pr&&(clearTimeout(pr),pr=void 0,To=!1)}function a(f){if(o(),fi=void 0,vr=void 0,Bt=void 0,f.type==="touchend"){var _=new Event("click",{bubbles:!0,cancelable:!0});f.target.dispatchEvent(_)}}function c(f){var _=!!f.touches,p=_?f.touches[0]:f;if(_&&r.delayTouchStartMs>0&&!To){Bt={x:p.clientX,y:p.clientY},(Math.abs(Bt.x-vr.x)>=Da||Math.abs(Bt.y-vr.y)>=Da)&&(pr&&(clearTimeout(pr),pr=void 0),a(f));return}f.preventDefault(),Bt={x:p.clientX,y:p.clientY},(Math.abs(Bt.x-vr.x)>=Da||Math.abs(Bt.y-vr.y)>=Da)&&(o(),d())}function h(f){if(!(f.target!==f.currentTarget&&(f.target.value!==void 0||f.target.isContentEditable))&&!f.button&&!ns){var _=!!f.touches,p=_&&r.delayTouchStartMs>0;p||f.preventDefault(),f.stopPropagation();var b=_?f.touches[0]:f;vr={x:b.clientX,y:b.clientY},Bt=ol({},vr),fi=f.currentTarget,p&&(To=!1,pr=window.setTimeout(function(){fi&&(To=!0,o(),d())},r.delayTouchStartMs)),n()}}function d(){ns=!0;var f=s.get(fi);Wl=f,st=fi.parentElement;var _=st.closest("dialog")||st.closest("[popover]")||st.getRootNode(),p=_.body||_,b=r.items,g=r.type,y=r.centreDraggedOnCursor,O=r.useCursorForDetection,R=Hi(b);pi=R[f],Fl=g,ks=yS(pi),Au=O,Tt=oS(fi,y&&Bt),p.appendChild(Tt);function S(){fi.parentElement?window.requestAnimationFrame(S):(fi.setAttribute(Ed,!0),p.appendChild(fi),mS(),Qv(fi),ks[Pt]=pi[Pt],Tt.focus())}window.requestAnimationFrame(S),qa(Array.from(lr.get(r.type)).filter(function(E){return E===st||!mt.get(E).dropFromOthersDisabled}),function(E){return mt.get(E).dropTargetStyle},function(E){return mt.get(E).dropTargetClasses}),R.splice(f,1,ks),Pu=dS(st),Rs(st,R,{trigger:ai.DRAG_STARTED,id:pi[Pt],source:mi.POINTER}),window.addEventListener("mousemove",cl,{passive:!1}),window.addEventListener("touchmove",cl,{passive:!1,capture:!1}),window.addEventListener("mouseup",lo,{passive:!1}),window.addEventListener("touchend",lo,{passive:!1})}function u(f){var _=f.items,p=_===void 0?void 0:_,b=f.flipDurationMs,g=b===void 0?0:b,y=f.type,O=y===void 0?fS:y,R=f.dragDisabled,S=R===void 0?!1:R,E=f.morphDisabled,A=E===void 0?!1:E,P=f.dropFromOthersDisabled,B=P===void 0?!1:P,U=f.dropTargetStyle,$=U===void 0?xd:U,q=f.dropTargetClasses,F=q===void 0?[]:q,L=f.transformDraggedElement,D=L===void 0?function(){}:L,I=f.centreDraggedOnCursor,H=I===void 0?!1:I,k=f.useCursorForDetection,x=k===void 0?!1:k,Q=f.dropAnimationDisabled,Z=Q===void 0?!1:Q,pe=f.delayTouchStart,be=pe===void 0?!1:pe;r.dropAnimationDurationMs=g;var ce=0;be===!0?ce=pS:typeof be=="number"&&isFinite(be)&&be>=0&&(ce=be),r.delayTouchStartMs=ce,r.type&&O!==r.type&&Dd(e,r.type),r.type=O,r.items=Hi(p),r.dragDisabled=S,r.morphDisabled=A,r.transformDraggedElement=D,r.centreDraggedOnCursor=H,r.useCursorForDetection=x,r.dropAnimationDisabled=Z,i&&ns&&!Ru&&(!Vy($,r.dropTargetStyle)||!Gy(F,r.dropTargetClasses))&&(hl([e],function(){return r.dropTargetStyle},function(){return F}),qa([e],function(){return $},function(){return F})),r.dropTargetStyle=$,r.dropTargetClasses=Hi(F);function se(Se,de){return mt.get(Se)?mt.get(Se)[de]:r[de]}i&&ns&&r.dropFromOthersDisabled!==B&&(B?hl([e],function(Se){return se(Se,"dropTargetStyle")},function(Se){return se(Se,"dropTargetClasses")}):qa([e],function(Se){return se(Se,"dropTargetStyle")},function(Se){return se(Se,"dropTargetClasses")})),r.dropFromOthersDisabled=B,mt.set(e,r),gS(e,O);for(var De=ns?Hl(r.items):-1,Te=0;Te<e.children.length;Te++){var _e=e.children[Te];if(hS(_e,S),Te===De){A||lS(Tt,_e,Bt.x,Bt.y),r.transformDraggedElement(Tt,pi,Te),cS(_e);continue}_e.removeEventListener("mousedown",sh.get(_e)),_e.removeEventListener("touchstart",sh.get(_e)),S||(_e.addEventListener("mousedown",h),_e.addEventListener("touchstart",h),sh.set(_e,h)),s.set(_e,Te),i||(i=!0)}}return u(t),{update:function(_){u(_)},destroy:function(){function _(){Dd(e,mt.get(e).type),mt.delete(e)}ns&&!e.closest("[".concat(Ed,"]"))?wS(e,_):_()}}}var Ta,ec={DND_ZONE_ACTIVE:"dnd-zone-active",DND_ZONE_DRAG_DISABLED:"dnd-zone-drag-disabled"},tp=(Ta={},oo(Ta,ec.DND_ZONE_ACTIVE,"Tab to one the items and press space-bar or enter to start dragging it"),oo(Ta,ec.DND_ZONE_DRAG_DISABLED,"This is a disabled drag and drop list"),Ta),xS="dnd-action-aria-alert",yt;function tc(){yt||(yt=document.createElement("div"),(function(){yt.id=xS,yt.style.position="fixed",yt.style.bottom="0",yt.style.left="0",yt.style.zIndex="-5",yt.style.opacity="0",yt.style.height="0",yt.style.width="0",yt.setAttribute("role","alert")})(),document.body.prepend(yt),Object.entries(tp).forEach(function(e){var t=Ey(e,2),i=t[0],r=t[1];return document.body.prepend(TS(i,r))}))}function ES(){return Du?null:(document.readyState==="complete"?tc():window.addEventListener("DOMContentLoaded",tc),ol({},ec))}function DS(){Du||!yt||(Object.keys(tp).forEach(function(e){var t;return(t=document.getElementById(e))===null||t===void 0?void 0:t.remove()}),yt.remove(),yt=void 0)}function TS(e,t){var i=document.createElement("div");return i.id=e,i.innerHTML="<p>".concat(t,"</p>"),i.style.display="none",i.style.position="fixed",i.style.zIndex="-5",i}function In(e){if(!Du){yt||tc(),yt.innerHTML="";var t=document.createTextNode(e);yt.appendChild(t),yt.style.display="none",yt.style.display="inline"}}var RS="--any--",Td={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Ii=!1,ic,ii,dn="",Ls,kr,ms="",ul=new WeakSet,Rd=new WeakMap,Pd=new WeakMap,rc=new Map,Vt=new Map,nr=new Map,dl;function PS(e,t){nr.size===0&&(dl=ES(),window.addEventListener("keydown",ip),window.addEventListener("click",rp)),nr.has(t)||nr.set(t,new Set),nr.get(t).has(e)||(nr.get(t).add(e),Kv())}function Ad(e,t){ii===e&&Go(),nr.get(t).delete(e),qv(),nr.get(t).size===0&&nr.delete(t),nr.size===0&&(window.removeEventListener("keydown",ip),window.removeEventListener("click",rp),dl=void 0,DS())}function ip(e){if(Ii)switch(e.key){case"Escape":{Go();break}}}function rp(){Ii&&(ul.has(document.activeElement)||Go())}function AS(e){if(Ii){var t=e.currentTarget;if(t!==ii){dn=t.getAttribute("aria-label")||"";var i=Vt.get(ii),r=i.items,s=r.find(function(u){return u[Pt]===kr}),n=r.indexOf(s),o=r.splice(n,1)[0],a=Vt.get(t),c=a.items,h=a.autoAriaDisabled;t.getBoundingClientRect().top<ii.getBoundingClientRect().top||t.getBoundingClientRect().left<ii.getBoundingClientRect().left?(c.push(o),h||In("Moved item ".concat(ms," to the end of the list ").concat(dn))):(c.unshift(o),h||In("Moved item ".concat(ms," to the beginning of the list ").concat(dn)));var d=ii;ao(d,r,{trigger:ai.DROPPED_INTO_ANOTHER,id:kr,source:mi.KEYBOARD}),ao(t,c,{trigger:ai.DROPPED_INTO_ZONE,id:kr,source:mi.KEYBOARD}),ii=t}}}function sp(){rc.forEach(function(e,t){var i=e.update;return i(Vt.get(t))})}function Go(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;Vt.get(ii).autoAriaDisabled||In("Stopped dragging item ".concat(ms)),ul.has(document.activeElement)&&document.activeElement.blur(),e&&Rs(ii,Vt.get(ii).items,{trigger:ai.DRAG_STOPPED,id:kr,source:mi.KEYBOARD}),hl(nr.get(ic),function(t){return Vt.get(t).dropTargetStyle},function(t){return Vt.get(t).dropTargetClasses}),Ls=null,kr=null,ms="",ic=null,ii=null,dn="",Ii=!1,sp()}function MS(e,t){var i={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Td,dropTargetClasses:[],autoAriaDisabled:!1};function r(d,u,f){d.length<=1||d.splice(f,1,d.splice(u,1,d[f])[0])}function s(d){switch(d.key){case"Enter":case" ":{if((d.target.disabled!==void 0||d.target.href||d.target.isContentEditable)&&!ul.has(d.target))return;d.preventDefault(),d.stopPropagation(),Ii?Go():n(d);break}case"ArrowDown":case"ArrowRight":{if(!Ii)return;d.preventDefault(),d.stopPropagation();var u=Vt.get(e),f=u.items,_=Array.from(e.children),p=_.indexOf(d.currentTarget);p<_.length-1&&(i.autoAriaDisabled||In("Moved item ".concat(ms," to position ").concat(p+2," in the list ").concat(dn)),r(f,p,p+1),ao(e,f,{trigger:ai.DROPPED_INTO_ZONE,id:kr,source:mi.KEYBOARD}));break}case"ArrowUp":case"ArrowLeft":{if(!Ii)return;d.preventDefault(),d.stopPropagation();var b=Vt.get(e),g=b.items,y=Array.from(e.children),O=y.indexOf(d.currentTarget);O>0&&(i.autoAriaDisabled||In("Moved item ".concat(ms," to position ").concat(O," in the list ").concat(dn)),r(g,O,O-1),ao(e,g,{trigger:ai.DROPPED_INTO_ZONE,id:kr,source:mi.KEYBOARD}));break}}}function n(d){a(d.currentTarget),ii=e,ic=i.type,Ii=!0;var u=Array.from(nr.get(i.type)).filter(function(_){return _===ii||!Vt.get(_).dropFromOthersDisabled});if(qa(u,function(_){return Vt.get(_).dropTargetStyle},function(_){return Vt.get(_).dropTargetClasses}),!i.autoAriaDisabled){var f="Started dragging item ".concat(ms,". Use the arrow keys to move it within its list ").concat(dn);u.length>1&&(f+=", or tab to another list in order to move the item into it"),In(f)}Rs(e,Vt.get(e).items,{trigger:ai.DRAG_STARTED,id:kr,source:mi.KEYBOARD}),sp()}function o(d){Ii&&d.currentTarget!==Ls&&(d.stopPropagation(),Go(!1),n(d))}function a(d){var u=Vt.get(e),f=u.items,_=Array.from(e.children),p=_.indexOf(d);Ls=d,Ls.tabIndex=i.zoneItemTabIndex,kr=f[p][Pt],ms=_[p].getAttribute("aria-label")||""}function c(d){var u=d.items,f=u===void 0?[]:u,_=d.type,p=_===void 0?RS:_,b=d.dragDisabled,g=b===void 0?!1:b,y=d.zoneTabIndex,O=y===void 0?0:y,R=d.zoneItemTabIndex,S=R===void 0?0:R,E=d.dropFromOthersDisabled,A=E===void 0?!1:E,P=d.dropTargetStyle,B=P===void 0?Td:P,U=d.dropTargetClasses,$=U===void 0?[]:U,q=d.autoAriaDisabled,F=q===void 0?!1:q;i.items=Hi(f),i.dragDisabled=g,i.dropFromOthersDisabled=A,i.zoneTabIndex=O,i.zoneItemTabIndex=S,i.dropTargetStyle=B,i.dropTargetClasses=$,i.autoAriaDisabled=F,i.type&&p!==i.type&&Ad(e,i.type),i.type=p,PS(e,p),F||(e.setAttribute("role","list"),e.setAttribute("aria-describedby",g?dl.DND_ZONE_DRAG_DISABLED:dl.DND_ZONE_ACTIVE)),Vt.set(e,i),Ii?e.tabIndex=e===ii||Ls.contains(e)||i.dropFromOthersDisabled||ii&&i.type!==Vt.get(ii).type?-1:0:e.tabIndex=i.zoneTabIndex,e.addEventListener("focus",AS);for(var L=function(H){var k=e.children[H];ul.add(k),k.tabIndex=Ii?-1:i.zoneItemTabIndex,F||k.setAttribute("role","listitem"),k.removeEventListener("keydown",Rd.get(k)),k.removeEventListener("click",Pd.get(k)),g||(k.addEventListener("keydown",s),Rd.set(k,s),k.addEventListener("click",o),Pd.set(k,o)),Ii&&i.items[H][Pt]===kr&&(Ls=k,Ls.tabIndex=i.zoneItemTabIndex,k.focus())},D=0;D<e.children.length;D++)L(D)}c(t);var h={update:function(u){c(u)},destroy:function(){Ad(e,i.type),Vt.delete(e),rc.delete(e)}};return rc.set(e,h),h}var OS=["items","flipDurationMs","type","dragDisabled","morphDisabled","dropFromOthersDisabled","zoneTabIndex","zoneItemTabIndex","dropTargetStyle","dropTargetClasses","transformDraggedElement","autoAriaDisabled","centreDraggedOnCursor","useCursorForDetection","delayTouchStart","dropAnimationDisabled"];function nh(e,t){if(LS(e))return{update:function(){},destroy:function(){}};Md(t);var i=kS(e,t),r=MS(e,t);return{update:function(n){Md(n),i.update(n),r.update(n)},destroy:function(){i.destroy(),r.destroy()}}}function LS(e){return!!e.closest("[".concat(Hy,'="true"]'))}function Md(e){var t=e.items;e.flipDurationMs,e.type,e.dragDisabled,e.morphDisabled,e.dropFromOthersDisabled;var i=e.zoneTabIndex,r=e.zoneItemTabIndex;e.dropTargetStyle;var s=e.dropTargetClasses;e.transformDraggedElement,e.autoAriaDisabled,e.centreDraggedOnCursor,e.useCursorForDetection;var n=e.delayTouchStart;e.dropAnimationDisabled;var o=xy(e,OS);if(Object.keys(o).length>0&&console.warn("dndzone will ignore unknown options",o),!t)throw new Error("no 'items' key provided to dndzone");var a=t.find(function(d){return!{}.hasOwnProperty.call(d,Pt)});if(a)throw new Error("missing '".concat(Pt,"' property for item ").concat(bo(a)));if(s&&!Array.isArray(s))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(Pn(s),", ").concat(bo(s)));if(i&&!Od(i))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(Pn(i),", ").concat(bo(i)));if(r&&!Od(r))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(Pn(r),", ").concat(bo(r)));if(n!==void 0&&n!==!1){var c=n===!0,h=typeof n=="number"&&isFinite(n)&&n>=0;if(!c&&!h)throw new Error("delayTouchStart should be a boolean (true/false) or a non-negative number but instead it is a ".concat(Pn(n),", ").concat(bo(n)))}}function Od(e){return!isNaN(e)&&(function(t){return(t|0)===t})(parseFloat(e))}var IS=z('<button class="context-menu-trigger svelte-1nmhce7" data-track="context-menu.open" aria-label="Actions" aria-haspopup="true">&middot;&middot;&middot;</button>'),BS=z('<li role="menuitem"> </li>'),NS=z('<div class="context-menu-backdrop svelte-1nmhce7"></div> <ul class="context-menu svelte-1nmhce7" role="menu"></ul>',1),FS=z("<!> <!>",1);function Ld(e,t){dt(t,!0);let i=Pr(t,"hideTrigger",3,!1),r=W(!1),s=W(null),n=W(null),o=W(null);function a(S){S.stopPropagation(),l(r)?c():(m(r,!0),requestAnimationFrame(d))}function c(){m(r,!1),m(o,null)}function h(S){m(o,S.getBoundingClientRect(),!0),m(r,!0),requestAnimationFrame(d)}function d(){var B;if(!l(n))return;const S=l(o)||((B=l(s))==null?void 0:B.getBoundingClientRect());if(!S)return;const E=l(n).getBoundingClientRect();let A=S.bottom+4,P=S.right-E.width;A+E.height>window.innerHeight-8&&(A=S.top-E.height-4),P<8&&(P=8),l(n).style.top=A+"px",l(n).style.left=P+"px"}function u(S,E){E.stopPropagation(),!S.disabled&&(c(),S.action())}function f(S){!l(r)||S.key!=="Escape"||(S.stopPropagation(),c())}function _(S){S.stopPropagation(),c()}var p={openAt:h},b=FS();xr("keydown",P_,f);var g=Ct(b);{var y=S=>{var E=IS();Ze(E,A=>m(s,A),()=>l(s)),he(()=>Ie(E,"aria-expanded",l(r))),G("click",E,a),N(S,E)};ie(g,S=>{i()||S(y)})}var O=T(g,2);{var R=S=>{var E=NS(),A=Ct(E),P=T(A,2);si(P,21,()=>t.items,Yo,(B,U)=>{var $=BS();let q;var F=w($);he(L=>{q=it($,1,"context-menu-item svelte-1nmhce7",null,q,{"context-menu-item--danger":l(U).danger,"context-menu-item--disabled":l(U).disabled}),Ie($,"tabindex",l(U).disabled?-1:0),Ie($,"data-track",`context-menu.${L??""}`),ne(F,l(U).label)},[()=>l(U).label.toLowerCase().replace(/\s+/g,"-")]),G("click",$,L=>u(l(U),L)),G("keydown",$,L=>L.key==="Enter"&&u(l(U),L)),N(B,$)}),Ze(P,B=>m(n,B),()=>l(n)),G("click",A,_),G("click",P,B=>B.stopPropagation()),N(S,E)};ie(O,S=>{l(r)&&S(R)})}return N(e,b),ft(p)}_t(["click","keydown"]);var WS=z("<span> </span>"),HS=z('<span class="collapse-count svelte-168i8d5"> </span>'),zS=z('<div class="workspace-actions svelte-168i8d5"><span class="action-btn svelte-168i8d5" title="Settings">⚙</span></div>'),US=z('<span class="terminal-icon svelte-168i8d5">&gt;_</span>'),KS=z("<span></span>"),qS=z('<span class="session-count-badge svelte-168i8d5"> </span>'),jS=z('<span class="secondary-branch svelte-168i8d5"> </span>'),YS=z('<li data-track="sidebar.session.click"><div class="session-row-primary svelte-168i8d5"><!> <span> </span> <!></div> <div class="session-row-secondary svelte-168i8d5"><span class="secondary-time svelte-168i8d5"> </span> <!></div> <div class="row-menu-overlay svelte-168i8d5"><!></div></li>'),VS=z('<div class="session-row-secondary svelte-168i8d5"><span class="secondary-branch svelte-168i8d5"> </span></div>'),GS=z('<li data-track="sidebar.repo.click"><div class="session-row-primary svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span></div> <!></li>'),XS=z('<span class="secondary-branch svelte-168i8d5"> </span>'),$S=z('<li data-track="sidebar.worktree.click"><div class="session-row-primary svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span></div> <div class="session-row-secondary svelte-168i8d5"><span class="secondary-time svelte-168i8d5"> </span> <!></div> <div class="row-menu-overlay svelte-168i8d5"><!></div></li>'),QS=z('<ul class="session-list svelte-168i8d5"><!> <!></ul>'),ZS=z('<div data-track="sidebar.new-worktree"><span class="add-worktree-btn svelte-168i8d5"> </span></div>'),JS=z('<div class="workspace-divider svelte-168i8d5"></div>'),ew=z('<div><div data-track="sidebar.workspace.click"><div class="workspace-left svelte-168i8d5"><!> <span class="initial-block svelte-168i8d5"> </span> <span class="workspace-name svelte-168i8d5"> </span> <!></div> <!></div> <!> <!> <!></div>');function tw(e,t){dt(t,!0);const i=yu(),r=mu();let s=Pr(t,"inactiveWorktrees",19,()=>[]),n=me(()=>[...t.sessionGroups.values()].flat());const o=["#d97757","#4ade80","#60a5fa","#a78bfa","#f472b6","#fb923c","#34d399","#f87171"];function a(X){let ve=0;for(let Fe=0;Fe<X.length;Fe++)ve=(ve<<5)-ve+X.charCodeAt(Fe)|0;return o[Math.abs(ve)%o.length]??"#d97757"}let c=me(()=>a(t.workspace.name)),h=me(()=>t.workspace.name.charAt(0).toUpperCase()),d=me(()=>Qb(t.workspace.path)),u=me(()=>l(n).length+s().length);function f(X){return"status-dot status-dot--"+ih(X)}function _(X){return X.type==="repo"?X.displayName&&X.displayName!==X.repoName?X.displayName:"default":X.displayName||X.branchName||X.repoName||X.id}let p=me(()=>l(n).some(X=>ih(X)==="attention")),b=me(()=>Qi(`new-worktree:${t.workspace.path}`)),g=me(()=>r.reorderMode),y=Xe(typeof window<"u"&&window.matchMedia("(max-width: 600px)").matches),O={},R=null;function S(X,ve){R=setTimeout(()=>{R=null;const Fe=O[X];Fe&&Fe.openAt(ve)},500)}function E(){R&&(clearTimeout(R),R=null)}function A(){R&&(clearTimeout(R),R=null)}let P=me(Zb);function B(X){return l(P),Sd(X.lastActivity)}function U(X){return l(P),Sd(X.lastActivity)}async function $(X){const ve=prompt("Rename session:",_(X));ve&&ve.trim()&&(await fetch(`/sessions/${X.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:ve.trim()})}),await gt())}function q(X){return[{label:"Rename",action:()=>$(X)},{label:"Kill",action:()=>{var ve;return(ve=t.onDeleteSession)==null?void 0:ve.call(t,X.id)},danger:!0}]}function F(X){return[{label:"Resume",action:async()=>{if(!Qi(X.path)){Tn(X.path);try{const ve=await On({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:X.path,branchName:X.branchName||X.name});await gt(),t.onSelectSession(ve.id)}catch{}finally{Rn(X.path)}}}},{label:"Resume (YOLO)",action:async()=>{if(!Qi(X.path)){Tn(X.path);try{const ve=await On({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:X.path,branchName:X.branchName||X.name,yolo:!0});await gt(),t.onSelectSession(ve.id)}catch{}finally{Rn(X.path)}}}},{label:"Delete Worktree",action:()=>{var ve;return(ve=t.onDeleteWorktree)==null?void 0:ve.call(t,X)},danger:!0}]}var L=ew();let D;var I=w(L);let H;var k=w(I),x=w(k);{var Q=X=>{var ve=WS();let Fe;var Ke=w(ve);he(()=>{Fe=it(ve,1,"collapse-chevron svelte-168i8d5",null,Fe,{collapsed:l(d)}),ne(Ke,l(d)?"›":"⌄")}),G("click",ve,Be=>{Be.stopPropagation(),$b(t.workspace.path)}),N(X,ve)};ie(x,X=>{l(g)||X(Q)})}var Z=T(x,2);let pe;var be=w(Z),ce=T(Z,2),se=w(ce),De=T(ce,2);{var Te=X=>{var ve=HS(),Fe=w(ve);he(()=>ne(Fe,l(u))),N(X,ve)};ie(De,X=>{l(d)&&l(u)>0&&!l(g)&&X(Te)})}var _e=T(k,2);{var Se=X=>{var ve=zS(),Fe=w(ve);G("click",Fe,Ke=>{Ke.stopPropagation(),t.onOpenSettings(t.workspace)}),N(X,ve)};ie(_e,X=>{l(g)||X(Se)})}var de=T(I,2);{var Me=X=>{var ve=QS(),Fe=w(ve);si(Fe,17,()=>[...t.sessionGroups.entries()],([Be,C])=>Be,(Be,C)=>{var J=me(()=>Eg(l(C),2));let fe=()=>l(J)[0],ye=()=>l(J)[1];const Ce=me(()=>ye().sort((oe,Ee)=>Ee.lastActivity.localeCompare(oe.lastActivity))[0]),M=me(()=>ye().length),Y=me(()=>fe()===t.workspace.path),ge=me(()=>l(M)>0),le=me(()=>ye().some(oe=>ih(oe)==="attention"));var re=Gr(),ke=Ct(re);{var we=oe=>{var Ee=YS();let Ge;var qt=w(Ee),ae=w(qt);{var Ye=tt=>{var Lt=US();N(tt,Lt)},jt=tt=>{var Lt=KS();he(Yi=>it(Lt,1,Yi,"svelte-168i8d5"),[()=>ev(f(l(Ce)))]),N(tt,Lt)};ie(ae,tt=>{l(Ce).type==="terminal"?tt(Ye):tt(jt,!1)})}var ji=T(ae,2);let Le;var ht=w(ji),Ot=T(ji,2);{var ur=tt=>{var Lt=qS(),Yi=w(Lt);he(()=>ne(Yi,l(M))),N(tt,Lt)};ie(Ot,tt=>{l(M)>1&&tt(ur)})}var Ti=T(qt,2),Cn=w(Ti),Ps=w(Cn),kn=T(Cn,2);{var Lr=tt=>{var Lt=jS(),Yi=w(Lt);he(()=>ne(Yi,l(Ce).branchName)),N(tt,Lt)};ie(kn,tt=>{l(Ce).branchName&&tt(Lr)})}var jl=T(Ti,2),Yl=w(jl);{let tt=me(()=>q(l(Ce)));Ze(Ld(Yl,{get items(){return l(tt)},get hideTrigger(){return y}}),(Lt,Yi)=>O[Yi.id]=Lt,Lt=>O==null?void 0:O[Lt.id],()=>[l(Ce)])}he((tt,Lt,Yi)=>{Ge=it(Ee,1,"session-row svelte-168i8d5",null,Ge,tt),Le=it(ji,1,"session-name svelte-168i8d5",null,Le,{bold:l(le)}),ne(ht,Lt),ne(Ps,Yi)},[()=>({terminal:l(Ce).type==="terminal",selected:ye().some(tt=>i.activeSessionId===tt.id),attention:l(le)}),()=>_(l(Ce)),()=>B(l(Ce))]),G("click",Ee,()=>t.onSelectSession(l(Ce).id)),G("touchstart",Ee,tt=>S(l(Ce).id,tt.currentTarget)),G("touchend",Ee,E),G("touchmove",Ee,A),N(oe,Ee)},Re=oe=>{const Ee=me(()=>`repo-session:${t.workspace.path}`);var Ge=GS();let qt;var ae=w(Ge),Ye=T(w(ae),2),jt=w(Ye),ji=T(ae,2);{var Le=ht=>{var Ot=VS(),ur=w(Ot),Ti=w(ur);he(()=>ne(Ti,t.workspace.defaultBranch)),N(ht,Ot)};ie(ji,ht=>{t.workspace.defaultBranch&&ht(Le)})}he((ht,Ot)=>{qt=it(Ge,1,"session-row inactive svelte-168i8d5",null,qt,ht),ne(jt,Ot)},[()=>({loading:Qi(l(Ee))}),()=>Qi(l(Ee))?"starting...":"default"]),G("click",Ge,async()=>{if(!Qi(l(Ee))){Tn(l(Ee));try{const ht=await gu({repoPath:t.workspace.path,repoName:t.workspace.name});await gt(),t.onSelectSession(ht.id)}catch{}finally{Rn(l(Ee))}}}),N(oe,Ge)};ie(ke,oe=>{l(ge)&&l(Ce)?oe(we):l(Y)&&oe(Re,1)})}N(Be,re)});var Ke=T(Fe,2);si(Ke,17,s,Be=>Be.path,(Be,C)=>{var J=$S();let fe;var ye=w(J),Ce=T(w(ye),2),M=w(Ce),Y=T(ye,2),ge=w(Y),le=w(ge),re=T(ge,2);{var ke=oe=>{var Ee=XS(),Ge=w(Ee);he(()=>ne(Ge,l(C).branchName)),N(oe,Ee)};ie(re,oe=>{l(C).branchName&&oe(ke)})}var we=T(Y,2),Re=w(we);{let oe=me(()=>F(l(C)));Ze(Ld(Re,{get items(){return l(oe)},get hideTrigger(){return y}}),(Ee,Ge)=>O[Ge.path]=Ee,Ee=>O==null?void 0:O[Ee.path],()=>[l(C)])}he((oe,Ee,Ge)=>{fe=it(J,1,"session-row inactive svelte-168i8d5",null,fe,oe),ne(M,Ee),ne(le,Ge)},[()=>({loading:Qi(l(C).path)}),()=>Qi(l(C).path)?"resuming...":l(C).branchName||l(C).displayName||l(C).name,()=>U(l(C))]),G("click",J,async()=>{if(!Qi(l(C).path)){Tn(l(C).path);try{const oe=await On({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:l(C).path,branchName:l(C).branchName||l(C).name});await gt(),t.onSelectSession(oe.id)}catch{}finally{Rn(l(C).path)}}}),G("touchstart",J,oe=>S(l(C).path,oe.currentTarget)),G("touchend",J,E),G("touchmove",J,A),N(Be,J)}),N(X,ve)};ie(de,X=>{!l(d)&&!l(g)&&X(Me)})}var Ne=T(de,2);{var je=X=>{var ve=ZS();let Fe;var Ke=w(ve),Be=w(Ke);he(()=>{Fe=it(ve,1,"add-worktree-row svelte-168i8d5",null,Fe,{disabled:l(b)}),ne(Be,l(b)?"creating...":"+ new worktree")}),G("click",ve,()=>{l(b)||t.onNewWorktree(t.workspace)}),N(X,ve)};ie(Ne,X=>{!l(d)&&!l(g)&&X(je)})}var Pe=T(Ne,2);{var et=X=>{var ve=JS();N(X,ve)};ie(Pe,X=>{l(g)||X(et)})}he(()=>{D=it(L,1,"workspace-item svelte-168i8d5",null,D,{active:t.isActive}),H=it(I,1,"workspace-header svelte-168i8d5",null,H,{attention:l(p),"reorder-mode":l(g)}),pe=_o(Z,"",pe,{background:l(c)}),ne(be,l(h)),ne(se,t.workspace.name)}),G("click",I,()=>{l(g)||t.onSelectWorkspace(t.workspace.path)}),N(e,L),ft()}_t(["click","touchstart","touchend","touchmove"]);var iw=z('<strong class="svelte-itm1qs"> </strong>'),rw=z("<span> </span>"),sw=z('<li role="option" data-track="search.select"><!> <span class="dropdown-path svelte-itm1qs"> </span></li>'),nw=z('<ul class="dropdown svelte-itm1qs" role="listbox"></ul>'),ow=z('<div class="smart-search svelte-itm1qs"><div class="input-row svelte-itm1qs"><span class="prompt svelte-itm1qs">&gt;</span> <input type="text" class="search-input svelte-itm1qs" data-track="search.input" placeholder="search workspaces..." autocomplete="off"/></div> <!></div>');function aw(e,t){dt(t,!0);let i=W(""),r=W(0),s=W(void 0),n=me(()=>{if(!l(i).trim())return[];const g=l(i).toLowerCase();return t.workspaces.filter(y=>y.name.toLowerCase().includes(g))}),o=me(()=>l(i).trim().length>0&&l(n).length>0);Ei(()=>{l(n).length,m(r,0)});function a(g){m(i,g.target.value,!0)}function c(g){var y;if(g.key==="Escape"){m(i,""),(y=l(s))==null||y.blur();return}if(l(o)){if(g.key==="ArrowDown")g.preventDefault(),m(r,Math.min(l(r)+1,l(n).length-1),!0);else if(g.key==="ArrowUp")g.preventDefault(),m(r,Math.max(l(r)-1,0),!0);else if(g.key==="Enter"){g.preventDefault();const O=l(n)[l(r)];O&&h(O)}}}function h(g){var y;t.onSelect(g.path),m(i,""),(y=l(s))==null||y.blur()}function d(g,y){if(!y)return[{text:g,bold:!1}];const O=g.toLowerCase(),R=y.toLowerCase(),S=O.indexOf(R);return S===-1?[{text:g,bold:!1}]:[{text:g.slice(0,S),bold:!1},{text:g.slice(S,S+R.length),bold:!0},{text:g.slice(S+R.length),bold:!1}].filter(E=>E.text.length>0)}var u=ow(),f=w(u),_=T(w(f),2);Ie(_,"spellcheck",!1),Ze(_,g=>m(s,g),()=>l(s));var p=T(f,2);{var b=g=>{var y=nw();si(y,23,()=>l(n),O=>O.path,(O,R,S)=>{var E=sw();let A;var P=w(E);si(P,17,()=>d(l(R).name,l(i)),Yo,($,q)=>{var F=Gr(),L=Ct(F);{var D=H=>{var k=iw(),x=w(k);he(()=>ne(x,l(q).text)),N(H,k)},I=H=>{var k=rw(),x=w(k);he(()=>ne(x,l(q).text)),N(H,k)};ie(L,H=>{l(q).bold?H(D):H(I,!1)})}N($,F)});var B=T(P,2),U=w(B);he(()=>{A=it(E,1,"dropdown-item svelte-itm1qs",null,A,{focused:l(S)===l(r)}),Ie(E,"aria-selected",l(S)===l(r)),ne(U,l(R).path)}),G("click",E,()=>h(l(R))),xr("mouseenter",E,()=>{m(r,l(S),!0)}),N(O,E)}),N(g,y)};ie(p,g=>{l(o)&&g(b)})}he(()=>nb(_,l(i))),G("input",_,a),G("keydown",_,c),N(e,u),ft()}_t(["input","keydown","click"]);var lw=z('<span class="sidebar-label svelte-owj5vn">Workspaces</span>'),hw=z("<div><!></div>"),cw=z('<div class="empty-state svelte-owj5vn"><span>No workspaces</span></div>'),uw=z('<button class="done-reorder-btn svelte-owj5vn">Done reordering</button>'),dw=z('<button class="add-workspace-btn svelte-owj5vn" data-track="sidebar.add-workspace">+ Add Workspace</button>'),fw=z('<!> <div class="workspace-list svelte-owj5vn"><!> <!></div> <!> <div class="sidebar-footer-row svelte-owj5vn"><!> <button class="settings-icon-btn svelte-owj5vn" data-track="sidebar.settings" aria-label="Settings">⚙</button></div> <div class="resize-handle svelte-owj5vn"></div>',1),_w=z('<aside><div class="sidebar-header svelte-owj5vn"><button class="collapse-btn svelte-owj5vn"> </button> <!> <button class="icon-btn svelte-owj5vn" aria-label="Close sidebar">✕</button></div> <!></aside>');function vw(e,t){dt(t,!0);const i=mu(),r=yu();let s=me(()=>i.sidebarCollapsed?Ub:i.sidebarWidth);function n(D){i.activeWorkspacePath=D,r.activeSessionId=null}function o(D){i.activeWorkspacePath=D,ki()}function a(D){D.preventDefault();const I=D.clientX,H=i.sidebarWidth,k=Q=>{const Z=Math.min(dv,Math.max(uv,H+(Q.clientX-I)));i.sidebarWidth=Z},x=()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",x),document.body.style.cursor="",document.body.style.userSelect="",md()};document.addEventListener("mousemove",k),document.addEventListener("mouseup",x),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function c(D){D.preventDefault(),i.sidebarWidth=cv,md()}const h=200;let d=me(()=>r.workspaces.map(D=>({id:D.path,workspace:D}))),u=W(Xe([]));Ei(()=>{m(u,l(d),!0)});function f(D){m(u,D.detail.items,!0)}function _(D){m(u,D.detail.items,!0);const I=l(u).map(H=>H.id);hy(I)}function p(){Vb()}let b=null;function g(){b=setTimeout(()=>{Yb(),b=null},500)}function y(){b&&(clearTimeout(b),b=null)}function O(){b&&(clearTimeout(b),b=null)}var R=_w();let S,E;var A=w(R),P=w(A),B=w(P),U=T(P,2);{var $=D=>{var I=lw();N(D,I)};ie(U,D=>{i.sidebarCollapsed||D($)})}var q=T(U,2),F=T(A,2);{var L=D=>{var I=fw(),H=Ct(I);{var k=de=>{aw(de,{get workspaces(){return r.workspaces},onSelect:o})};ie(H,de=>{i.reorderMode||de(k)})}var x=T(H,2),Q=w(x);si(Q,17,()=>l(u),de=>de.id,(de,Me)=>{const Ne=me(()=>l(Me).workspace),je=me(()=>wv(l(Ne).path)),Pe=me(()=>new Set(l(je).map(Ke=>Ke.repoPath))),et=me(()=>r.worktrees.filter(Ke=>Ke.repoPath===l(Ne).path&&Ke.path.startsWith(l(Ne).path+"/")&&!l(Pe).has(Ke.path))),X=me(()=>(()=>{const Ke=new Map;Ke.set(l(Ne).path,[]);for(const Be of l(je)){const C=Ke.get(Be.repoPath);C?C.push(Be):Ke.set(Be.repoPath,[Be])}return Ke})());var ve=hw(),Fe=w(ve);{let Ke=me(()=>i.activeWorkspacePath===l(Ne).path&&!r.activeSessionId);tw(Fe,{get workspace(){return l(Ne)},get sessionGroups(){return l(X)},get inactiveWorktrees(){return l(et)},get isActive(){return l(Ke)},onSelectWorkspace:n,get onSelectSession(){return t.onSelectSession},get onNewWorktree(){return t.onNewWorktree},onOpenSettings:Be=>t.onOpenSettings(Be),onDeleteSession:Be=>{var C;return(C=t.onDeleteSession)==null?void 0:C.call(t,Be)},onDeleteWorktree:Be=>{var C;return(C=t.onDeleteWorktree)==null?void 0:C.call(t,Be)}})}N(de,ve)});var Z=T(Q,2);{var pe=de=>{var Me=cw();N(de,Me)};ie(Z,de=>{r.workspaces.length===0&&de(pe)})}Qm(x,(de,Me)=>nh==null?void 0:nh(de,Me),()=>({items:l(u),flipDurationMs:h,type:"workspaces",dropTargetStyle:{}}));var be=T(x,2);{var ce=de=>{var Me=uw();G("click",Me,p),N(de,Me)};ie(be,de=>{i.reorderMode&&de(ce)})}var se=T(be,2),De=w(se);{var Te=de=>{var Me=dw();G("click",Me,function(...Ne){var je;(je=t.onAddWorkspace)==null||je.apply(this,Ne)}),N(de,Me)};ie(De,de=>{i.reorderMode||de(Te)})}var _e=T(De,2),Se=T(se,2);xr("consider",x,f),xr("finalize",x,_),G("touchstart",x,g),G("touchend",x,y),G("touchmove",x,O),G("click",_e,()=>t.onOpenSettings()),G("mousedown",Se,a),G("dblclick",Se,c),N(D,I)};ie(F,D=>{i.sidebarCollapsed||D(L)})}he(()=>{S=it(R,1,"sidebar svelte-owj5vn",null,S,{open:i.sidebarOpen,collapsed:i.sidebarCollapsed}),E=_o(R,"",E,{width:`${l(s)??""}px`,"min-width":`${l(s)??""}px`}),Ie(P,"aria-label",i.sidebarCollapsed?"Expand sidebar":"Collapse sidebar"),ne(B,i.sidebarCollapsed?"»":"«")}),G("click",P,function(...D){th==null||th.apply(this,D)}),G("click",q,function(...D){ki==null||ki.apply(this,D)}),N(e,R),ft()}_t(["click","touchstart","touchend","touchmove","mousedown","dblclick"]);/**
16
16
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
17
17
  * @license MIT
18
18
  *
@@ -23,21 +23,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
23
23
  * Fabrice Bellard's javascript vt100 for jslinux:
24
24
  * http://bellard.org/jslinux/
25
25
  * Copyright (c) 2011 Fabrice Bellard
26
- */var np=Object.defineProperty,pw=Object.getOwnPropertyDescriptor,gw=(e,t)=>{for(var i in t)np(e,i,{get:t[i],enumerable:!0})},vt=(e,t,i,r)=>{for(var s=r>1?void 0:r?pw(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(s=(r?o(t,i,s):o(s))||s);return r&&s&&np(t,i,s),s},ue=(e,t)=>(i,r)=>t(i,r,e),Id="Terminal input",sc={get:()=>Id,set:e=>Id=e},Bd="Too much output to announce, navigate to rows manually to read",nc={get:()=>Bd,set:e=>Bd=e};function mw(e){return e.replace(/\r?\n/g,"\r")}function bw(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function yw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Sw(e,t,i,r){if(e.stopPropagation(),e.clipboardData){let s=e.clipboardData.getData("text/plain");op(s,t,i,r)}}function op(e,t,i,r){e=mw(e),e=bw(e,i.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function ap(e,t,i){let r=i.getBoundingClientRect(),s=e.clientX-r.left-10,n=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${s}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Nd(e,t,i,r,s){ap(e,t,i),s&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function os(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function zl(e,t=0,i=e.length){let r="";for(let s=t;s<i;++s){let n=e[s];n>65535?(n-=65536,r+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):r+=String.fromCharCode(n)}return r}var ww=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let r=0,s=0;if(this._interim){let n=e.charCodeAt(s++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let n=s;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,r;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[r++]=(o-55296)*1024+a-56320+65536:(t[r++]=o,t[r++]=a);continue}o!==65279&&(t[r++]=o)}return r}},Cw=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let r=0,s,n,o,a,c=0,h=0;if(this.interim[0]){let f=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,b;for(;(b=this.interim[++p]&63)&&p<4;)_<<=6,_|=b;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,S=g-p;for(;h<S;){if(h>=i)return 0;if(b=e[h++],(b&192)!==128){h--,f=!0;break}else this.interim[p++]=b,_<<=6,_|=b&63}f||(g===2?_<128?h--:t[r++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(t[r++]=_):_<65536||_>1114111||(t[r++]=_)),this.interim.fill(0)}let d=i-4,u=h;for(;u<i;){for(;u<d&&!((s=e[u])&128)&&!((n=e[u+1])&128)&&!((o=e[u+2])&128)&&!((a=e[u+3])&128);)t[r++]=s,t[r++]=n,t[r++]=o,t[r++]=a,u+=4;if(s=e[u++],s<128)t[r++]=s;else if((s&224)===192){if(u>=i)return this.interim[0]=s,r;if(n=e[u++],(n&192)!==128){u--;continue}if(c=(s&31)<<6|n&63,c<128){u--;continue}t[r++]=c}else if((s&240)===224){if(u>=i)return this.interim[0]=s,r;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(c=(s&15)<<12|(n&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((s&248)===240){if(u>=i)return this.interim[0]=s,r;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,this.interim[2]=o,r;if(a=e[u++],(a&192)!==128){u--;continue}if(c=(s&7)<<18|(n&63)<<12|(o&63)<<6|a&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},lp="",bs=" ",ga=class hp{constructor(){this.fg=0,this.bg=0,this.extended=new fl}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new hp;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},fl=class cp{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new cp(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ki=class up extends ga{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new fl,this.combinedData=""}static fromCharData(t){let i=new up;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?os(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=t[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Fd="di$target",oc="di$dependencies",oh=new Map;function kw(e){return e[oc]||[]}function Kt(e){if(oh.has(e))return oh.get(e);let t=function(i,r,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");xw(t,i,s)};return t._id=e,oh.set(e,t),t}function xw(e,t,i){t[Fd]===t?t[oc].push({id:e,index:i}):(t[oc]=[{id:e,index:i}],t[Fd]=t)}var li=Kt("BufferService"),dp=Kt("CoreMouseService"),wn=Kt("CoreService"),Ew=Kt("CharsetService"),Mu=Kt("InstantiationService"),fp=Kt("LogService"),hi=Kt("OptionsService"),_p=Kt("OscLinkService"),Dw=Kt("UnicodeService"),ma=Kt("DecorationService"),ac=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var d;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let r=[],s=this._optionsService.rawOptions.linkHandler,n=new Ki,o=i.getTrimmedLength(),a=-1,c=-1,h=!1;for(let u=0;u<o;u++)if(!(c===-1&&!i.hasContent(u))){if(i.loadCell(u,n),n.hasExtendedAttrs()&&n.extended.urlId)if(c===-1){c=u,a=n.extended.urlId;continue}else h=n.extended.urlId!==a;else c!==-1&&(h=!0);if(h||c!==-1&&u===o-1){let f=(d=this._oscLinkService.getLinkData(a))==null?void 0:d.uri;if(f){let _={start:{x:c+1,y:e},end:{x:u+(!h&&u===o-1?1:0),y:e}},p=!1;if(!(s!=null&&s.allowNonHttpProtocols))try{let b=new URL(f);["http:","https:"].includes(b.protocol)||(p=!0)}catch{p=!0}p||r.push({text:f,range:_,activate:(b,g)=>s?s.activate(b,g,_):Tw(b,g),hover:(b,g)=>{var S;return(S=s==null?void 0:s.hover)==null?void 0:S.call(s,b,g,_)},leave:(b,g)=>{var S;return(S=s==null?void 0:s.leave)==null?void 0:S.call(s,b,g,_)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(c=u,a=n.extended.urlId):(c=-1,a=-1)}}t(r)}};ac=vt([ue(0,li),ue(1,hi),ue(2,_p)],ac);function Tw(e,t){if(confirm(`Do you want to navigate to ${t}?
26
+ */var np=Object.defineProperty,pw=Object.getOwnPropertyDescriptor,gw=(e,t)=>{for(var i in t)np(e,i,{get:t[i],enumerable:!0})},vt=(e,t,i,r)=>{for(var s=r>1?void 0:r?pw(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(s=(r?o(t,i,s):o(s))||s);return r&&s&&np(t,i,s),s},ue=(e,t)=>(i,r)=>t(i,r,e),Id="Terminal input",sc={get:()=>Id,set:e=>Id=e},Bd="Too much output to announce, navigate to rows manually to read",nc={get:()=>Bd,set:e=>Bd=e};function mw(e){return e.replace(/\r?\n/g,"\r")}function bw(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function yw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Sw(e,t,i,r){if(e.stopPropagation(),e.clipboardData){let s=e.clipboardData.getData("text/plain");op(s,t,i,r)}}function op(e,t,i,r){e=mw(e),e=bw(e,i.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function ap(e,t,i){let r=i.getBoundingClientRect(),s=e.clientX-r.left-10,n=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${s}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Nd(e,t,i,r,s){ap(e,t,i),s&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function os(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function zl(e,t=0,i=e.length){let r="";for(let s=t;s<i;++s){let n=e[s];n>65535?(n-=65536,r+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):r+=String.fromCharCode(n)}return r}var ww=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let r=0,s=0;if(this._interim){let n=e.charCodeAt(s++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let n=s;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,r;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[r++]=(o-55296)*1024+a-56320+65536:(t[r++]=o,t[r++]=a);continue}o!==65279&&(t[r++]=o)}return r}},Cw=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let r=0,s,n,o,a,c=0,h=0;if(this.interim[0]){let f=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,b;for(;(b=this.interim[++p]&63)&&p<4;)_<<=6,_|=b;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=g-p;for(;h<y;){if(h>=i)return 0;if(b=e[h++],(b&192)!==128){h--,f=!0;break}else this.interim[p++]=b,_<<=6,_|=b&63}f||(g===2?_<128?h--:t[r++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(t[r++]=_):_<65536||_>1114111||(t[r++]=_)),this.interim.fill(0)}let d=i-4,u=h;for(;u<i;){for(;u<d&&!((s=e[u])&128)&&!((n=e[u+1])&128)&&!((o=e[u+2])&128)&&!((a=e[u+3])&128);)t[r++]=s,t[r++]=n,t[r++]=o,t[r++]=a,u+=4;if(s=e[u++],s<128)t[r++]=s;else if((s&224)===192){if(u>=i)return this.interim[0]=s,r;if(n=e[u++],(n&192)!==128){u--;continue}if(c=(s&31)<<6|n&63,c<128){u--;continue}t[r++]=c}else if((s&240)===224){if(u>=i)return this.interim[0]=s,r;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(c=(s&15)<<12|(n&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((s&248)===240){if(u>=i)return this.interim[0]=s,r;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,this.interim[2]=o,r;if(a=e[u++],(a&192)!==128){u--;continue}if(c=(s&7)<<18|(n&63)<<12|(o&63)<<6|a&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},lp="",bs=" ",ga=class hp{constructor(){this.fg=0,this.bg=0,this.extended=new fl}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new hp;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},fl=class cp{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new cp(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ki=class up extends ga{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new fl,this.combinedData=""}static fromCharData(t){let i=new up;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?os(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=t[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Fd="di$target",oc="di$dependencies",oh=new Map;function kw(e){return e[oc]||[]}function Kt(e){if(oh.has(e))return oh.get(e);let t=function(i,r,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");xw(t,i,s)};return t._id=e,oh.set(e,t),t}function xw(e,t,i){t[Fd]===t?t[oc].push({id:e,index:i}):(t[oc]=[{id:e,index:i}],t[Fd]=t)}var li=Kt("BufferService"),dp=Kt("CoreMouseService"),wn=Kt("CoreService"),Ew=Kt("CharsetService"),Mu=Kt("InstantiationService"),fp=Kt("LogService"),hi=Kt("OptionsService"),_p=Kt("OscLinkService"),Dw=Kt("UnicodeService"),ma=Kt("DecorationService"),ac=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var d;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let r=[],s=this._optionsService.rawOptions.linkHandler,n=new Ki,o=i.getTrimmedLength(),a=-1,c=-1,h=!1;for(let u=0;u<o;u++)if(!(c===-1&&!i.hasContent(u))){if(i.loadCell(u,n),n.hasExtendedAttrs()&&n.extended.urlId)if(c===-1){c=u,a=n.extended.urlId;continue}else h=n.extended.urlId!==a;else c!==-1&&(h=!0);if(h||c!==-1&&u===o-1){let f=(d=this._oscLinkService.getLinkData(a))==null?void 0:d.uri;if(f){let _={start:{x:c+1,y:e},end:{x:u+(!h&&u===o-1?1:0),y:e}},p=!1;if(!(s!=null&&s.allowNonHttpProtocols))try{let b=new URL(f);["http:","https:"].includes(b.protocol)||(p=!0)}catch{p=!0}p||r.push({text:f,range:_,activate:(b,g)=>s?s.activate(b,g,_):Tw(b,g),hover:(b,g)=>{var y;return(y=s==null?void 0:s.hover)==null?void 0:y.call(s,b,g,_)},leave:(b,g)=>{var y;return(y=s==null?void 0:s.leave)==null?void 0:y.call(s,b,g,_)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(c=u,a=n.extended.urlId):(c=-1,a=-1)}}t(r)}};ac=vt([ue(0,li),ue(1,hi),ue(2,_p)],ac);function Tw(e,t){if(confirm(`Do you want to navigate to ${t}?
27
27
 
28
28
  WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Ul=Kt("CharSizeService"),Zr=Kt("CoreBrowserService"),Ou=Kt("MouseService"),Jr=Kt("RenderService"),Rw=Kt("SelectionService"),vp=Kt("CharacterJoinerService"),po=Kt("ThemeService"),pp=Kt("LinkProviderService"),Pw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Wd.isErrorNoTelemetry(e)?new Wd(e.message+`
29
29
 
30
30
  `+e.stack):new Error(e.message+`
31
31
 
32
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Aw=new Pw;function Ya(e){Mw(e)||Aw.onUnexpectedError(e)}var lc="Canceled";function Mw(e){return e instanceof Ow?!0:e instanceof Error&&e.name===lc&&e.message===lc}var Ow=class extends Error{constructor(){super(lc),this.name=this.message}};function Lw(e){return new Error(`Illegal argument: ${e}`)}var Wd=class hc extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof hc)return t;let i=new hc;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},cc=class gp extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,gp.prototype)}};function bi(e,t=0){return e[e.length-(1+t)]}var Iw;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function r(n){return n>0}e.isGreaterThan=r;function s(n){return n===0}e.isNeitherLessOrGreaterThan=s,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Iw||(Iw={}));function Bw(e,t){let i=this,r=!1,s;return function(){return r||(r=!0,t||(s=e.apply(i,arguments))),s}}var mp;(e=>{function t(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function r(){return i}e.empty=r;function*s(y){yield y}e.single=s;function n(y){return t(y)?y:s(y)}e.wrap=n;function o(y){return y||i}e.from=o;function*a(y){for(let x=y.length-1;x>=0;x--)yield y[x]}e.reverse=a;function c(y){return!y||y[Symbol.iterator]().next().done===!0}e.isEmpty=c;function h(y){return y[Symbol.iterator]().next().value}e.first=h;function d(y,x){let P=0;for(let I of y)if(x(I,P++))return!0;return!1}e.some=d;function u(y,x){for(let P of y)if(x(P))return P}e.find=u;function*f(y,x){for(let P of y)x(P)&&(yield P)}e.filter=f;function*_(y,x){let P=0;for(let I of y)yield x(I,P++)}e.map=_;function*p(y,x){let P=0;for(let I of y)yield*x(I,P++)}e.flatMap=p;function*b(...y){for(let x of y)yield*x}e.concat=b;function g(y,x,P){let I=P;for(let z of y)I=x(I,z);return I}e.reduce=g;function*S(y,x,P=y.length){for(x<0&&(x+=y.length),P<0?P+=y.length:P>y.length&&(P=y.length);x<P;x++)yield y[x]}e.slice=S;function O(y,x=Number.POSITIVE_INFINITY){let P=[];if(x===0)return[P,y];let I=y[Symbol.iterator]();for(let z=0;z<x;z++){let q=I.next();if(q.done)return[P,e.empty()];P.push(q.value)}return[P,{[Symbol.iterator](){return I}}]}e.consume=O;async function C(y){let x=[];for await(let P of y)x.push(P);return Promise.resolve(x)}e.asyncToArray=C})(mp||(mp={}));function bn(e){if(mp.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Nw(...e){return nt(()=>bn(e))}function nt(e){return{dispose:Bw(()=>{e()})}}var bp=class yp{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{bn(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?yp.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};bp.DISABLE_DISPOSED_WARNING=!1;var xs=bp,He=class{constructor(){this._store=new xs,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};He.None=Object.freeze({dispose(){}});var ho=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Kr=typeof window=="object"?window:globalThis,uc=class dc{constructor(t){this.element=t,this.next=dc.Undefined,this.prev=dc.Undefined}};uc.Undefined=new uc(void 0);var at=uc,Hd=class{constructor(){this._first=at.Undefined,this._last=at.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===at.Undefined}clear(){let e=this._first;for(;e!==at.Undefined;){let t=e.next;e.prev=at.Undefined,e.next=at.Undefined,e=t}this._first=at.Undefined,this._last=at.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new at(e);if(this._first===at.Undefined)this._first=i,this._last=i;else if(t){let s=this._last;this._last=i,i.prev=s,s.next=i}else{let s=this._first;this._first=i,i.next=s,s.prev=i}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(i))}}shift(){if(this._first!==at.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==at.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==at.Undefined&&e.next!==at.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===at.Undefined&&e.next===at.Undefined?(this._first=at.Undefined,this._last=at.Undefined):e.next===at.Undefined?(this._last=this._last.prev,this._last.next=at.Undefined):e.prev===at.Undefined&&(this._first=this._first.next,this._first.prev=at.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==at.Undefined;)yield e.element,e=e.next}},Fw=globalThis.performance&&typeof globalThis.performance.now=="function",Ww=class Sp{static create(t){return new Sp(t)}constructor(t){this._now=Fw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Qt;(e=>{e.None=()=>He.None;function t(N,A){return u(N,()=>{},0,void 0,!0,void 0,A)}e.defer=t;function i(N){return(A,T=null,L)=>{let H=!1,D;return D=N(E=>{if(!H)return D?D.dispose():H=!0,A.call(T,E)},null,L),H&&D.dispose(),D}}e.once=i;function r(N,A,T){return h((L,H=null,D)=>N(E=>L.call(H,A(E)),null,D),T)}e.map=r;function s(N,A,T){return h((L,H=null,D)=>N(E=>{A(E),L.call(H,E)},null,D),T)}e.forEach=s;function n(N,A,T){return h((L,H=null,D)=>N(E=>A(E)&&L.call(H,E),null,D),T)}e.filter=n;function o(N){return N}e.signal=o;function a(...N){return(A,T=null,L)=>{let H=Nw(...N.map(D=>D(E=>A.call(T,E))));return d(H,L)}}e.any=a;function c(N,A,T,L){let H=T;return r(N,D=>(H=A(H,D),H),L)}e.reduce=c;function h(N,A){let T,L={onWillAddFirstListener(){T=N(H.fire,H)},onDidRemoveLastListener(){T==null||T.dispose()}},H=new te(L);return A==null||A.add(H),H.event}function d(N,A){return A instanceof Array?A.push(N):A&&A.add(N),N}function u(N,A,T=100,L=!1,H=!1,D,E){let $,Q,pe,be=0,ce,se={leakWarningThreshold:D,onWillAddFirstListener(){$=N(Te=>{be++,Q=A(Q,Te),L&&!pe&&(De.fire(Q),Q=void 0),ce=()=>{let _e=Q;Q=void 0,pe=void 0,(!L||be>1)&&De.fire(_e),be=0},typeof T=="number"?(clearTimeout(pe),pe=setTimeout(ce,T)):pe===void 0&&(pe=0,queueMicrotask(ce))})},onWillRemoveListener(){H&&be>0&&(ce==null||ce())},onDidRemoveLastListener(){ce=void 0,$.dispose()}},De=new te(se);return E==null||E.add(De),De.event}e.debounce=u;function f(N,A=0,T){return e.debounce(N,(L,H)=>L?(L.push(H),L):[H],A,void 0,!0,void 0,T)}e.accumulate=f;function _(N,A=(L,H)=>L===H,T){let L=!0,H;return n(N,D=>{let E=L||!A(D,H);return L=!1,H=D,E},T)}e.latch=_;function p(N,A,T){return[e.filter(N,A,T),e.filter(N,L=>!A(L),T)]}e.split=p;function b(N,A=!1,T=[],L){let H=T.slice(),D=N(Q=>{H?H.push(Q):$.fire(Q)});L&&L.add(D);let E=()=>{H==null||H.forEach(Q=>$.fire(Q)),H=null},$=new te({onWillAddFirstListener(){D||(D=N(Q=>$.fire(Q)),L&&L.add(D))},onDidAddFirstListener(){H&&(A?setTimeout(E):E())},onDidRemoveLastListener(){D&&D.dispose(),D=null}});return L&&L.add($),$.event}e.buffer=b;function g(N,A){return(T,L,H)=>{let D=A(new O);return N(function(E){let $=D.evaluate(E);$!==S&&T.call(L,$)},void 0,H)}}e.chain=g;let S=Symbol("HaltChainable");class O{constructor(){this.steps=[]}map(A){return this.steps.push(A),this}forEach(A){return this.steps.push(T=>(A(T),T)),this}filter(A){return this.steps.push(T=>A(T)?T:S),this}reduce(A,T){let L=T;return this.steps.push(H=>(L=A(L,H),L)),this}latch(A=(T,L)=>T===L){let T=!0,L;return this.steps.push(H=>{let D=T||!A(H,L);return T=!1,L=H,D?H:S}),this}evaluate(A){for(let T of this.steps)if(A=T(A),A===S)break;return A}}function C(N,A,T=L=>L){let L=(...$)=>E.fire(T(...$)),H=()=>N.on(A,L),D=()=>N.removeListener(A,L),E=new te({onWillAddFirstListener:H,onDidRemoveLastListener:D});return E.event}e.fromNodeEventEmitter=C;function y(N,A,T=L=>L){let L=(...$)=>E.fire(T(...$)),H=()=>N.addEventListener(A,L),D=()=>N.removeEventListener(A,L),E=new te({onWillAddFirstListener:H,onDidRemoveLastListener:D});return E.event}e.fromDOMEventEmitter=y;function x(N){return new Promise(A=>i(N)(A))}e.toPromise=x;function P(N){let A=new te;return N.then(T=>{A.fire(T)},()=>{A.fire(void 0)}).finally(()=>{A.dispose()}),A.event}e.fromPromise=P;function I(N,A){return N(T=>A.fire(T))}e.forward=I;function z(N,A,T){return A(T),N(L=>A(L))}e.runAndSubscribe=z;class q{constructor(A,T){this._observable=A,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{A.addObserver(this)},onDidRemoveLastListener:()=>{A.removeObserver(this)}};this.emitter=new te(L),T&&T.add(this.emitter)}beginUpdate(A){this._counter++}handlePossibleChange(A){}handleChange(A,T){this._hasChanged=!0}endUpdate(A){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function J(N,A){return new q(N,A).emitter.event}e.fromObservable=J;function K(N){return(A,T,L)=>{let H=0,D=!1,E={beginUpdate(){H++},endUpdate(){H--,H===0&&(N.reportChanges(),D&&(D=!1,A.call(T)))},handlePossibleChange(){},handleChange(){D=!0}};N.addObserver(E),N.reportChanges();let $={dispose(){N.removeObserver(E)}};return L instanceof xs?L.add($):Array.isArray(L)&&L.push($),$}}e.fromObservableLight=K})(Qt||(Qt={}));var fc=class _c{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${_c._idPool++}`,_c.all.add(this)}start(t){this._stopWatch=new Ww,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};fc.all=new Set,fc._idPool=0;var Hw=fc,zw=-1,wp=class Cp{constructor(t,i,r=(Cp._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let r=this.threshold;if(r<=0||i<r)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let c=new qw(a,n);this._errorHandler(c)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[r,s]of this._stacks)(!t||i<s)&&(t=[r,s],i=s);return t}};wp._idPool=1;var Uw=wp,Kw=class kp{constructor(t){this.value=t}static create(){let t=new Error;return new kp(t.stack??"")}print(){console.warn(this.value.split(`
32
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Aw=new Pw;function Ya(e){Mw(e)||Aw.onUnexpectedError(e)}var lc="Canceled";function Mw(e){return e instanceof Ow?!0:e instanceof Error&&e.name===lc&&e.message===lc}var Ow=class extends Error{constructor(){super(lc),this.name=this.message}};function Lw(e){return new Error(`Illegal argument: ${e}`)}var Wd=class hc extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof hc)return t;let i=new hc;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},cc=class gp extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,gp.prototype)}};function bi(e,t=0){return e[e.length-(1+t)]}var Iw;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function r(n){return n>0}e.isGreaterThan=r;function s(n){return n===0}e.isNeitherLessOrGreaterThan=s,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Iw||(Iw={}));function Bw(e,t){let i=this,r=!1,s;return function(){return r||(r=!0,t||(s=e.apply(i,arguments))),s}}var mp;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function r(){return i}e.empty=r;function*s(S){yield S}e.single=s;function n(S){return t(S)?S:s(S)}e.wrap=n;function o(S){return S||i}e.from=o;function*a(S){for(let E=S.length-1;E>=0;E--)yield S[E]}e.reverse=a;function c(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=c;function h(S){return S[Symbol.iterator]().next().value}e.first=h;function d(S,E){let A=0;for(let P of S)if(E(P,A++))return!0;return!1}e.some=d;function u(S,E){for(let A of S)if(E(A))return A}e.find=u;function*f(S,E){for(let A of S)E(A)&&(yield A)}e.filter=f;function*_(S,E){let A=0;for(let P of S)yield E(P,A++)}e.map=_;function*p(S,E){let A=0;for(let P of S)yield*E(P,A++)}e.flatMap=p;function*b(...S){for(let E of S)yield*E}e.concat=b;function g(S,E,A){let P=A;for(let B of S)P=E(P,B);return P}e.reduce=g;function*y(S,E,A=S.length){for(E<0&&(E+=S.length),A<0?A+=S.length:A>S.length&&(A=S.length);E<A;E++)yield S[E]}e.slice=y;function O(S,E=Number.POSITIVE_INFINITY){let A=[];if(E===0)return[A,S];let P=S[Symbol.iterator]();for(let B=0;B<E;B++){let U=P.next();if(U.done)return[A,e.empty()];A.push(U.value)}return[A,{[Symbol.iterator](){return P}}]}e.consume=O;async function R(S){let E=[];for await(let A of S)E.push(A);return Promise.resolve(E)}e.asyncToArray=R})(mp||(mp={}));function bn(e){if(mp.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Nw(...e){return nt(()=>bn(e))}function nt(e){return{dispose:Bw(()=>{e()})}}var bp=class yp{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{bn(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?yp.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};bp.DISABLE_DISPOSED_WARNING=!1;var xs=bp,He=class{constructor(){this._store=new xs,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};He.None=Object.freeze({dispose(){}});var ho=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Kr=typeof window=="object"?window:globalThis,uc=class dc{constructor(t){this.element=t,this.next=dc.Undefined,this.prev=dc.Undefined}};uc.Undefined=new uc(void 0);var at=uc,Hd=class{constructor(){this._first=at.Undefined,this._last=at.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===at.Undefined}clear(){let e=this._first;for(;e!==at.Undefined;){let t=e.next;e.prev=at.Undefined,e.next=at.Undefined,e=t}this._first=at.Undefined,this._last=at.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new at(e);if(this._first===at.Undefined)this._first=i,this._last=i;else if(t){let s=this._last;this._last=i,i.prev=s,s.next=i}else{let s=this._first;this._first=i,i.next=s,s.prev=i}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(i))}}shift(){if(this._first!==at.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==at.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==at.Undefined&&e.next!==at.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===at.Undefined&&e.next===at.Undefined?(this._first=at.Undefined,this._last=at.Undefined):e.next===at.Undefined?(this._last=this._last.prev,this._last.next=at.Undefined):e.prev===at.Undefined&&(this._first=this._first.next,this._first.prev=at.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==at.Undefined;)yield e.element,e=e.next}},Fw=globalThis.performance&&typeof globalThis.performance.now=="function",Ww=class Sp{static create(t){return new Sp(t)}constructor(t){this._now=Fw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Qt;(e=>{e.None=()=>He.None;function t(F,L){return u(F,()=>{},0,void 0,!0,void 0,L)}e.defer=t;function i(F){return(L,D=null,I)=>{let H=!1,k;return k=F(x=>{if(!H)return k?k.dispose():H=!0,L.call(D,x)},null,I),H&&k.dispose(),k}}e.once=i;function r(F,L,D){return h((I,H=null,k)=>F(x=>I.call(H,L(x)),null,k),D)}e.map=r;function s(F,L,D){return h((I,H=null,k)=>F(x=>{L(x),I.call(H,x)},null,k),D)}e.forEach=s;function n(F,L,D){return h((I,H=null,k)=>F(x=>L(x)&&I.call(H,x),null,k),D)}e.filter=n;function o(F){return F}e.signal=o;function a(...F){return(L,D=null,I)=>{let H=Nw(...F.map(k=>k(x=>L.call(D,x))));return d(H,I)}}e.any=a;function c(F,L,D,I){let H=D;return r(F,k=>(H=L(H,k),H),I)}e.reduce=c;function h(F,L){let D,I={onWillAddFirstListener(){D=F(H.fire,H)},onDidRemoveLastListener(){D==null||D.dispose()}},H=new te(I);return L==null||L.add(H),H.event}function d(F,L){return L instanceof Array?L.push(F):L&&L.add(F),F}function u(F,L,D=100,I=!1,H=!1,k,x){let Q,Z,pe,be=0,ce,se={leakWarningThreshold:k,onWillAddFirstListener(){Q=F(Te=>{be++,Z=L(Z,Te),I&&!pe&&(De.fire(Z),Z=void 0),ce=()=>{let _e=Z;Z=void 0,pe=void 0,(!I||be>1)&&De.fire(_e),be=0},typeof D=="number"?(clearTimeout(pe),pe=setTimeout(ce,D)):pe===void 0&&(pe=0,queueMicrotask(ce))})},onWillRemoveListener(){H&&be>0&&(ce==null||ce())},onDidRemoveLastListener(){ce=void 0,Q.dispose()}},De=new te(se);return x==null||x.add(De),De.event}e.debounce=u;function f(F,L=0,D){return e.debounce(F,(I,H)=>I?(I.push(H),I):[H],L,void 0,!0,void 0,D)}e.accumulate=f;function _(F,L=(I,H)=>I===H,D){let I=!0,H;return n(F,k=>{let x=I||!L(k,H);return I=!1,H=k,x},D)}e.latch=_;function p(F,L,D){return[e.filter(F,L,D),e.filter(F,I=>!L(I),D)]}e.split=p;function b(F,L=!1,D=[],I){let H=D.slice(),k=F(Z=>{H?H.push(Z):Q.fire(Z)});I&&I.add(k);let x=()=>{H==null||H.forEach(Z=>Q.fire(Z)),H=null},Q=new te({onWillAddFirstListener(){k||(k=F(Z=>Q.fire(Z)),I&&I.add(k))},onDidAddFirstListener(){H&&(L?setTimeout(x):x())},onDidRemoveLastListener(){k&&k.dispose(),k=null}});return I&&I.add(Q),Q.event}e.buffer=b;function g(F,L){return(D,I,H)=>{let k=L(new O);return F(function(x){let Q=k.evaluate(x);Q!==y&&D.call(I,Q)},void 0,H)}}e.chain=g;let y=Symbol("HaltChainable");class O{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(D=>(L(D),D)),this}filter(L){return this.steps.push(D=>L(D)?D:y),this}reduce(L,D){let I=D;return this.steps.push(H=>(I=L(I,H),I)),this}latch(L=(D,I)=>D===I){let D=!0,I;return this.steps.push(H=>{let k=D||!L(H,I);return D=!1,I=H,k?H:y}),this}evaluate(L){for(let D of this.steps)if(L=D(L),L===y)break;return L}}function R(F,L,D=I=>I){let I=(...Q)=>x.fire(D(...Q)),H=()=>F.on(L,I),k=()=>F.removeListener(L,I),x=new te({onWillAddFirstListener:H,onDidRemoveLastListener:k});return x.event}e.fromNodeEventEmitter=R;function S(F,L,D=I=>I){let I=(...Q)=>x.fire(D(...Q)),H=()=>F.addEventListener(L,I),k=()=>F.removeEventListener(L,I),x=new te({onWillAddFirstListener:H,onDidRemoveLastListener:k});return x.event}e.fromDOMEventEmitter=S;function E(F){return new Promise(L=>i(F)(L))}e.toPromise=E;function A(F){let L=new te;return F.then(D=>{L.fire(D)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}e.fromPromise=A;function P(F,L){return F(D=>L.fire(D))}e.forward=P;function B(F,L,D){return L(D),F(I=>L(I))}e.runAndSubscribe=B;class U{constructor(L,D){this._observable=L,this._counter=0,this._hasChanged=!1;let I={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new te(I),D&&D.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,D){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function $(F,L){return new U(F,L).emitter.event}e.fromObservable=$;function q(F){return(L,D,I)=>{let H=0,k=!1,x={beginUpdate(){H++},endUpdate(){H--,H===0&&(F.reportChanges(),k&&(k=!1,L.call(D)))},handlePossibleChange(){},handleChange(){k=!0}};F.addObserver(x),F.reportChanges();let Q={dispose(){F.removeObserver(x)}};return I instanceof xs?I.add(Q):Array.isArray(I)&&I.push(Q),Q}}e.fromObservableLight=q})(Qt||(Qt={}));var fc=class _c{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${_c._idPool++}`,_c.all.add(this)}start(t){this._stopWatch=new Ww,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};fc.all=new Set,fc._idPool=0;var Hw=fc,zw=-1,wp=class Cp{constructor(t,i,r=(Cp._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let r=this.threshold;if(r<=0||i<r)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let c=new qw(a,n);this._errorHandler(c)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[r,s]of this._stacks)(!t||i<s)&&(t=[r,s],i=s);return t}};wp._idPool=1;var Uw=wp,Kw=class kp{constructor(t){this.value=t}static create(){let t=new Error;return new kp(t.stack??"")}print(){console.warn(this.value.split(`
33
33
  `).slice(2).join(`
34
- `))}},qw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},jw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Yw=0,ah=class{constructor(e){this.value=e,this.id=Yw++}},Vw=2,Gw,te=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Uw((e==null?void 0:e.onListenerError)??Ya,((i=this._options)==null?void 0:i.leakWarningThreshold)??zw):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Hw(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var e,t,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=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,a,c,h,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],_=new jw(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Ya)(_),He.None}if(this._disposed)return He.None;t&&(e=e.bind(t));let r=new ah(e),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Kw.create(),s=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof ah?(this._deliveryQueue??(this._deliveryQueue=new Xw),this._listeners=[this._listeners,r]):this._listeners.push(r):((c=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||c.call(a,this),this._listeners=r,(d=(h=this._options)==null?void 0:h.onDidAddFirstListener)==null||d.call(h,this)),this._size++;let n=nt(()=>{s==null||s(),this._removeListener(r)});return i instanceof xs?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var s,n,o,a;if((n=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||n.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.call(o,this),this._size=0;return}let t=this._listeners,i=t.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--,t[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Vw<=t.length){let c=0;for(let h=0;h<t.length;h++)t[h]?t[c++]=t[h]:r&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=c}}_deliver(e,t){var r;if(!e)return;let i=((r=this._options)==null?void 0:r.onListenerError)||Ya;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((t=this._deliveryQueue)!=null&&t.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 ah)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},Xw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},vc=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};vc.INSTANCE=new vc;var Lu=vc;function $w(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Lu.INSTANCE.onDidChangeZoomLevel;function Qw(e){return Lu.INSTANCE.getZoomFactor(e)}Lu.INSTANCE.onDidChangeFullscreen;var go=typeof navigator=="object"?navigator.userAgent:"",pc=go.indexOf("Firefox")>=0,Zw=go.indexOf("AppleWebKit")>=0,Iu=go.indexOf("Chrome")>=0,Jw=!Iu&&go.indexOf("Safari")>=0;go.indexOf("Electron/")>=0;go.indexOf("Android")>=0;var lh=!1;if(typeof Kr.matchMedia=="function"){let e=Kr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Kr.matchMedia("(display-mode: fullscreen)");lh=e.matches,$w(Kr,e,({matches:i})=>{lh&&t.matches||(lh=i)})}var An="en",gc=!1,mc=!1,Va=!1,xp=!1,Ra,Ga=An,zd=An,e0,Xi,fn=globalThis,Gt,qf;typeof fn.vscode<"u"&&typeof fn.vscode.process<"u"?Gt=fn.vscode.process:typeof process<"u"&&typeof((qf=process==null?void 0:process.versions)==null?void 0:qf.node)=="string"&&(Gt=process);var jf,t0=typeof((jf=Gt==null?void 0:Gt.versions)==null?void 0:jf.electron)=="string",i0=t0&&(Gt==null?void 0:Gt.type)==="renderer",Yf;if(typeof Gt=="object"){gc=Gt.platform==="win32",mc=Gt.platform==="darwin",Va=Gt.platform==="linux",Va&&Gt.env.SNAP&&Gt.env.SNAP_REVISION,Gt.env.CI||Gt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ra=An,Ga=An;let e=Gt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ra=t.userLocale,zd=t.osLocale,Ga=t.resolvedLanguage||An,e0=(Yf=t.languagePack)==null?void 0:Yf.translationsConfigFile}catch{}xp=!0}else typeof navigator=="object"&&!i0?(Xi=navigator.userAgent,gc=Xi.indexOf("Windows")>=0,mc=Xi.indexOf("Macintosh")>=0,(Xi.indexOf("Macintosh")>=0||Xi.indexOf("iPad")>=0||Xi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Va=Xi.indexOf("Linux")>=0,(Xi==null?void 0:Xi.indexOf("Mobi"))>=0,Ga=globalThis._VSCODE_NLS_LANGUAGE||An,Ra=navigator.language.toLowerCase(),zd=Ra):console.error("Unable to resolve platform.");var Ep=gc,Tr=mc,r0=Va,Ud=xp,Mr=Xi,ts=Ga,s0;(e=>{function t(){return ts}e.value=t;function i(){return ts.length===2?ts==="en":ts.length>=3?ts[0]==="e"&&ts[1]==="n"&&ts[2]==="-":!1}e.isDefaultVariant=i;function r(){return ts==="en"}e.isDefault=r})(s0||(s0={}));var n0=typeof fn.postMessage=="function"&&!fn.importScripts;(()=>{if(n0){let e=[];fn.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,s=e.length;r<s;r++){let n=e[r];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(r,1),n.callback();return}}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),fn.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var o0=!!(Mr&&Mr.indexOf("Chrome")>=0);Mr&&Mr.indexOf("Firefox")>=0;!o0&&Mr&&Mr.indexOf("Safari")>=0;Mr&&Mr.indexOf("Edg/")>=0;Mr&&Mr.indexOf("Android")>=0;var En=typeof navigator=="object"?navigator:{};Ud||document.queryCommandSupported&&document.queryCommandSupported("copy")||En&&En.clipboard&&En.clipboard.writeText,Ud||En&&En.clipboard&&En.clipboard.readText;var Bu=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},hh=new Bu,Kd=new Bu,qd=new Bu,a0=new Array(230),Dp;(e=>{function t(a){return hh.keyCodeToStr(a)}e.toString=t;function i(a){return hh.strToKeyCode(a)}e.fromString=i;function r(a){return Kd.keyCodeToStr(a)}e.toUserSettingsUS=r;function s(a){return qd.keyCodeToStr(a)}e.toUserSettingsGeneral=s;function n(a){return Kd.strToKeyCode(a)||qd.strToKeyCode(a)}e.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 hh.keyCodeToStr(a)}e.toElectronAccelerator=o})(Dp||(Dp={}));var l0=class Tp{constructor(t,i,r,s,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=r,this.metaKey=s,this.keyCode=n}equals(t){return t instanceof Tp&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",r=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${t}${i}${r}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new h0([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},h0=class{constructor(e){if(e.length===0)throw Lw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function c0(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Dp.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(pc)switch(t){case 59:return 85;case 60:if(r0)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Tr)return 57;break}else if(Zw&&(Tr&&t===93||!Tr&&t===92))return 57;return a0[t]||0}var u0=Tr?256:2048,d0=512,f0=1024,_0=Tr?2048:256,jd=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=c0(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=u0),this.altKey&&(t|=d0),this.shiftKey&&(t|=f0),this.metaKey&&(t|=_0),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new l0(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Yd=new WeakMap;function v0(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var p0=class{static getSameOriginWindowChain(e){let t=Yd.get(e);if(!t){t=[],Yd.set(e,t);let i=e,r;do r=v0(i),r?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=r;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,r=0,s=this.getSameOriginWindowChain(e);for(let n of s){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,r+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,r+=a.left}return{top:i,left:r}}},Pa=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=p0.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Vd=class{constructor(e,t=0,i=0){var s;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let r=!1;if(Iu){let n=navigator.userAgent.match(/Chrome\/(\d+)/);r=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((s=e.view)==null?void 0:s.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")r?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(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?pc&&!Tr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Jw&&Ep?this.deltaX=-(n.wheelDeltaX/120):r?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=-e.detail/3;else if(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?pc&&!Tr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Rp=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),g0;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof m0?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Qt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Rp})})(g0||(g0={}));var m0=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?Rp:(this._emitter||(this._emitter=new te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Nu=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new cc("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new cc("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},b0=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new cc("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=i.setInterval(()=>{e()},t);this.disposable=nt(()=>{i.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},y0;(e=>{async function t(r){let s,n=await Promise.all(r.map(o=>o.then(a=>a,a=>{s||(s=a)})));if(typeof s<"u")throw s;return n}e.settled=t;function i(r){return new Promise(async(s,n)=>{try{await r(s,n)}catch(o){n(o)}})}e.withAsyncBody=i})(y0||(y0={}));var Gd=class Pi{static fromArray(t){return new Pi(i=>{i.emitMany(t)})}static fromPromise(t){return new Pi(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Pi(async i=>{await Promise.all(t.map(async r=>i.emitOne(await r)))})}static merge(t){return new Pi(async i=>{await Promise.all(t.map(async r=>{for await(let s of r)i.emitOne(s)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new te,queueMicrotask(async()=>{let r={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(t(r)),this.resolve()}catch(s){this.reject(s)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Qt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Pi(async r=>{for await(let s of t)r.emitOne(i(s))})}map(t){return Pi.map(this,t)}static filter(t,i){return new Pi(async r=>{for await(let s of t)i(s)&&r.emitOne(s)})}filter(t){return Pi.filter(this,t)}static coalesce(t){return Pi.filter(t,i=>!!i)}coalesce(){return Pi.coalesce(this)}static async toPromise(t){let i=[];for await(let r of t)i.push(r);return i}toPromise(){return Pi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Gd.EMPTY=Gd.fromArray([]);var{getWindow:Er,getWindowId:S0,onDidRegisterWindow:w0}=(function(){let e=new Map,t={window:Kr,disposables:new xs};e.set(Kr.vscodeWindowId,t);let i=new te,r=new te,s=new te;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(o){if(e.has(o.vscodeWindowId))return He.None;let a=new xs,c={window:o,disposables:a.add(new xs)};return e.set(o.vscodeWindowId,c),a.add(nt(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),a.add(Ae(o,Ft.BEFORE_UNLOAD,()=>{s.fire(o)})),i.fire(c),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.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 c=o;return c!=null&&c.view?c.view.window:Kr},getDocument(o){return Er(o).document}}})(),C0=class{constructor(e,t,i,r){this._node=e,this._type=t,this._handler=i,this._options=r||!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 Ae(e,t,i,r){return new C0(e,t,i,r)}var Xd=function(e,t,i,r){return Ae(e,t,i,r)},Fu,k0=class extends b0{constructor(e){super(),this.defaultTarget=e&&Er(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},$d=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ya(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,r=new Map,s=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),r.set(n,!0);o.length>0;)o.sort($d.sort),o.shift().execute();r.set(n,!1)};Fu=(n,o,a=0)=>{let c=S0(n),h=new $d(o,a),d=e.get(c);return d||(d=[],e.set(c,d)),d.push(h),i.get(c)||(i.set(c,!0),n.requestAnimationFrame(()=>s(c))),h}})();function x0(e){let t=e.getBoundingClientRect(),i=Er(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Ft={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"},E0=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ci(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ci(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ci(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ci(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ci(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ci(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ci(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ci(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ci(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ci(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ci(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ci(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ci(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ci(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ci(e){return typeof e=="number"?`${e}px`:e}function Ko(e){return new E0(e)}var Pp=class{constructor(){this._hooks=new xs,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,r,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=s;let n=e;try{e.setPointerCapture(t),this._hooks.add(nt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=Er(e)}this._hooks.add(Ae(n,Ft.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ae(n,Ft.POINTER_UP,o=>this.stopMonitoring(!0)))}};function D0(e,t,i){let r=null,s=null;if(typeof i.value=="function"?(r="value",s=i.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(r="get",s=i.get),!s)throw new Error("not supported");let n=`$memoize$${t}`;i[r]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,o)}),this[n]}}var _r;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(_r||(_r={}));var Ro=class ei extends He{constructor(){super(),this.dispatched=!1,this.targets=new Hd,this.ignoreTargets=new Hd,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Qt.runAndSubscribe(w0,({window:t,disposables:i})=>{i.add(Ae(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),i.add(Ae(t.document,"touchend",r=>this.onTouchEnd(t,r))),i.add(Ae(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Kr,disposables:this._store}))}static addTarget(t){if(!ei.isTouchDevice())return He.None;ei.INSTANCE||(ei.INSTANCE=new ei);let i=ei.INSTANCE.targets.push(t);return nt(i)}static ignoreTarget(t){if(!ei.isTouchDevice())return He.None;ei.INSTANCE||(ei.INSTANCE=new ei);let i=ei.INSTANCE.ignoreTargets.push(t);return nt(i)}static isTouchDevice(){return"ontouchstart"in Kr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,s=t.targetTouches.length;r<s;r++){let n=t.targetTouches.item(r);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(_r.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let r=Date.now(),s=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],h=Date.now()-c.initialTimeStamp;if(h<ei.HOLD_DELAY&&Math.abs(c.initialPageX-bi(c.rollingPageX))<30&&Math.abs(c.initialPageY-bi(c.rollingPageY))<30){let d=this.newGestureEvent(_r.Tap,c.initialTarget);d.pageX=bi(c.rollingPageX),d.pageY=bi(c.rollingPageY),this.dispatchEvent(d)}else if(h>=ei.HOLD_DELAY&&Math.abs(c.initialPageX-bi(c.rollingPageX))<30&&Math.abs(c.initialPageY-bi(c.rollingPageY))<30){let d=this.newGestureEvent(_r.Contextmenu,c.initialTarget);d.pageX=bi(c.rollingPageX),d.pageY=bi(c.rollingPageY),this.dispatchEvent(d)}else if(s===1){let d=bi(c.rollingPageX),u=bi(c.rollingPageY),f=bi(c.rollingTimestamps)-c.rollingTimestamps[0],_=d-c.rollingPageX[0],p=u-c.rollingPageY[0],b=[...this.targets].filter(g=>c.initialTarget instanceof Node&&g.contains(c.initialTarget));this.inertia(t,b,r,Math.abs(_)/f,_>0?1:-1,d,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(_r.End,c.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=i,r.tapCount=0,r}dispatchEvent(t){if(t.type===_r.Tap){let i=new Date().getTime(),r=0;i-this._lastSetTapCountTime>ei.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=i,t.tapCount=r}else(t.type===_r.Change||t.type===_r.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let i=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let s=0,n=t.initialTarget;for(;n&&n!==r;)s++,n=n.parentElement;i.push([s,r])}i.sort((r,s)=>r[0]-s[0]);for(let[r,s]of i)s.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,r,s,n,o,a,c,h){this.handle=Fu(t,()=>{let d=Date.now(),u=d-r,f=0,_=0,p=!0;s+=ei.SCROLL_FRICTION*u,a+=ei.SCROLL_FRICTION*u,s>0&&(p=!1,f=n*s*u),a>0&&(p=!1,_=c*a*u);let b=this.newGestureEvent(_r.Change);b.translationX=f,b.translationY=_,i.forEach(g=>g.dispatchEvent(b)),p||this.inertia(t,i,d,s,n,o+f,a,c,h+_)})}onTouchMove(t){let i=Date.now();for(let r=0,s=t.changedTouches.length;r<s;r++){let n=t.changedTouches.item(r);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(_r.Change,o.initialTarget);a.translationX=n.pageX-bi(o.rollingPageX),a.translationY=n.pageY-bi(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(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ro.SCROLL_FRICTION=-.005,Ro.HOLD_DELAY=700,Ro.CLEAR_TAP_COUNT_TIME=400,vt([D0],Ro,"isTouchDevice",1);var T0=Ro,Wu=class extends He{onclick(e,t){this._register(Ae(e,Ft.CLICK,i=>t(new Pa(Er(e),i))))}onmousedown(e,t){this._register(Ae(e,Ft.MOUSE_DOWN,i=>t(new Pa(Er(e),i))))}onmouseover(e,t){this._register(Ae(e,Ft.MOUSE_OVER,i=>t(new Pa(Er(e),i))))}onmouseleave(e,t){this._register(Ae(e,Ft.MOUSE_LEAVE,i=>t(new Pa(Er(e),i))))}onkeydown(e,t){this._register(Ae(e,Ft.KEY_DOWN,i=>t(new jd(i))))}onkeyup(e,t){this._register(Ae(e,Ft.KEY_UP,i=>t(new jd(i))))}oninput(e,t){this._register(Ae(e,Ft.INPUT,t))}onblur(e,t){this._register(Ae(e,Ft.BLUR,t))}onfocus(e,t){this._register(Ae(e,Ft.FOCUS,t))}onchange(e,t){this._register(Ae(e,Ft.CHANGE,t))}ignoreGesture(e){return T0.ignoreTarget(e)}},Qd=11,R0=class extends Wu{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Qd+"px",this.domNode.style.height=Qd+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Pp),this._register(Xd(this.bgDomNode,Ft.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Xd(this.domNode,Ft.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new k0),this._pointerdownScheduleRepeatTimer=this._register(new Nu)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Er(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},P0=class bc{constructor(t,i,r,s,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,r=r|0,s=s|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=s,this.rawScrollTop=a,i<0&&(i=0),s+i>r&&(s=r-i),s<0&&(s=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=r,this.scrollLeft=s,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new bc(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new bc(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let r=this.width!==t.width,s=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:s,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:c}}},A0=class extends He{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new P0(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var r;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let r;t?r=new Jd(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Jd.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Zd=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function ch(e,t){let i=t-e;return function(r){return e+i*L0(r)}}function M0(e,t,i){return function(r){return r<i?e(r/i):t((r-i)/(1-i))}}var Jd=class yc{constructor(t,i,r,s){this.from=t,this.to=i,this.duration=s,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,r){if(Math.abs(t-i)>2.5*r){let s,n;return t<i?(s=t+.75*r,n=i-.75*r):(s=t-.75*r,n=i+.75*r),M0(ch(t,s),ch(n,i),.33)}return ch(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let r=this.scrollLeft(i),s=this.scrollTop(i);return new Zd(r,s,!1)}return new Zd(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,r){return yc.start(t,i,r)}static start(t,i,r){r=r+10;let s=Date.now()-10;return new yc(t,i,s,r)}};function O0(e){return Math.pow(e,3)}function L0(e){return 1-O0(1-e)}var I0=class extends He{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Nu)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},B0=140,Ap=class extends Wu{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new I0(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Pp),this._shouldRender=!0,this.domNode=Ko(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(Ae(this.domNode.domNode,Ft.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new R0(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,r){this.slider=Ko(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ae(this.slider.domNode,Ft.POINTER_DOWN,s=>{s.button===0&&(s.preventDefault(),this._sliderPointerDown(s))})),this.onclick(this.slider.domNode,s=>{s.leftButton&&s.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(e);i<=s&&s<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let s=x0(this.domNode.domNode);t=e.pageX-s.left,i=e.pageY-s.top}let r=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{let n=this._sliderOrthogonalPointerPosition(s),o=Math.abs(n-i);if(Ep&&o>B0){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let a=this._sliderPointerPosition(s)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Mp=class Sc{constructor(t,i,r,s,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=s,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Sc(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,r,s,n){let o=Math.max(0,r-t),a=Math.max(0,o-2*i),c=s>0&&s>r;if(!c)return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(r*a/s))),d=(a-h)/(s-r),u=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(h),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=Sc._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,r=this._scrollPosition;return i<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},N0=class extends Ap{constructor(e,t,i){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Mp(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,s.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},F0=class extends Ap{constructor(e,t,i){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Mp(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,s.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},W0=500,ef=50,H0=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},wc=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,r=1,s=this._rear;do{let n=s===this._front?t:Math.pow(2,-r);if(t-=n,i+=this._memory[s].score*n,s===this._front)break;s=(this._capacity+s-1)%this._capacity,r++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Iu){let i=Er(t.browserEvent),r=Qw(i);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,r){let s=null,n=new H0(t,i,r);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(s=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,s)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),i){let s=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),c=Math.max(Math.min(s,o),1),h=Math.max(Math.min(n,a),1),d=Math.max(s,o),u=Math.max(n,a);d%c===0&&u%h===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};wc.INSTANCE=new wc;var z0=wc,U0=class extends Wu{constructor(e,t,i){super(),this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new te),this.onWillScroll=this._onWillScroll.event,this._options=q0(t),this._scrollable=i,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let r={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new F0(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new N0(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ko(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ko(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ko(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,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new Nu),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=bn(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Tr&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Vd(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=bn(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Vd(i))};this._mouseWheelToDispose.push(Ae(this._listenOnDomNode,Ft.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var s;if((s=e.browserEvent)!=null&&s.defaultPrevented)return;let t=z0.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.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=!Tr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let c=this._scrollable.getFutureScrollPosition(),h={};if(n){let d=ef*n,u=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(h,u)}if(o){let d=ef*o,u=c.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(h,u)}h=this._scrollable.validateScrollPosition(h),(c.scrollLeft!==h.scrollLeft||c.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),i=!0)}let r=i;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,r=i?" left":"",s=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${s}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),W0)}},K0=class extends U0{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function q0(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Tr&&(t.className+=" mac"),t}var Cc=class extends He{constructor(e,t,i,r,s,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new A0({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Fu(r.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new K0(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Qt.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(nt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(nt(()=>this._styleElement.remove())),this._register(Qt.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(`
35
- `)})),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(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Cc=vt([ue(2,li),ue(3,Zr),ue(4,dp),ue(5,po),ue(6,hi),ue(7,Jr)],Cc);var kc=class extends He{constructor(e,t,i,r,s){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=r,this._renderService=s,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(nt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};kc=vt([ue(1,li),ue(2,Zr),ue(3,ma),ue(4,Jr)],kc);var j0=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},dr={full:0,left:0,center:0,right:0},is={full:0,left:0,center:0,right:0},So={full:0,left:0,center:0,right:0},_l=class extends He{constructor(e,t,i,r,s,n,o,a){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=r,this._renderService=s,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new j0,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(nt(()=>{var d;return(d=this._canvas)==null?void 0:d.remove()}));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);is.full=this._canvas.width,is.left=e,is.center=t,is.right=e,this._refreshDrawHeightConstants(),So.full=1,So.left=1,So.center=1+is.left,So.right=1+is.left+is.center}_refreshDrawHeightConstants(){dr.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);dr.left=t,dr.center=t,dr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(So[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-dr[e.position||"full"]/2),is[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+dr[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};_l=vt([ue(2,li),ue(3,ma),ue(4,Jr),ue(5,hi),ue(6,po),ue(7,Zr)],_l);var U;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
36
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(U||(U={}));var Xa;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Xa||(Xa={}));var Op;(e=>e.ST=`${U.ESC}\\`)(Op||(Op={}));var xc=class{constructor(e,t,i,r,s,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=r,this._coreService=s,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(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${U.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};xc=vt([ue(2,li),ue(3,hi),ue(4,wn),ue(5,Jr)],xc);var Wt=0,Ht=0,zt=0,ut=0,tf={css:"#00000000",rgba:0},wt;(e=>{function t(s,n,o,a){return a!==void 0?`#${Os(s)}${Os(n)}${Os(o)}${Os(a)}`:`#${Os(s)}${Os(n)}${Os(o)}`}e.toCss=t;function i(s,n,o,a=255){return(s<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function r(s,n,o,a){return{css:e.toCss(s,n,o,a),rgba:e.toRgba(s,n,o,a)}}e.toColor=r})(wt||(wt={}));var Je;(e=>{function t(c,h){if(ut=(h.rgba&255)/255,ut===1)return{css:h.css,rgba:h.rgba};let d=h.rgba>>24&255,u=h.rgba>>16&255,f=h.rgba>>8&255,_=c.rgba>>24&255,p=c.rgba>>16&255,b=c.rgba>>8&255;Wt=_+Math.round((d-_)*ut),Ht=p+Math.round((u-p)*ut),zt=b+Math.round((f-b)*ut);let g=wt.toCss(Wt,Ht,zt),S=wt.toRgba(Wt,Ht,zt);return{css:g,rgba:S}}e.blend=t;function i(c){return(c.rgba&255)===255}e.isOpaque=i;function r(c,h,d){let u=$a.ensureContrastRatio(c.rgba,h.rgba,d);if(u)return wt.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=r;function s(c){let h=(c.rgba|255)>>>0;return[Wt,Ht,zt]=$a.toChannels(h),{css:wt.toCss(Wt,Ht,zt),rgba:h}}e.opaque=s;function n(c,h){return ut=Math.round(h*255),[Wt,Ht,zt]=$a.toChannels(c.rgba),{css:wt.toCss(Wt,Ht,zt,ut),rgba:wt.toRgba(Wt,Ht,zt,ut)}}e.opacity=n;function o(c,h){return ut=c.rgba&255,n(c,ut*h/255)}e.multiplyOpacity=o;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})(Je||(Je={}));var lt;(e=>{let t,i;try{let s=document.createElement("canvas");s.width=1,s.height=1;let n=s.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function r(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Wt=parseInt(s.slice(1,2).repeat(2),16),Ht=parseInt(s.slice(2,3).repeat(2),16),zt=parseInt(s.slice(3,4).repeat(2),16),wt.toColor(Wt,Ht,zt);case 5:return Wt=parseInt(s.slice(1,2).repeat(2),16),Ht=parseInt(s.slice(2,3).repeat(2),16),zt=parseInt(s.slice(3,4).repeat(2),16),ut=parseInt(s.slice(4,5).repeat(2),16),wt.toColor(Wt,Ht,zt,ut);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let n=s.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 Wt=parseInt(n[1]),Ht=parseInt(n[2]),zt=parseInt(n[3]),ut=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),wt.toColor(Wt,Ht,zt,ut);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=s,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Wt,Ht,zt,ut]=t.getImageData(0,0,1,1).data,ut!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:wt.toRgba(Wt,Ht,zt,ut),css:s}}e.toColor=r})(lt||(lt={}));var ni;(e=>{function t(r){return i(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function i(r,s,n){let o=r/255,a=s/255,c=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return h*.2126+d*.7152+u*.0722}e.relativeLuminance2=i})(ni||(ni={}));var $a;(e=>{function t(o,a){if(ut=(a&255)/255,ut===1)return a;let c=a>>24&255,h=a>>16&255,d=a>>8&255,u=o>>24&255,f=o>>16&255,_=o>>8&255;return Wt=u+Math.round((c-u)*ut),Ht=f+Math.round((h-f)*ut),zt=_+Math.round((d-_)*ut),wt.toRgba(Wt,Ht,zt)}e.blend=t;function i(o,a,c){let h=ni.relativeLuminance(o>>8),d=ni.relativeLuminance(a>>8);if(Ir(h,d)<c){if(d<h){let _=r(o,a,c),p=Ir(h,ni.relativeLuminance(_>>8));if(p<c){let b=s(o,a,c),g=Ir(h,ni.relativeLuminance(b>>8));return p>g?_:b}return _}let u=s(o,a,c),f=Ir(h,ni.relativeLuminance(u>>8));if(f<c){let _=r(o,a,c),p=Ir(h,ni.relativeLuminance(_>>8));return f>p?u:_}return u}}e.ensureContrastRatio=i;function r(o,a,c){let h=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,_=a>>16&255,p=a>>8&255,b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));for(;b<c&&(f>0||_>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p-=Math.max(0,Math.ceil(p*.1)),b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));return(f<<24|_<<16|p<<8|255)>>>0}e.reduceLuminance=r;function s(o,a,c){let h=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,_=a>>16&255,p=a>>8&255,b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));for(;b<c&&(f<255||_<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));return(f<<24|_<<16|p<<8|255)>>>0}e.increaseLuminance=s;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})($a||($a={}));function Os(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ir(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Y0=class extends ga{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},vl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ki}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],r=t.translateToString(!0),s=0,n=0,o=0,a=t.getFg(0),c=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==c){if(h-s>1){let d=this._getJoinedRanges(r,o,n,t,s);for(let u=0;u<d.length;u++)i.push(d[u])}s=h,o=n,a=this._workCell.fg,c=this._workCell.bg}n+=this._workCell.getChars().length||bs.length}if(this._bufferService.cols-s>1){let h=this._getJoinedRanges(r,o,n,t,s);for(let d=0;d<h.length;d++)i.push(h[d])}return i}_getJoinedRanges(e,t,i,r,s){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let c=this._characterJoiners[a].handler(n);for(let h=0;h<c.length;h++)vl._mergeRanges(o,c[h])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,r,s),o}_stringRangesToCellRanges(e,t,i){let r=0,s=!1,n=0,o=e[r];if(o){for(let a=i;a<this._bufferService.cols;a++){let c=t.getWidth(a),h=t.getString(a).length||bs.length;if(c!==0){if(!s&&o[0]<=n&&(o[0]=a,s=!0),o[1]<=n){if(o[1]=a,o=e[++r],!o)break;o[0]<=n?(o[0]=a,s=!0):s=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let r=0;r<e.length;r++){let s=e[r];if(i){if(t[1]<=s[0])return e[r-1][1]=t[1],e;if(t[1]<=s[1])return e[r-1][1]=Math.max(t[1],s[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=s[0])return e.splice(r,0,t),e;if(t[1]<=s[1])return s[0]=Math.min(t[0],s[0]),e;t[0]<s[1]&&(s[0]=Math.min(t[0],s[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};vl=vt([ue(0,li)],vl);function V0(e){return 57508<=e&&e<=57558}function G0(e){return 9472<=e&&e<=9631}function X0(e){return V0(e)||G0(e)}function $0(){return{css:{canvas:Aa(),cell:Aa()},device:{canvas:Aa(),cell:Aa(),char:{width:0,height:0,left:0,top:0}}}}function Aa(){return{width:0,height:0}}var Ec=class{constructor(e,t,i,r,s,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=r,this._coreService=s,this._decorationService=n,this._themeService=o,this._workCell=new Ki,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,r,s,n,o,a,c,h,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,p=e.getNoBgTrimmedLength();i&&p<n+1&&(p=n+1);let b,g=0,S="",O=0,C=0,y=0,x=0,P=!1,I=0,z=!1,q=0,J=0,K=[],N=h!==-1&&d!==-1;for(let A=0;A<p;A++){e.loadCell(A,this._workCell);let T=this._workCell.getWidth();if(T===0)continue;let L=!1,H=A>=J,D=A,E=this._workCell;if(f.length>0&&A===f[0][0]&&H){let Pe=f.shift(),et=this._isCellInSelection(Pe[0],t);for(O=Pe[0]+1;O<Pe[1];O++)H&&(H=et===this._isCellInSelection(O,t));H&&(H=!i||n<Pe[0]||n>=Pe[1]),H?(L=!0,E=new Y0(this._workCell,e.translateToString(!0,Pe[0],Pe[1]),Pe[1]-Pe[0]),D=Pe[1]-1,T=E.getWidth()):J=Pe[1]}let $=this._isCellInSelection(A,t),Q=i&&A===n,pe=N&&A>=h&&A<=d,be=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,Pe=>{be=!0});let ce=E.getChars()||bs;if(ce===" "&&(E.isUnderline()||E.isOverline())&&(ce=" "),q=T*a-c.get(ce,E.isBold(),E.isItalic()),!b)b=this._document.createElement("span");else if(g&&($&&z||!$&&!z&&E.bg===C)&&($&&z&&_.selectionForeground||E.fg===y)&&E.extended.ext===x&&pe===P&&q===I&&!Q&&!L&&!be&&H){E.isInvisible()?S+=bs:S+=ce,g++;continue}else g&&(b.textContent=S),b=this._document.createElement("span"),g=0,S="";if(C=E.bg,y=E.fg,x=E.extended.ext,P=pe,I=q,z=$,L&&n>=A&&n<=D&&(n=A),!this._coreService.isCursorHidden&&Q&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&K.push("xterm-cursor-blink"),K.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(E.isBold()&&K.push("xterm-bold"),E.isItalic()&&K.push("xterm-italic"),E.isDim()&&K.push("xterm-dim"),E.isInvisible()?S=bs:S=E.getChars()||bs,E.isUnderline()&&(K.push(`xterm-underline-${E.extended.underlineStyle}`),S===" "&&(S=" "),!E.isUnderlineColorDefault()))if(E.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${ga.toColorRGB(E.getUnderlineColor()).join(",")})`;else{let Pe=E.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&E.isBold()&&Pe<8&&(Pe+=8),b.style.textDecorationColor=_.ansi[Pe].css}E.isOverline()&&(K.push("xterm-overline"),S===" "&&(S=" ")),E.isStrikethrough()&&K.push("xterm-strikethrough"),pe&&(b.style.textDecoration="underline");let se=E.getFgColor(),De=E.getFgColorMode(),Te=E.getBgColor(),_e=E.getBgColorMode(),Se=!!E.isInverse();if(Se){let Pe=se;se=Te,Te=Pe;let et=De;De=_e,_e=et}let de,Me,Ne=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,Pe=>{Pe.options.layer!=="top"&&Ne||(Pe.backgroundColorRGB&&(_e=50331648,Te=Pe.backgroundColorRGB.rgba>>8&16777215,de=Pe.backgroundColorRGB),Pe.foregroundColorRGB&&(De=50331648,se=Pe.foregroundColorRGB.rgba>>8&16777215,Me=Pe.foregroundColorRGB),Ne=Pe.options.layer==="top")}),!Ne&&$&&(de=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,Te=de.rgba>>8&16777215,_e=50331648,Ne=!0,_.selectionForeground&&(De=50331648,se=_.selectionForeground.rgba>>8&16777215,Me=_.selectionForeground)),Ne&&K.push("xterm-decoration-top");let je;switch(_e){case 16777216:case 33554432:je=_.ansi[Te],K.push(`xterm-bg-${Te}`);break;case 50331648:je=wt.toColor(Te>>16,Te>>8&255,Te&255),this._addStyle(b,`background-color:#${rf((Te>>>0).toString(16),"0",6)}`);break;case 0:default:Se?(je=_.foreground,K.push("xterm-bg-257")):je=_.background}switch(de||E.isDim()&&(de=Je.multiplyOpacity(je,.5)),De){case 16777216:case 33554432:E.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(b,je,_.ansi[se],E,de,void 0)||K.push(`xterm-fg-${se}`);break;case 50331648:let Pe=wt.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(b,je,Pe,E,de,Me)||this._addStyle(b,`color:#${rf(se.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,je,_.foreground,E,de,Me)||Se&&K.push("xterm-fg-257")}K.length&&(b.className=K.join(" "),K.length=0),!Q&&!L&&!be&&H?g++:b.textContent=S,q!==this.defaultSpacing&&(b.style.letterSpacing=`${q}px`),u.push(b),A=D}return b&&g&&(b.textContent=S),u}_applyMinimumContrast(e,t,i,r,s,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||X0(r.getCode()))return!1;let o=this._getContrastCache(r),a;if(!s&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);a=Je.ensureContrastRatio(s||t,n||i,c),o.setColor((s||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,r=this._selectionEnd;return!i||!r?!1:this._columnSelectMode?i[0]<=r[0]?e>=i[0]&&t>=i[1]&&e<r[0]&&t<=r[1]:e<i[0]&&t>=i[1]&&e>=r[0]&&t<=r[1]:t>i[1]&&t<r[1]||i[1]===r[1]&&t===i[1]&&e>=i[0]&&e<r[0]||i[1]<r[1]&&t===r[1]&&e<r[0]||i[1]<r[1]&&t===i[1]&&e>=i[0]}};Ec=vt([ue(1,vp),ue(2,hi),ue(3,Zr),ue(4,wn),ue(5,ma),ue(6,po)],Ec);function rf(e,t,i){for(;e.length<i;)e=t+e;return e}var Q0=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,r,s,n],this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(n),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,r){e===this._font&&t===this._fontSize&&i===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,i){let r=0;if(!t&&!i&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let o=this._measure(e,0);return o>0&&(this._flat[r]=o),o}let s=e;t&&(s+="B"),i&&(s+="I");let n=this._holey.get(s);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(s,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Z0=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,r=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let s=e.buffers.active.ydisp,n=t[1]-s,o=i[1]-s,a=Math.max(n,0),c=Math.min(o,e.rows-1);if(a>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function J0(){return new Z0}var uh="xterm-dom-renderer-owner-",Ri="xterm-rows",Ma="xterm-fg-",sf="xterm-bg-",wo="xterm-focus",Oa="xterm-selection",e1=1,Dc=class extends He{constructor(e,t,i,r,s,n,o,a,c,h,d,u,f,_){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=r,this._viewportElement=s,this._helperContainer=n,this._linkifier2=o,this._charSizeService=c,this._optionsService=h,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=_,this._terminalClass=e1++,this._rowElements=[],this._selectionRenderModel=J0(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ri),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(Oa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=$0(),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(Ec,document),this._element.classList.add(uh+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(nt(()=>{this._element.classList.remove(uh+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Q0(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ri} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ri} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ri} .xterm-dim { color: ${Je.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${s} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ri}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ri}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ri}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Oa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Oa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Oa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ma}${n} { color: ${o.css}; }${this._terminalSelector} .${Ma}${n}.xterm-dim { color: ${Je.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${sf}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ma}257 { color: ${Je.opaque(e.background).css}; }${this._terminalSelector} .${Ma}257.xterm-dim { color: ${Je.multiplyOpacity(Je.opaque(e.background),.5).css}; }${this._terminalSelector} .${sf}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(wo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(wo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let c=e[0]>t[0];a.appendChild(this._createSelectionElement(n,c?t[0]:e[0],c?e[0]:t[0],o-n+1))}else{let c=r===n?e[0]:0,h=n===s?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,c,h));let d=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==o){let u=s===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,r=1){let s=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),s.style.height=`${r*this.dimensions.css.cell.height}px`,s.style.top=`${e*this.dimensions.css.cell.height}px`,s.style.left=`${n}px`,s.style.width=`${o}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,r=i.ybase+i.y,s=Math.min(i.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 c=e;c<=t;c++){let h=c+i.ydisp,d=this._rowElements[c],u=i.lines.get(h);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,h,h===r,o,a,s,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${uh}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,r,s,n){i<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),r=Math.max(Math.min(r,o),0),s=Math.min(s,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,h=Math.min(a.x,s-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=i;_<=r;++_){let p=_+a.ydisp,b=this._rowElements[_],g=a.lines.get(p);if(!b||!g)break;b.replaceChildren(...this._rowFactory.createRow(g,p,p===c,u,f,h,d,this.dimensions.css.cell.width,this._widthCache,n?_===i?e:0:-1,n?(_===r?t:s)-1:-1))}}};Dc=vt([ue(7,Mu),ue(8,Ul),ue(9,hi),ue(10,li),ue(11,wn),ue(12,Zr),ue(13,po)],Dc);var Tc=class extends He{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new i1(this._optionsService))}catch{this._measureStrategy=this._register(new t1(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Tc=vt([ue(2,hi)],Tc);var Lp=class extends He{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},t1=class extends Lp{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},i1=class extends Lp{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},r1=class extends He{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new s1(this._window)),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Qt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ae(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ae(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},s1=class extends He{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ho),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(nt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ae(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},n1=class extends He{constructor(){super(),this.linkProviders=[],this._register(nt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Hu(e,t,i){let r=i.getBoundingClientRect(),s=e.getComputedStyle(i),n=parseInt(s.getPropertyValue("padding-left")),o=parseInt(s.getPropertyValue("padding-top"));return[t.clientX-r.left-n,t.clientY-r.top-o]}function o1(e,t,i,r,s,n,o,a,c){if(!n)return;let h=Hu(e,t,i);if(h)return h[0]=Math.ceil((h[0]+(c?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),r+(c?1:0)),h[1]=Math.min(Math.max(h[1],1),s),h}var Rc=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,r,s){return o1(window,e,t,i,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(e,t){let i=Hu(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Rc=vt([ue(0,Jr),ue(1,Ul)],Rc);var a1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Ip={};gw(Ip,{getSafariVersion:()=>h1,isChromeOS:()=>Wp,isFirefox:()=>Bp,isIpad:()=>c1,isIphone:()=>u1,isLegacyEdge:()=>l1,isLinux:()=>zu,isMac:()=>pl,isNode:()=>Kl,isSafari:()=>Np,isWindows:()=>Fp});var Kl=typeof process<"u"&&"title"in process,ba=Kl?"node":navigator.userAgent,ya=Kl?"node":navigator.platform,Bp=ba.includes("Firefox"),l1=ba.includes("Edge"),Np=/^((?!chrome|android).)*safari/i.test(ba);function h1(){if(!Np)return 0;let e=ba.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var pl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ya),c1=ya==="iPad",u1=ya==="iPhone",Fp=["Windows","Win16","Win32","WinCE"].includes(ya),zu=ya.indexOf("Linux")>=0,Wp=/\bCrOS\b/.test(ba),Hp=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,r=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),s=e.timeRemaining(),i*1.5>s){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=s}this.clear()}},d1=class extends Hp{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},f1=class extends Hp{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gl=!Kl&&"requestIdleCallback"in window?f1:d1,_1=class{constructor(){this._queue=new gl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Pc=class extends He{constructor(e,t,i,r,s,n,o,a,c){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=r,this._coreService=s,this._coreBrowserService=a,this._renderer=this._register(new ho),this._pausedResizeTask=new _1,this._observerDisposable=this._register(new ho),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 te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new a1((h,d)=>this._renderRows(h,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new v1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(nt(()=>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(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=nt(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Pc=vt([ue(2,hi),ue(3,Ul),ue(4,wn),ue(5,ma),ue(6,li),ue(7,Zr),ue(8,po)],Pc);var v1=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function p1(e,t,i,r){let s=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return b1(s,n,e,t,i,r)+ql(n,t,i,r)+y1(s,n,e,t,i,r);let o;if(n===t)return o=s>e?"D":"C",$o(Math.abs(s-e),Xo(o,r));o=n>t?"D":"C";let a=Math.abs(n-t),c=m1(n>t?e:s,i)+(a-1)*i.cols+1+g1(n>t?s:e);return $o(c,Xo(o,r))}function g1(e,t){return e-1}function m1(e,t){return t.cols-e}function b1(e,t,i,r,s,n){return ql(t,r,s,n).length===0?"":$o(Up(e,t,e,t-yn(t,s),!1,s).length,Xo("D",n))}function ql(e,t,i,r){let s=e-yn(e,i),n=t-yn(t,i),o=Math.abs(s-n)-S1(e,t,i);return $o(o,Xo(zp(e,t),r))}function y1(e,t,i,r,s,n){let o;ql(t,r,s,n).length>0?o=r-yn(r,s):o=t;let a=r,c=w1(e,t,i,r,s,n);return $o(Up(e,o,i,a,c==="C",s).length,Xo(c,n))}function S1(e,t,i){var o;let r=0,s=e-yn(e,i),n=t-yn(t,i);for(let a=0;a<Math.abs(s-n);a++){let c=zp(e,t)==="A"?-1:1;(o=i.buffer.lines.get(s+c*a))!=null&&o.isWrapped&&r++}return r}function yn(e,t){let i=0,r=t.buffer.lines.get(e),s=r==null?void 0:r.isWrapped;for(;s&&e>=0&&e<t.rows;)i++,r=t.buffer.lines.get(--e),s=r==null?void 0:r.isWrapped;return i}function w1(e,t,i,r,s,n){let o;return ql(i,r,s,n).length>0?o=r-yn(r,s):o=t,e<i&&o<=r||e>=i&&o<r?"C":"D"}function zp(e,t){return e>t?"A":"B"}function Up(e,t,i,r,s,n){let o=e,a=t,c="";for(;(o!==i||a!==r)&&a>=0&&a<n.buffer.lines.length;)o+=s?1:-1,s&&o>n.cols-1?(c+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!s&&o<0&&(c+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return c+n.buffer.translateBufferLineToString(a,!1,e,o)}function Xo(e,t){let i=t?"O":"[";return U.ESC+i+e}function $o(e,t){e=Math.floor(e);let i="";for(let r=0;r<e;r++)i+=t;return i}var C1=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function nf(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var dh=50,k1=15,x1=50,E1=500,D1=" ",T1=new RegExp(D1,"g"),Ac=class extends He{constructor(e,t,i,r,s,n,o,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=r,this._coreService=s,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ki,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new te),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 C1(this._bufferService),this._activeSelectionMode=0,this._register(nt(()=>{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 e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let s=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,s,n);r.push(a)}}else{let s=e[1]===t[1]?t[0]:void 0;r.push(i.translateBufferLineToString(e[1],!0,e[0],s));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?r[r.length-1]+=a:r.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?r[r.length-1]+=o:r.push(o)}}return r.map(s=>s.replace(T1," ")).join(Fp?`\r
34
+ `))}},qw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},jw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Yw=0,ah=class{constructor(e){this.value=e,this.id=Yw++}},Vw=2,Gw,te=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Uw((e==null?void 0:e.onListenerError)??Ya,((i=this._options)==null?void 0:i.leakWarningThreshold)??zw):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Hw(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var e,t,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=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,a,c,h,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],_=new jw(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Ya)(_),He.None}if(this._disposed)return He.None;t&&(e=e.bind(t));let r=new ah(e),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Kw.create(),s=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof ah?(this._deliveryQueue??(this._deliveryQueue=new Xw),this._listeners=[this._listeners,r]):this._listeners.push(r):((c=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||c.call(a,this),this._listeners=r,(d=(h=this._options)==null?void 0:h.onDidAddFirstListener)==null||d.call(h,this)),this._size++;let n=nt(()=>{s==null||s(),this._removeListener(r)});return i instanceof xs?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var s,n,o,a;if((n=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||n.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.call(o,this),this._size=0;return}let t=this._listeners,i=t.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--,t[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Vw<=t.length){let c=0;for(let h=0;h<t.length;h++)t[h]?t[c++]=t[h]:r&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=c}}_deliver(e,t){var r;if(!e)return;let i=((r=this._options)==null?void 0:r.onListenerError)||Ya;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((t=this._deliveryQueue)!=null&&t.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 ah)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},Xw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},vc=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};vc.INSTANCE=new vc;var Lu=vc;function $w(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Lu.INSTANCE.onDidChangeZoomLevel;function Qw(e){return Lu.INSTANCE.getZoomFactor(e)}Lu.INSTANCE.onDidChangeFullscreen;var go=typeof navigator=="object"?navigator.userAgent:"",pc=go.indexOf("Firefox")>=0,Zw=go.indexOf("AppleWebKit")>=0,Iu=go.indexOf("Chrome")>=0,Jw=!Iu&&go.indexOf("Safari")>=0;go.indexOf("Electron/")>=0;go.indexOf("Android")>=0;var lh=!1;if(typeof Kr.matchMedia=="function"){let e=Kr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Kr.matchMedia("(display-mode: fullscreen)");lh=e.matches,$w(Kr,e,({matches:i})=>{lh&&t.matches||(lh=i)})}var An="en",gc=!1,mc=!1,Va=!1,xp=!1,Ra,Ga=An,zd=An,e0,Xi,fn=globalThis,Gt,qf;typeof fn.vscode<"u"&&typeof fn.vscode.process<"u"?Gt=fn.vscode.process:typeof process<"u"&&typeof((qf=process==null?void 0:process.versions)==null?void 0:qf.node)=="string"&&(Gt=process);var jf,t0=typeof((jf=Gt==null?void 0:Gt.versions)==null?void 0:jf.electron)=="string",i0=t0&&(Gt==null?void 0:Gt.type)==="renderer",Yf;if(typeof Gt=="object"){gc=Gt.platform==="win32",mc=Gt.platform==="darwin",Va=Gt.platform==="linux",Va&&Gt.env.SNAP&&Gt.env.SNAP_REVISION,Gt.env.CI||Gt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ra=An,Ga=An;let e=Gt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ra=t.userLocale,zd=t.osLocale,Ga=t.resolvedLanguage||An,e0=(Yf=t.languagePack)==null?void 0:Yf.translationsConfigFile}catch{}xp=!0}else typeof navigator=="object"&&!i0?(Xi=navigator.userAgent,gc=Xi.indexOf("Windows")>=0,mc=Xi.indexOf("Macintosh")>=0,(Xi.indexOf("Macintosh")>=0||Xi.indexOf("iPad")>=0||Xi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Va=Xi.indexOf("Linux")>=0,(Xi==null?void 0:Xi.indexOf("Mobi"))>=0,Ga=globalThis._VSCODE_NLS_LANGUAGE||An,Ra=navigator.language.toLowerCase(),zd=Ra):console.error("Unable to resolve platform.");var Ep=gc,Tr=mc,r0=Va,Ud=xp,Mr=Xi,ts=Ga,s0;(e=>{function t(){return ts}e.value=t;function i(){return ts.length===2?ts==="en":ts.length>=3?ts[0]==="e"&&ts[1]==="n"&&ts[2]==="-":!1}e.isDefaultVariant=i;function r(){return ts==="en"}e.isDefault=r})(s0||(s0={}));var n0=typeof fn.postMessage=="function"&&!fn.importScripts;(()=>{if(n0){let e=[];fn.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,s=e.length;r<s;r++){let n=e[r];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(r,1),n.callback();return}}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),fn.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var o0=!!(Mr&&Mr.indexOf("Chrome")>=0);Mr&&Mr.indexOf("Firefox")>=0;!o0&&Mr&&Mr.indexOf("Safari")>=0;Mr&&Mr.indexOf("Edg/")>=0;Mr&&Mr.indexOf("Android")>=0;var En=typeof navigator=="object"?navigator:{};Ud||document.queryCommandSupported&&document.queryCommandSupported("copy")||En&&En.clipboard&&En.clipboard.writeText,Ud||En&&En.clipboard&&En.clipboard.readText;var Bu=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},hh=new Bu,Kd=new Bu,qd=new Bu,a0=new Array(230),Dp;(e=>{function t(a){return hh.keyCodeToStr(a)}e.toString=t;function i(a){return hh.strToKeyCode(a)}e.fromString=i;function r(a){return Kd.keyCodeToStr(a)}e.toUserSettingsUS=r;function s(a){return qd.keyCodeToStr(a)}e.toUserSettingsGeneral=s;function n(a){return Kd.strToKeyCode(a)||qd.strToKeyCode(a)}e.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 hh.keyCodeToStr(a)}e.toElectronAccelerator=o})(Dp||(Dp={}));var l0=class Tp{constructor(t,i,r,s,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=r,this.metaKey=s,this.keyCode=n}equals(t){return t instanceof Tp&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",r=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${t}${i}${r}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new h0([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},h0=class{constructor(e){if(e.length===0)throw Lw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function c0(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Dp.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(pc)switch(t){case 59:return 85;case 60:if(r0)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Tr)return 57;break}else if(Zw&&(Tr&&t===93||!Tr&&t===92))return 57;return a0[t]||0}var u0=Tr?256:2048,d0=512,f0=1024,_0=Tr?2048:256,jd=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=c0(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=u0),this.altKey&&(t|=d0),this.shiftKey&&(t|=f0),this.metaKey&&(t|=_0),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new l0(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Yd=new WeakMap;function v0(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var p0=class{static getSameOriginWindowChain(e){let t=Yd.get(e);if(!t){t=[],Yd.set(e,t);let i=e,r;do r=v0(i),r?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=r;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,r=0,s=this.getSameOriginWindowChain(e);for(let n of s){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,r+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,r+=a.left}return{top:i,left:r}}},Pa=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=p0.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Vd=class{constructor(e,t=0,i=0){var s;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let r=!1;if(Iu){let n=navigator.userAgent.match(/Chrome\/(\d+)/);r=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((s=e.view)==null?void 0:s.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")r?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(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?pc&&!Tr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Jw&&Ep?this.deltaX=-(n.wheelDeltaX/120):r?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=-e.detail/3;else if(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?pc&&!Tr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Rp=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),g0;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof m0?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Qt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Rp})})(g0||(g0={}));var m0=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?Rp:(this._emitter||(this._emitter=new te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Nu=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new cc("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new cc("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},b0=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new cc("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=i.setInterval(()=>{e()},t);this.disposable=nt(()=>{i.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},y0;(e=>{async function t(r){let s,n=await Promise.all(r.map(o=>o.then(a=>a,a=>{s||(s=a)})));if(typeof s<"u")throw s;return n}e.settled=t;function i(r){return new Promise(async(s,n)=>{try{await r(s,n)}catch(o){n(o)}})}e.withAsyncBody=i})(y0||(y0={}));var Gd=class Ai{static fromArray(t){return new Ai(i=>{i.emitMany(t)})}static fromPromise(t){return new Ai(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Ai(async i=>{await Promise.all(t.map(async r=>i.emitOne(await r)))})}static merge(t){return new Ai(async i=>{await Promise.all(t.map(async r=>{for await(let s of r)i.emitOne(s)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new te,queueMicrotask(async()=>{let r={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(t(r)),this.resolve()}catch(s){this.reject(s)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Qt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Ai(async r=>{for await(let s of t)r.emitOne(i(s))})}map(t){return Ai.map(this,t)}static filter(t,i){return new Ai(async r=>{for await(let s of t)i(s)&&r.emitOne(s)})}filter(t){return Ai.filter(this,t)}static coalesce(t){return Ai.filter(t,i=>!!i)}coalesce(){return Ai.coalesce(this)}static async toPromise(t){let i=[];for await(let r of t)i.push(r);return i}toPromise(){return Ai.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Gd.EMPTY=Gd.fromArray([]);var{getWindow:Er,getWindowId:S0,onDidRegisterWindow:w0}=(function(){let e=new Map,t={window:Kr,disposables:new xs};e.set(Kr.vscodeWindowId,t);let i=new te,r=new te,s=new te;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(o){if(e.has(o.vscodeWindowId))return He.None;let a=new xs,c={window:o,disposables:a.add(new xs)};return e.set(o.vscodeWindowId,c),a.add(nt(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),a.add(Ae(o,Ft.BEFORE_UNLOAD,()=>{s.fire(o)})),i.fire(c),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.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 c=o;return c!=null&&c.view?c.view.window:Kr},getDocument(o){return Er(o).document}}})(),C0=class{constructor(e,t,i,r){this._node=e,this._type=t,this._handler=i,this._options=r||!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 Ae(e,t,i,r){return new C0(e,t,i,r)}var Xd=function(e,t,i,r){return Ae(e,t,i,r)},Fu,k0=class extends b0{constructor(e){super(),this.defaultTarget=e&&Er(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},$d=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ya(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,r=new Map,s=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),r.set(n,!0);o.length>0;)o.sort($d.sort),o.shift().execute();r.set(n,!1)};Fu=(n,o,a=0)=>{let c=S0(n),h=new $d(o,a),d=e.get(c);return d||(d=[],e.set(c,d)),d.push(h),i.get(c)||(i.set(c,!0),n.requestAnimationFrame(()=>s(c))),h}})();function x0(e){let t=e.getBoundingClientRect(),i=Er(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Ft={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"},E0=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ci(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ci(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ci(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ci(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ci(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ci(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ci(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ci(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ci(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ci(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ci(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ci(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ci(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ci(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ci(e){return typeof e=="number"?`${e}px`:e}function Ko(e){return new E0(e)}var Pp=class{constructor(){this._hooks=new xs,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,r,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=s;let n=e;try{e.setPointerCapture(t),this._hooks.add(nt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=Er(e)}this._hooks.add(Ae(n,Ft.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ae(n,Ft.POINTER_UP,o=>this.stopMonitoring(!0)))}};function D0(e,t,i){let r=null,s=null;if(typeof i.value=="function"?(r="value",s=i.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(r="get",s=i.get),!s)throw new Error("not supported");let n=`$memoize$${t}`;i[r]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,o)}),this[n]}}var _r;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(_r||(_r={}));var Ro=class ei extends He{constructor(){super(),this.dispatched=!1,this.targets=new Hd,this.ignoreTargets=new Hd,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Qt.runAndSubscribe(w0,({window:t,disposables:i})=>{i.add(Ae(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),i.add(Ae(t.document,"touchend",r=>this.onTouchEnd(t,r))),i.add(Ae(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Kr,disposables:this._store}))}static addTarget(t){if(!ei.isTouchDevice())return He.None;ei.INSTANCE||(ei.INSTANCE=new ei);let i=ei.INSTANCE.targets.push(t);return nt(i)}static ignoreTarget(t){if(!ei.isTouchDevice())return He.None;ei.INSTANCE||(ei.INSTANCE=new ei);let i=ei.INSTANCE.ignoreTargets.push(t);return nt(i)}static isTouchDevice(){return"ontouchstart"in Kr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,s=t.targetTouches.length;r<s;r++){let n=t.targetTouches.item(r);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(_r.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let r=Date.now(),s=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],h=Date.now()-c.initialTimeStamp;if(h<ei.HOLD_DELAY&&Math.abs(c.initialPageX-bi(c.rollingPageX))<30&&Math.abs(c.initialPageY-bi(c.rollingPageY))<30){let d=this.newGestureEvent(_r.Tap,c.initialTarget);d.pageX=bi(c.rollingPageX),d.pageY=bi(c.rollingPageY),this.dispatchEvent(d)}else if(h>=ei.HOLD_DELAY&&Math.abs(c.initialPageX-bi(c.rollingPageX))<30&&Math.abs(c.initialPageY-bi(c.rollingPageY))<30){let d=this.newGestureEvent(_r.Contextmenu,c.initialTarget);d.pageX=bi(c.rollingPageX),d.pageY=bi(c.rollingPageY),this.dispatchEvent(d)}else if(s===1){let d=bi(c.rollingPageX),u=bi(c.rollingPageY),f=bi(c.rollingTimestamps)-c.rollingTimestamps[0],_=d-c.rollingPageX[0],p=u-c.rollingPageY[0],b=[...this.targets].filter(g=>c.initialTarget instanceof Node&&g.contains(c.initialTarget));this.inertia(t,b,r,Math.abs(_)/f,_>0?1:-1,d,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(_r.End,c.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=i,r.tapCount=0,r}dispatchEvent(t){if(t.type===_r.Tap){let i=new Date().getTime(),r=0;i-this._lastSetTapCountTime>ei.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=i,t.tapCount=r}else(t.type===_r.Change||t.type===_r.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let i=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let s=0,n=t.initialTarget;for(;n&&n!==r;)s++,n=n.parentElement;i.push([s,r])}i.sort((r,s)=>r[0]-s[0]);for(let[r,s]of i)s.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,r,s,n,o,a,c,h){this.handle=Fu(t,()=>{let d=Date.now(),u=d-r,f=0,_=0,p=!0;s+=ei.SCROLL_FRICTION*u,a+=ei.SCROLL_FRICTION*u,s>0&&(p=!1,f=n*s*u),a>0&&(p=!1,_=c*a*u);let b=this.newGestureEvent(_r.Change);b.translationX=f,b.translationY=_,i.forEach(g=>g.dispatchEvent(b)),p||this.inertia(t,i,d,s,n,o+f,a,c,h+_)})}onTouchMove(t){let i=Date.now();for(let r=0,s=t.changedTouches.length;r<s;r++){let n=t.changedTouches.item(r);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(_r.Change,o.initialTarget);a.translationX=n.pageX-bi(o.rollingPageX),a.translationY=n.pageY-bi(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(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ro.SCROLL_FRICTION=-.005,Ro.HOLD_DELAY=700,Ro.CLEAR_TAP_COUNT_TIME=400,vt([D0],Ro,"isTouchDevice",1);var T0=Ro,Wu=class extends He{onclick(e,t){this._register(Ae(e,Ft.CLICK,i=>t(new Pa(Er(e),i))))}onmousedown(e,t){this._register(Ae(e,Ft.MOUSE_DOWN,i=>t(new Pa(Er(e),i))))}onmouseover(e,t){this._register(Ae(e,Ft.MOUSE_OVER,i=>t(new Pa(Er(e),i))))}onmouseleave(e,t){this._register(Ae(e,Ft.MOUSE_LEAVE,i=>t(new Pa(Er(e),i))))}onkeydown(e,t){this._register(Ae(e,Ft.KEY_DOWN,i=>t(new jd(i))))}onkeyup(e,t){this._register(Ae(e,Ft.KEY_UP,i=>t(new jd(i))))}oninput(e,t){this._register(Ae(e,Ft.INPUT,t))}onblur(e,t){this._register(Ae(e,Ft.BLUR,t))}onfocus(e,t){this._register(Ae(e,Ft.FOCUS,t))}onchange(e,t){this._register(Ae(e,Ft.CHANGE,t))}ignoreGesture(e){return T0.ignoreTarget(e)}},Qd=11,R0=class extends Wu{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Qd+"px",this.domNode.style.height=Qd+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Pp),this._register(Xd(this.bgDomNode,Ft.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Xd(this.domNode,Ft.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new k0),this._pointerdownScheduleRepeatTimer=this._register(new Nu)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Er(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},P0=class bc{constructor(t,i,r,s,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,r=r|0,s=s|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=s,this.rawScrollTop=a,i<0&&(i=0),s+i>r&&(s=r-i),s<0&&(s=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=r,this.scrollLeft=s,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new bc(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new bc(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let r=this.width!==t.width,s=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:s,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:c}}},A0=class extends He{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new P0(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var r;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let r;t?r=new Jd(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Jd.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Zd=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function ch(e,t){let i=t-e;return function(r){return e+i*L0(r)}}function M0(e,t,i){return function(r){return r<i?e(r/i):t((r-i)/(1-i))}}var Jd=class yc{constructor(t,i,r,s){this.from=t,this.to=i,this.duration=s,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,r){if(Math.abs(t-i)>2.5*r){let s,n;return t<i?(s=t+.75*r,n=i-.75*r):(s=t-.75*r,n=i+.75*r),M0(ch(t,s),ch(n,i),.33)}return ch(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let r=this.scrollLeft(i),s=this.scrollTop(i);return new Zd(r,s,!1)}return new Zd(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,r){return yc.start(t,i,r)}static start(t,i,r){r=r+10;let s=Date.now()-10;return new yc(t,i,s,r)}};function O0(e){return Math.pow(e,3)}function L0(e){return 1-O0(1-e)}var I0=class extends He{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Nu)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},B0=140,Ap=class extends Wu{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new I0(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Pp),this._shouldRender=!0,this.domNode=Ko(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(Ae(this.domNode.domNode,Ft.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new R0(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,r){this.slider=Ko(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ae(this.slider.domNode,Ft.POINTER_DOWN,s=>{s.button===0&&(s.preventDefault(),this._sliderPointerDown(s))})),this.onclick(this.slider.domNode,s=>{s.leftButton&&s.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(e);i<=s&&s<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let s=x0(this.domNode.domNode);t=e.pageX-s.left,i=e.pageY-s.top}let r=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{let n=this._sliderOrthogonalPointerPosition(s),o=Math.abs(n-i);if(Ep&&o>B0){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let a=this._sliderPointerPosition(s)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Mp=class Sc{constructor(t,i,r,s,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=s,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Sc(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,r,s,n){let o=Math.max(0,r-t),a=Math.max(0,o-2*i),c=s>0&&s>r;if(!c)return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(r*a/s))),d=(a-h)/(s-r),u=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(h),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=Sc._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,r=this._scrollPosition;return i<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},N0=class extends Ap{constructor(e,t,i){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Mp(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,s.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},F0=class extends Ap{constructor(e,t,i){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Mp(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,s.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},W0=500,ef=50,H0=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},wc=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,r=1,s=this._rear;do{let n=s===this._front?t:Math.pow(2,-r);if(t-=n,i+=this._memory[s].score*n,s===this._front)break;s=(this._capacity+s-1)%this._capacity,r++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Iu){let i=Er(t.browserEvent),r=Qw(i);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,r){let s=null,n=new H0(t,i,r);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(s=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,s)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),i){let s=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),c=Math.max(Math.min(s,o),1),h=Math.max(Math.min(n,a),1),d=Math.max(s,o),u=Math.max(n,a);d%c===0&&u%h===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};wc.INSTANCE=new wc;var z0=wc,U0=class extends Wu{constructor(e,t,i){super(),this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new te),this.onWillScroll=this._onWillScroll.event,this._options=q0(t),this._scrollable=i,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let r={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new F0(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new N0(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ko(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ko(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ko(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,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new Nu),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=bn(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Tr&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Vd(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=bn(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Vd(i))};this._mouseWheelToDispose.push(Ae(this._listenOnDomNode,Ft.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var s;if((s=e.browserEvent)!=null&&s.defaultPrevented)return;let t=z0.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.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=!Tr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let c=this._scrollable.getFutureScrollPosition(),h={};if(n){let d=ef*n,u=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(h,u)}if(o){let d=ef*o,u=c.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(h,u)}h=this._scrollable.validateScrollPosition(h),(c.scrollLeft!==h.scrollLeft||c.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),i=!0)}let r=i;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,r=i?" left":"",s=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${s}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),W0)}},K0=class extends U0{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function q0(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Tr&&(t.className+=" mac"),t}var Cc=class extends He{constructor(e,t,i,r,s,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new A0({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Fu(r.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new K0(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Qt.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(nt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(nt(()=>this._styleElement.remove())),this._register(Qt.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(`
35
+ `)})),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(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Cc=vt([ue(2,li),ue(3,Zr),ue(4,dp),ue(5,po),ue(6,hi),ue(7,Jr)],Cc);var kc=class extends He{constructor(e,t,i,r,s){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=r,this._renderService=s,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(nt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};kc=vt([ue(1,li),ue(2,Zr),ue(3,ma),ue(4,Jr)],kc);var j0=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},dr={full:0,left:0,center:0,right:0},is={full:0,left:0,center:0,right:0},So={full:0,left:0,center:0,right:0},_l=class extends He{constructor(e,t,i,r,s,n,o,a){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=r,this._renderService=s,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new j0,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(nt(()=>{var d;return(d=this._canvas)==null?void 0:d.remove()}));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);is.full=this._canvas.width,is.left=e,is.center=t,is.right=e,this._refreshDrawHeightConstants(),So.full=1,So.left=1,So.center=1+is.left,So.right=1+is.left+is.center}_refreshDrawHeightConstants(){dr.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);dr.left=t,dr.center=t,dr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(So[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-dr[e.position||"full"]/2),is[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+dr[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};_l=vt([ue(2,li),ue(3,ma),ue(4,Jr),ue(5,hi),ue(6,po),ue(7,Zr)],_l);var K;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
36
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(K||(K={}));var Xa;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Xa||(Xa={}));var Op;(e=>e.ST=`${K.ESC}\\`)(Op||(Op={}));var xc=class{constructor(e,t,i,r,s,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=r,this._coreService=s,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(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${K.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};xc=vt([ue(2,li),ue(3,hi),ue(4,wn),ue(5,Jr)],xc);var Wt=0,Ht=0,zt=0,ut=0,tf={css:"#00000000",rgba:0},wt;(e=>{function t(s,n,o,a){return a!==void 0?`#${Os(s)}${Os(n)}${Os(o)}${Os(a)}`:`#${Os(s)}${Os(n)}${Os(o)}`}e.toCss=t;function i(s,n,o,a=255){return(s<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function r(s,n,o,a){return{css:e.toCss(s,n,o,a),rgba:e.toRgba(s,n,o,a)}}e.toColor=r})(wt||(wt={}));var Je;(e=>{function t(c,h){if(ut=(h.rgba&255)/255,ut===1)return{css:h.css,rgba:h.rgba};let d=h.rgba>>24&255,u=h.rgba>>16&255,f=h.rgba>>8&255,_=c.rgba>>24&255,p=c.rgba>>16&255,b=c.rgba>>8&255;Wt=_+Math.round((d-_)*ut),Ht=p+Math.round((u-p)*ut),zt=b+Math.round((f-b)*ut);let g=wt.toCss(Wt,Ht,zt),y=wt.toRgba(Wt,Ht,zt);return{css:g,rgba:y}}e.blend=t;function i(c){return(c.rgba&255)===255}e.isOpaque=i;function r(c,h,d){let u=$a.ensureContrastRatio(c.rgba,h.rgba,d);if(u)return wt.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=r;function s(c){let h=(c.rgba|255)>>>0;return[Wt,Ht,zt]=$a.toChannels(h),{css:wt.toCss(Wt,Ht,zt),rgba:h}}e.opaque=s;function n(c,h){return ut=Math.round(h*255),[Wt,Ht,zt]=$a.toChannels(c.rgba),{css:wt.toCss(Wt,Ht,zt,ut),rgba:wt.toRgba(Wt,Ht,zt,ut)}}e.opacity=n;function o(c,h){return ut=c.rgba&255,n(c,ut*h/255)}e.multiplyOpacity=o;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})(Je||(Je={}));var lt;(e=>{let t,i;try{let s=document.createElement("canvas");s.width=1,s.height=1;let n=s.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function r(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Wt=parseInt(s.slice(1,2).repeat(2),16),Ht=parseInt(s.slice(2,3).repeat(2),16),zt=parseInt(s.slice(3,4).repeat(2),16),wt.toColor(Wt,Ht,zt);case 5:return Wt=parseInt(s.slice(1,2).repeat(2),16),Ht=parseInt(s.slice(2,3).repeat(2),16),zt=parseInt(s.slice(3,4).repeat(2),16),ut=parseInt(s.slice(4,5).repeat(2),16),wt.toColor(Wt,Ht,zt,ut);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let n=s.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 Wt=parseInt(n[1]),Ht=parseInt(n[2]),zt=parseInt(n[3]),ut=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),wt.toColor(Wt,Ht,zt,ut);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=s,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Wt,Ht,zt,ut]=t.getImageData(0,0,1,1).data,ut!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:wt.toRgba(Wt,Ht,zt,ut),css:s}}e.toColor=r})(lt||(lt={}));var ni;(e=>{function t(r){return i(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function i(r,s,n){let o=r/255,a=s/255,c=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return h*.2126+d*.7152+u*.0722}e.relativeLuminance2=i})(ni||(ni={}));var $a;(e=>{function t(o,a){if(ut=(a&255)/255,ut===1)return a;let c=a>>24&255,h=a>>16&255,d=a>>8&255,u=o>>24&255,f=o>>16&255,_=o>>8&255;return Wt=u+Math.round((c-u)*ut),Ht=f+Math.round((h-f)*ut),zt=_+Math.round((d-_)*ut),wt.toRgba(Wt,Ht,zt)}e.blend=t;function i(o,a,c){let h=ni.relativeLuminance(o>>8),d=ni.relativeLuminance(a>>8);if(Ir(h,d)<c){if(d<h){let _=r(o,a,c),p=Ir(h,ni.relativeLuminance(_>>8));if(p<c){let b=s(o,a,c),g=Ir(h,ni.relativeLuminance(b>>8));return p>g?_:b}return _}let u=s(o,a,c),f=Ir(h,ni.relativeLuminance(u>>8));if(f<c){let _=r(o,a,c),p=Ir(h,ni.relativeLuminance(_>>8));return f>p?u:_}return u}}e.ensureContrastRatio=i;function r(o,a,c){let h=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,_=a>>16&255,p=a>>8&255,b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));for(;b<c&&(f>0||_>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p-=Math.max(0,Math.ceil(p*.1)),b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));return(f<<24|_<<16|p<<8|255)>>>0}e.reduceLuminance=r;function s(o,a,c){let h=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,_=a>>16&255,p=a>>8&255,b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));for(;b<c&&(f<255||_<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),b=Ir(ni.relativeLuminance2(f,_,p),ni.relativeLuminance2(h,d,u));return(f<<24|_<<16|p<<8|255)>>>0}e.increaseLuminance=s;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})($a||($a={}));function Os(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ir(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Y0=class extends ga{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},vl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ki}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],r=t.translateToString(!0),s=0,n=0,o=0,a=t.getFg(0),c=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==c){if(h-s>1){let d=this._getJoinedRanges(r,o,n,t,s);for(let u=0;u<d.length;u++)i.push(d[u])}s=h,o=n,a=this._workCell.fg,c=this._workCell.bg}n+=this._workCell.getChars().length||bs.length}if(this._bufferService.cols-s>1){let h=this._getJoinedRanges(r,o,n,t,s);for(let d=0;d<h.length;d++)i.push(h[d])}return i}_getJoinedRanges(e,t,i,r,s){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let c=this._characterJoiners[a].handler(n);for(let h=0;h<c.length;h++)vl._mergeRanges(o,c[h])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,r,s),o}_stringRangesToCellRanges(e,t,i){let r=0,s=!1,n=0,o=e[r];if(o){for(let a=i;a<this._bufferService.cols;a++){let c=t.getWidth(a),h=t.getString(a).length||bs.length;if(c!==0){if(!s&&o[0]<=n&&(o[0]=a,s=!0),o[1]<=n){if(o[1]=a,o=e[++r],!o)break;o[0]<=n?(o[0]=a,s=!0):s=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let r=0;r<e.length;r++){let s=e[r];if(i){if(t[1]<=s[0])return e[r-1][1]=t[1],e;if(t[1]<=s[1])return e[r-1][1]=Math.max(t[1],s[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=s[0])return e.splice(r,0,t),e;if(t[1]<=s[1])return s[0]=Math.min(t[0],s[0]),e;t[0]<s[1]&&(s[0]=Math.min(t[0],s[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};vl=vt([ue(0,li)],vl);function V0(e){return 57508<=e&&e<=57558}function G0(e){return 9472<=e&&e<=9631}function X0(e){return V0(e)||G0(e)}function $0(){return{css:{canvas:Aa(),cell:Aa()},device:{canvas:Aa(),cell:Aa(),char:{width:0,height:0,left:0,top:0}}}}function Aa(){return{width:0,height:0}}var Ec=class{constructor(e,t,i,r,s,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=r,this._coreService=s,this._decorationService=n,this._themeService=o,this._workCell=new Ki,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,r,s,n,o,a,c,h,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,p=e.getNoBgTrimmedLength();i&&p<n+1&&(p=n+1);let b,g=0,y="",O=0,R=0,S=0,E=0,A=!1,P=0,B=!1,U=0,$=0,q=[],F=h!==-1&&d!==-1;for(let L=0;L<p;L++){e.loadCell(L,this._workCell);let D=this._workCell.getWidth();if(D===0)continue;let I=!1,H=L>=$,k=L,x=this._workCell;if(f.length>0&&L===f[0][0]&&H){let Pe=f.shift(),et=this._isCellInSelection(Pe[0],t);for(O=Pe[0]+1;O<Pe[1];O++)H&&(H=et===this._isCellInSelection(O,t));H&&(H=!i||n<Pe[0]||n>=Pe[1]),H?(I=!0,x=new Y0(this._workCell,e.translateToString(!0,Pe[0],Pe[1]),Pe[1]-Pe[0]),k=Pe[1]-1,D=x.getWidth()):$=Pe[1]}let Q=this._isCellInSelection(L,t),Z=i&&L===n,pe=F&&L>=h&&L<=d,be=!1;this._decorationService.forEachDecorationAtCell(L,t,void 0,Pe=>{be=!0});let ce=x.getChars()||bs;if(ce===" "&&(x.isUnderline()||x.isOverline())&&(ce=" "),U=D*a-c.get(ce,x.isBold(),x.isItalic()),!b)b=this._document.createElement("span");else if(g&&(Q&&B||!Q&&!B&&x.bg===R)&&(Q&&B&&_.selectionForeground||x.fg===S)&&x.extended.ext===E&&pe===A&&U===P&&!Z&&!I&&!be&&H){x.isInvisible()?y+=bs:y+=ce,g++;continue}else g&&(b.textContent=y),b=this._document.createElement("span"),g=0,y="";if(R=x.bg,S=x.fg,E=x.extended.ext,A=pe,P=U,B=Q,I&&n>=L&&n<=k&&(n=L),!this._coreService.isCursorHidden&&Z&&this._coreService.isCursorInitialized){if(q.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&q.push("xterm-cursor-blink"),q.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":q.push("xterm-cursor-outline");break;case"block":q.push("xterm-cursor-block");break;case"bar":q.push("xterm-cursor-bar");break;case"underline":q.push("xterm-cursor-underline");break}}if(x.isBold()&&q.push("xterm-bold"),x.isItalic()&&q.push("xterm-italic"),x.isDim()&&q.push("xterm-dim"),x.isInvisible()?y=bs:y=x.getChars()||bs,x.isUnderline()&&(q.push(`xterm-underline-${x.extended.underlineStyle}`),y===" "&&(y=" "),!x.isUnderlineColorDefault()))if(x.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${ga.toColorRGB(x.getUnderlineColor()).join(",")})`;else{let Pe=x.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&x.isBold()&&Pe<8&&(Pe+=8),b.style.textDecorationColor=_.ansi[Pe].css}x.isOverline()&&(q.push("xterm-overline"),y===" "&&(y=" ")),x.isStrikethrough()&&q.push("xterm-strikethrough"),pe&&(b.style.textDecoration="underline");let se=x.getFgColor(),De=x.getFgColorMode(),Te=x.getBgColor(),_e=x.getBgColorMode(),Se=!!x.isInverse();if(Se){let Pe=se;se=Te,Te=Pe;let et=De;De=_e,_e=et}let de,Me,Ne=!1;this._decorationService.forEachDecorationAtCell(L,t,void 0,Pe=>{Pe.options.layer!=="top"&&Ne||(Pe.backgroundColorRGB&&(_e=50331648,Te=Pe.backgroundColorRGB.rgba>>8&16777215,de=Pe.backgroundColorRGB),Pe.foregroundColorRGB&&(De=50331648,se=Pe.foregroundColorRGB.rgba>>8&16777215,Me=Pe.foregroundColorRGB),Ne=Pe.options.layer==="top")}),!Ne&&Q&&(de=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,Te=de.rgba>>8&16777215,_e=50331648,Ne=!0,_.selectionForeground&&(De=50331648,se=_.selectionForeground.rgba>>8&16777215,Me=_.selectionForeground)),Ne&&q.push("xterm-decoration-top");let je;switch(_e){case 16777216:case 33554432:je=_.ansi[Te],q.push(`xterm-bg-${Te}`);break;case 50331648:je=wt.toColor(Te>>16,Te>>8&255,Te&255),this._addStyle(b,`background-color:#${rf((Te>>>0).toString(16),"0",6)}`);break;case 0:default:Se?(je=_.foreground,q.push("xterm-bg-257")):je=_.background}switch(de||x.isDim()&&(de=Je.multiplyOpacity(je,.5)),De){case 16777216:case 33554432:x.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(b,je,_.ansi[se],x,de,void 0)||q.push(`xterm-fg-${se}`);break;case 50331648:let Pe=wt.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(b,je,Pe,x,de,Me)||this._addStyle(b,`color:#${rf(se.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,je,_.foreground,x,de,Me)||Se&&q.push("xterm-fg-257")}q.length&&(b.className=q.join(" "),q.length=0),!Z&&!I&&!be&&H?g++:b.textContent=y,U!==this.defaultSpacing&&(b.style.letterSpacing=`${U}px`),u.push(b),L=k}return b&&g&&(b.textContent=y),u}_applyMinimumContrast(e,t,i,r,s,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||X0(r.getCode()))return!1;let o=this._getContrastCache(r),a;if(!s&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);a=Je.ensureContrastRatio(s||t,n||i,c),o.setColor((s||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,r=this._selectionEnd;return!i||!r?!1:this._columnSelectMode?i[0]<=r[0]?e>=i[0]&&t>=i[1]&&e<r[0]&&t<=r[1]:e<i[0]&&t>=i[1]&&e>=r[0]&&t<=r[1]:t>i[1]&&t<r[1]||i[1]===r[1]&&t===i[1]&&e>=i[0]&&e<r[0]||i[1]<r[1]&&t===r[1]&&e<r[0]||i[1]<r[1]&&t===i[1]&&e>=i[0]}};Ec=vt([ue(1,vp),ue(2,hi),ue(3,Zr),ue(4,wn),ue(5,ma),ue(6,po)],Ec);function rf(e,t,i){for(;e.length<i;)e=t+e;return e}var Q0=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,r,s,n],this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(n),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,r){e===this._font&&t===this._fontSize&&i===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,i){let r=0;if(!t&&!i&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let o=this._measure(e,0);return o>0&&(this._flat[r]=o),o}let s=e;t&&(s+="B"),i&&(s+="I");let n=this._holey.get(s);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(s,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Z0=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,r=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let s=e.buffers.active.ydisp,n=t[1]-s,o=i[1]-s,a=Math.max(n,0),c=Math.min(o,e.rows-1);if(a>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function J0(){return new Z0}var uh="xterm-dom-renderer-owner-",Pi="xterm-rows",Ma="xterm-fg-",sf="xterm-bg-",wo="xterm-focus",Oa="xterm-selection",e1=1,Dc=class extends He{constructor(e,t,i,r,s,n,o,a,c,h,d,u,f,_){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=r,this._viewportElement=s,this._helperContainer=n,this._linkifier2=o,this._charSizeService=c,this._optionsService=h,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=_,this._terminalClass=e1++,this._rowElements=[],this._selectionRenderModel=J0(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Pi),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(Oa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=$0(),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(Ec,document),this._element.classList.add(uh+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(nt(()=>{this._element.classList.remove(uh+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Q0(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Pi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Pi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Pi} .xterm-dim { color: ${Je.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${s} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Pi}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Pi}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Pi}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Pi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Pi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Pi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Pi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Pi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Oa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Oa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Oa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ma}${n} { color: ${o.css}; }${this._terminalSelector} .${Ma}${n}.xterm-dim { color: ${Je.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${sf}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ma}257 { color: ${Je.opaque(e.background).css}; }${this._terminalSelector} .${Ma}257.xterm-dim { color: ${Je.multiplyOpacity(Je.opaque(e.background),.5).css}; }${this._terminalSelector} .${sf}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(wo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(wo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let c=e[0]>t[0];a.appendChild(this._createSelectionElement(n,c?t[0]:e[0],c?e[0]:t[0],o-n+1))}else{let c=r===n?e[0]:0,h=n===s?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,c,h));let d=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==o){let u=s===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,r=1){let s=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),s.style.height=`${r*this.dimensions.css.cell.height}px`,s.style.top=`${e*this.dimensions.css.cell.height}px`,s.style.left=`${n}px`,s.style.width=`${o}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,r=i.ybase+i.y,s=Math.min(i.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 c=e;c<=t;c++){let h=c+i.ydisp,d=this._rowElements[c],u=i.lines.get(h);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,h,h===r,o,a,s,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${uh}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,r,s,n){i<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),r=Math.max(Math.min(r,o),0),s=Math.min(s,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,h=Math.min(a.x,s-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=i;_<=r;++_){let p=_+a.ydisp,b=this._rowElements[_],g=a.lines.get(p);if(!b||!g)break;b.replaceChildren(...this._rowFactory.createRow(g,p,p===c,u,f,h,d,this.dimensions.css.cell.width,this._widthCache,n?_===i?e:0:-1,n?(_===r?t:s)-1:-1))}}};Dc=vt([ue(7,Mu),ue(8,Ul),ue(9,hi),ue(10,li),ue(11,wn),ue(12,Zr),ue(13,po)],Dc);var Tc=class extends He{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new i1(this._optionsService))}catch{this._measureStrategy=this._register(new t1(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Tc=vt([ue(2,hi)],Tc);var Lp=class extends He{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},t1=class extends Lp{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},i1=class extends Lp{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},r1=class extends He{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new s1(this._window)),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Qt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ae(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ae(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},s1=class extends He{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ho),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(nt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ae(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},n1=class extends He{constructor(){super(),this.linkProviders=[],this._register(nt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Hu(e,t,i){let r=i.getBoundingClientRect(),s=e.getComputedStyle(i),n=parseInt(s.getPropertyValue("padding-left")),o=parseInt(s.getPropertyValue("padding-top"));return[t.clientX-r.left-n,t.clientY-r.top-o]}function o1(e,t,i,r,s,n,o,a,c){if(!n)return;let h=Hu(e,t,i);if(h)return h[0]=Math.ceil((h[0]+(c?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),r+(c?1:0)),h[1]=Math.min(Math.max(h[1],1),s),h}var Rc=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,r,s){return o1(window,e,t,i,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(e,t){let i=Hu(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Rc=vt([ue(0,Jr),ue(1,Ul)],Rc);var a1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Ip={};gw(Ip,{getSafariVersion:()=>h1,isChromeOS:()=>Wp,isFirefox:()=>Bp,isIpad:()=>c1,isIphone:()=>u1,isLegacyEdge:()=>l1,isLinux:()=>zu,isMac:()=>pl,isNode:()=>Kl,isSafari:()=>Np,isWindows:()=>Fp});var Kl=typeof process<"u"&&"title"in process,ba=Kl?"node":navigator.userAgent,ya=Kl?"node":navigator.platform,Bp=ba.includes("Firefox"),l1=ba.includes("Edge"),Np=/^((?!chrome|android).)*safari/i.test(ba);function h1(){if(!Np)return 0;let e=ba.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var pl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ya),c1=ya==="iPad",u1=ya==="iPhone",Fp=["Windows","Win16","Win32","WinCE"].includes(ya),zu=ya.indexOf("Linux")>=0,Wp=/\bCrOS\b/.test(ba),Hp=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,r=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),s=e.timeRemaining(),i*1.5>s){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=s}this.clear()}},d1=class extends Hp{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},f1=class extends Hp{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gl=!Kl&&"requestIdleCallback"in window?f1:d1,_1=class{constructor(){this._queue=new gl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Pc=class extends He{constructor(e,t,i,r,s,n,o,a,c){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=r,this._coreService=s,this._coreBrowserService=a,this._renderer=this._register(new ho),this._pausedResizeTask=new _1,this._observerDisposable=this._register(new ho),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 te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new a1((h,d)=>this._renderRows(h,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new v1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(nt(()=>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(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=nt(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Pc=vt([ue(2,hi),ue(3,Ul),ue(4,wn),ue(5,ma),ue(6,li),ue(7,Zr),ue(8,po)],Pc);var v1=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function p1(e,t,i,r){let s=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return b1(s,n,e,t,i,r)+ql(n,t,i,r)+y1(s,n,e,t,i,r);let o;if(n===t)return o=s>e?"D":"C",$o(Math.abs(s-e),Xo(o,r));o=n>t?"D":"C";let a=Math.abs(n-t),c=m1(n>t?e:s,i)+(a-1)*i.cols+1+g1(n>t?s:e);return $o(c,Xo(o,r))}function g1(e,t){return e-1}function m1(e,t){return t.cols-e}function b1(e,t,i,r,s,n){return ql(t,r,s,n).length===0?"":$o(Up(e,t,e,t-yn(t,s),!1,s).length,Xo("D",n))}function ql(e,t,i,r){let s=e-yn(e,i),n=t-yn(t,i),o=Math.abs(s-n)-S1(e,t,i);return $o(o,Xo(zp(e,t),r))}function y1(e,t,i,r,s,n){let o;ql(t,r,s,n).length>0?o=r-yn(r,s):o=t;let a=r,c=w1(e,t,i,r,s,n);return $o(Up(e,o,i,a,c==="C",s).length,Xo(c,n))}function S1(e,t,i){var o;let r=0,s=e-yn(e,i),n=t-yn(t,i);for(let a=0;a<Math.abs(s-n);a++){let c=zp(e,t)==="A"?-1:1;(o=i.buffer.lines.get(s+c*a))!=null&&o.isWrapped&&r++}return r}function yn(e,t){let i=0,r=t.buffer.lines.get(e),s=r==null?void 0:r.isWrapped;for(;s&&e>=0&&e<t.rows;)i++,r=t.buffer.lines.get(--e),s=r==null?void 0:r.isWrapped;return i}function w1(e,t,i,r,s,n){let o;return ql(i,r,s,n).length>0?o=r-yn(r,s):o=t,e<i&&o<=r||e>=i&&o<r?"C":"D"}function zp(e,t){return e>t?"A":"B"}function Up(e,t,i,r,s,n){let o=e,a=t,c="";for(;(o!==i||a!==r)&&a>=0&&a<n.buffer.lines.length;)o+=s?1:-1,s&&o>n.cols-1?(c+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!s&&o<0&&(c+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return c+n.buffer.translateBufferLineToString(a,!1,e,o)}function Xo(e,t){let i=t?"O":"[";return K.ESC+i+e}function $o(e,t){e=Math.floor(e);let i="";for(let r=0;r<e;r++)i+=t;return i}var C1=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function nf(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var dh=50,k1=15,x1=50,E1=500,D1=" ",T1=new RegExp(D1,"g"),Ac=class extends He{constructor(e,t,i,r,s,n,o,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=r,this._coreService=s,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ki,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new te),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 C1(this._bufferService),this._activeSelectionMode=0,this._register(nt(()=>{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 e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let s=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,s,n);r.push(a)}}else{let s=e[1]===t[1]?t[0]:void 0;r.push(i.translateBufferLineToString(e[1],!0,e[0],s));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?r[r.length-1]+=a:r.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?r[r.length-1]+=o:r.push(o)}}return r.map(s=>s.replace(T1," ")).join(Fp?`\r
37
37
  `:`
38
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),zu&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r||!t?!1:this._areCoordsInSelection(t,i,r)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r?!1:this._areCoordsInSelection([e,t],i,r)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var s,n;let i=(n=(s=this._linkifier.currentLink)==null?void 0:s.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=nf(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Hu(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-dh),dh),t/=dh,t/Math.abs(t)+Math.round(t*(k1-1)))}shouldForceSelection(e){return pl?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),x1)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(pl&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let r=i.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<E1&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let r=p1(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let r=0;t>=r;r++){let s=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:s>1&&t!==r&&(i+=s-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,n=s.lines.get(e[1]);if(!n)return;let o=s.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),c=a,h=e[0]-a,d=0,u=0,f=0,_=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;c<o.length&&o.charAt(c+1)===" ";)c++}else{let g=e[0],S=e[0];n.getWidth(g)===0&&(d++,g--),n.getWidth(S)===2&&(u++,S++);let O=n.getString(S).length;for(O>1&&(_+=O-1,c+=O-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):C>1&&(f+=C-1,a-=C-1),a--,g--}for(;S<n.length&&c+1<o.length&&!this._isCharWordSeparator(n.loadCell(S+1,this._workCell));){n.loadCell(S+1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,S++):C>1&&(_+=C-1,c+=C-1),c++,S++}}c++;let p=a+h-d+f,b=Math.min(this._bufferService.cols,c-a+d+u-f-_);if(!(!t&&o.slice(a,c).trim()==="")){if(i&&p===0&&n.getCodePoint(0)!==32){let g=s.lines.get(e[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){let O=this._bufferService.cols-S.start;p-=O,b+=O}}}if(r&&p+b===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=s.lines.get(e[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let S=this._getWordAt([0,e[1]+1],!1,!1,!0);S&&(b+=S.length)}}return{start:p,length:b}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=nf(i,this._bufferService.cols)}};Ac=vt([ue(3,li),ue(4,wn),ue(5,Ou),ue(6,hi),ue(7,Jr),ue(8,Zr)],Ac);var of=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},af=class{constructor(){this._color=new of,this._css=new of}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},xt=Object.freeze((()=>{let e=[lt.toColor("#2e3436"),lt.toColor("#cc0000"),lt.toColor("#4e9a06"),lt.toColor("#c4a000"),lt.toColor("#3465a4"),lt.toColor("#75507b"),lt.toColor("#06989a"),lt.toColor("#d3d7cf"),lt.toColor("#555753"),lt.toColor("#ef2929"),lt.toColor("#8ae234"),lt.toColor("#fce94f"),lt.toColor("#729fcf"),lt.toColor("#ad7fa8"),lt.toColor("#34e2e2"),lt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let r=t[i/36%6|0],s=t[i/6%6|0],n=t[i%6];e.push({css:wt.toCss(r,s,n),rgba:wt.toRgba(r,s,n)})}for(let i=0;i<24;i++){let r=8+i*10;e.push({css:wt.toCss(r,r,r),rgba:wt.toRgba(r,r,r)})}return e})()),Is=lt.toColor("#ffffff"),Po=lt.toColor("#000000"),lf=lt.toColor("#ffffff"),hf=Po,Co={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},R1=Is,Mc=class extends He{constructor(e){super(),this._optionsService=e,this._contrastCache=new af,this._halfContrastCache=new af,this._onChangeColors=this._register(new te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Is,background:Po,cursor:lf,cursorAccent:hf,selectionForeground:void 0,selectionBackgroundTransparent:Co,selectionBackgroundOpaque:Je.blend(Po,Co),selectionInactiveBackgroundTransparent:Co,selectionInactiveBackgroundOpaque:Je.blend(Po,Co),scrollbarSliderBackground:Je.opacity(Is,.2),scrollbarSliderHoverBackground:Je.opacity(Is,.4),scrollbarSliderActiveBackground:Je.opacity(Is,.5),overviewRulerBorder:Is,ansi:xt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Qe(e.foreground,Is),t.background=Qe(e.background,Po),t.cursor=Je.blend(t.background,Qe(e.cursor,lf)),t.cursorAccent=Je.blend(t.background,Qe(e.cursorAccent,hf)),t.selectionBackgroundTransparent=Qe(e.selectionBackground,Co),t.selectionBackgroundOpaque=Je.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Qe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Je.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Qe(e.selectionForeground,tf):void 0,t.selectionForeground===tf&&(t.selectionForeground=void 0),Je.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Je.opacity(t.selectionBackgroundTransparent,.3)),Je.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Je.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Qe(e.scrollbarSliderBackground,Je.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Qe(e.scrollbarSliderHoverBackground,Je.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Qe(e.scrollbarSliderActiveBackground,Je.opacity(t.foreground,.5)),t.overviewRulerBorder=Qe(e.overviewRulerBorder,R1),t.ansi=xt.slice(),t.ansi[0]=Qe(e.black,xt[0]),t.ansi[1]=Qe(e.red,xt[1]),t.ansi[2]=Qe(e.green,xt[2]),t.ansi[3]=Qe(e.yellow,xt[3]),t.ansi[4]=Qe(e.blue,xt[4]),t.ansi[5]=Qe(e.magenta,xt[5]),t.ansi[6]=Qe(e.cyan,xt[6]),t.ansi[7]=Qe(e.white,xt[7]),t.ansi[8]=Qe(e.brightBlack,xt[8]),t.ansi[9]=Qe(e.brightRed,xt[9]),t.ansi[10]=Qe(e.brightGreen,xt[10]),t.ansi[11]=Qe(e.brightYellow,xt[11]),t.ansi[12]=Qe(e.brightBlue,xt[12]),t.ansi[13]=Qe(e.brightMagenta,xt[13]),t.ansi[14]=Qe(e.brightCyan,xt[14]),t.ansi[15]=Qe(e.brightWhite,xt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<i;r++)t.ansi[r+16]=Qe(e.extendedAnsi[r],xt[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Mc=vt([ue(0,hi)],Mc);function Qe(e,t){if(e!==void 0)try{return lt.toColor(e)}catch{}return t}var P1=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},A1=class{constructor(){this._services=new P1,this._services.set(Mu,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=kw(e).sort((n,o)=>n.index-o.index),r=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);r.push(o)}let s=i.length>0?i[0].index:t.length;if(t.length!==s)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${s+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},M1={trace:0,debug:1,info:2,warn:3,error:4,off:5},O1="xterm.js: ",Oc=class extends He{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=M1[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":O1)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Oc=vt([ue(0,hi)],Oc);var cf=class extends He{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+i.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<i.length;r++)this._array[this._getCyclicIndex(e+r)]=i[r];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let r=this._length+i.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let s=t-1;s>=0;s--)this.set(e+s+i,this.get(e+s));let r=e+t+i-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+i,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},We=3,St=Object.freeze(new ga),La=0,fh=2,Ao=class Kp{constructor(t,i,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*We);let s=i||Ki.fromCharData([0,lp,1,0]);for(let n=0;n<t;++n)this.setCell(n,s);this.length=t}get(t){let i=this._data[t*We+0],r=i&2097151;return[this._data[t*We+1],i&2097152?this._combined[t]:r?os(r):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,i){this._data[t*We+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*We+0]=t|2097152|i[2]<<22):this._data[t*We+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*We+0]>>22}hasWidth(t){return this._data[t*We+0]&12582912}getFg(t){return this._data[t*We+1]}getBg(t){return this._data[t*We+2]}hasContent(t){return this._data[t*We+0]&4194303}getCodePoint(t){let i=this._data[t*We+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*We+0]&2097152}getString(t){let i=this._data[t*We+0];return i&2097152?this._combined[t]:i&2097151?os(i&2097151):""}isProtected(t){return this._data[t*We+2]&536870912}loadCell(t,i){return La=t*We,i.content=this._data[La+0],i.fg=this._data[La+1],i.bg=this._data[La+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*We+0]=i.content,this._data[t*We+1]=i.fg,this._data[t*We+2]=i.bg}setCellFromCodepoint(t,i,r,s){s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*We+0]=i|r<<22,this._data[t*We+1]=s.fg,this._data[t*We+2]=s.bg}addCodepointToCell(t,i,r){let s=this._data[t*We+0];s&2097152?this._combined[t]+=os(i):s&2097151?(this._combined[t]=os(s&2097151)+os(i),s&=-2097152,s|=2097152):s=i|1<<22,r&&(s&=-12582913,s|=r<<22),this._data[t*We+0]=s}insertCells(t,i,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length-t){let s=new Ki;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,s));for(let n=0;n<i;++n)this.setCell(t+n,r)}else for(let s=t;s<this.length;++s)this.setCell(s,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,i,r){if(t%=this.length,i<this.length-t){let s=new Ki;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,s));for(let n=this.length-i;n<this.length;++n)this.setCell(n,r)}else for(let s=t;s<this.length;++s)this.setCell(s,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,i,r,s=!1){if(s){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,r);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,r);t<i&&t<this.length;)this.setCell(t++,r)}resize(t,i){if(t===this.length)return this._data.length*4*fh<this._data.buffer.byteLength;let r=t*We;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let s=new Uint32Array(r);s.set(this._data),this._data=s}for(let s=this.length;s<t;++s)this.setCell(s,i)}else{this._data=this._data.subarray(0,r);let s=Object.keys(this._combined);for(let o=0;o<s.length;o++){let a=parseInt(s[o],10);a>=t&&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>=t&&delete this._extendedAttrs[a]}}return this.length=t,r*4*fh<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*fh<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new Kp(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*We+0]&4194303)return t+(this._data[t*We+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*We+0]&4194303||this._data[t*We+2]&50331648)return t+(this._data[t*We+0]>>22);return 0}copyCellsFrom(t,i,r,s,n){let o=t._data;if(n)for(let c=s-1;c>=0;c--){for(let h=0;h<We;h++)this._data[(r+c)*We+h]=o[(i+c)*We+h];o[(i+c)*We+2]&268435456&&(this._extendedAttrs[r+c]=t._extendedAttrs[i+c])}else for(let c=0;c<s;c++){for(let h=0;h<We;h++)this._data[(r+c)*We+h]=o[(i+c)*We+h];o[(i+c)*We+2]&268435456&&(this._extendedAttrs[r+c]=t._extendedAttrs[i+c])}let a=Object.keys(t._combined);for(let c=0;c<a.length;c++){let h=parseInt(a[c],10);h>=i&&(this._combined[h-i+r]=t._combined[h])}}translateToString(t,i,r,s){i=i??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),s&&(s.length=0);let n="";for(;i<r;){let o=this._data[i*We+0],a=o&2097151,c=o&2097152?this._combined[i]:a?os(a):bs;if(n+=c,s)for(let h=0;h<c.length;++h)s.push(i);i+=o>>22||1}return s&&s.push(i),n}};function L1(e,t,i,r,s,n){let o=[];for(let a=0;a<e.length-1;a++){let c=a,h=e.get(++c);if(!h.isWrapped)continue;let d=[e.get(a)];for(;c<e.length&&h.isWrapped;)d.push(h),h=e.get(++c);if(!n&&r>=a&&r<c){a+=d.length-1;continue}let u=0,f=Qo(d,u,t),_=1,p=0;for(;_<d.length;){let g=Qo(d,_,t),S=g-p,O=i-f,C=Math.min(S,O);d[u].copyCellsFrom(d[_],p,f,C,!1),f+=C,f===i&&(u++,f=0),p+=C,p===g&&(_++,p=0),f===0&&u!==0&&d[u-1].getWidth(i-1)===2&&(d[u].copyCellsFrom(d[u-1],i-1,f++,1,!1),d[u-1].setCell(i-1,s))}d[u].replaceCells(f,i,s);let b=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)b++;b>0&&(o.push(a+d.length-b),o.push(b)),a+=d.length-1}return o}function I1(e,t){let i=[],r=0,s=t[r],n=0;for(let o=0;o<e.length;o++)if(s===o){let a=t[++r];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,s=t[++r]}else i.push(o);return{layout:i,countRemoved:n}}function B1(e,t){let i=[];for(let r=0;r<t.length;r++)i.push(e.get(t[r]));for(let r=0;r<i.length;r++)e.set(r,i[r]);e.length=t.length}function N1(e,t,i){let r=[],s=e.map((c,h)=>Qo(e,h,t)).reduce((c,h)=>c+h),n=0,o=0,a=0;for(;a<s;){if(s-a<i){r.push(s-a);break}n+=i;let c=Qo(e,o,t);n>c&&(n-=c,o++);let h=e[o].getWidth(n-1)===2;h&&n--;let d=h?i-1:i;r.push(d),a+=d}return r}function Qo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,s=e[t+1].getWidth(0)===2;return r&&s?i-1:i}var qp=class jp{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=jp._nextId++,this._onDispose=this.register(new te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),bn(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};qp._nextId=1;var F1=qp,Mt={},Bs=Mt.B;Mt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Mt.A={"#":"£"};Mt.B=void 0;Mt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Mt.C=Mt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Mt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Mt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Mt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Mt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Mt.E=Mt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Mt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Mt.H=Mt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Mt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var uf=4294967295,df=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=St.clone(),this.savedCharset=Bs,this.markers=[],this._nullCell=Ki.fromCharData([0,lp,1,0]),this._whitespaceCell=Ki.fromCharData([0,bs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new cf(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new fl),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new fl),this._whitespaceCell}getBlankLine(e,t){return new Ao(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>uf?uf:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=St);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new cf(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(St),r=0,s=this._getCorrectBufferLength(t);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)r+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Ao(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ao(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let o=this.lines.length-s;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=s}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)r+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,r=L1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(St),i);if(r.length>0){let s=I1(this.lines,r);B1(this.lines,s.layout),this._reflowLargerAdjustViewport(e,t,s.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let r=this.getNullCell(St),s=i;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Ao(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(St),s=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),c.unshift(a);if(!i){let C=this.ybase+this.y;if(C>=o&&C<o+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=N1(c,this._cols,e),u=d.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let _=[];for(let C=0;C<u;C++){let y=this.getBlankLine(St,!0);_.push(y)}_.length>0&&(s.push({start:o+c.length+n,newLines:_}),n+=_.length),c.push(..._);let p=d.length-1,b=d[p];b===0&&(p--,b=d[p]);let g=c.length-u-1,S=h;for(;g>=0;){let C=Math.min(S,b);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[g],S-C,b-C,C,!0),b-=C,b===0&&(p--,b=d[p]),S-=C,S===0){g--;let y=Math.max(g,0);S=Qo(c,y,this._cols)}}for(let C=0;C<c.length;C++)d[C]<e&&c[C].setCell(d[C],r);let O=u-f;for(;O-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(s.length>0){let o=[],a=[];for(let b=0;b<this.lines.length;b++)a.push(this.lines.get(b));let c=this.lines.length,h=c-1,d=0,u=s[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let f=0;for(let b=Math.min(this.lines.maxLength-1,c+n-1);b>=0;b--)if(u&&u.start>h+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(b--,u.newLines[g]);b++,o.push({index:h+1,amount:u.newLines.length}),f+=u.newLines.length,u=s[++d]}else this.lines.set(b,a[h--]);let _=0;for(let b=o.length-1;b>=0;b--)o[b].index+=_,this.lines.onInsertEmitter.fire(o[b]),_+=o[b].amount;let p=Math.max(0,c+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,i=0,r){let s=this.lines.get(e);return s?s.translateToString(t,i,r):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new F1(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},W1=class extends He{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new te),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 df(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new df(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Yp=2,Vp=1,Lc=class extends He{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Yp),this.rows=Math.max(e.rawOptions.rows||0,Vp),this.buffers=this._register(new W1(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=i.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let s=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(r):i.lines.push(r.clone()):i.lines.splice(n+1,0,r.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-s+1;i.lines.shiftElements(s+1,o-1,-1),i.lines.set(n,r.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let r=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),r!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Lc=vt([ue(0,hi)],Lc);var Dn={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:pl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},H1=["normal","bold","100","200","300","400","500","600","700","800","900"],z1=class extends He{constructor(e){super(),this._onOptionChange=this._register(new te),this.onOptionChange=this._onOptionChange.event;let t={...Dn};for(let i in e)if(i in t)try{let r=e[i];t[i]=this._sanitizeAndValidateOption(i,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(nt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Dn))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,r)=>{if(!(i in Dn))throw new Error(`No option with key "${i}"`);r=this._sanitizeAndValidateOption(i,r),this.rawOptions[i]!==r&&(this.rawOptions[i]=r,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let r={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Dn[e]),!U1(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Dn[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=H1.includes(t)?t:Dn[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function U1(e){return e==="block"||e==="underline"||e==="bar"}function Mo(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let r in e)i[r]=t<=1?e[r]:e[r]&&Mo(e[r],t-1);return i}var ff=Object.freeze({insertMode:!1}),_f=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Ic=class extends He{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new te),this.onData=this._onData.event,this._onUserInput=this._register(new te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Mo(ff),this.decPrivateModes=Mo(_f)}reset(){this.modes=Mo(ff),this.decPrivateModes=Mo(_f)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Ic=vt([ue(0,li),ue(1,fp),ue(2,hi)],Ic);var vf={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function _h(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var vh=String.fromCharCode,pf={DEFAULT:e=>{let t=[_h(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${vh(t[0])}${vh(t[1])}${vh(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${_h(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${_h(e,!0)};${e.x};${e.y}${t}`}},Bc=class extends He{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new te),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(vf))this.addProtocol(r,vf[r]);for(let r of Object.keys(pf))this.addEncoding(r,pf[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let r=t/i,s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=r+0,Math.abs(e.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Bc=vt([ue(0,li),ue(1,wn),ue(2,hi)],Bc);var ph=[[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]],K1=[[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]],Et;function q1(e,t){let i=0,r=t.length-1,s;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=i;)if(s=i+r>>1,e>t[s][1])i=s+1;else if(e<t[s][0])r=s-1;else return!0;return!1}var j1=class{constructor(){if(this.version="6",!Et){Et=new Uint8Array(65536),Et.fill(1),Et[0]=0,Et.fill(0,1,32),Et.fill(0,127,160),Et.fill(2,4352,4448),Et[9001]=2,Et[9002]=2,Et.fill(2,11904,42192),Et[12351]=1,Et.fill(2,44032,55204),Et.fill(2,63744,64256),Et.fill(2,65040,65050),Et.fill(2,65072,65136),Et.fill(2,65280,65377),Et.fill(2,65504,65511);for(let e=0;e<ph.length;++e)Et.fill(0,ph[e][0],ph[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Et[e]:q1(e,K1)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),r=i===0&&t!==0;if(r){let s=qs.extractWidth(t);s===0?r=!1:s>i&&(i=s)}return qs.createPropertyValue(0,i,r)}},qs=class Qa{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new te,this.onChange=this._onChange.event;let t=new j1;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,r=!1){return(t&16777215)<<3|(i&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,r=0,s=t.length;for(let n=0;n<s;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=s)return i+this.wcwidth(o);let h=t.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,r),c=Qa.extractWidth(a);Qa.extractShouldJoin(a)&&(c-=Qa.extractWidth(r)),i+=c,r=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Y1=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function gf(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var ko=2147483647,V1=256,Gp=class Nc{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>V1)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Nc;if(!t.length)return i;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let s=t[r];if(Array.isArray(s))for(let n=0;n<s.length;++n)i.addSubParam(s[n]);else i.addParam(s)}return i}clone(){let t=new Nc(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let r=this._subParamsIdx[i]>>8,s=this._subParamsIdx[i]&255;s-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,s))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ko?ko:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>ko?ko:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-i>0?this._subParams.subarray(i,r):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let r=this._subParamsIdx[i]>>8,s=this._subParamsIdx[i]&255;s-r>0&&(t[i]=this._subParams.slice(r,s))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,s=r[i-1];r[i-1]=~s?Math.min(s*10+t,ko):t}},xo=[],G1=class{constructor(){this._state=0,this._active=xo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=xo}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=xo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||xo,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",zl(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].end(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=xo,this._id=-1,this._state=0}}},yi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=zl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Eo=[],X1=class{constructor(){this._handlers=Object.create(null),this._active=Eo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Eo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Eo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Eo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",zl(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].unhook(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=Eo,this._ident=0}},Oo=new Gp;Oo.addParam(0);var mf=class{constructor(e){this._handler=e,this._data="",this._params=Oo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Oo,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=zl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=Oo,this._data="",this._hitLimit=!1,i));return this._params=Oo,this._data="",this._hitLimit=!1,t}},$1=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,r){this.table[t<<8|e]=i<<4|r}addMany(e,t,i,r){for(let s=0;s<e.length;s++)this.table[t<<8|e[s]]=i<<4|r}},Ni=160,Q1=(function(){let e=new $1(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),i=(a,c)=>t.slice(a,c),r=i(32,127),s=i(0,24);s.push(25),s.push.apply(s,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(r,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(s,0,3,0),e.addMany(s,1,3,1),e.add(127,1,0,1),e.addMany(s,8,0,8),e.addMany(s,3,3,3),e.add(127,3,0,3),e.addMany(s,4,3,4),e.add(127,4,0,4),e.addMany(s,6,3,6),e.addMany(s,5,3,5),e.add(127,5,0,5),e.addMany(s,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(s,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(s,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(s,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(s,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(s,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(s,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Ni,0,2,0),e.add(Ni,8,5,8),e.add(Ni,6,0,6),e.add(Ni,11,0,11),e.add(Ni,13,13,13),e})(),Z1=class extends He{constructor(e=Q1){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Gp,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(nt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new G1),this._dcsParser=this._register(new X1),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let s=0;s<e.intermediates.length;++s){let n=e.intermediates.charCodeAt(s);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=r,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let r=this._escHandlers[i];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let r=this._csiHandlers[i];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,r,s){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=r,this._parseStack.chunkPos=s}parse(e,t,i){let r=0,s=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===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,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&c>-1){for(;c>=0&&(o=a[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&c>-1){for(;c>=0&&(o=a[c](),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,i),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,i),o)return o;r===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<t;++a){switch(r=e[a],s=this._transitions.table[this.currentState<<8|(r<160?r:Ni)],s>>4){case 2:for(let f=a+1;;++f){if(f>=t||(r=e[f])<32||r>126&&r<Ni){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<Ni){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<Ni){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<Ni){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|r],h=c?c.length-1:-1;for(;h>=0&&(o=c[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(3,c,h,s,a),o;h<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++a<t&&(r=e[a])>47&&r<60);a--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let d=this._escHandlers[this._collect<<8|r],u=d?d.length-1:-1;for(;u>=0&&(o=d[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,d,u,s,a),o;u<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(r=e[f])===24||r===26||r===27||r>127&&r<Ni){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,s,a),o;r===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=a+1;;f++)if(f>=t||(r=e[f])<32||r>127&&r<Ni){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,s,a),o;r===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=s&15}}},J1=/^([\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})$/,eC=/^[\da-f]+$/;function bf(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=J1.exec(t);if(i){let r=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/r*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/r*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),eC.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,r=[0,0,0];for(let s=0;s<3;++s){let n=parseInt(t.slice(i*s,i*s+i),16);r[s]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return r}}function gh(e,t){let i=e.toString(16),r=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function tC(e,t=16){let[i,r,s]=e;return`rgb:${gh(i,t)}/${gh(r,t)}/${gh(s,t)}`}var iC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},rs=131072,yf=10;function Sf(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var wf=5e3,Cf=0,rC=class extends He{constructor(e,t,i,r,s,n,o,a,c=new Z1){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=r,this._optionsService=s,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ww,this._utf8Decoder=new Cw,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=St.clone(),this._eraseAttrDataInternal=St.clone(),this._onRequestBell=this._register(new te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new te),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 Fc(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:d.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,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:d,data:u})}),this._parser.setDcsHandlerFallback((h,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:d,payload:u})}),this._parser.setPrintHandler((h,d,u)=>this.print(h,d,u)),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(U.BEL,()=>this.bell()),this._parser.setExecuteHandler(U.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(U.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(U.BS,()=>this.backspace()),this._parser.setExecuteHandler(U.HT,()=>this.tab()),this._parser.setExecuteHandler(U.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(U.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Xa.IND,()=>this.index()),this._parser.setExecuteHandler(Xa.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Xa.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new yi(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new yi(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new yi(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new yi(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new yi(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new yi(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new yi(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new yi(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new yi(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new yi(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new yi(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new yi(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 Mt)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 mf((h,d)=>this.requestStatusString(h,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),wf))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${wf} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,r=this._activeBuffer.x,s=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;r=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>rs&&(n=this._parseStack.position+rs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<rs&&(this._parseBuffer=new Uint32Array(Math.min(e.length,rs))),o||this._dirtyRowTracker.clearRange(),e.length>rs)for(let h=n;h<e.length;h+=rs){let d=h+rs<e.length?h+rs:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(h,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,u))return this._preserveStack(r,s,u,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(r,s,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==r||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let r,s,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let _=t;_<i;++_){if(r=e[_],r<127&&n){let S=n[String.fromCharCode(r)];S&&(r=S.charCodeAt(0))}let p=this._unicodeService.charProperties(r,f);s=qs.extractWidth(p);let b=qs.extractShouldJoin(p),g=b?qs.extractWidth(f):0;if(f=p,o&&this._onA11yChar.fire(os(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-g>a){if(c){let S=u,O=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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&u instanceof Ao&&u.copyCellsFrom(S,O,0,g,!1);O<a;)S.setCellFromCodepoint(O++,0,1,d)}else if(this._activeBuffer.x=a-1,s===2)continue}if(b&&this._activeBuffer.x){let S=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-S,r,s);for(let O=s-g;--O>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,s-g,this._activeBuffer.getNullCell(d)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,r,s,d),s>0)for(;--s;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&i-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Sf(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new mf(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new yi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,r=!1,s=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),s),r&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&r.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(s-1,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}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(St));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,r=qs.extractWidth(t),s=this._activeBuffer.x-r,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),o=new Uint32Array(n.length*i),a=0;for(let h=0;h<n.length;){let d=n.codePointAt(h)||0;o[a++]=d,h+=d>65535?2:1}let c=a;for(let h=1;h<i;++h)o.copyWithin(c,0,a),c+=a;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(U.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(U.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(U.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(U.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(U.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Bs),this._charsetService.setgCharset(1,Bs),this._charsetService.setgCharset(2,Bs),this._charsetService.setgCharset(3,Bs);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let r=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:h,alt:d}=a,u=this._optionsService.rawOptions,f=(b,g)=>(o.triggerDataEvent(`${U.ESC}[${t?"":"?"}${b};${g}$y`),!0),_=b=>b?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,_(o.modes.insertMode)):p===12?f(p,3):p===20?f(p,_(u.convertEol)):f(p,0):p===1?f(p,_(r.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,_(r.origin)):p===7?f(p,_(r.wraparound)):p===8?f(p,3):p===9?f(p,_(s==="X10")):p===12?f(p,_(u.cursorBlink)):p===25?f(p,_(!o.isCursorHidden)):p===45?f(p,_(r.reverseWraparound)):p===66?f(p,_(r.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,_(s==="VT200")):p===1002?f(p,_(s==="DRAG")):p===1003?f(p,_(s==="ANY")):p===1004?f(p,_(r.sendFocus)):p===1005?f(p,4):p===1006?f(p,_(n==="SGR")):p===1015?f(p,4):p===1016?f(p,_(n==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,_(h===d)):p===2004?f(p,_(r.bracketedPasteMode)):p===2026?f(p,_(r.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,i,r,s){return t===2?(e|=50331648,e&=-16777216,e|=ga.fromColorRGB([i,r,s])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let r=[0,0,-1,0,0,0],s=0,n=0;do{if(r[n+s]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do r[1]===5&&(s=1),r[n+a+1+s]=o[a];while(++a<o.length&&a+n+1+s<r.length);break}if(r[1]===5&&n+s>=2||r[1]===2&&n+s>=5)break;r[1]&&(s=1)}while(++n+t<e.length&&n+s<r.length);for(let o=2;o<r.length;++o)r[o]===-1&&(r[o]=0);switch(r[0]){case 38:i.fg=this._updateAttrColor(i.fg,r[1],r[3],r[4],r[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,r[1],r[3],r[4],r[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,r[1],r[3],r[4],r[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=St.fg,e.bg=St.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,r=this._curAttrData;for(let s=0;s<t;s++)i=e.params[s],i>=30&&i<=37?(r.fg&=-50331904,r.fg|=16777216|i-30):i>=40&&i<=47?(r.bg&=-50331904,r.bg|=16777216|i-40):i>=90&&i<=97?(r.fg&=-50331904,r.fg|=16777216|i-90|8):i>=100&&i<=107?(r.bg&=-50331904,r.bg|=16777216|i-100|8):i===0?this._processSGR0(r):i===1?r.fg|=134217728:i===3?r.bg|=67108864:i===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(s)?e.getSubParams(s)[0]:1,r)):i===5?r.fg|=536870912:i===7?r.fg|=67108864:i===8?r.fg|=1073741824:i===9?r.fg|=2147483648:i===2?r.bg|=134217728:i===21?this._processUnderline(2,r):i===22?(r.fg&=-134217729,r.bg&=-134217729):i===23?r.bg&=-67108865:i===24?(r.fg&=-268435457,this._processUnderline(0,r)):i===25?r.fg&=-536870913:i===27?r.fg&=-67108865:i===28?r.fg&=-1073741825:i===29?r.fg&=2147483647:i===39?(r.fg&=-67108864,r.fg|=St.fg&16777215):i===49?(r.bg&=-67108864,r.bg|=St.bg&16777215):i===38||i===48||i===58?s+=this._extractColor(e,s,r):i===53?r.bg|=1073741824:i===55?r.bg&=-1073741825:i===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):i===100?(r.fg&=-67108864,r.fg|=St.fg&16777215,r.bg&=-67108864,r.bg|=St.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${U.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${U.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${U.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=St.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Sf(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${U.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>yf&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>yf&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let r=i.shift(),s=i.shift();if(/^\d+$/.exec(r)){let n=parseInt(r);if(kf(n))if(s==="?")t.push({type:0,index:n});else{let o=bf(s);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(i,r):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),r,s=i.findIndex(n=>n.startsWith("id="));return s!==-1&&(r=i[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let r=0;r<i.length&&!(t>=this._specialColors.length);++r,++t)if(i[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let s=bf(i[r]);s&&this._onColor.fire([{type:1,index:this._specialColors[t],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let r=0;r<i.length;++r)if(/^\d+$/.exec(i[r])){let s=parseInt(i[r]);kf(s)&&t.push({type:2,index:s})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Bs),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(iC[e[0]],Mt[e[1]]||Bs),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=St.clone(),this._eraseAttrDataInternal=St.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ki;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(i);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${U.ESC}${o}${U.ESC}\\`),!0),r=this._bufferService.buffer,s=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Fc=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Cf=e,e=t,t=Cf),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Fc=vt([ue(0,li)],Fc);function kf(e){return 0<=e&&e<256}var sC=5e7,xf=12,nC=50,oC=class extends He{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>sC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],s=this._action(r,t);if(s){let o=a=>performance.now()-i>=xf?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);s.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-i>=xf)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>nC&&(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()}},Wc=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),c={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._dataByLinkId.set(c.id,c),c.id}let i=e,r=this._getEntryIdKey(i),s=this._entriesWithId.get(r);if(s)return this.addLineToLink(s.id,t.ybase+t.y),s.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);i.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(i,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Wc=vt([ue(0,li)],Wc);var Ef=!1,aC=class extends He{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ho),this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onData=this._register(new te),this.onData=this._onData.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new te),this._instantiationService=new A1,this.optionsService=this._register(new z1(e)),this._instantiationService.setService(hi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Lc)),this._instantiationService.setService(li,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Oc)),this._instantiationService.setService(fp,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Ic)),this._instantiationService.setService(wn,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Bc)),this._instantiationService.setService(dp,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(qs)),this._instantiationService.setService(Dw,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Y1),this._instantiationService.setService(Ew,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wc),this._instantiationService.setService(_p,this._oscLinkService),this._inputHandler=this._register(new rC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Qt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Qt.forward(this._bufferService.onResize,this._onResize)),this._register(Qt.forward(this.coreService.onData,this._onData)),this._register(Qt.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 oC((t,i)=>this._inputHandler.parse(t,i))),this._register(Qt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new te),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Ef&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ef=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Yp),t=Math.max(t,Vp),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(gf.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(gf(this._bufferService),!1))),this._windowsWrappingHeuristics.value=nt(()=>{for(let t of e)t.dispose()})}}},lC={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 hC(e,t,i,r){var o;let s={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?s.key=U.ESC+"OA":s.key=U.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?s.key=U.ESC+"OD":s.key=U.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?s.key=U.ESC+"OC":s.key=U.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?s.key=U.ESC+"OB":s.key=U.ESC+"[B");break;case 8:s.key=e.ctrlKey?"\b":U.DEL,e.altKey&&(s.key=U.ESC+s.key);break;case 9:if(e.shiftKey){s.key=U.ESC+"[Z";break}s.key=U.HT,s.cancel=!0;break;case 13:s.key=e.altKey?U.ESC+U.CR:U.CR,s.cancel=!0;break;case 27:s.key=U.ESC,e.altKey&&(s.key=U.ESC+U.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;n?s.key=U.ESC+"[1;"+(n+1)+"D":t?s.key=U.ESC+"OD":s.key=U.ESC+"[D";break;case 39:if(e.metaKey)break;n?s.key=U.ESC+"[1;"+(n+1)+"C":t?s.key=U.ESC+"OC":s.key=U.ESC+"[C";break;case 38:if(e.metaKey)break;n?s.key=U.ESC+"[1;"+(n+1)+"A":t?s.key=U.ESC+"OA":s.key=U.ESC+"[A";break;case 40:if(e.metaKey)break;n?s.key=U.ESC+"[1;"+(n+1)+"B":t?s.key=U.ESC+"OB":s.key=U.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(s.key=U.ESC+"[2~");break;case 46:n?s.key=U.ESC+"[3;"+(n+1)+"~":s.key=U.ESC+"[3~";break;case 36:n?s.key=U.ESC+"[1;"+(n+1)+"H":t?s.key=U.ESC+"OH":s.key=U.ESC+"[H";break;case 35:n?s.key=U.ESC+"[1;"+(n+1)+"F":t?s.key=U.ESC+"OF":s.key=U.ESC+"[F";break;case 33:e.shiftKey?s.type=2:e.ctrlKey?s.key=U.ESC+"[5;"+(n+1)+"~":s.key=U.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:e.ctrlKey?s.key=U.ESC+"[6;"+(n+1)+"~":s.key=U.ESC+"[6~";break;case 112:n?s.key=U.ESC+"[1;"+(n+1)+"P":s.key=U.ESC+"OP";break;case 113:n?s.key=U.ESC+"[1;"+(n+1)+"Q":s.key=U.ESC+"OQ";break;case 114:n?s.key=U.ESC+"[1;"+(n+1)+"R":s.key=U.ESC+"OR";break;case 115:n?s.key=U.ESC+"[1;"+(n+1)+"S":s.key=U.ESC+"OS";break;case 116:n?s.key=U.ESC+"[15;"+(n+1)+"~":s.key=U.ESC+"[15~";break;case 117:n?s.key=U.ESC+"[17;"+(n+1)+"~":s.key=U.ESC+"[17~";break;case 118:n?s.key=U.ESC+"[18;"+(n+1)+"~":s.key=U.ESC+"[18~";break;case 119:n?s.key=U.ESC+"[19;"+(n+1)+"~":s.key=U.ESC+"[19~";break;case 120:n?s.key=U.ESC+"[20;"+(n+1)+"~":s.key=U.ESC+"[20~";break;case 121:n?s.key=U.ESC+"[21;"+(n+1)+"~":s.key=U.ESC+"[21~";break;case 122:n?s.key=U.ESC+"[23;"+(n+1)+"~":s.key=U.ESC+"[23~";break;case 123:n?s.key=U.ESC+"[24;"+(n+1)+"~":s.key=U.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?s.key=U.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?s.key=U.DEL:e.keyCode===219?s.key=U.ESC:e.keyCode===220?s.key=U.FS:e.keyCode===221&&(s.key=U.GS);else if((!i||r)&&e.altKey&&!e.metaKey){let a=(o=lC[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)s.key=U.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let c=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(c);e.shiftKey&&(h=h.toUpperCase()),s.key=U.ESC+h}else if(e.keyCode===32)s.key=U.ESC+(e.ctrlKey?U.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let c=e.code.slice(3,4);e.shiftKey||(c=c.toLowerCase()),s.key=U.ESC+c,s.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?s.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(s.key=U.US),e.key==="@"&&(s.key=U.NUL));break}return s}var pt=0,cC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gl,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((s,n)=>this._getKey(s)-this._getKey(n)),t=0,i=0,r=new Array(this._array.length+this._insertedValues.length);for(let s=0;s<r.length;s++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(r[s]=e[t],t++):r[s]=this._array[i++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(pt=this._search(t),pt===-1)||this._getKey(this._array[pt])!==t)return!1;do if(this._array[pt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(pt),!0;while(++pt<this._array.length&&this._getKey(this._array[pt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((s,n)=>s-n),t=0,i=new Array(this._array.length-e.length),r=0;for(let s=0;s<this._array.length;s++)e[t]===s?t++:i[r++]=this._array[s];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pt=this._search(e),!(pt<0||pt>=this._array.length)&&this._getKey(this._array[pt])===e))do yield this._array[pt];while(++pt<this._array.length&&this._getKey(this._array[pt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pt=this._search(e),!(pt<0||pt>=this._array.length)&&this._getKey(this._array[pt])===e))do t(this._array[pt]);while(++pt<this._array.length&&this._getKey(this._array[pt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let r=t+i>>1,s=this._getKey(this._array[r]);if(s>e)i=r-1;else if(s<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},mh=0,Df=0,uC=class extends He{constructor(){super(),this._decorations=new cC(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(nt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new dC(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let r=0,s=0;for(let n of this._decorations.getKeyIterator(t))r=n.options.x??0,s=r+(n.options.width??1),e>=r&&e<s&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,r){this._decorations.forEachByKey(t,s=>{mh=s.options.x??0,Df=mh+(s.options.width??1),e>=mh&&e<Df&&(!i||(s.options.layer??"bottom")===i)&&r(s)})}},dC=class extends xs{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new te),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=lt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=lt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},fC=1e3,_C=class{constructor(e,t=fC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let s=r-this._lastRefreshMs,n=this._debounceThresholdMS-s;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 e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Tf=20,ml=class extends He{constructor(e,t,i,r){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.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=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new _C(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(`
38
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),zu&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r||!t?!1:this._areCoordsInSelection(t,i,r)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r?!1:this._areCoordsInSelection([e,t],i,r)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var s,n;let i=(n=(s=this._linkifier.currentLink)==null?void 0:s.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=nf(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Hu(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-dh),dh),t/=dh,t/Math.abs(t)+Math.round(t*(k1-1)))}shouldForceSelection(e){return pl?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),x1)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(pl&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let r=i.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<E1&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let r=p1(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let r=0;t>=r;r++){let s=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:s>1&&t!==r&&(i+=s-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,n=s.lines.get(e[1]);if(!n)return;let o=s.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),c=a,h=e[0]-a,d=0,u=0,f=0,_=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;c<o.length&&o.charAt(c+1)===" ";)c++}else{let g=e[0],y=e[0];n.getWidth(g)===0&&(d++,g--),n.getWidth(y)===2&&(u++,y++);let O=n.getString(y).length;for(O>1&&(_+=O-1,c+=O-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let R=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):R>1&&(f+=R-1,a-=R-1),a--,g--}for(;y<n.length&&c+1<o.length&&!this._isCharWordSeparator(n.loadCell(y+1,this._workCell));){n.loadCell(y+1,this._workCell);let R=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,y++):R>1&&(_+=R-1,c+=R-1),c++,y++}}c++;let p=a+h-d+f,b=Math.min(this._bufferService.cols,c-a+d+u-f-_);if(!(!t&&o.slice(a,c).trim()==="")){if(i&&p===0&&n.getCodePoint(0)!==32){let g=s.lines.get(e[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let O=this._bufferService.cols-y.start;p-=O,b+=O}}}if(r&&p+b===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=s.lines.get(e[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(b+=y.length)}}return{start:p,length:b}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=nf(i,this._bufferService.cols)}};Ac=vt([ue(3,li),ue(4,wn),ue(5,Ou),ue(6,hi),ue(7,Jr),ue(8,Zr)],Ac);var of=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},af=class{constructor(){this._color=new of,this._css=new of}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},xt=Object.freeze((()=>{let e=[lt.toColor("#2e3436"),lt.toColor("#cc0000"),lt.toColor("#4e9a06"),lt.toColor("#c4a000"),lt.toColor("#3465a4"),lt.toColor("#75507b"),lt.toColor("#06989a"),lt.toColor("#d3d7cf"),lt.toColor("#555753"),lt.toColor("#ef2929"),lt.toColor("#8ae234"),lt.toColor("#fce94f"),lt.toColor("#729fcf"),lt.toColor("#ad7fa8"),lt.toColor("#34e2e2"),lt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let r=t[i/36%6|0],s=t[i/6%6|0],n=t[i%6];e.push({css:wt.toCss(r,s,n),rgba:wt.toRgba(r,s,n)})}for(let i=0;i<24;i++){let r=8+i*10;e.push({css:wt.toCss(r,r,r),rgba:wt.toRgba(r,r,r)})}return e})()),Is=lt.toColor("#ffffff"),Po=lt.toColor("#000000"),lf=lt.toColor("#ffffff"),hf=Po,Co={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},R1=Is,Mc=class extends He{constructor(e){super(),this._optionsService=e,this._contrastCache=new af,this._halfContrastCache=new af,this._onChangeColors=this._register(new te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Is,background:Po,cursor:lf,cursorAccent:hf,selectionForeground:void 0,selectionBackgroundTransparent:Co,selectionBackgroundOpaque:Je.blend(Po,Co),selectionInactiveBackgroundTransparent:Co,selectionInactiveBackgroundOpaque:Je.blend(Po,Co),scrollbarSliderBackground:Je.opacity(Is,.2),scrollbarSliderHoverBackground:Je.opacity(Is,.4),scrollbarSliderActiveBackground:Je.opacity(Is,.5),overviewRulerBorder:Is,ansi:xt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Qe(e.foreground,Is),t.background=Qe(e.background,Po),t.cursor=Je.blend(t.background,Qe(e.cursor,lf)),t.cursorAccent=Je.blend(t.background,Qe(e.cursorAccent,hf)),t.selectionBackgroundTransparent=Qe(e.selectionBackground,Co),t.selectionBackgroundOpaque=Je.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Qe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Je.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Qe(e.selectionForeground,tf):void 0,t.selectionForeground===tf&&(t.selectionForeground=void 0),Je.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Je.opacity(t.selectionBackgroundTransparent,.3)),Je.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Je.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Qe(e.scrollbarSliderBackground,Je.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Qe(e.scrollbarSliderHoverBackground,Je.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Qe(e.scrollbarSliderActiveBackground,Je.opacity(t.foreground,.5)),t.overviewRulerBorder=Qe(e.overviewRulerBorder,R1),t.ansi=xt.slice(),t.ansi[0]=Qe(e.black,xt[0]),t.ansi[1]=Qe(e.red,xt[1]),t.ansi[2]=Qe(e.green,xt[2]),t.ansi[3]=Qe(e.yellow,xt[3]),t.ansi[4]=Qe(e.blue,xt[4]),t.ansi[5]=Qe(e.magenta,xt[5]),t.ansi[6]=Qe(e.cyan,xt[6]),t.ansi[7]=Qe(e.white,xt[7]),t.ansi[8]=Qe(e.brightBlack,xt[8]),t.ansi[9]=Qe(e.brightRed,xt[9]),t.ansi[10]=Qe(e.brightGreen,xt[10]),t.ansi[11]=Qe(e.brightYellow,xt[11]),t.ansi[12]=Qe(e.brightBlue,xt[12]),t.ansi[13]=Qe(e.brightMagenta,xt[13]),t.ansi[14]=Qe(e.brightCyan,xt[14]),t.ansi[15]=Qe(e.brightWhite,xt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<i;r++)t.ansi[r+16]=Qe(e.extendedAnsi[r],xt[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Mc=vt([ue(0,hi)],Mc);function Qe(e,t){if(e!==void 0)try{return lt.toColor(e)}catch{}return t}var P1=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},A1=class{constructor(){this._services=new P1,this._services.set(Mu,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=kw(e).sort((n,o)=>n.index-o.index),r=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);r.push(o)}let s=i.length>0?i[0].index:t.length;if(t.length!==s)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${s+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},M1={trace:0,debug:1,info:2,warn:3,error:4,off:5},O1="xterm.js: ",Oc=class extends He{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=M1[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":O1)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Oc=vt([ue(0,hi)],Oc);var cf=class extends He{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+i.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<i.length;r++)this._array[this._getCyclicIndex(e+r)]=i[r];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let r=this._length+i.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let s=t-1;s>=0;s--)this.set(e+s+i,this.get(e+s));let r=e+t+i-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+i,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},We=3,St=Object.freeze(new ga),La=0,fh=2,Ao=class Kp{constructor(t,i,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*We);let s=i||Ki.fromCharData([0,lp,1,0]);for(let n=0;n<t;++n)this.setCell(n,s);this.length=t}get(t){let i=this._data[t*We+0],r=i&2097151;return[this._data[t*We+1],i&2097152?this._combined[t]:r?os(r):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,i){this._data[t*We+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*We+0]=t|2097152|i[2]<<22):this._data[t*We+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*We+0]>>22}hasWidth(t){return this._data[t*We+0]&12582912}getFg(t){return this._data[t*We+1]}getBg(t){return this._data[t*We+2]}hasContent(t){return this._data[t*We+0]&4194303}getCodePoint(t){let i=this._data[t*We+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*We+0]&2097152}getString(t){let i=this._data[t*We+0];return i&2097152?this._combined[t]:i&2097151?os(i&2097151):""}isProtected(t){return this._data[t*We+2]&536870912}loadCell(t,i){return La=t*We,i.content=this._data[La+0],i.fg=this._data[La+1],i.bg=this._data[La+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*We+0]=i.content,this._data[t*We+1]=i.fg,this._data[t*We+2]=i.bg}setCellFromCodepoint(t,i,r,s){s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*We+0]=i|r<<22,this._data[t*We+1]=s.fg,this._data[t*We+2]=s.bg}addCodepointToCell(t,i,r){let s=this._data[t*We+0];s&2097152?this._combined[t]+=os(i):s&2097151?(this._combined[t]=os(s&2097151)+os(i),s&=-2097152,s|=2097152):s=i|1<<22,r&&(s&=-12582913,s|=r<<22),this._data[t*We+0]=s}insertCells(t,i,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length-t){let s=new Ki;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,s));for(let n=0;n<i;++n)this.setCell(t+n,r)}else for(let s=t;s<this.length;++s)this.setCell(s,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,i,r){if(t%=this.length,i<this.length-t){let s=new Ki;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,s));for(let n=this.length-i;n<this.length;++n)this.setCell(n,r)}else for(let s=t;s<this.length;++s)this.setCell(s,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,i,r,s=!1){if(s){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,r);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,r);t<i&&t<this.length;)this.setCell(t++,r)}resize(t,i){if(t===this.length)return this._data.length*4*fh<this._data.buffer.byteLength;let r=t*We;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let s=new Uint32Array(r);s.set(this._data),this._data=s}for(let s=this.length;s<t;++s)this.setCell(s,i)}else{this._data=this._data.subarray(0,r);let s=Object.keys(this._combined);for(let o=0;o<s.length;o++){let a=parseInt(s[o],10);a>=t&&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>=t&&delete this._extendedAttrs[a]}}return this.length=t,r*4*fh<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*fh<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new Kp(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*We+0]&4194303)return t+(this._data[t*We+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*We+0]&4194303||this._data[t*We+2]&50331648)return t+(this._data[t*We+0]>>22);return 0}copyCellsFrom(t,i,r,s,n){let o=t._data;if(n)for(let c=s-1;c>=0;c--){for(let h=0;h<We;h++)this._data[(r+c)*We+h]=o[(i+c)*We+h];o[(i+c)*We+2]&268435456&&(this._extendedAttrs[r+c]=t._extendedAttrs[i+c])}else for(let c=0;c<s;c++){for(let h=0;h<We;h++)this._data[(r+c)*We+h]=o[(i+c)*We+h];o[(i+c)*We+2]&268435456&&(this._extendedAttrs[r+c]=t._extendedAttrs[i+c])}let a=Object.keys(t._combined);for(let c=0;c<a.length;c++){let h=parseInt(a[c],10);h>=i&&(this._combined[h-i+r]=t._combined[h])}}translateToString(t,i,r,s){i=i??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),s&&(s.length=0);let n="";for(;i<r;){let o=this._data[i*We+0],a=o&2097151,c=o&2097152?this._combined[i]:a?os(a):bs;if(n+=c,s)for(let h=0;h<c.length;++h)s.push(i);i+=o>>22||1}return s&&s.push(i),n}};function L1(e,t,i,r,s,n){let o=[];for(let a=0;a<e.length-1;a++){let c=a,h=e.get(++c);if(!h.isWrapped)continue;let d=[e.get(a)];for(;c<e.length&&h.isWrapped;)d.push(h),h=e.get(++c);if(!n&&r>=a&&r<c){a+=d.length-1;continue}let u=0,f=Qo(d,u,t),_=1,p=0;for(;_<d.length;){let g=Qo(d,_,t),y=g-p,O=i-f,R=Math.min(y,O);d[u].copyCellsFrom(d[_],p,f,R,!1),f+=R,f===i&&(u++,f=0),p+=R,p===g&&(_++,p=0),f===0&&u!==0&&d[u-1].getWidth(i-1)===2&&(d[u].copyCellsFrom(d[u-1],i-1,f++,1,!1),d[u-1].setCell(i-1,s))}d[u].replaceCells(f,i,s);let b=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)b++;b>0&&(o.push(a+d.length-b),o.push(b)),a+=d.length-1}return o}function I1(e,t){let i=[],r=0,s=t[r],n=0;for(let o=0;o<e.length;o++)if(s===o){let a=t[++r];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,s=t[++r]}else i.push(o);return{layout:i,countRemoved:n}}function B1(e,t){let i=[];for(let r=0;r<t.length;r++)i.push(e.get(t[r]));for(let r=0;r<i.length;r++)e.set(r,i[r]);e.length=t.length}function N1(e,t,i){let r=[],s=e.map((c,h)=>Qo(e,h,t)).reduce((c,h)=>c+h),n=0,o=0,a=0;for(;a<s;){if(s-a<i){r.push(s-a);break}n+=i;let c=Qo(e,o,t);n>c&&(n-=c,o++);let h=e[o].getWidth(n-1)===2;h&&n--;let d=h?i-1:i;r.push(d),a+=d}return r}function Qo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,s=e[t+1].getWidth(0)===2;return r&&s?i-1:i}var qp=class jp{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=jp._nextId++,this._onDispose=this.register(new te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),bn(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};qp._nextId=1;var F1=qp,Mt={},Bs=Mt.B;Mt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Mt.A={"#":"£"};Mt.B=void 0;Mt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Mt.C=Mt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Mt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Mt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Mt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Mt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Mt.E=Mt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Mt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Mt.H=Mt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Mt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var uf=4294967295,df=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=St.clone(),this.savedCharset=Bs,this.markers=[],this._nullCell=Ki.fromCharData([0,lp,1,0]),this._whitespaceCell=Ki.fromCharData([0,bs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new cf(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new fl),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new fl),this._whitespaceCell}getBlankLine(e,t){return new Ao(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>uf?uf:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=St);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new cf(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(St),r=0,s=this._getCorrectBufferLength(t);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)r+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Ao(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ao(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let o=this.lines.length-s;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=s}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)r+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,r=L1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(St),i);if(r.length>0){let s=I1(this.lines,r);B1(this.lines,s.layout),this._reflowLargerAdjustViewport(e,t,s.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let r=this.getNullCell(St),s=i;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Ao(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(St),s=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),c.unshift(a);if(!i){let R=this.ybase+this.y;if(R>=o&&R<o+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=N1(c,this._cols,e),u=d.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let _=[];for(let R=0;R<u;R++){let S=this.getBlankLine(St,!0);_.push(S)}_.length>0&&(s.push({start:o+c.length+n,newLines:_}),n+=_.length),c.push(..._);let p=d.length-1,b=d[p];b===0&&(p--,b=d[p]);let g=c.length-u-1,y=h;for(;g>=0;){let R=Math.min(y,b);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[g],y-R,b-R,R,!0),b-=R,b===0&&(p--,b=d[p]),y-=R,y===0){g--;let S=Math.max(g,0);y=Qo(c,S,this._cols)}}for(let R=0;R<c.length;R++)d[R]<e&&c[R].setCell(d[R],r);let O=u-f;for(;O-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(s.length>0){let o=[],a=[];for(let b=0;b<this.lines.length;b++)a.push(this.lines.get(b));let c=this.lines.length,h=c-1,d=0,u=s[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let f=0;for(let b=Math.min(this.lines.maxLength-1,c+n-1);b>=0;b--)if(u&&u.start>h+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(b--,u.newLines[g]);b++,o.push({index:h+1,amount:u.newLines.length}),f+=u.newLines.length,u=s[++d]}else this.lines.set(b,a[h--]);let _=0;for(let b=o.length-1;b>=0;b--)o[b].index+=_,this.lines.onInsertEmitter.fire(o[b]),_+=o[b].amount;let p=Math.max(0,c+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,i=0,r){let s=this.lines.get(e);return s?s.translateToString(t,i,r):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new F1(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},W1=class extends He{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new te),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 df(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new df(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Yp=2,Vp=1,Lc=class extends He{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Yp),this.rows=Math.max(e.rawOptions.rows||0,Vp),this.buffers=this._register(new W1(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=i.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let s=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(r):i.lines.push(r.clone()):i.lines.splice(n+1,0,r.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-s+1;i.lines.shiftElements(s+1,o-1,-1),i.lines.set(n,r.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let r=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),r!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Lc=vt([ue(0,hi)],Lc);var Dn={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:pl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},H1=["normal","bold","100","200","300","400","500","600","700","800","900"],z1=class extends He{constructor(e){super(),this._onOptionChange=this._register(new te),this.onOptionChange=this._onOptionChange.event;let t={...Dn};for(let i in e)if(i in t)try{let r=e[i];t[i]=this._sanitizeAndValidateOption(i,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(nt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Dn))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,r)=>{if(!(i in Dn))throw new Error(`No option with key "${i}"`);r=this._sanitizeAndValidateOption(i,r),this.rawOptions[i]!==r&&(this.rawOptions[i]=r,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let r={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Dn[e]),!U1(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Dn[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=H1.includes(t)?t:Dn[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function U1(e){return e==="block"||e==="underline"||e==="bar"}function Mo(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let r in e)i[r]=t<=1?e[r]:e[r]&&Mo(e[r],t-1);return i}var ff=Object.freeze({insertMode:!1}),_f=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Ic=class extends He{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new te),this.onData=this._onData.event,this._onUserInput=this._register(new te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Mo(ff),this.decPrivateModes=Mo(_f)}reset(){this.modes=Mo(ff),this.decPrivateModes=Mo(_f)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Ic=vt([ue(0,li),ue(1,fp),ue(2,hi)],Ic);var vf={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function _h(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var vh=String.fromCharCode,pf={DEFAULT:e=>{let t=[_h(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${vh(t[0])}${vh(t[1])}${vh(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${_h(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${_h(e,!0)};${e.x};${e.y}${t}`}},Bc=class extends He{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new te),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(vf))this.addProtocol(r,vf[r]);for(let r of Object.keys(pf))this.addEncoding(r,pf[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let r=t/i,s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=r+0,Math.abs(e.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Bc=vt([ue(0,li),ue(1,wn),ue(2,hi)],Bc);var ph=[[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]],K1=[[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]],Et;function q1(e,t){let i=0,r=t.length-1,s;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=i;)if(s=i+r>>1,e>t[s][1])i=s+1;else if(e<t[s][0])r=s-1;else return!0;return!1}var j1=class{constructor(){if(this.version="6",!Et){Et=new Uint8Array(65536),Et.fill(1),Et[0]=0,Et.fill(0,1,32),Et.fill(0,127,160),Et.fill(2,4352,4448),Et[9001]=2,Et[9002]=2,Et.fill(2,11904,42192),Et[12351]=1,Et.fill(2,44032,55204),Et.fill(2,63744,64256),Et.fill(2,65040,65050),Et.fill(2,65072,65136),Et.fill(2,65280,65377),Et.fill(2,65504,65511);for(let e=0;e<ph.length;++e)Et.fill(0,ph[e][0],ph[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Et[e]:q1(e,K1)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),r=i===0&&t!==0;if(r){let s=qs.extractWidth(t);s===0?r=!1:s>i&&(i=s)}return qs.createPropertyValue(0,i,r)}},qs=class Qa{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new te,this.onChange=this._onChange.event;let t=new j1;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,r=!1){return(t&16777215)<<3|(i&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,r=0,s=t.length;for(let n=0;n<s;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=s)return i+this.wcwidth(o);let h=t.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,r),c=Qa.extractWidth(a);Qa.extractShouldJoin(a)&&(c-=Qa.extractWidth(r)),i+=c,r=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Y1=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function gf(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var ko=2147483647,V1=256,Gp=class Nc{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>V1)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Nc;if(!t.length)return i;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let s=t[r];if(Array.isArray(s))for(let n=0;n<s.length;++n)i.addSubParam(s[n]);else i.addParam(s)}return i}clone(){let t=new Nc(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let r=this._subParamsIdx[i]>>8,s=this._subParamsIdx[i]&255;s-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,s))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ko?ko:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>ko?ko:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-i>0?this._subParams.subarray(i,r):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let r=this._subParamsIdx[i]>>8,s=this._subParamsIdx[i]&255;s-r>0&&(t[i]=this._subParams.slice(r,s))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,s=r[i-1];r[i-1]=~s?Math.min(s*10+t,ko):t}},xo=[],G1=class{constructor(){this._state=0,this._active=xo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=xo}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=xo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||xo,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",zl(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].end(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=xo,this._id=-1,this._state=0}}},yi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=zl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Eo=[],X1=class{constructor(){this._handlers=Object.create(null),this._active=Eo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Eo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Eo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Eo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",zl(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].unhook(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=Eo,this._ident=0}},Oo=new Gp;Oo.addParam(0);var mf=class{constructor(e){this._handler=e,this._data="",this._params=Oo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Oo,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=zl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=Oo,this._data="",this._hitLimit=!1,i));return this._params=Oo,this._data="",this._hitLimit=!1,t}},$1=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,r){this.table[t<<8|e]=i<<4|r}addMany(e,t,i,r){for(let s=0;s<e.length;s++)this.table[t<<8|e[s]]=i<<4|r}},Fi=160,Q1=(function(){let e=new $1(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),i=(a,c)=>t.slice(a,c),r=i(32,127),s=i(0,24);s.push(25),s.push.apply(s,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(r,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(s,0,3,0),e.addMany(s,1,3,1),e.add(127,1,0,1),e.addMany(s,8,0,8),e.addMany(s,3,3,3),e.add(127,3,0,3),e.addMany(s,4,3,4),e.add(127,4,0,4),e.addMany(s,6,3,6),e.addMany(s,5,3,5),e.add(127,5,0,5),e.addMany(s,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(s,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(s,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(s,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(s,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(s,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(s,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Fi,0,2,0),e.add(Fi,8,5,8),e.add(Fi,6,0,6),e.add(Fi,11,0,11),e.add(Fi,13,13,13),e})(),Z1=class extends He{constructor(e=Q1){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Gp,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(nt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new G1),this._dcsParser=this._register(new X1),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let s=0;s<e.intermediates.length;++s){let n=e.intermediates.charCodeAt(s);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=r,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let r=this._escHandlers[i];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let r=this._csiHandlers[i];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,r,s){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=r,this._parseStack.chunkPos=s}parse(e,t,i){let r=0,s=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===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,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&c>-1){for(;c>=0&&(o=a[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&c>-1){for(;c>=0&&(o=a[c](),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,i),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,i),o)return o;r===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<t;++a){switch(r=e[a],s=this._transitions.table[this.currentState<<8|(r<160?r:Fi)],s>>4){case 2:for(let f=a+1;;++f){if(f>=t||(r=e[f])<32||r>126&&r<Fi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<Fi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<Fi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<Fi){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|r],h=c?c.length-1:-1;for(;h>=0&&(o=c[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(3,c,h,s,a),o;h<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++a<t&&(r=e[a])>47&&r<60);a--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let d=this._escHandlers[this._collect<<8|r],u=d?d.length-1:-1;for(;u>=0&&(o=d[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,d,u,s,a),o;u<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(r=e[f])===24||r===26||r===27||r>127&&r<Fi){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,s,a),o;r===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=a+1;;f++)if(f>=t||(r=e[f])<32||r>127&&r<Fi){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,s,a),o;r===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=s&15}}},J1=/^([\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})$/,eC=/^[\da-f]+$/;function bf(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=J1.exec(t);if(i){let r=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/r*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/r*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),eC.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,r=[0,0,0];for(let s=0;s<3;++s){let n=parseInt(t.slice(i*s,i*s+i),16);r[s]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return r}}function gh(e,t){let i=e.toString(16),r=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function tC(e,t=16){let[i,r,s]=e;return`rgb:${gh(i,t)}/${gh(r,t)}/${gh(s,t)}`}var iC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},rs=131072,yf=10;function Sf(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var wf=5e3,Cf=0,rC=class extends He{constructor(e,t,i,r,s,n,o,a,c=new Z1){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=r,this._optionsService=s,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ww,this._utf8Decoder=new Cw,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=St.clone(),this._eraseAttrDataInternal=St.clone(),this._onRequestBell=this._register(new te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new te),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 Fc(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:d.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,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:d,data:u})}),this._parser.setDcsHandlerFallback((h,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:d,payload:u})}),this._parser.setPrintHandler((h,d,u)=>this.print(h,d,u)),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(K.BEL,()=>this.bell()),this._parser.setExecuteHandler(K.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(K.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(K.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(K.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(K.BS,()=>this.backspace()),this._parser.setExecuteHandler(K.HT,()=>this.tab()),this._parser.setExecuteHandler(K.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(K.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Xa.IND,()=>this.index()),this._parser.setExecuteHandler(Xa.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Xa.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new yi(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new yi(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new yi(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new yi(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new yi(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new yi(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new yi(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new yi(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new yi(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new yi(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new yi(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new yi(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 Mt)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 mf((h,d)=>this.requestStatusString(h,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),wf))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${wf} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,r=this._activeBuffer.x,s=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;r=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>rs&&(n=this._parseStack.position+rs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<rs&&(this._parseBuffer=new Uint32Array(Math.min(e.length,rs))),o||this._dirtyRowTracker.clearRange(),e.length>rs)for(let h=n;h<e.length;h+=rs){let d=h+rs<e.length?h+rs:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(h,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,u))return this._preserveStack(r,s,u,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(r,s,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==r||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let r,s,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let _=t;_<i;++_){if(r=e[_],r<127&&n){let y=n[String.fromCharCode(r)];y&&(r=y.charCodeAt(0))}let p=this._unicodeService.charProperties(r,f);s=qs.extractWidth(p);let b=qs.extractShouldJoin(p),g=b?qs.extractWidth(f):0;if(f=p,o&&this._onA11yChar.fire(os(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-g>a){if(c){let y=u,O=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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&u instanceof Ao&&u.copyCellsFrom(y,O,0,g,!1);O<a;)y.setCellFromCodepoint(O++,0,1,d)}else if(this._activeBuffer.x=a-1,s===2)continue}if(b&&this._activeBuffer.x){let y=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-y,r,s);for(let O=s-g;--O>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,s-g,this._activeBuffer.getNullCell(d)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,r,s,d),s>0)for(;--s;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&i-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Sf(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new mf(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new yi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,r=!1,s=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),s),r&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&r.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(s-1,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}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(St));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,r=qs.extractWidth(t),s=this._activeBuffer.x-r,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),o=new Uint32Array(n.length*i),a=0;for(let h=0;h<n.length;){let d=n.codePointAt(h)||0;o[a++]=d,h+=d>65535?2:1}let c=a;for(let h=1;h<i;++h)o.copyWithin(c,0,a),c+=a;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(K.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(K.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(K.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(K.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(K.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Bs),this._charsetService.setgCharset(1,Bs),this._charsetService.setgCharset(2,Bs),this._charsetService.setgCharset(3,Bs);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let r=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:h,alt:d}=a,u=this._optionsService.rawOptions,f=(b,g)=>(o.triggerDataEvent(`${K.ESC}[${t?"":"?"}${b};${g}$y`),!0),_=b=>b?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,_(o.modes.insertMode)):p===12?f(p,3):p===20?f(p,_(u.convertEol)):f(p,0):p===1?f(p,_(r.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,_(r.origin)):p===7?f(p,_(r.wraparound)):p===8?f(p,3):p===9?f(p,_(s==="X10")):p===12?f(p,_(u.cursorBlink)):p===25?f(p,_(!o.isCursorHidden)):p===45?f(p,_(r.reverseWraparound)):p===66?f(p,_(r.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,_(s==="VT200")):p===1002?f(p,_(s==="DRAG")):p===1003?f(p,_(s==="ANY")):p===1004?f(p,_(r.sendFocus)):p===1005?f(p,4):p===1006?f(p,_(n==="SGR")):p===1015?f(p,4):p===1016?f(p,_(n==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,_(h===d)):p===2004?f(p,_(r.bracketedPasteMode)):p===2026?f(p,_(r.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,i,r,s){return t===2?(e|=50331648,e&=-16777216,e|=ga.fromColorRGB([i,r,s])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let r=[0,0,-1,0,0,0],s=0,n=0;do{if(r[n+s]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do r[1]===5&&(s=1),r[n+a+1+s]=o[a];while(++a<o.length&&a+n+1+s<r.length);break}if(r[1]===5&&n+s>=2||r[1]===2&&n+s>=5)break;r[1]&&(s=1)}while(++n+t<e.length&&n+s<r.length);for(let o=2;o<r.length;++o)r[o]===-1&&(r[o]=0);switch(r[0]){case 38:i.fg=this._updateAttrColor(i.fg,r[1],r[3],r[4],r[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,r[1],r[3],r[4],r[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,r[1],r[3],r[4],r[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=St.fg,e.bg=St.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,r=this._curAttrData;for(let s=0;s<t;s++)i=e.params[s],i>=30&&i<=37?(r.fg&=-50331904,r.fg|=16777216|i-30):i>=40&&i<=47?(r.bg&=-50331904,r.bg|=16777216|i-40):i>=90&&i<=97?(r.fg&=-50331904,r.fg|=16777216|i-90|8):i>=100&&i<=107?(r.bg&=-50331904,r.bg|=16777216|i-100|8):i===0?this._processSGR0(r):i===1?r.fg|=134217728:i===3?r.bg|=67108864:i===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(s)?e.getSubParams(s)[0]:1,r)):i===5?r.fg|=536870912:i===7?r.fg|=67108864:i===8?r.fg|=1073741824:i===9?r.fg|=2147483648:i===2?r.bg|=134217728:i===21?this._processUnderline(2,r):i===22?(r.fg&=-134217729,r.bg&=-134217729):i===23?r.bg&=-67108865:i===24?(r.fg&=-268435457,this._processUnderline(0,r)):i===25?r.fg&=-536870913:i===27?r.fg&=-67108865:i===28?r.fg&=-1073741825:i===29?r.fg&=2147483647:i===39?(r.fg&=-67108864,r.fg|=St.fg&16777215):i===49?(r.bg&=-67108864,r.bg|=St.bg&16777215):i===38||i===48||i===58?s+=this._extractColor(e,s,r):i===53?r.bg|=1073741824:i===55?r.bg&=-1073741825:i===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):i===100?(r.fg&=-67108864,r.fg|=St.fg&16777215,r.bg&=-67108864,r.bg|=St.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${K.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${K.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${K.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=St.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Sf(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${K.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>yf&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>yf&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let r=i.shift(),s=i.shift();if(/^\d+$/.exec(r)){let n=parseInt(r);if(kf(n))if(s==="?")t.push({type:0,index:n});else{let o=bf(s);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(i,r):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),r,s=i.findIndex(n=>n.startsWith("id="));return s!==-1&&(r=i[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let r=0;r<i.length&&!(t>=this._specialColors.length);++r,++t)if(i[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let s=bf(i[r]);s&&this._onColor.fire([{type:1,index:this._specialColors[t],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let r=0;r<i.length;++r)if(/^\d+$/.exec(i[r])){let s=parseInt(i[r]);kf(s)&&t.push({type:2,index:s})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Bs),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(iC[e[0]],Mt[e[1]]||Bs),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=St.clone(),this._eraseAttrDataInternal=St.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ki;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(i);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${K.ESC}${o}${K.ESC}\\`),!0),r=this._bufferService.buffer,s=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Fc=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Cf=e,e=t,t=Cf),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Fc=vt([ue(0,li)],Fc);function kf(e){return 0<=e&&e<256}var sC=5e7,xf=12,nC=50,oC=class extends He{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>sC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],s=this._action(r,t);if(s){let o=a=>performance.now()-i>=xf?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);s.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-i>=xf)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>nC&&(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()}},Wc=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),c={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._dataByLinkId.set(c.id,c),c.id}let i=e,r=this._getEntryIdKey(i),s=this._entriesWithId.get(r);if(s)return this.addLineToLink(s.id,t.ybase+t.y),s.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);i.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(i,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Wc=vt([ue(0,li)],Wc);var Ef=!1,aC=class extends He{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ho),this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onData=this._register(new te),this.onData=this._onData.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new te),this._instantiationService=new A1,this.optionsService=this._register(new z1(e)),this._instantiationService.setService(hi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Lc)),this._instantiationService.setService(li,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Oc)),this._instantiationService.setService(fp,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Ic)),this._instantiationService.setService(wn,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Bc)),this._instantiationService.setService(dp,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(qs)),this._instantiationService.setService(Dw,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Y1),this._instantiationService.setService(Ew,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wc),this._instantiationService.setService(_p,this._oscLinkService),this._inputHandler=this._register(new rC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Qt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Qt.forward(this._bufferService.onResize,this._onResize)),this._register(Qt.forward(this.coreService.onData,this._onData)),this._register(Qt.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 oC((t,i)=>this._inputHandler.parse(t,i))),this._register(Qt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new te),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Ef&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ef=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Yp),t=Math.max(t,Vp),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(gf.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(gf(this._bufferService),!1))),this._windowsWrappingHeuristics.value=nt(()=>{for(let t of e)t.dispose()})}}},lC={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 hC(e,t,i,r){var o;let s={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?s.key=K.ESC+"OA":s.key=K.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?s.key=K.ESC+"OD":s.key=K.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?s.key=K.ESC+"OC":s.key=K.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?s.key=K.ESC+"OB":s.key=K.ESC+"[B");break;case 8:s.key=e.ctrlKey?"\b":K.DEL,e.altKey&&(s.key=K.ESC+s.key);break;case 9:if(e.shiftKey){s.key=K.ESC+"[Z";break}s.key=K.HT,s.cancel=!0;break;case 13:s.key=e.altKey?K.ESC+K.CR:K.CR,s.cancel=!0;break;case 27:s.key=K.ESC,e.altKey&&(s.key=K.ESC+K.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;n?s.key=K.ESC+"[1;"+(n+1)+"D":t?s.key=K.ESC+"OD":s.key=K.ESC+"[D";break;case 39:if(e.metaKey)break;n?s.key=K.ESC+"[1;"+(n+1)+"C":t?s.key=K.ESC+"OC":s.key=K.ESC+"[C";break;case 38:if(e.metaKey)break;n?s.key=K.ESC+"[1;"+(n+1)+"A":t?s.key=K.ESC+"OA":s.key=K.ESC+"[A";break;case 40:if(e.metaKey)break;n?s.key=K.ESC+"[1;"+(n+1)+"B":t?s.key=K.ESC+"OB":s.key=K.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(s.key=K.ESC+"[2~");break;case 46:n?s.key=K.ESC+"[3;"+(n+1)+"~":s.key=K.ESC+"[3~";break;case 36:n?s.key=K.ESC+"[1;"+(n+1)+"H":t?s.key=K.ESC+"OH":s.key=K.ESC+"[H";break;case 35:n?s.key=K.ESC+"[1;"+(n+1)+"F":t?s.key=K.ESC+"OF":s.key=K.ESC+"[F";break;case 33:e.shiftKey?s.type=2:e.ctrlKey?s.key=K.ESC+"[5;"+(n+1)+"~":s.key=K.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:e.ctrlKey?s.key=K.ESC+"[6;"+(n+1)+"~":s.key=K.ESC+"[6~";break;case 112:n?s.key=K.ESC+"[1;"+(n+1)+"P":s.key=K.ESC+"OP";break;case 113:n?s.key=K.ESC+"[1;"+(n+1)+"Q":s.key=K.ESC+"OQ";break;case 114:n?s.key=K.ESC+"[1;"+(n+1)+"R":s.key=K.ESC+"OR";break;case 115:n?s.key=K.ESC+"[1;"+(n+1)+"S":s.key=K.ESC+"OS";break;case 116:n?s.key=K.ESC+"[15;"+(n+1)+"~":s.key=K.ESC+"[15~";break;case 117:n?s.key=K.ESC+"[17;"+(n+1)+"~":s.key=K.ESC+"[17~";break;case 118:n?s.key=K.ESC+"[18;"+(n+1)+"~":s.key=K.ESC+"[18~";break;case 119:n?s.key=K.ESC+"[19;"+(n+1)+"~":s.key=K.ESC+"[19~";break;case 120:n?s.key=K.ESC+"[20;"+(n+1)+"~":s.key=K.ESC+"[20~";break;case 121:n?s.key=K.ESC+"[21;"+(n+1)+"~":s.key=K.ESC+"[21~";break;case 122:n?s.key=K.ESC+"[23;"+(n+1)+"~":s.key=K.ESC+"[23~";break;case 123:n?s.key=K.ESC+"[24;"+(n+1)+"~":s.key=K.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?s.key=K.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?s.key=K.DEL:e.keyCode===219?s.key=K.ESC:e.keyCode===220?s.key=K.FS:e.keyCode===221&&(s.key=K.GS);else if((!i||r)&&e.altKey&&!e.metaKey){let a=(o=lC[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)s.key=K.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let c=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(c);e.shiftKey&&(h=h.toUpperCase()),s.key=K.ESC+h}else if(e.keyCode===32)s.key=K.ESC+(e.ctrlKey?K.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let c=e.code.slice(3,4);e.shiftKey||(c=c.toLowerCase()),s.key=K.ESC+c,s.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?s.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(s.key=K.US),e.key==="@"&&(s.key=K.NUL));break}return s}var pt=0,cC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gl,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((s,n)=>this._getKey(s)-this._getKey(n)),t=0,i=0,r=new Array(this._array.length+this._insertedValues.length);for(let s=0;s<r.length;s++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(r[s]=e[t],t++):r[s]=this._array[i++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(pt=this._search(t),pt===-1)||this._getKey(this._array[pt])!==t)return!1;do if(this._array[pt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(pt),!0;while(++pt<this._array.length&&this._getKey(this._array[pt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((s,n)=>s-n),t=0,i=new Array(this._array.length-e.length),r=0;for(let s=0;s<this._array.length;s++)e[t]===s?t++:i[r++]=this._array[s];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pt=this._search(e),!(pt<0||pt>=this._array.length)&&this._getKey(this._array[pt])===e))do yield this._array[pt];while(++pt<this._array.length&&this._getKey(this._array[pt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pt=this._search(e),!(pt<0||pt>=this._array.length)&&this._getKey(this._array[pt])===e))do t(this._array[pt]);while(++pt<this._array.length&&this._getKey(this._array[pt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let r=t+i>>1,s=this._getKey(this._array[r]);if(s>e)i=r-1;else if(s<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},mh=0,Df=0,uC=class extends He{constructor(){super(),this._decorations=new cC(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(nt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new dC(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let r=0,s=0;for(let n of this._decorations.getKeyIterator(t))r=n.options.x??0,s=r+(n.options.width??1),e>=r&&e<s&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,r){this._decorations.forEachByKey(t,s=>{mh=s.options.x??0,Df=mh+(s.options.width??1),e>=mh&&e<Df&&(!i||(s.options.layer??"bottom")===i)&&r(s)})}},dC=class extends xs{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new te),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=lt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=lt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},fC=1e3,_C=class{constructor(e,t=fC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let s=r-this._lastRefreshMs,n=this._debounceThresholdMS-s;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 e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Tf=20,ml=class extends He{constructor(e,t,i,r){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.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=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new _C(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(`
39
39
  `))),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(Ae(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(nt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Tf+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
40
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Tf+1&&(this._liveRegion.textContent+=nc.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,r=i.lines.length.toString();for(let s=e;s<=t;s++){let n=i.lines.get(i.ydisp+s),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",c=(i.ydisp+s+1).toString(),h=this._rowElements[s];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",c),h.setAttribute("aria-setsize",r),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],s=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(s===n||e.relatedTarget!==r)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:r,offset:((a=r.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let s=({node:c,offset:h})=>{let d=c instanceof Text?c.parentNode:c,u=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(d);if(!f)return console.warn("columns is null. Race condition?"),null;let _=h<f.length?f[h]:f.slice(-1)[0]+1;return _>=this._terminal.cols&&(++u,_=0),{row:u,column:_}},n=s(t),o=s(i);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(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var s,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(s=this._rowColumns.get(e))==null?void 0:s.slice(-1))==null?void 0:n[0];if(!i)return;let r=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};ml=vt([ue(1,Mu),ue(2,Zr),ue(3,Jr)],ml);var Hc=class extends He{constructor(e,t,i,r,s){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=r,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(nt(()=>{var n;bn(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(Ae(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ae(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ae(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ae(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let r=0;r<i.length;r++){let s=i[r];if(s.classList.contains("xterm"))break;if(s.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var r,s;(!this._activeProviderReplies||!t)&&((r=this._activeProviderReplies)==null||r.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(s=this._activeProviderReplies)!=null&&s.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var h,d;if(this._isMouseOut)return;let c=a==null?void 0:a.map(u=>({link:u}));(h=this._activeProviderReplies)==null||h.set(n,c),i=this._checkLinkProviderResult(n,e,i),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let r=0;r<t.size;r++){let s=t.get(r);if(s)for(let n=0;n<s.length;n++){let o=s[n],a=o.link.range.start.y<e?0:o.link.range.start.x,c=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=c;h++){if(i.has(h)){s.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let r=this._activeProviderReplies.get(e),s=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(s=!0);if(!s&&r){let o=r.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(c=>this._linkAtPosition(c.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&vC(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,bn(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.pointerCursor},set:i=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.underline},set:i=>{var r,s,n;(r=this._currentLink)!=null&&r.state&&((n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let r=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,r=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-r-1,i.end.x,i.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(e,t,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,s=t.y*this._bufferService.cols+t.x;return i<=s&&s<=r}_positionFromMouseEvent(e,t,i){let r=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,r,s){return{x1:e,y1:t,x2:i,y2:r,cols:this._bufferService.cols,fg:s}}};Hc=vt([ue(1,Ou),ue(2,Jr),ue(3,li),ue(4,pp)],Hc);function vC(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var pC=class extends aC{constructor(e={}){super(e),this._linkifier=this._register(new ho),this.browser=Ip,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ho),this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new te),this.onKey=this._onKey.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new te),this.onBell=this._onBell.event,this._onFocus=this._register(new te),this._onBlur=this._register(new te),this._onA11yCharEmitter=this._register(new te),this._onA11yTabEmitter=this._register(new te),this._onWillOpen=this._register(new te),this._setup(),this._decorationService=this._instantiationService.createInstance(uC),this._instantiationService.setService(ma,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(n1),this._instantiationService.setService(pp,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ac)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Qt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Qt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Qt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Qt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(nt(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,r="";switch(t.index){case 256:i="foreground",r="10";break;case 257:i="background",r="11";break;case 258:i="cursor",r="12";break;default:i="ansi",r="4;"+t.index}switch(t.type){case 0:let s=Je.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${U.ESC}]${r};${tC(s)}${Op.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=wt.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=wt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ml,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,s=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*s,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*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=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ae(this.element,"copy",t=>{this.hasSelection()&&yw(t,this._selectionService)}));let e=t=>Sw(t,this.textarea,this.coreService,this.optionsService);this._register(Ae(this.textarea,"paste",e)),this._register(Ae(this.element,"paste",e)),Bp?this._register(Ae(this.element,"mousedown",t=>{t.button===2&&Nd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ae(this.element,"contextmenu",t=>{Nd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),zu&&this._register(Ae(this.element,"auxclick",t=>{t.button===1&&ap(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ae(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ae(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ae(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ae(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ae(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ae(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ae(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var s;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((s=this.element)==null?void 0:s.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ae(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",sc.get()),Wp||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(r1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Zr,this._coreBrowserService),this._register(Ae(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(Ae(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Tc,this._document,this._helperContainer),this._instantiationService.setService(Ul,this._charSizeService),this._themeService=this._instantiationService.createInstance(Mc),this._instantiationService.setService(po,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vl),this._instantiationService.setService(vp,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Pc,this.rows,this.screenElement)),this._instantiationService.setService(Jr,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(xc,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Rc),this._instantiationService.setService(Ou,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Hc,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Cc,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(Ac,this.element,this.screenElement,r)),this._instantiationService.setService(Rw,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(Qt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(kc,this.screenElement)),this._register(Ae(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(ml,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_l,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_l,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Dc,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var h,d,u,f,_;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,c;switch(n.overrideType||n.type){case"mousemove":c=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":c=0,a=n.button<3?n.button:3;break;case"mousedown":c=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let p=n.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(n,(f=(u=(d=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:d.device)==null?void 0:u.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;c=p<0?0:1,a=4;break;default:return!1}return c===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:c,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(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?r.mousemove||(t.addEventListener("mousemove",s.mousemove),r.mousemove=s.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),n&16?r.wheel||(t.addEventListener("wheel",s.wheel,{passive:!1}),r.wheel=s.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),n&2?r.mouseup||(r.mouseup=s.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),n&4?r.mousedrag||(r.mousedrag=s.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ae(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(n)})),this._register(Ae(t,"wheel",n=>{var o,a,c,h,d;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(h=(c=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:c.cell)==null?void 0:h.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let u=U.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){op(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=hC(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let r=this.rows-1;return this.scrollLines(i.type===2?-r:r),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===U.ETX||i.key===U.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(gC(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(St));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(U.ESC+"[I"):this.coreService.triggerDataEvent(U.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${U.ESC}[4;${i};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${U.ESC}[6;${s};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function gC(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var mC=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},bC=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ki)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Rf=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new bC(t)}getNullCell(){return new Ki}},yC=class extends He{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new te),this.onBufferChange=this._onBufferChange.event,this._normal=new Rf(this._core.buffers.normal,"normal"),this._alternate=new Rf(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)}},SC=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,r)=>t(i,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},wC=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},CC=["cols","rows"],fr=0,kC=class extends He{constructor(e){super(),this._core=this._register(new pC(e)),this._addonManager=this._register(new mC),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],i=(r,s)=>{this._checkReadonlyOptions(r),this._core.options[r]=s};for(let r in this._core.options){let s={get:t.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this._publicOptions,r,s)}}_checkReadonlyOptions(e){if(CC.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new SC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new wC(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 yC(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
40
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Tf+1&&(this._liveRegion.textContent+=nc.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,r=i.lines.length.toString();for(let s=e;s<=t;s++){let n=i.lines.get(i.ydisp+s),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",c=(i.ydisp+s+1).toString(),h=this._rowElements[s];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",c),h.setAttribute("aria-setsize",r),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],s=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(s===n||e.relatedTarget!==r)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:r,offset:((a=r.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let s=({node:c,offset:h})=>{let d=c instanceof Text?c.parentNode:c,u=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(d);if(!f)return console.warn("columns is null. Race condition?"),null;let _=h<f.length?f[h]:f.slice(-1)[0]+1;return _>=this._terminal.cols&&(++u,_=0),{row:u,column:_}},n=s(t),o=s(i);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(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var s,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(s=this._rowColumns.get(e))==null?void 0:s.slice(-1))==null?void 0:n[0];if(!i)return;let r=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};ml=vt([ue(1,Mu),ue(2,Zr),ue(3,Jr)],ml);var Hc=class extends He{constructor(e,t,i,r,s){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=r,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(nt(()=>{var n;bn(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(Ae(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ae(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ae(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ae(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let r=0;r<i.length;r++){let s=i[r];if(s.classList.contains("xterm"))break;if(s.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var r,s;(!this._activeProviderReplies||!t)&&((r=this._activeProviderReplies)==null||r.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(s=this._activeProviderReplies)!=null&&s.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var h,d;if(this._isMouseOut)return;let c=a==null?void 0:a.map(u=>({link:u}));(h=this._activeProviderReplies)==null||h.set(n,c),i=this._checkLinkProviderResult(n,e,i),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let r=0;r<t.size;r++){let s=t.get(r);if(s)for(let n=0;n<s.length;n++){let o=s[n],a=o.link.range.start.y<e?0:o.link.range.start.x,c=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=c;h++){if(i.has(h)){s.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let r=this._activeProviderReplies.get(e),s=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(s=!0);if(!s&&r){let o=r.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(c=>this._linkAtPosition(c.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&vC(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,bn(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.pointerCursor},set:i=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.underline},set:i=>{var r,s,n;(r=this._currentLink)!=null&&r.state&&((n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let r=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,r=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-r-1,i.end.x,i.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(e,t,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,s=t.y*this._bufferService.cols+t.x;return i<=s&&s<=r}_positionFromMouseEvent(e,t,i){let r=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,r,s){return{x1:e,y1:t,x2:i,y2:r,cols:this._bufferService.cols,fg:s}}};Hc=vt([ue(1,Ou),ue(2,Jr),ue(3,li),ue(4,pp)],Hc);function vC(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var pC=class extends aC{constructor(e={}){super(e),this._linkifier=this._register(new ho),this.browser=Ip,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ho),this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new te),this.onKey=this._onKey.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new te),this.onBell=this._onBell.event,this._onFocus=this._register(new te),this._onBlur=this._register(new te),this._onA11yCharEmitter=this._register(new te),this._onA11yTabEmitter=this._register(new te),this._onWillOpen=this._register(new te),this._setup(),this._decorationService=this._instantiationService.createInstance(uC),this._instantiationService.setService(ma,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(n1),this._instantiationService.setService(pp,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ac)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Qt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Qt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Qt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Qt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(nt(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,r="";switch(t.index){case 256:i="foreground",r="10";break;case 257:i="background",r="11";break;case 258:i="cursor",r="12";break;default:i="ansi",r="4;"+t.index}switch(t.type){case 0:let s=Je.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${K.ESC}]${r};${tC(s)}${Op.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=wt.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=wt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ml,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(K.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(K.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,s=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*s,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*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=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ae(this.element,"copy",t=>{this.hasSelection()&&yw(t,this._selectionService)}));let e=t=>Sw(t,this.textarea,this.coreService,this.optionsService);this._register(Ae(this.textarea,"paste",e)),this._register(Ae(this.element,"paste",e)),Bp?this._register(Ae(this.element,"mousedown",t=>{t.button===2&&Nd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ae(this.element,"contextmenu",t=>{Nd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),zu&&this._register(Ae(this.element,"auxclick",t=>{t.button===1&&ap(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ae(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ae(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ae(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ae(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ae(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ae(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ae(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var s;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((s=this.element)==null?void 0:s.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ae(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",sc.get()),Wp||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(r1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Zr,this._coreBrowserService),this._register(Ae(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(Ae(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Tc,this._document,this._helperContainer),this._instantiationService.setService(Ul,this._charSizeService),this._themeService=this._instantiationService.createInstance(Mc),this._instantiationService.setService(po,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vl),this._instantiationService.setService(vp,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Pc,this.rows,this.screenElement)),this._instantiationService.setService(Jr,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(xc,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Rc),this._instantiationService.setService(Ou,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Hc,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Cc,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(Ac,this.element,this.screenElement,r)),this._instantiationService.setService(Rw,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(Qt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(kc,this.screenElement)),this._register(Ae(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(ml,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_l,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_l,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Dc,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var h,d,u,f,_;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,c;switch(n.overrideType||n.type){case"mousemove":c=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":c=0,a=n.button<3?n.button:3;break;case"mousedown":c=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let p=n.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(n,(f=(u=(d=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:d.device)==null?void 0:u.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;c=p<0?0:1,a=4;break;default:return!1}return c===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:c,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(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?r.mousemove||(t.addEventListener("mousemove",s.mousemove),r.mousemove=s.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),n&16?r.wheel||(t.addEventListener("wheel",s.wheel,{passive:!1}),r.wheel=s.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),n&2?r.mouseup||(r.mouseup=s.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),n&4?r.mousedrag||(r.mousedrag=s.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ae(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(n)})),this._register(Ae(t,"wheel",n=>{var o,a,c,h,d;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(h=(c=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:c.cell)==null?void 0:h.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let u=K.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){op(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=hC(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let r=this.rows-1;return this.scrollLines(i.type===2?-r:r),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===K.ETX||i.key===K.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(gC(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(St));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(K.ESC+"[I"):this.coreService.triggerDataEvent(K.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${K.ESC}[4;${i};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${K.ESC}[6;${s};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function gC(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var mC=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},bC=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ki)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Rf=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new bC(t)}getNullCell(){return new Ki}},yC=class extends He{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new te),this.onBufferChange=this._onBufferChange.event,this._normal=new Rf(this._core.buffers.normal,"normal"),this._alternate=new Rf(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)}},SC=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,r)=>t(i,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},wC=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},CC=["cols","rows"],fr=0,kC=class extends He{constructor(e){super(),this._core=this._register(new pC(e)),this._addonManager=this._register(new mC),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],i=(r,s)=>{this._checkReadonlyOptions(r),this._core.options[r]=s};for(let r in this._core.options){let s={get:t.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this._publicOptions,r,s)}}_checkReadonlyOptions(e){if(CC.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new SC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new wC(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 yC(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
41
41
  `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return sc.get()},set promptLabel(e){sc.set(e)},get tooMuchOutput(){return nc.get()},set tooMuchOutput(e){nc.set(e)}}}_verifyIntegers(...e){for(fr of e)if(fr===1/0||isNaN(fr)||fr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(fr of e)if(fr&&(fr===1/0||isNaN(fr)||fr%1!==0||fr<0))throw new Error("This API only accepts positive integers")}};/**
42
42
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
43
43
  * @license MIT
@@ -49,4 +49,4 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
49
49
  * Fabrice Bellard's javascript vt100 for jslinux:
50
50
  * http://bellard.org/jslinux/
51
51
  * Copyright (c) 2011 Fabrice Bellard
52
- */var xC=2,EC=1,DC=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var u;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((u=this._terminal.options.overviewRuler)==null?void 0:u.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,c=o.right+o.left,h=r-a,d=s-c-t;return{cols:Math.max(xC,Math.floor(d/e.css.cell.width)),rows:Math.max(EC,Math.floor(h/e.css.cell.height))}}},TC=W('<div class="scroll-fabs svelte-5qgfij"><button class="scroll-fab svelte-5qgfij" data-dir="up" data-track="terminal.scroll-up" aria-label="Page up">&#9650;</button> <button class="scroll-fab svelte-5qgfij" data-dir="down" data-track="terminal.scroll-down" aria-label="Page down">&#9660;</button> <button class="scroll-fab scroll-fab-bottom svelte-5qgfij" data-dir="bottom" data-track="terminal.scroll-bottom" aria-label="Skip to bottom">&#8615;</button></div>'),RC=W('<div data-track="terminal.focus"><div class="terminal-container svelte-5qgfij" role="presentation"></div> <div class="terminal-scrollbar svelte-5qgfij" role="scrollbar" aria-orientation="vertical"><div class="terminal-scrollbar-thumb svelte-5qgfij" role="presentation"></div></div> <!></div>');function PC(e,t){dt(t,!0);let i=Pr(t,"useTmux",3,!1),r=Pr(t,"companionMode",3,!1),s,n=F(null),o,a=!1;function c(){return l(n)}function h(){var M;(M=l(n))==null||M.focus()}function d(){if(!l(n))return;const M=l(n).buffer.active,Y=M.viewportY>=M.baseY,ge=M.viewportY;o==null||o.fit(),Y?l(n).scrollToBottom():l(n).scrollToLine(ge),rh(l(n).cols,l(n).rows),L()}vo(()=>{const M=new kC({cursorBlink:!0,fontSize:Nt?12:14,fontFamily:"Menlo, monospace",scrollback:1e4,theme:{background:"#000000",foreground:"#d4d4d4",cursor:"#d4d4d4"}});if(o=new DC,M.loadAddon(o),M.open(s),Nt){const le=s.querySelector(".xterm-viewport");le&&(le.style.touchAction="none",le.style.overflowY="hidden");const re=s.querySelector(".xterm-screen");if(re){re.addEventListener("wheel",we=>{we.stopImmediatePropagation(),we.preventDefault()},{capture:!0,passive:!1});const ke=we=>{M.modes.mouseTrackingMode!=="none"&&we.stopImmediatePropagation()};for(const we of["mousedown","mouseup","mousemove"])re.addEventListener(we,ke,{capture:!0})}}o.fit(),M.onData(le=>Cr(le));{const le=/Mac|iPhone|iPad|iPod/.test(navigator.platform||"");M.attachCustomKeyEventHandler(re=>!le&&re.type==="keydown"&&re.ctrlKey&&!re.shiftKey&&!re.altKey&&!re.metaKey&&(re.key==="v"||re.key==="V")&&navigator.clipboard&&navigator.clipboard.read?(navigator.clipboard.read().then(ke=>{let we=null,Re=null;for(const oe of ke){for(const Ee of oe.types)if(Ee.startsWith("image/")){Re=Ee,we=oe;break}if(we)break}we&&Re?we.getType(Re).then(oe=>de(oe,Re)):navigator.clipboard.readText().then(oe=>{oe&&M.paste(oe)})}).catch(()=>{navigator.clipboard.readText&&navigator.clipboard.readText().then(ke=>{ke&&M.paste(ke)}).catch(()=>{})}),!1):!0)}M.parser.registerOscHandler(52,le=>{var we;const re=le.indexOf(";");if(re===-1)return!0;const ke=le.slice(re+1);if(!ke||ke==="?")return!0;try{const Re=Uint8Array.from(atob(ke),Ee=>Ee.charCodeAt(0)),oe=new TextDecoder("utf-8").decode(Re);(we=navigator.clipboard)==null||we.writeText(oe).catch(()=>{})}catch{}return!0}),M.onScroll(L),M.onWriteParsed(L);let Y=null;const ge=new ResizeObserver(()=>{Y&&clearTimeout(Y),Y=setTimeout(()=>{const le=M.buffer.active,re=le.viewportY>=le.baseY,ke=le.viewportY;o.fit(),re?M.scrollToBottom():M.scrollToLine(ke),rh(M.cols,M.rows),L()},Nt?150:0)});return ge.observe(s),Nt&&(document.addEventListener("touchmove",ce,{passive:!1}),document.addEventListener("touchend",se),document.addEventListener("touchcancel",se)),m(n,M,!0),()=>{Y&&clearTimeout(Y),q&&clearTimeout(q),ge.disconnect(),M.dispose(),m(n,null),S=!1,u=!1,Nt&&(document.removeEventListener("touchmove",ce),document.removeEventListener("touchend",se),document.removeEventListener("touchcancel",se))}}),zi(()=>{t.sessionId&&l(n)&&!r()&&(l(n).write("\x1B[?1049l"),l(n).clear(),Rv(t.sessionId,l(n),()=>{l(n)&&rh(l(n).cols,l(n).rows)},()=>{}))});let u=!1,f=0,_=0,p=F(0),b=F(0),g=F(!1),S=!1,O=0,C=0,y=!1,x=0,P=0,I=F(!1),z=F(!1),q=null,J=0,K=0;const N=500,A=10;let T=!1;function L(){T||(T=!0,requestAnimationFrame(H))}function H(){if(T=!1,!l(n))return;const M=l(n).buffer.active,Y=M.baseY+l(n).rows,ge=M.viewportY,le=_e;if(!le)return;const re=le.clientHeight;if(Y<=l(n).rows){m(g,!1);return}m(g,!0),m(p,Math.max(Nt?44:20,l(n).rows/Y*re),!0),m(b,ge/(Y-l(n).rows)*(re-l(p)))}function D(M){if(!l(n)||!_e)return;const Y=_e.getBoundingClientRect(),le=l(n).buffer.active.baseY+l(n).rows;if(le<=l(n).rows)return;const re=_e.clientHeight,ke=Math.max(Nt?44:20,l(n).rows/le*re),we=re-ke,Re=M-Y.top-ke/2,oe=Math.max(0,Math.min(1,Re/we)),Ee=Math.round(oe*(le-l(n).rows));l(n).scrollToLine(Ee)}function E(M){const Y=M.touches[0];Y&&(u=!0,f=Y.clientY,_=l(b))}function $(){var M;l(z)&&(m(z,!1),(M=t.onCopyModeChange)==null||M.call(t,!1))}function Q(){var ge;if(q=null,S=!1,navigator.vibrate&&navigator.vibrate(50),i()){m(z,!0),(ge=t.onCopyModeChange)==null||ge.call(t,!0),Cr("[");return}m(I,!0);const M=s.querySelector(".xterm-screen");M&&(M.style.userSelect="text",M.style.webkitUserSelect="text"),s.querySelectorAll("canvas").forEach(le=>{le.style.pointerEvents="none"});const Y=s.querySelector(".xterm-rows");if(Y){const le=document.createRange();le.selectNodeContents(Y);const re=window.getSelection();re==null||re.removeAllRanges(),re==null||re.addRange(le)}}function pe(){var Y;m(I,!1);const M=s.querySelector(".xterm-screen");M&&(M.style.userSelect="",M.style.webkitUserSelect=""),s.querySelectorAll("canvas").forEach(ge=>{ge.style.pointerEvents=""}),(Y=window.getSelection())==null||Y.removeAllRanges()}function be(M){var ge;if(l(I)){const le=((ge=window.getSelection())==null?void 0:ge.toString())??"";le.trim().length>0&&(navigator.clipboard.writeText(le).catch(()=>{}),navigator.vibrate&&navigator.vibrate(30)),pe();return}if(l(z)||M.target.closest(".terminal-scrollbar")||M.target.closest(".scroll-fabs")||!l(n))return;const Y=M.touches[0];Y&&(O=Y.clientY,P=Y.clientY,C=l(n).buffer.active.viewportY,y=!1,x=0,S=!0,J=Y.clientX,K=Y.clientY,q&&clearTimeout(q),q=setTimeout(()=>{Q()},N))}function ce(M){const Y=M.touches[0];if(Y){if(u){if(!l(n)||!_e)return;M.preventDefault();const ge=Y.clientY-f,re=l(n).buffer.active.baseY+l(n).rows;if(re<=l(n).rows)return;const ke=_e.clientHeight,we=Math.max(44,l(n).rows/re*ke),Re=ke-we,Ee=Math.max(0,Math.min(Re,_+ge))/Re,Ge=Math.round(Ee*(re-l(n).rows));l(n).scrollToLine(Ge);return}if(S&&l(n)&&!l(I)){if(q){const le=Math.abs(Y.clientX-J),re=Math.abs(Y.clientY-K);(le>A||re>A)&&(clearTimeout(q),q=null)}if(l(n).rows===0||s.clientHeight===0)return;const ge=O-Y.clientY;if(Math.abs(ge)>5){y=!0,M.preventDefault();const le=s.clientHeight/l(n).rows;if(l(n).buffer.active.type==="alternate"){const re=P-Y.clientY;P=Y.clientY;const ke=re/le;x+=ke;const we=Math.trunc(x);if(we!==0){x-=we;const Re=we>0?65:64,oe=Math.max(1,Math.round(l(n).cols/2)),Ee=Math.max(1,Math.round(l(n).rows/2)),Ge=`\x1B[<${Re};${oe};${Ee}M`,qt=Math.min(Math.abs(we),5);for(let ae=0;ae<qt;ae++)Cr(Ge)}}else{const re=ge/le,ke=l(n).buffer.active.baseY,we=Math.max(0,Math.min(ke,Math.round(C+re)));l(n).scrollToLine(we)}}}}}function se(){q&&(clearTimeout(q),q=null),u=!1,S=!1,y=!1,x=0}function De(M){M.target!==Se&&D(M.clientY)}function Te(M){M.preventDefault();const Y=M.target.closest("button");if(!Y||!l(n))return;const ge=Y.dataset.dir;if(l(n).buffer.active.type==="alternate"){const le=Math.max(1,Math.round(l(n).cols/2)),re=Math.max(1,Math.round(l(n).rows/2));if(ge==="up"||ge==="down"){const we=`\x1B[<${ge==="down"?65:64};${le};${re}M`,Re=Math.max(1,Math.round(l(n).rows/2));for(let oe=0;oe<Re;oe++)Cr(we)}else if(ge==="bottom"){const ke=`\x1B[<65;${le};${re}M`;for(let we=0;we<l(n).rows;we++)Cr(ke)}}else ge==="up"?l(n).scrollPages(-1):ge==="down"?l(n).scrollPages(1):ge==="bottom"&&l(n).scrollToBottom()}let _e,Se;async function de(M,Y){var le;if(a||!t.sessionId)return;a=!0,(le=t.onImageUpload)==null||le.call(t,"Pasting image…",!1);const ge=new FileReader;ge.onload=async()=>{var ke,we,Re;const re=ge.result.split(",")[1];try{const oe=await xb(t.sessionId,re,Y);oe.clipboardSet?(ke=t.onImageUpload)==null||ke.call(t,"Image pasted",!1):(we=t.onImageUpload)==null||we.call(t,oe.path,!0,oe.path)}catch(oe){const Ee=oe instanceof Error?oe.message:"Image upload failed";(Re=t.onImageUpload)==null||Re.call(t,Ee,!1)}finally{a=!1}},ge.readAsDataURL(M)}function Me(M){var Y;if((Y=M.clipboardData)!=null&&Y.items){for(const ge of M.clipboardData.items)if(ge.type.startsWith("image/")){M.preventDefault(),M.stopPropagation();const le=ge.getAsFile();le&&de(le,ge.type);return}}}let Ne=F(!1);function je(M){var Y;(Y=M.dataTransfer)!=null&&Y.types.includes("Files")&&(M.preventDefault(),m(Ne,!0))}function Pe(){m(Ne,!1)}function et(M){var ge;if(M.preventDefault(),m(Ne,!1),!((ge=M.dataTransfer)!=null&&ge.files.length))return;const Y=M.dataTransfer.files[0];Y.type.startsWith("image/")&&de(Y,Y.type)}function X(M){var Y;u||y||M.target.closest(".terminal-scrollbar")||M.target.closest(".scroll-fabs")||l(I)||((Y=l(n))==null||Y.focus(),M.preventDefault())}var ve={getTerm:c,focusTerm:h,fitTerm:d,exitCopyMode:$,handleImageUpload:de},Fe=RC();let Ke;var Be=w(Fe);Ze(Be,M=>s=M,()=>s);var k=R(Be,2);Ie(k,"aria-valuenow",0);var Z=w(k);let fe;Ze(Z,M=>Se=M,()=>Se),Ze(k,M=>_e=M,()=>_e);var ye=R(k,2);{var Ce=M=>{var Y=TC();G("mousedown",Y,Te),B(M,Y)};ie(ye,M=>{Nt&&l(g)&&M(Ce)})}return he(()=>{Ke=it(Fe,1,"terminal-wrapper svelte-5qgfij",null,Ke,{"drag-over":l(Ne),"selection-mode":l(I)}),fe=_o(Z,"",fe,{display:l(g)?"block":"none",height:l(p)+"px",top:l(b)+"px"})}),G("touchstart",Fe,function(...M){var Y;(Y=Nt?be:void 0)==null||Y.apply(this,M)}),G("touchend",Fe,function(...M){var Y;(Y=Nt?X:void 0)==null||Y.apply(this,M)}),xr("paste",Be,Me),xr("dragover",Be,je),xr("dragleave",Be,Pe),xr("drop",Be,et),G("click",k,De),G("touchstart",Z,E),B(e,Fe),ft(ve)}_t(["touchstart","touchend","click","mousedown"]);var Sa=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},AC={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ls,ru,Vf,MC=(Vf=class{constructor(){ee(this,ls,AC);ee(this,ru,!1)}setTimeoutProvider(e){j(this,ls,e)}setTimeout(e,t){return v(this,ls).setTimeout(e,t)}clearTimeout(e){v(this,ls).clearTimeout(e)}setInterval(e,t){return v(this,ls).setInterval(e,t)}clearInterval(e){v(this,ls).clearInterval(e)}},ls=new WeakMap,ru=new WeakMap,Vf),js=new MC;function OC(e){setTimeout(e,0)}var co=typeof window>"u"||"Deno"in globalThis;function Ii(){}function LC(e,t){return typeof e=="function"?e(t):e}function zc(e){return typeof e=="number"&&e>=0&&e!==1/0}function Xp(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Es(e,t){return typeof e=="function"?e(t):e}function Fi(e,t){return typeof e=="function"?e(t):e}function Pf(e,t){const{type:i="all",exact:r,fetchStatus:s,predicate:n,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==Uu(o,t.options))return!1}else if(!Jo(t.queryKey,o))return!1}if(i!=="all"){const c=t.isActive();if(i==="active"&&!c||i==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||s&&s!==t.state.fetchStatus||n&&!n(t))}function Af(e,t){const{exact:i,status:r,predicate:s,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(i){if(Zo(t.options.mutationKey)!==Zo(n))return!1}else if(!Jo(t.options.mutationKey,n))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Uu(e,t){return((t==null?void 0:t.queryKeyHashFn)||Zo)(e)}function Zo(e){return JSON.stringify(e,(t,i)=>Kc(i)?Object.keys(i).sort().reduce((r,s)=>(r[s]=i[s],r),{}):i)}function Jo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>Jo(e[i],t[i])):!1}var IC=Object.prototype.hasOwnProperty;function $p(e,t,i=0){if(e===t)return e;if(i>500)return t;const r=Mf(e)&&Mf(t);if(!r&&!(Kc(e)&&Kc(t)))return t;const n=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),a=o.length,c=r?new Array(a):{};let h=0;for(let d=0;d<a;d++){const u=r?d:o[d],f=e[u],_=t[u];if(f===_){c[u]=f,(r?d<n:IC.call(e,u))&&h++;continue}if(f===null||_===null||typeof f!="object"||typeof _!="object"){c[u]=_;continue}const p=$p(f,_,i+1);c[u]=p,p===f&&h++}return n===a&&h===n?e:c}function Uc(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}function Mf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Kc(e){if(!Of(e))return!1;const t=e.constructor;if(t===void 0)return!0;const i=t.prototype;return!(!Of(i)||!i.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Of(e){return Object.prototype.toString.call(e)==="[object Object]"}function BC(e){return new Promise(t=>{js.setTimeout(t,e)})}function qc(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?$p(e,t):t}function NC(e,t,i=0){const r=[...e,t];return i&&r.length>i?r.slice(1):r}function FC(e,t,i=0){const r=[t,...e];return i&&r.length>i?r.slice(0,-1):r}var Ku=Symbol();function Qp(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Ku?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function WC(e,t,i){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?i():s.addEventListener("abort",i,{once:!0})),s)}),e}var Qs,hs,Kn,Gf,HC=(Gf=class extends Sa{constructor(){super();ee(this,Qs);ee(this,hs);ee(this,Kn);j(this,Kn,t=>{if(!co&&window.addEventListener){const i=()=>t();return window.addEventListener("visibilitychange",i,!1),()=>{window.removeEventListener("visibilitychange",i)}}})}onSubscribe(){v(this,hs)||this.setEventListener(v(this,Kn))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,hs))==null||t.call(this),j(this,hs,void 0))}setEventListener(t){var i;j(this,Kn,t),(i=v(this,hs))==null||i.call(this),j(this,hs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){v(this,Qs)!==t&&(j(this,Qs,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(i=>{i(t)})}isFocused(){var t;return typeof v(this,Qs)=="boolean"?v(this,Qs):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Qs=new WeakMap,hs=new WeakMap,Kn=new WeakMap,Gf),qu=new HC;function jc(){let e,t;const i=new Promise((s,n)=>{e=s,t=n});i.status="pending",i.catch(()=>{});function r(s){Object.assign(i,s),delete i.resolve,delete i.reject}return i.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},i.reject=s=>{r({status:"rejected",reason:s}),t(s)},i}var zC=OC;function UC(){let e=[],t=0,i=a=>{a()},r=a=>{a()},s=zC;const n=a=>{t?e.push(a):s(()=>{i(a)})},o=()=>{const a=e;e=[],a.length&&s(()=>{r(()=>{a.forEach(c=>{i(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||o()}return c},batchCalls:a=>(...c)=>{n(()=>{a(...c)})},schedule:n,setNotifyFunction:a=>{i=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{s=a}}}var ri=UC(),qn,cs,jn,Xf,KC=(Xf=class extends Sa{constructor(){super();ee(this,qn,!0);ee(this,cs);ee(this,jn);j(this,jn,t=>{if(!co&&window.addEventListener){const i=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",i,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",r)}}})}onSubscribe(){v(this,cs)||this.setEventListener(v(this,jn))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,cs))==null||t.call(this),j(this,cs,void 0))}setEventListener(t){var i;j(this,jn,t),(i=v(this,cs))==null||i.call(this),j(this,cs,t(this.setOnline.bind(this)))}setOnline(t){v(this,qn)!==t&&(j(this,qn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return v(this,qn)}},qn=new WeakMap,cs=new WeakMap,jn=new WeakMap,Xf),bl=new KC;function qC(e){return Math.min(1e3*2**e,3e4)}function Zp(e){return(e??"online")==="online"?bl.isOnline():!0}var Yc=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Jp(e){let t=!1,i=0,r;const s=jc(),n=()=>s.status!=="pending",o=b=>{var g;if(!n()){const S=new Yc(b);f(S),(g=e.onCancel)==null||g.call(e,S)}},a=()=>{t=!0},c=()=>{t=!1},h=()=>qu.isFocused()&&(e.networkMode==="always"||bl.isOnline())&&e.canRun(),d=()=>Zp(e.networkMode)&&e.canRun(),u=b=>{n()||(r==null||r(),s.resolve(b))},f=b=>{n()||(r==null||r(),s.reject(b))},_=()=>new Promise(b=>{var g;r=S=>{(n()||h())&&b(S)},(g=e.onPause)==null||g.call(e)}).then(()=>{var b;r=void 0,n()||(b=e.onContinue)==null||b.call(e)}),p=()=>{if(n())return;let b;const g=i===0?e.initialPromise:void 0;try{b=g??e.fn()}catch(S){b=Promise.reject(S)}Promise.resolve(b).then(u).catch(S=>{var P;if(n())return;const O=e.retry??(co?0:3),C=e.retryDelay??qC,y=typeof C=="function"?C(i,S):C,x=O===!0||typeof O=="number"&&i<O||typeof O=="function"&&O(i,S);if(t||!x){f(S);return}i++,(P=e.onFail)==null||P.call(e,i,S),BC(y).then(()=>h()?void 0:_()).then(()=>{t?f(S):p()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?p():_().then(p),s)}}var Zs,$f,eg=($f=class{constructor(){ee(this,Zs)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zc(this.gcTime)&&j(this,Zs,js.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(co?1/0:300*1e3))}clearGcTimeout(){v(this,Zs)&&(js.clearTimeout(v(this,Zs)),j(this,Zs,void 0))}},Zs=new WeakMap,$f),Js,Yn,Oi,en,It,sa,tn,er,Br,Qf,jC=(Qf=class extends eg{constructor(t){super();ee(this,er);ee(this,Js);ee(this,Yn);ee(this,Oi);ee(this,en);ee(this,It);ee(this,sa);ee(this,tn);j(this,tn,!1),j(this,sa,t.defaultOptions),this.setOptions(t.options),this.observers=[],j(this,en,t.client),j(this,Oi,v(this,en).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,j(this,Js,If(this.options)),this.state=t.state??v(this,Js),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=v(this,It))==null?void 0:t.promise}setOptions(t){if(this.options={...v(this,sa),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const i=If(this.options);i.data!==void 0&&(this.setState(Lf(i.data,i.dataUpdatedAt)),j(this,Js,i))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&v(this,Oi).remove(this)}setData(t,i){const r=qc(this.state.data,t,this.options);return xe(this,er,Br).call(this,{data:r,type:"success",dataUpdatedAt:i==null?void 0:i.updatedAt,manual:i==null?void 0:i.manual}),r}setState(t,i){xe(this,er,Br).call(this,{type:"setState",state:t,setStateOptions:i})}cancel(t){var r,s;const i=(r=v(this,It))==null?void 0:r.promise;return(s=v(this,It))==null||s.cancel(t),i?i.then(Ii).catch(Ii):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(v(this,Js))}isActive(){return this.observers.some(t=>Fi(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ku||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Es(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Xp(this.state.dataUpdatedAt,t)}onFocus(){var i;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(i=v(this,It))==null||i.continue()}onOnline(){var i;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(i=v(this,It))==null||i.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),v(this,Oi).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(i=>i!==t),this.observers.length||(v(this,It)&&(v(this,tn)?v(this,It).cancel({revert:!0}):v(this,It).cancelRetry()),this.scheduleGc()),v(this,Oi).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||xe(this,er,Br).call(this,{type:"invalidate"})}async fetch(t,i){var c,h,d,u,f,_,p,b,g,S,O,C;if(this.state.fetchStatus!=="idle"&&((c=v(this,It))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(i!=null&&i.cancelRefetch))this.cancel({silent:!0});else if(v(this,It))return v(this,It).continueRetry(),v(this,It).promise}if(t&&this.setOptions(t),!this.options.queryFn){const y=this.observers.find(x=>x.options.queryFn);y&&this.setOptions(y.options)}const r=new AbortController,s=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(j(this,tn,!0),r.signal)})},n=()=>{const y=Qp(this.options,i),P=(()=>{const I={client:v(this,en),queryKey:this.queryKey,meta:this.meta};return s(I),I})();return j(this,tn,!1),this.options.persister?this.options.persister(y,P,this):y(P)},a=(()=>{const y={fetchOptions:i,options:this.options,queryKey:this.queryKey,client:v(this,en),state:this.state,fetchFn:n};return s(y),y})();(h=this.options.behavior)==null||h.onFetch(a,this),j(this,Yn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&xe(this,er,Br).call(this,{type:"fetch",meta:(u=a.fetchOptions)==null?void 0:u.meta}),j(this,It,Jp({initialPromise:i==null?void 0:i.initialPromise,fn:a.fetchFn,onCancel:y=>{y instanceof Yc&&y.revert&&this.setState({...v(this,Yn),fetchStatus:"idle"}),r.abort()},onFail:(y,x)=>{xe(this,er,Br).call(this,{type:"failed",failureCount:y,error:x})},onPause:()=>{xe(this,er,Br).call(this,{type:"pause"})},onContinue:()=>{xe(this,er,Br).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const y=await v(this,It).start();if(y===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(y),(_=(f=v(this,Oi).config).onSuccess)==null||_.call(f,y,this),(b=(p=v(this,Oi).config).onSettled)==null||b.call(p,y,this.state.error,this),y}catch(y){if(y instanceof Yc){if(y.silent)return v(this,It).promise;if(y.revert){if(this.state.data===void 0)throw y;return this.state.data}}throw xe(this,er,Br).call(this,{type:"error",error:y}),(S=(g=v(this,Oi).config).onError)==null||S.call(g,y,this),(C=(O=v(this,Oi).config).onSettled)==null||C.call(O,this.state.data,y,this),y}finally{this.scheduleGc()}}},Js=new WeakMap,Yn=new WeakMap,Oi=new WeakMap,en=new WeakMap,It=new WeakMap,sa=new WeakMap,tn=new WeakMap,er=new WeakSet,Br=function(t){const i=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...tg(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...Lf(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return j(this,Yn,t.manual?s:void 0),s;case"error":const n=t.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=i(this.state),ri.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),v(this,Oi).notify({query:this,type:"updated",action:t})})},Qf);function tg(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zp(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Lf(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function If(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,i=t!==void 0,r=i?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:i?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:i?"success":"pending",fetchStatus:"idle"}}var di,qe,na,oi,rn,Vn,Hr,us,oa,Gn,Xn,sn,nn,ds,$n,Xe,Lo,Vc,Gc,Xc,$c,Qc,Zc,Jc,ig,Zf,YC=(Zf=class extends Sa{constructor(t,i){super();ee(this,Xe);ee(this,di);ee(this,qe);ee(this,na);ee(this,oi);ee(this,rn);ee(this,Vn);ee(this,Hr);ee(this,us);ee(this,oa);ee(this,Gn);ee(this,Xn);ee(this,sn);ee(this,nn);ee(this,ds);ee(this,$n,new Set);this.options=i,j(this,di,t),j(this,us,null),j(this,Hr,jc()),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(v(this,qe).addObserver(this),Bf(v(this,qe),this.options)?xe(this,Xe,Lo).call(this):this.updateResult(),xe(this,Xe,$c).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return eu(v(this,qe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return eu(v(this,qe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,xe(this,Xe,Qc).call(this),xe(this,Xe,Zc).call(this),v(this,qe).removeObserver(this)}setOptions(t){const i=this.options,r=v(this,qe);if(this.options=v(this,di).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Fi(this.options.enabled,v(this,qe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");xe(this,Xe,Jc).call(this),v(this,qe).setOptions(this.options),i._defaulted&&!Uc(this.options,i)&&v(this,di).getQueryCache().notify({type:"observerOptionsUpdated",query:v(this,qe),observer:this});const s=this.hasListeners();s&&Nf(v(this,qe),r,this.options,i)&&xe(this,Xe,Lo).call(this),this.updateResult(),s&&(v(this,qe)!==r||Fi(this.options.enabled,v(this,qe))!==Fi(i.enabled,v(this,qe))||Es(this.options.staleTime,v(this,qe))!==Es(i.staleTime,v(this,qe)))&&xe(this,Xe,Vc).call(this);const n=xe(this,Xe,Gc).call(this);s&&(v(this,qe)!==r||Fi(this.options.enabled,v(this,qe))!==Fi(i.enabled,v(this,qe))||n!==v(this,ds))&&xe(this,Xe,Xc).call(this,n)}getOptimisticResult(t){const i=v(this,di).getQueryCache().build(v(this,di),t),r=this.createResult(i,t);return GC(this,r)&&(j(this,oi,r),j(this,Vn,this.options),j(this,rn,v(this,qe).state)),r}getCurrentResult(){return v(this,oi)}trackResult(t,i){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),i==null||i(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&v(this,Hr).status==="pending"&&v(this,Hr).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){v(this,$n).add(t)}getCurrentQuery(){return v(this,qe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=v(this,di).defaultQueryOptions(t),r=v(this,di).getQueryCache().build(v(this,di),i);return r.fetch().then(()=>this.createResult(r,i))}fetch(t){return xe(this,Xe,Lo).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),v(this,oi)))}createResult(t,i){var q;const r=v(this,qe),s=this.options,n=v(this,oi),o=v(this,rn),a=v(this,Vn),h=t!==r?t.state:v(this,na),{state:d}=t;let u={...d},f=!1,_;if(i._optimisticResults){const J=this.hasListeners(),K=!J&&Bf(t,i),N=J&&Nf(t,r,i,s);(K||N)&&(u={...u,...tg(d.data,t.options)}),i._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:g}=u;_=u.data;let S=!1;if(i.placeholderData!==void 0&&_===void 0&&g==="pending"){let J;n!=null&&n.isPlaceholderData&&i.placeholderData===(a==null?void 0:a.placeholderData)?(J=n.data,S=!0):J=typeof i.placeholderData=="function"?i.placeholderData((q=v(this,Xn))==null?void 0:q.state.data,v(this,Xn)):i.placeholderData,J!==void 0&&(g="success",_=qc(n==null?void 0:n.data,J,i),f=!0)}if(i.select&&_!==void 0&&!S)if(n&&_===(o==null?void 0:o.data)&&i.select===v(this,oa))_=v(this,Gn);else try{j(this,oa,i.select),_=i.select(_),_=qc(n==null?void 0:n.data,_,i),j(this,Gn,_),j(this,us,null)}catch(J){j(this,us,J)}v(this,us)&&(p=v(this,us),_=v(this,Gn),b=Date.now(),g="error");const O=u.fetchStatus==="fetching",C=g==="pending",y=g==="error",x=C&&O,P=_!==void 0,z={status:g,fetchStatus:u.fetchStatus,isPending:C,isSuccess:g==="success",isError:y,isInitialLoading:x,isLoading:x,data:_,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>h.dataUpdateCount||u.errorUpdateCount>h.errorUpdateCount,isFetching:O,isRefetching:O&&!C,isLoadingError:y&&!P,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:y&&P,isStale:ju(t,i),refetch:this.refetch,promise:v(this,Hr),isEnabled:Fi(i.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const J=z.data!==void 0,K=z.status==="error"&&!J,N=L=>{K?L.reject(z.error):J&&L.resolve(z.data)},A=()=>{const L=j(this,Hr,z.promise=jc());N(L)},T=v(this,Hr);switch(T.status){case"pending":t.queryHash===r.queryHash&&N(T);break;case"fulfilled":(K||z.data!==T.value)&&A();break;case"rejected":(!K||z.error!==T.reason)&&A();break}}return z}updateResult(){const t=v(this,oi),i=this.createResult(v(this,qe),this.options);if(j(this,rn,v(this,qe).state),j(this,Vn,this.options),v(this,rn).data!==void 0&&j(this,Xn,v(this,qe)),Uc(i,t))return;j(this,oi,i);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,n=typeof s=="function"?s():s;if(n==="all"||!n&&!v(this,$n).size)return!0;const o=new Set(n??v(this,$n));return this.options.throwOnError&&o.add("error"),Object.keys(v(this,oi)).some(a=>{const c=a;return v(this,oi)[c]!==t[c]&&o.has(c)})};xe(this,Xe,ig).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&xe(this,Xe,$c).call(this)}},di=new WeakMap,qe=new WeakMap,na=new WeakMap,oi=new WeakMap,rn=new WeakMap,Vn=new WeakMap,Hr=new WeakMap,us=new WeakMap,oa=new WeakMap,Gn=new WeakMap,Xn=new WeakMap,sn=new WeakMap,nn=new WeakMap,ds=new WeakMap,$n=new WeakMap,Xe=new WeakSet,Lo=function(t){xe(this,Xe,Jc).call(this);let i=v(this,qe).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(Ii)),i},Vc=function(){xe(this,Xe,Qc).call(this);const t=Es(this.options.staleTime,v(this,qe));if(co||v(this,oi).isStale||!zc(t))return;const r=Xp(v(this,oi).dataUpdatedAt,t)+1;j(this,sn,js.setTimeout(()=>{v(this,oi).isStale||this.updateResult()},r))},Gc=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(v(this,qe)):this.options.refetchInterval)??!1},Xc=function(t){xe(this,Xe,Zc).call(this),j(this,ds,t),!(co||Fi(this.options.enabled,v(this,qe))===!1||!zc(v(this,ds))||v(this,ds)===0)&&j(this,nn,js.setInterval(()=>{(this.options.refetchIntervalInBackground||qu.isFocused())&&xe(this,Xe,Lo).call(this)},v(this,ds)))},$c=function(){xe(this,Xe,Vc).call(this),xe(this,Xe,Xc).call(this,xe(this,Xe,Gc).call(this))},Qc=function(){v(this,sn)&&(js.clearTimeout(v(this,sn)),j(this,sn,void 0))},Zc=function(){v(this,nn)&&(js.clearInterval(v(this,nn)),j(this,nn,void 0))},Jc=function(){const t=v(this,di).getQueryCache().build(v(this,di),this.options);if(t===v(this,qe))return;const i=v(this,qe);j(this,qe,t),j(this,na,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},ig=function(t){ri.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(v(this,oi))}),v(this,di).getQueryCache().notify({query:v(this,qe),type:"observerResultsUpdated"})})},Zf);function VC(e,t){return Fi(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Bf(e,t){return VC(e,t)||e.state.data!==void 0&&eu(e,t,t.refetchOnMount)}function eu(e,t,i){if(Fi(t.enabled,e)!==!1&&Es(t.staleTime,e)!=="static"){const r=typeof i=="function"?i(e):i;return r==="always"||r!==!1&&ju(e,t)}return!1}function Nf(e,t,i,r){return(e!==t||Fi(r.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&ju(e,i)}function ju(e,t){return Fi(t.enabled,e)!==!1&&e.isStaleByTime(Es(t.staleTime,e))}function GC(e,t){return!Uc(e.getCurrentResult(),t)}function Ff(e){return{onFetch:(t,i)=>{var d,u,f,_,p;const r=t.options,s=(f=(u=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:u.fetchMore)==null?void 0:f.direction,n=((_=t.state.data)==null?void 0:_.pages)||[],o=((p=t.state.data)==null?void 0:p.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const h=async()=>{let b=!1;const g=C=>{WC(C,()=>t.signal,()=>b=!0)},S=Qp(t.options,t.fetchOptions),O=async(C,y,x)=>{if(b)return Promise.reject();if(y==null&&C.pages.length)return Promise.resolve(C);const I=(()=>{const K={client:t.client,queryKey:t.queryKey,pageParam:y,direction:x?"backward":"forward",meta:t.options.meta};return g(K),K})(),z=await S(I),{maxPages:q}=t.options,J=x?FC:NC;return{pages:J(C.pages,z,q),pageParams:J(C.pageParams,y,q)}};if(s&&n.length){const C=s==="backward",y=C?XC:Wf,x={pages:n,pageParams:o},P=y(r,x);a=await O(x,P,C)}else{const C=e??n.length;do{const y=c===0?o[0]??r.initialPageParam:Wf(r,a);if(c>0&&y==null)break;a=await O(a,y),c++}while(c<C)}return a};t.options.persister?t.fetchFn=()=>{var b,g;return(g=(b=t.options).persister)==null?void 0:g.call(b,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i)}:t.fetchFn=h}}}function Wf(e,{pages:t,pageParams:i}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,i[r],i):void 0}function XC(e,{pages:t,pageParams:i}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,i[0],i):void 0}var aa,yr,ti,on,Sr,ss,Jf,$C=(Jf=class extends eg{constructor(t){super();ee(this,Sr);ee(this,aa);ee(this,yr);ee(this,ti);ee(this,on);j(this,aa,t.client),this.mutationId=t.mutationId,j(this,ti,t.mutationCache),j(this,yr,[]),this.state=t.state||QC(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){v(this,yr).includes(t)||(v(this,yr).push(t),this.clearGcTimeout(),v(this,ti).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){j(this,yr,v(this,yr).filter(i=>i!==t)),this.scheduleGc(),v(this,ti).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){v(this,yr).length||(this.state.status==="pending"?this.scheduleGc():v(this,ti).remove(this))}continue(){var t;return((t=v(this,on))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,c,h,d,u,f,_,p,b,g,S,O,C,y,x,P,I;const i=()=>{xe(this,Sr,ss).call(this,{type:"continue"})},r={client:v(this,aa),meta:this.options.meta,mutationKey:this.options.mutationKey};j(this,on,Jp({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(z,q)=>{xe(this,Sr,ss).call(this,{type:"failed",failureCount:z,error:q})},onPause:()=>{xe(this,Sr,ss).call(this,{type:"pause"})},onContinue:i,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>v(this,ti).canRun(this)}));const s=this.state.status==="pending",n=!v(this,on).canStart();try{if(s)i();else{xe(this,Sr,ss).call(this,{type:"pending",variables:t,isPaused:n}),v(this,ti).config.onMutate&&await v(this,ti).config.onMutate(t,this,r);const q=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,r));q!==this.state.context&&xe(this,Sr,ss).call(this,{type:"pending",context:q,variables:t,isPaused:n})}const z=await v(this,on).start();return await((h=(c=v(this,ti).config).onSuccess)==null?void 0:h.call(c,z,t,this.state.context,this,r)),await((u=(d=this.options).onSuccess)==null?void 0:u.call(d,z,t,this.state.context,r)),await((_=(f=v(this,ti).config).onSettled)==null?void 0:_.call(f,z,null,this.state.variables,this.state.context,this,r)),await((b=(p=this.options).onSettled)==null?void 0:b.call(p,z,null,t,this.state.context,r)),xe(this,Sr,ss).call(this,{type:"success",data:z}),z}catch(z){try{await((S=(g=v(this,ti).config).onError)==null?void 0:S.call(g,z,t,this.state.context,this,r))}catch(q){Promise.reject(q)}try{await((C=(O=this.options).onError)==null?void 0:C.call(O,z,t,this.state.context,r))}catch(q){Promise.reject(q)}try{await((x=(y=v(this,ti).config).onSettled)==null?void 0:x.call(y,void 0,z,this.state.variables,this.state.context,this,r))}catch(q){Promise.reject(q)}try{await((I=(P=this.options).onSettled)==null?void 0:I.call(P,void 0,z,t,this.state.context,r))}catch(q){Promise.reject(q)}throw xe(this,Sr,ss).call(this,{type:"error",error:z}),z}finally{v(this,ti).runNext(this)}}},aa=new WeakMap,yr=new WeakMap,ti=new WeakMap,on=new WeakMap,Sr=new WeakSet,ss=function(t){const i=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=i(this.state),ri.batch(()=>{v(this,yr).forEach(r=>{r.onMutationUpdate(t)}),v(this,ti).notify({mutation:this,type:"updated",action:t})})},Jf);function QC(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zr,tr,la,e_,ZC=(e_=class extends Sa{constructor(t={}){super();ee(this,zr);ee(this,tr);ee(this,la);this.config=t,j(this,zr,new Set),j(this,tr,new Map),j(this,la,0)}build(t,i,r){const s=new $C({client:t,mutationCache:this,mutationId:++Ca(this,la)._,options:t.defaultMutationOptions(i),state:r});return this.add(s),s}add(t){v(this,zr).add(t);const i=Ia(t);if(typeof i=="string"){const r=v(this,tr).get(i);r?r.push(t):v(this,tr).set(i,[t])}this.notify({type:"added",mutation:t})}remove(t){if(v(this,zr).delete(t)){const i=Ia(t);if(typeof i=="string"){const r=v(this,tr).get(i);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&v(this,tr).delete(i)}}this.notify({type:"removed",mutation:t})}canRun(t){const i=Ia(t);if(typeof i=="string"){const r=v(this,tr).get(i),s=r==null?void 0:r.find(n=>n.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const i=Ia(t);if(typeof i=="string"){const s=(r=v(this,tr).get(i))==null?void 0:r.find(n=>n!==t&&n.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ri.batch(()=>{v(this,zr).forEach(t=>{this.notify({type:"removed",mutation:t})}),v(this,zr).clear(),v(this,tr).clear()})}getAll(){return Array.from(v(this,zr))}find(t){const i={exact:!0,...t};return this.getAll().find(r=>Af(i,r))}findAll(t={}){return this.getAll().filter(i=>Af(t,i))}notify(t){ri.batch(()=>{this.listeners.forEach(i=>{i(t)})})}resumePausedMutations(){const t=this.getAll().filter(i=>i.state.isPaused);return ri.batch(()=>Promise.all(t.map(i=>i.continue().catch(Ii))))}},zr=new WeakMap,tr=new WeakMap,la=new WeakMap,e_);function Ia(e){var t;return(t=e.options.scope)==null?void 0:t.id}var wr,t_,JC=(t_=class extends Sa{constructor(t={}){super();ee(this,wr);this.config=t,j(this,wr,new Map)}build(t,i,r){const s=i.queryKey,n=i.queryHash??Uu(s,i);let o=this.get(n);return o||(o=new jC({client:t,queryKey:s,queryHash:n,options:t.defaultQueryOptions(i),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){v(this,wr).has(t.queryHash)||(v(this,wr).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const i=v(this,wr).get(t.queryHash);i&&(t.destroy(),i===t&&v(this,wr).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ri.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return v(this,wr).get(t)}getAll(){return[...v(this,wr).values()]}find(t){const i={exact:!0,...t};return this.getAll().find(r=>Pf(i,r))}findAll(t={}){const i=this.getAll();return Object.keys(t).length>0?i.filter(r=>Pf(t,r)):i}notify(t){ri.batch(()=>{this.listeners.forEach(i=>{i(t)})})}onFocus(){ri.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ri.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},wr=new WeakMap,t_),ct,fs,_s,Qn,Zn,vs,Jn,eo,i_,rg=(i_=class{constructor(e={}){ee(this,ct);ee(this,fs);ee(this,_s);ee(this,Qn);ee(this,Zn);ee(this,vs);ee(this,Jn);ee(this,eo);j(this,ct,e.queryCache||new JC),j(this,fs,e.mutationCache||new ZC),j(this,_s,e.defaultOptions||{}),j(this,Qn,new Map),j(this,Zn,new Map),j(this,vs,0)}mount(){Ca(this,vs)._++,v(this,vs)===1&&(j(this,Jn,qu.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,ct).onFocus())})),j(this,eo,bl.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,ct).onOnline())})))}unmount(){var e,t;Ca(this,vs)._--,v(this,vs)===0&&((e=v(this,Jn))==null||e.call(this),j(this,Jn,void 0),(t=v(this,eo))==null||t.call(this),j(this,eo,void 0))}isFetching(e){return v(this,ct).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return v(this,fs).findAll({...e,status:"pending"}).length}getQueryData(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=v(this,ct).get(t.queryHash))==null?void 0:i.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),i=v(this,ct).build(this,t),r=i.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime(Es(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return v(this,ct).findAll(e).map(({queryKey:t,state:i})=>{const r=i.data;return[t,r]})}setQueryData(e,t,i){const r=this.defaultQueryOptions({queryKey:e}),s=v(this,ct).get(r.queryHash),n=s==null?void 0:s.state.data,o=LC(t,n);if(o!==void 0)return v(this,ct).build(this,r).setData(o,{...i,manual:!0})}setQueriesData(e,t,i){return ri.batch(()=>v(this,ct).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,i)]))}getQueryState(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=v(this,ct).get(t.queryHash))==null?void 0:i.state}removeQueries(e){const t=v(this,ct);ri.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=v(this,ct);return ri.batch(()=>(i.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},r=ri.batch(()=>v(this,ct).findAll(e).map(s=>s.cancel(i)));return Promise.all(r).then(Ii).catch(Ii)}invalidateQueries(e,t={}){return ri.batch(()=>(v(this,ct).findAll(e).forEach(i=>{i.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const i={...t,cancelRefetch:t.cancelRefetch??!0},r=ri.batch(()=>v(this,ct).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let n=s.fetch(void 0,i);return i.throwOnError||(n=n.catch(Ii)),s.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(r).then(Ii)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const i=v(this,ct).build(this,t);return i.isStaleByTime(Es(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ii).catch(Ii)}fetchInfiniteQuery(e){return e.behavior=Ff(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ii).catch(Ii)}ensureInfiniteQueryData(e){return e.behavior=Ff(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return bl.isOnline()?v(this,fs).resumePausedMutations():Promise.resolve()}getQueryCache(){return v(this,ct)}getMutationCache(){return v(this,fs)}getDefaultOptions(){return v(this,_s)}setDefaultOptions(e){j(this,_s,e)}setQueryDefaults(e,t){v(this,Qn).set(Zo(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...v(this,Qn).values()],i={};return t.forEach(r=>{Jo(e,r.queryKey)&&Object.assign(i,r.defaultOptions)}),i}setMutationDefaults(e,t){v(this,Zn).set(Zo(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...v(this,Zn).values()],i={};return t.forEach(r=>{Jo(e,r.mutationKey)&&Object.assign(i,r.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={...v(this,_s).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Uu(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ku&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...v(this,_s).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){v(this,ct).clear(),v(this,fs).clear()}},ct=new WeakMap,fs=new WeakMap,_s=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,vs=new WeakMap,Jn=new WeakMap,eo=new WeakMap,i_);const sg=Symbol("QueryClient"),ek=()=>{const e=f_(sg);if(!e)throw new Error("No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?");return e},tk=e=>{im(sg,e)},ik=Symbol("isRestoring"),rk=()=>{try{return f_(ik)??{current:!1}}catch{return{current:!1}}};function sk(){return rk()}function nk(e){return ek()}var ok=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],ak=["difference","intersection","symmetricDifference","union"],Hf=!1,to,ir,ps,Cl,uo,ng,og;const kl=class kl extends Set{constructor(i){super();ee(this,uo);ee(this,to,new Map);ee(this,ir,F(0));ee(this,ps,F(0));ee(this,Cl,Vr||-1);if(i){for(var r of i)super.add(r);v(this,ps).v=super.size}Hf||xe(this,uo,og).call(this)}has(i){var r=super.has(i),s=v(this,to),n=s.get(i);if(n===void 0){if(!r)return l(v(this,ir)),!1;n=xe(this,uo,ng).call(this,!0),s.set(i,n)}return l(n),r}add(i){return super.has(i)||(super.add(i),m(v(this,ps),super.size),Cs(v(this,ir))),this}delete(i){var r=super.delete(i),s=v(this,to),n=s.get(i);return n!==void 0&&(s.delete(i),m(n,!1)),r&&(m(v(this,ps),super.size),Cs(v(this,ir))),r}clear(){if(super.size!==0){super.clear();var i=v(this,to);for(var r of i.values())m(r,!1);i.clear(),m(v(this,ps),0),Cs(v(this,ir))}}keys(){return this.values()}values(){return l(v(this,ir)),super.values()}entries(){return l(v(this,ir)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return l(v(this,ps))}};to=new WeakMap,ir=new WeakMap,ps=new WeakMap,Cl=new WeakMap,uo=new WeakSet,ng=function(i){return Vr===v(this,Cl)?F(i):Ds(i)},og=function(){Hf=!0;var i=kl.prototype,r=Set.prototype;for(const s of ok)i[s]=function(...n){return l(v(this,ir)),r[s].apply(this,n)};for(const s of ak)i[s]=function(...n){l(v(this,ir));var o=r[s].apply(this,n);return new kl(o)}};let tu=kl;function lk(e){const t=Array.isArray(e)?[]:{},i=new tu,r=new Proxy(t,{set(n,o,a,c){if(i.delete(o),o in n)return Reflect.set(n,o,a,c);let h=F(a);return Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:()=>l(h)&&ck(l(h))?l(h)():l(h),set:d=>{m(h,d)}}),!0},has:(n,o)=>i.has(o)?!1:o in n,ownKeys(n){return Reflect.ownKeys(n).filter(o=>!i.has(o))},getOwnPropertyDescriptor(n,o){if(!i.has(o))return Reflect.getOwnPropertyDescriptor(n,o)},deleteProperty(n,o){return o in n?(n[o]=void 0,i.add(o),Array.isArray(n)&&n.length--,!0):!1}});function s(n){const o=Object.keys(r),a=Object.keys(n),c=o.filter(h=>!a.includes(h));for(const h of c)delete r[h];for(const h of a)r[h]=hk(()=>n[h])}return s(e),[r,s]}const ag=Symbol("LazyValue");function hk(e){return e[ag]=!0,e}function ck(e){return!!e[ag]}function uk(e,t){switch(e){case"post":zi(t);break;case"pre":Am(t);break}}const bh=(e,t,i)=>{let r=!1,s=Array.isArray(e)?[]:void 0;uk(t,()=>{const n=Array.isArray(e)?e.map(a=>a()):e();if(!r){r=!0,s=n;return}const o=Qr(()=>i(n,s));return s=n,o})};function dk(e,t,i){const r=me(()=>nk()),s=sk(),n=me(()=>{const d=l(r).defaultQueryOptions(e());return d._optimisticResults=s.current?"isRestoring":"optimistic",d});let o=F($e(new t(l(r),l(n))));bh(()=>l(r),"pre",()=>{m(o,new t(l(r),l(n)),!0)});function a(){const d=l(o).getOptimisticResult(l(n));return l(n).notifyOnChangeProps?d:l(o).trackResult(d)}const[c,h]=lk(a());return zi(()=>{const d=s.current?()=>{}:l(o).subscribe(()=>h(a()));return l(o).updateResult(),d}),bh(()=>l(n),"pre",()=>{l(o).setOptions(l(n))}),bh(()=>[l(n),l(o)],"pre",()=>{h(a())}),c}function yl(e,t){return dk(e,YC)}function fk(e,t){dt(t,!0);const i=Pr(t,"client",19,()=>new rg);vo(()=>{i().mount()}),tk(i()),hb(()=>{i().unmount()});var r=Gr(),s=Ct(r);$m(s,()=>t.children),B(e,r),ft()}var _k=W('<div class="branch-error svelte-1ogsozk"> </div>'),vk=W('<div class="branch-loading svelte-1ogsozk">Loading...</div>'),pk=W('<div class="branch-empty svelte-1ogsozk">No branches match</div>'),gk=W('<span class="branch-check svelte-1ogsozk">✓</span>'),mk=W('<span class="branch-check branch-check--empty svelte-1ogsozk"></span>'),bk=W('<span class="branch-spinner svelte-1ogsozk">…</span>'),yk=W('<li role="option"><!> <span class="branch-option-name svelte-1ogsozk"> </span> <!></li>'),Sk=W('<ul class="branch-list svelte-1ogsozk"></ul>'),wk=W('<div class="branch-dropdown svelte-1ogsozk" role="listbox" tabindex="-1" aria-label="Branches"><div class="branch-filter-wrap svelte-1ogsozk"><input type="text" class="branch-filter svelte-1ogsozk" placeholder="Filter branches..." aria-label="Filter branches"/></div> <!> <!></div>'),Ck=W('<div class="branch-switcher svelte-1ogsozk"><button class="branch-trigger svelte-1ogsozk" aria-label="Switch branch" aria-haspopup="listbox"><span class="branch-icon svelte-1ogsozk">⑂</span> <span class="branch-name svelte-1ogsozk"> </span> <svg class="branch-caret svelte-1ogsozk" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5" stroke-linecap="round"></path></svg></button> <!></div>');function kk(e,t){dt(t,!0);let i=F(!1),r=F(""),s=F(null),n=F(null),o=F(null),a=F(null);const c=yl(()=>({queryKey:["branches",t.workspacePath],queryFn:()=>rv(t.workspacePath),staleTime:3e4,enabled:l(i)}));let h=me(()=>{const x=c.data??[];if(!l(r).trim())return x;const P=l(r).toLowerCase();return x.filter(I=>I.toLowerCase().includes(P))});function d(){m(i,!0),m(r,""),m(a,null),requestAnimationFrame(()=>{var x;return(x=l(n))==null?void 0:x.focus()})}function u(){m(i,!1),m(r,"")}async function f(x){if(x===t.currentBranch){u();return}m(o,x,!0),m(a,null);try{const P=await wb(t.workspacePath,x);P.success?(u(),t.onSwitch(x)):m(a,P.error??"Failed to switch branch",!0)}catch{m(a,"Failed to switch branch")}finally{m(o,null)}}function _(x){l(i)&&l(s)&&document.contains(x.target)&&!l(s).contains(x.target)&&u()}function p(x){x.key==="Escape"&&l(i)&&(u(),x.stopPropagation())}var b=Ck();xr("click",Ja,_);var g=w(b),S=R(w(g),2),O=w(S),C=R(g,2);{var y=x=>{var P=wk(),I=w(P),z=w(I);Ze(z,L=>m(n,L),()=>l(n));var q=R(I,2);{var J=L=>{var H=_k(),D=w(H);he(()=>ne(D,l(a))),B(L,H)};ie(q,L=>{l(a)&&L(J)})}var K=R(q,2);{var N=L=>{var H=vk();B(L,H)},A=L=>{var H=pk();B(L,H)},T=L=>{var H=Sk();si(H,20,()=>l(h),D=>D,(D,E)=>{var $=yk();let Q;var pe=w($);{var be=Se=>{var de=gk();B(Se,de)},ce=Se=>{var de=mk();B(Se,de)};ie(pe,Se=>{E===t.currentBranch?Se(be):Se(ce,!1)})}var se=R(pe,2),De=w(se),Te=R(se,2);{var _e=Se=>{var de=bk();B(Se,de)};ie(Te,Se=>{l(o)===E&&Se(_e)})}he(()=>{Q=it($,1,"branch-option svelte-1ogsozk",null,Q,{"branch-current":E===t.currentBranch,"branch-switching":l(o)===E}),Ie($,"aria-selected",E===t.currentBranch),ne(De,E)}),G("mousedown",$,()=>f(E)),B(D,$)}),B(L,H)};ie(K,L=>{c.isLoading?L(N):l(h).length===0?L(A,1):L(T,!1)})}G("keydown",P,p),G("keydown",z,p),rr(z,()=>l(r),L=>m(r,L)),B(x,P)};ie(C,x=>{l(i)&&x(y)})}Ze(b,x=>m(s,x),()=>l(s)),he(()=>{Ie(g,"aria-expanded",l(i)),ne(O,t.currentBranch)}),G("click",g,d),B(e,b),ft()}_t(["click","keydown","mousedown"]);var xk=W('<span class="target-branch svelte-1shtc4l" aria-label="target branch"><span class="target-sep svelte-1shtc4l">›</span> <span class="target-name svelte-1shtc4l"> </span></span>'),Ek=W('<div class="bar-middle svelte-1shtc4l" aria-label="pull request"><a class="pr-link svelte-1shtc4l" target="_blank" rel="noopener noreferrer" data-track="pr-top-bar.open-pr"> <svg class="pr-ext-icon svelte-1shtc4l" width="10" height="10" viewBox="0 0 10 10" aria-hidden="true"><path d="M1 9L9 1M9 1H4M9 1V6" stroke="currentColor" fill="none" stroke-width="1.5" stroke-linecap="round"></path></svg></a></div> <span class="diff-stats svelte-1shtc4l"><span class="diff-add svelte-1shtc4l"> </span> <span class="diff-del svelte-1shtc4l"> </span></span>',1),Dk=W('<span class="bar-loading svelte-1shtc4l">…</span>'),Tk=W('<button class="action-btn action-btn--secondary svelte-1shtc4l" data-track="pr-top-bar.secondary-action"> </button>'),Rk=W('<button data-track="pr-top-bar.primary-action"> </button>'),Pk=W("<!> <!>",1),Ak=W('<div><div class="bar-left svelte-1shtc4l"><!> <!></div> <!> <div class="bar-right svelte-1shtc4l"><!></div></div>');function Mk(e,t){dt(t,!0);let i=F($e(t.branchName));zi(()=>{m(i,t.branchName,!0)}),zi(()=>{!t.branchName&&t.workspacePath&&Sb(t.workspacePath).then(K=>{K&&m(i,K,!0)})});const r=yl(()=>({queryKey:["pr",t.workspacePath,l(i)],queryFn:()=>yb(t.workspacePath,l(i)),staleTime:6e4,refetchOnWindowFocus:!0})),s=yl(()=>{var K;return{queryKey:["ci-status",t.workspacePath,l(i)],queryFn:()=>bb(t.workspacePath,l(i)),staleTime:3e4,refetchOnWindowFocus:!0,enabled:((K=r.data)==null?void 0:K.state)==="OPEN"}});zi(()=>{t.sessionId&&(r.refetch(),s.refetch())});let n=me(()=>r.data??null),o=me(()=>s.data??null),a=me(()=>{var K,N,A,T,L,H;return{commitsAhead:l(n)?1:0,prState:l(n)?l(n).isDraft?"DRAFT":l(n).state:null,ciPassing:((K=l(o))==null?void 0:K.passing)??0,ciFailing:((N=l(o))==null?void 0:N.failing)??0,ciPending:((A=l(o))==null?void 0:A.pending)??0,ciTotal:((T=l(o))==null?void 0:T.total)??0,mergeable:((L=l(n))==null?void 0:L.mergeable)??null,unresolvedCommentCount:((H=l(n))==null?void 0:H.unresolvedCommentCount)??0}}),c=me(()=>ku(l(a))),h=me(()=>fy(l(c),l(a))),d=me(()=>Nv(l(c).color)),u=me(()=>Fv(l(c).color)),f=me(()=>l(c).type!=="none");function _(K=l(c)){var T,L,H,D;const N={branchName:l(i),baseBranch:((T=l(n))==null?void 0:T.baseRefName)??"",prNumber:((L=l(n))==null?void 0:L.number)??0,unresolvedCommentCount:((H=l(n))==null?void 0:H.unresolvedCommentCount)??0},A=Bv(K,N);A!==null?t.sessionId&&Cr(A+"\r"):(D=t.onArchive)==null||D.call(t)}function p(K){m(i,K,!0)}var b=Ak();let g;var S=w(b),O=w(S);kk(O,{get workspacePath(){return t.workspacePath},get currentBranch(){return l(i)},onSwitch:p});var C=R(O,2);{var y=K=>{var N=xk(),A=R(w(N),2),T=w(A);he(()=>ne(T,l(n).baseRefName)),B(K,N)};ie(C,K=>{var N;(N=l(n))!=null&&N.baseRefName&&K(y)})}var x=R(S,2);{var P=K=>{var N=Ek(),A=Ct(N),T=w(A),L=w(T),H=R(A,2),D=w(H),E=w(D),$=R(D,2),Q=w($);he(()=>{Ie(T,"href",l(n).url),Ie(T,"aria-label",`PR #${l(n).number??""}: ${l(n).title??""}`),ne(L,`PR #${l(n).number??""} `),ne(E,`+${l(n).additions??""}`),ne(Q,`-${l(n).deletions??""}`)}),B(K,N)};ie(x,K=>{l(n)&&K(P)})}var I=R(x,2),z=w(I);{var q=K=>{var N=Dk();B(K,N)},J=K=>{var N=Pk(),A=Ct(N);{var T=D=>{var E=Tk(),$=w(E);he(()=>{Ie(E,"aria-label",l(h).label),ne($,l(h).label)}),G("click",E,()=>_(l(h))),B(D,E)};ie(A,D=>{l(h)&&D(T)})}var L=R(A,2);{var H=D=>{var E=Rk();let $,Q;var pe=w(E);he(()=>{$=it(E,1,"action-btn svelte-1shtc4l",null,$,{"action-btn--dark-text":l(u),"action-btn--disabled":l(c).type==="checks-running"}),E.disabled=l(c).type==="checks-running",Ie(E,"aria-label",l(c).label),Q=_o(E,"",Q,{"--action-color":l(d)}),ne(pe,l(c).label)}),G("click",E,()=>_()),B(D,E)};ie(L,D=>{l(f)&&D(H)})}B(K,N)};ie(z,K=>{r.isLoading?K(q):K(J,!1)})}he(()=>{var K,N;return g=it(b,1,"pr-top-bar svelte-1shtc4l",null,g,{"bar-merged":((K=l(n))==null?void 0:K.state)==="MERGED","bar-conflicts":((N=l(n))==null?void 0:N.mergeable)==="CONFLICTING"})}),B(e,b),ft()}_t(["click"]);var Ok=W('<button role="tab" data-track="session-tab.select"><span class="tab-icon svelte-3dfyyn" aria-hidden="true"> </span> <span class="tab-name svelte-3dfyyn"> </span> <span class="tab-close svelte-3dfyyn" role="button" data-track="session-tab.close">×</span></button>'),Lk=W('<div class="new-menu svelte-3dfyyn" role="menu" tabindex="-1"><button class="new-menu-item svelte-3dfyyn" role="menuitem" data-track="session-tab.new-agent"><span class="new-menu-icon svelte-3dfyyn">🤖</span> New Agent</button> <button class="new-menu-item svelte-3dfyyn" role="menuitem" data-track="session-tab.new-terminal"><span class="new-menu-icon svelte-3dfyyn">🖥</span> New Terminal</button> <div class="new-menu-divider svelte-3dfyyn"></div> <button class="new-menu-item svelte-3dfyyn" role="menuitem" data-track="session-tab.customize"><span class="new-menu-icon svelte-3dfyyn">⚙</span> Customize...</button></div>'),Ik=W('<div class="session-tab-bar svelte-3dfyyn" role="tablist" aria-label="Sessions"><div class="tabs-scroll svelte-3dfyyn"></div> <div class="new-btn-wrap svelte-3dfyyn"><button class="tab-new svelte-3dfyyn" aria-label="New session" aria-haspopup="menu" data-track="session-tab.new-menu">+</button> <!></div></div>');function Bk(e,t){dt(t,!0);let i=F(!1),r=F(null);function s(C){return C.type==="terminal"?"🖥":"🤖"}function n(C,y){C.stopPropagation(),t.onCloseSession(y)}function o(C,y){(C.key==="Enter"||C.key===" ")&&(C.stopPropagation(),t.onCloseSession(y))}function a(){m(i,!l(i))}function c(){m(i,!1),t.onNewAgent()}function h(){m(i,!1),t.onNewTerminal()}function d(){m(i,!1),t.onCustomize()}function u(C){var y;l(i)&&l(r)&&document.contains(C.target)&&!((y=l(r).closest(".new-btn-wrap"))!=null&&y.contains(C.target))&&m(i,!1)}function f(C){var y;C.key==="Escape"&&l(i)&&(m(i,!1),(y=l(r))==null||y.focus())}var _=Ik();xr("click",Ja,u);var p=w(_);si(p,21,()=>t.sessions,C=>C.id,(C,y)=>{const x=me(()=>l(y).id===t.activeSessionId);var P=Ok();let I;var z=w(P),q=w(z),J=R(z,2),K=w(J),N=R(J,2);he(A=>{I=it(P,1,"tab svelte-3dfyyn",null,I,{"tab--active":l(x)}),Ie(P,"aria-selected",l(x)),Ie(P,"aria-label",l(y).displayName||l(y).id),Ie(P,"tabindex",l(x)?0:-1),ne(q,A),ne(K,l(y).displayName||l(y).id),Ie(N,"aria-label",`Close ${(l(y).displayName||l(y).id)??""}`)},[()=>s(l(y))]),G("click",P,()=>t.onSelectSession(l(y).id)),G("click",N,A=>n(A,l(y).id)),G("keydown",N,A=>o(A,l(y).id)),B(C,P)});var b=R(p,2),g=w(b);Ze(g,C=>m(r,C),()=>l(r));var S=R(g,2);{var O=C=>{var y=Lk(),x=w(y),P=R(x,2),I=R(P,4);G("keydown",y,f),G("click",x,c),G("click",P,h),G("click",I,d),B(C,y)};ie(S,C=>{l(i)&&C(O)})}he(()=>Ie(g,"aria-expanded",l(i))),G("click",g,a),G("keydown",g,f),B(e,_),ft()}_t(["click","keydown"]);var Nk=W('<div class="non-git-notice svelte-bvvs2r"><span class="non-git-msg svelte-bvvs2r">Not a git repository</span></div>'),Fk=W('<div class="pr-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-title svelte-bvvs2r"></div> <div class="skeleton-line skeleton-meta svelte-bvvs2r"></div></div>'),Wk=W('<div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>'),Hk=W('<div class="section-message svelte-bvvs2r">Could not load pull requests</div>'),zk=W('<div class="section-message info svelte-bvvs2r">Install GitHub CLI for PR tracking — <a href="https://cli.github.com" target="_blank" rel="noopener noreferrer" class="svelte-bvvs2r">cli.github.com</a></div>'),Uk=W('<div class="section-message svelte-bvvs2r">No open pull requests</div>'),Kk=W('<input class="pr-search svelte-bvvs2r" type="text" placeholder="Filter PRs by title, number, or branch..."/>'),qk=W('<button class="pr-action-pill pr-conflict-pill svelte-bvvs2r" title="Open worktree and fix merge conflicts">Fix Conflicts</button>'),jk=W('<a class="pr-action-pill pr-merge-pill svelte-bvvs2r" target="_blank" rel="noopener noreferrer" title="Ready to merge on GitHub">Merge</a>'),Yk=W("<button> </button>"),Vk=W('<div class="pr-row svelte-bvvs2r"><div class="pr-row-left svelte-bvvs2r"><div class="pr-row-title-line svelte-bvvs2r"><span></span> <a class="pr-title-link svelte-bvvs2r" target="_blank" rel="noopener noreferrer"> </a></div> <div class="pr-row-meta svelte-bvvs2r"><span class="pr-num svelte-bvvs2r"> </span> <span class="pr-sep svelte-bvvs2r">·</span> <span class="pr-role svelte-bvvs2r"> </span> <span class="pr-sep svelte-bvvs2r">·</span> <span class="pr-time svelte-bvvs2r"> </span></div></div> <div class="pr-row-actions svelte-bvvs2r"><button class="pr-session-btn svelte-bvvs2r" title="Open session on this branch">+</button> <!> <!> <!></div></div>'),Gk=W('<!> <div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>',1),Xk=W('<div class="activity-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-activity svelte-bvvs2r"></div></div>'),$k=W('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),Qk=W('<div class="section-message svelte-bvvs2r">No recent commits (24h)</div>'),Zk=W('<span class="commit-branch svelte-bvvs2r"> </span>'),Jk=W('<div class="activity-row svelte-bvvs2r"><span class="commit-hash svelte-bvvs2r"> </span> <span class="commit-msg svelte-bvvs2r"> </span> <!> <span class="commit-time svelte-bvvs2r"> </span></div>'),ex=W('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),tx=W('<section class="dashboard-section dashboard-section--scroll svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">OPEN PULL REQUESTS</div> <!></section> <section class="dashboard-section dashboard-section--scroll svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">RECENT ACTIVITY</div> <!></section>',1),ix=W('<button class="cta-btn svelte-bvvs2r"> </button>'),rx=W('<div class="repo-dashboard svelte-bvvs2r"><!> <div class="cta-row svelte-bvvs2r"><button class="cta-btn svelte-bvvs2r">+ Start Session</button> <!></div></div>');function sx(e,t){dt(t,!0);let i=Pr(t,"creatingWorktree",3,!1);const r=yl(()=>({queryKey:["dashboard",t.workspacePath],queryFn:()=>mb(t.workspacePath),staleTime:6e4,refetchOnWindowFocus:!0}));let s=me(()=>r.data),n=me(()=>r.isLoading),o=me(()=>r.isError);function a(P){return P.state!=="OPEN"?"dot dot-muted":P.reviewDecision==="CHANGES_REQUESTED"?"dot dot-error":"dot dot-success"}function c(P){const I=P.state==="OPEN"?"OPEN":P.state==="MERGED"?"MERGED":"CLOSED";return ku({commitsAhead:1,prState:I,ciFailing:0,ciPending:0,ciTotal:0,mergeable:P.mergeable??null,unresolvedCommentCount:0})}function h(P){return P.role==="author"?"by you":"review requested"}function d(P){return!P.branches||P.branches.length===0?"":"("+P.branches.join(", ")+")"}let u=F(""),f=me(()=>l(s)?l(s).prs.length>5:!1),_=me(()=>()=>{if(!l(s))return[];const P=l(u).toLowerCase().trim();return P?l(s).prs.filter(I=>I.title.toLowerCase().includes(P)||String(I.number).includes(P)||I.headRefName.toLowerCase().includes(P)):l(s).prs});var p=rx(),b=w(p);{var g=P=>{var I=Nk();B(P,I)},S=P=>{var I=tx(),z=Ct(I),q=R(w(z),2);{var J=Q=>{var pe=Wk(),be=w(pe);si(be,20,()=>[1,2],Yo,(ce,se)=>{var De=Fk();B(ce,De)}),B(Q,pe)},K=Q=>{var pe=Hk();B(Q,pe)},N=Q=>{var pe=zk();B(Q,pe)},A=Q=>{var pe=Uk();B(Q,pe)},T=Q=>{var pe=Gk(),be=Ct(pe);{var ce=Te=>{var _e=Kk();rr(_e,()=>l(u),Se=>m(u,Se)),B(Te,_e)};ie(be,Te=>{l(f)&&Te(ce)})}var se=R(be,2),De=w(se);si(De,21,()=>l(_)(),Te=>Te.number,(Te,_e)=>{const Se=me(()=>c(l(_e))),de=me(()=>Nv(l(Se).color)),Me=me(()=>Fv(l(Se).color));var Ne=Vk(),je=w(Ne),Pe=w(je),et=w(Pe),X=R(et,2),ve=w(X),Fe=R(Pe,2),Ke=w(Fe),Be=w(Ke),k=R(Ke,4),Z=w(k),fe=R(k,4),ye=w(fe),Ce=R(je,2),M=w(Ce),Y=R(M,2);{var ge=Re=>{var oe=qk();G("click",oe,()=>t.onFixConflicts(l(_e))),B(Re,oe)};ie(Y,Re=>{l(_e).mergeable==="CONFLICTING"&&Re(ge)})}var le=R(Y,2);{var re=Re=>{var oe=jk();he(()=>Ie(oe,"href",l(_e).url)),B(Re,oe)};ie(le,Re=>{l(_e).mergeable==="MERGEABLE"&&l(_e).state==="OPEN"&&Re(re)})}var ke=R(le,2);{var we=Re=>{var oe=Yk();let Ee,Ge;var qt=w(oe);he(()=>{Ee=it(oe,1,"pr-action-pill svelte-bvvs2r",null,Ee,{"dark-text":l(Me)}),Ie(oe,"title",l(Se).label),Ge=_o(oe,"",Ge,{"--pill-color":l(de)}),ne(qt,l(Se).label)}),G("click",oe,()=>t.onPrAction(l(_e))),B(Re,oe)};ie(ke,Re=>{l(Se).type!=="none"&&l(Se).label&&Re(we)})}he((Re,oe,Ee)=>{it(et,1,Re,"svelte-bvvs2r"),Ie(X,"href",l(_e).url),ne(ve,l(_e).title),ne(Be,`#${l(_e).number??""}`),ne(Z,oe),ne(ye,Ee)},[()=>ev(a(l(_e))),()=>h(l(_e)),()=>dy(l(_e).updatedAt)]),G("click",M,()=>t.onOpenPrSession(l(_e))),B(Te,Ne)}),B(Q,pe)};ie(q,Q=>{l(n)?Q(J):l(o)?Q(K,1):l(s)&&!l(s).hasGhCli?Q(N,2):l(s)&&l(s).prs.length===0?Q(A,3):l(s)&&Q(T,4)})}var L=R(z,2),H=R(w(L),2);{var D=Q=>{var pe=$k(),be=w(pe);si(be,20,()=>[1,2,3],Yo,(ce,se)=>{var De=Xk();B(ce,De)}),B(Q,pe)},E=Q=>{var pe=Qk();B(Q,pe)},$=Q=>{var pe=ex(),be=w(pe);si(be,21,()=>l(s).activity,ce=>ce.hash,(ce,se)=>{var De=Jk(),Te=w(De),_e=w(Te),Se=R(Te,2),de=w(Se),Me=R(Se,2);{var Ne=et=>{var X=Zk(),ve=w(X);he(Fe=>ne(ve,Fe),[()=>d(l(se))]),B(et,X)};ie(Me,et=>{l(se).branches.length>0&&et(Ne)})}var je=R(Me,2),Pe=w(je);he(()=>{ne(_e,l(se).shortHash),ne(de,l(se).message),ne(Pe,l(se).timeAgo)}),B(ce,De)}),B(Q,pe)};ie(H,Q=>{l(n)?Q(D):l(s)&&l(s).activity.length===0?Q(E,1):l(s)&&Q($,2)})}B(P,I)};ie(b,P=>{l(s)&&!l(s).isGitRepo?P(g):P(S,!1)})}var O=R(b,2),C=w(O),y=R(C,2);{var x=P=>{var I=ix(),z=w(I);he(()=>{I.disabled=i(),ne(z,i()?"Creating...":"+ New Worktree")}),G("click",I,function(...q){var J;(J=t.onNewWorktree)==null||J.apply(this,q)}),B(P,I)};ie(y,P=>{(!l(s)||l(s).isGitRepo)&&P(x)})}G("click",C,function(...P){var I;(I=t.onNewSession)==null||I.apply(this,P)}),B(e,p),ft()}_t(["click"]);var nx=W('<div class="empty-icon svelte-1luen49" aria-hidden="true"> </div>'),ox=W('<p class="empty-description svelte-1luen49"> </p>'),ax=W('<button class="empty-action svelte-1luen49"> </button>'),lx=W('<div class="empty-state svelte-1luen49"><!> <div class="empty-heading svelte-1luen49"> </div> <!> <!></div>');function hx(e,t){var i=lx(),r=w(i);{var s=u=>{var f=nx(),_=w(f);he(()=>ne(_,t.icon)),B(u,f)};ie(r,u=>{t.icon&&u(s)})}var n=R(r,2),o=w(n),a=R(n,2);{var c=u=>{var f=ox(),_=w(f);he(()=>ne(_,t.description)),B(u,f)};ie(a,u=>{t.description&&u(c)})}var h=R(a,2);{var d=u=>{var f=ax(),_=w(f);he(()=>ne(_,t.actionLabel)),G("click",f,function(...p){var b;(b=t.onAction)==null||b.apply(this,p)}),B(u,f)};ie(h,u=>{t.actionLabel&&t.onAction&&u(d)})}he(()=>ne(o,t.heading)),B(e,i)}_t(["click"]);var cx=W("<button><!></button>"),ux=W("<button><!></button>"),dx=W('<div class="toolbar svelte-k7we1m" role="toolbar"><div class="toolbar-grid svelte-k7we1m"><!></div></div>');function fx(e,t){dt(t,!0),Pr(t,"useTmux",3,!1);let i=Pr(t,"inCopyMode",3,!1);const r=[{html:"Tab",key:" ",label:"Tab"},{html:"&#8679;Tab",key:"\x1B[Z",label:"Shift+Tab"},{html:"&#8593;",key:"\x1B[A",label:"Up arrow",extraClass:"tb-arrow"},{html:"Esc",key:"\x1B",label:"Escape"},{html:"&#128247;",id:"upload-image-btn",label:"Upload image"},{html:"^V",id:"paste-btn",label:"Paste from clipboard"},{html:"^C",key:"",label:"Ctrl+C"},{html:"&#8592;",key:"\x1B[D",label:"Left arrow",extraClass:"tb-arrow"},{html:"&#8595;",key:"\x1B[B",label:"Down arrow",extraClass:"tb-arrow"},{html:"&#8594;",key:"\x1B[C",label:"Right arrow",extraClass:"tb-arrow"},{html:"&#8679;&#9166;",key:"\x1B[13;2u",label:"Shift+Enter (newline)",extraClass:"tb-newline"},{html:"&#9166;",key:"\r",label:"Enter",extraClass:"tb-enter"}],s=[{html:"Sel",key:" ",label:"Start selection"},{html:"w",key:"w",label:"Word forward"},{html:"b",key:"b",label:"Word backward"},{html:"&#8592;",key:"h",label:"Left",extraClass:"tb-arrow"},{html:"&#8595;",key:"j",label:"Down",extraClass:"tb-arrow"},{html:"&#8593;",key:"k",label:"Up",extraClass:"tb-arrow"},{html:"&#8594;",key:"l",label:"Right",extraClass:"tb-arrow"},{html:"$",key:"$",label:"End of line"},{html:"0",key:"0",label:"Start of line"},{html:"PgUp",key:"\x1B[5~",label:"Page up"},{html:"Copy",key:"\r",label:"Copy and exit",extraClass:"tb-enter",exitsCopyMode:!0},{html:"Exit",key:"q",label:"Cancel",exitsCopyMode:!0}];function n(u){var f;if(u.id==="upload-image-btn"){t.onUploadImage(),Nt&&t.onRefocusMobileInput();return}if(u.id==="paste-btn"){(f=navigator.clipboard)!=null&&f.readText?navigator.clipboard.readText().then(_=>{_&&t.onSendKey(_)}).catch(()=>{t.onUploadImage()}):t.onUploadImage(),Nt&&t.onRefocusMobileInput();return}u.key&&((u.key==="\r"||u.key==="\x1B[13;2u")&&t.onFlushComposedText(),t.onSendKey(u.key),(u.key==="\r"||u.key==="\x1B[13;2u")&&t.onClearInput(),Nt&&t.onRefocusMobileInput())}function o(u){var f;t.onSendKey(u.key),u.exitsCopyMode&&((f=t.onExitCopyMode)==null||f.call(t)),Nt&&t.onRefocusMobileInput()}function a(u){u.preventDefault();const f=u.target.closest("button");if(!f)return;if(i()){const p=s.find(b=>f.dataset.key===b.key);p&&o(p);return}const _=r.find(p=>p.id===f.id||p.key&&f.dataset.key===p.key);_&&n(_)}var c=Gr(),h=Ct(c);{var d=u=>{var f=dx(),_=w(f),p=w(_);{var b=S=>{var O=Gr(),C=Ct(O);si(C,17,()=>s,y=>y.label,(y,x)=>{var P=cx(),I=w(P);ad(I,()=>l(x).html),he(z=>{it(P,1,`tb-btn ${l(x).extraClass??""??""}`,"svelte-k7we1m"),Ie(P,"data-key",l(x).key),Ie(P,"data-track",`toolbar.${z??""}`),Ie(P,"aria-label",l(x).label)},[()=>l(x).label.toLowerCase().replace(/[^a-z0-9]/g,"-")]),B(y,P)}),B(S,O)},g=S=>{var O=Gr(),C=Ct(O);si(C,17,()=>r,y=>y.label,(y,x)=>{var P=ux(),I=w(P);ad(I,()=>l(x).html),he(z=>{it(P,1,`tb-btn ${l(x).extraClass??""??""}`,"svelte-k7we1m"),Ie(P,"id",l(x).id),Ie(P,"data-key",l(x).key),Ie(P,"data-track",`toolbar.${z??""}`),Ie(P,"aria-label",l(x).label)},[()=>l(x).label.toLowerCase().replace(/[^a-z0-9]/g,"-")]),B(y,P)}),B(S,O)};ie(p,S=>{i()?S(b):S(g,!1)})}G("mousedown",f,a),B(u,f)};ie(h,u=>{Nt&&u(d)})}B(e,c),ft()}_t(["mousedown"]);var _x=W('<div><button class="icon-btn svelte-wp0i5g" aria-label="Open sessions menu">&#9776;</button> <span class="mobile-title svelte-wp0i5g"> </span></div>');function vx(e,t){let i=Pr(t,"hidden",3,!1);var r=_x();let s;var n=w(r),o=R(n,2),a=w(o);he(()=>{s=it(r,1,"mobile-header svelte-wp0i5g",null,s,{hidden:i()}),ne(a,t.title)}),G("click",n,function(...c){var h;(h=t.onMenuClick)==null||h.apply(this,c)}),B(e,r)}_t(["click"]);var px=W('<div class="update-toast-actions svelte-1trivgv"><button class="update-toast-btn svelte-1trivgv"> </button> <button class="update-toast-dismiss svelte-1trivgv" aria-label="Dismiss">&times;</button></div>'),gx=W('<div class="update-toast svelte-1trivgv"><div class="update-toast-content svelte-1trivgv"><span class="update-toast-text svelte-1trivgv"> </span> <!></div></div>');function mx(e,t){dt(t,!0);let i=F(!1),r=F(""),s=F("Update Now"),n=F(!1),o=F(!0);vo(async()=>{try{const f=await nv();f.updateAvailable&&(m(r,`Update available: v${f.current} → v${f.latest}`),m(s,"Update Now"),m(n,!1),m(o,!0),m(i,!0))}catch{}});async function a(){m(n,!0),m(s,"Updating…");try{(await ov()).restarting?(m(r,"Updated! Restarting server…"),m(o,!1),setTimeout(()=>{location.reload()},5e3)):(m(r,"Updated! Please restart the server manually."),m(o,!1))}catch{m(r,"Update failed. Please try again."),m(n,!1),m(s,"Retry"),m(o,!0)}}function c(){m(i,!1)}var h=Gr(),d=Ct(h);{var u=f=>{var _=gx(),p=w(_),b=w(p),g=w(b),S=R(b,2);{var O=C=>{var y=px(),x=w(y),P=w(x),I=R(x,2);he(()=>{x.disabled=l(n),ne(P,l(s))}),G("click",x,a),G("click",I,c),B(C,y)};ie(S,C=>{l(o)&&C(O)})}he(()=>ne(g,l(r))),B(f,_)};ie(d,f=>{l(i)&&f(u)})}B(e,h),ft()}_t(["click"]);var bx=W('<button class="image-toast-insert svelte-1y8sviv">Insert</button>'),yx=W('<div class="image-toast svelte-1y8sviv"><div class="image-toast-content svelte-1y8sviv"><span class="image-toast-text svelte-1y8sviv"> </span> <div class="image-toast-actions svelte-1y8sviv"><!> <button class="image-toast-dismiss svelte-1y8sviv" aria-label="Dismiss">&times;</button></div></div></div>');function Sx(e,t){dt(t,!0);let i=F(!1),r=F(""),s=F(!1),n=F(null),o=null;function a(g,S,O){o&&(clearTimeout(o),o=null),m(r,g,!0),m(s,S,!0),m(n,O??null,!0),m(i,!0)}function c(){m(i,!1),m(n,null),o&&(clearTimeout(o),o=null)}function h(g){o&&clearTimeout(o),o=setTimeout(()=>{l(n)||c()},g)}function d(){l(n)&&Cr(l(n)),c()}function u(){c()}var f={show:a,hide:c,autoDismiss:h},_=Gr(),p=Ct(_);{var b=g=>{var S=yx(),O=w(S),C=w(O),y=w(C),x=R(C,2),P=w(x);{var I=q=>{var J=bx();G("click",J,d),B(q,J)};ie(P,q=>{l(s)&&q(I)})}var z=R(P,2);he(()=>ne(y,l(r))),G("click",z,u),B(g,S)};ie(p,g=>{l(i)&&g(b)})}return B(e,_),ft(f)}_t(["click"]);var wx=W('<span class="dialog-title-repo svelte-8ywkqk"> </span>'),Cx=W('<dialog class="dialog svelte-8ywkqk"><div class="dialog-content svelte-8ywkqk"><h2 class="dialog-title svelte-8ywkqk">New Agent Session <!></h2> <div class="dialog-body svelte-8ywkqk"><div class="dialog-field svelte-8ywkqk"><label class="dialog-label svelte-8ywkqk" for="cs-agent">Coding agent</label> <select id="cs-agent" class="dialog-select svelte-8ywkqk" data-track="dialog.customize-session.agent"><option>Claude</option><option>Codex</option></select></div> <div class="dialog-field dialog-field--inline svelte-8ywkqk"><input id="cs-continue" type="checkbox" class="dialog-checkbox svelte-8ywkqk"/> <label for="cs-continue" class="dialog-label-inline svelte-8ywkqk">Continue existing session</label></div> <div class="dialog-field dialog-field--inline svelte-8ywkqk"><input id="cs-yolo" type="checkbox" class="dialog-checkbox svelte-8ywkqk"/> <label for="cs-yolo" class="dialog-label-inline svelte-8ywkqk">Yolo mode (skip permission checks)</label></div> <div class="dialog-field dialog-field--inline svelte-8ywkqk"><input id="cs-tmux" type="checkbox" class="dialog-checkbox svelte-8ywkqk"/> <label for="cs-tmux" class="dialog-label-inline svelte-8ywkqk">Launch in tmux</label></div> <div class="dialog-field svelte-8ywkqk"><label class="dialog-label svelte-8ywkqk" for="cs-args">Extra args (optional)</label> <input id="cs-args" type="text" class="dialog-input svelte-8ywkqk" placeholder="e.g. --verbose" autocomplete="off"/></div></div> <div class="dialog-footer svelte-8ywkqk"><button class="btn btn-ghost svelte-8ywkqk">Cancel</button> <button class="btn btn-primary svelte-8ywkqk" data-track="dialog.customize-session.create"> </button></div></div></dialog>');function kx(e,t){dt(t,!0);const i=Cu();let r,s=F(""),n=F(""),o=F(""),a=F("claude"),c=F(!1),h=F(!1),d=F(!1),u=F(!1);function f(){m(o,""),m(c,!1),m(h,!1),m(d,!1)}async function _(se){f(),m(s,se.path,!0),m(n,se.name,!0),await Lv(),m(a,i.defaultAgent,!0),m(c,i.defaultYolo,!0),m(h,i.defaultContinue,!0),m(d,i.launchInTmux,!0),r.showModal()}function p(){r.close()}async function b(){var _e,Se;if(!l(s)||l(u))return;m(u,!0);const se=l(o).trim().split(/\s+/).filter(Boolean),{cols:De,rows:Te}=Iv();try{const de=await gu({repoPath:l(s),repoName:l(n)||l(s).split("/").filter(Boolean).pop(),continue:l(h),yolo:l(c),claudeArgs:se.length>0?se:void 0,agent:l(a),useTmux:l(d),cols:De,rows:Te});r.close(),await gt(),de!=null&&de.id&&((_e=t.onSessionCreated)==null||_e.call(t,de.id))}catch(de){if(de instanceof Error&&"sessionId"in de){const Me=de;r.close(),await gt(),Me.sessionId&&((Se=t.onSessionCreated)==null||Se.call(t,Me.sessionId))}}finally{m(u,!1)}}function g(se){se.target===r&&r.close()}var S={open:_,close:p},O=Cx(),C=w(O),y=w(C),x=R(w(y));{var P=se=>{var De=wx(),Te=w(De);he(()=>ne(Te,`— ${l(n)??""}`)),B(se,De)};ie(x,se=>{l(n)&&se(P)})}var I=R(y,2),z=w(I),q=R(w(z),2),J=w(q);J.value=J.__value="claude";var K=R(J);K.value=K.__value="codex";var N=R(z,2),A=w(N),T=R(N,2),L=w(T),H=R(T,2),D=w(H),E=R(H,2),$=R(w(E),2),Q=R(I,2),pe=w(Q),be=R(pe,2),ce=w(be);return Ze(O,se=>r=se,()=>r),he(()=>{pe.disabled=l(u),be.disabled=!l(s)||l(u),ne(ce,l(u)?"Creating...":"Start Session")}),G("click",O,g),el(q,()=>l(a),se=>m(a,se)),sr(A,()=>l(h),se=>m(h,se)),sr(L,()=>l(c),se=>m(c,se)),sr(D,()=>l(d),se=>m(d,se)),rr($,()=>l(o),se=>m(o,se)),G("click",pe,()=>r.close()),G("click",be,b),B(e,O),ft(S)}_t(["click"]);var xx=W('<p class="error-msg svelte-fdtoa4"> </p>'),Ex=W('<span class="version-status svelte-fdtoa4">Up to date</span>'),Dx=W('<div class="version-update-row svelte-fdtoa4"><span class="version-update-text svelte-fdtoa4"> </span> <button class="btn btn-primary btn-sm svelte-fdtoa4"> </button></div>'),Tx=W('<button class="btn btn-ghost btn-sm svelte-fdtoa4"> </button>'),Rx=W('<p class="version-status-msg svelte-fdtoa4"> </p>'),Px=W('<dialog class="dialog svelte-fdtoa4"><div class="dialog-content svelte-fdtoa4"><div class="dialog-header svelte-fdtoa4"><h2 class="dialog-title svelte-fdtoa4">Settings</h2> <button class="close-btn svelte-fdtoa4" aria-label="Close settings">&#10005;</button></div> <div class="dialog-body svelte-fdtoa4"><!> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Default Coding Agent</h3> <p class="section-desc svelte-fdtoa4">CLI used when creating new sessions.</p> <select class="agent-select svelte-fdtoa4"><option>Claude</option><option>Codex</option></select></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Global Defaults</h3> <p class="section-desc svelte-fdtoa4">Default options for all workspaces. Override per-workspace in workspace settings.</p> <div class="devtools-row svelte-fdtoa4"><input id="default-continue" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-continue" class="devtools-label svelte-fdtoa4">Continue existing session</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-yolo" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-yolo" class="devtools-label svelte-fdtoa4">YOLO mode (skip permission checks)</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-tmux" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-tmux" class="devtools-label svelte-fdtoa4">Launch in tmux</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-notifications" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-notifications" class="devtools-label svelte-fdtoa4">Enable notifications for new sessions</label></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Developer Tools</h3> <div class="devtools-row svelte-fdtoa4"><input id="devtools-toggle" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="devtools-toggle" class="devtools-label svelte-fdtoa4">Enable mobile debug panel</label></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Analytics</h3> <div class="version-row svelte-fdtoa4"><span class="version-current svelte-fdtoa4"> </span> <button class="btn btn-ghost btn-sm svelte-fdtoa4" data-track="dialog.settings.clear-analytics"> </button></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Version</h3> <div class="version-row svelte-fdtoa4"><span class="version-current svelte-fdtoa4"><!></span> <!></div> <!> <!></section></div> <div class="dialog-footer svelte-fdtoa4"><button class="btn btn-ghost svelte-fdtoa4">Close</button></div></div></dialog>');function Ax(e,t){dt(t,!0);let i,r=F(!1);const s=Cu();let n=F(""),o=F(""),a=F(null),c=F(!1),h=F(!1),d=F(!1),u=F(!1),f=F(""),_=F(null),p=F(!1);async function b(){m(n,""),m(f,""),m(h,!1),m(u,!1),m(r,localStorage.getItem("devtools-enabled")==="true"),await Lv(),i.showModal(),P(),Fb().then(ae=>{m(_,ae.bytes,!0)}).catch(()=>{})}function g(){i.close()}async function S(){const ae=s.defaultAgent;m(n,"");try{await Db(s.defaultAgent)}catch{s.defaultAgent=ae,m(n,"Failed to update default agent.")}}async function O(){const ae=s.defaultContinue;m(n,"");try{await Rb(s.defaultContinue)}catch{s.defaultContinue=ae,m(n,"Failed to update continue default.")}}async function C(){const ae=s.defaultYolo;m(n,"");try{await Ab(s.defaultYolo)}catch{s.defaultYolo=ae,m(n,"Failed to update yolo default.")}}async function y(){const ae=s.launchInTmux;m(n,"");try{await Ob(s.launchInTmux)}catch(Ye){s.launchInTmux=ae,m(n,Ye instanceof Error?Ye.message:"Failed to update tmux setting.",!0)}}async function x(){const ae=s.defaultNotifications;m(n,"");try{await Ib(s.defaultNotifications)}catch{s.defaultNotifications=ae,m(n,"Failed to update notifications default.")}}async function P(){m(d,!0),m(f,"");try{const ae=await nv();m(o,ae.current,!0),m(a,ae.latest,!0),m(c,ae.updateAvailable,!0),m(h,!0)}catch{m(f,"Failed to check for updates.")}finally{m(d,!1)}}async function I(){m(u,!0),m(f,"");try{(await ov()).restarting?(m(f,"Updated! Restarting server…"),setTimeout(()=>{location.reload()},5e3)):m(f,"Updated! Please restart the server manually."),m(c,!1)}catch{m(f,"Update failed. Please try again."),m(u,!1)}}function z(){localStorage.setItem("devtools-enabled",l(r)?"true":"false"),window.dispatchEvent(new Event("devtools-changed"))}async function q(){if(confirm("Clear all analytics data? This cannot be undone.")){m(p,!0);try{await Wb(),m(_,0)}catch{m(n,"Failed to clear analytics.")}finally{m(p,!1)}}}async function J(){i.close(),await gt()}function K(ae){ae.target===i&&J()}var N={open:b,close:g},A=Px(),T=w(A),L=w(T),H=R(w(L),2),D=R(L,2),E=w(D);{var $=ae=>{var Ye=xx(),jt=w(Ye);he(()=>ne(jt,l(n))),B(ae,Ye)};ie(E,ae=>{l(n)&&ae($)})}var Q=R(E,2),pe=R(w(Q),4),be=w(pe);be.value=be.__value="claude";var ce=R(be);ce.value=ce.__value="codex";var se=R(Q,2),De=R(w(se),4),Te=w(De),_e=R(De,2),Se=w(_e),de=R(_e,2),Me=w(de),Ne=R(de,2),je=w(Ne),Pe=R(se,2),et=R(w(Pe),2),X=w(et),ve=R(Pe,2),Fe=R(w(ve),2),Ke=w(Fe),Be=w(Ke),k=R(Ke,2),Z=w(k),fe=R(ve,2),ye=R(w(fe),2),Ce=w(ye),M=w(Ce);{var Y=ae=>{var Ye=hn();he(()=>ne(Ye,`v${l(o)??""}`)),B(ae,Ye)},ge=ae=>{var Ye=hn("...");B(ae,Ye)};ie(M,ae=>{l(o)?ae(Y):ae(ge,!1)})}var le=R(Ce,2);{var re=ae=>{var Ye=Ex();B(ae,Ye)};ie(le,ae=>{l(h)&&!l(c)&&!l(u)&&ae(re)})}var ke=R(ye,2);{var we=ae=>{var Ye=Dx(),jt=w(Ye),ji=w(jt),Le=R(jt,2),ht=w(Le);he(()=>{ne(ji,`v${l(o)??""} → v${l(a)??""}`),Le.disabled=l(u),ne(ht,l(u)?"Updating…":"Update Now")}),G("click",Le,I),B(ae,Ye)},Re=ae=>{var Ye=Tx(),jt=w(Ye);he(()=>{Ye.disabled=l(d),ne(jt,l(d)?"Checking…":"Check for updates")}),G("click",Ye,P),B(ae,Ye)};ie(ke,ae=>{l(c)?ae(we):l(h)||ae(Re,1)})}var oe=R(ke,2);{var Ee=ae=>{var Ye=Rx(),jt=w(Ye);he(()=>ne(jt,l(f))),B(ae,Ye)};ie(oe,ae=>{l(f)&&ae(Ee)})}var Ge=R(D,2),qt=w(Ge);return Ze(A,ae=>i=ae,()=>i),he(ae=>{ne(Be,`DB size: ${ae??""}`),k.disabled=l(p),ne(Z,l(p)?"Clearing…":"Clear")},[()=>l(_)!==null?(l(_)/1024/1024).toFixed(1)+" MB":"..."]),G("click",A,K),G("click",H,J),G("change",pe,S),el(pe,()=>s.defaultAgent,ae=>s.defaultAgent=ae),G("change",Te,O),sr(Te,()=>s.defaultContinue,ae=>s.defaultContinue=ae),G("change",Se,C),sr(Se,()=>s.defaultYolo,ae=>s.defaultYolo=ae),G("change",Me,y),sr(Me,()=>s.launchInTmux,ae=>s.launchInTmux=ae),G("change",je,x),sr(je,()=>s.defaultNotifications,ae=>s.defaultNotifications=ae),G("change",X,z),sr(X,()=>l(r),ae=>m(r,ae)),G("click",k,q),G("click",qt,J),B(e,A),ft(N)}_t(["click","change"]);var Mx=W('<p class="confirm-msg svelte-15sco2n">Are you sure you want to delete the worktree <strong class="wt-name svelte-15sco2n"> </strong>?</p> <p class="wt-path svelte-15sco2n"> </p> <p class="warning-msg svelte-15sco2n">This action cannot be undone.</p>',1),Ox=W('<p class="error-msg svelte-15sco2n"> </p>'),Lx=W('<dialog class="dialog svelte-15sco2n"><div class="dialog-content svelte-15sco2n"><h2 class="dialog-title svelte-15sco2n">Delete Worktree</h2> <div class="dialog-body svelte-15sco2n"><!> <!></div> <div class="dialog-footer svelte-15sco2n"><button class="btn btn-ghost svelte-15sco2n">Cancel</button> <button class="btn btn-danger svelte-15sco2n"> </button></div></div></dialog>');function Ix(e,t){dt(t,!0);let i,r=F(null),s=F(""),n=F(!1);function o(I){m(r,I,!0),m(s,""),m(n,!1),i.showModal()}function a(){i.close()}async function c(){if(!(!l(r)||l(n))){m(n,!0),m(s,""),Tn(l(r).path);try{await sv(l(r).path,l(r).repoPath),i.close(),await gt()}catch(I){m(s,I instanceof Error?I.message:"Failed to delete worktree.",!0),m(n,!1)}finally{l(r)&&Rn(l(r).path)}}}function h(){i.close()}function d(I){I.target===i&&i.close()}var u={open:o,close:a},f=Lx(),_=w(f),p=R(w(_),2),b=w(p);{var g=I=>{var z=Mx(),q=Ct(z),J=R(w(q)),K=w(J),N=R(q,2),A=w(N);he(()=>{ne(K,l(r).displayName||l(r).name),ne(A,l(r).path)}),B(I,z)};ie(b,I=>{l(r)&&I(g)})}var S=R(b,2);{var O=I=>{var z=Ox(),q=w(z);he(()=>ne(q,l(s))),B(I,z)};ie(S,I=>{l(s)&&I(O)})}var C=R(p,2),y=w(C),x=R(y,2),P=w(x);return Ze(f,I=>i=I,()=>i),he(()=>{y.disabled=l(n),x.disabled=l(n),ne(P,l(n)?"Deleting...":"Delete")}),G("click",f,d),G("click",y,h),G("click",x,c),B(e,f),ft(u)}_t(["click"]);var Bx=W('<div class="loading-placeholder svelte-15gfcbp">Loading...</div>'),Nx=W('<div class="empty-placeholder svelte-15gfcbp"><!></div>'),Fx=W('<span class="spinner svelte-15gfcbp">...</span>'),Wx=W("<span>&#9654;</span>"),Hx=W('<button class="expand-btn svelte-15gfcbp" data-track="file-browser.expand"><!></button>'),zx=W('<span class="expand-spacer svelte-15gfcbp"></span>'),Ux=W('<span class="git-badge svelte-15gfcbp" aria-label="Git repository">git</span>'),Kx=W('<div role="treeitem"><!> <input type="checkbox" class="node-checkbox svelte-15gfcbp" data-track="file-browser.select"/> <span class="node-name svelte-15gfcbp"> </span> <!></div>'),qx=W('<div class="truncated-notice svelte-15gfcbp"> </div>'),jx=W("<!> <!>",1),Yx=W('<div class="file-browser svelte-15gfcbp"><div class="filter-row svelte-15gfcbp"><input type="text" class="filter-input svelte-15gfcbp" placeholder="Filter..." aria-label="Filter directories" autocomplete="off" spellcheck="false"/></div> <div class="tree-container svelte-15gfcbp" role="tree" aria-label="File browser" tabindex="0"><!></div></div>');function Vx(e,t){dt(t,!0);let i=Pr(t,"selectedPaths",31,()=>$e([])),r=F($e([])),s=F(""),n=F(-1),o=F(!0),a=F(null),c=F(void 0);vo(()=>{h()});async function h(){m(o,!0),m(a,null);try{const D=await dd();m(r,D.entries.map(E=>d(E,0)),!0),D.truncated&&m(a,{shown:D.entries.length,total:D.total},!0)}catch{m(r,[],!0)}finally{m(o,!1)}}function d(D,E){return{name:D.name,path:D.path,isGitRepo:D.isGitRepo,hasChildren:D.hasChildren,children:null,expanded:!1,selected:!1,loading:!1,depth:E,truncatedInfo:null}}async function u(D){if(D.expanded){D.expanded=!1;return}if(D.children===null){D.loading=!0;try{const E=await dd(D.path);D.children=E.entries.map($=>d($,D.depth+1)),D.truncatedInfo=E.truncated?{shown:E.entries.length,total:E.total}:null}catch{D.children=[]}finally{D.loading=!1}}D.expanded=!0}function f(D){D.selected=!D.selected,_()}function _(){i(p(l(r)))}function p(D){const E=[];for(const $ of D)$.selected&&E.push($.path),$.children&&E.push(...p($.children));return E}function b(D,E){return D.toLowerCase().includes(E.toLowerCase())}function g(D,E){var $;return!!(!E||D.expanded||b(D.name,E)||($=D.children)!=null&&$.some(Q=>g(Q,E)))}function S(D,E){const $=[];for(const Q of D)g(Q,E)&&($.push(Q),Q.expanded&&Q.children&&$.push(...S(Q.children,E)));return $}let O=me(()=>S(l(r),l(s)));function C(D){var $;if(D.key==="ArrowDown"){D.preventDefault(),m(n,Math.min(l(n)+1,l(O).length-1),!0);return}if(D.key==="ArrowUp"){D.preventDefault(),m(n,Math.max(l(n)-1,0),!0);return}const E=l(n)>=0?l(O)[l(n)]:void 0;if(E){if(D.key==="ArrowRight"){if(D.preventDefault(),E.hasChildren&&!E.expanded)u(E);else if(E.expanded&&(($=E.children)!=null&&$.length)){const Q=l(O).indexOf(E.children[0]);Q>=0&&m(n,Q,!0)}return}if(D.key==="ArrowLeft"){if(D.preventDefault(),E.expanded)E.expanded=!1;else{const Q=E.depth-1;for(let pe=l(n)-1;pe>=0;pe--)if(l(O)[pe].depth===Q){m(n,pe,!0);break}}return}if(D.key===" "){D.preventDefault(),f(E);return}}}function y(D,E){const $=E.target;$.closest(".expand-btn")||$.closest(".node-checkbox")||(D.hasChildren&&!D.expanded?u(D):f(D))}function x(){m(s,""),m(n,-1),P(l(r)),i([]),I(l(r))}function P(D){for(const E of D)E.selected=!1,E.children&&P(E.children)}function I(D){for(const E of D)E.expanded=!1,E.children&&I(E.children)}var z={reset:x},q=Yx(),J=w(q),K=w(J),N=R(J,2),A=w(N);{var T=D=>{var E=Bx();B(D,E)},L=D=>{var E=Nx(),$=w(E);{var Q=be=>{var ce=hn();he(()=>ne(ce,`No matches for "${l(s)??""}"`)),B(be,ce)},pe=be=>{var ce=hn("No directories found");B(be,ce)};ie($,be=>{l(s)?be(Q):be(pe,!1)})}B(D,E)},H=D=>{var E=jx(),$=Ct(E);si($,19,()=>l(O),be=>be.path,(be,ce,se)=>{var De=Kx();let Te;var _e=w(De);{var Se=X=>{var ve=Hx(),Fe=w(ve);{var Ke=k=>{var Z=Fx();B(k,Z)},Be=k=>{var Z=Wx();let fe;he(()=>fe=it(Z,1,"arrow svelte-15gfcbp",null,fe,{expanded:l(ce).expanded})),B(k,Z)};ie(Fe,k=>{l(ce).loading?k(Ke):k(Be,!1)})}he(()=>Ie(ve,"aria-label",l(ce).expanded?"Collapse":"Expand")),G("click",ve,()=>u(l(ce))),B(X,ve)},de=X=>{var ve=zx();B(X,ve)};ie(_e,X=>{l(ce).hasChildren?X(Se):X(de,!1)})}var Me=R(_e,2),Ne=R(Me,2),je=w(Ne),Pe=R(Ne,2);{var et=X=>{var ve=Ux();B(X,ve)};ie(Pe,X=>{l(ce).isGitRepo&&X(et)})}he(()=>{Te=it(De,1,"tree-row svelte-15gfcbp",null,Te,{focused:l(se)===l(n),selected:l(ce).selected}),_o(De,`padding-left: ${12+l(ce).depth*20}px`),Ie(De,"aria-expanded",l(ce).hasChildren?l(ce).expanded:void 0),Ie(De,"aria-selected",l(ce).selected),Ie(De,"aria-level",l(ce).depth+1),ob(Me,l(ce).selected),Ie(Me,"aria-label",`Select ${l(ce).name??""}`),ne(je,l(ce).name)}),G("click",De,X=>y(l(ce),X)),G("change",Me,()=>f(l(ce))),G("click",Me,X=>X.stopPropagation()),B(be,De)});var Q=R($,2);{var pe=be=>{var ce=qx(),se=w(ce);he(()=>ne(se,`Showing ${l(a).shown??""} of ${l(a).total??""} directories. Use the filter to narrow results.`)),B(be,ce)};ie(Q,be=>{l(a)&&be(pe)})}B(D,E)};ie(A,D=>{l(o)?D(T):l(O).length===0?D(L,1):D(H,!1)})}return Ze(N,D=>m(c,D),()=>l(c)),rr(K,()=>l(s),D=>m(s,D)),G("keydown",N,C),B(e,q),ft(z)}_t(["keydown","click","change"]);var Gx=W('<p class="error-msg svelte-4yj2yx"> </p>'),Xx=W('<dialog class="dialog svelte-4yj2yx"><div class="dialog-content svelte-4yj2yx"><div class="dialog-header svelte-4yj2yx"><h2 class="dialog-title svelte-4yj2yx">Add Workspace</h2> <button class="close-btn svelte-4yj2yx" aria-label="Close">&#10005;</button></div> <div class="dialog-body svelte-4yj2yx"><p class="dialog-desc svelte-4yj2yx">Browse for folders on your machine. Git repos get PR tracking and branch management.</p> <!> <!></div> <div class="dialog-footer svelte-4yj2yx"><span class="selected-count svelte-4yj2yx"><!></span> <div class="footer-actions svelte-4yj2yx"><button class="btn btn-ghost svelte-4yj2yx">Cancel</button> <button class="btn btn-primary svelte-4yj2yx"><!></button></div></div></div></dialog>');function $x(e,t){dt(t,!0);let i,r=F(void 0),s=F($e([])),n=F(""),o=F(!1);function a(){var T;m(s,[],!0),m(n,""),m(o,!1),(T=l(r))==null||T.reset(),i.showModal()}function c(){i.close()}async function h(){if(l(s).length!==0){m(o,!0),m(n,"");try{const T=await gb(l(s));if(T.errors.length>0&&T.added.length===0){m(n,T.errors.map(L=>`${L.path}: ${L.error}`).join("; "),!0),m(o,!1);return}T.added.length>0&&t.onWorkspacesAdded(T.added.map(L=>L.path)),T.errors.length>0&&console.warn("Some workspaces failed to add:",T.errors),c()}catch{m(n,"Failed to add workspaces.")}finally{m(o,!1)}}}function d(T){T.target===i&&c()}var u={open:a,close:c},f=Xx(),_=w(f),p=w(_),b=R(w(p),2),g=R(p,2),S=R(w(g),2);Ze(Vx(S,{get selectedPaths(){return l(s)},set selectedPaths(T){m(s,T,!0)}}),T=>m(r,T,!0),()=>l(r));var O=R(S,2);{var C=T=>{var L=Gx(),H=w(L);he(()=>ne(H,l(n))),B(T,L)};ie(O,T=>{l(n)&&T(C)})}var y=R(g,2),x=w(y),P=w(x);{var I=T=>{var L=hn();he(()=>ne(L,`${l(s).length??""} selected`)),B(T,L)};ie(P,T=>{l(s).length>0&&T(I)})}var z=R(x,2),q=w(z),J=R(q,2),K=w(J);{var N=T=>{var L=hn("Adding...");B(T,L)},A=T=>{var L=hn();he(()=>ne(L,`Add Workspace${l(s).length>1?"s":""}`)),B(T,L)};ie(K,T=>{l(o)?T(N):T(A,!1)})}return Ze(f,T=>i=T,()=>i),he(()=>J.disabled=l(s).length===0||l(o)),G("click",f,d),G("click",b,c),G("click",q,c),G("click",J,h),B(e,f),ft(u)}_t(["click"]);var Qx=W('<p class="error-msg svelte-1n78dcx"> </p>'),Zx=W("<option> </option>"),Jx=W("<option> </option>"),eE=W('<span class="override-badge svelte-1n78dcx">overridden</span>'),tE=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. focus on security, error handling"></textarea>'),iE=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. include test plan section"></textarea>'),rE=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. prefix with dy/, use conventional commits style"></textarea>'),sE=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. use TypeScript, follow CLAUDE.md"></textarea>'),nE=W('<button class="btn btn-ghost svelte-1n78dcx">Reset to Global</button>'),oE=W('<span class="save-success svelte-1n78dcx">Saved</span>'),aE=W('<dialog class="dialog svelte-1n78dcx"><div class="dialog-content svelte-1n78dcx"><div class="dialog-header svelte-1n78dcx"><h2 class="dialog-title svelte-1n78dcx"><span class="gear-icon svelte-1n78dcx">&#9881;</span> </h2> <button class="close-btn svelte-1n78dcx" aria-label="Close settings">&#10005;</button></div> <div class="dialog-body svelte-1n78dcx"><!> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">GIT SETTINGS</h3> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-default-branch">Branch new worktrees from</label> <select id="ws-default-branch" class="field-select svelte-1n78dcx"><option>-- auto --</option><!><!></select></div> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-remote">Remote origin</label> <input id="ws-remote" type="text" class="field-input svelte-1n78dcx" placeholder="origin"/></div> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-branch-prefix">Branch prefix</label> <input id="ws-branch-prefix" type="text" class="field-input svelte-1n78dcx" placeholder="e.g. dy/"/></div></section> <div class="divider svelte-1n78dcx"></div> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">SESSION DEFAULTS <!></h3> <div class="inline-row svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-agent">Default agent</label> <select id="ws-agent" class="field-select field-select-inline svelte-1n78dcx"><option>Claude</option><option>Codex</option></select></div> <div class="checkbox-row svelte-1n78dcx"><label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>Continue</span></label> <label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>YOLO</span></label> <label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>Tmux</span></label></div></section> <div class="divider svelte-1n78dcx"></div> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">PROMPTS</h3> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Code review preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Create PR preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Branch rename preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> General preferences</button> <!></div></section></div> <div class="dialog-footer svelte-1n78dcx"><button class="btn btn-danger svelte-1n78dcx">Remove Workspace</button> <div class="footer-right svelte-1n78dcx"><!> <!> <button class="btn btn-primary svelte-1n78dcx"> </button></div></div></div></dialog>');function lE(e,t){dt(t,!0);let i,r=F(""),s=F(""),n=F(!1),o=F(""),a=F(!1),c=F($e([])),h=F(""),d=F(""),u=F(""),f=F("claude"),_=F(!1),p=F(!1),b=F(!1),g=F(""),S=F(""),O=F(""),C=F(""),y=F($e([])),x=F($e({})),P=F(!1),I=F(!1),z=F(!1),q=F(!1);async function J(V,ze){m(r,V,!0),m(s,ze,!0),m(o,""),m(a,!1),m(n,!1),m(h,""),m(d,""),m(u,""),m(f,"claude"),m(_,!1),m(p,!1),m(b,!1),m(g,""),m(S,""),m(O,""),m(C,""),i.showModal();try{const[ot,xn]=await Promise.all([fd(V),rv(V).catch(()=>[])]);m(c,xn,!0),N(ot.settings),m(x,{defaultAgent:ot.settings.defaultAgent,defaultContinue:ot.settings.defaultContinue,defaultYolo:ot.settings.defaultYolo,launchInTmux:ot.settings.launchInTmux},!0),m(y,ot.overridden,!0)}catch{m(o,"Failed to load workspace settings.")}}function K(){i.close()}function N(V){m(h,V.defaultBranch??"",!0),m(d,V.remote??"",!0),m(u,V.branchPrefix??"",!0),m(f,V.defaultAgent??"claude",!0),m(_,V.defaultContinue??!1,!0),m(p,V.defaultYolo??!1,!0),m(b,V.launchInTmux??!1,!0),m(g,V.promptCodeReview??"",!0),m(S,V.promptCreatePr??"",!0),m(O,V.promptBranchRename??"",!0),m(C,V.promptGeneral??"",!0)}async function A(){m(n,!0),m(o,""),m(a,!1);try{const V={};l(f)!==l(x).defaultAgent&&(V.defaultAgent=l(f)),l(_)!==l(x).defaultContinue&&(V.defaultContinue=l(_)),l(p)!==l(x).defaultYolo&&(V.defaultYolo=l(p)),l(b)!==l(x).launchInTmux&&(V.launchInTmux=l(b)),l(h)&&(V.defaultBranch=l(h)),l(d)&&(V.remote=l(d)),l(u)&&(V.branchPrefix=l(u)),l(g)&&(V.promptCodeReview=l(g)),l(S)&&(V.promptCreatePr=l(S)),l(O)&&(V.promptBranchRename=l(O)),l(C)&&(V.promptGeneral=l(C)),Object.keys(V).length>0&&await _d(l(r),V),m(a,!0),setTimeout(()=>{m(a,!1)},2e3)}catch(V){m(o,V instanceof Error?V.message:"Failed to save settings.",!0)}finally{m(n,!1)}}async function T(){m(n,!0),m(o,"");try{await _d(l(r),{defaultAgent:null,defaultContinue:null,defaultYolo:null,launchInTmux:null});const V=await fd(l(r));N(V.settings),m(x,{defaultAgent:V.settings.defaultAgent,defaultContinue:V.settings.defaultContinue,defaultYolo:V.settings.defaultYolo,launchInTmux:V.settings.launchInTmux},!0),m(y,V.overridden,!0),m(a,!0),setTimeout(()=>{m(a,!1)},2e3)}catch(V){m(o,V instanceof Error?V.message:"Failed to reset settings.",!0)}finally{m(n,!1)}}function L(){i.close(),t.onRemoveWorkspace(l(r))}function H(V){V.target===i&&i.close()}var D={open:J,close:K},E=aE(),$=w(E),Q=w($),pe=w(Q),be=R(w(pe)),ce=R(pe,2),se=R(Q,2),De=w(se);{var Te=V=>{var ze=Qx(),ot=w(ze);he(()=>ne(ot,l(o))),B(V,ze)};ie(De,V=>{l(o)&&V(Te)})}var _e=R(De,2),Se=R(w(_e),2),de=R(w(Se),2),Me=w(de);Me.value=Me.__value="";var Ne=R(Me);si(Ne,17,()=>l(c),Yo,(V,ze)=>{var ot=Zx(),xn=w(ot),$u={};he(()=>{ne(xn,l(ze)),$u!==($u=l(ze))&&(ot.value=(ot.__value=l(ze))??"")}),B(V,ot)});var je=R(Ne);{var Pe=V=>{var ze=Jx(),ot=w(ze),xn={};he(()=>{ne(ot,l(h)),xn!==(xn=l(h))&&(ze.value=(ze.__value=l(h))??"")}),B(V,ze)},et=me(()=>l(h)&&!l(c).includes(l(h)));ie(je,V=>{l(et)&&V(Pe)})}var X=R(Se,2),ve=R(w(X),2),Fe=R(X,2),Ke=R(w(Fe),2),Be=R(_e,4),k=w(Be),Z=R(w(k));{var fe=V=>{var ze=eE();B(V,ze)},ye=me(()=>l(y).some(V=>["defaultAgent","defaultContinue","defaultYolo","launchInTmux"].includes(V)));ie(Z,V=>{l(ye)&&V(fe)})}var Ce=R(k,2),M=R(w(Ce),2),Y=w(M);Y.value=Y.__value="claude";var ge=R(Y);ge.value=ge.__value="codex";var le=R(Ce,2),re=w(le),ke=w(re),we=R(re,2),Re=w(we),oe=R(we,2),Ee=w(oe),Ge=R(Be,4),qt=R(w(Ge),2),ae=w(qt),Ye=w(ae),jt=w(Ye),ji=R(ae,2);{var Le=V=>{var ze=tE();Ie(ze,"rows",3),rr(ze,()=>l(g),ot=>m(g,ot)),B(V,ze)};ie(ji,V=>{l(P)&&V(Le)})}var ht=R(qt,2),Ot=w(ht),ur=w(Ot),Di=w(ur),Cn=R(Ot,2);{var Ps=V=>{var ze=iE();Ie(ze,"rows",3),rr(ze,()=>l(S),ot=>m(S,ot)),B(V,ze)};ie(Cn,V=>{l(I)&&V(Ps)})}var kn=R(ht,2),Lr=w(kn),jl=w(Lr),Yl=w(jl),tt=R(Lr,2);{var Lt=V=>{var ze=rE();Ie(ze,"rows",3),rr(ze,()=>l(O),ot=>m(O,ot)),B(V,ze)};ie(tt,V=>{l(z)&&V(Lt)})}var Yi=R(kn,2),wa=w(Yi),lg=w(wa),hg=w(lg),cg=R(wa,2);{var ug=V=>{var ze=sE();Ie(ze,"rows",3),rr(ze,()=>l(C),ot=>m(C,ot)),B(V,ze)};ie(cg,V=>{l(q)&&V(ug)})}var dg=R(se,2),Vu=w(dg),fg=R(Vu,2),Gu=w(fg);{var _g=V=>{var ze=nE();he(()=>ze.disabled=l(n)),G("click",ze,T),B(V,ze)},vg=me(()=>l(y).some(V=>["defaultAgent","defaultContinue","defaultYolo","launchInTmux"].includes(V)));ie(Gu,V=>{l(vg)&&V(_g)})}var Xu=R(Gu,2);{var pg=V=>{var ze=oE();B(V,ze)};ie(Xu,V=>{l(a)&&V(pg)})}var Vl=R(Xu,2),gg=w(Vl);return Ze(E,V=>i=V,()=>i),he(()=>{ne(be,` ${l(s)??""}`),Ie(ae,"aria-expanded",l(P)),ne(jt,l(P)?"▾":"▸"),Ie(Ot,"aria-expanded",l(I)),ne(Di,l(I)?"▾":"▸"),Ie(Lr,"aria-expanded",l(z)),ne(Yl,l(z)?"▾":"▸"),Ie(wa,"aria-expanded",l(q)),ne(hg,l(q)?"▾":"▸"),Vl.disabled=l(n),ne(gg,l(n)?"Saving…":"Save")}),G("click",E,H),G("click",ce,()=>i.close()),el(de,()=>l(h),V=>m(h,V)),rr(ve,()=>l(d),V=>m(d,V)),rr(Ke,()=>l(u),V=>m(u,V)),el(M,()=>l(f),V=>m(f,V)),sr(ke,()=>l(_),V=>m(_,V)),sr(Re,()=>l(p),V=>m(p,V)),sr(Ee,()=>l(b),V=>m(b,V)),G("click",ae,()=>{m(P,!l(P))}),G("click",Ot,()=>{m(I,!l(I))}),G("click",Lr,()=>{m(z,!l(z))}),G("click",wa,()=>{m(q,!l(q))}),G("click",Vu,L),G("click",Vl,A),B(e,E),ft(D)}_t(["click"]);var hE=W('<div class="sidebar-overlay svelte-13zv0lp"></div>'),cE=W("<!> <!> <!> <!>",1),uE=W('<div class="main-app svelte-13zv0lp"><!> <!> <div class="terminal-area svelte-13zv0lp"><!> <!></div></div> <!> <!> <!> <!> <!> <!> <!>',1);function dE(e,t){dt(t,!0);const i=new rg({defaultOptions:{queries:{staleTime:60*1e3,gcTime:600*1e3,refetchOnWindowFocus:!0}}}),r=av(),s=mu(),n=yu(),o=Cu();function a(k,Z){n.activeSessionId=k;const fe=n.sessions.find(ye=>ye.id===k);fe&&(s.activeWorkspacePath=fe.repoPath),bd(k),ki()}ey(a);let c=F(void 0),h=F(void 0),d=F(void 0),u=F(void 0),f=F(void 0),_=F(void 0),p=F(void 0),b=F(!1);vo(()=>{by(()=>n.activeSessionId),Hb();let k,Z;if(Nt&&window.visualViewport){const Ce=window.visualViewport;let M=null;const Y=()=>{const ge=window.innerHeight-Ce.height;m(b,ge>50),l(p)&&(l(p).style.height=l(b)?Ce.height+"px":""),window.scrollTo(0,0),M&&clearTimeout(M),M=setTimeout(()=>{var le;return(le=l(c))==null?void 0:le.fitTerm()},100)};Ce.addEventListener("resize",Y),Ce.addEventListener("scroll",Y),k=()=>{Ce.removeEventListener("resize",Y),Ce.removeEventListener("scroll",Y),M&&clearTimeout(M)}}const fe=navigator.platform.toUpperCase().includes("MAC");let ye;{const Ce=M=>{var le;const Y=(le=document.activeElement)==null?void 0:le.tagName;if(!(Y==="INPUT"||Y==="TEXTAREA"||!(fe?M.metaKey:M.ctrlKey))){if(M.key==="t"&&!M.shiftKey){M.preventDefault(),K();return}if(M.key==="w"&&!M.shiftKey){M.preventDefault(),n.activeSessionId&&be(n.activeSessionId);return}if(!M.shiftKey&&M.key>="1"&&M.key<="9"){const re=l(y);if(re.length===0)return;M.preventDefault();const ke=parseInt(M.key,10),we=ke===9?re[re.length-1]:re[ke-1];we&&J(we.id);return}if(M.shiftKey&&M.key==="["){const re=l(y);if(re.length===0)return;M.preventDefault();const ke=re.findIndex(Re=>Re.id===n.activeSessionId),we=ke<=0?re[re.length-1]:re[ke-1];we&&J(we.id);return}if(M.shiftKey&&M.key==="]"){const re=l(y);if(re.length===0)return;M.preventDefault();const ke=re.findIndex(Re=>Re.id===n.activeSessionId),we=ke===-1||ke===re.length-1?re[0]:re[ke+1];we&&J(we.id);return}}};document.addEventListener("keydown",Ce),ye=()=>document.removeEventListener("keydown",Ce)}if(Nt){let Y=0,ge=0,le=!1;const re=Re=>{const oe=Re.touches[0];oe&&oe.clientX<=30&&!s.sidebarOpen&&(Y=oe.clientX,ge=oe.clientY,le=!0)},ke=Re=>{if(!le)return;const oe=Re.touches[0];if(!oe)return;const Ee=oe.clientX-Y,Ge=Math.abs(oe.clientY-ge);if(Ge>Ee&&(Ge>8||Ee>8)){le=!1;return}Ee>=50&&(le=!1,gd())},we=()=>{le=!1};document.addEventListener("touchstart",re,{passive:!0}),document.addEventListener("touchmove",ke,{passive:!0}),document.addEventListener("touchend",we),Z=()=>{document.removeEventListener("touchstart",re),document.removeEventListener("touchmove",ke),document.removeEventListener("touchend",we)}}return()=>{ye==null||ye(),k==null||k(),Z==null||Z(),yy()}});let g;zi(()=>{const k=n.activeSessionId;if(g===void 0){g=k;return}k!==g&&(g=k,k?Gh("navigation","page.view","/terminal",void 0,k):Gh("navigation","page.view","/dashboard",{workspace:s.activeWorkspacePath}))}),zi(()=>{r.authenticated&&gt().then(()=>{const Z=new URLSearchParams(window.location.search).get("session");Z&&(window.history.replaceState({},"","/"),a(Z)),!n.activeSessionId&&!Z&&n.sessions.length===1&&J(n.sessions[0].id),!n.activeSessionId&&!Z&&n.sessions.length===1&&J(n.sessions[0].id);for(const fe of n.sessions)As(fe.id,o.defaultNotifications);ty().then(()=>{iy(ly())})})}),zi(()=>{r.authenticated&&Su(k=>{k.type==="worktrees-changed"?gt():k.type==="session-state-changed"&&k.sessionId&&k.state?oy(k.sessionId,k.state):k.type==="session-idle-changed"&&k.sessionId?ay(k.sessionId,k.idle??!1):k.type==="session-renamed"&&k.sessionId?ny(k.sessionId,k.branchName??"",k.displayName??""):k.type==="session-ended"&&(i.invalidateQueries({queryKey:["pr"]}),i.invalidateQueries({queryKey:["ci-status"]}))})});let S=me(()=>s.activeWorkspacePath?n.workspaces.find(k=>k.path===s.activeWorkspacePath):void 0),O=me(()=>s.activeWorkspacePath?wv(s.activeWorkspacePath):[]),C=me(()=>n.activeSessionId?n.sessions.find(k=>k.id===n.activeSessionId):void 0),y=me(()=>(l(C)?l(O).filter(k=>k.repoPath===l(C).repoPath):l(O)).toSorted((k,Z)=>new Date(k.createdAt).getTime()-new Date(Z.createdAt).getTime())),x=me(()=>!!l(C)&&!!s.activeWorkspacePath&&(l(C).repoPath===s.activeWorkspacePath||l(C).repoPath.startsWith(s.activeWorkspacePath+"/"))),P=me(()=>{var k,Z;return((k=l(C))==null?void 0:k.displayName)||((Z=l(S))==null?void 0:Z.name)||"Claude Remote CLI"}),I=me(()=>{var k;return((k=l(C))==null?void 0:k.useTmux)??!1}),z=F(!1),q=me(()=>l(S)?l(x)?"session":"dashboard":"empty");function J(k){var fe;n.activeSessionId=k;const Z=n.sessions.find(ye=>ye.id===k);if(Z){const ye=n.workspaces.find(Ce=>Z.repoPath===Ce.path||Z.repoPath.startsWith(Ce.path+"/"));s.activeWorkspacePath=(ye==null?void 0:ye.path)??Z.repoPath}bd(k),ki(),(fe=l(c))==null||fe.focusTerm()}async function K(){if(!l(S))return;const{cols:k,rows:Z}=Iv();try{const fe=await gu({repoPath:l(S).path,repoName:l(S).name,continue:o.defaultContinue,yolo:o.defaultYolo,agent:o.defaultAgent,useTmux:o.launchInTmux,cols:k,rows:Z});await gt(),fe!=null&&fe.id&&(n.activeSessionId=fe.id,As(fe.id,o.defaultNotifications))}catch(fe){if(fe instanceof Error&&"sessionId"in fe){const ye=fe;await gt(),ye.sessionId&&(n.activeSessionId=ye.sessionId)}else console.error("Failed to create agent session:",fe)}}async function N(){if(l(S))try{const k=await Cb(l(S).path);await gt(),k!=null&&k.id&&(n.activeSessionId=k.id,As(k.id,o.defaultNotifications))}catch(k){console.error("Failed to create terminal session:",k)}}function A(){var k;l(S)&&((k=l(d))==null||k.open({name:l(S).name,path:l(S).path}))}function T(k){var Z,fe;k?(Z=l(_))==null||Z.open(k.path,k.name):(fe=l(u))==null||fe.open()}async function L(k){var fe,ye;const Z=`new-worktree:${k.path}`;if(!Qi(Z)){Tn(Z);try{const{branchName:Ce,worktreePath:M}=await eh(k.path),Y=await On({repoPath:k.path,repoName:k.name,worktreePath:M,branchName:Ce,needsBranchRename:!0});await gt(),n.activeSessionId=Y.id,s.activeWorkspacePath=k.path,As(Y.id,o.defaultNotifications),ki(),(fe=l(c))==null||fe.focusTerm()}catch{(ye=l(d))==null||ye.open({name:k.name,path:k.path})}finally{Rn(Z)}}}async function H(k){if(!l(S))return;const Z=l(S).path,fe=n.sessions.find(M=>M.branchName===k.headRefName&&M.repoPath.startsWith(Z)),ye=n.worktrees.find(M=>M.branchName===k.headRefName&&M.repoPath===Z);let Ce=`Merge the branch "${k.baseRefName}" into this branch and resolve all merge conflicts. Use \`git merge ${k.baseRefName}\` and fix any conflicts in the working tree. After resolving, verify the build passes.`;try{const M=await Nb(Z);M.promptFixConflicts&&(Ce=M.promptFixConflicts.replace(/\{baseRefName\}/g,k.baseRefName).replace(/\{headRefName\}/g,k.headRefName))}catch{}try{let M,Y;if(fe)M=fe.repoPath,Y=fe.branchName;else if(ye)M=ye.path,Y=ye.branchName;else{const le=await eh(Z,k.headRefName);M=le.worktreePath,Y=le.branchName}const ge=await On({repoPath:Z,repoName:l(S).name,worktreePath:M,branchName:Y});await gt(),n.activeSessionId=ge.id,s.activeWorkspacePath=Z,As(ge.id,o.defaultNotifications),ki(),setTimeout(()=>{Cr(Ce+"\r")},1500)}catch(M){console.error("Failed to start conflict resolution:",M)}}async function D(k,Z){if(!l(S))return;const fe=l(S).path,ye=n.sessions.find(M=>M.branchName===k.headRefName&&M.repoPath.startsWith(fe)),Ce=n.worktrees.find(M=>M.branchName===k.headRefName&&M.repoPath===fe);try{let M,Y;if(ye)M=ye.repoPath,Y=ye.branchName;else if(Ce)M=Ce.path,Y=Ce.branchName;else{const le=await eh(fe,k.headRefName);M=le.worktreePath,Y=le.branchName}const ge=await On({repoPath:fe,repoName:l(S).name,worktreePath:M,branchName:Y});await gt(),n.activeSessionId=ge.id,s.activeWorkspacePath=fe,As(ge.id,o.defaultNotifications),ki(),Z&&setTimeout(()=>{Cr(Z+"\r")},1500)}catch(M){console.error("Failed to open PR branch session:",M)}}function E(k){const Z=k.state==="OPEN"?"OPEN":k.state==="MERGED"?"MERGED":"CLOSED",fe=ku({commitsAhead:1,prState:Z,ciFailing:0,ciPending:0,ciTotal:0,mergeable:k.mergeable??null,unresolvedCommentCount:0}),ye=Bv(fe,{branchName:k.headRefName,baseBranch:k.baseRefName,prNumber:k.number});ye&&D(k,ye)}function $(k){D(k)}function Q(k){var Z;(Z=l(f))==null||Z.open(k)}function pe(k){var Z;n.activeSessionId=k,As(k,o.defaultNotifications),ki(),(Z=l(c))==null||Z.focusTerm()}function be(k){var Z;if(fetch(`/sessions/${k}`,{method:"DELETE"}).then(()=>gt()),n.activeSessionId===k){const fe=l(y).filter(ye=>ye.id!==k);n.activeSessionId=((Z=fe[0])==null?void 0:Z.id)??null}}function ce(k,Z,fe){var ye,Ce;(ye=l(h))==null||ye.show(k,Z,fe),Z||(Ce=l(h))==null||Ce.autoDismiss(3e3)}function se(k){Cr(k)}function De(){}function Te(){}function _e(){const k=document.createElement("input");k.type="file",k.accept="image/*",k.onchange=()=>{var fe,ye;const Z=(fe=k.files)==null?void 0:fe[0];Z&&((ye=l(c))==null||ye.handleImageUpload(Z,Z.type))},k.click()}function Se(){var k;(k=l(c))==null||k.focusTerm()}function de(k){m(z,k,!0)}function Me(){var k;(k=l(c))==null||k.exitCopyMode()}let Ne=F(void 0);function je(){var k;(k=l(Ne))==null||k.open()}async function Pe(k){await gt(),k.length>0&&(s.activeWorkspacePath=k[0])}async function et(){const k=n.activeSessionId;if(!k)return;const Z=n.sessions.find(fe=>fe.id===k);if(Z){if(await kb(k),Z.type==="worktree"){const fe=n.workspaces.find(ye=>Z.repoPath===ye.path||Z.repoPath.startsWith(ye.path+"/"));if(fe&&Z.repoPath!==fe.path)try{await sv(Z.repoPath,fe.path)}catch{}}n.activeSessionId=null,await gt()}}var X=Gr(),ve=Ct(X);{var Fe=k=>{},Ke=k=>{Cy(k,{})},Be=k=>{fk(k,{get client(){return i},children:(Z,fe)=>{var ye=uE(),Ce=Ct(ye),M=w(Ce);{var Y=Le=>{var ht=hE();G("click",ht,function(...Ot){ki==null||ki.apply(this,Ot)}),B(Le,ht)};ie(M,Le=>{s.sidebarOpen&&Le(Y)})}var ge=R(M,2);vw(ge,{onSelectSession:J,onOpenSettings:T,onNewWorktree:L,onAddWorkspace:je,onDeleteSession:be,onDeleteWorktree:Q});var le=R(ge,2),re=w(le);vx(re,{get title(){return l(P)},get onMenuClick(){return gd},get hidden(){return l(b)}});var ke=R(re,2);{var we=Le=>{hx(Le,{heading:"Add a workspace to get started",description:"Point to any folder on your machine. Git repos get PR tracking and branch management.",actionLabel:"+ Add Workspace",onAction:je})},Re=Le=>{{let ht=me(()=>s.activeWorkspacePath??""),Ot=me(()=>{var Di;return((Di=l(S))==null?void 0:Di.name)??""}),ur=me(()=>Qi(`new-worktree:${s.activeWorkspacePath??""}`));sx(Le,{get workspacePath(){return l(ht)},get workspaceName(){return l(Ot)},get creatingWorktree(){return l(ur)},onNewSession:()=>K(),onNewWorktree:()=>{l(S)&&L(l(S))},onFixConflicts:H,onPrAction:E,onOpenPrSession:$})}},oe=Le=>{var ht=cE(),Ot=Ct(ht);{let Ps=me(()=>s.activeWorkspacePath??""),kn=me(()=>{var Lr;return((Lr=l(C))==null?void 0:Lr.branchName)??""});Mk(Ot,{get workspacePath(){return l(Ps)},get branchName(){return l(kn)},get sessionId(){return n.activeSessionId},onArchive:et})}var ur=R(Ot,2);Bk(ur,{get sessions(){return l(y)},get activeSessionId(){return n.activeSessionId},onSelectSession:J,onCloseSession:be,onNewAgent:()=>K(),onNewTerminal:()=>N(),onCustomize:()=>A()});var Di=R(ur,2);Ze(PC(Di,{get sessionId(){return n.activeSessionId},onImageUpload:ce,get useTmux(){return l(I)},onCopyModeChange:de}),Ps=>m(c,Ps,!0),()=>l(c));var Cn=R(Di,2);fx(Cn,{onSendKey:se,onFlushComposedText:De,onClearInput:Te,onUploadImage:_e,onRefocusMobileInput:Se,get useTmux(){return l(I)},get inCopyMode(){return l(z)},onExitCopyMode:Me}),B(Le,ht)};ie(ke,Le=>{l(q)==="empty"?Le(we):l(q)==="dashboard"?Le(Re,1):l(q)==="session"&&Le(oe,2)})}Ze(Ce,Le=>m(p,Le),()=>l(p));var Ee=R(Ce,2);Ze(kx(Ee,{onSessionCreated:pe}),Le=>m(d,Le,!0),()=>l(d));var Ge=R(Ee,2);Ze(Ax(Ge,{}),Le=>m(u,Le,!0),()=>l(u));var qt=R(Ge,2);Ze(Ix(qt,{}),Le=>m(f,Le,!0),()=>l(f));var ae=R(qt,2);Ze($x(ae,{onWorkspacesAdded:Pe}),Le=>m(Ne,Le,!0),()=>l(Ne));var Ye=R(ae,2);Ze(lE(Ye,{onRemoveWorkspace:async Le=>{await fetch("/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Le})}),await gt(),s.activeWorkspacePath===Le&&(s.activeWorkspacePath=null)}}),Le=>m(_,Le,!0),()=>l(_));var jt=R(Ye,2);mx(jt,{});var ji=R(jt,2);Ze(Sx(ji,{}),Le=>m(h,Le,!0),()=>l(h)),B(Z,ye)},$$slots:{default:!0}})};ie(ve,k=>{r.checking?k(Fe):r.authenticated?k(Be,!1):k(Ke,1)})}B(e,X),ft()}_t(["click"]);qm(dE,{target:document.getElementById("app")});
52
+ */var xC=2,EC=1,DC=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var u;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((u=this._terminal.options.overviewRuler)==null?void 0:u.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,c=o.right+o.left,h=r-a,d=s-c-t;return{cols:Math.max(xC,Math.floor(d/e.css.cell.width)),rows:Math.max(EC,Math.floor(h/e.css.cell.height))}}},TC=z('<div class="scroll-fabs svelte-5qgfij"><button class="scroll-fab svelte-5qgfij" data-dir="up" data-track="terminal.scroll-up" aria-label="Page up">&#9650;</button> <button class="scroll-fab svelte-5qgfij" data-dir="down" data-track="terminal.scroll-down" aria-label="Page down">&#9660;</button> <button class="scroll-fab scroll-fab-bottom svelte-5qgfij" data-dir="bottom" data-track="terminal.scroll-bottom" aria-label="Skip to bottom">&#8615;</button></div>'),RC=z('<div data-track="terminal.focus"><div class="terminal-container svelte-5qgfij" role="presentation"></div> <div class="terminal-scrollbar svelte-5qgfij" role="scrollbar" aria-orientation="vertical"><div class="terminal-scrollbar-thumb svelte-5qgfij" role="presentation"></div></div> <!></div>');function PC(e,t){dt(t,!0);let i=Pr(t,"useTmux",3,!1),r=Pr(t,"companionMode",3,!1),s,n=W(null),o,a=!1;function c(){return l(n)}function h(){var M;(M=l(n))==null||M.focus()}function d(){if(!l(n))return;const M=l(n).buffer.active,Y=M.viewportY>=M.baseY,ge=M.viewportY;o==null||o.fit(),Y?l(n).scrollToBottom():l(n).scrollToLine(ge),rh(l(n).cols,l(n).rows),I()}vo(()=>{const M=new kC({cursorBlink:!0,fontSize:Nt?12:14,fontFamily:"Menlo, monospace",scrollback:1e4,theme:{background:"#000000",foreground:"#d4d4d4",cursor:"#d4d4d4"}});if(o=new DC,M.loadAddon(o),M.open(s),Nt){const le=s.querySelector(".xterm-viewport");le&&(le.style.touchAction="none",le.style.overflowY="hidden");const re=s.querySelector(".xterm-screen");if(re){re.addEventListener("wheel",we=>{we.stopImmediatePropagation(),we.preventDefault()},{capture:!0,passive:!1});const ke=we=>{M.modes.mouseTrackingMode!=="none"&&we.stopImmediatePropagation()};for(const we of["mousedown","mouseup","mousemove"])re.addEventListener(we,ke,{capture:!0})}}o.fit(),M.onData(le=>Cr(le));{const le=/Mac|iPhone|iPad|iPod/.test(navigator.platform||"");M.attachCustomKeyEventHandler(re=>!le&&re.type==="keydown"&&re.ctrlKey&&!re.shiftKey&&!re.altKey&&!re.metaKey&&(re.key==="v"||re.key==="V")&&navigator.clipboard&&navigator.clipboard.read?(navigator.clipboard.read().then(ke=>{let we=null,Re=null;for(const oe of ke){for(const Ee of oe.types)if(Ee.startsWith("image/")){Re=Ee,we=oe;break}if(we)break}we&&Re?we.getType(Re).then(oe=>de(oe,Re)):navigator.clipboard.readText().then(oe=>{oe&&M.paste(oe)})}).catch(()=>{navigator.clipboard.readText&&navigator.clipboard.readText().then(ke=>{ke&&M.paste(ke)}).catch(()=>{})}),!1):!0)}M.parser.registerOscHandler(52,le=>{var we;const re=le.indexOf(";");if(re===-1)return!0;const ke=le.slice(re+1);if(!ke||ke==="?")return!0;try{const Re=Uint8Array.from(atob(ke),Ee=>Ee.charCodeAt(0)),oe=new TextDecoder("utf-8").decode(Re);(we=navigator.clipboard)==null||we.writeText(oe).catch(()=>{})}catch{}return!0}),M.onScroll(I),M.onWriteParsed(I);let Y=null;const ge=new ResizeObserver(()=>{Y&&clearTimeout(Y),Y=setTimeout(()=>{const le=M.buffer.active,re=le.viewportY>=le.baseY,ke=le.viewportY;o.fit(),re?M.scrollToBottom():M.scrollToLine(ke),rh(M.cols,M.rows),I()},Nt?150:0)});return ge.observe(s),Nt&&(document.addEventListener("touchmove",ce,{passive:!1}),document.addEventListener("touchend",se),document.addEventListener("touchcancel",se)),m(n,M,!0),()=>{Y&&clearTimeout(Y),U&&clearTimeout(U),ge.disconnect(),M.dispose(),m(n,null),y=!1,u=!1,Nt&&(document.removeEventListener("touchmove",ce),document.removeEventListener("touchend",se),document.removeEventListener("touchcancel",se))}}),Ei(()=>{t.sessionId&&l(n)&&!r()&&(l(n).write("\x1B[?1049l"),l(n).clear(),Rv(t.sessionId,l(n),()=>{l(n)&&rh(l(n).cols,l(n).rows)},()=>{}))});let u=!1,f=0,_=0,p=W(0),b=W(0),g=W(!1),y=!1,O=0,R=0,S=!1,E=0,A=0,P=W(!1),B=W(!1),U=null,$=0,q=0;const F=500,L=10;let D=!1;function I(){D||(D=!0,requestAnimationFrame(H))}function H(){if(D=!1,!l(n))return;const M=l(n).buffer.active,Y=M.baseY+l(n).rows,ge=M.viewportY,le=_e;if(!le)return;const re=le.clientHeight;if(Y<=l(n).rows){m(g,!1);return}m(g,!0),m(p,Math.max(Nt?44:20,l(n).rows/Y*re),!0),m(b,ge/(Y-l(n).rows)*(re-l(p)))}function k(M){if(!l(n)||!_e)return;const Y=_e.getBoundingClientRect(),le=l(n).buffer.active.baseY+l(n).rows;if(le<=l(n).rows)return;const re=_e.clientHeight,ke=Math.max(Nt?44:20,l(n).rows/le*re),we=re-ke,Re=M-Y.top-ke/2,oe=Math.max(0,Math.min(1,Re/we)),Ee=Math.round(oe*(le-l(n).rows));l(n).scrollToLine(Ee)}function x(M){const Y=M.touches[0];Y&&(u=!0,f=Y.clientY,_=l(b))}function Q(){var M;l(B)&&(m(B,!1),(M=t.onCopyModeChange)==null||M.call(t,!1))}function Z(){var ge;if(U=null,y=!1,navigator.vibrate&&navigator.vibrate(50),i()){m(B,!0),(ge=t.onCopyModeChange)==null||ge.call(t,!0),Cr("[");return}m(P,!0);const M=s.querySelector(".xterm-screen");M&&(M.style.userSelect="text",M.style.webkitUserSelect="text"),s.querySelectorAll("canvas").forEach(le=>{le.style.pointerEvents="none"});const Y=s.querySelector(".xterm-rows");if(Y){const le=document.createRange();le.selectNodeContents(Y);const re=window.getSelection();re==null||re.removeAllRanges(),re==null||re.addRange(le)}}function pe(){var Y;m(P,!1);const M=s.querySelector(".xterm-screen");M&&(M.style.userSelect="",M.style.webkitUserSelect=""),s.querySelectorAll("canvas").forEach(ge=>{ge.style.pointerEvents=""}),(Y=window.getSelection())==null||Y.removeAllRanges()}function be(M){var ge;if(l(P)){const le=((ge=window.getSelection())==null?void 0:ge.toString())??"";le.trim().length>0&&(navigator.clipboard.writeText(le).catch(()=>{}),navigator.vibrate&&navigator.vibrate(30)),pe();return}if(l(B)||M.target.closest(".terminal-scrollbar")||M.target.closest(".scroll-fabs")||!l(n))return;const Y=M.touches[0];Y&&(O=Y.clientY,A=Y.clientY,R=l(n).buffer.active.viewportY,S=!1,E=0,y=!0,$=Y.clientX,q=Y.clientY,U&&clearTimeout(U),U=setTimeout(()=>{Z()},F))}function ce(M){const Y=M.touches[0];if(Y){if(u){if(!l(n)||!_e)return;M.preventDefault();const ge=Y.clientY-f,re=l(n).buffer.active.baseY+l(n).rows;if(re<=l(n).rows)return;const ke=_e.clientHeight,we=Math.max(44,l(n).rows/re*ke),Re=ke-we,Ee=Math.max(0,Math.min(Re,_+ge))/Re,Ge=Math.round(Ee*(re-l(n).rows));l(n).scrollToLine(Ge);return}if(y&&l(n)&&!l(P)){if(U){const le=Math.abs(Y.clientX-$),re=Math.abs(Y.clientY-q);(le>L||re>L)&&(clearTimeout(U),U=null)}if(l(n).rows===0||s.clientHeight===0)return;const ge=O-Y.clientY;if(Math.abs(ge)>5){S=!0,M.preventDefault();const le=s.clientHeight/l(n).rows;if(l(n).buffer.active.type==="alternate"){const re=A-Y.clientY;A=Y.clientY;const ke=re/le;E+=ke;const we=Math.trunc(E);if(we!==0){E-=we;const Re=we>0?65:64,oe=Math.max(1,Math.round(l(n).cols/2)),Ee=Math.max(1,Math.round(l(n).rows/2)),Ge=`\x1B[<${Re};${oe};${Ee}M`,qt=Math.min(Math.abs(we),5);for(let ae=0;ae<qt;ae++)Cr(Ge)}}else{const re=ge/le,ke=l(n).buffer.active.baseY,we=Math.max(0,Math.min(ke,Math.round(R+re)));l(n).scrollToLine(we)}}}}}function se(){U&&(clearTimeout(U),U=null),u=!1,y=!1,S=!1,E=0}function De(M){M.target!==Se&&k(M.clientY)}function Te(M){M.preventDefault();const Y=M.target.closest("button");if(!Y||!l(n))return;const ge=Y.dataset.dir;if(l(n).buffer.active.type==="alternate"){const le=Math.max(1,Math.round(l(n).cols/2)),re=Math.max(1,Math.round(l(n).rows/2));if(ge==="up"||ge==="down"){const we=`\x1B[<${ge==="down"?65:64};${le};${re}M`,Re=Math.max(1,Math.round(l(n).rows/2));for(let oe=0;oe<Re;oe++)Cr(we)}else if(ge==="bottom"){const ke=`\x1B[<65;${le};${re}M`;for(let we=0;we<l(n).rows;we++)Cr(ke)}}else ge==="up"?l(n).scrollPages(-1):ge==="down"?l(n).scrollPages(1):ge==="bottom"&&l(n).scrollToBottom()}let _e,Se;async function de(M,Y){var le;if(a||!t.sessionId)return;a=!0,(le=t.onImageUpload)==null||le.call(t,"Pasting image…",!1);const ge=new FileReader;ge.onload=async()=>{var ke,we,Re;const re=ge.result.split(",")[1];try{const oe=await xb(t.sessionId,re,Y);oe.clipboardSet?(ke=t.onImageUpload)==null||ke.call(t,"Image pasted",!1):(we=t.onImageUpload)==null||we.call(t,oe.path,!0,oe.path)}catch(oe){const Ee=oe instanceof Error?oe.message:"Image upload failed";(Re=t.onImageUpload)==null||Re.call(t,Ee,!1)}finally{a=!1}},ge.readAsDataURL(M)}function Me(M){var Y;if((Y=M.clipboardData)!=null&&Y.items){for(const ge of M.clipboardData.items)if(ge.type.startsWith("image/")){M.preventDefault(),M.stopPropagation();const le=ge.getAsFile();le&&de(le,ge.type);return}}}let Ne=W(!1);function je(M){var Y;(Y=M.dataTransfer)!=null&&Y.types.includes("Files")&&(M.preventDefault(),m(Ne,!0))}function Pe(){m(Ne,!1)}function et(M){var ge;if(M.preventDefault(),m(Ne,!1),!((ge=M.dataTransfer)!=null&&ge.files.length))return;const Y=M.dataTransfer.files[0];Y.type.startsWith("image/")&&de(Y,Y.type)}function X(M){var Y;u||S||M.target.closest(".terminal-scrollbar")||M.target.closest(".scroll-fabs")||l(P)||((Y=l(n))==null||Y.focus(),M.preventDefault())}var ve={getTerm:c,focusTerm:h,fitTerm:d,exitCopyMode:Q,handleImageUpload:de},Fe=RC();let Ke;var Be=w(Fe);Ze(Be,M=>s=M,()=>s);var C=T(Be,2);Ie(C,"aria-valuenow",0);var J=w(C);let fe;Ze(J,M=>Se=M,()=>Se),Ze(C,M=>_e=M,()=>_e);var ye=T(C,2);{var Ce=M=>{var Y=TC();G("mousedown",Y,Te),N(M,Y)};ie(ye,M=>{Nt&&l(g)&&M(Ce)})}return he(()=>{Ke=it(Fe,1,"terminal-wrapper svelte-5qgfij",null,Ke,{"drag-over":l(Ne),"selection-mode":l(P)}),fe=_o(J,"",fe,{display:l(g)?"block":"none",height:l(p)+"px",top:l(b)+"px"})}),G("touchstart",Fe,function(...M){var Y;(Y=Nt?be:void 0)==null||Y.apply(this,M)}),G("touchend",Fe,function(...M){var Y;(Y=Nt?X:void 0)==null||Y.apply(this,M)}),xr("paste",Be,Me),xr("dragover",Be,je),xr("dragleave",Be,Pe),xr("drop",Be,et),G("click",C,De),G("touchstart",J,x),N(e,Fe),ft(ve)}_t(["touchstart","touchend","click","mousedown"]);var Sa=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},AC={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ls,ru,Vf,MC=(Vf=class{constructor(){ee(this,ls,AC);ee(this,ru,!1)}setTimeoutProvider(e){j(this,ls,e)}setTimeout(e,t){return v(this,ls).setTimeout(e,t)}clearTimeout(e){v(this,ls).clearTimeout(e)}setInterval(e,t){return v(this,ls).setInterval(e,t)}clearInterval(e){v(this,ls).clearInterval(e)}},ls=new WeakMap,ru=new WeakMap,Vf),js=new MC;function OC(e){setTimeout(e,0)}var co=typeof window>"u"||"Deno"in globalThis;function Bi(){}function LC(e,t){return typeof e=="function"?e(t):e}function zc(e){return typeof e=="number"&&e>=0&&e!==1/0}function Xp(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Es(e,t){return typeof e=="function"?e(t):e}function Wi(e,t){return typeof e=="function"?e(t):e}function Pf(e,t){const{type:i="all",exact:r,fetchStatus:s,predicate:n,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==Uu(o,t.options))return!1}else if(!Jo(t.queryKey,o))return!1}if(i!=="all"){const c=t.isActive();if(i==="active"&&!c||i==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||s&&s!==t.state.fetchStatus||n&&!n(t))}function Af(e,t){const{exact:i,status:r,predicate:s,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(i){if(Zo(t.options.mutationKey)!==Zo(n))return!1}else if(!Jo(t.options.mutationKey,n))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Uu(e,t){return((t==null?void 0:t.queryKeyHashFn)||Zo)(e)}function Zo(e){return JSON.stringify(e,(t,i)=>Kc(i)?Object.keys(i).sort().reduce((r,s)=>(r[s]=i[s],r),{}):i)}function Jo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>Jo(e[i],t[i])):!1}var IC=Object.prototype.hasOwnProperty;function $p(e,t,i=0){if(e===t)return e;if(i>500)return t;const r=Mf(e)&&Mf(t);if(!r&&!(Kc(e)&&Kc(t)))return t;const n=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),a=o.length,c=r?new Array(a):{};let h=0;for(let d=0;d<a;d++){const u=r?d:o[d],f=e[u],_=t[u];if(f===_){c[u]=f,(r?d<n:IC.call(e,u))&&h++;continue}if(f===null||_===null||typeof f!="object"||typeof _!="object"){c[u]=_;continue}const p=$p(f,_,i+1);c[u]=p,p===f&&h++}return n===a&&h===n?e:c}function Uc(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}function Mf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Kc(e){if(!Of(e))return!1;const t=e.constructor;if(t===void 0)return!0;const i=t.prototype;return!(!Of(i)||!i.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Of(e){return Object.prototype.toString.call(e)==="[object Object]"}function BC(e){return new Promise(t=>{js.setTimeout(t,e)})}function qc(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?$p(e,t):t}function NC(e,t,i=0){const r=[...e,t];return i&&r.length>i?r.slice(1):r}function FC(e,t,i=0){const r=[t,...e];return i&&r.length>i?r.slice(0,-1):r}var Ku=Symbol();function Qp(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Ku?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function WC(e,t,i){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?i():s.addEventListener("abort",i,{once:!0})),s)}),e}var Qs,hs,Kn,Gf,HC=(Gf=class extends Sa{constructor(){super();ee(this,Qs);ee(this,hs);ee(this,Kn);j(this,Kn,t=>{if(!co&&window.addEventListener){const i=()=>t();return window.addEventListener("visibilitychange",i,!1),()=>{window.removeEventListener("visibilitychange",i)}}})}onSubscribe(){v(this,hs)||this.setEventListener(v(this,Kn))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,hs))==null||t.call(this),j(this,hs,void 0))}setEventListener(t){var i;j(this,Kn,t),(i=v(this,hs))==null||i.call(this),j(this,hs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){v(this,Qs)!==t&&(j(this,Qs,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(i=>{i(t)})}isFocused(){var t;return typeof v(this,Qs)=="boolean"?v(this,Qs):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Qs=new WeakMap,hs=new WeakMap,Kn=new WeakMap,Gf),qu=new HC;function jc(){let e,t;const i=new Promise((s,n)=>{e=s,t=n});i.status="pending",i.catch(()=>{});function r(s){Object.assign(i,s),delete i.resolve,delete i.reject}return i.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},i.reject=s=>{r({status:"rejected",reason:s}),t(s)},i}var zC=OC;function UC(){let e=[],t=0,i=a=>{a()},r=a=>{a()},s=zC;const n=a=>{t?e.push(a):s(()=>{i(a)})},o=()=>{const a=e;e=[],a.length&&s(()=>{r(()=>{a.forEach(c=>{i(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||o()}return c},batchCalls:a=>(...c)=>{n(()=>{a(...c)})},schedule:n,setNotifyFunction:a=>{i=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{s=a}}}var ri=UC(),qn,cs,jn,Xf,KC=(Xf=class extends Sa{constructor(){super();ee(this,qn,!0);ee(this,cs);ee(this,jn);j(this,jn,t=>{if(!co&&window.addEventListener){const i=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",i,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",r)}}})}onSubscribe(){v(this,cs)||this.setEventListener(v(this,jn))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,cs))==null||t.call(this),j(this,cs,void 0))}setEventListener(t){var i;j(this,jn,t),(i=v(this,cs))==null||i.call(this),j(this,cs,t(this.setOnline.bind(this)))}setOnline(t){v(this,qn)!==t&&(j(this,qn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return v(this,qn)}},qn=new WeakMap,cs=new WeakMap,jn=new WeakMap,Xf),bl=new KC;function qC(e){return Math.min(1e3*2**e,3e4)}function Zp(e){return(e??"online")==="online"?bl.isOnline():!0}var Yc=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Jp(e){let t=!1,i=0,r;const s=jc(),n=()=>s.status!=="pending",o=b=>{var g;if(!n()){const y=new Yc(b);f(y),(g=e.onCancel)==null||g.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},h=()=>qu.isFocused()&&(e.networkMode==="always"||bl.isOnline())&&e.canRun(),d=()=>Zp(e.networkMode)&&e.canRun(),u=b=>{n()||(r==null||r(),s.resolve(b))},f=b=>{n()||(r==null||r(),s.reject(b))},_=()=>new Promise(b=>{var g;r=y=>{(n()||h())&&b(y)},(g=e.onPause)==null||g.call(e)}).then(()=>{var b;r=void 0,n()||(b=e.onContinue)==null||b.call(e)}),p=()=>{if(n())return;let b;const g=i===0?e.initialPromise:void 0;try{b=g??e.fn()}catch(y){b=Promise.reject(y)}Promise.resolve(b).then(u).catch(y=>{var A;if(n())return;const O=e.retry??(co?0:3),R=e.retryDelay??qC,S=typeof R=="function"?R(i,y):R,E=O===!0||typeof O=="number"&&i<O||typeof O=="function"&&O(i,y);if(t||!E){f(y);return}i++,(A=e.onFail)==null||A.call(e,i,y),BC(S).then(()=>h()?void 0:_()).then(()=>{t?f(y):p()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?p():_().then(p),s)}}var Zs,$f,eg=($f=class{constructor(){ee(this,Zs)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zc(this.gcTime)&&j(this,Zs,js.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(co?1/0:300*1e3))}clearGcTimeout(){v(this,Zs)&&(js.clearTimeout(v(this,Zs)),j(this,Zs,void 0))}},Zs=new WeakMap,$f),Js,Yn,Li,en,It,sa,tn,er,Br,Qf,jC=(Qf=class extends eg{constructor(t){super();ee(this,er);ee(this,Js);ee(this,Yn);ee(this,Li);ee(this,en);ee(this,It);ee(this,sa);ee(this,tn);j(this,tn,!1),j(this,sa,t.defaultOptions),this.setOptions(t.options),this.observers=[],j(this,en,t.client),j(this,Li,v(this,en).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,j(this,Js,If(this.options)),this.state=t.state??v(this,Js),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=v(this,It))==null?void 0:t.promise}setOptions(t){if(this.options={...v(this,sa),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const i=If(this.options);i.data!==void 0&&(this.setState(Lf(i.data,i.dataUpdatedAt)),j(this,Js,i))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&v(this,Li).remove(this)}setData(t,i){const r=qc(this.state.data,t,this.options);return xe(this,er,Br).call(this,{data:r,type:"success",dataUpdatedAt:i==null?void 0:i.updatedAt,manual:i==null?void 0:i.manual}),r}setState(t,i){xe(this,er,Br).call(this,{type:"setState",state:t,setStateOptions:i})}cancel(t){var r,s;const i=(r=v(this,It))==null?void 0:r.promise;return(s=v(this,It))==null||s.cancel(t),i?i.then(Bi).catch(Bi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(v(this,Js))}isActive(){return this.observers.some(t=>Wi(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ku||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Es(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Xp(this.state.dataUpdatedAt,t)}onFocus(){var i;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(i=v(this,It))==null||i.continue()}onOnline(){var i;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(i=v(this,It))==null||i.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),v(this,Li).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(i=>i!==t),this.observers.length||(v(this,It)&&(v(this,tn)?v(this,It).cancel({revert:!0}):v(this,It).cancelRetry()),this.scheduleGc()),v(this,Li).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||xe(this,er,Br).call(this,{type:"invalidate"})}async fetch(t,i){var c,h,d,u,f,_,p,b,g,y,O,R;if(this.state.fetchStatus!=="idle"&&((c=v(this,It))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(i!=null&&i.cancelRefetch))this.cancel({silent:!0});else if(v(this,It))return v(this,It).continueRetry(),v(this,It).promise}if(t&&this.setOptions(t),!this.options.queryFn){const S=this.observers.find(E=>E.options.queryFn);S&&this.setOptions(S.options)}const r=new AbortController,s=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(j(this,tn,!0),r.signal)})},n=()=>{const S=Qp(this.options,i),A=(()=>{const P={client:v(this,en),queryKey:this.queryKey,meta:this.meta};return s(P),P})();return j(this,tn,!1),this.options.persister?this.options.persister(S,A,this):S(A)},a=(()=>{const S={fetchOptions:i,options:this.options,queryKey:this.queryKey,client:v(this,en),state:this.state,fetchFn:n};return s(S),S})();(h=this.options.behavior)==null||h.onFetch(a,this),j(this,Yn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&xe(this,er,Br).call(this,{type:"fetch",meta:(u=a.fetchOptions)==null?void 0:u.meta}),j(this,It,Jp({initialPromise:i==null?void 0:i.initialPromise,fn:a.fetchFn,onCancel:S=>{S instanceof Yc&&S.revert&&this.setState({...v(this,Yn),fetchStatus:"idle"}),r.abort()},onFail:(S,E)=>{xe(this,er,Br).call(this,{type:"failed",failureCount:S,error:E})},onPause:()=>{xe(this,er,Br).call(this,{type:"pause"})},onContinue:()=>{xe(this,er,Br).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const S=await v(this,It).start();if(S===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(S),(_=(f=v(this,Li).config).onSuccess)==null||_.call(f,S,this),(b=(p=v(this,Li).config).onSettled)==null||b.call(p,S,this.state.error,this),S}catch(S){if(S instanceof Yc){if(S.silent)return v(this,It).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw xe(this,er,Br).call(this,{type:"error",error:S}),(y=(g=v(this,Li).config).onError)==null||y.call(g,S,this),(R=(O=v(this,Li).config).onSettled)==null||R.call(O,this.state.data,S,this),S}finally{this.scheduleGc()}}},Js=new WeakMap,Yn=new WeakMap,Li=new WeakMap,en=new WeakMap,It=new WeakMap,sa=new WeakMap,tn=new WeakMap,er=new WeakSet,Br=function(t){const i=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...tg(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...Lf(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return j(this,Yn,t.manual?s:void 0),s;case"error":const n=t.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=i(this.state),ri.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),v(this,Li).notify({query:this,type:"updated",action:t})})},Qf);function tg(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zp(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Lf(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function If(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,i=t!==void 0,r=i?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:i?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:i?"success":"pending",fetchStatus:"idle"}}var di,qe,na,oi,rn,Vn,Hr,us,oa,Gn,Xn,sn,nn,ds,$n,$e,Lo,Vc,Gc,Xc,$c,Qc,Zc,Jc,ig,Zf,YC=(Zf=class extends Sa{constructor(t,i){super();ee(this,$e);ee(this,di);ee(this,qe);ee(this,na);ee(this,oi);ee(this,rn);ee(this,Vn);ee(this,Hr);ee(this,us);ee(this,oa);ee(this,Gn);ee(this,Xn);ee(this,sn);ee(this,nn);ee(this,ds);ee(this,$n,new Set);this.options=i,j(this,di,t),j(this,us,null),j(this,Hr,jc()),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(v(this,qe).addObserver(this),Bf(v(this,qe),this.options)?xe(this,$e,Lo).call(this):this.updateResult(),xe(this,$e,$c).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return eu(v(this,qe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return eu(v(this,qe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,xe(this,$e,Qc).call(this),xe(this,$e,Zc).call(this),v(this,qe).removeObserver(this)}setOptions(t){const i=this.options,r=v(this,qe);if(this.options=v(this,di).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Wi(this.options.enabled,v(this,qe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");xe(this,$e,Jc).call(this),v(this,qe).setOptions(this.options),i._defaulted&&!Uc(this.options,i)&&v(this,di).getQueryCache().notify({type:"observerOptionsUpdated",query:v(this,qe),observer:this});const s=this.hasListeners();s&&Nf(v(this,qe),r,this.options,i)&&xe(this,$e,Lo).call(this),this.updateResult(),s&&(v(this,qe)!==r||Wi(this.options.enabled,v(this,qe))!==Wi(i.enabled,v(this,qe))||Es(this.options.staleTime,v(this,qe))!==Es(i.staleTime,v(this,qe)))&&xe(this,$e,Vc).call(this);const n=xe(this,$e,Gc).call(this);s&&(v(this,qe)!==r||Wi(this.options.enabled,v(this,qe))!==Wi(i.enabled,v(this,qe))||n!==v(this,ds))&&xe(this,$e,Xc).call(this,n)}getOptimisticResult(t){const i=v(this,di).getQueryCache().build(v(this,di),t),r=this.createResult(i,t);return GC(this,r)&&(j(this,oi,r),j(this,Vn,this.options),j(this,rn,v(this,qe).state)),r}getCurrentResult(){return v(this,oi)}trackResult(t,i){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),i==null||i(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&v(this,Hr).status==="pending"&&v(this,Hr).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){v(this,$n).add(t)}getCurrentQuery(){return v(this,qe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=v(this,di).defaultQueryOptions(t),r=v(this,di).getQueryCache().build(v(this,di),i);return r.fetch().then(()=>this.createResult(r,i))}fetch(t){return xe(this,$e,Lo).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),v(this,oi)))}createResult(t,i){var U;const r=v(this,qe),s=this.options,n=v(this,oi),o=v(this,rn),a=v(this,Vn),h=t!==r?t.state:v(this,na),{state:d}=t;let u={...d},f=!1,_;if(i._optimisticResults){const $=this.hasListeners(),q=!$&&Bf(t,i),F=$&&Nf(t,r,i,s);(q||F)&&(u={...u,...tg(d.data,t.options)}),i._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:g}=u;_=u.data;let y=!1;if(i.placeholderData!==void 0&&_===void 0&&g==="pending"){let $;n!=null&&n.isPlaceholderData&&i.placeholderData===(a==null?void 0:a.placeholderData)?($=n.data,y=!0):$=typeof i.placeholderData=="function"?i.placeholderData((U=v(this,Xn))==null?void 0:U.state.data,v(this,Xn)):i.placeholderData,$!==void 0&&(g="success",_=qc(n==null?void 0:n.data,$,i),f=!0)}if(i.select&&_!==void 0&&!y)if(n&&_===(o==null?void 0:o.data)&&i.select===v(this,oa))_=v(this,Gn);else try{j(this,oa,i.select),_=i.select(_),_=qc(n==null?void 0:n.data,_,i),j(this,Gn,_),j(this,us,null)}catch($){j(this,us,$)}v(this,us)&&(p=v(this,us),_=v(this,Gn),b=Date.now(),g="error");const O=u.fetchStatus==="fetching",R=g==="pending",S=g==="error",E=R&&O,A=_!==void 0,B={status:g,fetchStatus:u.fetchStatus,isPending:R,isSuccess:g==="success",isError:S,isInitialLoading:E,isLoading:E,data:_,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>h.dataUpdateCount||u.errorUpdateCount>h.errorUpdateCount,isFetching:O,isRefetching:O&&!R,isLoadingError:S&&!A,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&A,isStale:ju(t,i),refetch:this.refetch,promise:v(this,Hr),isEnabled:Wi(i.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const $=B.data!==void 0,q=B.status==="error"&&!$,F=I=>{q?I.reject(B.error):$&&I.resolve(B.data)},L=()=>{const I=j(this,Hr,B.promise=jc());F(I)},D=v(this,Hr);switch(D.status){case"pending":t.queryHash===r.queryHash&&F(D);break;case"fulfilled":(q||B.data!==D.value)&&L();break;case"rejected":(!q||B.error!==D.reason)&&L();break}}return B}updateResult(){const t=v(this,oi),i=this.createResult(v(this,qe),this.options);if(j(this,rn,v(this,qe).state),j(this,Vn,this.options),v(this,rn).data!==void 0&&j(this,Xn,v(this,qe)),Uc(i,t))return;j(this,oi,i);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,n=typeof s=="function"?s():s;if(n==="all"||!n&&!v(this,$n).size)return!0;const o=new Set(n??v(this,$n));return this.options.throwOnError&&o.add("error"),Object.keys(v(this,oi)).some(a=>{const c=a;return v(this,oi)[c]!==t[c]&&o.has(c)})};xe(this,$e,ig).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&xe(this,$e,$c).call(this)}},di=new WeakMap,qe=new WeakMap,na=new WeakMap,oi=new WeakMap,rn=new WeakMap,Vn=new WeakMap,Hr=new WeakMap,us=new WeakMap,oa=new WeakMap,Gn=new WeakMap,Xn=new WeakMap,sn=new WeakMap,nn=new WeakMap,ds=new WeakMap,$n=new WeakMap,$e=new WeakSet,Lo=function(t){xe(this,$e,Jc).call(this);let i=v(this,qe).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(Bi)),i},Vc=function(){xe(this,$e,Qc).call(this);const t=Es(this.options.staleTime,v(this,qe));if(co||v(this,oi).isStale||!zc(t))return;const r=Xp(v(this,oi).dataUpdatedAt,t)+1;j(this,sn,js.setTimeout(()=>{v(this,oi).isStale||this.updateResult()},r))},Gc=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(v(this,qe)):this.options.refetchInterval)??!1},Xc=function(t){xe(this,$e,Zc).call(this),j(this,ds,t),!(co||Wi(this.options.enabled,v(this,qe))===!1||!zc(v(this,ds))||v(this,ds)===0)&&j(this,nn,js.setInterval(()=>{(this.options.refetchIntervalInBackground||qu.isFocused())&&xe(this,$e,Lo).call(this)},v(this,ds)))},$c=function(){xe(this,$e,Vc).call(this),xe(this,$e,Xc).call(this,xe(this,$e,Gc).call(this))},Qc=function(){v(this,sn)&&(js.clearTimeout(v(this,sn)),j(this,sn,void 0))},Zc=function(){v(this,nn)&&(js.clearInterval(v(this,nn)),j(this,nn,void 0))},Jc=function(){const t=v(this,di).getQueryCache().build(v(this,di),this.options);if(t===v(this,qe))return;const i=v(this,qe);j(this,qe,t),j(this,na,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},ig=function(t){ri.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(v(this,oi))}),v(this,di).getQueryCache().notify({query:v(this,qe),type:"observerResultsUpdated"})})},Zf);function VC(e,t){return Wi(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Bf(e,t){return VC(e,t)||e.state.data!==void 0&&eu(e,t,t.refetchOnMount)}function eu(e,t,i){if(Wi(t.enabled,e)!==!1&&Es(t.staleTime,e)!=="static"){const r=typeof i=="function"?i(e):i;return r==="always"||r!==!1&&ju(e,t)}return!1}function Nf(e,t,i,r){return(e!==t||Wi(r.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&ju(e,i)}function ju(e,t){return Wi(t.enabled,e)!==!1&&e.isStaleByTime(Es(t.staleTime,e))}function GC(e,t){return!Uc(e.getCurrentResult(),t)}function Ff(e){return{onFetch:(t,i)=>{var d,u,f,_,p;const r=t.options,s=(f=(u=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:u.fetchMore)==null?void 0:f.direction,n=((_=t.state.data)==null?void 0:_.pages)||[],o=((p=t.state.data)==null?void 0:p.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const h=async()=>{let b=!1;const g=R=>{WC(R,()=>t.signal,()=>b=!0)},y=Qp(t.options,t.fetchOptions),O=async(R,S,E)=>{if(b)return Promise.reject();if(S==null&&R.pages.length)return Promise.resolve(R);const P=(()=>{const q={client:t.client,queryKey:t.queryKey,pageParam:S,direction:E?"backward":"forward",meta:t.options.meta};return g(q),q})(),B=await y(P),{maxPages:U}=t.options,$=E?FC:NC;return{pages:$(R.pages,B,U),pageParams:$(R.pageParams,S,U)}};if(s&&n.length){const R=s==="backward",S=R?XC:Wf,E={pages:n,pageParams:o},A=S(r,E);a=await O(E,A,R)}else{const R=e??n.length;do{const S=c===0?o[0]??r.initialPageParam:Wf(r,a);if(c>0&&S==null)break;a=await O(a,S),c++}while(c<R)}return a};t.options.persister?t.fetchFn=()=>{var b,g;return(g=(b=t.options).persister)==null?void 0:g.call(b,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i)}:t.fetchFn=h}}}function Wf(e,{pages:t,pageParams:i}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,i[r],i):void 0}function XC(e,{pages:t,pageParams:i}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,i[0],i):void 0}var aa,yr,ti,on,Sr,ss,Jf,$C=(Jf=class extends eg{constructor(t){super();ee(this,Sr);ee(this,aa);ee(this,yr);ee(this,ti);ee(this,on);j(this,aa,t.client),this.mutationId=t.mutationId,j(this,ti,t.mutationCache),j(this,yr,[]),this.state=t.state||QC(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){v(this,yr).includes(t)||(v(this,yr).push(t),this.clearGcTimeout(),v(this,ti).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){j(this,yr,v(this,yr).filter(i=>i!==t)),this.scheduleGc(),v(this,ti).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){v(this,yr).length||(this.state.status==="pending"?this.scheduleGc():v(this,ti).remove(this))}continue(){var t;return((t=v(this,on))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,c,h,d,u,f,_,p,b,g,y,O,R,S,E,A,P;const i=()=>{xe(this,Sr,ss).call(this,{type:"continue"})},r={client:v(this,aa),meta:this.options.meta,mutationKey:this.options.mutationKey};j(this,on,Jp({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(B,U)=>{xe(this,Sr,ss).call(this,{type:"failed",failureCount:B,error:U})},onPause:()=>{xe(this,Sr,ss).call(this,{type:"pause"})},onContinue:i,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>v(this,ti).canRun(this)}));const s=this.state.status==="pending",n=!v(this,on).canStart();try{if(s)i();else{xe(this,Sr,ss).call(this,{type:"pending",variables:t,isPaused:n}),v(this,ti).config.onMutate&&await v(this,ti).config.onMutate(t,this,r);const U=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,r));U!==this.state.context&&xe(this,Sr,ss).call(this,{type:"pending",context:U,variables:t,isPaused:n})}const B=await v(this,on).start();return await((h=(c=v(this,ti).config).onSuccess)==null?void 0:h.call(c,B,t,this.state.context,this,r)),await((u=(d=this.options).onSuccess)==null?void 0:u.call(d,B,t,this.state.context,r)),await((_=(f=v(this,ti).config).onSettled)==null?void 0:_.call(f,B,null,this.state.variables,this.state.context,this,r)),await((b=(p=this.options).onSettled)==null?void 0:b.call(p,B,null,t,this.state.context,r)),xe(this,Sr,ss).call(this,{type:"success",data:B}),B}catch(B){try{await((y=(g=v(this,ti).config).onError)==null?void 0:y.call(g,B,t,this.state.context,this,r))}catch(U){Promise.reject(U)}try{await((R=(O=this.options).onError)==null?void 0:R.call(O,B,t,this.state.context,r))}catch(U){Promise.reject(U)}try{await((E=(S=v(this,ti).config).onSettled)==null?void 0:E.call(S,void 0,B,this.state.variables,this.state.context,this,r))}catch(U){Promise.reject(U)}try{await((P=(A=this.options).onSettled)==null?void 0:P.call(A,void 0,B,t,this.state.context,r))}catch(U){Promise.reject(U)}throw xe(this,Sr,ss).call(this,{type:"error",error:B}),B}finally{v(this,ti).runNext(this)}}},aa=new WeakMap,yr=new WeakMap,ti=new WeakMap,on=new WeakMap,Sr=new WeakSet,ss=function(t){const i=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=i(this.state),ri.batch(()=>{v(this,yr).forEach(r=>{r.onMutationUpdate(t)}),v(this,ti).notify({mutation:this,type:"updated",action:t})})},Jf);function QC(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zr,tr,la,e_,ZC=(e_=class extends Sa{constructor(t={}){super();ee(this,zr);ee(this,tr);ee(this,la);this.config=t,j(this,zr,new Set),j(this,tr,new Map),j(this,la,0)}build(t,i,r){const s=new $C({client:t,mutationCache:this,mutationId:++Ca(this,la)._,options:t.defaultMutationOptions(i),state:r});return this.add(s),s}add(t){v(this,zr).add(t);const i=Ia(t);if(typeof i=="string"){const r=v(this,tr).get(i);r?r.push(t):v(this,tr).set(i,[t])}this.notify({type:"added",mutation:t})}remove(t){if(v(this,zr).delete(t)){const i=Ia(t);if(typeof i=="string"){const r=v(this,tr).get(i);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&v(this,tr).delete(i)}}this.notify({type:"removed",mutation:t})}canRun(t){const i=Ia(t);if(typeof i=="string"){const r=v(this,tr).get(i),s=r==null?void 0:r.find(n=>n.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const i=Ia(t);if(typeof i=="string"){const s=(r=v(this,tr).get(i))==null?void 0:r.find(n=>n!==t&&n.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ri.batch(()=>{v(this,zr).forEach(t=>{this.notify({type:"removed",mutation:t})}),v(this,zr).clear(),v(this,tr).clear()})}getAll(){return Array.from(v(this,zr))}find(t){const i={exact:!0,...t};return this.getAll().find(r=>Af(i,r))}findAll(t={}){return this.getAll().filter(i=>Af(t,i))}notify(t){ri.batch(()=>{this.listeners.forEach(i=>{i(t)})})}resumePausedMutations(){const t=this.getAll().filter(i=>i.state.isPaused);return ri.batch(()=>Promise.all(t.map(i=>i.continue().catch(Bi))))}},zr=new WeakMap,tr=new WeakMap,la=new WeakMap,e_);function Ia(e){var t;return(t=e.options.scope)==null?void 0:t.id}var wr,t_,JC=(t_=class extends Sa{constructor(t={}){super();ee(this,wr);this.config=t,j(this,wr,new Map)}build(t,i,r){const s=i.queryKey,n=i.queryHash??Uu(s,i);let o=this.get(n);return o||(o=new jC({client:t,queryKey:s,queryHash:n,options:t.defaultQueryOptions(i),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){v(this,wr).has(t.queryHash)||(v(this,wr).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const i=v(this,wr).get(t.queryHash);i&&(t.destroy(),i===t&&v(this,wr).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ri.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return v(this,wr).get(t)}getAll(){return[...v(this,wr).values()]}find(t){const i={exact:!0,...t};return this.getAll().find(r=>Pf(i,r))}findAll(t={}){const i=this.getAll();return Object.keys(t).length>0?i.filter(r=>Pf(t,r)):i}notify(t){ri.batch(()=>{this.listeners.forEach(i=>{i(t)})})}onFocus(){ri.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ri.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},wr=new WeakMap,t_),ct,fs,_s,Qn,Zn,vs,Jn,eo,i_,rg=(i_=class{constructor(e={}){ee(this,ct);ee(this,fs);ee(this,_s);ee(this,Qn);ee(this,Zn);ee(this,vs);ee(this,Jn);ee(this,eo);j(this,ct,e.queryCache||new JC),j(this,fs,e.mutationCache||new ZC),j(this,_s,e.defaultOptions||{}),j(this,Qn,new Map),j(this,Zn,new Map),j(this,vs,0)}mount(){Ca(this,vs)._++,v(this,vs)===1&&(j(this,Jn,qu.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,ct).onFocus())})),j(this,eo,bl.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,ct).onOnline())})))}unmount(){var e,t;Ca(this,vs)._--,v(this,vs)===0&&((e=v(this,Jn))==null||e.call(this),j(this,Jn,void 0),(t=v(this,eo))==null||t.call(this),j(this,eo,void 0))}isFetching(e){return v(this,ct).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return v(this,fs).findAll({...e,status:"pending"}).length}getQueryData(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=v(this,ct).get(t.queryHash))==null?void 0:i.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),i=v(this,ct).build(this,t),r=i.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime(Es(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return v(this,ct).findAll(e).map(({queryKey:t,state:i})=>{const r=i.data;return[t,r]})}setQueryData(e,t,i){const r=this.defaultQueryOptions({queryKey:e}),s=v(this,ct).get(r.queryHash),n=s==null?void 0:s.state.data,o=LC(t,n);if(o!==void 0)return v(this,ct).build(this,r).setData(o,{...i,manual:!0})}setQueriesData(e,t,i){return ri.batch(()=>v(this,ct).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,i)]))}getQueryState(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=v(this,ct).get(t.queryHash))==null?void 0:i.state}removeQueries(e){const t=v(this,ct);ri.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=v(this,ct);return ri.batch(()=>(i.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},r=ri.batch(()=>v(this,ct).findAll(e).map(s=>s.cancel(i)));return Promise.all(r).then(Bi).catch(Bi)}invalidateQueries(e,t={}){return ri.batch(()=>(v(this,ct).findAll(e).forEach(i=>{i.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const i={...t,cancelRefetch:t.cancelRefetch??!0},r=ri.batch(()=>v(this,ct).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let n=s.fetch(void 0,i);return i.throwOnError||(n=n.catch(Bi)),s.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(r).then(Bi)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const i=v(this,ct).build(this,t);return i.isStaleByTime(Es(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Bi).catch(Bi)}fetchInfiniteQuery(e){return e.behavior=Ff(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Bi).catch(Bi)}ensureInfiniteQueryData(e){return e.behavior=Ff(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return bl.isOnline()?v(this,fs).resumePausedMutations():Promise.resolve()}getQueryCache(){return v(this,ct)}getMutationCache(){return v(this,fs)}getDefaultOptions(){return v(this,_s)}setDefaultOptions(e){j(this,_s,e)}setQueryDefaults(e,t){v(this,Qn).set(Zo(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...v(this,Qn).values()],i={};return t.forEach(r=>{Jo(e,r.queryKey)&&Object.assign(i,r.defaultOptions)}),i}setMutationDefaults(e,t){v(this,Zn).set(Zo(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...v(this,Zn).values()],i={};return t.forEach(r=>{Jo(e,r.mutationKey)&&Object.assign(i,r.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={...v(this,_s).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Uu(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ku&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...v(this,_s).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){v(this,ct).clear(),v(this,fs).clear()}},ct=new WeakMap,fs=new WeakMap,_s=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,vs=new WeakMap,Jn=new WeakMap,eo=new WeakMap,i_);const sg=Symbol("QueryClient"),ek=()=>{const e=f_(sg);if(!e)throw new Error("No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?");return e},tk=e=>{im(sg,e)},ik=Symbol("isRestoring"),rk=()=>{try{return f_(ik)??{current:!1}}catch{return{current:!1}}};function sk(){return rk()}function nk(e){return ek()}var ok=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],ak=["difference","intersection","symmetricDifference","union"],Hf=!1,to,ir,ps,Cl,uo,ng,og;const kl=class kl extends Set{constructor(i){super();ee(this,uo);ee(this,to,new Map);ee(this,ir,W(0));ee(this,ps,W(0));ee(this,Cl,Vr||-1);if(i){for(var r of i)super.add(r);v(this,ps).v=super.size}Hf||xe(this,uo,og).call(this)}has(i){var r=super.has(i),s=v(this,to),n=s.get(i);if(n===void 0){if(!r)return l(v(this,ir)),!1;n=xe(this,uo,ng).call(this,!0),s.set(i,n)}return l(n),r}add(i){return super.has(i)||(super.add(i),m(v(this,ps),super.size),Cs(v(this,ir))),this}delete(i){var r=super.delete(i),s=v(this,to),n=s.get(i);return n!==void 0&&(s.delete(i),m(n,!1)),r&&(m(v(this,ps),super.size),Cs(v(this,ir))),r}clear(){if(super.size!==0){super.clear();var i=v(this,to);for(var r of i.values())m(r,!1);i.clear(),m(v(this,ps),0),Cs(v(this,ir))}}keys(){return this.values()}values(){return l(v(this,ir)),super.values()}entries(){return l(v(this,ir)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return l(v(this,ps))}};to=new WeakMap,ir=new WeakMap,ps=new WeakMap,Cl=new WeakMap,uo=new WeakSet,ng=function(i){return Vr===v(this,Cl)?W(i):Ds(i)},og=function(){Hf=!0;var i=kl.prototype,r=Set.prototype;for(const s of ok)i[s]=function(...n){return l(v(this,ir)),r[s].apply(this,n)};for(const s of ak)i[s]=function(...n){l(v(this,ir));var o=r[s].apply(this,n);return new kl(o)}};let tu=kl;function lk(e){const t=Array.isArray(e)?[]:{},i=new tu,r=new Proxy(t,{set(n,o,a,c){if(i.delete(o),o in n)return Reflect.set(n,o,a,c);let h=W(a);return Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:()=>l(h)&&ck(l(h))?l(h)():l(h),set:d=>{m(h,d)}}),!0},has:(n,o)=>i.has(o)?!1:o in n,ownKeys(n){return Reflect.ownKeys(n).filter(o=>!i.has(o))},getOwnPropertyDescriptor(n,o){if(!i.has(o))return Reflect.getOwnPropertyDescriptor(n,o)},deleteProperty(n,o){return o in n?(n[o]=void 0,i.add(o),Array.isArray(n)&&n.length--,!0):!1}});function s(n){const o=Object.keys(r),a=Object.keys(n),c=o.filter(h=>!a.includes(h));for(const h of c)delete r[h];for(const h of a)r[h]=hk(()=>n[h])}return s(e),[r,s]}const ag=Symbol("LazyValue");function hk(e){return e[ag]=!0,e}function ck(e){return!!e[ag]}function uk(e,t){switch(e){case"post":Ei(t);break;case"pre":Am(t);break}}const bh=(e,t,i)=>{let r=!1,s=Array.isArray(e)?[]:void 0;uk(t,()=>{const n=Array.isArray(e)?e.map(a=>a()):e();if(!r){r=!0,s=n;return}const o=Qr(()=>i(n,s));return s=n,o})};function dk(e,t,i){const r=me(()=>nk()),s=sk(),n=me(()=>{const d=l(r).defaultQueryOptions(e());return d._optimisticResults=s.current?"isRestoring":"optimistic",d});let o=W(Xe(new t(l(r),l(n))));bh(()=>l(r),"pre",()=>{m(o,new t(l(r),l(n)),!0)});function a(){const d=l(o).getOptimisticResult(l(n));return l(n).notifyOnChangeProps?d:l(o).trackResult(d)}const[c,h]=lk(a());return Ei(()=>{const d=s.current?()=>{}:l(o).subscribe(()=>h(a()));return l(o).updateResult(),d}),bh(()=>l(n),"pre",()=>{l(o).setOptions(l(n))}),bh(()=>[l(n),l(o)],"pre",()=>{h(a())}),c}function yl(e,t){return dk(e,YC)}function fk(e,t){dt(t,!0);const i=Pr(t,"client",19,()=>new rg);vo(()=>{i().mount()}),tk(i()),hb(()=>{i().unmount()});var r=Gr(),s=Ct(r);$m(s,()=>t.children),N(e,r),ft()}var _k=z('<div class="branch-error svelte-1ogsozk"> </div>'),vk=z('<div class="branch-loading svelte-1ogsozk">Loading...</div>'),pk=z('<div class="branch-empty svelte-1ogsozk">No branches match</div>'),gk=z('<span class="branch-check svelte-1ogsozk">✓</span>'),mk=z('<span class="branch-check branch-check--empty svelte-1ogsozk"></span>'),bk=z('<span class="branch-spinner svelte-1ogsozk">…</span>'),yk=z('<li role="option"><!> <span class="branch-option-name svelte-1ogsozk"> </span> <!></li>'),Sk=z('<ul class="branch-list svelte-1ogsozk"></ul>'),wk=z('<div class="branch-dropdown svelte-1ogsozk" role="listbox" tabindex="-1" aria-label="Branches"><div class="branch-filter-wrap svelte-1ogsozk"><input type="text" class="branch-filter svelte-1ogsozk" placeholder="Filter branches..." aria-label="Filter branches"/></div> <!> <!></div>'),Ck=z('<div class="branch-switcher svelte-1ogsozk"><button class="branch-trigger svelte-1ogsozk" aria-label="Switch branch" aria-haspopup="listbox"><span class="branch-icon svelte-1ogsozk">⑂</span> <span class="branch-name svelte-1ogsozk"> </span> <svg class="branch-caret svelte-1ogsozk" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5" stroke-linecap="round"></path></svg></button> <!></div>');function kk(e,t){dt(t,!0);let i=W(!1),r=W(""),s=W(null),n=W(null),o=W(null),a=W(null);const c=yl(()=>({queryKey:["branches",t.workspacePath],queryFn:()=>rv(t.workspacePath),staleTime:3e4,enabled:l(i)}));let h=me(()=>{const E=c.data??[];if(!l(r).trim())return E;const A=l(r).toLowerCase();return E.filter(P=>P.toLowerCase().includes(A))});function d(){m(i,!0),m(r,""),m(a,null),requestAnimationFrame(()=>{var E;return(E=l(n))==null?void 0:E.focus()})}function u(){m(i,!1),m(r,"")}async function f(E){if(E===t.currentBranch){u();return}m(o,E,!0),m(a,null);try{const A=await wb(t.workspacePath,E);A.success?(u(),t.onSwitch(E)):m(a,A.error??"Failed to switch branch",!0)}catch{m(a,"Failed to switch branch")}finally{m(o,null)}}function _(E){l(i)&&l(s)&&document.contains(E.target)&&!l(s).contains(E.target)&&u()}function p(E){E.key==="Escape"&&l(i)&&(u(),E.stopPropagation())}var b=Ck();xr("click",Ja,_);var g=w(b),y=T(w(g),2),O=w(y),R=T(g,2);{var S=E=>{var A=wk(),P=w(A),B=w(P);Ze(B,I=>m(n,I),()=>l(n));var U=T(P,2);{var $=I=>{var H=_k(),k=w(H);he(()=>ne(k,l(a))),N(I,H)};ie(U,I=>{l(a)&&I($)})}var q=T(U,2);{var F=I=>{var H=vk();N(I,H)},L=I=>{var H=pk();N(I,H)},D=I=>{var H=Sk();si(H,20,()=>l(h),k=>k,(k,x)=>{var Q=yk();let Z;var pe=w(Q);{var be=Se=>{var de=gk();N(Se,de)},ce=Se=>{var de=mk();N(Se,de)};ie(pe,Se=>{x===t.currentBranch?Se(be):Se(ce,!1)})}var se=T(pe,2),De=w(se),Te=T(se,2);{var _e=Se=>{var de=bk();N(Se,de)};ie(Te,Se=>{l(o)===x&&Se(_e)})}he(()=>{Z=it(Q,1,"branch-option svelte-1ogsozk",null,Z,{"branch-current":x===t.currentBranch,"branch-switching":l(o)===x}),Ie(Q,"aria-selected",x===t.currentBranch),ne(De,x)}),G("mousedown",Q,()=>f(x)),N(k,Q)}),N(I,H)};ie(q,I=>{c.isLoading?I(F):l(h).length===0?I(L,1):I(D,!1)})}G("keydown",A,p),G("keydown",B,p),rr(B,()=>l(r),I=>m(r,I)),N(E,A)};ie(R,E=>{l(i)&&E(S)})}Ze(b,E=>m(s,E),()=>l(s)),he(()=>{Ie(g,"aria-expanded",l(i)),ne(O,t.currentBranch)}),G("click",g,d),N(e,b),ft()}_t(["click","keydown","mousedown"]);var xk=z('<span class="target-branch svelte-1shtc4l" aria-label="target branch"><span class="target-sep svelte-1shtc4l">›</span> <span class="target-name svelte-1shtc4l"> </span></span>'),Ek=z('<div class="bar-middle svelte-1shtc4l" aria-label="pull request"><a class="pr-link svelte-1shtc4l" target="_blank" rel="noopener noreferrer" data-track="pr-top-bar.open-pr"> <svg class="pr-ext-icon svelte-1shtc4l" width="10" height="10" viewBox="0 0 10 10" aria-hidden="true"><path d="M1 9L9 1M9 1H4M9 1V6" stroke="currentColor" fill="none" stroke-width="1.5" stroke-linecap="round"></path></svg></a></div> <span class="diff-stats svelte-1shtc4l"><span class="diff-add svelte-1shtc4l"> </span> <span class="diff-del svelte-1shtc4l"> </span></span>',1),Dk=z('<span class="bar-loading svelte-1shtc4l">…</span>'),Tk=z('<button class="action-btn action-btn--secondary svelte-1shtc4l" data-track="pr-top-bar.secondary-action"> </button>'),Rk=z('<button data-track="pr-top-bar.primary-action"> </button>'),Pk=z("<!> <!>",1),Ak=z('<div><div class="bar-left svelte-1shtc4l"><!> <!></div> <!> <div class="bar-right svelte-1shtc4l"><!></div></div>');function Mk(e,t){dt(t,!0);let i=W(Xe(t.branchName));Ei(()=>{m(i,t.branchName,!0)}),Ei(()=>{!t.branchName&&t.workspacePath&&Sb(t.workspacePath).then(q=>{q&&m(i,q,!0)})});const r=yl(()=>({queryKey:["pr",t.workspacePath,l(i)],queryFn:()=>yb(t.workspacePath,l(i)),staleTime:6e4,refetchOnWindowFocus:!0})),s=yl(()=>{var q;return{queryKey:["ci-status",t.workspacePath,l(i)],queryFn:()=>bb(t.workspacePath,l(i)),staleTime:3e4,refetchOnWindowFocus:!0,enabled:((q=r.data)==null?void 0:q.state)==="OPEN"}});Ei(()=>{t.sessionId&&(r.refetch(),s.refetch())});let n=me(()=>r.data??null),o=me(()=>s.data??null),a=me(()=>{var q,F,L,D,I,H;return{commitsAhead:l(n)?1:0,prState:l(n)?l(n).isDraft?"DRAFT":l(n).state:null,ciPassing:((q=l(o))==null?void 0:q.passing)??0,ciFailing:((F=l(o))==null?void 0:F.failing)??0,ciPending:((L=l(o))==null?void 0:L.pending)??0,ciTotal:((D=l(o))==null?void 0:D.total)??0,mergeable:((I=l(n))==null?void 0:I.mergeable)??null,unresolvedCommentCount:((H=l(n))==null?void 0:H.unresolvedCommentCount)??0}}),c=me(()=>ku(l(a))),h=me(()=>fy(l(c),l(a))),d=me(()=>Nv(l(c).color)),u=me(()=>Fv(l(c).color)),f=me(()=>l(c).type!=="none");function _(q=l(c)){var D,I,H,k;const F={branchName:l(i),baseBranch:((D=l(n))==null?void 0:D.baseRefName)??"",prNumber:((I=l(n))==null?void 0:I.number)??0,unresolvedCommentCount:((H=l(n))==null?void 0:H.unresolvedCommentCount)??0},L=Bv(q,F);L!==null?t.sessionId&&Cr(L+"\r"):(k=t.onArchive)==null||k.call(t)}function p(q){m(i,q,!0)}var b=Ak();let g;var y=w(b),O=w(y);kk(O,{get workspacePath(){return t.workspacePath},get currentBranch(){return l(i)},onSwitch:p});var R=T(O,2);{var S=q=>{var F=xk(),L=T(w(F),2),D=w(L);he(()=>ne(D,l(n).baseRefName)),N(q,F)};ie(R,q=>{var F;(F=l(n))!=null&&F.baseRefName&&q(S)})}var E=T(y,2);{var A=q=>{var F=Ek(),L=Ct(F),D=w(L),I=w(D),H=T(L,2),k=w(H),x=w(k),Q=T(k,2),Z=w(Q);he(()=>{Ie(D,"href",l(n).url),Ie(D,"aria-label",`PR #${l(n).number??""}: ${l(n).title??""}`),ne(I,`PR #${l(n).number??""} `),ne(x,`+${l(n).additions??""}`),ne(Z,`-${l(n).deletions??""}`)}),N(q,F)};ie(E,q=>{l(n)&&q(A)})}var P=T(E,2),B=w(P);{var U=q=>{var F=Dk();N(q,F)},$=q=>{var F=Pk(),L=Ct(F);{var D=k=>{var x=Tk(),Q=w(x);he(()=>{Ie(x,"aria-label",l(h).label),ne(Q,l(h).label)}),G("click",x,()=>_(l(h))),N(k,x)};ie(L,k=>{l(h)&&k(D)})}var I=T(L,2);{var H=k=>{var x=Rk();let Q,Z;var pe=w(x);he(()=>{Q=it(x,1,"action-btn svelte-1shtc4l",null,Q,{"action-btn--dark-text":l(u),"action-btn--disabled":l(c).type==="checks-running"}),x.disabled=l(c).type==="checks-running",Ie(x,"aria-label",l(c).label),Z=_o(x,"",Z,{"--action-color":l(d)}),ne(pe,l(c).label)}),G("click",x,()=>_()),N(k,x)};ie(I,k=>{l(f)&&k(H)})}N(q,F)};ie(B,q=>{r.isLoading?q(U):q($,!1)})}he(()=>{var q,F;return g=it(b,1,"pr-top-bar svelte-1shtc4l",null,g,{"bar-merged":((q=l(n))==null?void 0:q.state)==="MERGED","bar-conflicts":((F=l(n))==null?void 0:F.mergeable)==="CONFLICTING"})}),N(e,b),ft()}_t(["click"]);var Ok=z('<button role="tab" data-track="session-tab.select"><span class="tab-icon svelte-3dfyyn" aria-hidden="true"> </span> <span class="tab-name svelte-3dfyyn"> </span> <span class="tab-close svelte-3dfyyn" role="button" data-track="session-tab.close">×</span></button>'),Lk=z('<div class="new-menu svelte-3dfyyn" role="menu" tabindex="-1"><button class="new-menu-item svelte-3dfyyn" role="menuitem" data-track="session-tab.new-agent"><span class="new-menu-icon svelte-3dfyyn">🤖</span> New Agent</button> <button class="new-menu-item svelte-3dfyyn" role="menuitem" data-track="session-tab.new-terminal"><span class="new-menu-icon svelte-3dfyyn">🖥</span> New Terminal</button> <div class="new-menu-divider svelte-3dfyyn"></div> <button class="new-menu-item svelte-3dfyyn" role="menuitem" data-track="session-tab.customize"><span class="new-menu-icon svelte-3dfyyn">⚙</span> Customize...</button></div>'),Ik=z('<div class="session-tab-bar svelte-3dfyyn" role="tablist" aria-label="Sessions"><div class="tabs-scroll svelte-3dfyyn"></div> <div class="new-btn-wrap svelte-3dfyyn"><button class="tab-new svelte-3dfyyn" aria-label="New session" aria-haspopup="menu" data-track="session-tab.new-menu">+</button> <!></div></div>');function Bk(e,t){dt(t,!0);let i=W(!1),r=W(null),s=W(Xe(new Map)),n=W(0),o=W(0);Ei(()=>{let P=new Map(l(s)),B=!1;for(const U of t.sessions)P.has(U.id)||(U.type==="terminal"?(m(o,l(o)+1),P.set(U.id,`Terminal ${l(o)}`)):(m(n,l(n)+1),P.set(U.id,`Agent ${l(n)}`)),B=!0);B&&m(s,P,!0)});function a(P){return l(s).get(P)??P}function c(P){return P.type==="terminal"?"🖥":"🤖"}function h(P,B){P.stopPropagation(),t.onCloseSession(B)}function d(P,B){(P.key==="Enter"||P.key===" ")&&(P.stopPropagation(),t.onCloseSession(B))}function u(){m(i,!l(i))}function f(){m(i,!1),t.onNewAgent()}function _(){m(i,!1),t.onNewTerminal()}function p(){m(i,!1),t.onCustomize()}function b(P){var B;l(i)&&l(r)&&document.contains(P.target)&&!((B=l(r).closest(".new-btn-wrap"))!=null&&B.contains(P.target))&&m(i,!1)}function g(P){var B;P.key==="Escape"&&l(i)&&(m(i,!1),(B=l(r))==null||B.focus())}var y=Ik();xr("click",Ja,b);var O=w(y);si(O,21,()=>t.sessions,P=>P.id,(P,B)=>{const U=me(()=>l(B).id===t.activeSessionId);var $=Ok();let q;var F=w($),L=w(F),D=T(F,2),I=w(D),H=T(D,2);he((k,x,Q,Z)=>{q=it($,1,"tab svelte-3dfyyn",null,q,{"tab--active":l(U)}),Ie($,"aria-selected",l(U)),Ie($,"aria-label",k),Ie($,"tabindex",l(U)?0:-1),ne(L,x),ne(I,Q),Ie(H,"aria-label",`Close ${Z??""}`)},[()=>a(l(B).id),()=>c(l(B)),()=>a(l(B).id),()=>a(l(B).id)]),G("click",$,()=>t.onSelectSession(l(B).id)),G("click",H,k=>h(k,l(B).id)),G("keydown",H,k=>d(k,l(B).id)),N(P,$)});var R=T(O,2),S=w(R);Ze(S,P=>m(r,P),()=>l(r));var E=T(S,2);{var A=P=>{var B=Lk(),U=w(B),$=T(U,2),q=T($,4);G("keydown",B,g),G("click",U,f),G("click",$,_),G("click",q,p),N(P,B)};ie(E,P=>{l(i)&&P(A)})}he(()=>Ie(S,"aria-expanded",l(i))),G("click",S,u),G("keydown",S,g),N(e,y),ft()}_t(["click","keydown"]);var Nk=z('<div class="non-git-notice svelte-bvvs2r"><span class="non-git-msg svelte-bvvs2r">Not a git repository</span></div>'),Fk=z('<div class="pr-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-title svelte-bvvs2r"></div> <div class="skeleton-line skeleton-meta svelte-bvvs2r"></div></div>'),Wk=z('<div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>'),Hk=z('<div class="section-message svelte-bvvs2r">Could not load pull requests</div>'),zk=z('<div class="section-message info svelte-bvvs2r">Install GitHub CLI for PR tracking — <a href="https://cli.github.com" target="_blank" rel="noopener noreferrer" class="svelte-bvvs2r">cli.github.com</a></div>'),Uk=z('<div class="section-message svelte-bvvs2r">No open pull requests</div>'),Kk=z('<input class="pr-search svelte-bvvs2r" type="text" placeholder="Filter PRs by title, number, or branch..."/>'),qk=z('<button class="pr-action-pill pr-conflict-pill svelte-bvvs2r" title="Open worktree and fix merge conflicts">Fix Conflicts</button>'),jk=z('<a class="pr-action-pill pr-merge-pill svelte-bvvs2r" target="_blank" rel="noopener noreferrer" title="Ready to merge on GitHub">Merge</a>'),Yk=z("<button> </button>"),Vk=z('<div class="pr-row svelte-bvvs2r"><div class="pr-row-left svelte-bvvs2r"><div class="pr-row-title-line svelte-bvvs2r"><span></span> <a class="pr-title-link svelte-bvvs2r" target="_blank" rel="noopener noreferrer"> </a></div> <div class="pr-row-meta svelte-bvvs2r"><span class="pr-num svelte-bvvs2r"> </span> <span class="pr-sep svelte-bvvs2r">·</span> <span class="pr-role svelte-bvvs2r"> </span> <span class="pr-sep svelte-bvvs2r">·</span> <span class="pr-time svelte-bvvs2r"> </span></div></div> <div class="pr-row-actions svelte-bvvs2r"><button class="pr-session-btn svelte-bvvs2r" title="Open session on this branch">+</button> <!> <!> <!></div></div>'),Gk=z('<!> <div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>',1),Xk=z('<div class="activity-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-activity svelte-bvvs2r"></div></div>'),$k=z('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),Qk=z('<div class="section-message svelte-bvvs2r">No recent commits (24h)</div>'),Zk=z('<span class="commit-branch svelte-bvvs2r"> </span>'),Jk=z('<div class="activity-row svelte-bvvs2r"><span class="commit-hash svelte-bvvs2r"> </span> <span class="commit-msg svelte-bvvs2r"> </span> <!> <span class="commit-time svelte-bvvs2r"> </span></div>'),ex=z('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),tx=z('<section class="dashboard-section dashboard-section--scroll svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">OPEN PULL REQUESTS</div> <!></section> <section class="dashboard-section dashboard-section--scroll svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">RECENT ACTIVITY</div> <!></section>',1),ix=z('<button class="cta-btn svelte-bvvs2r"> </button>'),rx=z('<div class="repo-dashboard svelte-bvvs2r"><!> <div class="cta-row svelte-bvvs2r"><button class="cta-btn svelte-bvvs2r">+ Start Session</button> <!></div></div>');function sx(e,t){dt(t,!0);let i=Pr(t,"creatingWorktree",3,!1);const r=yl(()=>({queryKey:["dashboard",t.workspacePath],queryFn:()=>mb(t.workspacePath),staleTime:6e4,refetchOnWindowFocus:!0}));let s=me(()=>r.data),n=me(()=>r.isLoading),o=me(()=>r.isError);function a(A){return A.state!=="OPEN"?"dot dot-muted":A.reviewDecision==="CHANGES_REQUESTED"?"dot dot-error":"dot dot-success"}function c(A){const P=A.state==="OPEN"?"OPEN":A.state==="MERGED"?"MERGED":"CLOSED";return ku({commitsAhead:1,prState:P,ciFailing:0,ciPending:0,ciTotal:0,mergeable:A.mergeable??null,unresolvedCommentCount:0})}function h(A){return A.role==="author"?"by you":"review requested"}function d(A){return!A.branches||A.branches.length===0?"":"("+A.branches.join(", ")+")"}let u=W(""),f=me(()=>l(s)?l(s).prs.length>5:!1),_=me(()=>()=>{if(!l(s))return[];const A=l(u).toLowerCase().trim();return A?l(s).prs.filter(P=>P.title.toLowerCase().includes(A)||String(P.number).includes(A)||P.headRefName.toLowerCase().includes(A)):l(s).prs});var p=rx(),b=w(p);{var g=A=>{var P=Nk();N(A,P)},y=A=>{var P=tx(),B=Ct(P),U=T(w(B),2);{var $=Z=>{var pe=Wk(),be=w(pe);si(be,20,()=>[1,2],Yo,(ce,se)=>{var De=Fk();N(ce,De)}),N(Z,pe)},q=Z=>{var pe=Hk();N(Z,pe)},F=Z=>{var pe=zk();N(Z,pe)},L=Z=>{var pe=Uk();N(Z,pe)},D=Z=>{var pe=Gk(),be=Ct(pe);{var ce=Te=>{var _e=Kk();rr(_e,()=>l(u),Se=>m(u,Se)),N(Te,_e)};ie(be,Te=>{l(f)&&Te(ce)})}var se=T(be,2),De=w(se);si(De,21,()=>l(_)(),Te=>Te.number,(Te,_e)=>{const Se=me(()=>c(l(_e))),de=me(()=>Nv(l(Se).color)),Me=me(()=>Fv(l(Se).color));var Ne=Vk(),je=w(Ne),Pe=w(je),et=w(Pe),X=T(et,2),ve=w(X),Fe=T(Pe,2),Ke=w(Fe),Be=w(Ke),C=T(Ke,4),J=w(C),fe=T(C,4),ye=w(fe),Ce=T(je,2),M=w(Ce),Y=T(M,2);{var ge=Re=>{var oe=qk();G("click",oe,()=>t.onFixConflicts(l(_e))),N(Re,oe)};ie(Y,Re=>{l(_e).mergeable==="CONFLICTING"&&Re(ge)})}var le=T(Y,2);{var re=Re=>{var oe=jk();he(()=>Ie(oe,"href",l(_e).url)),N(Re,oe)};ie(le,Re=>{l(_e).mergeable==="MERGEABLE"&&l(_e).state==="OPEN"&&Re(re)})}var ke=T(le,2);{var we=Re=>{var oe=Yk();let Ee,Ge;var qt=w(oe);he(()=>{Ee=it(oe,1,"pr-action-pill svelte-bvvs2r",null,Ee,{"dark-text":l(Me)}),Ie(oe,"title",l(Se).label),Ge=_o(oe,"",Ge,{"--pill-color":l(de)}),ne(qt,l(Se).label)}),G("click",oe,()=>t.onPrAction(l(_e))),N(Re,oe)};ie(ke,Re=>{l(Se).type!=="none"&&l(Se).label&&Re(we)})}he((Re,oe,Ee)=>{it(et,1,Re,"svelte-bvvs2r"),Ie(X,"href",l(_e).url),ne(ve,l(_e).title),ne(Be,`#${l(_e).number??""}`),ne(J,oe),ne(ye,Ee)},[()=>ev(a(l(_e))),()=>h(l(_e)),()=>dy(l(_e).updatedAt)]),G("click",M,()=>t.onOpenPrSession(l(_e))),N(Te,Ne)}),N(Z,pe)};ie(U,Z=>{l(n)?Z($):l(o)?Z(q,1):l(s)&&!l(s).hasGhCli?Z(F,2):l(s)&&l(s).prs.length===0?Z(L,3):l(s)&&Z(D,4)})}var I=T(B,2),H=T(w(I),2);{var k=Z=>{var pe=$k(),be=w(pe);si(be,20,()=>[1,2,3],Yo,(ce,se)=>{var De=Xk();N(ce,De)}),N(Z,pe)},x=Z=>{var pe=Qk();N(Z,pe)},Q=Z=>{var pe=ex(),be=w(pe);si(be,21,()=>l(s).activity,ce=>ce.hash,(ce,se)=>{var De=Jk(),Te=w(De),_e=w(Te),Se=T(Te,2),de=w(Se),Me=T(Se,2);{var Ne=et=>{var X=Zk(),ve=w(X);he(Fe=>ne(ve,Fe),[()=>d(l(se))]),N(et,X)};ie(Me,et=>{l(se).branches.length>0&&et(Ne)})}var je=T(Me,2),Pe=w(je);he(()=>{ne(_e,l(se).shortHash),ne(de,l(se).message),ne(Pe,l(se).timeAgo)}),N(ce,De)}),N(Z,pe)};ie(H,Z=>{l(n)?Z(k):l(s)&&l(s).activity.length===0?Z(x,1):l(s)&&Z(Q,2)})}N(A,P)};ie(b,A=>{l(s)&&!l(s).isGitRepo?A(g):A(y,!1)})}var O=T(b,2),R=w(O),S=T(R,2);{var E=A=>{var P=ix(),B=w(P);he(()=>{P.disabled=i(),ne(B,i()?"Creating...":"+ New Worktree")}),G("click",P,function(...U){var $;($=t.onNewWorktree)==null||$.apply(this,U)}),N(A,P)};ie(S,A=>{(!l(s)||l(s).isGitRepo)&&A(E)})}G("click",R,function(...A){var P;(P=t.onNewSession)==null||P.apply(this,A)}),N(e,p),ft()}_t(["click"]);var nx=z('<div class="empty-icon svelte-1luen49" aria-hidden="true"> </div>'),ox=z('<p class="empty-description svelte-1luen49"> </p>'),ax=z('<button class="empty-action svelte-1luen49"> </button>'),lx=z('<div class="empty-state svelte-1luen49"><!> <div class="empty-heading svelte-1luen49"> </div> <!> <!></div>');function hx(e,t){var i=lx(),r=w(i);{var s=u=>{var f=nx(),_=w(f);he(()=>ne(_,t.icon)),N(u,f)};ie(r,u=>{t.icon&&u(s)})}var n=T(r,2),o=w(n),a=T(n,2);{var c=u=>{var f=ox(),_=w(f);he(()=>ne(_,t.description)),N(u,f)};ie(a,u=>{t.description&&u(c)})}var h=T(a,2);{var d=u=>{var f=ax(),_=w(f);he(()=>ne(_,t.actionLabel)),G("click",f,function(...p){var b;(b=t.onAction)==null||b.apply(this,p)}),N(u,f)};ie(h,u=>{t.actionLabel&&t.onAction&&u(d)})}he(()=>ne(o,t.heading)),N(e,i)}_t(["click"]);var cx=z("<button><!></button>"),ux=z("<button><!></button>"),dx=z('<div class="toolbar svelte-k7we1m" role="toolbar"><div class="toolbar-grid svelte-k7we1m"><!></div></div>');function fx(e,t){dt(t,!0),Pr(t,"useTmux",3,!1);let i=Pr(t,"inCopyMode",3,!1);const r=[{html:"Tab",key:" ",label:"Tab"},{html:"&#8679;Tab",key:"\x1B[Z",label:"Shift+Tab"},{html:"&#8593;",key:"\x1B[A",label:"Up arrow",extraClass:"tb-arrow"},{html:"Esc",key:"\x1B",label:"Escape"},{html:"&#128247;",id:"upload-image-btn",label:"Upload image"},{html:"^V",id:"paste-btn",label:"Paste from clipboard"},{html:"^C",key:"",label:"Ctrl+C"},{html:"&#8592;",key:"\x1B[D",label:"Left arrow",extraClass:"tb-arrow"},{html:"&#8595;",key:"\x1B[B",label:"Down arrow",extraClass:"tb-arrow"},{html:"&#8594;",key:"\x1B[C",label:"Right arrow",extraClass:"tb-arrow"},{html:"&#8679;&#9166;",key:"\x1B[13;2u",label:"Shift+Enter (newline)",extraClass:"tb-newline"},{html:"&#9166;",key:"\r",label:"Enter",extraClass:"tb-enter"}],s=[{html:"Sel",key:" ",label:"Start selection"},{html:"w",key:"w",label:"Word forward"},{html:"b",key:"b",label:"Word backward"},{html:"&#8592;",key:"h",label:"Left",extraClass:"tb-arrow"},{html:"&#8595;",key:"j",label:"Down",extraClass:"tb-arrow"},{html:"&#8593;",key:"k",label:"Up",extraClass:"tb-arrow"},{html:"&#8594;",key:"l",label:"Right",extraClass:"tb-arrow"},{html:"$",key:"$",label:"End of line"},{html:"0",key:"0",label:"Start of line"},{html:"PgUp",key:"\x1B[5~",label:"Page up"},{html:"Copy",key:"\r",label:"Copy and exit",extraClass:"tb-enter",exitsCopyMode:!0},{html:"Exit",key:"q",label:"Cancel",exitsCopyMode:!0}];function n(u){var f;if(u.id==="upload-image-btn"){t.onUploadImage(),Nt&&t.onRefocusMobileInput();return}if(u.id==="paste-btn"){(f=navigator.clipboard)!=null&&f.readText?navigator.clipboard.readText().then(_=>{_&&t.onSendKey(_)}).catch(()=>{t.onUploadImage()}):t.onUploadImage(),Nt&&t.onRefocusMobileInput();return}u.key&&((u.key==="\r"||u.key==="\x1B[13;2u")&&t.onFlushComposedText(),t.onSendKey(u.key),(u.key==="\r"||u.key==="\x1B[13;2u")&&t.onClearInput(),Nt&&t.onRefocusMobileInput())}function o(u){var f;t.onSendKey(u.key),u.exitsCopyMode&&((f=t.onExitCopyMode)==null||f.call(t)),Nt&&t.onRefocusMobileInput()}function a(u){u.preventDefault();const f=u.target.closest("button");if(!f)return;if(i()){const p=s.find(b=>f.dataset.key===b.key);p&&o(p);return}const _=r.find(p=>p.id===f.id||p.key&&f.dataset.key===p.key);_&&n(_)}var c=Gr(),h=Ct(c);{var d=u=>{var f=dx(),_=w(f),p=w(_);{var b=y=>{var O=Gr(),R=Ct(O);si(R,17,()=>s,S=>S.label,(S,E)=>{var A=cx(),P=w(A);ad(P,()=>l(E).html),he(B=>{it(A,1,`tb-btn ${l(E).extraClass??""??""}`,"svelte-k7we1m"),Ie(A,"data-key",l(E).key),Ie(A,"data-track",`toolbar.${B??""}`),Ie(A,"aria-label",l(E).label)},[()=>l(E).label.toLowerCase().replace(/[^a-z0-9]/g,"-")]),N(S,A)}),N(y,O)},g=y=>{var O=Gr(),R=Ct(O);si(R,17,()=>r,S=>S.label,(S,E)=>{var A=ux(),P=w(A);ad(P,()=>l(E).html),he(B=>{it(A,1,`tb-btn ${l(E).extraClass??""??""}`,"svelte-k7we1m"),Ie(A,"id",l(E).id),Ie(A,"data-key",l(E).key),Ie(A,"data-track",`toolbar.${B??""}`),Ie(A,"aria-label",l(E).label)},[()=>l(E).label.toLowerCase().replace(/[^a-z0-9]/g,"-")]),N(S,A)}),N(y,O)};ie(p,y=>{i()?y(b):y(g,!1)})}G("mousedown",f,a),N(u,f)};ie(h,u=>{Nt&&u(d)})}N(e,c),ft()}_t(["mousedown"]);var _x=z('<div><button class="icon-btn svelte-wp0i5g" aria-label="Open sessions menu">&#9776;</button> <span class="mobile-title svelte-wp0i5g"> </span></div>');function vx(e,t){let i=Pr(t,"hidden",3,!1);var r=_x();let s;var n=w(r),o=T(n,2),a=w(o);he(()=>{s=it(r,1,"mobile-header svelte-wp0i5g",null,s,{hidden:i()}),ne(a,t.title)}),G("click",n,function(...c){var h;(h=t.onMenuClick)==null||h.apply(this,c)}),N(e,r)}_t(["click"]);var px=z('<div class="update-toast-actions svelte-1trivgv"><button class="update-toast-btn svelte-1trivgv"> </button> <button class="update-toast-dismiss svelte-1trivgv" aria-label="Dismiss">&times;</button></div>'),gx=z('<div class="update-toast svelte-1trivgv"><div class="update-toast-content svelte-1trivgv"><span class="update-toast-text svelte-1trivgv"> </span> <!></div></div>');function mx(e,t){dt(t,!0);let i=W(!1),r=W(""),s=W("Update Now"),n=W(!1),o=W(!0);vo(async()=>{try{const f=await nv();f.updateAvailable&&(m(r,`Update available: v${f.current} → v${f.latest}`),m(s,"Update Now"),m(n,!1),m(o,!0),m(i,!0))}catch{}});async function a(){m(n,!0),m(s,"Updating…");try{(await ov()).restarting?(m(r,"Updated! Restarting server…"),m(o,!1),setTimeout(()=>{location.reload()},5e3)):(m(r,"Updated! Please restart the server manually."),m(o,!1))}catch{m(r,"Update failed. Please try again."),m(n,!1),m(s,"Retry"),m(o,!0)}}function c(){m(i,!1)}var h=Gr(),d=Ct(h);{var u=f=>{var _=gx(),p=w(_),b=w(p),g=w(b),y=T(b,2);{var O=R=>{var S=px(),E=w(S),A=w(E),P=T(E,2);he(()=>{E.disabled=l(n),ne(A,l(s))}),G("click",E,a),G("click",P,c),N(R,S)};ie(y,R=>{l(o)&&R(O)})}he(()=>ne(g,l(r))),N(f,_)};ie(d,f=>{l(i)&&f(u)})}N(e,h),ft()}_t(["click"]);var bx=z('<button class="image-toast-insert svelte-1y8sviv">Insert</button>'),yx=z('<div class="image-toast svelte-1y8sviv"><div class="image-toast-content svelte-1y8sviv"><span class="image-toast-text svelte-1y8sviv"> </span> <div class="image-toast-actions svelte-1y8sviv"><!> <button class="image-toast-dismiss svelte-1y8sviv" aria-label="Dismiss">&times;</button></div></div></div>');function Sx(e,t){dt(t,!0);let i=W(!1),r=W(""),s=W(!1),n=W(null),o=null;function a(g,y,O){o&&(clearTimeout(o),o=null),m(r,g,!0),m(s,y,!0),m(n,O??null,!0),m(i,!0)}function c(){m(i,!1),m(n,null),o&&(clearTimeout(o),o=null)}function h(g){o&&clearTimeout(o),o=setTimeout(()=>{l(n)||c()},g)}function d(){l(n)&&Cr(l(n)),c()}function u(){c()}var f={show:a,hide:c,autoDismiss:h},_=Gr(),p=Ct(_);{var b=g=>{var y=yx(),O=w(y),R=w(O),S=w(R),E=T(R,2),A=w(E);{var P=U=>{var $=bx();G("click",$,d),N(U,$)};ie(A,U=>{l(s)&&U(P)})}var B=T(A,2);he(()=>ne(S,l(r))),G("click",B,u),N(g,y)};ie(p,g=>{l(i)&&g(b)})}return N(e,_),ft(f)}_t(["click"]);var wx=z('<span class="dialog-title-repo svelte-8ywkqk"> </span>'),Cx=z('<dialog class="dialog svelte-8ywkqk"><div class="dialog-content svelte-8ywkqk"><h2 class="dialog-title svelte-8ywkqk">New Agent Session <!></h2> <div class="dialog-body svelte-8ywkqk"><div class="dialog-field svelte-8ywkqk"><label class="dialog-label svelte-8ywkqk" for="cs-agent">Coding agent</label> <select id="cs-agent" class="dialog-select svelte-8ywkqk" data-track="dialog.customize-session.agent"><option>Claude</option><option>Codex</option></select></div> <div class="dialog-field dialog-field--inline svelte-8ywkqk"><input id="cs-continue" type="checkbox" class="dialog-checkbox svelte-8ywkqk"/> <label for="cs-continue" class="dialog-label-inline svelte-8ywkqk">Continue existing session</label></div> <div class="dialog-field dialog-field--inline svelte-8ywkqk"><input id="cs-yolo" type="checkbox" class="dialog-checkbox svelte-8ywkqk"/> <label for="cs-yolo" class="dialog-label-inline svelte-8ywkqk">Yolo mode (skip permission checks)</label></div> <div class="dialog-field dialog-field--inline svelte-8ywkqk"><input id="cs-tmux" type="checkbox" class="dialog-checkbox svelte-8ywkqk"/> <label for="cs-tmux" class="dialog-label-inline svelte-8ywkqk">Launch in tmux</label></div> <div class="dialog-field svelte-8ywkqk"><label class="dialog-label svelte-8ywkqk" for="cs-args">Extra args (optional)</label> <input id="cs-args" type="text" class="dialog-input svelte-8ywkqk" placeholder="e.g. --verbose" autocomplete="off"/></div></div> <div class="dialog-footer svelte-8ywkqk"><button class="btn btn-ghost svelte-8ywkqk">Cancel</button> <button class="btn btn-primary svelte-8ywkqk" data-track="dialog.customize-session.create"> </button></div></div></dialog>');function kx(e,t){dt(t,!0);const i=Cu();let r,s=W(""),n=W(""),o=W(""),a=W("claude"),c=W(!1),h=W(!1),d=W(!1),u=W(!1);function f(){m(o,""),m(c,!1),m(h,!1),m(d,!1)}async function _(se){f(),m(s,se.path,!0),m(n,se.name,!0),await Lv(),m(a,i.defaultAgent,!0),m(c,i.defaultYolo,!0),m(h,i.defaultContinue,!0),m(d,i.launchInTmux,!0),r.showModal()}function p(){r.close()}async function b(){var _e,Se;if(!l(s)||l(u))return;m(u,!0);const se=l(o).trim().split(/\s+/).filter(Boolean),{cols:De,rows:Te}=Iv();try{const de=await gu({repoPath:l(s),repoName:l(n)||l(s).split("/").filter(Boolean).pop(),continue:l(h),yolo:l(c),claudeArgs:se.length>0?se:void 0,agent:l(a),useTmux:l(d),cols:De,rows:Te});r.close(),await gt(),de!=null&&de.id&&((_e=t.onSessionCreated)==null||_e.call(t,de.id))}catch(de){if(de instanceof Error&&"sessionId"in de){const Me=de;r.close(),await gt(),Me.sessionId&&((Se=t.onSessionCreated)==null||Se.call(t,Me.sessionId))}}finally{m(u,!1)}}function g(se){se.target===r&&r.close()}var y={open:_,close:p},O=Cx(),R=w(O),S=w(R),E=T(w(S));{var A=se=>{var De=wx(),Te=w(De);he(()=>ne(Te,`— ${l(n)??""}`)),N(se,De)};ie(E,se=>{l(n)&&se(A)})}var P=T(S,2),B=w(P),U=T(w(B),2),$=w(U);$.value=$.__value="claude";var q=T($);q.value=q.__value="codex";var F=T(B,2),L=w(F),D=T(F,2),I=w(D),H=T(D,2),k=w(H),x=T(H,2),Q=T(w(x),2),Z=T(P,2),pe=w(Z),be=T(pe,2),ce=w(be);return Ze(O,se=>r=se,()=>r),he(()=>{pe.disabled=l(u),be.disabled=!l(s)||l(u),ne(ce,l(u)?"Creating...":"Start Session")}),G("click",O,g),el(U,()=>l(a),se=>m(a,se)),sr(L,()=>l(h),se=>m(h,se)),sr(I,()=>l(c),se=>m(c,se)),sr(k,()=>l(d),se=>m(d,se)),rr(Q,()=>l(o),se=>m(o,se)),G("click",pe,()=>r.close()),G("click",be,b),N(e,O),ft(y)}_t(["click"]);var xx=z('<p class="error-msg svelte-fdtoa4"> </p>'),Ex=z('<span class="version-status svelte-fdtoa4">Up to date</span>'),Dx=z('<div class="version-update-row svelte-fdtoa4"><span class="version-update-text svelte-fdtoa4"> </span> <button class="btn btn-primary btn-sm svelte-fdtoa4"> </button></div>'),Tx=z('<button class="btn btn-ghost btn-sm svelte-fdtoa4"> </button>'),Rx=z('<p class="version-status-msg svelte-fdtoa4"> </p>'),Px=z('<dialog class="dialog svelte-fdtoa4"><div class="dialog-content svelte-fdtoa4"><div class="dialog-header svelte-fdtoa4"><h2 class="dialog-title svelte-fdtoa4">Settings</h2> <button class="close-btn svelte-fdtoa4" aria-label="Close settings">&#10005;</button></div> <div class="dialog-body svelte-fdtoa4"><!> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Default Coding Agent</h3> <p class="section-desc svelte-fdtoa4">CLI used when creating new sessions.</p> <select class="agent-select svelte-fdtoa4"><option>Claude</option><option>Codex</option></select></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Global Defaults</h3> <p class="section-desc svelte-fdtoa4">Default options for all workspaces. Override per-workspace in workspace settings.</p> <div class="devtools-row svelte-fdtoa4"><input id="default-continue" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-continue" class="devtools-label svelte-fdtoa4">Continue existing session</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-yolo" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-yolo" class="devtools-label svelte-fdtoa4">YOLO mode (skip permission checks)</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-tmux" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-tmux" class="devtools-label svelte-fdtoa4">Launch in tmux</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-notifications" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-notifications" class="devtools-label svelte-fdtoa4">Enable notifications for new sessions</label></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Developer Tools</h3> <div class="devtools-row svelte-fdtoa4"><input id="devtools-toggle" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="devtools-toggle" class="devtools-label svelte-fdtoa4">Enable mobile debug panel</label></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Analytics</h3> <div class="version-row svelte-fdtoa4"><span class="version-current svelte-fdtoa4"> </span> <button class="btn btn-ghost btn-sm svelte-fdtoa4" data-track="dialog.settings.clear-analytics"> </button></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Version</h3> <div class="version-row svelte-fdtoa4"><span class="version-current svelte-fdtoa4"><!></span> <!></div> <!> <!></section></div> <div class="dialog-footer svelte-fdtoa4"><button class="btn btn-ghost svelte-fdtoa4">Close</button></div></div></dialog>');function Ax(e,t){dt(t,!0);let i,r=W(!1);const s=Cu();let n=W(""),o=W(""),a=W(null),c=W(!1),h=W(!1),d=W(!1),u=W(!1),f=W(""),_=W(null),p=W(!1);async function b(){m(n,""),m(f,""),m(h,!1),m(u,!1),m(r,localStorage.getItem("devtools-enabled")==="true"),await Lv(),i.showModal(),A(),Fb().then(ae=>{m(_,ae.bytes,!0)}).catch(()=>{})}function g(){i.close()}async function y(){const ae=s.defaultAgent;m(n,"");try{await Db(s.defaultAgent)}catch{s.defaultAgent=ae,m(n,"Failed to update default agent.")}}async function O(){const ae=s.defaultContinue;m(n,"");try{await Rb(s.defaultContinue)}catch{s.defaultContinue=ae,m(n,"Failed to update continue default.")}}async function R(){const ae=s.defaultYolo;m(n,"");try{await Ab(s.defaultYolo)}catch{s.defaultYolo=ae,m(n,"Failed to update yolo default.")}}async function S(){const ae=s.launchInTmux;m(n,"");try{await Ob(s.launchInTmux)}catch(Ye){s.launchInTmux=ae,m(n,Ye instanceof Error?Ye.message:"Failed to update tmux setting.",!0)}}async function E(){const ae=s.defaultNotifications;m(n,"");try{await Ib(s.defaultNotifications)}catch{s.defaultNotifications=ae,m(n,"Failed to update notifications default.")}}async function A(){m(d,!0),m(f,"");try{const ae=await nv();m(o,ae.current,!0),m(a,ae.latest,!0),m(c,ae.updateAvailable,!0),m(h,!0)}catch{m(f,"Failed to check for updates.")}finally{m(d,!1)}}async function P(){m(u,!0),m(f,"");try{(await ov()).restarting?(m(f,"Updated! Restarting server…"),setTimeout(()=>{location.reload()},5e3)):m(f,"Updated! Please restart the server manually."),m(c,!1)}catch{m(f,"Update failed. Please try again."),m(u,!1)}}function B(){localStorage.setItem("devtools-enabled",l(r)?"true":"false"),window.dispatchEvent(new Event("devtools-changed"))}async function U(){if(confirm("Clear all analytics data? This cannot be undone.")){m(p,!0);try{await Wb(),m(_,0)}catch{m(n,"Failed to clear analytics.")}finally{m(p,!1)}}}async function $(){i.close(),await gt()}function q(ae){ae.target===i&&$()}var F={open:b,close:g},L=Px(),D=w(L),I=w(D),H=T(w(I),2),k=T(I,2),x=w(k);{var Q=ae=>{var Ye=xx(),jt=w(Ye);he(()=>ne(jt,l(n))),N(ae,Ye)};ie(x,ae=>{l(n)&&ae(Q)})}var Z=T(x,2),pe=T(w(Z),4),be=w(pe);be.value=be.__value="claude";var ce=T(be);ce.value=ce.__value="codex";var se=T(Z,2),De=T(w(se),4),Te=w(De),_e=T(De,2),Se=w(_e),de=T(_e,2),Me=w(de),Ne=T(de,2),je=w(Ne),Pe=T(se,2),et=T(w(Pe),2),X=w(et),ve=T(Pe,2),Fe=T(w(ve),2),Ke=w(Fe),Be=w(Ke),C=T(Ke,2),J=w(C),fe=T(ve,2),ye=T(w(fe),2),Ce=w(ye),M=w(Ce);{var Y=ae=>{var Ye=hn();he(()=>ne(Ye,`v${l(o)??""}`)),N(ae,Ye)},ge=ae=>{var Ye=hn("...");N(ae,Ye)};ie(M,ae=>{l(o)?ae(Y):ae(ge,!1)})}var le=T(Ce,2);{var re=ae=>{var Ye=Ex();N(ae,Ye)};ie(le,ae=>{l(h)&&!l(c)&&!l(u)&&ae(re)})}var ke=T(ye,2);{var we=ae=>{var Ye=Dx(),jt=w(Ye),ji=w(jt),Le=T(jt,2),ht=w(Le);he(()=>{ne(ji,`v${l(o)??""} → v${l(a)??""}`),Le.disabled=l(u),ne(ht,l(u)?"Updating…":"Update Now")}),G("click",Le,P),N(ae,Ye)},Re=ae=>{var Ye=Tx(),jt=w(Ye);he(()=>{Ye.disabled=l(d),ne(jt,l(d)?"Checking…":"Check for updates")}),G("click",Ye,A),N(ae,Ye)};ie(ke,ae=>{l(c)?ae(we):l(h)||ae(Re,1)})}var oe=T(ke,2);{var Ee=ae=>{var Ye=Rx(),jt=w(Ye);he(()=>ne(jt,l(f))),N(ae,Ye)};ie(oe,ae=>{l(f)&&ae(Ee)})}var Ge=T(k,2),qt=w(Ge);return Ze(L,ae=>i=ae,()=>i),he(ae=>{ne(Be,`DB size: ${ae??""}`),C.disabled=l(p),ne(J,l(p)?"Clearing…":"Clear")},[()=>l(_)!==null?(l(_)/1024/1024).toFixed(1)+" MB":"..."]),G("click",L,q),G("click",H,$),G("change",pe,y),el(pe,()=>s.defaultAgent,ae=>s.defaultAgent=ae),G("change",Te,O),sr(Te,()=>s.defaultContinue,ae=>s.defaultContinue=ae),G("change",Se,R),sr(Se,()=>s.defaultYolo,ae=>s.defaultYolo=ae),G("change",Me,S),sr(Me,()=>s.launchInTmux,ae=>s.launchInTmux=ae),G("change",je,E),sr(je,()=>s.defaultNotifications,ae=>s.defaultNotifications=ae),G("change",X,B),sr(X,()=>l(r),ae=>m(r,ae)),G("click",C,U),G("click",qt,$),N(e,L),ft(F)}_t(["click","change"]);var Mx=z('<p class="confirm-msg svelte-15sco2n">Are you sure you want to delete the worktree <strong class="wt-name svelte-15sco2n"> </strong>?</p> <p class="wt-path svelte-15sco2n"> </p> <p class="warning-msg svelte-15sco2n">This action cannot be undone.</p>',1),Ox=z('<p class="error-msg svelte-15sco2n"> </p>'),Lx=z('<dialog class="dialog svelte-15sco2n"><div class="dialog-content svelte-15sco2n"><h2 class="dialog-title svelte-15sco2n">Delete Worktree</h2> <div class="dialog-body svelte-15sco2n"><!> <!></div> <div class="dialog-footer svelte-15sco2n"><button class="btn btn-ghost svelte-15sco2n">Cancel</button> <button class="btn btn-danger svelte-15sco2n"> </button></div></div></dialog>');function Ix(e,t){dt(t,!0);let i,r=W(null),s=W(""),n=W(!1);function o(P){m(r,P,!0),m(s,""),m(n,!1),i.showModal()}function a(){i.close()}async function c(){if(!(!l(r)||l(n))){m(n,!0),m(s,""),Tn(l(r).path);try{await sv(l(r).path,l(r).repoPath),i.close(),await gt()}catch(P){m(s,P instanceof Error?P.message:"Failed to delete worktree.",!0),m(n,!1)}finally{l(r)&&Rn(l(r).path)}}}function h(){i.close()}function d(P){P.target===i&&i.close()}var u={open:o,close:a},f=Lx(),_=w(f),p=T(w(_),2),b=w(p);{var g=P=>{var B=Mx(),U=Ct(B),$=T(w(U)),q=w($),F=T(U,2),L=w(F);he(()=>{ne(q,l(r).displayName||l(r).name),ne(L,l(r).path)}),N(P,B)};ie(b,P=>{l(r)&&P(g)})}var y=T(b,2);{var O=P=>{var B=Ox(),U=w(B);he(()=>ne(U,l(s))),N(P,B)};ie(y,P=>{l(s)&&P(O)})}var R=T(p,2),S=w(R),E=T(S,2),A=w(E);return Ze(f,P=>i=P,()=>i),he(()=>{S.disabled=l(n),E.disabled=l(n),ne(A,l(n)?"Deleting...":"Delete")}),G("click",f,d),G("click",S,h),G("click",E,c),N(e,f),ft(u)}_t(["click"]);var Bx=z('<div class="loading-placeholder svelte-15gfcbp">Loading...</div>'),Nx=z('<div class="empty-placeholder svelte-15gfcbp"><!></div>'),Fx=z('<span class="spinner svelte-15gfcbp">...</span>'),Wx=z("<span>&#9654;</span>"),Hx=z('<button class="expand-btn svelte-15gfcbp" data-track="file-browser.expand"><!></button>'),zx=z('<span class="expand-spacer svelte-15gfcbp"></span>'),Ux=z('<span class="git-badge svelte-15gfcbp" aria-label="Git repository">git</span>'),Kx=z('<div role="treeitem"><!> <input type="checkbox" class="node-checkbox svelte-15gfcbp" data-track="file-browser.select"/> <span class="node-name svelte-15gfcbp"> </span> <!></div>'),qx=z('<div class="truncated-notice svelte-15gfcbp"> </div>'),jx=z("<!> <!>",1),Yx=z('<div class="file-browser svelte-15gfcbp"><div class="filter-row svelte-15gfcbp"><input type="text" class="filter-input svelte-15gfcbp" placeholder="Filter..." aria-label="Filter directories" autocomplete="off" spellcheck="false"/></div> <div class="tree-container svelte-15gfcbp" role="tree" aria-label="File browser" tabindex="0"><!></div></div>');function Vx(e,t){dt(t,!0);let i=Pr(t,"selectedPaths",31,()=>Xe([])),r=W(Xe([])),s=W(""),n=W(-1),o=W(!0),a=W(null),c=W(void 0);vo(()=>{h()});async function h(){m(o,!0),m(a,null);try{const k=await dd();m(r,k.entries.map(x=>d(x,0)),!0),k.truncated&&m(a,{shown:k.entries.length,total:k.total},!0)}catch{m(r,[],!0)}finally{m(o,!1)}}function d(k,x){return{name:k.name,path:k.path,isGitRepo:k.isGitRepo,hasChildren:k.hasChildren,children:null,expanded:!1,selected:!1,loading:!1,depth:x,truncatedInfo:null}}async function u(k){if(k.expanded){k.expanded=!1;return}if(k.children===null){k.loading=!0;try{const x=await dd(k.path);k.children=x.entries.map(Q=>d(Q,k.depth+1)),k.truncatedInfo=x.truncated?{shown:x.entries.length,total:x.total}:null}catch{k.children=[]}finally{k.loading=!1}}k.expanded=!0}function f(k){k.selected=!k.selected,_()}function _(){i(p(l(r)))}function p(k){const x=[];for(const Q of k)Q.selected&&x.push(Q.path),Q.children&&x.push(...p(Q.children));return x}function b(k,x){return k.toLowerCase().includes(x.toLowerCase())}function g(k,x){var Q;return!!(!x||k.expanded||b(k.name,x)||(Q=k.children)!=null&&Q.some(Z=>g(Z,x)))}function y(k,x){const Q=[];for(const Z of k)g(Z,x)&&(Q.push(Z),Z.expanded&&Z.children&&Q.push(...y(Z.children,x)));return Q}let O=me(()=>y(l(r),l(s)));function R(k){var Q;if(k.key==="ArrowDown"){k.preventDefault(),m(n,Math.min(l(n)+1,l(O).length-1),!0);return}if(k.key==="ArrowUp"){k.preventDefault(),m(n,Math.max(l(n)-1,0),!0);return}const x=l(n)>=0?l(O)[l(n)]:void 0;if(x){if(k.key==="ArrowRight"){if(k.preventDefault(),x.hasChildren&&!x.expanded)u(x);else if(x.expanded&&((Q=x.children)!=null&&Q.length)){const Z=l(O).indexOf(x.children[0]);Z>=0&&m(n,Z,!0)}return}if(k.key==="ArrowLeft"){if(k.preventDefault(),x.expanded)x.expanded=!1;else{const Z=x.depth-1;for(let pe=l(n)-1;pe>=0;pe--)if(l(O)[pe].depth===Z){m(n,pe,!0);break}}return}if(k.key===" "){k.preventDefault(),f(x);return}}}function S(k,x){const Q=x.target;Q.closest(".expand-btn")||Q.closest(".node-checkbox")||(k.hasChildren&&!k.expanded?u(k):f(k))}function E(){m(s,""),m(n,-1),A(l(r)),i([]),P(l(r))}function A(k){for(const x of k)x.selected=!1,x.children&&A(x.children)}function P(k){for(const x of k)x.expanded=!1,x.children&&P(x.children)}var B={reset:E},U=Yx(),$=w(U),q=w($),F=T($,2),L=w(F);{var D=k=>{var x=Bx();N(k,x)},I=k=>{var x=Nx(),Q=w(x);{var Z=be=>{var ce=hn();he(()=>ne(ce,`No matches for "${l(s)??""}"`)),N(be,ce)},pe=be=>{var ce=hn("No directories found");N(be,ce)};ie(Q,be=>{l(s)?be(Z):be(pe,!1)})}N(k,x)},H=k=>{var x=jx(),Q=Ct(x);si(Q,19,()=>l(O),be=>be.path,(be,ce,se)=>{var De=Kx();let Te;var _e=w(De);{var Se=X=>{var ve=Hx(),Fe=w(ve);{var Ke=C=>{var J=Fx();N(C,J)},Be=C=>{var J=Wx();let fe;he(()=>fe=it(J,1,"arrow svelte-15gfcbp",null,fe,{expanded:l(ce).expanded})),N(C,J)};ie(Fe,C=>{l(ce).loading?C(Ke):C(Be,!1)})}he(()=>Ie(ve,"aria-label",l(ce).expanded?"Collapse":"Expand")),G("click",ve,()=>u(l(ce))),N(X,ve)},de=X=>{var ve=zx();N(X,ve)};ie(_e,X=>{l(ce).hasChildren?X(Se):X(de,!1)})}var Me=T(_e,2),Ne=T(Me,2),je=w(Ne),Pe=T(Ne,2);{var et=X=>{var ve=Ux();N(X,ve)};ie(Pe,X=>{l(ce).isGitRepo&&X(et)})}he(()=>{Te=it(De,1,"tree-row svelte-15gfcbp",null,Te,{focused:l(se)===l(n),selected:l(ce).selected}),_o(De,`padding-left: ${12+l(ce).depth*20}px`),Ie(De,"aria-expanded",l(ce).hasChildren?l(ce).expanded:void 0),Ie(De,"aria-selected",l(ce).selected),Ie(De,"aria-level",l(ce).depth+1),ob(Me,l(ce).selected),Ie(Me,"aria-label",`Select ${l(ce).name??""}`),ne(je,l(ce).name)}),G("click",De,X=>S(l(ce),X)),G("change",Me,()=>f(l(ce))),G("click",Me,X=>X.stopPropagation()),N(be,De)});var Z=T(Q,2);{var pe=be=>{var ce=qx(),se=w(ce);he(()=>ne(se,`Showing ${l(a).shown??""} of ${l(a).total??""} directories. Use the filter to narrow results.`)),N(be,ce)};ie(Z,be=>{l(a)&&be(pe)})}N(k,x)};ie(L,k=>{l(o)?k(D):l(O).length===0?k(I,1):k(H,!1)})}return Ze(F,k=>m(c,k),()=>l(c)),rr(q,()=>l(s),k=>m(s,k)),G("keydown",F,R),N(e,U),ft(B)}_t(["keydown","click","change"]);var Gx=z('<p class="error-msg svelte-4yj2yx"> </p>'),Xx=z('<dialog class="dialog svelte-4yj2yx"><div class="dialog-content svelte-4yj2yx"><div class="dialog-header svelte-4yj2yx"><h2 class="dialog-title svelte-4yj2yx">Add Workspace</h2> <button class="close-btn svelte-4yj2yx" aria-label="Close">&#10005;</button></div> <div class="dialog-body svelte-4yj2yx"><p class="dialog-desc svelte-4yj2yx">Browse for folders on your machine. Git repos get PR tracking and branch management.</p> <!> <!></div> <div class="dialog-footer svelte-4yj2yx"><span class="selected-count svelte-4yj2yx"><!></span> <div class="footer-actions svelte-4yj2yx"><button class="btn btn-ghost svelte-4yj2yx">Cancel</button> <button class="btn btn-primary svelte-4yj2yx"><!></button></div></div></div></dialog>');function $x(e,t){dt(t,!0);let i,r=W(void 0),s=W(Xe([])),n=W(""),o=W(!1);function a(){var D;m(s,[],!0),m(n,""),m(o,!1),(D=l(r))==null||D.reset(),i.showModal()}function c(){i.close()}async function h(){if(l(s).length!==0){m(o,!0),m(n,"");try{const D=await gb(l(s));if(D.errors.length>0&&D.added.length===0){m(n,D.errors.map(I=>`${I.path}: ${I.error}`).join("; "),!0),m(o,!1);return}D.added.length>0&&t.onWorkspacesAdded(D.added.map(I=>I.path)),D.errors.length>0&&console.warn("Some workspaces failed to add:",D.errors),c()}catch{m(n,"Failed to add workspaces.")}finally{m(o,!1)}}}function d(D){D.target===i&&c()}var u={open:a,close:c},f=Xx(),_=w(f),p=w(_),b=T(w(p),2),g=T(p,2),y=T(w(g),2);Ze(Vx(y,{get selectedPaths(){return l(s)},set selectedPaths(D){m(s,D,!0)}}),D=>m(r,D,!0),()=>l(r));var O=T(y,2);{var R=D=>{var I=Gx(),H=w(I);he(()=>ne(H,l(n))),N(D,I)};ie(O,D=>{l(n)&&D(R)})}var S=T(g,2),E=w(S),A=w(E);{var P=D=>{var I=hn();he(()=>ne(I,`${l(s).length??""} selected`)),N(D,I)};ie(A,D=>{l(s).length>0&&D(P)})}var B=T(E,2),U=w(B),$=T(U,2),q=w($);{var F=D=>{var I=hn("Adding...");N(D,I)},L=D=>{var I=hn();he(()=>ne(I,`Add Workspace${l(s).length>1?"s":""}`)),N(D,I)};ie(q,D=>{l(o)?D(F):D(L,!1)})}return Ze(f,D=>i=D,()=>i),he(()=>$.disabled=l(s).length===0||l(o)),G("click",f,d),G("click",b,c),G("click",U,c),G("click",$,h),N(e,f),ft(u)}_t(["click"]);var Qx=z('<p class="error-msg svelte-1n78dcx"> </p>'),Zx=z("<option> </option>"),Jx=z("<option> </option>"),eE=z('<span class="override-badge svelte-1n78dcx">overridden</span>'),tE=z('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. focus on security, error handling"></textarea>'),iE=z('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. include test plan section"></textarea>'),rE=z('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. prefix with dy/, use conventional commits style"></textarea>'),sE=z('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. use TypeScript, follow CLAUDE.md"></textarea>'),nE=z('<button class="btn btn-ghost svelte-1n78dcx">Reset to Global</button>'),oE=z('<span class="save-success svelte-1n78dcx">Saved</span>'),aE=z('<dialog class="dialog svelte-1n78dcx"><div class="dialog-content svelte-1n78dcx"><div class="dialog-header svelte-1n78dcx"><h2 class="dialog-title svelte-1n78dcx"><span class="gear-icon svelte-1n78dcx">&#9881;</span> </h2> <button class="close-btn svelte-1n78dcx" aria-label="Close settings">&#10005;</button></div> <div class="dialog-body svelte-1n78dcx"><!> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">GIT SETTINGS</h3> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-default-branch">Branch new worktrees from</label> <select id="ws-default-branch" class="field-select svelte-1n78dcx"><option>-- auto --</option><!><!></select></div> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-remote">Remote origin</label> <input id="ws-remote" type="text" class="field-input svelte-1n78dcx" placeholder="origin"/></div> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-branch-prefix">Branch prefix</label> <input id="ws-branch-prefix" type="text" class="field-input svelte-1n78dcx" placeholder="e.g. dy/"/></div></section> <div class="divider svelte-1n78dcx"></div> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">SESSION DEFAULTS <!></h3> <div class="inline-row svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-agent">Default agent</label> <select id="ws-agent" class="field-select field-select-inline svelte-1n78dcx"><option>Claude</option><option>Codex</option></select></div> <div class="checkbox-row svelte-1n78dcx"><label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>Continue</span></label> <label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>YOLO</span></label> <label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>Tmux</span></label></div></section> <div class="divider svelte-1n78dcx"></div> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">PROMPTS</h3> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Code review preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Create PR preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Branch rename preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> General preferences</button> <!></div></section></div> <div class="dialog-footer svelte-1n78dcx"><button class="btn btn-danger svelte-1n78dcx">Remove Workspace</button> <div class="footer-right svelte-1n78dcx"><!> <!> <button class="btn btn-primary svelte-1n78dcx"> </button></div></div></div></dialog>');function lE(e,t){dt(t,!0);let i,r=W(""),s=W(""),n=W(!1),o=W(""),a=W(!1),c=W(Xe([])),h=W(""),d=W(""),u=W(""),f=W("claude"),_=W(!1),p=W(!1),b=W(!1),g=W(""),y=W(""),O=W(""),R=W(""),S=W(Xe([])),E=W(Xe({})),A=W(!1),P=W(!1),B=W(!1),U=W(!1);async function $(V,ze){m(r,V,!0),m(s,ze,!0),m(o,""),m(a,!1),m(n,!1),m(h,""),m(d,""),m(u,""),m(f,"claude"),m(_,!1),m(p,!1),m(b,!1),m(g,""),m(y,""),m(O,""),m(R,""),i.showModal();try{const[ot,xn]=await Promise.all([fd(V),rv(V).catch(()=>[])]);m(c,xn,!0),F(ot.settings),m(E,{defaultAgent:ot.settings.defaultAgent,defaultContinue:ot.settings.defaultContinue,defaultYolo:ot.settings.defaultYolo,launchInTmux:ot.settings.launchInTmux},!0),m(S,ot.overridden,!0)}catch{m(o,"Failed to load workspace settings.")}}function q(){i.close()}function F(V){m(h,V.defaultBranch??"",!0),m(d,V.remote??"",!0),m(u,V.branchPrefix??"",!0),m(f,V.defaultAgent??"claude",!0),m(_,V.defaultContinue??!1,!0),m(p,V.defaultYolo??!1,!0),m(b,V.launchInTmux??!1,!0),m(g,V.promptCodeReview??"",!0),m(y,V.promptCreatePr??"",!0),m(O,V.promptBranchRename??"",!0),m(R,V.promptGeneral??"",!0)}async function L(){m(n,!0),m(o,""),m(a,!1);try{const V={};l(f)!==l(E).defaultAgent&&(V.defaultAgent=l(f)),l(_)!==l(E).defaultContinue&&(V.defaultContinue=l(_)),l(p)!==l(E).defaultYolo&&(V.defaultYolo=l(p)),l(b)!==l(E).launchInTmux&&(V.launchInTmux=l(b)),l(h)&&(V.defaultBranch=l(h)),l(d)&&(V.remote=l(d)),l(u)&&(V.branchPrefix=l(u)),l(g)&&(V.promptCodeReview=l(g)),l(y)&&(V.promptCreatePr=l(y)),l(O)&&(V.promptBranchRename=l(O)),l(R)&&(V.promptGeneral=l(R)),Object.keys(V).length>0&&await _d(l(r),V),m(a,!0),setTimeout(()=>{m(a,!1)},2e3)}catch(V){m(o,V instanceof Error?V.message:"Failed to save settings.",!0)}finally{m(n,!1)}}async function D(){m(n,!0),m(o,"");try{await _d(l(r),{defaultAgent:null,defaultContinue:null,defaultYolo:null,launchInTmux:null});const V=await fd(l(r));F(V.settings),m(E,{defaultAgent:V.settings.defaultAgent,defaultContinue:V.settings.defaultContinue,defaultYolo:V.settings.defaultYolo,launchInTmux:V.settings.launchInTmux},!0),m(S,V.overridden,!0),m(a,!0),setTimeout(()=>{m(a,!1)},2e3)}catch(V){m(o,V instanceof Error?V.message:"Failed to reset settings.",!0)}finally{m(n,!1)}}function I(){i.close(),t.onRemoveWorkspace(l(r))}function H(V){V.target===i&&i.close()}var k={open:$,close:q},x=aE(),Q=w(x),Z=w(Q),pe=w(Z),be=T(w(pe)),ce=T(pe,2),se=T(Z,2),De=w(se);{var Te=V=>{var ze=Qx(),ot=w(ze);he(()=>ne(ot,l(o))),N(V,ze)};ie(De,V=>{l(o)&&V(Te)})}var _e=T(De,2),Se=T(w(_e),2),de=T(w(Se),2),Me=w(de);Me.value=Me.__value="";var Ne=T(Me);si(Ne,17,()=>l(c),Yo,(V,ze)=>{var ot=Zx(),xn=w(ot),$u={};he(()=>{ne(xn,l(ze)),$u!==($u=l(ze))&&(ot.value=(ot.__value=l(ze))??"")}),N(V,ot)});var je=T(Ne);{var Pe=V=>{var ze=Jx(),ot=w(ze),xn={};he(()=>{ne(ot,l(h)),xn!==(xn=l(h))&&(ze.value=(ze.__value=l(h))??"")}),N(V,ze)},et=me(()=>l(h)&&!l(c).includes(l(h)));ie(je,V=>{l(et)&&V(Pe)})}var X=T(Se,2),ve=T(w(X),2),Fe=T(X,2),Ke=T(w(Fe),2),Be=T(_e,4),C=w(Be),J=T(w(C));{var fe=V=>{var ze=eE();N(V,ze)},ye=me(()=>l(S).some(V=>["defaultAgent","defaultContinue","defaultYolo","launchInTmux"].includes(V)));ie(J,V=>{l(ye)&&V(fe)})}var Ce=T(C,2),M=T(w(Ce),2),Y=w(M);Y.value=Y.__value="claude";var ge=T(Y);ge.value=ge.__value="codex";var le=T(Ce,2),re=w(le),ke=w(re),we=T(re,2),Re=w(we),oe=T(we,2),Ee=w(oe),Ge=T(Be,4),qt=T(w(Ge),2),ae=w(qt),Ye=w(ae),jt=w(Ye),ji=T(ae,2);{var Le=V=>{var ze=tE();Ie(ze,"rows",3),rr(ze,()=>l(g),ot=>m(g,ot)),N(V,ze)};ie(ji,V=>{l(A)&&V(Le)})}var ht=T(qt,2),Ot=w(ht),ur=w(Ot),Ti=w(ur),Cn=T(Ot,2);{var Ps=V=>{var ze=iE();Ie(ze,"rows",3),rr(ze,()=>l(y),ot=>m(y,ot)),N(V,ze)};ie(Cn,V=>{l(P)&&V(Ps)})}var kn=T(ht,2),Lr=w(kn),jl=w(Lr),Yl=w(jl),tt=T(Lr,2);{var Lt=V=>{var ze=rE();Ie(ze,"rows",3),rr(ze,()=>l(O),ot=>m(O,ot)),N(V,ze)};ie(tt,V=>{l(B)&&V(Lt)})}var Yi=T(kn,2),wa=w(Yi),lg=w(wa),hg=w(lg),cg=T(wa,2);{var ug=V=>{var ze=sE();Ie(ze,"rows",3),rr(ze,()=>l(R),ot=>m(R,ot)),N(V,ze)};ie(cg,V=>{l(U)&&V(ug)})}var dg=T(se,2),Vu=w(dg),fg=T(Vu,2),Gu=w(fg);{var _g=V=>{var ze=nE();he(()=>ze.disabled=l(n)),G("click",ze,D),N(V,ze)},vg=me(()=>l(S).some(V=>["defaultAgent","defaultContinue","defaultYolo","launchInTmux"].includes(V)));ie(Gu,V=>{l(vg)&&V(_g)})}var Xu=T(Gu,2);{var pg=V=>{var ze=oE();N(V,ze)};ie(Xu,V=>{l(a)&&V(pg)})}var Vl=T(Xu,2),gg=w(Vl);return Ze(x,V=>i=V,()=>i),he(()=>{ne(be,` ${l(s)??""}`),Ie(ae,"aria-expanded",l(A)),ne(jt,l(A)?"▾":"▸"),Ie(Ot,"aria-expanded",l(P)),ne(Ti,l(P)?"▾":"▸"),Ie(Lr,"aria-expanded",l(B)),ne(Yl,l(B)?"▾":"▸"),Ie(wa,"aria-expanded",l(U)),ne(hg,l(U)?"▾":"▸"),Vl.disabled=l(n),ne(gg,l(n)?"Saving…":"Save")}),G("click",x,H),G("click",ce,()=>i.close()),el(de,()=>l(h),V=>m(h,V)),rr(ve,()=>l(d),V=>m(d,V)),rr(Ke,()=>l(u),V=>m(u,V)),el(M,()=>l(f),V=>m(f,V)),sr(ke,()=>l(_),V=>m(_,V)),sr(Re,()=>l(p),V=>m(p,V)),sr(Ee,()=>l(b),V=>m(b,V)),G("click",ae,()=>{m(A,!l(A))}),G("click",Ot,()=>{m(P,!l(P))}),G("click",Lr,()=>{m(B,!l(B))}),G("click",wa,()=>{m(U,!l(U))}),G("click",Vu,I),G("click",Vl,L),N(e,x),ft(k)}_t(["click"]);var hE=z('<div class="sidebar-overlay svelte-13zv0lp"></div>'),cE=z("<!> <!> <!> <!>",1),uE=z('<div class="main-app svelte-13zv0lp"><!> <!> <div class="terminal-area svelte-13zv0lp"><!> <!></div></div> <!> <!> <!> <!> <!> <!> <!>',1);function dE(e,t){dt(t,!0);const i=new rg({defaultOptions:{queries:{staleTime:60*1e3,gcTime:600*1e3,refetchOnWindowFocus:!0}}}),r=av(),s=mu(),n=yu(),o=Cu();function a(C,J){n.activeSessionId=C;const fe=n.sessions.find(ye=>ye.id===C);fe&&(s.activeWorkspacePath=fe.repoPath),bd(C),ki()}ey(a);let c=W(void 0),h=W(void 0),d=W(void 0),u=W(void 0),f=W(void 0),_=W(void 0),p=W(void 0),b=W(!1);vo(()=>{by(()=>n.activeSessionId),Hb();let C,J;if(Nt&&window.visualViewport){const Ce=window.visualViewport;let M=null;const Y=()=>{const ge=window.innerHeight-Ce.height;m(b,ge>50),l(p)&&(l(p).style.height=l(b)?Ce.height+"px":""),window.scrollTo(0,0),M&&clearTimeout(M),M=setTimeout(()=>{var le;return(le=l(c))==null?void 0:le.fitTerm()},100)};Ce.addEventListener("resize",Y),Ce.addEventListener("scroll",Y),C=()=>{Ce.removeEventListener("resize",Y),Ce.removeEventListener("scroll",Y),M&&clearTimeout(M)}}const fe=navigator.platform.toUpperCase().includes("MAC");let ye;{const Ce=M=>{var le;const Y=(le=document.activeElement)==null?void 0:le.tagName;if(!(Y==="INPUT"||Y==="TEXTAREA"||!(fe?M.metaKey:M.ctrlKey))){if(M.key==="t"&&!M.shiftKey){M.preventDefault(),q();return}if(M.key==="w"&&!M.shiftKey){M.preventDefault(),n.activeSessionId&&be(n.activeSessionId);return}if(!M.shiftKey&&M.key>="1"&&M.key<="9"){const re=l(S);if(re.length===0)return;M.preventDefault();const ke=parseInt(M.key,10),we=ke===9?re[re.length-1]:re[ke-1];we&&$(we.id);return}if(M.shiftKey&&M.key==="["){const re=l(S);if(re.length===0)return;M.preventDefault();const ke=re.findIndex(Re=>Re.id===n.activeSessionId),we=ke<=0?re[re.length-1]:re[ke-1];we&&$(we.id);return}if(M.shiftKey&&M.key==="]"){const re=l(S);if(re.length===0)return;M.preventDefault();const ke=re.findIndex(Re=>Re.id===n.activeSessionId),we=ke===-1||ke===re.length-1?re[0]:re[ke+1];we&&$(we.id);return}}};document.addEventListener("keydown",Ce),ye=()=>document.removeEventListener("keydown",Ce)}if(Nt){let Y=0,ge=0,le=!1;const re=Re=>{const oe=Re.touches[0];oe&&oe.clientX<=30&&!s.sidebarOpen&&(Y=oe.clientX,ge=oe.clientY,le=!0)},ke=Re=>{if(!le)return;const oe=Re.touches[0];if(!oe)return;const Ee=oe.clientX-Y,Ge=Math.abs(oe.clientY-ge);if(Ge>Ee&&(Ge>8||Ee>8)){le=!1;return}Ee>=50&&(le=!1,gd())},we=()=>{le=!1};document.addEventListener("touchstart",re,{passive:!0}),document.addEventListener("touchmove",ke,{passive:!0}),document.addEventListener("touchend",we),J=()=>{document.removeEventListener("touchstart",re),document.removeEventListener("touchmove",ke),document.removeEventListener("touchend",we)}}return()=>{ye==null||ye(),C==null||C(),J==null||J(),yy()}});let g;Ei(()=>{const C=n.activeSessionId;if(g===void 0){g=C;return}C!==g&&(g=C,C?Gh("navigation","page.view","/terminal",void 0,C):Gh("navigation","page.view","/dashboard",{workspace:s.activeWorkspacePath}))}),Ei(()=>{r.authenticated&&gt().then(()=>{const J=new URLSearchParams(window.location.search).get("session");J&&(window.history.replaceState({},"","/"),a(J)),!n.activeSessionId&&!J&&n.sessions.length===1&&$(n.sessions[0].id),!n.activeSessionId&&!J&&n.sessions.length===1&&$(n.sessions[0].id);for(const fe of n.sessions)As(fe.id,o.defaultNotifications);ty().then(()=>{iy(ly())})})}),Ei(()=>{r.authenticated&&Su(C=>{C.type==="worktrees-changed"?gt():C.type==="session-state-changed"&&C.sessionId&&C.state?oy(C.sessionId,C.state):C.type==="session-idle-changed"&&C.sessionId?ay(C.sessionId,C.idle??!1):C.type==="session-renamed"&&C.sessionId?ny(C.sessionId,C.branchName??"",C.displayName??""):C.type==="session-ended"&&(i.invalidateQueries({queryKey:["pr"]}),i.invalidateQueries({queryKey:["ci-status"]}))})});let y=me(()=>s.activeWorkspacePath?n.workspaces.find(C=>C.path===s.activeWorkspacePath):void 0),O=me(()=>s.activeWorkspacePath?wv(s.activeWorkspacePath):[]),R=me(()=>n.activeSessionId?n.sessions.find(C=>C.id===n.activeSessionId):void 0),S=me(()=>(l(R)?l(O).filter(C=>C.repoPath===l(R).repoPath):l(O)).toSorted((C,J)=>new Date(C.createdAt).getTime()-new Date(J.createdAt).getTime())),E=me(()=>!!l(R)&&!!s.activeWorkspacePath&&(l(R).repoPath===s.activeWorkspacePath||l(R).repoPath.startsWith(s.activeWorkspacePath+"/"))),A=me(()=>{var C,J;return((C=l(R))==null?void 0:C.displayName)||((J=l(y))==null?void 0:J.name)||"Claude Remote CLI"}),P=me(()=>{var C;return((C=l(R))==null?void 0:C.useTmux)??!1}),B=W(!1),U=me(()=>l(y)?l(E)?"session":"dashboard":"empty");function $(C){var fe;n.activeSessionId=C;const J=n.sessions.find(ye=>ye.id===C);if(J){const ye=n.workspaces.find(Ce=>J.repoPath===Ce.path||J.repoPath.startsWith(Ce.path+"/"));s.activeWorkspacePath=(ye==null?void 0:ye.path)??J.repoPath}bd(C),ki(),(fe=l(c))==null||fe.focusTerm()}async function q(){if(!l(y))return;const{cols:C,rows:J}=Iv();try{const fe=await gu({repoPath:l(y).path,repoName:l(y).name,continue:o.defaultContinue,yolo:o.defaultYolo,agent:o.defaultAgent,useTmux:o.launchInTmux,cols:C,rows:J});await gt(),fe!=null&&fe.id&&(n.activeSessionId=fe.id,As(fe.id,o.defaultNotifications))}catch(fe){if(fe instanceof Error&&"sessionId"in fe){const ye=fe;await gt(),ye.sessionId&&(n.activeSessionId=ye.sessionId)}else console.error("Failed to create agent session:",fe)}}async function F(){if(l(y))try{const C=await Cb(l(y).path);await gt(),C!=null&&C.id&&(n.activeSessionId=C.id,As(C.id,o.defaultNotifications))}catch(C){console.error("Failed to create terminal session:",C)}}function L(){var C;l(y)&&((C=l(d))==null||C.open({name:l(y).name,path:l(y).path}))}function D(C){var J,fe;C?(J=l(_))==null||J.open(C.path,C.name):(fe=l(u))==null||fe.open()}async function I(C){var fe,ye;const J=`new-worktree:${C.path}`;if(!Qi(J)){Tn(J);try{const{branchName:Ce,worktreePath:M}=await eh(C.path),Y=await On({repoPath:C.path,repoName:C.name,worktreePath:M,branchName:Ce,needsBranchRename:!0});await gt(),n.activeSessionId=Y.id,s.activeWorkspacePath=C.path,As(Y.id,o.defaultNotifications),ki(),(fe=l(c))==null||fe.focusTerm()}catch{(ye=l(d))==null||ye.open({name:C.name,path:C.path})}finally{Rn(J)}}}async function H(C){if(!l(y))return;const J=l(y).path,fe=n.sessions.find(M=>M.branchName===C.headRefName&&M.repoPath.startsWith(J)),ye=n.worktrees.find(M=>M.branchName===C.headRefName&&M.repoPath===J);let Ce=`Merge the branch "${C.baseRefName}" into this branch and resolve all merge conflicts. Use \`git merge ${C.baseRefName}\` and fix any conflicts in the working tree. After resolving, verify the build passes.`;try{const M=await Nb(J);M.promptFixConflicts&&(Ce=M.promptFixConflicts.replace(/\{baseRefName\}/g,C.baseRefName).replace(/\{headRefName\}/g,C.headRefName))}catch{}try{let M,Y;if(fe)M=fe.repoPath,Y=fe.branchName;else if(ye)M=ye.path,Y=ye.branchName;else{const le=await eh(J,C.headRefName);M=le.worktreePath,Y=le.branchName}const ge=await On({repoPath:J,repoName:l(y).name,worktreePath:M,branchName:Y});await gt(),n.activeSessionId=ge.id,s.activeWorkspacePath=J,As(ge.id,o.defaultNotifications),ki(),setTimeout(()=>{Cr(Ce+"\r")},1500)}catch(M){console.error("Failed to start conflict resolution:",M)}}async function k(C,J){if(!l(y))return;const fe=l(y).path,ye=n.sessions.find(M=>M.branchName===C.headRefName&&M.repoPath.startsWith(fe)),Ce=n.worktrees.find(M=>M.branchName===C.headRefName&&M.repoPath===fe);try{let M,Y;if(ye)M=ye.repoPath,Y=ye.branchName;else if(Ce)M=Ce.path,Y=Ce.branchName;else{const le=await eh(fe,C.headRefName);M=le.worktreePath,Y=le.branchName}const ge=await On({repoPath:fe,repoName:l(y).name,worktreePath:M,branchName:Y});await gt(),n.activeSessionId=ge.id,s.activeWorkspacePath=fe,As(ge.id,o.defaultNotifications),ki(),J&&setTimeout(()=>{Cr(J+"\r")},1500)}catch(M){console.error("Failed to open PR branch session:",M)}}function x(C){const J=C.state==="OPEN"?"OPEN":C.state==="MERGED"?"MERGED":"CLOSED",fe=ku({commitsAhead:1,prState:J,ciFailing:0,ciPending:0,ciTotal:0,mergeable:C.mergeable??null,unresolvedCommentCount:0}),ye=Bv(fe,{branchName:C.headRefName,baseBranch:C.baseRefName,prNumber:C.number});ye&&k(C,ye)}function Q(C){k(C)}function Z(C){var J;(J=l(f))==null||J.open(C)}function pe(C){var J;n.activeSessionId=C,As(C,o.defaultNotifications),ki(),(J=l(c))==null||J.focusTerm()}function be(C){var J;if(fetch(`/sessions/${C}`,{method:"DELETE"}).then(()=>gt()),n.activeSessionId===C){const fe=l(S).filter(ye=>ye.id!==C);n.activeSessionId=((J=fe[0])==null?void 0:J.id)??null}}function ce(C,J,fe){var ye,Ce;(ye=l(h))==null||ye.show(C,J,fe),J||(Ce=l(h))==null||Ce.autoDismiss(3e3)}function se(C){Cr(C)}function De(){}function Te(){}function _e(){const C=document.createElement("input");C.type="file",C.accept="image/*",C.onchange=()=>{var fe,ye;const J=(fe=C.files)==null?void 0:fe[0];J&&((ye=l(c))==null||ye.handleImageUpload(J,J.type))},C.click()}function Se(){var C;(C=l(c))==null||C.focusTerm()}function de(C){m(B,C,!0)}function Me(){var C;(C=l(c))==null||C.exitCopyMode()}let Ne=W(void 0);function je(){var C;(C=l(Ne))==null||C.open()}async function Pe(C){await gt(),C.length>0&&(s.activeWorkspacePath=C[0])}async function et(){const C=n.activeSessionId;if(!C)return;const J=n.sessions.find(fe=>fe.id===C);if(J){if(await kb(C),J.type==="worktree"){const fe=n.workspaces.find(ye=>J.repoPath===ye.path||J.repoPath.startsWith(ye.path+"/"));if(fe&&J.repoPath!==fe.path)try{await sv(J.repoPath,fe.path)}catch{}}n.activeSessionId=null,await gt()}}var X=Gr(),ve=Ct(X);{var Fe=C=>{},Ke=C=>{Cy(C,{})},Be=C=>{fk(C,{get client(){return i},children:(J,fe)=>{var ye=uE(),Ce=Ct(ye),M=w(Ce);{var Y=Le=>{var ht=hE();G("click",ht,function(...Ot){ki==null||ki.apply(this,Ot)}),N(Le,ht)};ie(M,Le=>{s.sidebarOpen&&Le(Y)})}var ge=T(M,2);vw(ge,{onSelectSession:$,onOpenSettings:D,onNewWorktree:I,onAddWorkspace:je,onDeleteSession:be,onDeleteWorktree:Z});var le=T(ge,2),re=w(le);vx(re,{get title(){return l(A)},get onMenuClick(){return gd},get hidden(){return l(b)}});var ke=T(re,2);{var we=Le=>{hx(Le,{heading:"Add a workspace to get started",description:"Point to any folder on your machine. Git repos get PR tracking and branch management.",actionLabel:"+ Add Workspace",onAction:je})},Re=Le=>{{let ht=me(()=>s.activeWorkspacePath??""),Ot=me(()=>{var Ti;return((Ti=l(y))==null?void 0:Ti.name)??""}),ur=me(()=>Qi(`new-worktree:${s.activeWorkspacePath??""}`));sx(Le,{get workspacePath(){return l(ht)},get workspaceName(){return l(Ot)},get creatingWorktree(){return l(ur)},onNewSession:()=>q(),onNewWorktree:()=>{l(y)&&I(l(y))},onFixConflicts:H,onPrAction:x,onOpenPrSession:Q})}},oe=Le=>{var ht=cE(),Ot=Ct(ht);{let Ps=me(()=>s.activeWorkspacePath??""),kn=me(()=>{var Lr;return((Lr=l(R))==null?void 0:Lr.branchName)??""});Mk(Ot,{get workspacePath(){return l(Ps)},get branchName(){return l(kn)},get sessionId(){return n.activeSessionId},onArchive:et})}var ur=T(Ot,2);Bk(ur,{get sessions(){return l(S)},get activeSessionId(){return n.activeSessionId},onSelectSession:$,onCloseSession:be,onNewAgent:()=>q(),onNewTerminal:()=>F(),onCustomize:()=>L()});var Ti=T(ur,2);Ze(PC(Ti,{get sessionId(){return n.activeSessionId},onImageUpload:ce,get useTmux(){return l(P)},onCopyModeChange:de}),Ps=>m(c,Ps,!0),()=>l(c));var Cn=T(Ti,2);fx(Cn,{onSendKey:se,onFlushComposedText:De,onClearInput:Te,onUploadImage:_e,onRefocusMobileInput:Se,get useTmux(){return l(P)},get inCopyMode(){return l(B)},onExitCopyMode:Me}),N(Le,ht)};ie(ke,Le=>{l(U)==="empty"?Le(we):l(U)==="dashboard"?Le(Re,1):l(U)==="session"&&Le(oe,2)})}Ze(Ce,Le=>m(p,Le),()=>l(p));var Ee=T(Ce,2);Ze(kx(Ee,{onSessionCreated:pe}),Le=>m(d,Le,!0),()=>l(d));var Ge=T(Ee,2);Ze(Ax(Ge,{}),Le=>m(u,Le,!0),()=>l(u));var qt=T(Ge,2);Ze(Ix(qt,{}),Le=>m(f,Le,!0),()=>l(f));var ae=T(qt,2);Ze($x(ae,{onWorkspacesAdded:Pe}),Le=>m(Ne,Le,!0),()=>l(Ne));var Ye=T(ae,2);Ze(lE(Ye,{onRemoveWorkspace:async Le=>{await fetch("/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Le})}),await gt(),s.activeWorkspacePath===Le&&(s.activeWorkspacePath=null)}}),Le=>m(_,Le,!0),()=>l(_));var jt=T(Ye,2);mx(jt,{});var ji=T(jt,2);Ze(Sx(ji,{}),Le=>m(h,Le,!0),()=>l(h)),N(J,ye)},$$slots:{default:!0}})};ie(ve,C=>{r.checking?C(Fe):r.authenticated?C(Be,!1):C(Ke,1)})}N(e,X),ft()}_t(["click"]);qm(dE,{target:document.getElementById("app")});