claude-remote-cli 3.1.1 → 3.2.0

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,13 +1,13 @@
1
- var R_=Object.defineProperty;var Xh=e=>{throw TypeError(e)};var P_=(e,t,i)=>t in e?R_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ri=(e,t,i)=>P_(e,typeof t!="symbol"?t+"":t,i),xa=(e,t,i)=>t.has(e)||Xh("Cannot "+i);var p=(e,t,i)=>(xa(e,t,"read from private field"),i?i.call(e):t.get(e)),$=(e,t,i)=>t.has(e)?Xh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),G=(e,t,i,s)=>(xa(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i),_e=(e,t,i)=>(xa(e,t,"access private method"),i);var xo=(e,t,i,s)=>({set _(r){G(e,t,r,i)},get _(){return p(e,t,s)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function i(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=i(r);fetch(r.href,n)}})();const Ya=!1;var vh=Array.isArray,T_=Array.prototype.indexOf,vn=Array.prototype.includes,da=Array.from,M_=Object.defineProperty,Kr=Object.getOwnPropertyDescriptor,B_=Object.getOwnPropertyDescriptors,L_=Object.prototype,A_=Array.prototype,zu=Object.getPrototypeOf,Qh=Object.isExtensible;const O_=()=>{};function I_(e){for(var t=0;t<e.length;t++)e[t]()}function Uu(){var e,t,i=new Promise((s,r)=>{e=s,t=r});return{promise:i,resolve:e,reject:t}}const Bt=2,vo=4,po=8,Ku=1<<24,Ss=16,Ki=32,Ar=64,Ga=128,Ci=512,xt=1024,Lt=2048,zi=4096,ai=8192,vs=16384,Rr=32768,Pr=65536,Jh=1<<17,qu=1<<18,kn=1<<19,ju=1<<20,fs=1<<25,Tr=65536,Xa=1<<21,ph=1<<22,Us=1<<23,kr=Symbol("$state"),N_=Symbol("legacy props"),F_=Symbol(""),rr=new class extends Error{constructor(){super(...arguments);Ri(this,"name","StaleReactionError");Ri(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var xu;const W_=!!((xu=globalThis.document)!=null&&xu.contentType)&&globalThis.document.contentType.includes("xml");function gh(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function H_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function z_(e,t,i){throw new Error("https://svelte.dev/e/each_key_duplicate")}function U_(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function K_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function q_(e){throw new Error("https://svelte.dev/e/effect_orphan")}function j_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function V_(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function Y_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function G_(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function X_(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Q_(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const J_=1,Z_=2,Vu=4,$_=8,ev=16,tv=1,iv=4,sv=8,rv=16,nv=1,ov=2,Dt=Symbol(),Yu="http://www.w3.org/1999/xhtml",av="http://www.w3.org/2000/svg",lv="http://www.w3.org/1998/Math/MathML";function hv(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function cv(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Gu(e){return e===this.v}function uv(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Xu(e){return!uv(e,this.v)}let dv=!1,_t=null;function pn(e){_t=e}function Qu(e){return Zu().get(e)}function fv(e,t){return Zu().set(e,t),t}function Ye(e,t=!1,i){_t={p:_t,i:!1,c:null,e:null,s:e,x:null,l:null}}function Ge(e){var t=_t,i=t.e;if(i!==null){t.e=null;for(var s of i)Sd(s)}return e!==void 0&&(t.x=e),t.i=!0,_t=t.p,e??{}}function Ju(){return!0}function Zu(e){return _t===null&&gh(),_t.c??(_t.c=new Map(_v(_t)||void 0))}function _v(e){let t=e.p;for(;t!==null;){const i=t.c;if(i!==null)return i;t=t.p}return null}let nr=[];function $u(){var e=nr;nr=[],I_(e)}function ts(e){if(nr.length===0&&!Kn){var t=nr;queueMicrotask(()=>{t===nr&&$u()})}nr.push(e)}function vv(){for(;nr.length>0;)$u()}function ed(e){var t=Ue;if(t===null)return Ne.f|=Us,e;if((t.f&Rr)===0&&(t.f&vo)===0)throw e;Hs(e,t)}function Hs(e,t){for(;t!==null;){if((t.f&Ga)!==0){if((t.f&Rr)===0)throw e;try{t.b.error(e);return}catch(i){e=i}}t=t.parent}throw e}const pv=-7169;function ht(e,t){e.f=e.f&pv|t}function mh(e){(e.f&Ci)!==0||e.deps===null?ht(e,xt):ht(e,zi)}function td(e){if(e!==null)for(const t of e)(t.f&Bt)===0||(t.f&Tr)===0||(t.f^=Tr,td(t.deps))}function id(e,t,i){(e.f&Lt)!==0?t.add(e):(e.f&zi)!==0&&i.add(e),td(e.deps),ht(e,xt)}const Eo=new Set;let Re=null,Go=null,Tt=null,Qt=[],fa=null,Qa=!1,Kn=!1;var Gr,Xr,cr,Qr,no,oo,ur,ls,Jr,li,Ja,Za,$a,sd;const jh=class jh{constructor(){$(this,li);Ri(this,"current",new Map);Ri(this,"previous",new Map);$(this,Gr,new Set);$(this,Xr,new Set);$(this,cr,0);$(this,Qr,0);$(this,no,null);$(this,oo,new Set);$(this,ur,new Set);$(this,ls,new Map);Ri(this,"is_fork",!1);$(this,Jr,!1)}skip_effect(t){p(this,ls).has(t)||p(this,ls).set(t,{d:[],m:[]})}unskip_effect(t){var i=p(this,ls).get(t);if(i){p(this,ls).delete(t);for(var s of i.d)ht(s,Lt),Fi(s);for(s of i.m)ht(s,zi),Fi(s)}}process(t){var r;Qt=[],this.apply();var i=[],s=[];for(const n of t)_e(this,li,Za).call(this,n,i,s);if(_e(this,li,Ja).call(this)){_e(this,li,$a).call(this,s),_e(this,li,$a).call(this,i);for(const[n,o]of p(this,ls))ad(n,o)}else{for(const n of p(this,Gr))n();p(this,Gr).clear(),p(this,cr)===0&&_e(this,li,sd).call(this),Go=this,Re=null,Zh(s),Zh(i),Go=null,(r=p(this,no))==null||r.resolve()}Tt=null}capture(t,i){i!==Dt&&!this.previous.has(t)&&this.previous.set(t,i),(t.f&Us)===0&&(this.current.set(t,t.v),Tt==null||Tt.set(t,t.v))}activate(){Re=this,this.apply()}deactivate(){Re===this&&(Re=null,Tt=null)}flush(){if(this.activate(),Qt.length>0){if(rd(),Re!==null&&Re!==this)return}else p(this,cr)===0&&this.process([]);this.deactivate()}discard(){for(const t of p(this,Xr))t(this);p(this,Xr).clear()}increment(t){G(this,cr,p(this,cr)+1),t&&G(this,Qr,p(this,Qr)+1)}decrement(t){G(this,cr,p(this,cr)-1),t&&G(this,Qr,p(this,Qr)-1),!p(this,Jr)&&(G(this,Jr,!0),ts(()=>{G(this,Jr,!1),_e(this,li,Ja).call(this)?Qt.length>0&&this.flush():this.revive()}))}revive(){for(const t of p(this,oo))p(this,ur).delete(t),ht(t,Lt),Fi(t);for(const t of p(this,ur))ht(t,zi),Fi(t);this.flush()}oncommit(t){p(this,Gr).add(t)}ondiscard(t){p(this,Xr).add(t)}settled(){return(p(this,no)??G(this,no,Uu())).promise}static ensure(){if(Re===null){const t=Re=new jh;Eo.add(Re),Kn||ts(()=>{Re===t&&t.flush()})}return Re}apply(){}};Gr=new WeakMap,Xr=new WeakMap,cr=new WeakMap,Qr=new WeakMap,no=new WeakMap,oo=new WeakMap,ur=new WeakMap,ls=new WeakMap,Jr=new WeakMap,li=new WeakSet,Ja=function(){return this.is_fork||p(this,Qr)>0},Za=function(t,i,s){t.f^=xt;for(var r=t.first;r!==null;){var n=r.f,o=(n&(Ki|Ar))!==0,a=o&&(n&xt)!==0,c=a||(n&ai)!==0||p(this,ls).has(r);if(!c&&r.fn!==null){o?r.f^=xt:(n&vo)!==0?i.push(r):mo(r)&&((n&Ss)!==0&&p(this,ur).add(r),mn(r));var h=r.first;if(h!==null){r=h;continue}}for(;r!==null;){var d=r.next;if(d!==null){r=d;break}r=r.parent}}},$a=function(t){for(var i=0;i<t.length;i+=1)id(t[i],p(this,oo),p(this,ur))},sd=function(){var r;if(Eo.size>1){this.previous.clear();var t=Tt,i=!0;for(const n of Eo){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 s=Qt;Qt=[];const c=new Set,h=new Map;for(const d of o)nd(d,a,c,h);if(Qt.length>0){Re=n,n.apply();for(const d of Qt)_e(r=n,li,Za).call(r,d,[],[]);n.deactivate()}Qt=s}}Re=null,Tt=t}Eo.delete(this)};let Ks=jh;function gv(e){var t=Kn;Kn=!0;try{for(var i;;){if(vv(),Qt.length===0&&(Re==null||Re.flush(),Qt.length===0))return fa=null,i;rd()}}finally{Kn=t}}function rd(){Qa=!0;var e=null;try{for(var t=0;Qt.length>0;){var i=Ks.ensure();if(t++>1e3){var s,r;mv()}i.process(Qt),qs.clear()}}finally{Qt=[],Qa=!1,fa=null}}function mv(){try{j_()}catch(e){Hs(e,fa)}}let Mi=null;function Zh(e){var t=e.length;if(t!==0){for(var i=0;i<t;){var s=e[i++];if((s.f&(vs|ai))===0&&mo(s)&&(Mi=new Set,mn(s),s.deps===null&&s.first===null&&s.nodes===null&&s.teardown===null&&s.ac===null&&kd(s),(Mi==null?void 0:Mi.size)>0)){qs.clear();for(const r of Mi){if((r.f&(vs|ai))!==0)continue;const n=[r];let o=r.parent;for(;o!==null;)Mi.has(o)&&(Mi.delete(o),n.push(o)),o=o.parent;for(let a=n.length-1;a>=0;a--){const c=n[a];(c.f&(vs|ai))===0&&mn(c)}}Mi.clear()}}Mi=null}}function nd(e,t,i,s){if(!i.has(e)&&(i.add(e),e.reactions!==null))for(const r of e.reactions){const n=r.f;(n&Bt)!==0?nd(r,t,i,s):(n&(ph|Ss))!==0&&(n&Lt)===0&&od(r,t,s)&&(ht(r,Lt),Fi(r))}}function od(e,t,i){const s=i.get(e);if(s!==void 0)return s;if(e.deps!==null)for(const r of e.deps){if(vn.call(t,r))return!0;if((r.f&Bt)!==0&&od(r,t,i))return i.set(r,!0),!0}return i.set(e,!1),!1}function Fi(e){var t=fa=e,i=t.b;if(i!=null&&i.is_pending&&(e.f&(vo|po|Ku))!==0&&(e.f&Rr)===0){i.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var s=t.f;if(Qa&&t===Ue&&(s&Ss)!==0&&(s&qu)===0&&(s&Rr)!==0)return;if((s&(Ar|Ki))!==0){if((s&xt)===0)return;t.f^=xt}}Qt.push(t)}function ad(e,t){if(!((e.f&Ki)!==0&&(e.f&xt)!==0)){(e.f&Lt)!==0?t.d.push(e):(e.f&zi)!==0&&t.m.push(e),ht(e,xt);for(var i=e.first;i!==null;)ad(i,t),i=i.next}}function bv(e){let t=0,i=Xs(0),s;return()=>{yh()&&(l(i),pa(()=>(t===0&&(s=Js(()=>e(()=>js(i)))),t+=1,()=>{ts(()=>{t-=1,t===0&&(s==null||s(),s=void 0,js(i))})})))}}var Sv=Pr|kn;function yv(e,t,i,s){new wv(e,t,i,s)}var _i,fh,Yi,dr,Gt,Gi,ni,Bi,hs,fr,Ts,Zr,$r,en,cs,la,gt,Cv,kv,xv,el,Fo,Wo,tl;class wv{constructor(t,i,s,r){$(this,gt);Ri(this,"parent");Ri(this,"is_pending",!1);Ri(this,"transform_error");$(this,_i);$(this,fh,null);$(this,Yi);$(this,dr);$(this,Gt);$(this,Gi,null);$(this,ni,null);$(this,Bi,null);$(this,hs,null);$(this,fr,0);$(this,Ts,0);$(this,Zr,!1);$(this,$r,new Set);$(this,en,new Set);$(this,cs,null);$(this,la,bv(()=>(G(this,cs,Xs(p(this,fr))),()=>{G(this,cs,null)})));var n;G(this,_i,t),G(this,Yi,i),G(this,dr,o=>{var a=Ue;a.b=this,a.f|=Ga,s(o)}),this.parent=Ue.b,this.transform_error=r??((n=this.parent)==null?void 0:n.transform_error)??(o=>o),G(this,Gt,ga(()=>{_e(this,gt,el).call(this)},Sv))}defer_effect(t){id(t,p(this,$r),p(this,en))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!p(this,Yi).pending}update_pending_count(t){_e(this,gt,tl).call(this,t),G(this,fr,p(this,fr)+t),!(!p(this,cs)||p(this,Zr))&&(G(this,Zr,!0),ts(()=>{G(this,Zr,!1),p(this,cs)&&gn(p(this,cs),p(this,fr))}))}get_effect_pending(){return p(this,la).call(this),l(p(this,cs))}error(t){var i=p(this,Yi).onerror;let s=p(this,Yi).failed;if(!i&&!s)throw t;p(this,Gi)&&($t(p(this,Gi)),G(this,Gi,null)),p(this,ni)&&($t(p(this,ni)),G(this,ni,null)),p(this,Bi)&&($t(p(this,Bi)),G(this,Bi,null));var r=!1,n=!1;const o=()=>{if(r){cv();return}r=!0,n&&Q_(),p(this,Bi)!==null&&xr(p(this,Bi),()=>{G(this,Bi,null)}),_e(this,gt,Wo).call(this,()=>{Ks.ensure(),_e(this,gt,el).call(this)})},a=c=>{try{n=!0,i==null||i(c,o),n=!1}catch(h){Hs(h,p(this,Gt)&&p(this,Gt).parent)}s&&G(this,Bi,_e(this,gt,Wo).call(this,()=>{Ks.ensure();try{return mi(()=>{var h=Ue;h.b=this,h.f|=Ga,s(p(this,_i),()=>c,()=>o)})}catch(h){return Hs(h,p(this,Gt).parent),null}}))};ts(()=>{var c;try{c=this.transform_error(t)}catch(h){Hs(h,p(this,Gt)&&p(this,Gt).parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(a,h=>Hs(h,p(this,Gt)&&p(this,Gt).parent)):a(c)})}}_i=new WeakMap,fh=new WeakMap,Yi=new WeakMap,dr=new WeakMap,Gt=new WeakMap,Gi=new WeakMap,ni=new WeakMap,Bi=new WeakMap,hs=new WeakMap,fr=new WeakMap,Ts=new WeakMap,Zr=new WeakMap,$r=new WeakMap,en=new WeakMap,cs=new WeakMap,la=new WeakMap,gt=new WeakSet,Cv=function(){try{G(this,Gi,mi(()=>p(this,dr).call(this,p(this,_i))))}catch(t){this.error(t)}},kv=function(t){const i=p(this,Yi).failed;i&&G(this,Bi,mi(()=>{i(p(this,_i),()=>t,()=>()=>{})}))},xv=function(){const t=p(this,Yi).pending;t&&(this.is_pending=!0,G(this,ni,mi(()=>t(p(this,_i)))),ts(()=>{var i=G(this,hs,document.createDocumentFragment()),s=ps();i.append(s),G(this,Gi,_e(this,gt,Wo).call(this,()=>(Ks.ensure(),mi(()=>p(this,dr).call(this,s))))),p(this,Ts)===0&&(p(this,_i).before(i),G(this,hs,null),xr(p(this,ni),()=>{G(this,ni,null)}),_e(this,gt,Fo).call(this))}))},el=function(){try{if(this.is_pending=this.has_pending_snippet(),G(this,Ts,0),G(this,fr,0),G(this,Gi,mi(()=>{p(this,dr).call(this,p(this,_i))})),p(this,Ts)>0){var t=G(this,hs,document.createDocumentFragment());Dd(p(this,Gi),t);const i=p(this,Yi).pending;G(this,ni,mi(()=>i(p(this,_i))))}else _e(this,gt,Fo).call(this)}catch(i){this.error(i)}},Fo=function(){this.is_pending=!1;for(const t of p(this,$r))ht(t,Lt),Fi(t);for(const t of p(this,en))ht(t,zi),Fi(t);p(this,$r).clear(),p(this,en).clear()},Wo=function(t){var i=Ue,s=Ne,r=_t;ss(p(this,Gt)),Ei(p(this,Gt)),pn(p(this,Gt).ctx);try{return t()}catch(n){return ed(n),null}finally{ss(i),Ei(s),pn(r)}},tl=function(t){var i;if(!this.has_pending_snippet()){this.parent&&_e(i=this.parent,gt,tl).call(i,t);return}G(this,Ts,p(this,Ts)+t),p(this,Ts)===0&&(_e(this,gt,Fo).call(this),p(this,ni)&&xr(p(this,ni),()=>{G(this,ni,null)}),p(this,hs)&&(p(this,_i).before(p(this,hs)),G(this,hs,null)))};function Ev(e,t,i,s){const r=_a;var n=e.filter(u=>!u.settled);if(i.length===0&&n.length===0){s(t.map(r));return}var o=Ue,a=Dv(),c=n.length===1?n[0].promise:n.length>1?Promise.all(n.map(u=>u.promise)):null;function h(u){a();try{s(u)}catch(f){(o.f&vs)===0&&Hs(f,o)}il()}if(i.length===0){c.then(()=>h(t.map(r)));return}function d(){a(),Promise.all(i.map(u=>Pv(u))).then(u=>h([...t.map(r),...u])).catch(u=>Hs(u,o))}c?c.then(d):d()}function Dv(){var e=Ue,t=Ne,i=_t,s=Re;return function(n=!0){ss(e),Ei(t),pn(i),n&&(s==null||s.activate())}}function il(e=!0){ss(null),Ei(null),pn(null),e&&(Re==null||Re.deactivate())}function Rv(){var e=Ue.b,t=Re,i=e.is_rendered();return e.update_pending_count(1),t.increment(i),()=>{e.update_pending_count(-1),t.decrement(i)}}function _a(e){var t=Bt|Lt,i=Ne!==null&&(Ne.f&Bt)!==0?Ne:null;return Ue!==null&&(Ue.f|=kn),{ctx:_t,deps:null,effects:null,equals:Gu,f:t,fn:e,reactions:null,rv:0,v:Dt,wv:0,parent:i??Ue,ac:null}}function Pv(e,t,i){Ue===null&&H_();var r=void 0,n=Xs(Dt),o=!Ne,a=new Map;return Kv(()=>{var f;var c=Uu();r=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(il)}catch(_){c.reject(_),il()}var h=Re;if(o){var d=Rv();(f=a.get(h))==null||f.reject(rr),a.delete(h),a.set(h,c)}const u=(_,v=void 0)=>{if(h.activate(),v)v!==rr&&(n.f|=Us,gn(n,v));else{(n.f&Us)!==0&&(n.f^=Us),gn(n,_);for(const[m,g]of a){if(a.delete(m),m===h)break;g.reject(rr)}}d&&d()};c.promise.then(u,_=>u(null,_||"unknown"))}),wh(()=>{for(const c of a.values())c.reject(rr)}),new Promise(c=>{function h(d){function u(){d===r?c(n):h(r)}d.then(u,u)}h(r)})}function ce(e){const t=_a(e);return Rd(t),t}function ld(e){const t=_a(e);return t.equals=Xu,t}function Tv(e){var t=e.effects;if(t!==null){e.effects=null;for(var i=0;i<t.length;i+=1)$t(t[i])}}function Mv(e){for(var t=e.parent;t!==null;){if((t.f&Bt)===0)return(t.f&vs)===0?t:null;t=t.parent}return null}function bh(e){var t,i=Ue;ss(Mv(e));try{e.f&=~Tr,Tv(e),t=Bd(e)}finally{ss(i)}return t}function hd(e){var t=bh(e);if(!e.equals(t)&&(e.wv=Td(),(!(Re!=null&&Re.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){ht(e,xt);return}Qs||(Tt!==null?(yh()||Re!=null&&Re.is_fork)&&Tt.set(e,t):mh(e))}function Bv(e){var t,i;if(e.effects!==null)for(const s of e.effects)(s.teardown||s.ac)&&((t=s.teardown)==null||t.call(s),(i=s.ac)==null||i.abort(rr),s.teardown=O_,s.ac=null,Xn(s,0),Ch(s))}function cd(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&mn(t)}let sl=new Set;const qs=new Map;let ud=!1;function Xs(e,t){var i={f:0,v:e,reactions:null,equals:Gu,rv:0,wv:0};return i}function I(e,t){const i=Xs(e);return Rd(i),i}function Lv(e,t=!1,i=!0){const s=Xs(e);return t||(s.equals=Xu),s}function b(e,t,i=!1){Ne!==null&&(!Wi||(Ne.f&Jh)!==0)&&Ju()&&(Ne.f&(Bt|Ss|ph|Jh))!==0&&(ki===null||!vn.call(ki,e))&&X_();let s=i?Xe(t):t;return gn(e,s)}function gn(e,t){if(!e.equals(t)){var i=e.v;Qs?qs.set(e,t):qs.set(e,i),e.v=t;var s=Ks.ensure();if(s.capture(e,i),(e.f&Bt)!==0){const r=e;(e.f&Lt)!==0&&bh(r),mh(r)}e.wv=Td(),dd(e,Lt),Ue!==null&&(Ue.f&xt)!==0&&(Ue.f&(Ki|Ar))===0&&(fi===null?jv([e]):fi.push(e)),!s.is_fork&&sl.size>0&&!ud&&Av()}return t}function Av(){ud=!1;for(const e of sl)(e.f&xt)!==0&&ht(e,zi),mo(e)&&mn(e);sl.clear()}function js(e){b(e,e.v+1)}function dd(e,t){var i=e.reactions;if(i!==null)for(var s=i.length,r=0;r<s;r++){var n=i[r],o=n.f,a=(o&Lt)===0;if(a&&ht(n,t),(o&Bt)!==0){var c=n;Tt==null||Tt.delete(c),(o&Tr)===0&&(o&Ci&&(n.f|=Tr),dd(c,zi))}else a&&((o&Ss)!==0&&Mi!==null&&Mi.add(n),Fi(n))}}function Xe(e){if(typeof e!="object"||e===null||kr in e)return e;const t=zu(e);if(t!==L_&&t!==A_)return e;var i=new Map,s=vh(e),r=I(0),n=ms,o=a=>{if(ms===n)return a();var c=Ne,h=ms;Ei(null),ic(n);var d=a();return Ei(c),ic(h),d};return s&&i.set("length",I(e.length)),new Proxy(e,{defineProperty(a,c,h){(!("value"in h)||h.configurable===!1||h.enumerable===!1||h.writable===!1)&&Y_();var d=i.get(c);return d===void 0?o(()=>{var u=I(h.value);return i.set(c,u),u}):b(d,h.value,!0),!0},deleteProperty(a,c){var h=i.get(c);if(h===void 0){if(c in a){const d=o(()=>I(Dt));i.set(c,d),js(r)}}else b(h,Dt),js(r);return!0},get(a,c,h){var _;if(c===kr)return e;var d=i.get(c),u=c in a;if(d===void 0&&(!u||(_=Kr(a,c))!=null&&_.writable)&&(d=o(()=>{var v=Xe(u?a[c]:Dt),m=I(v);return m}),i.set(c,d)),d!==void 0){var f=l(d);return f===Dt?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!==Dt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return h},has(a,c){var f;if(c===kr)return!0;var h=i.get(c),d=h!==void 0&&h.v!==Dt||Reflect.has(a,c);if(h!==void 0||Ue!==null&&(!d||(f=Kr(a,c))!=null&&f.writable)){h===void 0&&(h=o(()=>{var _=d?Xe(a[c]):Dt,v=I(_);return v}),i.set(c,h));var u=l(h);if(u===Dt)return!1}return d},set(a,c,h,d){var k;var u=i.get(c),f=c in a;if(s&&c==="length")for(var _=h;_<u.v;_+=1){var v=i.get(_+"");v!==void 0?b(v,Dt):_ in a&&(v=o(()=>I(Dt)),i.set(_+"",v))}if(u===void 0)(!f||(k=Kr(a,c))!=null&&k.writable)&&(u=o(()=>I(void 0)),b(u,Xe(h)),i.set(c,u));else{f=u.v!==Dt;var m=o(()=>Xe(h));b(u,m)}var g=Reflect.getOwnPropertyDescriptor(a,c);if(g!=null&&g.set&&g.set.call(d,h),!f){if(s&&typeof c=="string"){var y=i.get("length"),C=Number(c);Number.isInteger(C)&&C>=y.v&&b(y,C+1)}js(r)}return!0},ownKeys(a){l(r);var c=Reflect.ownKeys(a).filter(u=>{var f=i.get(u);return f===void 0||f.v!==Dt});for(var[h,d]of i)d.v!==Dt&&!(h in a)&&c.push(h);return c},setPrototypeOf(){G_()}})}function $h(e){try{if(e!==null&&typeof e=="object"&&kr in e)return e[kr]}catch{}return e}function Ov(e,t){return Object.is($h(e),$h(t))}var Xo,fd,_d,vd,pd;function Iv(){if(Xo===void 0){Xo=window,fd=document,_d=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,i=Text.prototype;vd=Kr(t,"firstChild").get,pd=Kr(t,"nextSibling").get,Qh(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Qh(i)&&(i.__t=void 0)}}function ps(e=""){return document.createTextNode(e)}function gs(e){return vd.call(e)}function go(e){return pd.call(e)}function S(e,t){return gs(e)}function pt(e,t=!1){{var i=gs(e);return i instanceof Comment&&i.data===""?go(i):i}}function x(e,t=1,i=!1){let s=e;for(;t--;)s=go(s);return s}function Nv(e){e.textContent=""}function gd(){return!1}function md(e,t,i){return document.createElementNS(t??Yu,e,void 0)}function Fv(e,t){{const i=document.body;e.autofocus=!0,ts(()=>{document.activeElement===i&&e.focus()})}}let ec=!1;function Wv(){ec||(ec=!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 va(e){var t=Ne,i=Ue;Ei(null),ss(null);try{return e()}finally{Ei(t),ss(i)}}function Sh(e,t,i,s=i){e.addEventListener(t,()=>va(i));const r=e.__on_r;r?e.__on_r=()=>{r(),s(!0)}:e.__on_r=()=>s(!0),Wv()}function bd(e){Ue===null&&(Ne===null&&q_(),K_()),Qs&&U_()}function Hv(e,t){var i=t.last;i===null?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}function ns(e,t,i){var s=Ue;s!==null&&(s.f&ai)!==0&&(e|=ai);var r={ctx:_t,deps:null,nodes:null,f:e|Lt|Ci,first:null,fn:t,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,wv:0,ac:null};if(i)try{mn(r)}catch(a){throw $t(r),a}else t!==null&&Fi(r);var n=r;if(i&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&kn)===0&&(n=n.first,(e&Ss)!==0&&(e&Pr)!==0&&n!==null&&(n.f|=Pr)),n!==null&&(n.parent=s,s!==null&&Hv(n,s),Ne!==null&&(Ne.f&Bt)!==0&&(e&Ar)===0)){var o=Ne;(o.effects??(o.effects=[])).push(n)}return r}function yh(){return Ne!==null&&!Wi}function wh(e){const t=ns(po,null,!1);return ht(t,xt),t.teardown=e,t}function Ui(e){bd();var t=Ue.f,i=!Ne&&(t&Ki)!==0&&(t&Rr)===0;if(i){var s=_t;(s.e??(s.e=[])).push(e)}else return Sd(e)}function Sd(e){return ns(vo|ju,e,!1)}function zv(e){return bd(),ns(po|ju,e,!0)}function Uv(e){Ks.ensure();const t=ns(Ar|kn,e,!0);return(i={})=>new Promise(s=>{i.outro?xr(t,()=>{$t(t),s(void 0)}):($t(t),s(void 0))})}function yd(e){return ns(vo,e,!1)}function Kv(e){return ns(ph|kn,e,!0)}function pa(e,t=0){return ns(po|t,e,!0)}function re(e,t=[],i=[],s=[]){Ev(s,t,i,r=>{ns(po,()=>e(...r.map(l)),!0)})}function ga(e,t=0){var i=ns(Ss|t,e,!0);return i}function mi(e){return ns(Ki|kn,e,!0)}function wd(e){var t=e.teardown;if(t!==null){const i=Qs,s=Ne;tc(!0),Ei(null);try{t.call(null)}finally{tc(i),Ei(s)}}}function Ch(e,t=!1){var i=e.first;for(e.first=e.last=null;i!==null;){const r=i.ac;r!==null&&va(()=>{r.abort(rr)});var s=i.next;(i.f&Ar)!==0?i.parent=null:$t(i,t),i=s}}function qv(e){for(var t=e.first;t!==null;){var i=t.next;(t.f&Ki)===0&&$t(t),t=i}}function $t(e,t=!0){var i=!1;(t||(e.f&qu)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Cd(e.nodes.start,e.nodes.end),i=!0),Ch(e,t&&!i),Xn(e,0),ht(e,vs);var s=e.nodes&&e.nodes.t;if(s!==null)for(const n of s)n.stop();wd(e);var r=e.parent;r!==null&&r.first!==null&&kd(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Cd(e,t){for(;e!==null;){var i=e===t?null:go(e);e.remove(),e=i}}function kd(e){var t=e.parent,i=e.prev,s=e.next;i!==null&&(i.next=s),s!==null&&(s.prev=i),t!==null&&(t.first===e&&(t.first=s),t.last===e&&(t.last=i))}function xr(e,t,i=!0){var s=[];xd(e,s,!0);var r=()=>{i&&$t(e),t&&t()},n=s.length;if(n>0){var o=()=>--n||r();for(var a of s)a.out(o)}else r()}function xd(e,t,i){if((e.f&ai)===0){e.f^=ai;var s=e.nodes&&e.nodes.t;if(s!==null)for(const a of s)(a.is_global||i)&&t.push(a);for(var r=e.first;r!==null;){var n=r.next,o=(r.f&Pr)!==0||(r.f&Ki)!==0&&(e.f&Ss)!==0;xd(r,t,o?i:!1),r=n}}}function kh(e){Ed(e,!0)}function Ed(e,t){if((e.f&ai)!==0){e.f^=ai,(e.f&xt)===0&&(ht(e,Lt),Fi(e));for(var i=e.first;i!==null;){var s=i.next,r=(i.f&Pr)!==0||(i.f&Ki)!==0;Ed(i,r?t:!1),i=s}var n=e.nodes&&e.nodes.t;if(n!==null)for(const o of n)(o.is_global||t)&&o.in()}}function Dd(e,t){if(e.nodes)for(var i=e.nodes.start,s=e.nodes.end;i!==null;){var r=i===s?null:go(i);t.append(i),i=r}}let Ho=!1,Qs=!1;function tc(e){Qs=e}let Ne=null,Wi=!1;function Ei(e){Ne=e}let Ue=null;function ss(e){Ue=e}let ki=null;function Rd(e){Ne!==null&&(ki===null?ki=[e]:ki.push(e))}let Jt=null,ri=0,fi=null;function jv(e){fi=e}let Pd=1,or=0,ms=or;function ic(e){ms=e}function Td(){return++Pd}function mo(e){var t=e.f;if((t&Lt)!==0)return!0;if(t&Bt&&(e.f&=~Tr),(t&zi)!==0){for(var i=e.deps,s=i.length,r=0;r<s;r++){var n=i[r];if(mo(n)&&hd(n),n.wv>e.wv)return!0}(t&Ci)!==0&&Tt===null&&ht(e,xt)}return!1}function Md(e,t,i=!0){var s=e.reactions;if(s!==null&&!(ki!==null&&vn.call(ki,e)))for(var r=0;r<s.length;r++){var n=s[r];(n.f&Bt)!==0?Md(n,t,!1):t===n&&(i?ht(n,Lt):(n.f&xt)!==0&&ht(n,zi),Fi(n))}}function Bd(e){var m;var t=Jt,i=ri,s=fi,r=Ne,n=ki,o=_t,a=Wi,c=ms,h=e.f;Jt=null,ri=0,fi=null,Ne=(h&(Ki|Ar))===0?e:null,ki=null,pn(e.ctx),Wi=!1,ms=++or,e.ac!==null&&(va(()=>{e.ac.abort(rr)}),e.ac=null);try{e.f|=Xa;var d=e.fn,u=d();e.f|=Rr;var f=e.deps,_=Re==null?void 0:Re.is_fork;if(Jt!==null){var v;if(_||Xn(e,ri),f!==null&&ri>0)for(f.length=ri+Jt.length,v=0;v<Jt.length;v++)f[ri+v]=Jt[v];else e.deps=f=Jt;if(yh()&&(e.f&Ci)!==0)for(v=ri;v<f.length;v++)((m=f[v]).reactions??(m.reactions=[])).push(e)}else!_&&f!==null&&ri<f.length&&(Xn(e,ri),f.length=ri);if(Ju()&&fi!==null&&!Wi&&f!==null&&(e.f&(Bt|zi|Lt))===0)for(v=0;v<fi.length;v++)Md(fi[v],e);if(r!==null&&r!==e){if(or++,r.deps!==null)for(let g=0;g<i;g+=1)r.deps[g].rv=or;if(t!==null)for(const g of t)g.rv=or;fi!==null&&(s===null?s=fi:s.push(...fi))}return(e.f&Us)!==0&&(e.f^=Us),u}catch(g){return ed(g)}finally{e.f^=Xa,Jt=t,ri=i,fi=s,Ne=r,ki=n,pn(o),Wi=a,ms=c}}function Vv(e,t){let i=t.reactions;if(i!==null){var s=T_.call(i,e);if(s!==-1){var r=i.length-1;r===0?i=t.reactions=null:(i[s]=i[r],i.pop())}}if(i===null&&(t.f&Bt)!==0&&(Jt===null||!vn.call(Jt,t))){var n=t;(n.f&Ci)!==0&&(n.f^=Ci,n.f&=~Tr),mh(n),Bv(n),Xn(n,0)}}function Xn(e,t){var i=e.deps;if(i!==null)for(var s=t;s<i.length;s++)Vv(e,i[s])}function mn(e){var t=e.f;if((t&vs)===0){ht(e,xt);var i=Ue,s=Ho;Ue=e,Ho=!0;try{(t&(Ss|Ku))!==0?qv(e):Ch(e),wd(e);var r=Bd(e);e.teardown=typeof r=="function"?r:null,e.wv=Pd;var n;Ya&&dv&&(e.f&Lt)!==0&&e.deps}finally{Ho=s,Ue=i}}}async function Yv(){await Promise.resolve(),gv()}function l(e){var t=e.f,i=(t&Bt)!==0;if(Ne!==null&&!Wi){var s=Ue!==null&&(Ue.f&vs)!==0;if(!s&&(ki===null||!vn.call(ki,e))){var r=Ne.deps;if((Ne.f&Xa)!==0)e.rv<or&&(e.rv=or,Jt===null&&r!==null&&r[ri]===e?ri++:Jt===null?Jt=[e]:Jt.push(e));else{(Ne.deps??(Ne.deps=[])).push(e);var n=e.reactions;n===null?e.reactions=[Ne]:vn.call(n,Ne)||n.push(Ne)}}}if(Qs&&qs.has(e))return qs.get(e);if(i){var o=e;if(Qs){var a=o.v;return((o.f&xt)===0&&o.reactions!==null||Ad(o))&&(a=bh(o)),qs.set(o,a),a}var c=(o.f&Ci)===0&&!Wi&&Ne!==null&&(Ho||(Ne.f&Ci)!==0),h=(o.f&Rr)===0;mo(o)&&(c&&(o.f|=Ci),hd(o)),c&&!h&&(cd(o),Ld(o))}if(Tt!=null&&Tt.has(e))return Tt.get(e);if((e.f&Us)!==0)throw e.v;return e.v}function Ld(e){if(e.f|=Ci,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&Bt)!==0&&(t.f&Ci)===0&&(cd(t),Ld(t))}function Ad(e){if(e.v===Dt)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(qs.has(t)||(t.f&Bt)!==0&&Ad(t))return!0;return!1}function Js(e){var t=Wi;try{return Wi=!0,e()}finally{Wi=t}}const Gv=["touchstart","touchmove"];function Xv(e){return Gv.includes(e)}const ar=Symbol("events"),Od=new Set,rl=new Set;function Qv(e,t,i,s={}){function r(n){if(s.capture||nl.call(t,n),!n.cancelBubble)return va(()=>i==null?void 0:i.call(this,n))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?ts(()=>{t.addEventListener(e,r,s)}):t.addEventListener(e,r,s),r}function $i(e,t,i,s,r){var n={capture:s,passive:r},o=Qv(e,t,i,n);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&wh(()=>{t.removeEventListener(e,o,n)})}function X(e,t,i){(t[ar]??(t[ar]={}))[e]=i}function Ze(e){for(var t=0;t<e.length;t++)Od.add(e[t]);for(var i of rl)i(e)}let sc=null;function nl(e){var g,y;var t=this,i=t.ownerDocument,s=e.type,r=((g=e.composedPath)==null?void 0:g.call(e))||[],n=r[0]||e.target;sc=e;var o=0,a=sc===e&&e[ar];if(a){var c=r.indexOf(a);if(c!==-1&&(t===document||t===window)){e[ar]=t;return}var h=r.indexOf(t);if(h===-1)return;c<=h&&(o=c)}if(n=r[o]||e.target,n!==t){M_(e,"currentTarget",{configurable:!0,get(){return n||i}});var d=Ne,u=Ue;Ei(null),ss(null);try{for(var f,_=[];n!==null;){var v=n.assignedSlot||n.parentNode||n.host||null;try{var m=(y=n[ar])==null?void 0:y[s];m!=null&&(!n.disabled||e.target===n)&&m.call(n,e)}catch(C){f?_.push(C):f=C}if(e.cancelBubble||v===t||v===null)break;n=v}if(f){for(let C of _)queueMicrotask(()=>{throw C});throw f}}finally{e[ar]=t,delete e.currentTarget,Ei(d),ss(u)}}}var Eu;const Ea=((Eu=globalThis==null?void 0:globalThis.window)==null?void 0:Eu.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Jv(e){return(Ea==null?void 0:Ea.createHTML(e))??e}function Id(e){var t=md("template");return t.innerHTML=Jv(e.replaceAll("<!>","<!---->")),t.content}function bn(e,t){var i=Ue;i.nodes===null&&(i.nodes={start:e,end:t,a:null,t:null})}function L(e,t){var i=(t&nv)!==0,s=(t&ov)!==0,r,n=!e.startsWith("<!>");return()=>{r===void 0&&(r=Id(n?e:"<!>"+e),i||(r=gs(r)));var o=s||_d?document.importNode(r,!0):r.cloneNode(!0);if(i){var a=gs(o),c=o.lastChild;bn(a,c)}else bn(o,o);return o}}function Zv(e,t,i="svg"){var s=!e.startsWith("<!>"),r=`<${i}>${s?e:"<!>"+e}</${i}>`,n;return()=>{if(!n){var o=Id(r),a=gs(o);n=gs(a)}var c=n.cloneNode(!0);return bn(c,c),c}}function $v(e,t){return Zv(e,t,"svg")}function Vs(e=""){{var t=ps(e+"");return bn(t,t),t}}function Hi(){var e=document.createDocumentFragment(),t=document.createComment(""),i=ps();return e.append(t,i),bn(t,i),e}function T(e,t){e!==null&&e.before(t)}function se(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 ep(e,t){return tp(e,t)}const Do=new Map;function tp(e,{target:t,anchor:i,props:s={},events:r,context:n,intro:o=!0,transformError:a}){Iv();var c=void 0,h=Uv(()=>{var d=i??t.appendChild(ps());yv(d,{pending:()=>{}},_=>{Ye({});var v=_t;n&&(v.c=n),r&&(s.$$events=r),c=e(_,s)||{},Ge()},a);var u=new Set,f=_=>{for(var v=0;v<_.length;v++){var m=_[v];if(!u.has(m)){u.add(m);var g=Xv(m);for(const k of[t,document]){var y=Do.get(k);y===void 0&&(y=new Map,Do.set(k,y));var C=y.get(m);C===void 0?(k.addEventListener(m,nl,{passive:g}),y.set(m,1)):y.set(m,C+1)}}}};return f(da(Od)),rl.add(f),()=>{var g;for(var _ of u)for(const y of[t,document]){var v=Do.get(y),m=v.get(_);--m==0?(y.removeEventListener(_,nl),v.delete(_),v.size===0&&Do.delete(y)):v.set(_,m)}rl.delete(f),d!==i&&((g=d.parentNode)==null||g.removeChild(d))}});return ip.set(c,h),c}let ip=new WeakMap;var Li,Xi,oi,_r,ao,lo,ha;class Nd{constructor(t,i=!0){Ri(this,"anchor");$(this,Li,new Map);$(this,Xi,new Map);$(this,oi,new Map);$(this,_r,new Set);$(this,ao,!0);$(this,lo,()=>{var t=Re;if(p(this,Li).has(t)){var i=p(this,Li).get(t),s=p(this,Xi).get(i);if(s)kh(s),p(this,_r).delete(i);else{var r=p(this,oi).get(i);r&&(p(this,Xi).set(i,r.effect),p(this,oi).delete(i),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),s=r.effect)}for(const[n,o]of p(this,Li)){if(p(this,Li).delete(n),n===t)break;const a=p(this,oi).get(o);a&&($t(a.effect),p(this,oi).delete(o))}for(const[n,o]of p(this,Xi)){if(n===i||p(this,_r).has(n))continue;const a=()=>{if(Array.from(p(this,Li).values()).includes(n)){var h=document.createDocumentFragment();Dd(o,h),h.append(ps()),p(this,oi).set(n,{effect:o,fragment:h})}else $t(o);p(this,_r).delete(n),p(this,Xi).delete(n)};p(this,ao)||!s?(p(this,_r).add(n),xr(o,a,!1)):a()}}});$(this,ha,t=>{p(this,Li).delete(t);const i=Array.from(p(this,Li).values());for(const[s,r]of p(this,oi))i.includes(s)||($t(r.effect),p(this,oi).delete(s))});this.anchor=t,G(this,ao,i)}ensure(t,i){var s=Re,r=gd();if(i&&!p(this,Xi).has(t)&&!p(this,oi).has(t))if(r){var n=document.createDocumentFragment(),o=ps();n.append(o),p(this,oi).set(t,{effect:mi(()=>i(o)),fragment:n})}else p(this,Xi).set(t,mi(()=>i(this.anchor)));if(p(this,Li).set(s,t),r){for(const[a,c]of p(this,Xi))a===t?s.unskip_effect(c):s.skip_effect(c);for(const[a,c]of p(this,oi))a===t?s.unskip_effect(c.effect):s.skip_effect(c.effect);s.oncommit(p(this,lo)),s.ondiscard(p(this,ha))}else p(this,lo).call(this)}}Li=new WeakMap,Xi=new WeakMap,oi=new WeakMap,_r=new WeakMap,ao=new WeakMap,lo=new WeakMap,ha=new WeakMap;function ee(e,t,i=!1){var s=new Nd(e),r=i?Pr:0;function n(o,a){s.ensure(o,a)}ga(()=>{var o=!1;t((a,c=0)=>{o=!0,n(c,a)}),o||n(!1,null)},r)}function Sn(e,t){return t}function sp(e,t,i){for(var s=[],r=t.length,n,o=t.length,a=0;a<r;a++){let u=t[a];xr(u,()=>{if(n){if(n.pending.delete(u),n.done.add(u),n.pending.size===0){var f=e.outrogroups;ol(da(n.done)),f.delete(n),f.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var c=s.length===0&&i!==null;if(c){var h=i,d=h.parentNode;Nv(d),d.append(h),e.items.clear()}ol(t,!c)}else n={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(n)}function ol(e,t=!0){for(var i=0;i<e.length;i++)$t(e[i],t)}var rc;function vt(e,t,i,s,r,n=null){var o=e,a=new Map,c=(t&Vu)!==0;if(c){var h=e;o=h.appendChild(ps())}var d=null,u=ld(()=>{var y=i();return vh(y)?y:y==null?[]:da(y)}),f,_=!0;function v(){g.fallback=d,rp(g,f,o,t,s),d!==null&&(f.length===0?(d.f&fs)===0?kh(d):(d.f^=fs,In(d,null,o)):xr(d,()=>{d=null}))}var m=ga(()=>{f=l(u);for(var y=f.length,C=new Set,k=Re,w=gd(),D=0;D<y;D+=1){var F=f[D],z=s(F,D),N=_?null:a.get(z);N?(N.v&&gn(N.v,F),N.i&&gn(N.i,D),w&&k.unskip_effect(N.e)):(N=np(a,_?o:rc??(rc=ps()),F,z,D,r,t,i),_||(N.e.f|=fs),a.set(z,N)),C.add(z)}if(y===0&&n&&!d&&(_?d=mi(()=>n(o)):(d=mi(()=>n(rc??(rc=ps()))),d.f|=fs)),y>C.size&&z_(),!_)if(w){for(const[U,Y]of a)C.has(U)||k.skip_effect(Y.e);k.oncommit(v),k.ondiscard(()=>{})}else v();l(u)}),g={effect:m,items:a,outrogroups:null,fallback:d};_=!1}function Pn(e){for(;e!==null&&(e.f&Ki)===0;)e=e.next;return e}function rp(e,t,i,s,r){var Y,K,W,O,A,E,B,R,P;var n=(s&$_)!==0,o=t.length,a=e.items,c=Pn(e.effect.first),h,d=null,u,f=[],_=[],v,m,g,y;if(n)for(y=0;y<o;y+=1)v=t[y],m=r(v,y),g=a.get(m).e,(g.f&fs)===0&&((K=(Y=g.nodes)==null?void 0:Y.a)==null||K.measure(),(u??(u=new Set)).add(g));for(y=0;y<o;y+=1){if(v=t[y],m=r(v,y),g=a.get(m).e,e.outrogroups!==null)for(const H of e.outrogroups)H.pending.delete(g),H.done.delete(g);if((g.f&fs)!==0)if(g.f^=fs,g===c)In(g,null,i);else{var C=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),ks(e,d,g),ks(e,g,C),In(g,C,i),d=g,f=[],_=[],c=Pn(d.next);continue}if((g.f&ai)!==0&&(kh(g),n&&((O=(W=g.nodes)==null?void 0:W.a)==null||O.unfix(),(u??(u=new Set)).delete(g))),g!==c){if(h!==void 0&&h.has(g)){if(f.length<_.length){var k=_[0],w;d=k.prev;var D=f[0],F=f[f.length-1];for(w=0;w<f.length;w+=1)In(f[w],k,i);for(w=0;w<_.length;w+=1)h.delete(_[w]);ks(e,D.prev,F.next),ks(e,d,D),ks(e,F,k),c=k,d=F,y-=1,f=[],_=[]}else h.delete(g),In(g,c,i),ks(e,g.prev,g.next),ks(e,g,d===null?e.effect.first:d.next),ks(e,d,g),d=g;continue}for(f=[],_=[];c!==null&&c!==g;)(h??(h=new Set)).add(c),_.push(c),c=Pn(c.next);if(c===null)continue}(g.f&fs)===0&&f.push(g),d=g,c=Pn(g.next)}if(e.outrogroups!==null){for(const H of e.outrogroups)H.pending.size===0&&(ol(da(H.done)),(A=e.outrogroups)==null||A.delete(H));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||h!==void 0){var z=[];if(h!==void 0)for(g of h)(g.f&ai)===0&&z.push(g);for(;c!==null;)(c.f&ai)===0&&c!==e.fallback&&z.push(c),c=Pn(c.next);var N=z.length;if(N>0){var U=(s&Vu)!==0&&o===0?i:null;if(n){for(y=0;y<N;y+=1)(B=(E=z[y].nodes)==null?void 0:E.a)==null||B.measure();for(y=0;y<N;y+=1)(P=(R=z[y].nodes)==null?void 0:R.a)==null||P.fix()}sp(e,z,U)}}n&&ts(()=>{var H,Z;if(u!==void 0)for(g of u)(Z=(H=g.nodes)==null?void 0:H.a)==null||Z.apply()})}function np(e,t,i,s,r,n,o,a){var c=(o&J_)!==0?(o&ev)===0?Lv(i,!1,!1):Xs(i):null,h=(o&Z_)!==0?Xs(r):null;return{v:c,i:h,e:mi(()=>(n(t,c??i,h??r,a),()=>{e.delete(s)}))}}function In(e,t,i){if(e.nodes)for(var s=e.nodes.start,r=e.nodes.end,n=t&&(t.f&fs)===0?t.nodes.start:i;s!==null;){var o=go(s);if(n.before(s),s===r)return;s=o}}function ks(e,t,i){t===null?e.effect.first=i:t.next=i,i===null?e.effect.last=t:i.prev=t}function al(e,t,i=!1,s=!1,r=!1){var n=e,o="";re(()=>{var a=Ue;if(o!==(o=t()??"")&&(a.nodes!==null&&(Cd(a.nodes.start,a.nodes.end),a.nodes=null),o!=="")){var c=i?av:s?lv:void 0,h=md(i?"svg":s?"math":"template",c);h.innerHTML=o;var d=i||s?h:h.content;if(bn(gs(d),d.lastChild),i||s)for(;gs(d);)n.before(gs(d));else n.before(d)}})}function op(e,t,...i){var s=new Nd(e);ga(()=>{const r=t()??null;s.ensure(r,r&&(n=>r(n,...i)))},Pr)}function Fd(e){var t,i,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(i=Fd(e[t]))&&(s&&(s+=" "),s+=i)}else for(i in e)e[i]&&(s&&(s+=" "),s+=i);return s}function ap(){for(var e,t,i=0,s="",r=arguments.length;i<r;i++)(e=arguments[i])&&(t=Fd(e))&&(s&&(s+=" "),s+=t);return s}function Wd(e){return typeof e=="object"?ap(e):e??""}const nc=[...`
2
- \r\f \v\uFEFF`];function lp(e,t,i){var s=e==null?"":""+e;if(t&&(s=s?s+" "+t:t),i){for(var r of Object.keys(i))if(i[r])s=s?s+" "+r:r;else if(s.length)for(var n=r.length,o=0;(o=s.indexOf(r,o))>=0;){var a=o+n;(o===0||nc.includes(s[o-1]))&&(a===s.length||nc.includes(s[a]))?s=(o===0?"":s.substring(0,o))+s.substring(a+1):o=a}}return s===""?null:s}function oc(e,t=!1){var i=t?" !important;":";",s="";for(var r of Object.keys(e)){var n=e[r];n!=null&&n!==""&&(s+=" "+r+": "+n+i)}return s}function Da(e){return e[0]!=="-"||e[1]!=="-"?e.toLowerCase():e}function hp(e,t){if(t){var i="",s,r;if(Array.isArray(t)?(s=t[0],r=t[1]):s=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,a=!1,c=[];s&&c.push(...Object.keys(s).map(Da)),r&&c.push(...Object.keys(r).map(Da));var h=0,d=-1;const m=e.length;for(var u=0;u<m;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===m-1){if(d!==-1){var _=Da(e.substring(h,d).trim());if(!c.includes(_)){f!==";"&&u++;var v=e.substring(h,u).trim();i+=" "+v+";"}}h=u+1,d=-1}}}}return s&&(i+=oc(s)),r&&(i+=oc(r,!0)),i=i.trim(),i===""?null:i}return e==null?null:String(e)}function et(e,t,i,s,r,n){var o=e.__className;if(o!==i||o===void 0){var a=lp(i,s,n);a==null?e.removeAttribute("class"):t?e.className=a:e.setAttribute("class",a),e.__className=i}else if(n&&r!==n)for(var c in n){var h=!!n[c];(r==null||h!==!!r[c])&&e.classList.toggle(c,h)}return n}function Ra(e,t={},i,s){for(var r in i){var n=i[r];t[r]!==n&&(i[r]==null?e.style.removeProperty(r):e.style.setProperty(r,n,s))}}function Or(e,t,i,s){var r=e.__style;if(r!==t){var n=hp(t,s);n==null?e.removeAttribute("style"):e.style.cssText=n,e.__style=t}else s&&(Array.isArray(s)?(Ra(e,i==null?void 0:i[0],s[0]),Ra(e,i==null?void 0:i[1],s[1],"important")):Ra(e,i,s));return s}function Hd(e,t,i=!1){if(e.multiple){if(t==null)return;if(!vh(t))return hv();for(var s of e.options)s.selected=t.includes(qn(s));return}for(s of e.options){var r=qn(s);if(Ov(r,t)){s.selected=!0;return}}(!i||t!==void 0)&&(e.selectedIndex=-1)}function cp(e){var t=new MutationObserver(()=>{Hd(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),wh(()=>{t.disconnect()})}function Qo(e,t,i=t){var s=new WeakSet,r=!0;Sh(e,"change",n=>{var o=n?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(o),qn);else{var c=e.querySelector(o)??e.querySelector("option:not([disabled])");a=c&&qn(c)}i(a),Re!==null&&s.add(Re)}),yd(()=>{var n=t();if(e===document.activeElement){var o=Go??Re;if(s.has(o))return}if(Hd(e,n,r),r&&n===void 0){var a=e.querySelector(":checked");a!==null&&(n=qn(a),i(n))}e.__value=n,r=!1}),cp(e)}function qn(e){return"__value"in e?e.__value:e.value}const up=Symbol("is custom element"),dp=Symbol("is html"),fp=W_?"progress":"PROGRESS";function _p(e,t){var i=xh(e);i.value===(i.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==fp)||(e.value=t??"")}function vp(e,t){var i=xh(e);i.checked!==(i.checked=t??void 0)&&(e.checked=t)}function Me(e,t,i,s){var r=xh(e);r[t]!==(r[t]=i)&&(t==="loading"&&(e[F_]=i),i==null?e.removeAttribute(t):typeof i!="string"&&pp(e).includes(t)?e[t]=i:e.setAttribute(t,i))}function xh(e){return e.__attributes??(e.__attributes={[up]:e.nodeName.includes("-"),[dp]:e.namespaceURI===Yu})}var ac=new Map;function pp(e){var t=e.getAttribute("is")||e.nodeName,i=ac.get(t);if(i)return i;ac.set(t,i=[]);for(var s,r=e,n=Element.prototype;n!==r;){s=B_(r);for(var o in s)s[o].set&&i.push(o);r=zu(r)}return i}function yi(e,t,i=t){var s=new WeakSet;Sh(e,"input",async r=>{var n=r?e.defaultValue:e.value;if(n=Pa(e)?Ta(n):n,i(n),Re!==null&&s.add(Re),await Yv(),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))}}}),Js(t)==null&&e.value&&(i(Pa(e)?Ta(e.value):e.value),Re!==null&&s.add(Re)),pa(()=>{var r=t();if(e===document.activeElement){var n=Go??Re;if(s.has(n))return}Pa(e)&&r===Ta(e.value)||e.type==="date"&&!r&&!e.value||r!==e.value&&(e.value=r??"")})}function Ni(e,t,i=t){Sh(e,"change",s=>{var r=s?e.defaultChecked:e.checked;i(r)}),Js(t)==null&&i(e.checked),pa(()=>{var s=t();e.checked=!!s})}function Pa(e){var t=e.type;return t==="number"||t==="range"}function Ta(e){return e===""?null:+e}function lc(e,t){return e===t||(e==null?void 0:e[kr])===t}function Je(e={},t,i,s){return yd(()=>{var r,n;return pa(()=>{r=n,n=[],Js(()=>{e!==i(...n)&&(t(e,...n),r&&lc(i(...r),e)&&t(null,...r))})}),()=>{ts(()=>{n&&lc(i(...n),e)&&t(null,...n)})}}),e}let Ro=!1;function gp(e){var t=Ro;try{return Ro=!1,[e(),Ro]}finally{Ro=t}}function Kt(e,t,i,s){var C;var r=(i&sv)!==0,n=(i&rv)!==0,o=s,a=!0,c=()=>(a&&(a=!1,o=n?Js(s):s),o),h;if(r){var d=kr in e||N_ in e;h=((C=Kr(e,t))==null?void 0:C.set)??(d&&t in e?k=>e[t]=k:void 0)}var u,f=!1;r?[u,f]=gp(()=>e[t]):u=e[t],u===void 0&&s!==void 0&&(u=c(),h&&(V_(),h(u)));var _;if(_=()=>{var k=e[t];return k===void 0?c():(a=!0,k)},(i&iv)===0)return _;if(h){var v=e.$$legacy;return(function(k,w){return arguments.length>0?((!w||v||f)&&h(w?_():k),k):_()})}var m=!1,g=((i&tv)!==0?_a:ld)(()=>(m=!1,_()));r&&l(g);var y=Ue;return(function(k,w){if(arguments.length>0){const D=w?l(g):r?Xe(k):k;return b(g,D),m=!0,o!==void 0&&(o=D),k}return Qs&&m||(y.f&vs)!==0?g.v:l(g)})}function xn(e){_t===null&&gh(),Ui(()=>{const t=Js(e);if(typeof t=="function")return t})}function mp(e){_t===null&&gh(),xn(()=>()=>Js(e))}const bp="5";var Du;typeof window<"u"&&((Du=window.__svelte??(window.__svelte={})).v??(Du.v=new Set)).add(bp);class zd extends Error{constructor(i){super("conflict");Ri(this,"sessionId");this.name="ConflictError",this.sessionId=i}}async function Ft(e){if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function Sp(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 yp(){return(await fetch("/sessions")).ok}async function wp(){return Ft(await fetch("/sessions"))}async function Cp(){return Ft(await fetch("/worktrees"))}async function kp(){return(await Ft(await fetch("/workspaces"))).workspaces}async function hc(e,t){const i=new URLSearchParams;return e&&i.set("path",e),Ft(await fetch("/workspaces/browse?"+i.toString()))}async function xp(e){return Ft(await fetch("/workspaces/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))}async function Ep(e){var i,s;const t=await Ft(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:!((s=t.pullRequests)!=null&&s.error)}}async function Dp(e,t){const i=await fetch("/workspaces/ci-status?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function Rp(e,t){const i=await fetch("/workspaces/pr?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function Pp(e){return(await Ft(await fetch("/workspaces/current-branch?path="+encodeURIComponent(e)))).branch}async function cc(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 s=await i.json();throw new Error(s.error||"Failed to create worktree")}return i.json()}async function Tp(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 Eh(e,t={}){const i=new URLSearchParams({repo:e});return t.refresh&&i.set("refresh","1"),Ft(await fetch("/branches?"+i.toString()))}async function qr(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 zd(i.sessionId??"")}return Ft(t)}async function Mp(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 zd(i.sessionId??"")}return Ft(t)}async function Bp(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 s=await i.json();throw new Error(s.error||"Failed to delete worktree")}}async function Lp(e,t,i){return Ft(await fetch("/sessions/"+e+"/image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t,mimeType:i})}))}async function Ud(){return Ft(await fetch("/version"))}async function Kd(){return Ft(await fetch("/update",{method:"POST"}))}async function Ap(){return(await Ft(await fetch("/config/defaultAgent"))).defaultAgent}async function Op(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 ma(e){return(await Ft(await fetch(`/config/${e}`)))[e]}async function ba(e,t){const i=await fetch(`/config/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(!i.ok){const s=await i.json();throw new Error(s.error||`Failed to update ${e}`)}}const Ip=()=>ma("defaultContinue"),Np=e=>ba("defaultContinue",e),Fp=()=>ma("defaultYolo"),Wp=e=>ba("defaultYolo",e),Hp=()=>ma("launchInTmux"),zp=e=>ba("launchInTmux",e),Up=()=>ma("defaultNotifications"),Kp=e=>ba("defaultNotifications",e);async function qp(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 ll(e){return Ft(await fetch("/workspaces/settings?path="+encodeURIComponent(e)))}async function jp(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 s=await i.json();throw new Error(s.error||"Failed to update workspace settings")}}let Jo=I(!1),hl=I(null),cl=I(!0);function qd(){return{get authenticated(){return l(Jo)},get pinError(){return l(hl)},get checking(){return l(cl)}}}async function Vp(){b(cl,!0);try{b(Jo,await yp(),!0)}catch{b(Jo,!1)}finally{b(cl,!1)}}async function Yp(e){b(hl,null);try{await Sp(e),b(Jo,!0)}catch(t){b(hl,t instanceof Error?t.message:"Authentication failed",!0)}}const jd="claude-remote-sidebar-width",Vd="claude-remote-sidebar-collapsed",ul="claude-remote-active-workspace",Yd=240,Gd=180,Xd=500,Gp=44;function Xp(){try{const e=localStorage.getItem(jd);if(e){const t=parseInt(e,10);if(t>=Gd&&t<=Xd)return t}}catch{}return Yd}function Qp(){try{return localStorage.getItem(Vd)==="true"}catch{return!1}}function Jp(){try{return localStorage.getItem(ul)}catch{return null}}let Zo=I(!1),dl=I(Xe(Xp())),jn=I(Xe(Qp())),uc=I(""),dc=I(Xe(Jp()));function Qd(){return{get sidebarOpen(){return l(Zo)},set sidebarOpen(e){b(Zo,e,!0)},get sidebarWidth(){return l(dl)},set sidebarWidth(e){b(dl,e,!0)},get sidebarCollapsed(){return l(jn)},set sidebarCollapsed(e){b(jn,e,!0)},get searchQuery(){return l(uc)},set searchQuery(e){b(uc,e,!0)},get activeWorkspacePath(){return l(dc)},set activeWorkspacePath(e){b(dc,e,!0);try{e===null?localStorage.removeItem(ul):localStorage.setItem(ul,e)}catch{}}}}function fc(){b(Zo,!0)}function pi(){b(Zo,!1)}function _c(){try{localStorage.setItem(jd,String(l(dl)))}catch{}}function Ma(){b(jn,!l(jn));try{localStorage.setItem(Vd,String(l(jn)))}catch{}}let Vn=null,Zp=null;function $p(e){Vn=e,"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const i=t.data;i.type==="notification-click"&&i.sessionId&&Vn&&Vn(i.sessionId,i.sessionType||"repo")})}function eg(){return document.hidden||!document.hasFocus()}function tg(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(),Vn&&Vn(e.id,e.type),t.close()}}function Jd(){return"serviceWorker"in navigator&&"PushManager"in window}async function ig(){if(Jd())try{Zp=await navigator.serviceWorker.register("/sw.js")}catch{return}}async function sg(e){if(Jd())try{const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();i&&await qp(i.toJSON(),e)}catch{}}const Zd="claude-remote-notifications",fl="claude-remote-active-session";function rg(){try{return localStorage.getItem(fl)}catch{return null}}function $d(e){try{e===null?localStorage.removeItem(fl):localStorage.setItem(fl,e)}catch{}}let Qn=I(Xe([])),ef=I(Xe([])),tf=I(Xe([])),jr=I(Xe(rg())),Mr=Xe({}),Jn=Xe({}),Dh=Xe({}),bs=I(Xe({}));try{const e=localStorage.getItem(Zd);e&&b(bs,JSON.parse(e),!0)}catch{}function sf(){try{localStorage.setItem(Zd,JSON.stringify(l(bs)))}catch{}}function Rh(){return{get sessions(){return l(Qn)},get worktrees(){return l(ef)},get workspaces(){return l(tf)},get activeSessionId(){return l(jr)},set activeSessionId(e){b(jr,e,!0),$d(e)},get attentionSessions(){return Mr},get loadingItems(){return Dh},get notificationSessions(){return l(bs)}}}async function Ut(){try{const[e,t,i]=await Promise.all([wp(),Cp(),kp()]);b(Qn,e,!0),b(ef,t,!0),b(tf,i,!0);const s=new Set(l(Qn).map(n=>n.id));l(jr)!==null&&!s.has(l(jr))&&(b(jr,null),$d(null));let r=!1;for(const n of Object.keys(Mr))s.has(n)||delete Mr[n];for(const n of Object.keys(Jn))s.has(n)||delete Jn[n];for(const n of Object.keys(l(bs)))s.has(n)||(delete l(bs)[n],r=!0);r&&sf()}catch{}}function rf(e){return l(Qn).filter(t=>t.repoPath===e||t.repoPath.startsWith(e+"/"))}const ng=3e4;function og(e,t){const i=l(Qn).find(s=>s.id===e);if(i&&(i.idle=t),t&&e!==l(jr)&&(i==null?void 0:i.type)!=="terminal"){const s=Jn[e];if(s&&Date.now()-s<ng)return;delete Jn[e],Mr[e]=!0,i&&l(bs)[e]&&eg()&&tg(i)}else delete Mr[e]}function vc(e){delete Mr[e],Jn[e]=Date.now()}function Po(e,t){e in l(bs)||(l(bs)[e]=t,sf())}function ag(){return Object.entries(l(bs)).filter(([,e])=>e).map(([e])=>e)}function To(e){return Mr[e.id]?"attention":e.idle?"idle":"running"}function lg(e){Dh[e]=!0}function hg(e){delete Dh[e]}const Ph=location.protocol==="https:"?"wss:":"ws:";let er=null,Zt=null,ci=null,wi=null;const _l=30;let Yn=null,Vr=0,zo=0;function nf(e){er&&(er.close(),er=null);const t=Ph+"//"+location.host+"/ws/events";er=new WebSocket(t),er.onmessage=i=>{try{e(JSON.parse(i.data))}catch{}},er.onclose=()=>{setTimeout(()=>nf(e),3e3)},er.onerror=()=>{}}function of(e,t,i,s){Yn&&(clearTimeout(Yn),Yn=null),Vr=0,ci&&(ci.onopen=null,ci.onmessage=null,ci.onclose=null,ci.onerror=null,ci.close(),ci=null),Zt&&(Zt.onclose=null,Zt.close(),Zt=null);const r=Ph+"//"+location.host+"/ws/"+e,n=new WebSocket(r);ci=n,n.onopen=()=>{ci=null,Zt=n,Vr=0,i()},n.onmessage=o=>{t.write(o.data)},n.onclose=o=>{if(ci===n&&(ci=null),!(ci!==n&&Zt!==n)){if(o.code===1e3){t.write(`\r
1
+ var P_=Object.defineProperty;var Xh=e=>{throw TypeError(e)};var T_=(e,t,i)=>t in e?P_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Di=(e,t,i)=>T_(e,typeof t!="symbol"?t+"":t,i),xa=(e,t,i)=>t.has(e)||Xh("Cannot "+i);var p=(e,t,i)=>(xa(e,t,"read from private field"),i?i.call(e):t.get(e)),$=(e,t,i)=>t.has(e)?Xh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),V=(e,t,i,s)=>(xa(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i),ve=(e,t,i)=>(xa(e,t,"access private method"),i);var xo=(e,t,i,s)=>({set _(r){V(e,t,r,i)},get _(){return p(e,t,s)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function i(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=i(r);fetch(r.href,n)}})();const Ya=!1;var vh=Array.isArray,M_=Array.prototype.indexOf,_n=Array.prototype.includes,da=Array.from,B_=Object.defineProperty,Ur=Object.getOwnPropertyDescriptor,L_=Object.getOwnPropertyDescriptors,A_=Object.prototype,O_=Array.prototype,zu=Object.getPrototypeOf,Qh=Object.isExtensible;const I_=()=>{};function N_(e){for(var t=0;t<e.length;t++)e[t]()}function Uu(){var e,t,i=new Promise((s,r)=>{e=s,t=r});return{promise:i,resolve:e,reject:t}}const Lt=2,vo=4,po=8,Ku=1<<24,ys=16,zi=32,Ar=64,Ga=128,wi=512,Et=1024,At=2048,Hi=4096,ai=8192,ps=16384,Rr=32768,Pr=65536,Jh=1<<17,qu=1<<18,Cn=1<<19,ju=1<<20,_s=1<<25,Tr=65536,Xa=1<<21,ph=1<<22,Ks=1<<23,kr=Symbol("$state"),F_=Symbol("legacy props"),W_=Symbol(""),rr=new class extends Error{constructor(){super(...arguments);Di(this,"name","StaleReactionError");Di(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var xu;const H_=!!((xu=globalThis.document)!=null&&xu.contentType)&&globalThis.document.contentType.includes("xml");function gh(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function z_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function U_(e,t,i){throw new Error("https://svelte.dev/e/each_key_duplicate")}function K_(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function q_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function j_(e){throw new Error("https://svelte.dev/e/effect_orphan")}function V_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Y_(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function G_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function X_(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Q_(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function J_(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Z_=1,$_=2,Vu=4,ev=8,tv=16,iv=1,sv=4,rv=8,nv=16,ov=1,av=2,Rt=Symbol(),Yu="http://www.w3.org/1999/xhtml",lv="http://www.w3.org/2000/svg",hv="http://www.w3.org/1998/Math/MathML";function cv(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function uv(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Gu(e){return e===this.v}function dv(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Xu(e){return!dv(e,this.v)}let fv=!1,_t=null;function vn(e){_t=e}function Qu(e){return Zu().get(e)}function _v(e,t){return Zu().set(e,t),t}function je(e,t=!1,i){_t={p:_t,i:!1,c:null,e:null,s:e,x:null,l:null}}function Ve(e){var t=_t,i=t.e;if(i!==null){t.e=null;for(var s of i)Sd(s)}return e!==void 0&&(t.x=e),t.i=!0,_t=t.p,e??{}}function Ju(){return!0}function Zu(e){return _t===null&&gh(),_t.c??(_t.c=new Map(vv(_t)||void 0))}function vv(e){let t=e.p;for(;t!==null;){const i=t.c;if(i!==null)return i;t=t.p}return null}let nr=[];function $u(){var e=nr;nr=[],N_(e)}function is(e){if(nr.length===0&&!Kn){var t=nr;queueMicrotask(()=>{t===nr&&$u()})}nr.push(e)}function pv(){for(;nr.length>0;)$u()}function ed(e){var t=ze;if(t===null)return Ne.f|=Ks,e;if((t.f&Rr)===0&&(t.f&vo)===0)throw e;zs(e,t)}function zs(e,t){for(;t!==null;){if((t.f&Ga)!==0){if((t.f&Rr)===0)throw e;try{t.b.error(e);return}catch(i){e=i}}t=t.parent}throw e}const gv=-7169;function lt(e,t){e.f=e.f&gv|t}function mh(e){(e.f&wi)!==0||e.deps===null?lt(e,Et):lt(e,Hi)}function td(e){if(e!==null)for(const t of e)(t.f&Lt)===0||(t.f&Tr)===0||(t.f^=Tr,td(t.deps))}function id(e,t,i){(e.f&At)!==0?t.add(e):(e.f&Hi)!==0&&i.add(e),td(e.deps),lt(e,Et)}const Eo=new Set;let Re=null,Go=null,Mt=null,Zt=[],fa=null,Qa=!1,Kn=!1;var Yr,Gr,cr,Xr,no,oo,ur,hs,Qr,li,Ja,Za,$a,sd;const jh=class jh{constructor(){$(this,li);Di(this,"current",new Map);Di(this,"previous",new Map);$(this,Yr,new Set);$(this,Gr,new Set);$(this,cr,0);$(this,Xr,0);$(this,no,null);$(this,oo,new Set);$(this,ur,new Set);$(this,hs,new Map);Di(this,"is_fork",!1);$(this,Qr,!1)}skip_effect(t){p(this,hs).has(t)||p(this,hs).set(t,{d:[],m:[]})}unskip_effect(t){var i=p(this,hs).get(t);if(i){p(this,hs).delete(t);for(var s of i.d)lt(s,At),Ni(s);for(s of i.m)lt(s,Hi),Ni(s)}}process(t){var r;Zt=[],this.apply();var i=[],s=[];for(const n of t)ve(this,li,Za).call(this,n,i,s);if(ve(this,li,Ja).call(this)){ve(this,li,$a).call(this,s),ve(this,li,$a).call(this,i);for(const[n,o]of p(this,hs))ad(n,o)}else{for(const n of p(this,Yr))n();p(this,Yr).clear(),p(this,cr)===0&&ve(this,li,sd).call(this),Go=this,Re=null,Zh(s),Zh(i),Go=null,(r=p(this,no))==null||r.resolve()}Mt=null}capture(t,i){i!==Rt&&!this.previous.has(t)&&this.previous.set(t,i),(t.f&Ks)===0&&(this.current.set(t,t.v),Mt==null||Mt.set(t,t.v))}activate(){Re=this,this.apply()}deactivate(){Re===this&&(Re=null,Mt=null)}flush(){if(this.activate(),Zt.length>0){if(rd(),Re!==null&&Re!==this)return}else p(this,cr)===0&&this.process([]);this.deactivate()}discard(){for(const t of p(this,Gr))t(this);p(this,Gr).clear()}increment(t){V(this,cr,p(this,cr)+1),t&&V(this,Xr,p(this,Xr)+1)}decrement(t){V(this,cr,p(this,cr)-1),t&&V(this,Xr,p(this,Xr)-1),!p(this,Qr)&&(V(this,Qr,!0),is(()=>{V(this,Qr,!1),ve(this,li,Ja).call(this)?Zt.length>0&&this.flush():this.revive()}))}revive(){for(const t of p(this,oo))p(this,ur).delete(t),lt(t,At),Ni(t);for(const t of p(this,ur))lt(t,Hi),Ni(t);this.flush()}oncommit(t){p(this,Yr).add(t)}ondiscard(t){p(this,Gr).add(t)}settled(){return(p(this,no)??V(this,no,Uu())).promise}static ensure(){if(Re===null){const t=Re=new jh;Eo.add(Re),Kn||is(()=>{Re===t&&t.flush()})}return Re}apply(){}};Yr=new WeakMap,Gr=new WeakMap,cr=new WeakMap,Xr=new WeakMap,no=new WeakMap,oo=new WeakMap,ur=new WeakMap,hs=new WeakMap,Qr=new WeakMap,li=new WeakSet,Ja=function(){return this.is_fork||p(this,Xr)>0},Za=function(t,i,s){t.f^=Et;for(var r=t.first;r!==null;){var n=r.f,o=(n&(zi|Ar))!==0,a=o&&(n&Et)!==0,c=a||(n&ai)!==0||p(this,hs).has(r);if(!c&&r.fn!==null){o?r.f^=Et:(n&vo)!==0?i.push(r):mo(r)&&((n&ys)!==0&&p(this,ur).add(r),gn(r));var h=r.first;if(h!==null){r=h;continue}}for(;r!==null;){var d=r.next;if(d!==null){r=d;break}r=r.parent}}},$a=function(t){for(var i=0;i<t.length;i+=1)id(t[i],p(this,oo),p(this,ur))},sd=function(){var r;if(Eo.size>1){this.previous.clear();var t=Mt,i=!0;for(const n of Eo){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 s=Zt;Zt=[];const c=new Set,h=new Map;for(const d of o)nd(d,a,c,h);if(Zt.length>0){Re=n,n.apply();for(const d of Zt)ve(r=n,li,Za).call(r,d,[],[]);n.deactivate()}Zt=s}}Re=null,Mt=t}Eo.delete(this)};let qs=jh;function mv(e){var t=Kn;Kn=!0;try{for(var i;;){if(pv(),Zt.length===0&&(Re==null||Re.flush(),Zt.length===0))return fa=null,i;rd()}}finally{Kn=t}}function rd(){Qa=!0;var e=null;try{for(var t=0;Zt.length>0;){var i=qs.ensure();if(t++>1e3){var s,r;bv()}i.process(Zt),js.clear()}}finally{Zt=[],Qa=!1,fa=null}}function bv(){try{V_()}catch(e){zs(e,fa)}}let Ti=null;function Zh(e){var t=e.length;if(t!==0){for(var i=0;i<t;){var s=e[i++];if((s.f&(ps|ai))===0&&mo(s)&&(Ti=new Set,gn(s),s.deps===null&&s.first===null&&s.nodes===null&&s.teardown===null&&s.ac===null&&kd(s),(Ti==null?void 0:Ti.size)>0)){js.clear();for(const r of Ti){if((r.f&(ps|ai))!==0)continue;const n=[r];let o=r.parent;for(;o!==null;)Ti.has(o)&&(Ti.delete(o),n.push(o)),o=o.parent;for(let a=n.length-1;a>=0;a--){const c=n[a];(c.f&(ps|ai))===0&&gn(c)}}Ti.clear()}}Ti=null}}function nd(e,t,i,s){if(!i.has(e)&&(i.add(e),e.reactions!==null))for(const r of e.reactions){const n=r.f;(n&Lt)!==0?nd(r,t,i,s):(n&(ph|ys))!==0&&(n&At)===0&&od(r,t,s)&&(lt(r,At),Ni(r))}}function od(e,t,i){const s=i.get(e);if(s!==void 0)return s;if(e.deps!==null)for(const r of e.deps){if(_n.call(t,r))return!0;if((r.f&Lt)!==0&&od(r,t,i))return i.set(r,!0),!0}return i.set(e,!1),!1}function Ni(e){var t=fa=e,i=t.b;if(i!=null&&i.is_pending&&(e.f&(vo|po|Ku))!==0&&(e.f&Rr)===0){i.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var s=t.f;if(Qa&&t===ze&&(s&ys)!==0&&(s&qu)===0&&(s&Rr)!==0)return;if((s&(Ar|zi))!==0){if((s&Et)===0)return;t.f^=Et}}Zt.push(t)}function ad(e,t){if(!((e.f&zi)!==0&&(e.f&Et)!==0)){(e.f&At)!==0?t.d.push(e):(e.f&Hi)!==0&&t.m.push(e),lt(e,Et);for(var i=e.first;i!==null;)ad(i,t),i=i.next}}function Sv(e){let t=0,i=Qs(0),s;return()=>{yh()&&(l(i),pa(()=>(t===0&&(s=Zs(()=>e(()=>Vs(i)))),t+=1,()=>{is(()=>{t-=1,t===0&&(s==null||s(),s=void 0,Vs(i))})})))}}var yv=Pr|Cn;function wv(e,t,i,s){new Cv(e,t,i,s)}var fi,fh,Gi,dr,Qt,Xi,ni,Mi,cs,fr,Ms,Jr,Zr,$r,us,la,pt,kv,xv,Ev,el,Fo,Wo,tl;class Cv{constructor(t,i,s,r){$(this,pt);Di(this,"parent");Di(this,"is_pending",!1);Di(this,"transform_error");$(this,fi);$(this,fh,null);$(this,Gi);$(this,dr);$(this,Qt);$(this,Xi,null);$(this,ni,null);$(this,Mi,null);$(this,cs,null);$(this,fr,0);$(this,Ms,0);$(this,Jr,!1);$(this,Zr,new Set);$(this,$r,new Set);$(this,us,null);$(this,la,Sv(()=>(V(this,us,Qs(p(this,fr))),()=>{V(this,us,null)})));var n;V(this,fi,t),V(this,Gi,i),V(this,dr,o=>{var a=ze;a.b=this,a.f|=Ga,s(o)}),this.parent=ze.b,this.transform_error=r??((n=this.parent)==null?void 0:n.transform_error)??(o=>o),V(this,Qt,ga(()=>{ve(this,pt,el).call(this)},yv))}defer_effect(t){id(t,p(this,Zr),p(this,$r))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!p(this,Gi).pending}update_pending_count(t){ve(this,pt,tl).call(this,t),V(this,fr,p(this,fr)+t),!(!p(this,us)||p(this,Jr))&&(V(this,Jr,!0),is(()=>{V(this,Jr,!1),p(this,us)&&pn(p(this,us),p(this,fr))}))}get_effect_pending(){return p(this,la).call(this),l(p(this,us))}error(t){var i=p(this,Gi).onerror;let s=p(this,Gi).failed;if(!i&&!s)throw t;p(this,Xi)&&(ti(p(this,Xi)),V(this,Xi,null)),p(this,ni)&&(ti(p(this,ni)),V(this,ni,null)),p(this,Mi)&&(ti(p(this,Mi)),V(this,Mi,null));var r=!1,n=!1;const o=()=>{if(r){uv();return}r=!0,n&&J_(),p(this,Mi)!==null&&xr(p(this,Mi),()=>{V(this,Mi,null)}),ve(this,pt,Wo).call(this,()=>{qs.ensure(),ve(this,pt,el).call(this)})},a=c=>{try{n=!0,i==null||i(c,o),n=!1}catch(h){zs(h,p(this,Qt)&&p(this,Qt).parent)}s&&V(this,Mi,ve(this,pt,Wo).call(this,()=>{qs.ensure();try{return gi(()=>{var h=ze;h.b=this,h.f|=Ga,s(p(this,fi),()=>c,()=>o)})}catch(h){return zs(h,p(this,Qt).parent),null}}))};is(()=>{var c;try{c=this.transform_error(t)}catch(h){zs(h,p(this,Qt)&&p(this,Qt).parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(a,h=>zs(h,p(this,Qt)&&p(this,Qt).parent)):a(c)})}}fi=new WeakMap,fh=new WeakMap,Gi=new WeakMap,dr=new WeakMap,Qt=new WeakMap,Xi=new WeakMap,ni=new WeakMap,Mi=new WeakMap,cs=new WeakMap,fr=new WeakMap,Ms=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,$r=new WeakMap,us=new WeakMap,la=new WeakMap,pt=new WeakSet,kv=function(){try{V(this,Xi,gi(()=>p(this,dr).call(this,p(this,fi))))}catch(t){this.error(t)}},xv=function(t){const i=p(this,Gi).failed;i&&V(this,Mi,gi(()=>{i(p(this,fi),()=>t,()=>()=>{})}))},Ev=function(){const t=p(this,Gi).pending;t&&(this.is_pending=!0,V(this,ni,gi(()=>t(p(this,fi)))),is(()=>{var i=V(this,cs,document.createDocumentFragment()),s=gs();i.append(s),V(this,Xi,ve(this,pt,Wo).call(this,()=>(qs.ensure(),gi(()=>p(this,dr).call(this,s))))),p(this,Ms)===0&&(p(this,fi).before(i),V(this,cs,null),xr(p(this,ni),()=>{V(this,ni,null)}),ve(this,pt,Fo).call(this))}))},el=function(){try{if(this.is_pending=this.has_pending_snippet(),V(this,Ms,0),V(this,fr,0),V(this,Xi,gi(()=>{p(this,dr).call(this,p(this,fi))})),p(this,Ms)>0){var t=V(this,cs,document.createDocumentFragment());Dd(p(this,Xi),t);const i=p(this,Gi).pending;V(this,ni,gi(()=>i(p(this,fi))))}else ve(this,pt,Fo).call(this)}catch(i){this.error(i)}},Fo=function(){this.is_pending=!1;for(const t of p(this,Zr))lt(t,At),Ni(t);for(const t of p(this,$r))lt(t,Hi),Ni(t);p(this,Zr).clear(),p(this,$r).clear()},Wo=function(t){var i=ze,s=Ne,r=_t;rs(p(this,Qt)),Ei(p(this,Qt)),vn(p(this,Qt).ctx);try{return t()}catch(n){return ed(n),null}finally{rs(i),Ei(s),vn(r)}},tl=function(t){var i;if(!this.has_pending_snippet()){this.parent&&ve(i=this.parent,pt,tl).call(i,t);return}V(this,Ms,p(this,Ms)+t),p(this,Ms)===0&&(ve(this,pt,Fo).call(this),p(this,ni)&&xr(p(this,ni),()=>{V(this,ni,null)}),p(this,cs)&&(p(this,fi).before(p(this,cs)),V(this,cs,null)))};function Dv(e,t,i,s){const r=_a;var n=e.filter(u=>!u.settled);if(i.length===0&&n.length===0){s(t.map(r));return}var o=ze,a=Rv(),c=n.length===1?n[0].promise:n.length>1?Promise.all(n.map(u=>u.promise)):null;function h(u){a();try{s(u)}catch(f){(o.f&ps)===0&&zs(f,o)}il()}if(i.length===0){c.then(()=>h(t.map(r)));return}function d(){a(),Promise.all(i.map(u=>Tv(u))).then(u=>h([...t.map(r),...u])).catch(u=>zs(u,o))}c?c.then(d):d()}function Rv(){var e=ze,t=Ne,i=_t,s=Re;return function(n=!0){rs(e),Ei(t),vn(i),n&&(s==null||s.activate())}}function il(e=!0){rs(null),Ei(null),vn(null),e&&(Re==null||Re.deactivate())}function Pv(){var e=ze.b,t=Re,i=e.is_rendered();return e.update_pending_count(1),t.increment(i),()=>{e.update_pending_count(-1),t.decrement(i)}}function _a(e){var t=Lt|At,i=Ne!==null&&(Ne.f&Lt)!==0?Ne:null;return ze!==null&&(ze.f|=Cn),{ctx:_t,deps:null,effects:null,equals:Gu,f:t,fn:e,reactions:null,rv:0,v:Rt,wv:0,parent:i??ze,ac:null}}function Tv(e,t,i){ze===null&&z_();var r=void 0,n=Qs(Rt),o=!Ne,a=new Map;return qv(()=>{var f;var c=Uu();r=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(il)}catch(_){c.reject(_),il()}var h=Re;if(o){var d=Pv();(f=a.get(h))==null||f.reject(rr),a.delete(h),a.set(h,c)}const u=(_,v=void 0)=>{if(h.activate(),v)v!==rr&&(n.f|=Ks,pn(n,v));else{(n.f&Ks)!==0&&(n.f^=Ks),pn(n,_);for(const[m,g]of a){if(a.delete(m),m===h)break;g.reject(rr)}}d&&d()};c.promise.then(u,_=>u(null,_||"unknown"))}),wh(()=>{for(const c of a.values())c.reject(rr)}),new Promise(c=>{function h(d){function u(){d===r?c(n):h(r)}d.then(u,u)}h(r)})}function ce(e){const t=_a(e);return Rd(t),t}function ld(e){const t=_a(e);return t.equals=Xu,t}function Mv(e){var t=e.effects;if(t!==null){e.effects=null;for(var i=0;i<t.length;i+=1)ti(t[i])}}function Bv(e){for(var t=e.parent;t!==null;){if((t.f&Lt)===0)return(t.f&ps)===0?t:null;t=t.parent}return null}function bh(e){var t,i=ze;rs(Bv(e));try{e.f&=~Tr,Mv(e),t=Bd(e)}finally{rs(i)}return t}function hd(e){var t=bh(e);if(!e.equals(t)&&(e.wv=Td(),(!(Re!=null&&Re.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){lt(e,Et);return}Js||(Mt!==null?(yh()||Re!=null&&Re.is_fork)&&Mt.set(e,t):mh(e))}function Lv(e){var t,i;if(e.effects!==null)for(const s of e.effects)(s.teardown||s.ac)&&((t=s.teardown)==null||t.call(s),(i=s.ac)==null||i.abort(rr),s.teardown=I_,s.ac=null,Xn(s,0),Ch(s))}function cd(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&gn(t)}let sl=new Set;const js=new Map;let ud=!1;function Qs(e,t){var i={f:0,v:e,reactions:null,equals:Gu,rv:0,wv:0};return i}function F(e,t){const i=Qs(e);return Rd(i),i}function Av(e,t=!1,i=!0){const s=Qs(e);return t||(s.equals=Xu),s}function b(e,t,i=!1){Ne!==null&&(!Fi||(Ne.f&Jh)!==0)&&Ju()&&(Ne.f&(Lt|ys|ph|Jh))!==0&&(ki===null||!_n.call(ki,e))&&Q_();let s=i?Ye(t):t;return pn(e,s)}function pn(e,t){if(!e.equals(t)){var i=e.v;Js?js.set(e,t):js.set(e,i),e.v=t;var s=qs.ensure();if(s.capture(e,i),(e.f&Lt)!==0){const r=e;(e.f&At)!==0&&bh(r),mh(r)}e.wv=Td(),dd(e,At),ze!==null&&(ze.f&Et)!==0&&(ze.f&(zi|Ar))===0&&(di===null?Vv([e]):di.push(e)),!s.is_fork&&sl.size>0&&!ud&&Ov()}return t}function Ov(){ud=!1;for(const e of sl)(e.f&Et)!==0&&lt(e,Hi),mo(e)&&gn(e);sl.clear()}function Vs(e){b(e,e.v+1)}function dd(e,t){var i=e.reactions;if(i!==null)for(var s=i.length,r=0;r<s;r++){var n=i[r],o=n.f,a=(o&At)===0;if(a&&lt(n,t),(o&Lt)!==0){var c=n;Mt==null||Mt.delete(c),(o&Tr)===0&&(o&wi&&(n.f|=Tr),dd(c,Hi))}else a&&((o&ys)!==0&&Ti!==null&&Ti.add(n),Ni(n))}}function Ye(e){if(typeof e!="object"||e===null||kr in e)return e;const t=zu(e);if(t!==A_&&t!==O_)return e;var i=new Map,s=vh(e),r=F(0),n=bs,o=a=>{if(bs===n)return a();var c=Ne,h=bs;Ei(null),ic(n);var d=a();return Ei(c),ic(h),d};return s&&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)&&G_();var d=i.get(c);return d===void 0?o(()=>{var u=F(h.value);return i.set(c,u),u}):b(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(Rt));i.set(c,d),Vs(r)}}else b(h,Rt),Vs(r);return!0},get(a,c,h){var _;if(c===kr)return e;var d=i.get(c),u=c in a;if(d===void 0&&(!u||(_=Ur(a,c))!=null&&_.writable)&&(d=o(()=>{var v=Ye(u?a[c]:Rt),m=F(v);return m}),i.set(c,d)),d!==void 0){var f=l(d);return f===Rt?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!==Rt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return h},has(a,c){var f;if(c===kr)return!0;var h=i.get(c),d=h!==void 0&&h.v!==Rt||Reflect.has(a,c);if(h!==void 0||ze!==null&&(!d||(f=Ur(a,c))!=null&&f.writable)){h===void 0&&(h=o(()=>{var _=d?Ye(a[c]):Rt,v=F(_);return v}),i.set(c,h));var u=l(h);if(u===Rt)return!1}return d},set(a,c,h,d){var k;var u=i.get(c),f=c in a;if(s&&c==="length")for(var _=h;_<u.v;_+=1){var v=i.get(_+"");v!==void 0?b(v,Rt):_ in a&&(v=o(()=>F(Rt)),i.set(_+"",v))}if(u===void 0)(!f||(k=Ur(a,c))!=null&&k.writable)&&(u=o(()=>F(void 0)),b(u,Ye(h)),i.set(c,u));else{f=u.v!==Rt;var m=o(()=>Ye(h));b(u,m)}var g=Reflect.getOwnPropertyDescriptor(a,c);if(g!=null&&g.set&&g.set.call(d,h),!f){if(s&&typeof c=="string"){var y=i.get("length"),C=Number(c);Number.isInteger(C)&&C>=y.v&&b(y,C+1)}Vs(r)}return!0},ownKeys(a){l(r);var c=Reflect.ownKeys(a).filter(u=>{var f=i.get(u);return f===void 0||f.v!==Rt});for(var[h,d]of i)d.v!==Rt&&!(h in a)&&c.push(h);return c},setPrototypeOf(){X_()}})}function $h(e){try{if(e!==null&&typeof e=="object"&&kr in e)return e[kr]}catch{}return e}function Iv(e,t){return Object.is($h(e),$h(t))}var Xo,fd,_d,vd,pd;function Nv(){if(Xo===void 0){Xo=window,fd=document,_d=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,i=Text.prototype;vd=Ur(t,"firstChild").get,pd=Ur(t,"nextSibling").get,Qh(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Qh(i)&&(i.__t=void 0)}}function gs(e=""){return document.createTextNode(e)}function ms(e){return vd.call(e)}function go(e){return pd.call(e)}function S(e,t){return ms(e)}function ht(e,t=!1){{var i=ms(e);return i instanceof Comment&&i.data===""?go(i):i}}function D(e,t=1,i=!1){let s=e;for(;t--;)s=go(s);return s}function Fv(e){e.textContent=""}function gd(){return!1}function md(e,t,i){return document.createElementNS(t??Yu,e,void 0)}function Wv(e,t){{const i=document.body;e.autofocus=!0,is(()=>{document.activeElement===i&&e.focus()})}}let ec=!1;function Hv(){ec||(ec=!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 va(e){var t=Ne,i=ze;Ei(null),rs(null);try{return e()}finally{Ei(t),rs(i)}}function Sh(e,t,i,s=i){e.addEventListener(t,()=>va(i));const r=e.__on_r;r?e.__on_r=()=>{r(),s(!0)}:e.__on_r=()=>s(!0),Hv()}function bd(e){ze===null&&(Ne===null&&j_(),q_()),Js&&K_()}function zv(e,t){var i=t.last;i===null?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}function os(e,t,i){var s=ze;s!==null&&(s.f&ai)!==0&&(e|=ai);var r={ctx:_t,deps:null,nodes:null,f:e|At|wi,first:null,fn:t,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,wv:0,ac:null};if(i)try{gn(r)}catch(a){throw ti(r),a}else t!==null&&Ni(r);var n=r;if(i&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&Cn)===0&&(n=n.first,(e&ys)!==0&&(e&Pr)!==0&&n!==null&&(n.f|=Pr)),n!==null&&(n.parent=s,s!==null&&zv(n,s),Ne!==null&&(Ne.f&Lt)!==0&&(e&Ar)===0)){var o=Ne;(o.effects??(o.effects=[])).push(n)}return r}function yh(){return Ne!==null&&!Fi}function wh(e){const t=os(po,null,!1);return lt(t,Et),t.teardown=e,t}function Ci(e){bd();var t=ze.f,i=!Ne&&(t&zi)!==0&&(t&Rr)===0;if(i){var s=_t;(s.e??(s.e=[])).push(e)}else return Sd(e)}function Sd(e){return os(vo|ju,e,!1)}function Uv(e){return bd(),os(po|ju,e,!0)}function Kv(e){qs.ensure();const t=os(Ar|Cn,e,!0);return(i={})=>new Promise(s=>{i.outro?xr(t,()=>{ti(t),s(void 0)}):(ti(t),s(void 0))})}function yd(e){return os(vo,e,!1)}function qv(e){return os(ph|Cn,e,!0)}function pa(e,t=0){return os(po|t,e,!0)}function re(e,t=[],i=[],s=[]){Dv(s,t,i,r=>{os(po,()=>e(...r.map(l)),!0)})}function ga(e,t=0){var i=os(ys|t,e,!0);return i}function gi(e){return os(zi|Cn,e,!0)}function wd(e){var t=e.teardown;if(t!==null){const i=Js,s=Ne;tc(!0),Ei(null);try{t.call(null)}finally{tc(i),Ei(s)}}}function Ch(e,t=!1){var i=e.first;for(e.first=e.last=null;i!==null;){const r=i.ac;r!==null&&va(()=>{r.abort(rr)});var s=i.next;(i.f&Ar)!==0?i.parent=null:ti(i,t),i=s}}function jv(e){for(var t=e.first;t!==null;){var i=t.next;(t.f&zi)===0&&ti(t),t=i}}function ti(e,t=!0){var i=!1;(t||(e.f&qu)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Cd(e.nodes.start,e.nodes.end),i=!0),Ch(e,t&&!i),Xn(e,0),lt(e,ps);var s=e.nodes&&e.nodes.t;if(s!==null)for(const n of s)n.stop();wd(e);var r=e.parent;r!==null&&r.first!==null&&kd(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Cd(e,t){for(;e!==null;){var i=e===t?null:go(e);e.remove(),e=i}}function kd(e){var t=e.parent,i=e.prev,s=e.next;i!==null&&(i.next=s),s!==null&&(s.prev=i),t!==null&&(t.first===e&&(t.first=s),t.last===e&&(t.last=i))}function xr(e,t,i=!0){var s=[];xd(e,s,!0);var r=()=>{i&&ti(e),t&&t()},n=s.length;if(n>0){var o=()=>--n||r();for(var a of s)a.out(o)}else r()}function xd(e,t,i){if((e.f&ai)===0){e.f^=ai;var s=e.nodes&&e.nodes.t;if(s!==null)for(const a of s)(a.is_global||i)&&t.push(a);for(var r=e.first;r!==null;){var n=r.next,o=(r.f&Pr)!==0||(r.f&zi)!==0&&(e.f&ys)!==0;xd(r,t,o?i:!1),r=n}}}function kh(e){Ed(e,!0)}function Ed(e,t){if((e.f&ai)!==0){e.f^=ai,(e.f&Et)===0&&(lt(e,At),Ni(e));for(var i=e.first;i!==null;){var s=i.next,r=(i.f&Pr)!==0||(i.f&zi)!==0;Ed(i,r?t:!1),i=s}var n=e.nodes&&e.nodes.t;if(n!==null)for(const o of n)(o.is_global||t)&&o.in()}}function Dd(e,t){if(e.nodes)for(var i=e.nodes.start,s=e.nodes.end;i!==null;){var r=i===s?null:go(i);t.append(i),i=r}}let Ho=!1,Js=!1;function tc(e){Js=e}let Ne=null,Fi=!1;function Ei(e){Ne=e}let ze=null;function rs(e){ze=e}let ki=null;function Rd(e){Ne!==null&&(ki===null?ki=[e]:ki.push(e))}let $t=null,ri=0,di=null;function Vv(e){di=e}let Pd=1,or=0,bs=or;function ic(e){bs=e}function Td(){return++Pd}function mo(e){var t=e.f;if((t&At)!==0)return!0;if(t&Lt&&(e.f&=~Tr),(t&Hi)!==0){for(var i=e.deps,s=i.length,r=0;r<s;r++){var n=i[r];if(mo(n)&&hd(n),n.wv>e.wv)return!0}(t&wi)!==0&&Mt===null&&lt(e,Et)}return!1}function Md(e,t,i=!0){var s=e.reactions;if(s!==null&&!(ki!==null&&_n.call(ki,e)))for(var r=0;r<s.length;r++){var n=s[r];(n.f&Lt)!==0?Md(n,t,!1):t===n&&(i?lt(n,At):(n.f&Et)!==0&&lt(n,Hi),Ni(n))}}function Bd(e){var m;var t=$t,i=ri,s=di,r=Ne,n=ki,o=_t,a=Fi,c=bs,h=e.f;$t=null,ri=0,di=null,Ne=(h&(zi|Ar))===0?e:null,ki=null,vn(e.ctx),Fi=!1,bs=++or,e.ac!==null&&(va(()=>{e.ac.abort(rr)}),e.ac=null);try{e.f|=Xa;var d=e.fn,u=d();e.f|=Rr;var f=e.deps,_=Re==null?void 0:Re.is_fork;if($t!==null){var v;if(_||Xn(e,ri),f!==null&&ri>0)for(f.length=ri+$t.length,v=0;v<$t.length;v++)f[ri+v]=$t[v];else e.deps=f=$t;if(yh()&&(e.f&wi)!==0)for(v=ri;v<f.length;v++)((m=f[v]).reactions??(m.reactions=[])).push(e)}else!_&&f!==null&&ri<f.length&&(Xn(e,ri),f.length=ri);if(Ju()&&di!==null&&!Fi&&f!==null&&(e.f&(Lt|Hi|At))===0)for(v=0;v<di.length;v++)Md(di[v],e);if(r!==null&&r!==e){if(or++,r.deps!==null)for(let g=0;g<i;g+=1)r.deps[g].rv=or;if(t!==null)for(const g of t)g.rv=or;di!==null&&(s===null?s=di:s.push(...di))}return(e.f&Ks)!==0&&(e.f^=Ks),u}catch(g){return ed(g)}finally{e.f^=Xa,$t=t,ri=i,di=s,Ne=r,ki=n,vn(o),Fi=a,bs=c}}function Yv(e,t){let i=t.reactions;if(i!==null){var s=M_.call(i,e);if(s!==-1){var r=i.length-1;r===0?i=t.reactions=null:(i[s]=i[r],i.pop())}}if(i===null&&(t.f&Lt)!==0&&($t===null||!_n.call($t,t))){var n=t;(n.f&wi)!==0&&(n.f^=wi,n.f&=~Tr),mh(n),Lv(n),Xn(n,0)}}function Xn(e,t){var i=e.deps;if(i!==null)for(var s=t;s<i.length;s++)Yv(e,i[s])}function gn(e){var t=e.f;if((t&ps)===0){lt(e,Et);var i=ze,s=Ho;ze=e,Ho=!0;try{(t&(ys|Ku))!==0?jv(e):Ch(e),wd(e);var r=Bd(e);e.teardown=typeof r=="function"?r:null,e.wv=Pd;var n;Ya&&fv&&(e.f&At)!==0&&e.deps}finally{Ho=s,ze=i}}}async function Gv(){await Promise.resolve(),mv()}function l(e){var t=e.f,i=(t&Lt)!==0;if(Ne!==null&&!Fi){var s=ze!==null&&(ze.f&ps)!==0;if(!s&&(ki===null||!_n.call(ki,e))){var r=Ne.deps;if((Ne.f&Xa)!==0)e.rv<or&&(e.rv=or,$t===null&&r!==null&&r[ri]===e?ri++:$t===null?$t=[e]:$t.push(e));else{(Ne.deps??(Ne.deps=[])).push(e);var n=e.reactions;n===null?e.reactions=[Ne]:_n.call(n,Ne)||n.push(Ne)}}}if(Js&&js.has(e))return js.get(e);if(i){var o=e;if(Js){var a=o.v;return((o.f&Et)===0&&o.reactions!==null||Ad(o))&&(a=bh(o)),js.set(o,a),a}var c=(o.f&wi)===0&&!Fi&&Ne!==null&&(Ho||(Ne.f&wi)!==0),h=(o.f&Rr)===0;mo(o)&&(c&&(o.f|=wi),hd(o)),c&&!h&&(cd(o),Ld(o))}if(Mt!=null&&Mt.has(e))return Mt.get(e);if((e.f&Ks)!==0)throw e.v;return e.v}function Ld(e){if(e.f|=wi,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&Lt)!==0&&(t.f&wi)===0&&(cd(t),Ld(t))}function Ad(e){if(e.v===Rt)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(js.has(t)||(t.f&Lt)!==0&&Ad(t))return!0;return!1}function Zs(e){var t=Fi;try{return Fi=!0,e()}finally{Fi=t}}const Xv=["touchstart","touchmove"];function Qv(e){return Xv.includes(e)}const ar=Symbol("events"),Od=new Set,rl=new Set;function Jv(e,t,i,s={}){function r(n){if(s.capture||nl.call(t,n),!n.cancelBubble)return va(()=>i==null?void 0:i.call(this,n))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?is(()=>{t.addEventListener(e,r,s)}):t.addEventListener(e,r,s),r}function es(e,t,i,s,r){var n={capture:s,passive:r},o=Jv(e,t,i,n);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&wh(()=>{t.removeEventListener(e,o,n)})}function Y(e,t,i){(t[ar]??(t[ar]={}))[e]=i}function Je(e){for(var t=0;t<e.length;t++)Od.add(e[t]);for(var i of rl)i(e)}let sc=null;function nl(e){var g,y;var t=this,i=t.ownerDocument,s=e.type,r=((g=e.composedPath)==null?void 0:g.call(e))||[],n=r[0]||e.target;sc=e;var o=0,a=sc===e&&e[ar];if(a){var c=r.indexOf(a);if(c!==-1&&(t===document||t===window)){e[ar]=t;return}var h=r.indexOf(t);if(h===-1)return;c<=h&&(o=c)}if(n=r[o]||e.target,n!==t){B_(e,"currentTarget",{configurable:!0,get(){return n||i}});var d=Ne,u=ze;Ei(null),rs(null);try{for(var f,_=[];n!==null;){var v=n.assignedSlot||n.parentNode||n.host||null;try{var m=(y=n[ar])==null?void 0:y[s];m!=null&&(!n.disabled||e.target===n)&&m.call(n,e)}catch(C){f?_.push(C):f=C}if(e.cancelBubble||v===t||v===null)break;n=v}if(f){for(let C of _)queueMicrotask(()=>{throw C});throw f}}finally{e[ar]=t,delete e.currentTarget,Ei(d),rs(u)}}}var Eu;const Ea=((Eu=globalThis==null?void 0:globalThis.window)==null?void 0:Eu.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Zv(e){return(Ea==null?void 0:Ea.createHTML(e))??e}function Id(e){var t=md("template");return t.innerHTML=Zv(e.replaceAll("<!>","<!---->")),t.content}function mn(e,t){var i=ze;i.nodes===null&&(i.nodes={start:e,end:t,a:null,t:null})}function O(e,t){var i=(t&ov)!==0,s=(t&av)!==0,r,n=!e.startsWith("<!>");return()=>{r===void 0&&(r=Id(n?e:"<!>"+e),i||(r=ms(r)));var o=s||_d?document.importNode(r,!0):r.cloneNode(!0);if(i){var a=ms(o),c=o.lastChild;mn(a,c)}else mn(o,o);return o}}function $v(e,t,i="svg"){var s=!e.startsWith("<!>"),r=`<${i}>${s?e:"<!>"+e}</${i}>`,n;return()=>{if(!n){var o=Id(r),a=ms(o);n=ms(a)}var c=n.cloneNode(!0);return mn(c,c),c}}function ep(e,t){return $v(e,t,"svg")}function Ys(e=""){{var t=gs(e+"");return mn(t,t),t}}function Wi(){var e=document.createDocumentFragment(),t=document.createComment(""),i=gs();return e.append(t,i),mn(t,i),e}function T(e,t){e!==null&&e.before(t)}function se(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 tp(e,t){return ip(e,t)}const Do=new Map;function ip(e,{target:t,anchor:i,props:s={},events:r,context:n,intro:o=!0,transformError:a}){Nv();var c=void 0,h=Kv(()=>{var d=i??t.appendChild(gs());wv(d,{pending:()=>{}},_=>{je({});var v=_t;n&&(v.c=n),r&&(s.$$events=r),c=e(_,s)||{},Ve()},a);var u=new Set,f=_=>{for(var v=0;v<_.length;v++){var m=_[v];if(!u.has(m)){u.add(m);var g=Qv(m);for(const k of[t,document]){var y=Do.get(k);y===void 0&&(y=new Map,Do.set(k,y));var C=y.get(m);C===void 0?(k.addEventListener(m,nl,{passive:g}),y.set(m,1)):y.set(m,C+1)}}}};return f(da(Od)),rl.add(f),()=>{var g;for(var _ of u)for(const y of[t,document]){var v=Do.get(y),m=v.get(_);--m==0?(y.removeEventListener(_,nl),v.delete(_),v.size===0&&Do.delete(y)):v.set(_,m)}rl.delete(f),d!==i&&((g=d.parentNode)==null||g.removeChild(d))}});return sp.set(c,h),c}let sp=new WeakMap;var Bi,Qi,oi,_r,ao,lo,ha;class Nd{constructor(t,i=!0){Di(this,"anchor");$(this,Bi,new Map);$(this,Qi,new Map);$(this,oi,new Map);$(this,_r,new Set);$(this,ao,!0);$(this,lo,()=>{var t=Re;if(p(this,Bi).has(t)){var i=p(this,Bi).get(t),s=p(this,Qi).get(i);if(s)kh(s),p(this,_r).delete(i);else{var r=p(this,oi).get(i);r&&(p(this,Qi).set(i,r.effect),p(this,oi).delete(i),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),s=r.effect)}for(const[n,o]of p(this,Bi)){if(p(this,Bi).delete(n),n===t)break;const a=p(this,oi).get(o);a&&(ti(a.effect),p(this,oi).delete(o))}for(const[n,o]of p(this,Qi)){if(n===i||p(this,_r).has(n))continue;const a=()=>{if(Array.from(p(this,Bi).values()).includes(n)){var h=document.createDocumentFragment();Dd(o,h),h.append(gs()),p(this,oi).set(n,{effect:o,fragment:h})}else ti(o);p(this,_r).delete(n),p(this,Qi).delete(n)};p(this,ao)||!s?(p(this,_r).add(n),xr(o,a,!1)):a()}}});$(this,ha,t=>{p(this,Bi).delete(t);const i=Array.from(p(this,Bi).values());for(const[s,r]of p(this,oi))i.includes(s)||(ti(r.effect),p(this,oi).delete(s))});this.anchor=t,V(this,ao,i)}ensure(t,i){var s=Re,r=gd();if(i&&!p(this,Qi).has(t)&&!p(this,oi).has(t))if(r){var n=document.createDocumentFragment(),o=gs();n.append(o),p(this,oi).set(t,{effect:gi(()=>i(o)),fragment:n})}else p(this,Qi).set(t,gi(()=>i(this.anchor)));if(p(this,Bi).set(s,t),r){for(const[a,c]of p(this,Qi))a===t?s.unskip_effect(c):s.skip_effect(c);for(const[a,c]of p(this,oi))a===t?s.unskip_effect(c.effect):s.skip_effect(c.effect);s.oncommit(p(this,lo)),s.ondiscard(p(this,ha))}else p(this,lo).call(this)}}Bi=new WeakMap,Qi=new WeakMap,oi=new WeakMap,_r=new WeakMap,ao=new WeakMap,lo=new WeakMap,ha=new WeakMap;function ee(e,t,i=!1){var s=new Nd(e),r=i?Pr:0;function n(o,a){s.ensure(o,a)}ga(()=>{var o=!1;t((a,c=0)=>{o=!0,n(c,a)}),o||n(!1,null)},r)}function bn(e,t){return t}function rp(e,t,i){for(var s=[],r=t.length,n,o=t.length,a=0;a<r;a++){let u=t[a];xr(u,()=>{if(n){if(n.pending.delete(u),n.done.add(u),n.pending.size===0){var f=e.outrogroups;ol(da(n.done)),f.delete(n),f.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var c=s.length===0&&i!==null;if(c){var h=i,d=h.parentNode;Fv(d),d.append(h),e.items.clear()}ol(t,!c)}else n={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(n)}function ol(e,t=!0){for(var i=0;i<e.length;i++)ti(e[i],t)}var rc;function vt(e,t,i,s,r,n=null){var o=e,a=new Map,c=(t&Vu)!==0;if(c){var h=e;o=h.appendChild(gs())}var d=null,u=ld(()=>{var y=i();return vh(y)?y:y==null?[]:da(y)}),f,_=!0;function v(){g.fallback=d,np(g,f,o,t,s),d!==null&&(f.length===0?(d.f&_s)===0?kh(d):(d.f^=_s,In(d,null,o)):xr(d,()=>{d=null}))}var m=ga(()=>{f=l(u);for(var y=f.length,C=new Set,k=Re,w=gd(),P=0;P<y;P+=1){var H=f[P],U=s(H,P),j=_?null:a.get(U);j?(j.v&&pn(j.v,H),j.i&&pn(j.i,P),w&&k.unskip_effect(j.e)):(j=op(a,_?o:rc??(rc=gs()),H,U,P,r,t,i),_||(j.e.f|=_s),a.set(U,j)),C.add(U)}if(y===0&&n&&!d&&(_?d=gi(()=>n(o)):(d=gi(()=>n(rc??(rc=gs()))),d.f|=_s)),y>C.size&&U_(),!_)if(w){for(const[Z,G]of a)C.has(Z)||k.skip_effect(G.e);k.oncommit(v),k.ondiscard(()=>{})}else v();l(u)}),g={effect:m,items:a,outrogroups:null,fallback:d};_=!1}function Pn(e){for(;e!==null&&(e.f&zi)===0;)e=e.next;return e}function np(e,t,i,s,r){var G,N,I,A,L,x,M,E,R;var n=(s&ev)!==0,o=t.length,a=e.items,c=Pn(e.effect.first),h,d=null,u,f=[],_=[],v,m,g,y;if(n)for(y=0;y<o;y+=1)v=t[y],m=r(v,y),g=a.get(m).e,(g.f&_s)===0&&((N=(G=g.nodes)==null?void 0:G.a)==null||N.measure(),(u??(u=new Set)).add(g));for(y=0;y<o;y+=1){if(v=t[y],m=r(v,y),g=a.get(m).e,e.outrogroups!==null)for(const z of e.outrogroups)z.pending.delete(g),z.done.delete(g);if((g.f&_s)!==0)if(g.f^=_s,g===c)In(g,null,i);else{var C=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),xs(e,d,g),xs(e,g,C),In(g,C,i),d=g,f=[],_=[],c=Pn(d.next);continue}if((g.f&ai)!==0&&(kh(g),n&&((A=(I=g.nodes)==null?void 0:I.a)==null||A.unfix(),(u??(u=new Set)).delete(g))),g!==c){if(h!==void 0&&h.has(g)){if(f.length<_.length){var k=_[0],w;d=k.prev;var P=f[0],H=f[f.length-1];for(w=0;w<f.length;w+=1)In(f[w],k,i);for(w=0;w<_.length;w+=1)h.delete(_[w]);xs(e,P.prev,H.next),xs(e,d,P),xs(e,H,k),c=k,d=H,y-=1,f=[],_=[]}else h.delete(g),In(g,c,i),xs(e,g.prev,g.next),xs(e,g,d===null?e.effect.first:d.next),xs(e,d,g),d=g;continue}for(f=[],_=[];c!==null&&c!==g;)(h??(h=new Set)).add(c),_.push(c),c=Pn(c.next);if(c===null)continue}(g.f&_s)===0&&f.push(g),d=g,c=Pn(g.next)}if(e.outrogroups!==null){for(const z of e.outrogroups)z.pending.size===0&&(ol(da(z.done)),(L=e.outrogroups)==null||L.delete(z));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||h!==void 0){var U=[];if(h!==void 0)for(g of h)(g.f&ai)===0&&U.push(g);for(;c!==null;)(c.f&ai)===0&&c!==e.fallback&&U.push(c),c=Pn(c.next);var j=U.length;if(j>0){var Z=(s&Vu)!==0&&o===0?i:null;if(n){for(y=0;y<j;y+=1)(M=(x=U[y].nodes)==null?void 0:x.a)==null||M.measure();for(y=0;y<j;y+=1)(R=(E=U[y].nodes)==null?void 0:E.a)==null||R.fix()}rp(e,U,Z)}}n&&is(()=>{var z,X;if(u!==void 0)for(g of u)(X=(z=g.nodes)==null?void 0:z.a)==null||X.apply()})}function op(e,t,i,s,r,n,o,a){var c=(o&Z_)!==0?(o&tv)===0?Av(i,!1,!1):Qs(i):null,h=(o&$_)!==0?Qs(r):null;return{v:c,i:h,e:gi(()=>(n(t,c??i,h??r,a),()=>{e.delete(s)}))}}function In(e,t,i){if(e.nodes)for(var s=e.nodes.start,r=e.nodes.end,n=t&&(t.f&_s)===0?t.nodes.start:i;s!==null;){var o=go(s);if(n.before(s),s===r)return;s=o}}function xs(e,t,i){t===null?e.effect.first=i:t.next=i,i===null?e.effect.last=t:i.prev=t}function al(e,t,i=!1,s=!1,r=!1){var n=e,o="";re(()=>{var a=ze;if(o!==(o=t()??"")&&(a.nodes!==null&&(Cd(a.nodes.start,a.nodes.end),a.nodes=null),o!=="")){var c=i?lv:s?hv:void 0,h=md(i?"svg":s?"math":"template",c);h.innerHTML=o;var d=i||s?h:h.content;if(mn(ms(d),d.lastChild),i||s)for(;ms(d);)n.before(ms(d));else n.before(d)}})}function ap(e,t,...i){var s=new Nd(e);ga(()=>{const r=t()??null;s.ensure(r,r&&(n=>r(n,...i)))},Pr)}function Fd(e){var t,i,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(i=Fd(e[t]))&&(s&&(s+=" "),s+=i)}else for(i in e)e[i]&&(s&&(s+=" "),s+=i);return s}function lp(){for(var e,t,i=0,s="",r=arguments.length;i<r;i++)(e=arguments[i])&&(t=Fd(e))&&(s&&(s+=" "),s+=t);return s}function Wd(e){return typeof e=="object"?lp(e):e??""}const nc=[...`
2
+ \r\f \v\uFEFF`];function hp(e,t,i){var s=e==null?"":""+e;if(t&&(s=s?s+" "+t:t),i){for(var r of Object.keys(i))if(i[r])s=s?s+" "+r:r;else if(s.length)for(var n=r.length,o=0;(o=s.indexOf(r,o))>=0;){var a=o+n;(o===0||nc.includes(s[o-1]))&&(a===s.length||nc.includes(s[a]))?s=(o===0?"":s.substring(0,o))+s.substring(a+1):o=a}}return s===""?null:s}function oc(e,t=!1){var i=t?" !important;":";",s="";for(var r of Object.keys(e)){var n=e[r];n!=null&&n!==""&&(s+=" "+r+": "+n+i)}return s}function Da(e){return e[0]!=="-"||e[1]!=="-"?e.toLowerCase():e}function cp(e,t){if(t){var i="",s,r;if(Array.isArray(t)?(s=t[0],r=t[1]):s=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,a=!1,c=[];s&&c.push(...Object.keys(s).map(Da)),r&&c.push(...Object.keys(r).map(Da));var h=0,d=-1;const m=e.length;for(var u=0;u<m;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===m-1){if(d!==-1){var _=Da(e.substring(h,d).trim());if(!c.includes(_)){f!==";"&&u++;var v=e.substring(h,u).trim();i+=" "+v+";"}}h=u+1,d=-1}}}}return s&&(i+=oc(s)),r&&(i+=oc(r,!0)),i=i.trim(),i===""?null:i}return e==null?null:String(e)}function Ze(e,t,i,s,r,n){var o=e.__className;if(o!==i||o===void 0){var a=hp(i,s,n);a==null?e.removeAttribute("class"):t?e.className=a:e.setAttribute("class",a),e.__className=i}else if(n&&r!==n)for(var c in n){var h=!!n[c];(r==null||h!==!!r[c])&&e.classList.toggle(c,h)}return n}function Ra(e,t={},i,s){for(var r in i){var n=i[r];t[r]!==n&&(i[r]==null?e.style.removeProperty(r):e.style.setProperty(r,n,s))}}function Or(e,t,i,s){var r=e.__style;if(r!==t){var n=cp(t,s);n==null?e.removeAttribute("style"):e.style.cssText=n,e.__style=t}else s&&(Array.isArray(s)?(Ra(e,i==null?void 0:i[0],s[0]),Ra(e,i==null?void 0:i[1],s[1],"important")):Ra(e,i,s));return s}function Hd(e,t,i=!1){if(e.multiple){if(t==null)return;if(!vh(t))return cv();for(var s of e.options)s.selected=t.includes(qn(s));return}for(s of e.options){var r=qn(s);if(Iv(r,t)){s.selected=!0;return}}(!i||t!==void 0)&&(e.selectedIndex=-1)}function up(e){var t=new MutationObserver(()=>{Hd(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),wh(()=>{t.disconnect()})}function Qo(e,t,i=t){var s=new WeakSet,r=!0;Sh(e,"change",n=>{var o=n?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(o),qn);else{var c=e.querySelector(o)??e.querySelector("option:not([disabled])");a=c&&qn(c)}i(a),Re!==null&&s.add(Re)}),yd(()=>{var n=t();if(e===document.activeElement){var o=Go??Re;if(s.has(o))return}if(Hd(e,n,r),r&&n===void 0){var a=e.querySelector(":checked");a!==null&&(n=qn(a),i(n))}e.__value=n,r=!1}),up(e)}function qn(e){return"__value"in e?e.__value:e.value}const dp=Symbol("is custom element"),fp=Symbol("is html"),_p=H_?"progress":"PROGRESS";function vp(e,t){var i=xh(e);i.value===(i.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==_p)||(e.value=t??"")}function pp(e,t){var i=xh(e);i.checked!==(i.checked=t??void 0)&&(e.checked=t)}function Pe(e,t,i,s){var r=xh(e);r[t]!==(r[t]=i)&&(t==="loading"&&(e[W_]=i),i==null?e.removeAttribute(t):typeof i!="string"&&gp(e).includes(t)?e[t]=i:e.setAttribute(t,i))}function xh(e){return e.__attributes??(e.__attributes={[dp]:e.nodeName.includes("-"),[fp]:e.namespaceURI===Yu})}var ac=new Map;function gp(e){var t=e.getAttribute("is")||e.nodeName,i=ac.get(t);if(i)return i;ac.set(t,i=[]);for(var s,r=e,n=Element.prototype;n!==r;){s=L_(r);for(var o in s)s[o].set&&i.push(o);r=zu(r)}return i}function Si(e,t,i=t){var s=new WeakSet;Sh(e,"input",async r=>{var n=r?e.defaultValue:e.value;if(n=Pa(e)?Ta(n):n,i(n),Re!==null&&s.add(Re),await Gv(),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))}}}),Zs(t)==null&&e.value&&(i(Pa(e)?Ta(e.value):e.value),Re!==null&&s.add(Re)),pa(()=>{var r=t();if(e===document.activeElement){var n=Go??Re;if(s.has(n))return}Pa(e)&&r===Ta(e.value)||e.type==="date"&&!r&&!e.value||r!==e.value&&(e.value=r??"")})}function Ii(e,t,i=t){Sh(e,"change",s=>{var r=s?e.defaultChecked:e.checked;i(r)}),Zs(t)==null&&i(e.checked),pa(()=>{var s=t();e.checked=!!s})}function Pa(e){var t=e.type;return t==="number"||t==="range"}function Ta(e){return e===""?null:+e}function lc(e,t){return e===t||(e==null?void 0:e[kr])===t}function Qe(e={},t,i,s){return yd(()=>{var r,n;return pa(()=>{r=n,n=[],Zs(()=>{e!==i(...n)&&(t(e,...n),r&&lc(i(...r),e)&&t(null,...r))})}),()=>{is(()=>{n&&lc(i(...n),e)&&t(null,...n)})}}),e}let Ro=!1;function mp(e){var t=Ro;try{return Ro=!1,[e(),Ro]}finally{Ro=t}}function Ut(e,t,i,s){var C;var r=(i&rv)!==0,n=(i&nv)!==0,o=s,a=!0,c=()=>(a&&(a=!1,o=n?Zs(s):s),o),h;if(r){var d=kr in e||F_ in e;h=((C=Ur(e,t))==null?void 0:C.set)??(d&&t in e?k=>e[t]=k:void 0)}var u,f=!1;r?[u,f]=mp(()=>e[t]):u=e[t],u===void 0&&s!==void 0&&(u=c(),h&&(Y_(),h(u)));var _;if(_=()=>{var k=e[t];return k===void 0?c():(a=!0,k)},(i&sv)===0)return _;if(h){var v=e.$$legacy;return(function(k,w){return arguments.length>0?((!w||v||f)&&h(w?_():k),k):_()})}var m=!1,g=((i&iv)!==0?_a:ld)(()=>(m=!1,_()));r&&l(g);var y=ze;return(function(k,w){if(arguments.length>0){const P=w?l(g):r?Ye(k):k;return b(g,P),m=!0,o!==void 0&&(o=P),k}return Js&&m||(y.f&ps)!==0?g.v:l(g)})}function kn(e){_t===null&&gh(),Ci(()=>{const t=Zs(e);if(typeof t=="function")return t})}function bp(e){_t===null&&gh(),kn(()=>()=>Zs(e))}const Sp="5";var Du;typeof window<"u"&&((Du=window.__svelte??(window.__svelte={})).v??(Du.v=new Set)).add(Sp);class zd extends Error{constructor(i){super("conflict");Di(this,"sessionId");this.name="ConflictError",this.sessionId=i}}async function Wt(e){if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function yp(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 wp(){return(await fetch("/sessions")).ok}async function Cp(){return Wt(await fetch("/sessions"))}async function kp(){return Wt(await fetch("/worktrees"))}async function xp(){return(await Wt(await fetch("/workspaces"))).workspaces}async function hc(e,t){const i=new URLSearchParams;return e&&i.set("path",e),Wt(await fetch("/workspaces/browse?"+i.toString()))}async function Ep(e){return Wt(await fetch("/workspaces/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))}async function Dp(e){var i,s;const t=await Wt(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:!((s=t.pullRequests)!=null&&s.error)}}async function Rp(e,t){const i=await fetch("/workspaces/ci-status?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function Pp(e,t){const i=await fetch("/workspaces/pr?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function Tp(e){return(await Wt(await fetch("/workspaces/current-branch?path="+encodeURIComponent(e)))).branch}async function cc(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 s=await i.json();throw new Error(s.error||"Failed to create worktree")}return i.json()}async function Mp(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 Eh(e,t={}){const i=new URLSearchParams({repo:e});return t.refresh&&i.set("refresh","1"),Wt(await fetch("/branches?"+i.toString()))}async function Kr(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 zd(i.sessionId??"")}return Wt(t)}async function Bp(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 zd(i.sessionId??"")}return Wt(t)}async function Lp(e){await fetch("/sessions/"+e,{method:"DELETE"})}async function Ud(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 s=await i.json();throw new Error(s.error||"Failed to delete worktree")}}async function Ap(e,t,i){return Wt(await fetch("/sessions/"+e+"/image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t,mimeType:i})}))}async function Kd(){return Wt(await fetch("/version"))}async function qd(){return Wt(await fetch("/update",{method:"POST"}))}async function Op(){return(await Wt(await fetch("/config/defaultAgent"))).defaultAgent}async function Ip(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 ma(e){return(await Wt(await fetch(`/config/${e}`)))[e]}async function ba(e,t){const i=await fetch(`/config/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(!i.ok){const s=await i.json();throw new Error(s.error||`Failed to update ${e}`)}}const Np=()=>ma("defaultContinue"),Fp=e=>ba("defaultContinue",e),Wp=()=>ma("defaultYolo"),Hp=e=>ba("defaultYolo",e),zp=()=>ma("launchInTmux"),Up=e=>ba("launchInTmux",e),Kp=()=>ma("defaultNotifications"),qp=e=>ba("defaultNotifications",e);async function jp(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 ll(e){return Wt(await fetch("/workspaces/settings?path="+encodeURIComponent(e)))}async function Vp(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 s=await i.json();throw new Error(s.error||"Failed to update workspace settings")}}let Jo=F(!1),hl=F(null),cl=F(!0);function jd(){return{get authenticated(){return l(Jo)},get pinError(){return l(hl)},get checking(){return l(cl)}}}async function Yp(){b(cl,!0);try{b(Jo,await wp(),!0)}catch{b(Jo,!1)}finally{b(cl,!1)}}async function Gp(e){b(hl,null);try{await yp(e),b(Jo,!0)}catch(t){b(hl,t instanceof Error?t.message:"Authentication failed",!0)}}const Vd="claude-remote-sidebar-width",Yd="claude-remote-sidebar-collapsed",ul="claude-remote-active-workspace",Gd=240,Xd=180,Qd=500,Xp=44;function Qp(){try{const e=localStorage.getItem(Vd);if(e){const t=parseInt(e,10);if(t>=Xd&&t<=Qd)return t}}catch{}return Gd}function Jp(){try{return localStorage.getItem(Yd)==="true"}catch{return!1}}function Zp(){try{return localStorage.getItem(ul)}catch{return null}}let Zo=F(!1),dl=F(Ye(Qp())),jn=F(Ye(Jp())),uc=F(""),dc=F(Ye(Zp()));function Jd(){return{get sidebarOpen(){return l(Zo)},set sidebarOpen(e){b(Zo,e,!0)},get sidebarWidth(){return l(dl)},set sidebarWidth(e){b(dl,e,!0)},get sidebarCollapsed(){return l(jn)},set sidebarCollapsed(e){b(jn,e,!0)},get searchQuery(){return l(uc)},set searchQuery(e){b(uc,e,!0)},get activeWorkspacePath(){return l(dc)},set activeWorkspacePath(e){b(dc,e,!0);try{e===null?localStorage.removeItem(ul):localStorage.setItem(ul,e)}catch{}}}}function fc(){b(Zo,!0)}function vi(){b(Zo,!1)}function _c(){try{localStorage.setItem(Vd,String(l(dl)))}catch{}}function Ma(){b(jn,!l(jn));try{localStorage.setItem(Yd,String(l(jn)))}catch{}}let Vn=null,$p=null;function eg(e){Vn=e,"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const i=t.data;i.type==="notification-click"&&i.sessionId&&Vn&&Vn(i.sessionId,i.sessionType||"repo")})}function tg(){return document.hidden||!document.hasFocus()}function ig(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(),Vn&&Vn(e.id,e.type),t.close()}}function Zd(){return"serviceWorker"in navigator&&"PushManager"in window}async function sg(){if(Zd())try{$p=await navigator.serviceWorker.register("/sw.js")}catch{return}}async function rg(e){if(Zd())try{const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();i&&await jp(i.toJSON(),e)}catch{}}const $d="claude-remote-notifications",fl="claude-remote-active-session";function ng(){try{return localStorage.getItem(fl)}catch{return null}}function ef(e){try{e===null?localStorage.removeItem(fl):localStorage.setItem(fl,e)}catch{}}let Qn=F(Ye([])),tf=F(Ye([])),sf=F(Ye([])),qr=F(Ye(ng())),Mr=Ye({}),Jn=Ye({}),Dh=Ye({}),Ss=F(Ye({}));try{const e=localStorage.getItem($d);e&&b(Ss,JSON.parse(e),!0)}catch{}function rf(){try{localStorage.setItem($d,JSON.stringify(l(Ss)))}catch{}}function Rh(){return{get sessions(){return l(Qn)},get worktrees(){return l(tf)},get workspaces(){return l(sf)},get activeSessionId(){return l(qr)},set activeSessionId(e){b(qr,e,!0),ef(e)},get attentionSessions(){return Mr},get loadingItems(){return Dh},get notificationSessions(){return l(Ss)}}}async function Nt(){try{const[e,t,i]=await Promise.all([Cp(),kp(),xp()]);b(Qn,e,!0),b(tf,t,!0),b(sf,i,!0);const s=new Set(l(Qn).map(n=>n.id));l(qr)!==null&&!s.has(l(qr))&&(b(qr,null),ef(null));let r=!1;for(const n of Object.keys(Mr))s.has(n)||delete Mr[n];for(const n of Object.keys(Jn))s.has(n)||delete Jn[n];for(const n of Object.keys(l(Ss)))s.has(n)||(delete l(Ss)[n],r=!0);r&&rf()}catch{}}function nf(e){return l(Qn).filter(t=>t.repoPath===e||t.repoPath.startsWith(e+"/"))}const og=3e4;function ag(e,t){const i=l(Qn).find(s=>s.id===e);if(i&&(i.idle=t),t&&e!==l(qr)&&(i==null?void 0:i.type)!=="terminal"){const s=Jn[e];if(s&&Date.now()-s<og)return;delete Jn[e],Mr[e]=!0,i&&l(Ss)[e]&&tg()&&ig(i)}else delete Mr[e]}function vc(e){delete Mr[e],Jn[e]=Date.now()}function Po(e,t){e in l(Ss)||(l(Ss)[e]=t,rf())}function lg(){return Object.entries(l(Ss)).filter(([,e])=>e).map(([e])=>e)}function To(e){return Mr[e.id]?"attention":e.idle?"idle":"running"}function hg(e){Dh[e]=!0}function cg(e){delete Dh[e]}const Ph=location.protocol==="https:"?"wss:":"ws:";let er=null,ei=null,hi=null,yi=null;const _l=30;let Yn=null,jr=0,zo=0;function of(e){er&&(er.close(),er=null);const t=Ph+"//"+location.host+"/ws/events";er=new WebSocket(t),er.onmessage=i=>{try{e(JSON.parse(i.data))}catch{}},er.onclose=()=>{setTimeout(()=>of(e),3e3)},er.onerror=()=>{}}function af(e,t,i,s){Yn&&(clearTimeout(Yn),Yn=null),jr=0,hi&&(hi.onopen=null,hi.onmessage=null,hi.onclose=null,hi.onerror=null,hi.close(),hi=null),ei&&(ei.onclose=null,ei.close(),ei=null);const r=Ph+"//"+location.host+"/ws/"+e,n=new WebSocket(r);hi=n,n.onopen=()=>{hi=null,ei=n,jr=0,i()},n.onmessage=o=>{t.write(o.data)},n.onclose=o=>{if(hi===n&&(hi=null),!(hi!==n&&ei!==n)){if(o.code===1e3){t.write(`\r
3
3
  [Session ended]\r
4
- `),Zt=null,s();return}Zt=null,Vr===0&&t.write(`\r
4
+ `),ei=null,s();return}ei=null,jr===0&&t.write(`\r
5
5
  [Reconnecting...]\r
6
- `),af(e,t,i,s)}},n.onerror=()=>{}}function af(e,t,i,s){if(Vr>=_l){t.write(`\r
6
+ `),lf(e,t,i,s)}},n.onerror=()=>{}}function lf(e,t,i,s){if(jr>=_l){t.write(`\r
7
7
  [Gave up reconnecting after `+_l+` attempts]\r
8
- `);return}const r=Math.min(1e3*2**Vr,1e4);Vr++,Yn=setTimeout(async()=>{Yn=null;try{if(!(await(await fetch("/sessions")).json()).some(a=>a.id===e)){t.write(`\r
8
+ `);return}const r=Math.min(1e3*2**jr,1e4);jr++,Yn=setTimeout(async()=>{Yn=null;try{if(!(await(await fetch("/sessions")).json()).some(a=>a.id===e)){t.write(`\r
9
9
  [Session ended]\r
10
- `),s();return}t.clear(),of(e,t,i,s)}catch{af(e,t,i,s)}},r)}function Er(e){Zt&&Zt.readyState===WebSocket.OPEN&&Zt.send(e)}function Ba(e,t){Zt&&Zt.readyState===WebSocket.OPEN&&Zt.send(JSON.stringify({type:"resize",cols:e,rows:t}))}let Vt=null;function lf(e,t){wi&&(wi.onclose=null,wi.close(),wi=null),zo=0,Vt=t;const i=Ph+"//"+location.host+"/ws/"+e,s=new WebSocket(i);s.onopen=()=>{wi=s},s.onmessage=r=>{var n,o;try{const a=JSON.parse(r.data);if(a.type==="session_info")return;if(a.type==="terminal_data"){(n=Vt==null?void 0:Vt.onTerminalData)==null||n.call(Vt,a.data);return}if(a.type==="terminal_exit"){(o=Vt==null?void 0:Vt.onTerminalExit)==null||o.call(Vt);return}Vt==null||Vt.onEvent(a)}catch{}},s.onclose=r=>{if(wi=null,r.code===1e3){t.onSessionEnd();return}cg(e,t)},s.onerror=()=>{}}function cg(e,t){if(zo>=_l)return;const i=Math.min(1e3*2**zo,1e4);zo++,setTimeout(()=>{lf(e,t)},i)}function ug(e){wi&&wi.readyState===WebSocket.OPEN&&wi.send(JSON.stringify({type:"message",text:e}))}function pc(e,t){wi&&wi.readyState===WebSocket.OPEN&&wi.send(JSON.stringify({type:"permission",requestId:e,approved:t}))}const Pi=Xe({defaultContinue:!0,defaultYolo:!1,launchInTmux:!1,defaultAgent:"claude",defaultNotifications:!0});function Th(){return Pi}async function hf(){const[e,t,i,s,r]=await Promise.all([Ip().catch(()=>Pi.defaultContinue),Fp().catch(()=>Pi.defaultYolo),Hp().catch(()=>Pi.launchInTmux),Ap().catch(()=>Pi.defaultAgent),Up().catch(()=>Pi.defaultNotifications)]);Pi.defaultContinue=e,Pi.defaultYolo=t,Pi.launchInTmux=i,Pi.defaultAgent=s,Pi.defaultNotifications=r}function dg(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),s=Math.floor((t-i)/1e3);if(s<60)return"just now";const r=Math.floor(s/60);if(r<60)return r+"m ago";const n=Math.floor(r/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()}const Rt=typeof window<"u"&&"ontouchstart"in window&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);var fg=L('<p class="error svelte-1qp96yb"> </p>'),_g=L('<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 vg(e,t){Ye(t,!0);const i=qd();let s=I("");async function r(){const f=l(s).trim();f&&(await Yp(f),i.pinError&&b(s,""))}function n(f){f.key==="Enter"&&r()}var o=_g(),a=S(o),c=x(S(a),4);Fv(c);var h=x(c,2),d=x(h,2);{var u=f=>{var _=fg(),v=S(_);re(()=>se(v,i.pinError)),T(f,_)};ee(d,f=>{i.pinError&&f(u)})}X("keydown",c,n),yi(c,()=>l(s),f=>b(s,f)),X("click",h,r),T(e,o),Ge()}Ze(["keydown","click"]);var pg=L('<li role="menuitem"> </li>'),gg=L('<div class="context-menu-backdrop svelte-1nmhce7"></div> <ul class="context-menu svelte-1nmhce7" role="menu"></ul>',1),mg=L('<button class="context-menu-trigger svelte-1nmhce7" aria-label="Actions" aria-haspopup="true">&middot;&middot;&middot;</button> <!>',1);function gc(e,t){let i=I(!1),s=I(null),r=I(null);function n(m){m.stopPropagation(),l(i)?o():(b(i,!0),requestAnimationFrame(a))}function o(){b(i,!1)}function a(){if(!l(s)||!l(r))return;const m=l(s).getBoundingClientRect(),g=l(r).getBoundingClientRect();let y=m.bottom+4,C=m.right-g.width;y+g.height>window.innerHeight-8&&(y=m.top-g.height-4),C<8&&(C=8),l(r).style.top=y+"px",l(r).style.left=C+"px"}function c(m,g){g.stopPropagation(),!m.disabled&&(o(),m.action())}function h(m){!l(i)||m.key!=="Escape"||(m.stopPropagation(),o())}function d(m){m.stopPropagation(),o()}var u=mg();$i("keydown",fd,h);var f=pt(u);Je(f,m=>b(s,m),()=>l(s));var _=x(f,2);{var v=m=>{var g=gg(),y=pt(g),C=x(y,2);vt(C,21,()=>t.items,Sn,(k,w)=>{var D=pg();let F;var z=S(D);re(()=>{F=et(D,1,"context-menu-item svelte-1nmhce7",null,F,{"context-menu-item--danger":l(w).danger,"context-menu-item--disabled":l(w).disabled}),Me(D,"tabindex",l(w).disabled?-1:0),se(z,l(w).label)}),X("click",D,N=>c(l(w),N)),X("keydown",D,N=>N.key==="Enter"&&c(l(w),N)),T(k,D)}),Je(C,k=>b(r,k),()=>l(r)),X("click",y,d),X("click",C,k=>k.stopPropagation()),T(m,g)};ee(_,m=>{l(i)&&m(v)})}re(()=>Me(f,"aria-expanded",l(i))),X("click",f,n),T(e,u)}Ze(["click","keydown"]);var bg=L('<span class="terminal-icon svelte-168i8d5">&gt;_</span>'),Sg=L("<span></span>"),yg=L("<li><!> <span> </span> <!></li>"),wg=L('<li class="session-row inactive svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span> <!></li>'),Cg=L('<ul class="session-list svelte-168i8d5"><!> <!></ul>'),kg=L('<div><div><div class="workspace-left svelte-168i8d5"><span class="initial-block svelte-168i8d5"> </span> <span class="workspace-name svelte-168i8d5"> </span></div> <div class="workspace-actions svelte-168i8d5"><span class="action-btn svelte-168i8d5" title="New session">+</span> <span class="action-btn svelte-168i8d5" title="New terminal">&gt;_</span> <span class="action-btn svelte-168i8d5" title="Settings">⚙</span></div></div> <!> <div class="add-worktree-row svelte-168i8d5"><span class="add-worktree-btn svelte-168i8d5">+ new worktree</span></div> <div class="workspace-divider svelte-168i8d5"></div></div>');function xg(e,t){Ye(t,!0);const i=Rh();let s=Kt(t,"inactiveWorktrees",19,()=>[]);const r=["#d97757","#4ade80","#60a5fa","#a78bfa","#f472b6","#fb923c","#34d399","#f87171"];function n(E){let B=0;for(let R=0;R<E.length;R++)B=(B<<5)-B+E.charCodeAt(R)|0;return r[Math.abs(B)%r.length]??"#d97757"}let o=ce(()=>n(t.workspace.name)),a=ce(()=>t.workspace.name.charAt(0).toUpperCase());function c(E){return"status-dot status-dot--"+To(E)}function h(E){return E.displayName||E.branchName||E.repoName||E.id}let d=ce(()=>t.sessions.some(E=>To(E)==="attention"));async function u(E){const B=prompt("Rename session:",h(E));B&&B.trim()&&(await fetch(`/sessions/${E.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:B.trim()})}),await Ut())}function f(E){return[{label:"Rename",action:()=>u(E)},{label:"Kill",action:()=>{var B;return(B=t.onDeleteSession)==null?void 0:B.call(t,E.id)},danger:!0}]}function _(E){return[{label:"Resume",action:async()=>{try{const B=await qr({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:E.path,branchName:E.branchName||E.name});await Ut(),t.onSelectSession(B.id)}catch{}}},{label:"Resume (YOLO)",action:async()=>{try{const B=await qr({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:E.path,branchName:E.branchName||E.name,yolo:!0});await Ut(),t.onSelectSession(B.id)}catch{}}},{label:"Delete Worktree",action:()=>{var B;return(B=t.onDeleteWorktree)==null?void 0:B.call(t,E)},danger:!0}]}var v=kg();let m;var g=S(v);let y;var C=S(g),k=S(C);let w;var D=S(k),F=x(k,2),z=S(F),N=x(C,2),U=S(N),Y=x(U,2),K=x(Y,2),W=x(g,2);{var O=E=>{var B=Cg(),R=S(B);vt(R,17,()=>t.sessions,H=>H.id,(H,Z)=>{var de=yg();let be;var he=S(de);{var ge=Le=>{var We=bg();T(Le,We)},ye=Le=>{var We=Sg();re(ze=>et(We,1,ze,"svelte-168i8d5"),[()=>Wd(c(l(Z)))]),T(Le,We)};ee(he,Le=>{l(Z).type==="terminal"?Le(ge):Le(ye,!1)})}var ke=x(he,2);let ue;var pe=S(ke),xe=x(ke,2);{let Le=ce(()=>f(l(Z)));gc(xe,{get items(){return l(Le)}})}re((Le,We,ze)=>{be=et(de,1,"session-row svelte-168i8d5",null,be,Le),ue=et(ke,1,"session-name svelte-168i8d5",null,ue,We),se(pe,ze)},[()=>({terminal:l(Z).type==="terminal",selected:i.activeSessionId===l(Z).id,attention:To(l(Z))==="attention"}),()=>({bold:To(l(Z))==="attention"}),()=>h(l(Z))]),X("click",de,()=>t.onSelectSession(l(Z).id)),T(H,de)});var P=x(R,2);vt(P,17,s,H=>H.path,(H,Z)=>{var de=wg(),be=x(S(de),2),he=S(be),ge=x(be,2);{let ye=ce(()=>_(l(Z)));gc(ge,{get items(){return l(ye)}})}re(()=>se(he,l(Z).branchName||l(Z).displayName||l(Z).name)),X("click",de,async()=>{try{const ye=await qr({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:l(Z).path,branchName:l(Z).branchName||l(Z).name});await Ut(),t.onSelectSession(ye.id)}catch{}}),T(H,de)}),T(E,B)};ee(W,E=>{(t.sessions.length>0||s().length>0)&&E(O)})}var A=x(W,2);re(()=>{m=et(v,1,"workspace-item svelte-168i8d5",null,m,{active:t.isActive}),y=et(g,1,"workspace-header svelte-168i8d5",null,y,{attention:l(d)}),w=Or(k,"",w,{background:l(o)}),se(D,l(a)),se(z,t.workspace.name)}),X("click",g,()=>t.onSelectWorkspace(t.workspace.path)),X("click",U,E=>{E.stopPropagation(),t.onNewSession(t.workspace)}),X("click",Y,E=>{E.stopPropagation(),t.onNewTerminal(t.workspace)}),X("click",K,E=>{E.stopPropagation(),t.onOpenSettings(t.workspace)}),X("click",A,()=>t.onNewWorktree(t.workspace)),T(e,v),Ge()}Ze(["click"]);var Eg=L('<strong class="svelte-itm1qs"> </strong>'),Dg=L("<span> </span>"),Rg=L('<li role="option"><!> <span class="dropdown-path svelte-itm1qs"> </span></li>'),Pg=L('<ul class="dropdown svelte-itm1qs" role="listbox"></ul>'),Tg=L('<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" placeholder="search workspaces..." autocomplete="off"/></div> <!></div>');function Mg(e,t){Ye(t,!0);let i=I(""),s=I(0),r=I(void 0),n=ce(()=>{if(!l(i).trim())return[];const g=l(i).toLowerCase();return t.workspaces.filter(y=>y.name.toLowerCase().includes(g))}),o=ce(()=>l(i).trim().length>0&&l(n).length>0);Ui(()=>{l(n).length,b(s,0)});function a(g){b(i,g.target.value,!0)}function c(g){var y;if(g.key==="Escape"){b(i,""),(y=l(r))==null||y.blur();return}if(l(o)){if(g.key==="ArrowDown")g.preventDefault(),b(s,Math.min(l(s)+1,l(n).length-1),!0);else if(g.key==="ArrowUp")g.preventDefault(),b(s,Math.max(l(s)-1,0),!0);else if(g.key==="Enter"){g.preventDefault();const C=l(n)[l(s)];C&&h(C)}}}function h(g){var y;t.onSelect(g.path),b(i,""),(y=l(r))==null||y.blur()}function d(g,y){if(!y)return[{text:g,bold:!1}];const C=g.toLowerCase(),k=y.toLowerCase(),w=C.indexOf(k);return w===-1?[{text:g,bold:!1}]:[{text:g.slice(0,w),bold:!1},{text:g.slice(w,w+k.length),bold:!0},{text:g.slice(w+k.length),bold:!1}].filter(D=>D.text.length>0)}var u=Tg(),f=S(u),_=x(S(f),2);Me(_,"spellcheck",!1),Je(_,g=>b(r,g),()=>l(r));var v=x(f,2);{var m=g=>{var y=Pg();vt(y,23,()=>l(n),C=>C.path,(C,k,w)=>{var D=Rg();let F;var z=S(D);vt(z,17,()=>d(l(k).name,l(i)),Sn,(Y,K)=>{var W=Hi(),O=pt(W);{var A=B=>{var R=Eg(),P=S(R);re(()=>se(P,l(K).text)),T(B,R)},E=B=>{var R=Dg(),P=S(R);re(()=>se(P,l(K).text)),T(B,R)};ee(O,B=>{l(K).bold?B(A):B(E,!1)})}T(Y,W)});var N=x(z,2),U=S(N);re(()=>{F=et(D,1,"dropdown-item svelte-itm1qs",null,F,{focused:l(w)===l(s)}),Me(D,"aria-selected",l(w)===l(s)),se(U,l(k).path)}),X("click",D,()=>h(l(k))),$i("mouseenter",D,()=>{b(s,l(w),!0)}),T(C,D)}),T(g,y)};ee(v,g=>{l(o)&&g(m)})}re(()=>_p(_,l(i))),X("input",_,a),X("keydown",_,c),T(e,u),Ge()}Ze(["input","keydown","click"]);var Bg=L('<span class="sidebar-label svelte-owj5vn">Workspaces</span>'),Lg=L('<div class="empty-state svelte-owj5vn"><span>No workspaces</span></div>'),Ag=L('<!> <div class="workspace-list svelte-owj5vn"><!> <!></div> <button class="add-workspace-btn svelte-owj5vn">+ Add Workspace</button> <button class="settings-btn svelte-owj5vn">⚙ Settings</button> <div class="resize-handle svelte-owj5vn"></div>',1),Og=L('<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 Ig(e,t){Ye(t,!0);const i=Qd(),s=Rh();let r=ce(()=>i.sidebarCollapsed?Gp:i.sidebarWidth);function n(w){i.activeWorkspacePath=w,s.activeSessionId=null}function o(w){i.activeWorkspacePath=w,pi()}function a(w){w.preventDefault();const D=w.clientX,F=i.sidebarWidth,z=U=>{const Y=Math.min(Xd,Math.max(Gd,F+(U.clientX-D)));i.sidebarWidth=Y},N=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",N),document.body.style.cursor="",document.body.style.userSelect="",_c()};document.addEventListener("mousemove",z),document.addEventListener("mouseup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function c(w){w.preventDefault(),i.sidebarWidth=Yd,_c()}var h=Og();let d,u;var f=S(h),_=S(f),v=S(_),m=x(_,2);{var g=w=>{var D=Bg();T(w,D)};ee(m,w=>{i.sidebarCollapsed||w(g)})}var y=x(m,2),C=x(f,2);{var k=w=>{var D=Ag(),F=pt(D);Mg(F,{get workspaces(){return s.workspaces},onSelect:o});var z=x(F,2),N=S(z);vt(N,17,()=>s.workspaces,A=>A.path,(A,E)=>{const B=ce(()=>rf(l(E).path)),R=ce(()=>new Set(l(B).map(H=>H.repoPath))),P=ce(()=>s.worktrees.filter(H=>H.repoPath===l(E).path&&H.path.startsWith(l(E).path+"/")&&!l(R).has(H.path)));{let H=ce(()=>i.activeWorkspacePath===l(E).path&&!s.activeSessionId);xg(A,{get workspace(){return l(E)},get sessions(){return l(B)},get inactiveWorktrees(){return l(P)},get isActive(){return l(H)},onSelectWorkspace:n,get onSelectSession(){return t.onSelectSession},get onNewWorktree(){return t.onNewWorktree},get onNewSession(){return t.onNewSession},get onNewTerminal(){return t.onNewTerminal},onOpenSettings:Z=>t.onOpenSettings(Z),onDeleteSession:Z=>{var de;return(de=t.onDeleteSession)==null?void 0:de.call(t,Z)},onDeleteWorktree:Z=>{var de;return(de=t.onDeleteWorktree)==null?void 0:de.call(t,Z)}})}});var U=x(N,2);{var Y=A=>{var E=Lg();T(A,E)};ee(U,A=>{s.workspaces.length===0&&A(Y)})}var K=x(z,2),W=x(K,2),O=x(W,2);X("click",K,function(...A){var E;(E=t.onAddWorkspace)==null||E.apply(this,A)}),X("click",W,()=>t.onOpenSettings()),X("mousedown",O,a),X("dblclick",O,c),T(w,D)};ee(C,w=>{i.sidebarCollapsed||w(k)})}re(()=>{d=et(h,1,"sidebar svelte-owj5vn",null,d,{open:i.sidebarOpen,collapsed:i.sidebarCollapsed}),u=Or(h,"",u,{width:`${l(r)??""}px`,"min-width":`${l(r)??""}px`}),Me(_,"aria-label",i.sidebarCollapsed?"Expand sidebar":"Collapse sidebar"),se(v,i.sidebarCollapsed?"»":"«")}),X("click",_,function(...w){Ma==null||Ma.apply(this,w)}),X("click",y,function(...w){pi==null||pi.apply(this,w)}),T(e,h),Ge()}Ze(["click","mousedown","dblclick"]);/**
10
+ `),s();return}t.clear(),af(e,t,i,s)}catch{lf(e,t,i,s)}},r)}function Er(e){ei&&ei.readyState===WebSocket.OPEN&&ei.send(e)}function Ba(e,t){ei&&ei.readyState===WebSocket.OPEN&&ei.send(JSON.stringify({type:"resize",cols:e,rows:t}))}let Gt=null;function hf(e,t){yi&&(yi.onclose=null,yi.close(),yi=null),zo=0,Gt=t;const i=Ph+"//"+location.host+"/ws/"+e,s=new WebSocket(i);s.onopen=()=>{yi=s},s.onmessage=r=>{var n,o;try{const a=JSON.parse(r.data);if(a.type==="session_info")return;if(a.type==="terminal_data"){(n=Gt==null?void 0:Gt.onTerminalData)==null||n.call(Gt,a.data);return}if(a.type==="terminal_exit"){(o=Gt==null?void 0:Gt.onTerminalExit)==null||o.call(Gt);return}Gt==null||Gt.onEvent(a)}catch{}},s.onclose=r=>{if(yi=null,r.code===1e3){t.onSessionEnd();return}ug(e,t)},s.onerror=()=>{}}function ug(e,t){if(zo>=_l)return;const i=Math.min(1e3*2**zo,1e4);zo++,setTimeout(()=>{hf(e,t)},i)}function dg(e){yi&&yi.readyState===WebSocket.OPEN&&yi.send(JSON.stringify({type:"message",text:e}))}function pc(e,t){yi&&yi.readyState===WebSocket.OPEN&&yi.send(JSON.stringify({type:"permission",requestId:e,approved:t}))}const Ri=Ye({defaultContinue:!0,defaultYolo:!1,launchInTmux:!1,defaultAgent:"claude",defaultNotifications:!0});function Th(){return Ri}async function cf(){const[e,t,i,s,r]=await Promise.all([Np().catch(()=>Ri.defaultContinue),Wp().catch(()=>Ri.defaultYolo),zp().catch(()=>Ri.launchInTmux),Op().catch(()=>Ri.defaultAgent),Kp().catch(()=>Ri.defaultNotifications)]);Ri.defaultContinue=e,Ri.defaultYolo=t,Ri.launchInTmux=i,Ri.defaultAgent=s,Ri.defaultNotifications=r}function fg(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),s=Math.floor((t-i)/1e3);if(s<60)return"just now";const r=Math.floor(s/60);if(r<60)return r+"m ago";const n=Math.floor(r/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()}const Pt=typeof window<"u"&&"ontouchstart"in window&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);var _g=O('<p class="error svelte-1qp96yb"> </p>'),vg=O('<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 pg(e,t){je(t,!0);const i=jd();let s=F("");async function r(){const f=l(s).trim();f&&(await Gp(f),i.pinError&&b(s,""))}function n(f){f.key==="Enter"&&r()}var o=vg(),a=S(o),c=D(S(a),4);Wv(c);var h=D(c,2),d=D(h,2);{var u=f=>{var _=_g(),v=S(_);re(()=>se(v,i.pinError)),T(f,_)};ee(d,f=>{i.pinError&&f(u)})}Y("keydown",c,n),Si(c,()=>l(s),f=>b(s,f)),Y("click",h,r),T(e,o),Ve()}Je(["keydown","click"]);var gg=O('<li role="menuitem"> </li>'),mg=O('<div class="context-menu-backdrop svelte-1nmhce7"></div> <ul class="context-menu svelte-1nmhce7" role="menu"></ul>',1),bg=O('<button class="context-menu-trigger svelte-1nmhce7" aria-label="Actions" aria-haspopup="true">&middot;&middot;&middot;</button> <!>',1);function gc(e,t){let i=F(!1),s=F(null),r=F(null);function n(m){m.stopPropagation(),l(i)?o():(b(i,!0),requestAnimationFrame(a))}function o(){b(i,!1)}function a(){if(!l(s)||!l(r))return;const m=l(s).getBoundingClientRect(),g=l(r).getBoundingClientRect();let y=m.bottom+4,C=m.right-g.width;y+g.height>window.innerHeight-8&&(y=m.top-g.height-4),C<8&&(C=8),l(r).style.top=y+"px",l(r).style.left=C+"px"}function c(m,g){g.stopPropagation(),!m.disabled&&(o(),m.action())}function h(m){!l(i)||m.key!=="Escape"||(m.stopPropagation(),o())}function d(m){m.stopPropagation(),o()}var u=bg();es("keydown",fd,h);var f=ht(u);Qe(f,m=>b(s,m),()=>l(s));var _=D(f,2);{var v=m=>{var g=mg(),y=ht(g),C=D(y,2);vt(C,21,()=>t.items,bn,(k,w)=>{var P=gg();let H;var U=S(P);re(()=>{H=Ze(P,1,"context-menu-item svelte-1nmhce7",null,H,{"context-menu-item--danger":l(w).danger,"context-menu-item--disabled":l(w).disabled}),Pe(P,"tabindex",l(w).disabled?-1:0),se(U,l(w).label)}),Y("click",P,j=>c(l(w),j)),Y("keydown",P,j=>j.key==="Enter"&&c(l(w),j)),T(k,P)}),Qe(C,k=>b(r,k),()=>l(r)),Y("click",y,d),Y("click",C,k=>k.stopPropagation()),T(m,g)};ee(_,m=>{l(i)&&m(v)})}re(()=>Pe(f,"aria-expanded",l(i))),Y("click",f,n),T(e,u)}Je(["click","keydown"]);var Sg=O('<span class="terminal-icon svelte-168i8d5">&gt;_</span>'),yg=O("<span></span>"),wg=O("<li><!> <span> </span> <!></li>"),Cg=O('<li class="session-row inactive svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span> <!></li>'),kg=O('<ul class="session-list svelte-168i8d5"><!> <!></ul>'),xg=O('<div><div><div class="workspace-left svelte-168i8d5"><span class="initial-block svelte-168i8d5"> </span> <span class="workspace-name svelte-168i8d5"> </span></div> <div class="workspace-actions svelte-168i8d5"><span class="action-btn svelte-168i8d5" title="New session">+</span> <span class="action-btn svelte-168i8d5" title="New terminal">&gt;_</span> <span class="action-btn svelte-168i8d5" title="Settings">⚙</span></div></div> <!> <div class="add-worktree-row svelte-168i8d5"><span class="add-worktree-btn svelte-168i8d5">+ new worktree</span></div> <div class="workspace-divider svelte-168i8d5"></div></div>');function Eg(e,t){je(t,!0);const i=Rh();let s=Ut(t,"inactiveWorktrees",19,()=>[]);const r=["#d97757","#4ade80","#60a5fa","#a78bfa","#f472b6","#fb923c","#34d399","#f87171"];function n(x){let M=0;for(let E=0;E<x.length;E++)M=(M<<5)-M+x.charCodeAt(E)|0;return r[Math.abs(M)%r.length]??"#d97757"}let o=ce(()=>n(t.workspace.name)),a=ce(()=>t.workspace.name.charAt(0).toUpperCase());function c(x){return"status-dot status-dot--"+To(x)}function h(x){return x.displayName||x.branchName||x.repoName||x.id}let d=ce(()=>t.sessions.some(x=>To(x)==="attention"));async function u(x){const M=prompt("Rename session:",h(x));M&&M.trim()&&(await fetch(`/sessions/${x.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:M.trim()})}),await Nt())}function f(x){return[{label:"Rename",action:()=>u(x)},{label:"Kill",action:()=>{var M;return(M=t.onDeleteSession)==null?void 0:M.call(t,x.id)},danger:!0}]}function _(x){return[{label:"Resume",action:async()=>{try{const M=await Kr({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:x.path,branchName:x.branchName||x.name});await Nt(),t.onSelectSession(M.id)}catch{}}},{label:"Resume (YOLO)",action:async()=>{try{const M=await Kr({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:x.path,branchName:x.branchName||x.name,yolo:!0});await Nt(),t.onSelectSession(M.id)}catch{}}},{label:"Delete Worktree",action:()=>{var M;return(M=t.onDeleteWorktree)==null?void 0:M.call(t,x)},danger:!0}]}var v=xg();let m;var g=S(v);let y;var C=S(g),k=S(C);let w;var P=S(k),H=D(k,2),U=S(H),j=D(C,2),Z=S(j),G=D(Z,2),N=D(G,2),I=D(g,2);{var A=x=>{var M=kg(),E=S(M);vt(E,17,()=>t.sessions,z=>z.id,(z,X)=>{var de=wg();let Se;var he=S(de);{var me=Be=>{var We=Sg();T(Be,We)},we=Be=>{var We=yg();re(He=>Ze(We,1,He,"svelte-168i8d5"),[()=>Wd(c(l(X)))]),T(Be,We)};ee(he,Be=>{l(X).type==="terminal"?Be(me):Be(we,!1)})}var xe=D(he,2);let fe;var ge=S(xe),De=D(xe,2);{let Be=ce(()=>f(l(X)));gc(De,{get items(){return l(Be)}})}re((Be,We,He)=>{Se=Ze(de,1,"session-row svelte-168i8d5",null,Se,Be),fe=Ze(xe,1,"session-name svelte-168i8d5",null,fe,We),se(ge,He)},[()=>({terminal:l(X).type==="terminal",selected:i.activeSessionId===l(X).id,attention:To(l(X))==="attention"}),()=>({bold:To(l(X))==="attention"}),()=>h(l(X))]),Y("click",de,()=>t.onSelectSession(l(X).id)),T(z,de)});var R=D(E,2);vt(R,17,s,z=>z.path,(z,X)=>{var de=Cg(),Se=D(S(de),2),he=S(Se),me=D(Se,2);{let we=ce(()=>_(l(X)));gc(me,{get items(){return l(we)}})}re(()=>se(he,l(X).branchName||l(X).displayName||l(X).name)),Y("click",de,async()=>{try{const we=await Kr({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:l(X).path,branchName:l(X).branchName||l(X).name});await Nt(),t.onSelectSession(we.id)}catch{}}),T(z,de)}),T(x,M)};ee(I,x=>{(t.sessions.length>0||s().length>0)&&x(A)})}var L=D(I,2);re(()=>{m=Ze(v,1,"workspace-item svelte-168i8d5",null,m,{active:t.isActive}),y=Ze(g,1,"workspace-header svelte-168i8d5",null,y,{attention:l(d)}),w=Or(k,"",w,{background:l(o)}),se(P,l(a)),se(U,t.workspace.name)}),Y("click",g,()=>t.onSelectWorkspace(t.workspace.path)),Y("click",Z,x=>{x.stopPropagation(),t.onNewSession(t.workspace)}),Y("click",G,x=>{x.stopPropagation(),t.onNewTerminal(t.workspace)}),Y("click",N,x=>{x.stopPropagation(),t.onOpenSettings(t.workspace)}),Y("click",L,()=>t.onNewWorktree(t.workspace)),T(e,v),Ve()}Je(["click"]);var Dg=O('<strong class="svelte-itm1qs"> </strong>'),Rg=O("<span> </span>"),Pg=O('<li role="option"><!> <span class="dropdown-path svelte-itm1qs"> </span></li>'),Tg=O('<ul class="dropdown svelte-itm1qs" role="listbox"></ul>'),Mg=O('<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" placeholder="search workspaces..." autocomplete="off"/></div> <!></div>');function Bg(e,t){je(t,!0);let i=F(""),s=F(0),r=F(void 0),n=ce(()=>{if(!l(i).trim())return[];const g=l(i).toLowerCase();return t.workspaces.filter(y=>y.name.toLowerCase().includes(g))}),o=ce(()=>l(i).trim().length>0&&l(n).length>0);Ci(()=>{l(n).length,b(s,0)});function a(g){b(i,g.target.value,!0)}function c(g){var y;if(g.key==="Escape"){b(i,""),(y=l(r))==null||y.blur();return}if(l(o)){if(g.key==="ArrowDown")g.preventDefault(),b(s,Math.min(l(s)+1,l(n).length-1),!0);else if(g.key==="ArrowUp")g.preventDefault(),b(s,Math.max(l(s)-1,0),!0);else if(g.key==="Enter"){g.preventDefault();const C=l(n)[l(s)];C&&h(C)}}}function h(g){var y;t.onSelect(g.path),b(i,""),(y=l(r))==null||y.blur()}function d(g,y){if(!y)return[{text:g,bold:!1}];const C=g.toLowerCase(),k=y.toLowerCase(),w=C.indexOf(k);return w===-1?[{text:g,bold:!1}]:[{text:g.slice(0,w),bold:!1},{text:g.slice(w,w+k.length),bold:!0},{text:g.slice(w+k.length),bold:!1}].filter(P=>P.text.length>0)}var u=Mg(),f=S(u),_=D(S(f),2);Pe(_,"spellcheck",!1),Qe(_,g=>b(r,g),()=>l(r));var v=D(f,2);{var m=g=>{var y=Tg();vt(y,23,()=>l(n),C=>C.path,(C,k,w)=>{var P=Pg();let H;var U=S(P);vt(U,17,()=>d(l(k).name,l(i)),bn,(G,N)=>{var I=Wi(),A=ht(I);{var L=M=>{var E=Dg(),R=S(E);re(()=>se(R,l(N).text)),T(M,E)},x=M=>{var E=Rg(),R=S(E);re(()=>se(R,l(N).text)),T(M,E)};ee(A,M=>{l(N).bold?M(L):M(x,!1)})}T(G,I)});var j=D(U,2),Z=S(j);re(()=>{H=Ze(P,1,"dropdown-item svelte-itm1qs",null,H,{focused:l(w)===l(s)}),Pe(P,"aria-selected",l(w)===l(s)),se(Z,l(k).path)}),Y("click",P,()=>h(l(k))),es("mouseenter",P,()=>{b(s,l(w),!0)}),T(C,P)}),T(g,y)};ee(v,g=>{l(o)&&g(m)})}re(()=>vp(_,l(i))),Y("input",_,a),Y("keydown",_,c),T(e,u),Ve()}Je(["input","keydown","click"]);var Lg=O('<span class="sidebar-label svelte-owj5vn">Workspaces</span>'),Ag=O('<div class="empty-state svelte-owj5vn"><span>No workspaces</span></div>'),Og=O('<!> <div class="workspace-list svelte-owj5vn"><!> <!></div> <button class="add-workspace-btn svelte-owj5vn">+ Add Workspace</button> <button class="settings-btn svelte-owj5vn">⚙ Settings</button> <div class="resize-handle svelte-owj5vn"></div>',1),Ig=O('<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 Ng(e,t){je(t,!0);const i=Jd(),s=Rh();let r=ce(()=>i.sidebarCollapsed?Xp:i.sidebarWidth);function n(w){i.activeWorkspacePath=w,s.activeSessionId=null}function o(w){i.activeWorkspacePath=w,vi()}function a(w){w.preventDefault();const P=w.clientX,H=i.sidebarWidth,U=Z=>{const G=Math.min(Qd,Math.max(Xd,H+(Z.clientX-P)));i.sidebarWidth=G},j=()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect="",_c()};document.addEventListener("mousemove",U),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function c(w){w.preventDefault(),i.sidebarWidth=Gd,_c()}var h=Ig();let d,u;var f=S(h),_=S(f),v=S(_),m=D(_,2);{var g=w=>{var P=Lg();T(w,P)};ee(m,w=>{i.sidebarCollapsed||w(g)})}var y=D(m,2),C=D(f,2);{var k=w=>{var P=Og(),H=ht(P);Bg(H,{get workspaces(){return s.workspaces},onSelect:o});var U=D(H,2),j=S(U);vt(j,17,()=>s.workspaces,L=>L.path,(L,x)=>{const M=ce(()=>nf(l(x).path)),E=ce(()=>new Set(l(M).map(z=>z.repoPath))),R=ce(()=>s.worktrees.filter(z=>z.repoPath===l(x).path&&z.path.startsWith(l(x).path+"/")&&!l(E).has(z.path)));{let z=ce(()=>i.activeWorkspacePath===l(x).path&&!s.activeSessionId);Eg(L,{get workspace(){return l(x)},get sessions(){return l(M)},get inactiveWorktrees(){return l(R)},get isActive(){return l(z)},onSelectWorkspace:n,get onSelectSession(){return t.onSelectSession},get onNewWorktree(){return t.onNewWorktree},get onNewSession(){return t.onNewSession},get onNewTerminal(){return t.onNewTerminal},onOpenSettings:X=>t.onOpenSettings(X),onDeleteSession:X=>{var de;return(de=t.onDeleteSession)==null?void 0:de.call(t,X)},onDeleteWorktree:X=>{var de;return(de=t.onDeleteWorktree)==null?void 0:de.call(t,X)}})}});var Z=D(j,2);{var G=L=>{var x=Ag();T(L,x)};ee(Z,L=>{s.workspaces.length===0&&L(G)})}var N=D(U,2),I=D(N,2),A=D(I,2);Y("click",N,function(...L){var x;(x=t.onAddWorkspace)==null||x.apply(this,L)}),Y("click",I,()=>t.onOpenSettings()),Y("mousedown",A,a),Y("dblclick",A,c),T(w,P)};ee(C,w=>{i.sidebarCollapsed||w(k)})}re(()=>{d=Ze(h,1,"sidebar svelte-owj5vn",null,d,{open:i.sidebarOpen,collapsed:i.sidebarCollapsed}),u=Or(h,"",u,{width:`${l(r)??""}px`,"min-width":`${l(r)??""}px`}),Pe(_,"aria-label",i.sidebarCollapsed?"Expand sidebar":"Collapse sidebar"),se(v,i.sidebarCollapsed?"»":"«")}),Y("click",_,function(...w){Ma==null||Ma.apply(this,w)}),Y("click",y,function(...w){vi==null||vi.apply(this,w)}),T(e,h),Ve()}Je(["click","mousedown","dblclick"]);/**
11
11
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
12
12
  * @license MIT
13
13
  *
@@ -18,22 +18,22 @@ var R_=Object.defineProperty;var Xh=e=>{throw TypeError(e)};var P_=(e,t,i)=>t in
18
18
  * Fabrice Bellard's javascript vt100 for jslinux:
19
19
  * http://bellard.org/jslinux/
20
20
  * Copyright (c) 2011 Fabrice Bellard
21
- */var cf=Object.defineProperty,Ng=Object.getOwnPropertyDescriptor,Fg=(e,t)=>{for(var i in t)cf(e,i,{get:t[i],enumerable:!0})},at=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ng(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&cf(t,i,r),r},ae=(e,t)=>(i,s)=>t(i,s,e),mc="Terminal input",vl={get:()=>mc,set:e=>mc=e},bc="Too much output to announce, navigate to rows manually to read",pl={get:()=>bc,set:e=>bc=e};function Wg(e){return e.replace(/\r?\n/g,"\r")}function Hg(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function zg(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ug(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");uf(r,t,i,s)}}function uf(e,t,i,s){e=Wg(e),e=Hg(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function df(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Sc(e,t,i,s,r){df(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Ps(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Sa(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var Kg=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},qg=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,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 v=0,m;for(;(m=this.interim[++v]&63)&&v<4;)_<<=6,_|=m;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=g-v;for(;h<y;){if(h>=i)return 0;if(m=e[h++],(m&192)!==128){h--,f=!0;break}else this.interim[v++]=m,_<<=6,_|=m&63}f||(g===2?_<128?h--:t[s++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(t[s++]=_):_<65536||_>1114111||(t[s++]=_)),this.interim.fill(0)}let d=i-4,u=h;for(;u<i;){for(;u<d&&!((r=e[u])&128)&&!((n=e[u+1])&128)&&!((o=e[u+2])&128)&&!((a=e[u+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,u+=4;if(r=e[u++],r<128)t[s++]=r;else if((r&224)===192){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(c=(r&31)<<6|n&63,c<128){u--;continue}t[s++]=c}else if((r&240)===224){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(c=(r&15)<<12|(n&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((r&248)===240){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[u++],(a&192)!==128){u--;continue}if(c=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,c<65536||c>1114111)continue;t[s++]=c}}return s}},ff="",zs=" ",bo=class _f{constructor(){this.fg=0,this.bg=0,this.extended=new $o}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 _f;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}},$o=class vf{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 vf(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},xi=class pf extends bo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new $o,this.combinedData=""}static fromCharData(t){let i=new pf;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?Ps(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 s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-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()]}},yc="di$target",gl="di$dependencies",La=new Map;function jg(e){return e[gl]||[]}function Et(e){if(La.has(e))return La.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Vg(t,i,r)};return t._id=e,La.set(e,t),t}function Vg(e,t,i){t[yc]===t?t[gl].push({id:e,index:i}):(t[gl]=[{id:e,index:i}],t[yc]=t)}var qt=Et("BufferService"),gf=Et("CoreMouseService"),Ir=Et("CoreService"),Yg=Et("CharsetService"),Mh=Et("InstantiationService"),mf=Et("LogService"),jt=Et("OptionsService"),bf=Et("OscLinkService"),Gg=Et("UnicodeService"),So=Et("DecorationService"),ml=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 s=[],r=this._optionsService.rawOptions.linkHandler,n=new xi,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}},v=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let m=new URL(f);["http:","https:"].includes(m.protocol)||(v=!0)}catch{v=!0}v||s.push({text:f,range:_,activate:(m,g)=>r?r.activate(m,g,_):Xg(m,g),hover:(m,g)=>{var y;return(y=r==null?void 0:r.hover)==null?void 0:y.call(r,m,g,_)},leave:(m,g)=>{var y;return(y=r==null?void 0:r.leave)==null?void 0:y.call(r,m,g,_)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(c=u,a=n.extended.urlId):(c=-1,a=-1)}}t(s)}};ml=at([ae(0,qt),ae(1,jt),ae(2,bf)],ml);function Xg(e,t){if(confirm(`Do you want to navigate to ${t}?
21
+ */var uf=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,Wg=(e,t)=>{for(var i in t)uf(e,i,{get:t[i],enumerable:!0})},ot=(e,t,i,s)=>{for(var r=s>1?void 0:s?Fg(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&uf(t,i,r),r},ae=(e,t)=>(i,s)=>t(i,s,e),mc="Terminal input",vl={get:()=>mc,set:e=>mc=e},bc="Too much output to announce, navigate to rows manually to read",pl={get:()=>bc,set:e=>bc=e};function Hg(e){return e.replace(/\r?\n/g,"\r")}function zg(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Ug(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Kg(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");df(r,t,i,s)}}function df(e,t,i,s){e=Hg(e),e=zg(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function ff(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Sc(e,t,i,s,r){ff(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Ts(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Sa(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var qg=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},jg=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,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 v=0,m;for(;(m=this.interim[++v]&63)&&v<4;)_<<=6,_|=m;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=g-v;for(;h<y;){if(h>=i)return 0;if(m=e[h++],(m&192)!==128){h--,f=!0;break}else this.interim[v++]=m,_<<=6,_|=m&63}f||(g===2?_<128?h--:t[s++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(t[s++]=_):_<65536||_>1114111||(t[s++]=_)),this.interim.fill(0)}let d=i-4,u=h;for(;u<i;){for(;u<d&&!((r=e[u])&128)&&!((n=e[u+1])&128)&&!((o=e[u+2])&128)&&!((a=e[u+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,u+=4;if(r=e[u++],r<128)t[s++]=r;else if((r&224)===192){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(c=(r&31)<<6|n&63,c<128){u--;continue}t[s++]=c}else if((r&240)===224){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(c=(r&15)<<12|(n&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((r&248)===240){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[u++],(a&192)!==128){u--;continue}if(c=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,c<65536||c>1114111)continue;t[s++]=c}}return s}},_f="",Us=" ",bo=class vf{constructor(){this.fg=0,this.bg=0,this.extended=new $o}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 vf;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}},$o=class pf{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 pf(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},xi=class gf extends bo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new $o,this.combinedData=""}static fromCharData(t){let i=new gf;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?Ts(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 s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-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()]}},yc="di$target",gl="di$dependencies",La=new Map;function Vg(e){return e[gl]||[]}function Dt(e){if(La.has(e))return La.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Yg(t,i,r)};return t._id=e,La.set(e,t),t}function Yg(e,t,i){t[yc]===t?t[gl].push({id:e,index:i}):(t[gl]=[{id:e,index:i}],t[yc]=t)}var Kt=Dt("BufferService"),mf=Dt("CoreMouseService"),Ir=Dt("CoreService"),Gg=Dt("CharsetService"),Mh=Dt("InstantiationService"),bf=Dt("LogService"),qt=Dt("OptionsService"),Sf=Dt("OscLinkService"),Xg=Dt("UnicodeService"),So=Dt("DecorationService"),ml=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 s=[],r=this._optionsService.rawOptions.linkHandler,n=new xi,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}},v=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let m=new URL(f);["http:","https:"].includes(m.protocol)||(v=!0)}catch{v=!0}v||s.push({text:f,range:_,activate:(m,g)=>r?r.activate(m,g,_):Qg(m,g),hover:(m,g)=>{var y;return(y=r==null?void 0:r.hover)==null?void 0:y.call(r,m,g,_)},leave:(m,g)=>{var y;return(y=r==null?void 0:r.leave)==null?void 0:y.call(r,m,g,_)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(c=u,a=n.extended.urlId):(c=-1,a=-1)}}t(s)}};ml=ot([ae(0,Kt),ae(1,qt),ae(2,Sf)],ml);function Qg(e,t){if(confirm(`Do you want to navigate to ${t}?
22
22
 
23
- 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 ya=Et("CharSizeService"),ys=Et("CoreBrowserService"),Bh=Et("MouseService"),ws=Et("RenderService"),Qg=Et("SelectionService"),Sf=Et("CharacterJoinerService"),En=Et("ThemeService"),yf=Et("LinkProviderService"),Jg=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?wc.isErrorNoTelemetry(e)?new wc(e.message+`
23
+ 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 ya=Dt("CharSizeService"),ws=Dt("CoreBrowserService"),Bh=Dt("MouseService"),Cs=Dt("RenderService"),Jg=Dt("SelectionService"),yf=Dt("CharacterJoinerService"),xn=Dt("ThemeService"),wf=Dt("LinkProviderService"),Zg=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?wc.isErrorNoTelemetry(e)?new wc(e.message+`
24
24
 
25
25
  `+e.stack):new Error(e.message+`
26
26
 
27
- `+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)}},Zg=new Jg;function Uo(e){$g(e)||Zg.onUnexpectedError(e)}var bl="Canceled";function $g(e){return e instanceof em?!0:e instanceof Error&&e.name===bl&&e.message===bl}var em=class extends Error{constructor(){super(bl),this.name=this.message}};function tm(e){return new Error(`Illegal argument: ${e}`)}var wc=class Sl extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Sl)return t;let i=new Sl;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},yl=class wf extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,wf.prototype)}};function ii(e,t=0){return e[e.length-(1+t)]}var im;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(im||(im={}));function sm(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Cf;(e=>{function t(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(w){yield w}e.single=r;function n(w){return t(w)?w:r(w)}e.wrap=n;function o(w){return w||i}e.from=o;function*a(w){for(let D=w.length-1;D>=0;D--)yield w[D]}e.reverse=a;function c(w){return!w||w[Symbol.iterator]().next().done===!0}e.isEmpty=c;function h(w){return w[Symbol.iterator]().next().value}e.first=h;function d(w,D){let F=0;for(let z of w)if(D(z,F++))return!0;return!1}e.some=d;function u(w,D){for(let F of w)if(D(F))return F}e.find=u;function*f(w,D){for(let F of w)D(F)&&(yield F)}e.filter=f;function*_(w,D){let F=0;for(let z of w)yield D(z,F++)}e.map=_;function*v(w,D){let F=0;for(let z of w)yield*D(z,F++)}e.flatMap=v;function*m(...w){for(let D of w)yield*D}e.concat=m;function g(w,D,F){let z=F;for(let N of w)z=D(z,N);return z}e.reduce=g;function*y(w,D,F=w.length){for(D<0&&(D+=w.length),F<0?F+=w.length:F>w.length&&(F=w.length);D<F;D++)yield w[D]}e.slice=y;function C(w,D=Number.POSITIVE_INFINITY){let F=[];if(D===0)return[F,w];let z=w[Symbol.iterator]();for(let N=0;N<D;N++){let U=z.next();if(U.done)return[F,e.empty()];F.push(U.value)}return[F,{[Symbol.iterator](){return z}}]}e.consume=C;async function k(w){let D=[];for await(let F of w)D.push(F);return Promise.resolve(D)}e.asyncToArray=k})(Cf||(Cf={}));function Br(e){if(Cf.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}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 rm(...e){return it(()=>Br(e))}function it(e){return{dispose:sm(()=>{e()})}}var kf=class xf{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{Br(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?xf.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)}};kf.DISABLE_DISPOSED_WARNING=!1;var Ys=kf,Oe=class{constructor(){this._store=new Ys,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)}};Oe.None=Object.freeze({dispose(){}});var yn=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}},_s=typeof window=="object"?window:globalThis,wl=class Cl{constructor(t){this.element=t,this.next=Cl.Undefined,this.prev=Cl.Undefined}};wl.Undefined=new wl(void 0);var st=wl,Cc=class{constructor(){this._first=st.Undefined,this._last=st.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===st.Undefined}clear(){let e=this._first;for(;e!==st.Undefined;){let t=e.next;e.prev=st.Undefined,e.next=st.Undefined,e=t}this._first=st.Undefined,this._last=st.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new st(e);if(this._first===st.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==st.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==st.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==st.Undefined&&e.next!==st.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===st.Undefined&&e.next===st.Undefined?(this._first=st.Undefined,this._last=st.Undefined):e.next===st.Undefined?(this._last=this._last.prev,this._last.next=st.Undefined):e.prev===st.Undefined&&(this._first=this._first.next,this._first.prev=st.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==st.Undefined;)yield e.element,e=e.next}},nm=globalThis.performance&&typeof globalThis.performance.now=="function",om=class Ef{static create(t){return new Ef(t)}constructor(t){this._now=nm&&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}},Mt;(e=>{e.None=()=>Oe.None;function t(W,O){return u(W,()=>{},0,void 0,!0,void 0,O)}e.defer=t;function i(W){return(O,A=null,E)=>{let B=!1,R;return R=W(P=>{if(!B)return R?R.dispose():B=!0,O.call(A,P)},null,E),B&&R.dispose(),R}}e.once=i;function s(W,O,A){return h((E,B=null,R)=>W(P=>E.call(B,O(P)),null,R),A)}e.map=s;function r(W,O,A){return h((E,B=null,R)=>W(P=>{O(P),E.call(B,P)},null,R),A)}e.forEach=r;function n(W,O,A){return h((E,B=null,R)=>W(P=>O(P)&&E.call(B,P),null,R),A)}e.filter=n;function o(W){return W}e.signal=o;function a(...W){return(O,A=null,E)=>{let B=rm(...W.map(R=>R(P=>O.call(A,P))));return d(B,E)}}e.any=a;function c(W,O,A,E){let B=A;return s(W,R=>(B=O(B,R),B),E)}e.reduce=c;function h(W,O){let A,E={onWillAddFirstListener(){A=W(B.fire,B)},onDidRemoveLastListener(){A==null||A.dispose()}},B=new te(E);return O==null||O.add(B),B.event}function d(W,O){return O instanceof Array?O.push(W):O&&O.add(W),W}function u(W,O,A=100,E=!1,B=!1,R,P){let H,Z,de,be=0,he,ge={leakWarningThreshold:R,onWillAddFirstListener(){H=W(ke=>{be++,Z=O(Z,ke),E&&!de&&(ye.fire(Z),Z=void 0),he=()=>{let ue=Z;Z=void 0,de=void 0,(!E||be>1)&&ye.fire(ue),be=0},typeof A=="number"?(clearTimeout(de),de=setTimeout(he,A)):de===void 0&&(de=0,queueMicrotask(he))})},onWillRemoveListener(){B&&be>0&&(he==null||he())},onDidRemoveLastListener(){he=void 0,H.dispose()}},ye=new te(ge);return P==null||P.add(ye),ye.event}e.debounce=u;function f(W,O=0,A){return e.debounce(W,(E,B)=>E?(E.push(B),E):[B],O,void 0,!0,void 0,A)}e.accumulate=f;function _(W,O=(E,B)=>E===B,A){let E=!0,B;return n(W,R=>{let P=E||!O(R,B);return E=!1,B=R,P},A)}e.latch=_;function v(W,O,A){return[e.filter(W,O,A),e.filter(W,E=>!O(E),A)]}e.split=v;function m(W,O=!1,A=[],E){let B=A.slice(),R=W(Z=>{B?B.push(Z):H.fire(Z)});E&&E.add(R);let P=()=>{B==null||B.forEach(Z=>H.fire(Z)),B=null},H=new te({onWillAddFirstListener(){R||(R=W(Z=>H.fire(Z)),E&&E.add(R))},onDidAddFirstListener(){B&&(O?setTimeout(P):P())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return E&&E.add(H),H.event}e.buffer=m;function g(W,O){return(A,E,B)=>{let R=O(new C);return W(function(P){let H=R.evaluate(P);H!==y&&A.call(E,H)},void 0,B)}}e.chain=g;let y=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(O){return this.steps.push(O),this}forEach(O){return this.steps.push(A=>(O(A),A)),this}filter(O){return this.steps.push(A=>O(A)?A:y),this}reduce(O,A){let E=A;return this.steps.push(B=>(E=O(E,B),E)),this}latch(O=(A,E)=>A===E){let A=!0,E;return this.steps.push(B=>{let R=A||!O(B,E);return A=!1,E=B,R?B:y}),this}evaluate(O){for(let A of this.steps)if(O=A(O),O===y)break;return O}}function k(W,O,A=E=>E){let E=(...H)=>P.fire(A(...H)),B=()=>W.on(O,E),R=()=>W.removeListener(O,E),P=new te({onWillAddFirstListener:B,onDidRemoveLastListener:R});return P.event}e.fromNodeEventEmitter=k;function w(W,O,A=E=>E){let E=(...H)=>P.fire(A(...H)),B=()=>W.addEventListener(O,E),R=()=>W.removeEventListener(O,E),P=new te({onWillAddFirstListener:B,onDidRemoveLastListener:R});return P.event}e.fromDOMEventEmitter=w;function D(W){return new Promise(O=>i(W)(O))}e.toPromise=D;function F(W){let O=new te;return W.then(A=>{O.fire(A)},()=>{O.fire(void 0)}).finally(()=>{O.dispose()}),O.event}e.fromPromise=F;function z(W,O){return W(A=>O.fire(A))}e.forward=z;function N(W,O,A){return O(A),W(E=>O(E))}e.runAndSubscribe=N;class U{constructor(O,A){this._observable=O,this._counter=0,this._hasChanged=!1;let E={onWillAddFirstListener:()=>{O.addObserver(this)},onDidRemoveLastListener:()=>{O.removeObserver(this)}};this.emitter=new te(E),A&&A.add(this.emitter)}beginUpdate(O){this._counter++}handlePossibleChange(O){}handleChange(O,A){this._hasChanged=!0}endUpdate(O){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Y(W,O){return new U(W,O).emitter.event}e.fromObservable=Y;function K(W){return(O,A,E)=>{let B=0,R=!1,P={beginUpdate(){B++},endUpdate(){B--,B===0&&(W.reportChanges(),R&&(R=!1,O.call(A)))},handlePossibleChange(){},handleChange(){R=!0}};W.addObserver(P),W.reportChanges();let H={dispose(){W.removeObserver(P)}};return E instanceof Ys?E.add(H):Array.isArray(E)&&E.push(H),H}}e.fromObservableLight=K})(Mt||(Mt={}));var kl=class xl{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${xl._idPool++}`,xl.all.add(this)}start(t){this._stopWatch=new om,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}}};kl.all=new Set,kl._idPool=0;var am=kl,lm=-1,Df=class Rf{constructor(t,i,s=(Rf._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.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 um(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[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};Df._idPool=1;var hm=Df,cm=class Pf{constructor(t){this.value=t}static create(){let t=new Error;return new Pf(t.stack??"")}print(){console.warn(this.value.split(`
27
+ `+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)}},$g=new Zg;function Uo(e){em(e)||$g.onUnexpectedError(e)}var bl="Canceled";function em(e){return e instanceof tm?!0:e instanceof Error&&e.name===bl&&e.message===bl}var tm=class extends Error{constructor(){super(bl),this.name=this.message}};function im(e){return new Error(`Illegal argument: ${e}`)}var wc=class Sl extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Sl)return t;let i=new Sl;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},yl=class Cf extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Cf.prototype)}};function ii(e,t=0){return e[e.length-(1+t)]}var sm;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(sm||(sm={}));function rm(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var kf;(e=>{function t(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(w){yield w}e.single=r;function n(w){return t(w)?w:r(w)}e.wrap=n;function o(w){return w||i}e.from=o;function*a(w){for(let P=w.length-1;P>=0;P--)yield w[P]}e.reverse=a;function c(w){return!w||w[Symbol.iterator]().next().done===!0}e.isEmpty=c;function h(w){return w[Symbol.iterator]().next().value}e.first=h;function d(w,P){let H=0;for(let U of w)if(P(U,H++))return!0;return!1}e.some=d;function u(w,P){for(let H of w)if(P(H))return H}e.find=u;function*f(w,P){for(let H of w)P(H)&&(yield H)}e.filter=f;function*_(w,P){let H=0;for(let U of w)yield P(U,H++)}e.map=_;function*v(w,P){let H=0;for(let U of w)yield*P(U,H++)}e.flatMap=v;function*m(...w){for(let P of w)yield*P}e.concat=m;function g(w,P,H){let U=H;for(let j of w)U=P(U,j);return U}e.reduce=g;function*y(w,P,H=w.length){for(P<0&&(P+=w.length),H<0?H+=w.length:H>w.length&&(H=w.length);P<H;P++)yield w[P]}e.slice=y;function C(w,P=Number.POSITIVE_INFINITY){let H=[];if(P===0)return[H,w];let U=w[Symbol.iterator]();for(let j=0;j<P;j++){let Z=U.next();if(Z.done)return[H,e.empty()];H.push(Z.value)}return[H,{[Symbol.iterator](){return U}}]}e.consume=C;async function k(w){let P=[];for await(let H of w)P.push(H);return Promise.resolve(P)}e.asyncToArray=k})(kf||(kf={}));function Br(e){if(kf.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}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 nm(...e){return tt(()=>Br(e))}function tt(e){return{dispose:rm(()=>{e()})}}var xf=class Ef{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{Br(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?Ef.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)}};xf.DISABLE_DISPOSED_WARNING=!1;var Gs=xf,Oe=class{constructor(){this._store=new Gs,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)}};Oe.None=Object.freeze({dispose(){}});var Sn=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}},vs=typeof window=="object"?window:globalThis,wl=class Cl{constructor(t){this.element=t,this.next=Cl.Undefined,this.prev=Cl.Undefined}};wl.Undefined=new wl(void 0);var it=wl,Cc=class{constructor(){this._first=it.Undefined,this._last=it.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===it.Undefined}clear(){let e=this._first;for(;e!==it.Undefined;){let t=e.next;e.prev=it.Undefined,e.next=it.Undefined,e=t}this._first=it.Undefined,this._last=it.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new it(e);if(this._first===it.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==it.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==it.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==it.Undefined&&e.next!==it.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===it.Undefined&&e.next===it.Undefined?(this._first=it.Undefined,this._last=it.Undefined):e.next===it.Undefined?(this._last=this._last.prev,this._last.next=it.Undefined):e.prev===it.Undefined&&(this._first=this._first.next,this._first.prev=it.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==it.Undefined;)yield e.element,e=e.next}},om=globalThis.performance&&typeof globalThis.performance.now=="function",am=class Df{static create(t){return new Df(t)}constructor(t){this._now=om&&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}},Bt;(e=>{e.None=()=>Oe.None;function t(I,A){return u(I,()=>{},0,void 0,!0,void 0,A)}e.defer=t;function i(I){return(A,L=null,x)=>{let M=!1,E;return E=I(R=>{if(!M)return E?E.dispose():M=!0,A.call(L,R)},null,x),M&&E.dispose(),E}}e.once=i;function s(I,A,L){return h((x,M=null,E)=>I(R=>x.call(M,A(R)),null,E),L)}e.map=s;function r(I,A,L){return h((x,M=null,E)=>I(R=>{A(R),x.call(M,R)},null,E),L)}e.forEach=r;function n(I,A,L){return h((x,M=null,E)=>I(R=>A(R)&&x.call(M,R),null,E),L)}e.filter=n;function o(I){return I}e.signal=o;function a(...I){return(A,L=null,x)=>{let M=nm(...I.map(E=>E(R=>A.call(L,R))));return d(M,x)}}e.any=a;function c(I,A,L,x){let M=L;return s(I,E=>(M=A(M,E),M),x)}e.reduce=c;function h(I,A){let L,x={onWillAddFirstListener(){L=I(M.fire,M)},onDidRemoveLastListener(){L==null||L.dispose()}},M=new ie(x);return A==null||A.add(M),M.event}function d(I,A){return A instanceof Array?A.push(I):A&&A.add(I),I}function u(I,A,L=100,x=!1,M=!1,E,R){let z,X,de,Se=0,he,me={leakWarningThreshold:E,onWillAddFirstListener(){z=I(xe=>{Se++,X=A(X,xe),x&&!de&&(we.fire(X),X=void 0),he=()=>{let fe=X;X=void 0,de=void 0,(!x||Se>1)&&we.fire(fe),Se=0},typeof L=="number"?(clearTimeout(de),de=setTimeout(he,L)):de===void 0&&(de=0,queueMicrotask(he))})},onWillRemoveListener(){M&&Se>0&&(he==null||he())},onDidRemoveLastListener(){he=void 0,z.dispose()}},we=new ie(me);return R==null||R.add(we),we.event}e.debounce=u;function f(I,A=0,L){return e.debounce(I,(x,M)=>x?(x.push(M),x):[M],A,void 0,!0,void 0,L)}e.accumulate=f;function _(I,A=(x,M)=>x===M,L){let x=!0,M;return n(I,E=>{let R=x||!A(E,M);return x=!1,M=E,R},L)}e.latch=_;function v(I,A,L){return[e.filter(I,A,L),e.filter(I,x=>!A(x),L)]}e.split=v;function m(I,A=!1,L=[],x){let M=L.slice(),E=I(X=>{M?M.push(X):z.fire(X)});x&&x.add(E);let R=()=>{M==null||M.forEach(X=>z.fire(X)),M=null},z=new ie({onWillAddFirstListener(){E||(E=I(X=>z.fire(X)),x&&x.add(E))},onDidAddFirstListener(){M&&(A?setTimeout(R):R())},onDidRemoveLastListener(){E&&E.dispose(),E=null}});return x&&x.add(z),z.event}e.buffer=m;function g(I,A){return(L,x,M)=>{let E=A(new C);return I(function(R){let z=E.evaluate(R);z!==y&&L.call(x,z)},void 0,M)}}e.chain=g;let y=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(A){return this.steps.push(A),this}forEach(A){return this.steps.push(L=>(A(L),L)),this}filter(A){return this.steps.push(L=>A(L)?L:y),this}reduce(A,L){let x=L;return this.steps.push(M=>(x=A(x,M),x)),this}latch(A=(L,x)=>L===x){let L=!0,x;return this.steps.push(M=>{let E=L||!A(M,x);return L=!1,x=M,E?M:y}),this}evaluate(A){for(let L of this.steps)if(A=L(A),A===y)break;return A}}function k(I,A,L=x=>x){let x=(...z)=>R.fire(L(...z)),M=()=>I.on(A,x),E=()=>I.removeListener(A,x),R=new ie({onWillAddFirstListener:M,onDidRemoveLastListener:E});return R.event}e.fromNodeEventEmitter=k;function w(I,A,L=x=>x){let x=(...z)=>R.fire(L(...z)),M=()=>I.addEventListener(A,x),E=()=>I.removeEventListener(A,x),R=new ie({onWillAddFirstListener:M,onDidRemoveLastListener:E});return R.event}e.fromDOMEventEmitter=w;function P(I){return new Promise(A=>i(I)(A))}e.toPromise=P;function H(I){let A=new ie;return I.then(L=>{A.fire(L)},()=>{A.fire(void 0)}).finally(()=>{A.dispose()}),A.event}e.fromPromise=H;function U(I,A){return I(L=>A.fire(L))}e.forward=U;function j(I,A,L){return A(L),I(x=>A(x))}e.runAndSubscribe=j;class Z{constructor(A,L){this._observable=A,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{A.addObserver(this)},onDidRemoveLastListener:()=>{A.removeObserver(this)}};this.emitter=new ie(x),L&&L.add(this.emitter)}beginUpdate(A){this._counter++}handlePossibleChange(A){}handleChange(A,L){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 G(I,A){return new Z(I,A).emitter.event}e.fromObservable=G;function N(I){return(A,L,x)=>{let M=0,E=!1,R={beginUpdate(){M++},endUpdate(){M--,M===0&&(I.reportChanges(),E&&(E=!1,A.call(L)))},handlePossibleChange(){},handleChange(){E=!0}};I.addObserver(R),I.reportChanges();let z={dispose(){I.removeObserver(R)}};return x instanceof Gs?x.add(z):Array.isArray(x)&&x.push(z),z}}e.fromObservableLight=N})(Bt||(Bt={}));var kl=class xl{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${xl._idPool++}`,xl.all.add(this)}start(t){this._stopWatch=new am,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}}};kl.all=new Set,kl._idPool=0;var lm=kl,hm=-1,Rf=class Pf{constructor(t,i,s=(Pf._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.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 dm(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[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};Rf._idPool=1;var cm=Rf,um=class Tf{constructor(t){this.value=t}static create(){let t=new Error;return new Tf(t.stack??"")}print(){console.warn(this.value.split(`
28
28
  `).slice(2).join(`
29
- `))}},um=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},dm=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},fm=0,Aa=class{constructor(e){this.value=e,this.id=fm++}},_m=2,vm,te=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new hm((e==null?void 0:e.onListenerError)??Uo,((i=this._options)==null?void 0:i.leakWarningThreshold)??lm):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new am(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;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),(s=this._leakageMon)==null||s.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 dm(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Uo)(_),Oe.None}if(this._disposed)return Oe.None;t&&(e=e.bind(t));let s=new Aa(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=cm.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Aa?(this._deliveryQueue??(this._deliveryQueue=new pm),this._listeners=[this._listeners,s]):this._listeners.push(s):((c=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||c.call(a,this),this._listeners=s,(d=(h=this._options)==null?void 0:h.onDidAddFirstListener)==null||d.call(h,this)),this._size++;let n=it(()=>{r==null||r(),this._removeListener(s)});return i instanceof Ys?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,a;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,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 s=this._deliveryQueue.current===this;if(this._size*_m<=t.length){let c=0;for(let h=0;h<t.length;h++)t[h]?t[c++]=t[h]:s&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=c}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Uo;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_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,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Aa)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},pm=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}},El=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 s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}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 s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};El.INSTANCE=new El;var Lh=El;function gm(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Lh.INSTANCE.onDidChangeZoomLevel;function mm(e){return Lh.INSTANCE.getZoomFactor(e)}Lh.INSTANCE.onDidChangeFullscreen;var Dn=typeof navigator=="object"?navigator.userAgent:"",Dl=Dn.indexOf("Firefox")>=0,bm=Dn.indexOf("AppleWebKit")>=0,Ah=Dn.indexOf("Chrome")>=0,Sm=!Ah&&Dn.indexOf("Safari")>=0;Dn.indexOf("Electron/")>=0;Dn.indexOf("Android")>=0;var Oa=!1;if(typeof _s.matchMedia=="function"){let e=_s.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=_s.matchMedia("(display-mode: fullscreen)");Oa=e.matches,gm(_s,e,({matches:i})=>{Oa&&t.matches||(Oa=i)})}var Ur="en",Rl=!1,Pl=!1,Ko=!1,Tf=!1,Mo,qo=Ur,kc=Ur,ym,Ti,Dr=globalThis,Pt,Ru;typeof Dr.vscode<"u"&&typeof Dr.vscode.process<"u"?Pt=Dr.vscode.process:typeof process<"u"&&typeof((Ru=process==null?void 0:process.versions)==null?void 0:Ru.node)=="string"&&(Pt=process);var Pu,wm=typeof((Pu=Pt==null?void 0:Pt.versions)==null?void 0:Pu.electron)=="string",Cm=wm&&(Pt==null?void 0:Pt.type)==="renderer",Tu;if(typeof Pt=="object"){Rl=Pt.platform==="win32",Pl=Pt.platform==="darwin",Ko=Pt.platform==="linux",Ko&&Pt.env.SNAP&&Pt.env.SNAP_REVISION,Pt.env.CI||Pt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Mo=Ur,qo=Ur;let e=Pt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Mo=t.userLocale,kc=t.osLocale,qo=t.resolvedLanguage||Ur,ym=(Tu=t.languagePack)==null?void 0:Tu.translationsConfigFile}catch{}Tf=!0}else typeof navigator=="object"&&!Cm?(Ti=navigator.userAgent,Rl=Ti.indexOf("Windows")>=0,Pl=Ti.indexOf("Macintosh")>=0,(Ti.indexOf("Macintosh")>=0||Ti.indexOf("iPad")>=0||Ti.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ko=Ti.indexOf("Linux")>=0,(Ti==null?void 0:Ti.indexOf("Mobi"))>=0,qo=globalThis._VSCODE_NLS_LANGUAGE||Ur,Mo=navigator.language.toLowerCase(),kc=Mo):console.error("Unable to resolve platform.");var Mf=Rl,is=Pl,km=Ko,xc=Tf,rs=Ti,xs=qo,xm;(e=>{function t(){return xs}e.value=t;function i(){return xs.length===2?xs==="en":xs.length>=3?xs[0]==="e"&&xs[1]==="n"&&xs[2]==="-":!1}e.isDefaultVariant=i;function s(){return xs==="en"}e.isDefault=s})(xm||(xm={}));var Em=typeof Dr.postMessage=="function"&&!Dr.importScripts;(()=>{if(Em){let e=[];Dr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Dr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Dm=!!(rs&&rs.indexOf("Chrome")>=0);rs&&rs.indexOf("Firefox")>=0;!Dm&&rs&&rs.indexOf("Safari")>=0;rs&&rs.indexOf("Edg/")>=0;rs&&rs.indexOf("Android")>=0;var Hr=typeof navigator=="object"?navigator:{};xc||document.queryCommandSupported&&document.queryCommandSupported("copy")||Hr&&Hr.clipboard&&Hr.clipboard.writeText,xc||Hr&&Hr.clipboard&&Hr.clipboard.readText;var Oh=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}},Ia=new Oh,Ec=new Oh,Dc=new Oh,Rm=new Array(230),Bf;(e=>{function t(a){return Ia.keyCodeToStr(a)}e.toString=t;function i(a){return Ia.strToKeyCode(a)}e.fromString=i;function s(a){return Ec.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return Dc.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return Ec.strToKeyCode(a)||Dc.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 Ia.keyCodeToStr(a)}e.toElectronAccelerator=o})(Bf||(Bf={}));var Pm=class Lf{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Lf&&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",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Tm([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Tm=class{constructor(e){if(e.length===0)throw tm("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 Mm(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Bf.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Dl)switch(t){case 59:return 85;case 60:if(km)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(is)return 57;break}else if(bm&&(is&&t===93||!is&&t===92))return 57;return Rm[t]||0}var Bm=is?256:2048,Lm=512,Am=1024,Om=is?2048:256,Rc=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=Mm(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|=Bm),this.altKey&&(t|=Lm),this.shiftKey&&(t|=Am),this.metaKey&&(t|=Om),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Pm(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Pc=new WeakMap;function Im(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 Nm=class{static getSameOriginWindowChain(e){let t=Pc.get(e);if(!t){t=[],Pc.set(e,t);let i=e,s;do s=Im(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},Bo=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=Nm.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Tc=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Ah){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?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?Dl&&!is?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Sm&&Mf?this.deltaX=-(n.wheelDeltaX/120):s?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?Dl&&!is?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?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()}},Af=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Fm;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Wm?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Af})})(Fm||(Fm={}));var Wm=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?Af:(this._emitter||(this._emitter=new te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ih=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 yl("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new yl("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Hm=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 yl("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=it(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},zm;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(zm||(zm={}));var Mc=class di{static fromArray(t){return new di(i=>{i.emitMany(t)})}static fromPromise(t){return new di(async i=>{i.emitMany(await t)})}static fromPromises(t){return new di(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new di(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new te,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 Mt.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 di(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return di.map(this,t)}static filter(t,i){return new di(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return di.filter(this,t)}static coalesce(t){return di.filter(t,i=>!!i)}coalesce(){return di.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return di.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())}};Mc.EMPTY=Mc.fromArray([]);var{getWindow:es,getWindowId:Um,onDidRegisterWindow:Km}=(function(){let e=new Map,t={window:_s,disposables:new Ys};e.set(_s.vscodeWindowId,t);let i=new te,s=new te,r=new te;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Oe.None;let a=new Ys,c={window:o,disposables:a.add(new Ys)};return e.set(o.vscodeWindowId,c),a.add(it(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(we(o,yt.BEFORE_UNLOAD,()=>{r.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:_s},getDocument(o){return es(o).document}}})(),qm=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function we(e,t,i,s){return new qm(e,t,i,s)}var Bc=function(e,t,i,s){return we(e,t,i,s)},Nh,jm=class extends Hm{constructor(e){super(),this.defaultTarget=e&&es(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Lc=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){Uo(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(Lc.sort),o.shift().execute();s.set(n,!1)};Nh=(n,o,a=0)=>{let c=Um(n),h=new Lc(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(()=>r(c))),h}})();function Vm(e){let t=e.getBoundingClientRect(),i=es(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var yt={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"},Ym=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=Yt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Yt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Yt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Yt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Yt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Yt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Yt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Yt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Yt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Yt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Yt(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=Yt(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=Yt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Yt(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 Yt(e){return typeof e=="number"?`${e}px`:e}function Gn(e){return new Ym(e)}var Of=class{constructor(){this._hooks=new Ys,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,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(it(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=es(e)}this._hooks.add(we(n,yt.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(we(n,yt.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Gm(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Vi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Vi||(Vi={}));var Nn=class Ot extends Oe{constructor(){super(),this.dispatched=!1,this.targets=new Cc,this.ignoreTargets=new Cc,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Mt.runAndSubscribe(Km,({window:t,disposables:i})=>{i.add(we(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(we(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(we(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:_s,disposables:this._store}))}static addTarget(t){if(!Ot.isTouchDevice())return Oe.None;Ot.INSTANCE||(Ot.INSTANCE=new Ot);let i=Ot.INSTANCE.targets.push(t);return it(i)}static ignoreTarget(t){if(!Ot.isTouchDevice())return Oe.None;Ot.INSTANCE||(Ot.INSTANCE=new Ot);let i=Ot.INSTANCE.ignoreTargets.push(t);return it(i)}static isTouchDevice(){return"ontouchstart"in _s||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 s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);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(Vi.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 s=Date.now(),r=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<Ot.HOLD_DELAY&&Math.abs(c.initialPageX-ii(c.rollingPageX))<30&&Math.abs(c.initialPageY-ii(c.rollingPageY))<30){let d=this.newGestureEvent(Vi.Tap,c.initialTarget);d.pageX=ii(c.rollingPageX),d.pageY=ii(c.rollingPageY),this.dispatchEvent(d)}else if(h>=Ot.HOLD_DELAY&&Math.abs(c.initialPageX-ii(c.rollingPageX))<30&&Math.abs(c.initialPageY-ii(c.rollingPageY))<30){let d=this.newGestureEvent(Vi.Contextmenu,c.initialTarget);d.pageX=ii(c.rollingPageX),d.pageY=ii(c.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=ii(c.rollingPageX),u=ii(c.rollingPageY),f=ii(c.rollingTimestamps)-c.rollingTimestamps[0],_=d-c.rollingPageX[0],v=u-c.rollingPageY[0],m=[...this.targets].filter(g=>c.initialTarget instanceof Node&&g.contains(c.initialTarget));this.inertia(t,m,s,Math.abs(_)/f,_>0?1:-1,d,Math.abs(v)/f,v>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Vi.End,c.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Vi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Ot.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Vi.Change||t.type===Vi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,c,h){this.handle=Nh(t,()=>{let d=Date.now(),u=d-s,f=0,_=0,v=!0;r+=Ot.SCROLL_FRICTION*u,a+=Ot.SCROLL_FRICTION*u,r>0&&(v=!1,f=n*r*u),a>0&&(v=!1,_=c*a*u);let m=this.newGestureEvent(Vi.Change);m.translationX=f,m.translationY=_,i.forEach(g=>g.dispatchEvent(m)),v||this.inertia(t,i,d,r,n,o+f,a,c,h+_)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);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(Vi.Change,o.initialTarget);a.translationX=n.pageX-ii(o.rollingPageX),a.translationY=n.pageY-ii(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)}};Nn.SCROLL_FRICTION=-.005,Nn.HOLD_DELAY=700,Nn.CLEAR_TAP_COUNT_TIME=400,at([Gm],Nn,"isTouchDevice",1);var Xm=Nn,Fh=class extends Oe{onclick(e,t){this._register(we(e,yt.CLICK,i=>t(new Bo(es(e),i))))}onmousedown(e,t){this._register(we(e,yt.MOUSE_DOWN,i=>t(new Bo(es(e),i))))}onmouseover(e,t){this._register(we(e,yt.MOUSE_OVER,i=>t(new Bo(es(e),i))))}onmouseleave(e,t){this._register(we(e,yt.MOUSE_LEAVE,i=>t(new Bo(es(e),i))))}onkeydown(e,t){this._register(we(e,yt.KEY_DOWN,i=>t(new Rc(i))))}onkeyup(e,t){this._register(we(e,yt.KEY_UP,i=>t(new Rc(i))))}oninput(e,t){this._register(we(e,yt.INPUT,t))}onblur(e,t){this._register(we(e,yt.BLUR,t))}onfocus(e,t){this._register(we(e,yt.FOCUS,t))}onchange(e,t){this._register(we(e,yt.CHANGE,t))}ignoreGesture(e){return Xm.ignoreTarget(e)}},Ac=11,Qm=class extends Fh{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=Ac+"px",this.domNode.style.height=Ac+"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 Of),this._register(Bc(this.bgDomNode,yt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Bc(this.domNode,yt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new jm),this._pointerdownScheduleRepeatTimer=this._register(new Ih)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,es(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()}},Jm=class Tl{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,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 Tl(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 Tl(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 s=this.width!==t.width,r=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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:c}}},Zm=class extends Oe{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 Jm(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 s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 s;t?s=new Ic(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Ic.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)))}},Oc=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Na(e,t){let i=t-e;return function(s){return e+i*tb(s)}}function $m(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Ic=class Ml{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),$m(Na(t,r),Na(n,i),.33)}return Na(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 s=this.scrollLeft(i),r=this.scrollTop(i);return new Oc(s,r,!1)}return new Oc(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Ml.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new Ml(t,i,r,s)}};function eb(e){return Math.pow(e,3)}function tb(e){return 1-eb(1-e)}var ib=class extends Oe{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 Ih)}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":"")))}},sb=140,If=class extends Fh{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 ib(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Of),this._shouldRender=!0,this.domNode=Gn(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(we(this.domNode.domNode,yt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Qm(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Gn(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 s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(we(this.slider.domNode,yt.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.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(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?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 r=Vm(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),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),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(Mf&&o>sb){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.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()}},Nf=class Bl{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Bl(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,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),c=r>0&&r>s;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(s*a/r))),d=(a-h)/(r-s),u=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(h),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=Bl._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,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},rb=class extends If{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Nf(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.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}},nb=class extends If{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Nf(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.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}},ob=500,Nc=50,ab=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Ll=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,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Ah){let i=es(t.browserEvent),s=mm(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new ab(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),c=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,a),1),d=Math.max(r,o),u=Math.max(n,a);d%c===0&&u%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Ll.INSTANCE=new Ll;var lb=Ll,hb=class extends Fh{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=ub(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new nb(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new rb(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Gn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Gn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Gn(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Ih),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Br(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,is&&(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 Tc(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Br(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Tc(i))};this._mouseWheelToDispose.push(we(this._listenOnDomNode,yt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=lb.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=!is&&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=Nc*n,u=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(h,u)}if(o){let d=Nc*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 s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw 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,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),ob)}},cb=class extends hb{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 ub(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,is&&(t.className+=" mac"),t}var Al=class extends Oe{constructor(e,t,i,s,r,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 Zm({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Nh(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new cb(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(r.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Mt.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(it(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(it(()=>this._styleElement.remove())),this._register(Mt.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(`
30
- `)})),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}};Al=at([ae(2,qt),ae(3,ys),ae(4,gf),ae(5,En),ae(6,jt),ae(7,ws)],Al);var Ol=class extends Oe{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(it(()=>{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 s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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()}};Ol=at([ae(1,qt),ae(2,ys),ae(3,So),ae(4,ws)],Ol);var db=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)}},qi={full:0,left:0,center:0,right:0},Es={full:0,left:0,center:0,right:0},Tn={full:0,left:0,center:0,right:0},ea=class extends Oe{constructor(e,t,i,s,r,n,o,a){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new db,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(it(()=>{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);Es.full=this._canvas.width,Es.left=e,Es.center=t,Es.right=e,this._refreshDrawHeightConstants(),Tn.full=1,Tn.left=1,Tn.center=1+Es.left,Tn.right=1+Es.left+Es.center}_refreshDrawHeightConstants(){qi.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);qi.left=t,qi.center=t,qi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.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(Tn[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-qi[e.position||"full"]/2),Es[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+qi[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}))}};ea=at([ae(2,qt),ae(3,So),ae(4,ws),ae(5,jt),ae(6,En),ae(7,ys)],ea);var V;(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=`
31
- `,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=""))(V||(V={}));var jo;(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="Ÿ"))(jo||(jo={}));var Ff;(e=>e.ST=`${V.ESC}\\`)(Ff||(Ff={}));var Il=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(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(`${V.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,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"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=r+"px",this._textarea.style.top=s+"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)}}};Il=at([ae(2,qt),ae(3,jt),ae(4,Ir),ae(5,ws)],Il);var wt=0,Ct=0,kt=0,ot=0,Fc={css:"#00000000",rgba:0},ut;(e=>{function t(r,n,o,a){return a!==void 0?`#${tr(r)}${tr(n)}${tr(o)}${tr(a)}`:`#${tr(r)}${tr(n)}${tr(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(ut||(ut={}));var $e;(e=>{function t(c,h){if(ot=(h.rgba&255)/255,ot===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,v=c.rgba>>16&255,m=c.rgba>>8&255;wt=_+Math.round((d-_)*ot),Ct=v+Math.round((u-v)*ot),kt=m+Math.round((f-m)*ot);let g=ut.toCss(wt,Ct,kt),y=ut.toRgba(wt,Ct,kt);return{css:g,rgba:y}}e.blend=t;function i(c){return(c.rgba&255)===255}e.isOpaque=i;function s(c,h,d){let u=Vo.ensureContrastRatio(c.rgba,h.rgba,d);if(u)return ut.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function r(c){let h=(c.rgba|255)>>>0;return[wt,Ct,kt]=Vo.toChannels(h),{css:ut.toCss(wt,Ct,kt),rgba:h}}e.opaque=r;function n(c,h){return ot=Math.round(h*255),[wt,Ct,kt]=Vo.toChannels(c.rgba),{css:ut.toCss(wt,Ct,kt,ot),rgba:ut.toRgba(wt,Ct,kt,ot)}}e.opacity=n;function o(c,h){return ot=c.rgba&255,n(c,ot*h/255)}e.multiplyOpacity=o;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})($e||($e={}));var rt;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return wt=parseInt(r.slice(1,2).repeat(2),16),Ct=parseInt(r.slice(2,3).repeat(2),16),kt=parseInt(r.slice(3,4).repeat(2),16),ut.toColor(wt,Ct,kt);case 5:return wt=parseInt(r.slice(1,2).repeat(2),16),Ct=parseInt(r.slice(2,3).repeat(2),16),kt=parseInt(r.slice(3,4).repeat(2),16),ot=parseInt(r.slice(4,5).repeat(2),16),ut.toColor(wt,Ct,kt,ot);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return wt=parseInt(n[1]),Ct=parseInt(n[2]),kt=parseInt(n[3]),ot=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ut.toColor(wt,Ct,kt,ot);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[wt,Ct,kt,ot]=t.getImageData(0,0,1,1).data,ot!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ut.toRgba(wt,Ct,kt,ot),css:r}}e.toColor=s})(rt||(rt={}));var Ht;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/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})(Ht||(Ht={}));var Vo;(e=>{function t(o,a){if(ot=(a&255)/255,ot===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)*ot),Ct=f+Math.round((h-f)*ot),kt=_+Math.round((d-_)*ot),ut.toRgba(wt,Ct,kt)}e.blend=t;function i(o,a,c){let h=Ht.relativeLuminance(o>>8),d=Ht.relativeLuminance(a>>8);if(os(h,d)<c){if(d<h){let _=s(o,a,c),v=os(h,Ht.relativeLuminance(_>>8));if(v<c){let m=r(o,a,c),g=os(h,Ht.relativeLuminance(m>>8));return v>g?_:m}return _}let u=r(o,a,c),f=os(h,Ht.relativeLuminance(u>>8));if(f<c){let _=s(o,a,c),v=os(h,Ht.relativeLuminance(_>>8));return f>v?u:_}return u}}e.ensureContrastRatio=i;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,v=a>>8&255,m=os(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));for(;m<c&&(f>0||_>0||v>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),m=os(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));return(f<<24|_<<16|v<<8|255)>>>0}e.reduceLuminance=s;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,v=a>>8&255,m=os(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));for(;m<c&&(f<255||_<255||v<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),m=os(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));return(f<<24|_<<16|v<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Vo||(Vo={}));function tr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function os(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var fb=class extends bo{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()]}},ta=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new xi}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=[],s=t.translateToString(!0),r=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-r>1){let d=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<d.length;u++)i.push(d[u])}r=h,o=n,a=this._workCell.fg,c=this._workCell.bg}n+=this._workCell.getChars().length||zs.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<h.length;d++)i.push(h[d])}return i}_getJoinedRanges(e,t,i,s,r){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++)ta._mergeRanges(o,c[h])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let c=t.getWidth(a),h=t.getString(a).length||zs.length;if(c!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ta=at([ae(0,qt)],ta);function _b(e){return 57508<=e&&e<=57558}function vb(e){return 9472<=e&&e<=9631}function pb(e){return _b(e)||vb(e)}function gb(){return{css:{canvas:Lo(),cell:Lo()},device:{canvas:Lo(),cell:Lo(),char:{width:0,height:0,left:0,top:0}}}}function Lo(){return{width:0,height:0}}var Nl=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new xi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,c,h,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,v=e.getNoBgTrimmedLength();i&&v<n+1&&(v=n+1);let m,g=0,y="",C=0,k=0,w=0,D=0,F=!1,z=0,N=!1,U=0,Y=0,K=[],W=h!==-1&&d!==-1;for(let O=0;O<v;O++){e.loadCell(O,this._workCell);let A=this._workCell.getWidth();if(A===0)continue;let E=!1,B=O>=Y,R=O,P=this._workCell;if(f.length>0&&O===f[0][0]&&B){let Ce=f.shift(),q=this._isCellInSelection(Ce[0],t);for(C=Ce[0]+1;C<Ce[1];C++)B&&(B=q===this._isCellInSelection(C,t));B&&(B=!i||n<Ce[0]||n>=Ce[1]),B?(E=!0,P=new fb(this._workCell,e.translateToString(!0,Ce[0],Ce[1]),Ce[1]-Ce[0]),R=Ce[1]-1,A=P.getWidth()):Y=Ce[1]}let H=this._isCellInSelection(O,t),Z=i&&O===n,de=W&&O>=h&&O<=d,be=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,Ce=>{be=!0});let he=P.getChars()||zs;if(he===" "&&(P.isUnderline()||P.isOverline())&&(he=" "),U=A*a-c.get(he,P.isBold(),P.isItalic()),!m)m=this._document.createElement("span");else if(g&&(H&&N||!H&&!N&&P.bg===k)&&(H&&N&&_.selectionForeground||P.fg===w)&&P.extended.ext===D&&de===F&&U===z&&!Z&&!E&&!be&&B){P.isInvisible()?y+=zs:y+=he,g++;continue}else g&&(m.textContent=y),m=this._document.createElement("span"),g=0,y="";if(k=P.bg,w=P.fg,D=P.extended.ext,F=de,z=U,N=H,E&&n>=O&&n<=R&&(n=O),!this._coreService.isCursorHidden&&Z&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){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(P.isBold()&&K.push("xterm-bold"),P.isItalic()&&K.push("xterm-italic"),P.isDim()&&K.push("xterm-dim"),P.isInvisible()?y=zs:y=P.getChars()||zs,P.isUnderline()&&(K.push(`xterm-underline-${P.extended.underlineStyle}`),y===" "&&(y=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())m.style.textDecorationColor=`rgb(${bo.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let Ce=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&Ce<8&&(Ce+=8),m.style.textDecorationColor=_.ansi[Ce].css}P.isOverline()&&(K.push("xterm-overline"),y===" "&&(y=" ")),P.isStrikethrough()&&K.push("xterm-strikethrough"),de&&(m.style.textDecoration="underline");let ge=P.getFgColor(),ye=P.getFgColorMode(),ke=P.getBgColor(),ue=P.getBgColorMode(),pe=!!P.isInverse();if(pe){let Ce=ge;ge=ke,ke=Ce;let q=ye;ye=ue,ue=q}let xe,Le,We=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,Ce=>{Ce.options.layer!=="top"&&We||(Ce.backgroundColorRGB&&(ue=50331648,ke=Ce.backgroundColorRGB.rgba>>8&16777215,xe=Ce.backgroundColorRGB),Ce.foregroundColorRGB&&(ye=50331648,ge=Ce.foregroundColorRGB.rgba>>8&16777215,Le=Ce.foregroundColorRGB),We=Ce.options.layer==="top")}),!We&&H&&(xe=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,ke=xe.rgba>>8&16777215,ue=50331648,We=!0,_.selectionForeground&&(ye=50331648,ge=_.selectionForeground.rgba>>8&16777215,Le=_.selectionForeground)),We&&K.push("xterm-decoration-top");let ze;switch(ue){case 16777216:case 33554432:ze=_.ansi[ke],K.push(`xterm-bg-${ke}`);break;case 50331648:ze=ut.toColor(ke>>16,ke>>8&255,ke&255),this._addStyle(m,`background-color:#${Wc((ke>>>0).toString(16),"0",6)}`);break;case 0:default:pe?(ze=_.foreground,K.push("xterm-bg-257")):ze=_.background}switch(xe||P.isDim()&&(xe=$e.multiplyOpacity(ze,.5)),ye){case 16777216:case 33554432:P.isBold()&&ge<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ge+=8),this._applyMinimumContrast(m,ze,_.ansi[ge],P,xe,void 0)||K.push(`xterm-fg-${ge}`);break;case 50331648:let Ce=ut.toColor(ge>>16&255,ge>>8&255,ge&255);this._applyMinimumContrast(m,ze,Ce,P,xe,Le)||this._addStyle(m,`color:#${Wc(ge.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(m,ze,_.foreground,P,xe,Le)||pe&&K.push("xterm-fg-257")}K.length&&(m.className=K.join(" "),K.length=0),!Z&&!E&&!be&&B?g++:m.textContent=y,U!==this.defaultSpacing&&(m.style.letterSpacing=`${U}px`),u.push(m),O=R}return m&&g&&(m.textContent=y),u}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||pb(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=$e.ensureContrastRatio(r||t,n||i,c),o.setColor((r||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,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Nl=at([ae(1,Sf),ae(2,jt),ae(3,ys),ae(4,Ir),ae(5,So),ae(6,En)],Nl);function Wc(e,t,i){for(;e.length<i;)e=t+e;return e}var mb=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.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,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),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,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},bb=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,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,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=s,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 Sb(){return new bb}var Fa="xterm-dom-renderer-owner-",ui="xterm-rows",Ao="xterm-fg-",Hc="xterm-bg-",Mn="xterm-focus",Oo="xterm-selection",yb=1,Fl=class extends Oe{constructor(e,t,i,s,r,n,o,a,c,h,d,u,f,_){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,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=yb++,this._rowElements=[],this._selectionRenderModel=Sb(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ui),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(Oo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=gb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(v=>this._injectCss(v))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Nl,document),this._element.classList.add(Fa+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(v=>this._handleLinkHover(v))),this._register(this._linkifier2.onHideLinkUnderline(v=>this._handleLinkLeave(v))),this._register(it(()=>{this._element.classList.remove(Fa+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new mb(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} .${ui} 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} .${ui} { 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} .${ui} .xterm-dim { color: ${$e.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}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ui}.${Mn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ui}.${Mn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ui}.${Mn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ui} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ui} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ui} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ui} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ui} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Oo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Oo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Oo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ao}${n} { color: ${o.css}; }${this._terminalSelector} .${Ao}${n}.xterm-dim { color: ${$e.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${Hc}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ao}257 { color: ${$e.opaque(e.background).css}; }${this._terminalSelector} .${Ao}257.xterm-dim { color: ${$e.multiplyOpacity($e.opaque(e.background),.5).css}; }${this._terminalSelector} .${Hc}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 s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(Mn),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Mn),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 s=this._selectionRenderModel.viewportStartRow,r=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=s===n?e[0]:0,h=n===r?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=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=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),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=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===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Fa}${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,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,h=Math.min(a.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=i;_<=s;++_){let v=_+a.ydisp,m=this._rowElements[_],g=a.lines.get(v);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,v,v===c,u,f,h,d,this.dimensions.css.cell.width,this._widthCache,n?_===i?e:0:-1,n?(_===s?t:r)-1:-1))}}};Fl=at([ae(7,Mh),ae(8,ya),ae(9,jt),ae(10,qt),ae(11,Ir),ae(12,ys),ae(13,En)],Fl);var Wl=class extends Oe{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 Cb(this._optionsService))}catch{this._measureStrategy=this._register(new wb(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())}};Wl=at([ae(2,jt)],Wl);var Wf=class extends Oe{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)}},wb=class extends Wf{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}},Cb=class extends Wf{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}},kb=class extends Oe{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 xb(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(s=>this._screenDprMonitor.setWindow(s))),this._register(Mt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(we(this._textarea,"focus",()=>this._isFocused=!0)),this._register(we(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}},xb=class extends Oe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new yn),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(it(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=we(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)}},Eb=class extends Oe{constructor(){super(),this.linkProviders=[],this._register(it(()=>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 Wh(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function Db(e,t,i,s,r,n,o,a,c){if(!n)return;let h=Wh(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),s+(c?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h}var Hl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return Db(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Wh(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])}}};Hl=at([ae(0,ws),ae(1,ya)],Hl);var Rb=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=[]}},Hf={};Fg(Hf,{getSafariVersion:()=>Tb,isChromeOS:()=>qf,isFirefox:()=>zf,isIpad:()=>Mb,isIphone:()=>Bb,isLegacyEdge:()=>Pb,isLinux:()=>Hh,isMac:()=>ia,isNode:()=>wa,isSafari:()=>Uf,isWindows:()=>Kf});var wa=typeof process<"u"&&"title"in process,yo=wa?"node":navigator.userAgent,wo=wa?"node":navigator.platform,zf=yo.includes("Firefox"),Pb=yo.includes("Edge"),Uf=/^((?!chrome|android).)*safari/i.test(yo);function Tb(){if(!Uf)return 0;let e=yo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ia=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(wo),Mb=wo==="iPad",Bb=wo==="iPhone",Kf=["Windows","Win16","Win32","WinCE"].includes(wo),Hh=wo.indexOf("Linux")>=0,qf=/\bCrOS\b/.test(yo),jf=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,s=e.timeRemaining(),r=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),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},Lb=class extends jf{_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())}}},Ab=class extends jf{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},sa=!wa&&"requestIdleCallback"in window?Ab:Lb,Ob=class{constructor(){this._queue=new sa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},zl=class extends Oe{constructor(e,t,i,s,r,n,o,a,c){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new yn),this._pausedResizeTask=new Ob,this._observerDisposable=this._register(new yn),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 Rb((h,d)=>this._renderRows(h,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Ib(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(it(()=>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(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=it(()=>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 s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.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 s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};zl=at([ae(2,jt),ae(3,ya),ae(4,Ir),ae(5,So),ae(6,qt),ae(7,ys),ae(8,En)],zl);var Ib=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 Nb(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return Hb(r,n,e,t,i,s)+Ca(n,t,i,s)+zb(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",$n(Math.abs(r-e),Zn(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),c=Wb(n>t?e:r,i)+(a-1)*i.cols+1+Fb(n>t?r:e);return $n(c,Zn(o,s))}function Fb(e,t){return e-1}function Wb(e,t){return t.cols-e}function Hb(e,t,i,s,r,n){return Ca(t,s,r,n).length===0?"":$n(Yf(e,t,e,t-Lr(t,r),!1,r).length,Zn("D",n))}function Ca(e,t,i,s){let r=e-Lr(e,i),n=t-Lr(t,i),o=Math.abs(r-n)-Ub(e,t,i);return $n(o,Zn(Vf(e,t),s))}function zb(e,t,i,s,r,n){let o;Ca(t,s,r,n).length>0?o=s-Lr(s,r):o=t;let a=s,c=Kb(e,t,i,s,r,n);return $n(Yf(e,o,i,a,c==="C",r).length,Zn(c,n))}function Ub(e,t,i){var o;let s=0,r=e-Lr(e,i),n=t-Lr(t,i);for(let a=0;a<Math.abs(r-n);a++){let c=Vf(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+c*a))!=null&&o.isWrapped&&s++}return s}function Lr(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function Kb(e,t,i,s,r,n){let o;return Ca(i,s,r,n).length>0?o=s-Lr(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function Vf(e,t){return e>t?"A":"B"}function Yf(e,t,i,s,r,n){let o=e,a=t,c="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(c+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&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 Zn(e,t){let i=t?"O":"[";return V.ESC+i+e}function $n(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var qb=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 zc(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 Wa=50,jb=15,Vb=50,Yb=500,Gb=" ",Xb=new RegExp(Gb,"g"),Ul=class extends Oe{constructor(e,t,i,s,r,n,o,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new xi,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 qb(this._bufferService),this._activeSelectionMode=0,this._register(it(()=>{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,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=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,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));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?s[s.length-1]+=a:s.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?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(Xb," ")).join(Kf?`\r
29
+ `))}},dm=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},fm=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},_m=0,Aa=class{constructor(e){this.value=e,this.id=_m++}},vm=2,pm,ie=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new cm((e==null?void 0:e.onListenerError)??Uo,((i=this._options)==null?void 0:i.leakWarningThreshold)??hm):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new lm(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;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),(s=this._leakageMon)==null||s.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 fm(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Uo)(_),Oe.None}if(this._disposed)return Oe.None;t&&(e=e.bind(t));let s=new Aa(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=um.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Aa?(this._deliveryQueue??(this._deliveryQueue=new gm),this._listeners=[this._listeners,s]):this._listeners.push(s):((c=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||c.call(a,this),this._listeners=s,(d=(h=this._options)==null?void 0:h.onDidAddFirstListener)==null||d.call(h,this)),this._size++;let n=tt(()=>{r==null||r(),this._removeListener(s)});return i instanceof Gs?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,a;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,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 s=this._deliveryQueue.current===this;if(this._size*vm<=t.length){let c=0;for(let h=0;h<t.length;h++)t[h]?t[c++]=t[h]:s&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=c}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Uo;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_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,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Aa)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},gm=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}},El=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ie,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ie,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 s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}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 s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};El.INSTANCE=new El;var Lh=El;function mm(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Lh.INSTANCE.onDidChangeZoomLevel;function bm(e){return Lh.INSTANCE.getZoomFactor(e)}Lh.INSTANCE.onDidChangeFullscreen;var En=typeof navigator=="object"?navigator.userAgent:"",Dl=En.indexOf("Firefox")>=0,Sm=En.indexOf("AppleWebKit")>=0,Ah=En.indexOf("Chrome")>=0,ym=!Ah&&En.indexOf("Safari")>=0;En.indexOf("Electron/")>=0;En.indexOf("Android")>=0;var Oa=!1;if(typeof vs.matchMedia=="function"){let e=vs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=vs.matchMedia("(display-mode: fullscreen)");Oa=e.matches,mm(vs,e,({matches:i})=>{Oa&&t.matches||(Oa=i)})}var zr="en",Rl=!1,Pl=!1,Ko=!1,Mf=!1,Mo,qo=zr,kc=zr,wm,Pi,Dr=globalThis,Tt,Ru;typeof Dr.vscode<"u"&&typeof Dr.vscode.process<"u"?Tt=Dr.vscode.process:typeof process<"u"&&typeof((Ru=process==null?void 0:process.versions)==null?void 0:Ru.node)=="string"&&(Tt=process);var Pu,Cm=typeof((Pu=Tt==null?void 0:Tt.versions)==null?void 0:Pu.electron)=="string",km=Cm&&(Tt==null?void 0:Tt.type)==="renderer",Tu;if(typeof Tt=="object"){Rl=Tt.platform==="win32",Pl=Tt.platform==="darwin",Ko=Tt.platform==="linux",Ko&&Tt.env.SNAP&&Tt.env.SNAP_REVISION,Tt.env.CI||Tt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Mo=zr,qo=zr;let e=Tt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Mo=t.userLocale,kc=t.osLocale,qo=t.resolvedLanguage||zr,wm=(Tu=t.languagePack)==null?void 0:Tu.translationsConfigFile}catch{}Mf=!0}else typeof navigator=="object"&&!km?(Pi=navigator.userAgent,Rl=Pi.indexOf("Windows")>=0,Pl=Pi.indexOf("Macintosh")>=0,(Pi.indexOf("Macintosh")>=0||Pi.indexOf("iPad")>=0||Pi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ko=Pi.indexOf("Linux")>=0,(Pi==null?void 0:Pi.indexOf("Mobi"))>=0,qo=globalThis._VSCODE_NLS_LANGUAGE||zr,Mo=navigator.language.toLowerCase(),kc=Mo):console.error("Unable to resolve platform.");var Bf=Rl,ss=Pl,xm=Ko,xc=Mf,ns=Pi,Es=qo,Em;(e=>{function t(){return Es}e.value=t;function i(){return Es.length===2?Es==="en":Es.length>=3?Es[0]==="e"&&Es[1]==="n"&&Es[2]==="-":!1}e.isDefaultVariant=i;function s(){return Es==="en"}e.isDefault=s})(Em||(Em={}));var Dm=typeof Dr.postMessage=="function"&&!Dr.importScripts;(()=>{if(Dm){let e=[];Dr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Dr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Rm=!!(ns&&ns.indexOf("Chrome")>=0);ns&&ns.indexOf("Firefox")>=0;!Rm&&ns&&ns.indexOf("Safari")>=0;ns&&ns.indexOf("Edg/")>=0;ns&&ns.indexOf("Android")>=0;var Wr=typeof navigator=="object"?navigator:{};xc||document.queryCommandSupported&&document.queryCommandSupported("copy")||Wr&&Wr.clipboard&&Wr.clipboard.writeText,xc||Wr&&Wr.clipboard&&Wr.clipboard.readText;var Oh=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}},Ia=new Oh,Ec=new Oh,Dc=new Oh,Pm=new Array(230),Lf;(e=>{function t(a){return Ia.keyCodeToStr(a)}e.toString=t;function i(a){return Ia.strToKeyCode(a)}e.fromString=i;function s(a){return Ec.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return Dc.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return Ec.strToKeyCode(a)||Dc.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 Ia.keyCodeToStr(a)}e.toElectronAccelerator=o})(Lf||(Lf={}));var Tm=class Af{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Af&&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",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Mm([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Mm=class{constructor(e){if(e.length===0)throw im("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 Bm(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Lf.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Dl)switch(t){case 59:return 85;case 60:if(xm)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ss)return 57;break}else if(Sm&&(ss&&t===93||!ss&&t===92))return 57;return Pm[t]||0}var Lm=ss?256:2048,Am=512,Om=1024,Im=ss?2048:256,Rc=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=Bm(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|=Lm),this.altKey&&(t|=Am),this.shiftKey&&(t|=Om),this.metaKey&&(t|=Im),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Tm(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Pc=new WeakMap;function Nm(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 Fm=class{static getSameOriginWindowChain(e){let t=Pc.get(e);if(!t){t=[],Pc.set(e,t);let i=e,s;do s=Nm(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},Bo=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=Fm.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Tc=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Ah){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?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?Dl&&!ss?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")ym&&Bf?this.deltaX=-(n.wheelDeltaX/120):s?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?Dl&&!ss?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?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()}},Of=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Wm;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Hm?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Bt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Of})})(Wm||(Wm={}));var Hm=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?Of:(this._emitter||(this._emitter=new ie),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ih=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 yl("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new yl("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},zm=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 yl("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=tt(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Um;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(Um||(Um={}));var Mc=class ui{static fromArray(t){return new ui(i=>{i.emitMany(t)})}static fromPromise(t){return new ui(async i=>{i.emitMany(await t)})}static fromPromises(t){return new ui(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new ui(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ie,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 Bt.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 ui(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return ui.map(this,t)}static filter(t,i){return new ui(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return ui.filter(this,t)}static coalesce(t){return ui.filter(t,i=>!!i)}coalesce(){return ui.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return ui.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())}};Mc.EMPTY=Mc.fromArray([]);var{getWindow:ts,getWindowId:Km,onDidRegisterWindow:qm}=(function(){let e=new Map,t={window:vs,disposables:new Gs};e.set(vs.vscodeWindowId,t);let i=new ie,s=new ie,r=new ie;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Oe.None;let a=new Gs,c={window:o,disposables:a.add(new Gs)};return e.set(o.vscodeWindowId,c),a.add(tt(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(Ce(o,wt.BEFORE_UNLOAD,()=>{r.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:vs},getDocument(o){return ts(o).document}}})(),jm=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ce(e,t,i,s){return new jm(e,t,i,s)}var Bc=function(e,t,i,s){return Ce(e,t,i,s)},Nh,Vm=class extends zm{constructor(e){super(),this.defaultTarget=e&&ts(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Lc=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){Uo(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(Lc.sort),o.shift().execute();s.set(n,!1)};Nh=(n,o,a=0)=>{let c=Km(n),h=new Lc(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(()=>r(c))),h}})();function Ym(e){let t=e.getBoundingClientRect(),i=ts(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var wt={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"},Gm=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=Xt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Xt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Xt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Xt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Xt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Xt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Xt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Xt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Xt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Xt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Xt(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=Xt(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=Xt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Xt(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 Xt(e){return typeof e=="number"?`${e}px`:e}function Gn(e){return new Gm(e)}var If=class{constructor(){this._hooks=new Gs,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,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(tt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=ts(e)}this._hooks.add(Ce(n,wt.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ce(n,wt.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Xm(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Yi||(Yi={}));var Nn=class Ot extends Oe{constructor(){super(),this.dispatched=!1,this.targets=new Cc,this.ignoreTargets=new Cc,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Bt.runAndSubscribe(qm,({window:t,disposables:i})=>{i.add(Ce(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ce(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ce(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:vs,disposables:this._store}))}static addTarget(t){if(!Ot.isTouchDevice())return Oe.None;Ot.INSTANCE||(Ot.INSTANCE=new Ot);let i=Ot.INSTANCE.targets.push(t);return tt(i)}static ignoreTarget(t){if(!Ot.isTouchDevice())return Oe.None;Ot.INSTANCE||(Ot.INSTANCE=new Ot);let i=Ot.INSTANCE.ignoreTargets.push(t);return tt(i)}static isTouchDevice(){return"ontouchstart"in vs||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 s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);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(Yi.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 s=Date.now(),r=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<Ot.HOLD_DELAY&&Math.abs(c.initialPageX-ii(c.rollingPageX))<30&&Math.abs(c.initialPageY-ii(c.rollingPageY))<30){let d=this.newGestureEvent(Yi.Tap,c.initialTarget);d.pageX=ii(c.rollingPageX),d.pageY=ii(c.rollingPageY),this.dispatchEvent(d)}else if(h>=Ot.HOLD_DELAY&&Math.abs(c.initialPageX-ii(c.rollingPageX))<30&&Math.abs(c.initialPageY-ii(c.rollingPageY))<30){let d=this.newGestureEvent(Yi.Contextmenu,c.initialTarget);d.pageX=ii(c.rollingPageX),d.pageY=ii(c.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=ii(c.rollingPageX),u=ii(c.rollingPageY),f=ii(c.rollingTimestamps)-c.rollingTimestamps[0],_=d-c.rollingPageX[0],v=u-c.rollingPageY[0],m=[...this.targets].filter(g=>c.initialTarget instanceof Node&&g.contains(c.initialTarget));this.inertia(t,m,s,Math.abs(_)/f,_>0?1:-1,d,Math.abs(v)/f,v>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Yi.End,c.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Yi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Ot.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Yi.Change||t.type===Yi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,c,h){this.handle=Nh(t,()=>{let d=Date.now(),u=d-s,f=0,_=0,v=!0;r+=Ot.SCROLL_FRICTION*u,a+=Ot.SCROLL_FRICTION*u,r>0&&(v=!1,f=n*r*u),a>0&&(v=!1,_=c*a*u);let m=this.newGestureEvent(Yi.Change);m.translationX=f,m.translationY=_,i.forEach(g=>g.dispatchEvent(m)),v||this.inertia(t,i,d,r,n,o+f,a,c,h+_)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);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(Yi.Change,o.initialTarget);a.translationX=n.pageX-ii(o.rollingPageX),a.translationY=n.pageY-ii(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)}};Nn.SCROLL_FRICTION=-.005,Nn.HOLD_DELAY=700,Nn.CLEAR_TAP_COUNT_TIME=400,ot([Xm],Nn,"isTouchDevice",1);var Qm=Nn,Fh=class extends Oe{onclick(e,t){this._register(Ce(e,wt.CLICK,i=>t(new Bo(ts(e),i))))}onmousedown(e,t){this._register(Ce(e,wt.MOUSE_DOWN,i=>t(new Bo(ts(e),i))))}onmouseover(e,t){this._register(Ce(e,wt.MOUSE_OVER,i=>t(new Bo(ts(e),i))))}onmouseleave(e,t){this._register(Ce(e,wt.MOUSE_LEAVE,i=>t(new Bo(ts(e),i))))}onkeydown(e,t){this._register(Ce(e,wt.KEY_DOWN,i=>t(new Rc(i))))}onkeyup(e,t){this._register(Ce(e,wt.KEY_UP,i=>t(new Rc(i))))}oninput(e,t){this._register(Ce(e,wt.INPUT,t))}onblur(e,t){this._register(Ce(e,wt.BLUR,t))}onfocus(e,t){this._register(Ce(e,wt.FOCUS,t))}onchange(e,t){this._register(Ce(e,wt.CHANGE,t))}ignoreGesture(e){return Qm.ignoreTarget(e)}},Ac=11,Jm=class extends Fh{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=Ac+"px",this.domNode.style.height=Ac+"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 If),this._register(Bc(this.bgDomNode,wt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Bc(this.domNode,wt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Vm),this._pointerdownScheduleRepeatTimer=this._register(new Ih)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ts(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()}},Zm=class Tl{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,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 Tl(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 Tl(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 s=this.width!==t.width,r=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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:c}}},$m=class extends Oe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Zm(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 s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 s;t?s=new Ic(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Ic.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)))}},Oc=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Na(e,t){let i=t-e;return function(s){return e+i*ib(s)}}function eb(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Ic=class Ml{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),eb(Na(t,r),Na(n,i),.33)}return Na(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 s=this.scrollLeft(i),r=this.scrollTop(i);return new Oc(s,r,!1)}return new Oc(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Ml.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new Ml(t,i,r,s)}};function tb(e){return Math.pow(e,3)}function ib(e){return 1-tb(1-e)}var sb=class extends Oe{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 Ih)}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":"")))}},rb=140,Nf=class extends Fh{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 sb(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new If),this._shouldRender=!0,this.domNode=Gn(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(Ce(this.domNode.domNode,wt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Jm(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Gn(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 s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ce(this.slider.domNode,wt.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.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(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?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 r=Ym(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),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),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(Bf&&o>rb){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.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()}},Ff=class Bl{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Bl(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,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),c=r>0&&r>s;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(s*a/r))),d=(a-h)/(r-s),u=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(h),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=Bl._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,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},nb=class extends Nf{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ff(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.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}},ob=class extends Nf{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ff(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.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}},ab=500,Nc=50,lb=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Ll=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,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Ah){let i=ts(t.browserEvent),s=bm(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new lb(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),c=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,a),1),d=Math.max(r,o),u=Math.max(n,a);d%c===0&&u%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Ll.INSTANCE=new Ll;var hb=Ll,cb=class extends Fh{constructor(e,t,i){super(),this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ie),this.onWillScroll=this._onWillScroll.event,this._options=db(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new ob(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new nb(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Gn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Gn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Gn(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Ih),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Br(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,ss&&(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 Tc(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Br(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Tc(i))};this._mouseWheelToDispose.push(Ce(this._listenOnDomNode,wt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=hb.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=!ss&&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=Nc*n,u=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(h,u)}if(o){let d=Nc*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 s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw 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,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),ab)}},ub=class extends cb{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 db(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,ss&&(t.className+=" mac"),t}var Al=class extends Oe{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new ie),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new $m({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Nh(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ub(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(r.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Bt.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(tt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(tt(()=>this._styleElement.remove())),this._register(Bt.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(`
30
+ `)})),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}};Al=ot([ae(2,Kt),ae(3,ws),ae(4,mf),ae(5,xn),ae(6,qt),ae(7,Cs)],Al);var Ol=class extends Oe{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(tt(()=>{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 s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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()}};Ol=ot([ae(1,Kt),ae(2,ws),ae(3,So),ae(4,Cs)],Ol);var fb=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)}},ji={full:0,left:0,center:0,right:0},Ds={full:0,left:0,center:0,right:0},Tn={full:0,left:0,center:0,right:0},ea=class extends Oe{constructor(e,t,i,s,r,n,o,a){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new fb,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(tt(()=>{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);Ds.full=this._canvas.width,Ds.left=e,Ds.center=t,Ds.right=e,this._refreshDrawHeightConstants(),Tn.full=1,Tn.left=1,Tn.center=1+Ds.left,Tn.right=1+Ds.left+Ds.center}_refreshDrawHeightConstants(){ji.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);ji.left=t,ji.center=t,ji.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ji.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ji.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ji.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ji.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(Tn[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ji[e.position||"full"]/2),Ds[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ji[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}))}};ea=ot([ae(2,Kt),ae(3,So),ae(4,Cs),ae(5,qt),ae(6,xn),ae(7,ws)],ea);var q;(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=`
31
+ `,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=""))(q||(q={}));var jo;(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="Ÿ"))(jo||(jo={}));var Wf;(e=>e.ST=`${q.ESC}\\`)(Wf||(Wf={}));var Il=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(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(`${q.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,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"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=r+"px",this._textarea.style.top=s+"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)}}};Il=ot([ae(2,Kt),ae(3,qt),ae(4,Ir),ae(5,Cs)],Il);var Ct=0,kt=0,xt=0,nt=0,Fc={css:"#00000000",rgba:0},ut;(e=>{function t(r,n,o,a){return a!==void 0?`#${tr(r)}${tr(n)}${tr(o)}${tr(a)}`:`#${tr(r)}${tr(n)}${tr(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(ut||(ut={}));var et;(e=>{function t(c,h){if(nt=(h.rgba&255)/255,nt===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,v=c.rgba>>16&255,m=c.rgba>>8&255;Ct=_+Math.round((d-_)*nt),kt=v+Math.round((u-v)*nt),xt=m+Math.round((f-m)*nt);let g=ut.toCss(Ct,kt,xt),y=ut.toRgba(Ct,kt,xt);return{css:g,rgba:y}}e.blend=t;function i(c){return(c.rgba&255)===255}e.isOpaque=i;function s(c,h,d){let u=Vo.ensureContrastRatio(c.rgba,h.rgba,d);if(u)return ut.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function r(c){let h=(c.rgba|255)>>>0;return[Ct,kt,xt]=Vo.toChannels(h),{css:ut.toCss(Ct,kt,xt),rgba:h}}e.opaque=r;function n(c,h){return nt=Math.round(h*255),[Ct,kt,xt]=Vo.toChannels(c.rgba),{css:ut.toCss(Ct,kt,xt,nt),rgba:ut.toRgba(Ct,kt,xt,nt)}}e.opacity=n;function o(c,h){return nt=c.rgba&255,n(c,nt*h/255)}e.multiplyOpacity=o;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})(et||(et={}));var st;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ct=parseInt(r.slice(1,2).repeat(2),16),kt=parseInt(r.slice(2,3).repeat(2),16),xt=parseInt(r.slice(3,4).repeat(2),16),ut.toColor(Ct,kt,xt);case 5:return Ct=parseInt(r.slice(1,2).repeat(2),16),kt=parseInt(r.slice(2,3).repeat(2),16),xt=parseInt(r.slice(3,4).repeat(2),16),nt=parseInt(r.slice(4,5).repeat(2),16),ut.toColor(Ct,kt,xt,nt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ct=parseInt(n[1]),kt=parseInt(n[2]),xt=parseInt(n[3]),nt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ut.toColor(Ct,kt,xt,nt);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ct,kt,xt,nt]=t.getImageData(0,0,1,1).data,nt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ut.toRgba(Ct,kt,xt,nt),css:r}}e.toColor=s})(st||(st={}));var Ht;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/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})(Ht||(Ht={}));var Vo;(e=>{function t(o,a){if(nt=(a&255)/255,nt===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 Ct=u+Math.round((c-u)*nt),kt=f+Math.round((h-f)*nt),xt=_+Math.round((d-_)*nt),ut.toRgba(Ct,kt,xt)}e.blend=t;function i(o,a,c){let h=Ht.relativeLuminance(o>>8),d=Ht.relativeLuminance(a>>8);if(as(h,d)<c){if(d<h){let _=s(o,a,c),v=as(h,Ht.relativeLuminance(_>>8));if(v<c){let m=r(o,a,c),g=as(h,Ht.relativeLuminance(m>>8));return v>g?_:m}return _}let u=r(o,a,c),f=as(h,Ht.relativeLuminance(u>>8));if(f<c){let _=s(o,a,c),v=as(h,Ht.relativeLuminance(_>>8));return f>v?u:_}return u}}e.ensureContrastRatio=i;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,v=a>>8&255,m=as(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));for(;m<c&&(f>0||_>0||v>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),m=as(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));return(f<<24|_<<16|v<<8|255)>>>0}e.reduceLuminance=s;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,v=a>>8&255,m=as(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));for(;m<c&&(f<255||_<255||v<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),m=as(Ht.relativeLuminance2(f,_,v),Ht.relativeLuminance2(h,d,u));return(f<<24|_<<16|v<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Vo||(Vo={}));function tr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function as(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var _b=class extends bo{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()]}},ta=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new xi}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=[],s=t.translateToString(!0),r=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-r>1){let d=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<d.length;u++)i.push(d[u])}r=h,o=n,a=this._workCell.fg,c=this._workCell.bg}n+=this._workCell.getChars().length||Us.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<h.length;d++)i.push(h[d])}return i}_getJoinedRanges(e,t,i,s,r){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++)ta._mergeRanges(o,c[h])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let c=t.getWidth(a),h=t.getString(a).length||Us.length;if(c!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ta=ot([ae(0,Kt)],ta);function vb(e){return 57508<=e&&e<=57558}function pb(e){return 9472<=e&&e<=9631}function gb(e){return vb(e)||pb(e)}function mb(){return{css:{canvas:Lo(),cell:Lo()},device:{canvas:Lo(),cell:Lo(),char:{width:0,height:0,left:0,top:0}}}}function Lo(){return{width:0,height:0}}var Nl=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new xi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,c,h,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,v=e.getNoBgTrimmedLength();i&&v<n+1&&(v=n+1);let m,g=0,y="",C=0,k=0,w=0,P=0,H=!1,U=0,j=!1,Z=0,G=0,N=[],I=h!==-1&&d!==-1;for(let A=0;A<v;A++){e.loadCell(A,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let x=!1,M=A>=G,E=A,R=this._workCell;if(f.length>0&&A===f[0][0]&&M){let ke=f.shift(),mt=this._isCellInSelection(ke[0],t);for(C=ke[0]+1;C<ke[1];C++)M&&(M=mt===this._isCellInSelection(C,t));M&&(M=!i||n<ke[0]||n>=ke[1]),M?(x=!0,R=new _b(this._workCell,e.translateToString(!0,ke[0],ke[1]),ke[1]-ke[0]),E=ke[1]-1,L=R.getWidth()):G=ke[1]}let z=this._isCellInSelection(A,t),X=i&&A===n,de=I&&A>=h&&A<=d,Se=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,ke=>{Se=!0});let he=R.getChars()||Us;if(he===" "&&(R.isUnderline()||R.isOverline())&&(he=" "),Z=L*a-c.get(he,R.isBold(),R.isItalic()),!m)m=this._document.createElement("span");else if(g&&(z&&j||!z&&!j&&R.bg===k)&&(z&&j&&_.selectionForeground||R.fg===w)&&R.extended.ext===P&&de===H&&Z===U&&!X&&!x&&!Se&&M){R.isInvisible()?y+=Us:y+=he,g++;continue}else g&&(m.textContent=y),m=this._document.createElement("span"),g=0,y="";if(k=R.bg,w=R.fg,P=R.extended.ext,H=de,U=Z,j=z,x&&n>=A&&n<=E&&(n=A),!this._coreService.isCursorHidden&&X&&this._coreService.isCursorInitialized){if(N.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&N.push("xterm-cursor-blink"),N.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":N.push("xterm-cursor-outline");break;case"block":N.push("xterm-cursor-block");break;case"bar":N.push("xterm-cursor-bar");break;case"underline":N.push("xterm-cursor-underline");break}}if(R.isBold()&&N.push("xterm-bold"),R.isItalic()&&N.push("xterm-italic"),R.isDim()&&N.push("xterm-dim"),R.isInvisible()?y=Us:y=R.getChars()||Us,R.isUnderline()&&(N.push(`xterm-underline-${R.extended.underlineStyle}`),y===" "&&(y=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())m.style.textDecorationColor=`rgb(${bo.toColorRGB(R.getUnderlineColor()).join(",")})`;else{let ke=R.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&R.isBold()&&ke<8&&(ke+=8),m.style.textDecorationColor=_.ansi[ke].css}R.isOverline()&&(N.push("xterm-overline"),y===" "&&(y=" ")),R.isStrikethrough()&&N.push("xterm-strikethrough"),de&&(m.style.textDecoration="underline");let me=R.getFgColor(),we=R.getFgColorMode(),xe=R.getBgColor(),fe=R.getBgColorMode(),ge=!!R.isInverse();if(ge){let ke=me;me=xe,xe=ke;let mt=we;we=fe,fe=mt}let De,Be,We=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,ke=>{ke.options.layer!=="top"&&We||(ke.backgroundColorRGB&&(fe=50331648,xe=ke.backgroundColorRGB.rgba>>8&16777215,De=ke.backgroundColorRGB),ke.foregroundColorRGB&&(we=50331648,me=ke.foregroundColorRGB.rgba>>8&16777215,Be=ke.foregroundColorRGB),We=ke.options.layer==="top")}),!We&&z&&(De=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,xe=De.rgba>>8&16777215,fe=50331648,We=!0,_.selectionForeground&&(we=50331648,me=_.selectionForeground.rgba>>8&16777215,Be=_.selectionForeground)),We&&N.push("xterm-decoration-top");let He;switch(fe){case 16777216:case 33554432:He=_.ansi[xe],N.push(`xterm-bg-${xe}`);break;case 50331648:He=ut.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(m,`background-color:#${Wc((xe>>>0).toString(16),"0",6)}`);break;case 0:default:ge?(He=_.foreground,N.push("xterm-bg-257")):He=_.background}switch(De||R.isDim()&&(De=et.multiplyOpacity(He,.5)),we){case 16777216:case 33554432:R.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(m,He,_.ansi[me],R,De,void 0)||N.push(`xterm-fg-${me}`);break;case 50331648:let ke=ut.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(m,He,ke,R,De,Be)||this._addStyle(m,`color:#${Wc(me.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(m,He,_.foreground,R,De,Be)||ge&&N.push("xterm-fg-257")}N.length&&(m.className=N.join(" "),N.length=0),!X&&!x&&!Se&&M?g++:m.textContent=y,Z!==this.defaultSpacing&&(m.style.letterSpacing=`${Z}px`),u.push(m),A=E}return m&&g&&(m.textContent=y),u}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||gb(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=et.ensureContrastRatio(r||t,n||i,c),o.setColor((r||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,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Nl=ot([ae(1,yf),ae(2,qt),ae(3,ws),ae(4,Ir),ae(5,So),ae(6,xn)],Nl);function Wc(e,t,i){for(;e.length<i;)e=t+e;return e}var bb=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.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,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),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,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Sb=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,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,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=s,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 yb(){return new Sb}var Fa="xterm-dom-renderer-owner-",ci="xterm-rows",Ao="xterm-fg-",Hc="xterm-bg-",Mn="xterm-focus",Oo="xterm-selection",wb=1,Fl=class extends Oe{constructor(e,t,i,s,r,n,o,a,c,h,d,u,f,_){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,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=wb++,this._rowElements=[],this._selectionRenderModel=yb(),this.onRequestRedraw=this._register(new ie).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ci),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(Oo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=mb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(v=>this._injectCss(v))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Nl,document),this._element.classList.add(Fa+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(v=>this._handleLinkHover(v))),this._register(this._linkifier2.onHideLinkUnderline(v=>this._handleLinkLeave(v))),this._register(tt(()=>{this._element.classList.remove(Fa+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new bb(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} .${ci} 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} .${ci} { 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} .${ci} .xterm-dim { color: ${et.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}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ci}.${Mn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ci}.${Mn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ci}.${Mn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ci} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ci} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ci} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ci} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ci} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Oo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Oo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Oo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ao}${n} { color: ${o.css}; }${this._terminalSelector} .${Ao}${n}.xterm-dim { color: ${et.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${Hc}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ao}257 { color: ${et.opaque(e.background).css}; }${this._terminalSelector} .${Ao}257.xterm-dim { color: ${et.multiplyOpacity(et.opaque(e.background),.5).css}; }${this._terminalSelector} .${Hc}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 s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(Mn),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Mn),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 s=this._selectionRenderModel.viewportStartRow,r=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=s===n?e[0]:0,h=n===r?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=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=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),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=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===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Fa}${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,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,h=Math.min(a.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=i;_<=s;++_){let v=_+a.ydisp,m=this._rowElements[_],g=a.lines.get(v);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,v,v===c,u,f,h,d,this.dimensions.css.cell.width,this._widthCache,n?_===i?e:0:-1,n?(_===s?t:r)-1:-1))}}};Fl=ot([ae(7,Mh),ae(8,ya),ae(9,qt),ae(10,Kt),ae(11,Ir),ae(12,ws),ae(13,xn)],Fl);var Wl=class extends Oe{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ie),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new kb(this._optionsService))}catch{this._measureStrategy=this._register(new Cb(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())}};Wl=ot([ae(2,qt)],Wl);var Hf=class extends Oe{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)}},Cb=class extends Hf{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}},kb=class extends Hf{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}},xb=class extends Oe{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 Eb(this._window)),this._onDprChange=this._register(new ie),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ie),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Bt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ce(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ce(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}},Eb=class extends Oe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Sn),this._onDprChange=this._register(new ie),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(tt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ce(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)}},Db=class extends Oe{constructor(){super(),this.linkProviders=[],this._register(tt(()=>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 Wh(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function Rb(e,t,i,s,r,n,o,a,c){if(!n)return;let h=Wh(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),s+(c?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h}var Hl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return Rb(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Wh(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])}}};Hl=ot([ae(0,Cs),ae(1,ya)],Hl);var Pb=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=[]}},zf={};Wg(zf,{getSafariVersion:()=>Mb,isChromeOS:()=>jf,isFirefox:()=>Uf,isIpad:()=>Bb,isIphone:()=>Lb,isLegacyEdge:()=>Tb,isLinux:()=>Hh,isMac:()=>ia,isNode:()=>wa,isSafari:()=>Kf,isWindows:()=>qf});var wa=typeof process<"u"&&"title"in process,yo=wa?"node":navigator.userAgent,wo=wa?"node":navigator.platform,Uf=yo.includes("Firefox"),Tb=yo.includes("Edge"),Kf=/^((?!chrome|android).)*safari/i.test(yo);function Mb(){if(!Kf)return 0;let e=yo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ia=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(wo),Bb=wo==="iPad",Lb=wo==="iPhone",qf=["Windows","Win16","Win32","WinCE"].includes(wo),Hh=wo.indexOf("Linux")>=0,jf=/\bCrOS\b/.test(yo),Vf=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,s=e.timeRemaining(),r=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),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},Ab=class extends Vf{_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())}}},Ob=class extends Vf{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},sa=!wa&&"requestIdleCallback"in window?Ob:Ab,Ib=class{constructor(){this._queue=new sa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},zl=class extends Oe{constructor(e,t,i,s,r,n,o,a,c){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Sn),this._pausedResizeTask=new Ib,this._observerDisposable=this._register(new Sn),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 ie),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ie),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ie),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ie),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Pb((h,d)=>this._renderRows(h,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Nb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(tt(()=>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(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=tt(()=>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 s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.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 s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};zl=ot([ae(2,qt),ae(3,ya),ae(4,Ir),ae(5,So),ae(6,Kt),ae(7,ws),ae(8,xn)],zl);var Nb=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 Fb(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return zb(r,n,e,t,i,s)+Ca(n,t,i,s)+Ub(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",$n(Math.abs(r-e),Zn(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),c=Hb(n>t?e:r,i)+(a-1)*i.cols+1+Wb(n>t?r:e);return $n(c,Zn(o,s))}function Wb(e,t){return e-1}function Hb(e,t){return t.cols-e}function zb(e,t,i,s,r,n){return Ca(t,s,r,n).length===0?"":$n(Gf(e,t,e,t-Lr(t,r),!1,r).length,Zn("D",n))}function Ca(e,t,i,s){let r=e-Lr(e,i),n=t-Lr(t,i),o=Math.abs(r-n)-Kb(e,t,i);return $n(o,Zn(Yf(e,t),s))}function Ub(e,t,i,s,r,n){let o;Ca(t,s,r,n).length>0?o=s-Lr(s,r):o=t;let a=s,c=qb(e,t,i,s,r,n);return $n(Gf(e,o,i,a,c==="C",r).length,Zn(c,n))}function Kb(e,t,i){var o;let s=0,r=e-Lr(e,i),n=t-Lr(t,i);for(let a=0;a<Math.abs(r-n);a++){let c=Yf(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+c*a))!=null&&o.isWrapped&&s++}return s}function Lr(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function qb(e,t,i,s,r,n){let o;return Ca(i,s,r,n).length>0?o=s-Lr(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function Yf(e,t){return e>t?"A":"B"}function Gf(e,t,i,s,r,n){let o=e,a=t,c="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(c+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&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 Zn(e,t){let i=t?"O":"[";return q.ESC+i+e}function $n(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var jb=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 zc(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 Wa=50,Vb=15,Yb=50,Gb=500,Xb=" ",Qb=new RegExp(Xb,"g"),Ul=class extends Oe{constructor(e,t,i,s,r,n,o,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new xi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ie),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ie),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ie),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ie),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 jb(this._bufferService),this._activeSelectionMode=0,this._register(tt(()=>{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,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=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,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));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?s[s.length-1]+=a:s.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?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(Qb," ")).join(qf?`\r
32
32
  `:`
33
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Hh&&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,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_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 r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=zc(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=Wh(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,-Wa),Wa),t/=Wa,t/Math.abs(t)+Math.round(t*(jb-1)))}shouldForceSelection(e){return ia?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(),Vb)}_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&&!(ia&&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 s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<Yb&&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 s=Nb(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!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 s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-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,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.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 C=n.getString(y).length;for(C>1&&(_+=C-1,c+=C-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):k>1&&(f+=k-1,a-=k-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 k=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,y++):k>1&&(_+=k-1,c+=k-1),c++,y++}}c++;let v=a+h-d+f,m=Math.min(this._bufferService.cols,c-a+d+u-f-_);if(!(!t&&o.slice(a,c).trim()==="")){if(i&&v===0&&n.getCodePoint(0)!==32){let g=r.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 C=this._bufferService.cols-y.start;v-=C,m+=C}}}if(s&&v+m===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.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&&(m+=y.length)}}return{start:v,length:m}}}_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=zc(i,this._bufferService.cols)}};Ul=at([ae(3,qt),ae(4,Ir),ae(5,Bh),ae(6,jt),ae(7,ws),ae(8,ys)],Ul);var Uc=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={}}},Kc=class{constructor(){this._color=new Uc,this._css=new Uc}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()}},dt=Object.freeze((()=>{let e=[rt.toColor("#2e3436"),rt.toColor("#cc0000"),rt.toColor("#4e9a06"),rt.toColor("#c4a000"),rt.toColor("#3465a4"),rt.toColor("#75507b"),rt.toColor("#06989a"),rt.toColor("#d3d7cf"),rt.toColor("#555753"),rt.toColor("#ef2929"),rt.toColor("#8ae234"),rt.toColor("#fce94f"),rt.toColor("#729fcf"),rt.toColor("#ad7fa8"),rt.toColor("#34e2e2"),rt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ut.toCss(s,r,n),rgba:ut.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ut.toCss(s,s,s),rgba:ut.toRgba(s,s,s)})}return e})()),ir=rt.toColor("#ffffff"),Fn=rt.toColor("#000000"),qc=rt.toColor("#ffffff"),jc=Fn,Bn={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Qb=ir,Kl=class extends Oe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Kc,this._halfContrastCache=new Kc,this._onChangeColors=this._register(new te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ir,background:Fn,cursor:qc,cursorAccent:jc,selectionForeground:void 0,selectionBackgroundTransparent:Bn,selectionBackgroundOpaque:$e.blend(Fn,Bn),selectionInactiveBackgroundTransparent:Bn,selectionInactiveBackgroundOpaque:$e.blend(Fn,Bn),scrollbarSliderBackground:$e.opacity(ir,.2),scrollbarSliderHoverBackground:$e.opacity(ir,.4),scrollbarSliderActiveBackground:$e.opacity(ir,.5),overviewRulerBorder:ir,ansi:dt.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,ir),t.background=Qe(e.background,Fn),t.cursor=$e.blend(t.background,Qe(e.cursor,qc)),t.cursorAccent=$e.blend(t.background,Qe(e.cursorAccent,jc)),t.selectionBackgroundTransparent=Qe(e.selectionBackground,Bn),t.selectionBackgroundOpaque=$e.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Qe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=$e.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Qe(e.selectionForeground,Fc):void 0,t.selectionForeground===Fc&&(t.selectionForeground=void 0),$e.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=$e.opacity(t.selectionBackgroundTransparent,.3)),$e.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=$e.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Qe(e.scrollbarSliderBackground,$e.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Qe(e.scrollbarSliderHoverBackground,$e.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Qe(e.scrollbarSliderActiveBackground,$e.opacity(t.foreground,.5)),t.overviewRulerBorder=Qe(e.overviewRulerBorder,Qb),t.ansi=dt.slice(),t.ansi[0]=Qe(e.black,dt[0]),t.ansi[1]=Qe(e.red,dt[1]),t.ansi[2]=Qe(e.green,dt[2]),t.ansi[3]=Qe(e.yellow,dt[3]),t.ansi[4]=Qe(e.blue,dt[4]),t.ansi[5]=Qe(e.magenta,dt[5]),t.ansi[6]=Qe(e.cyan,dt[6]),t.ansi[7]=Qe(e.white,dt[7]),t.ansi[8]=Qe(e.brightBlack,dt[8]),t.ansi[9]=Qe(e.brightRed,dt[9]),t.ansi[10]=Qe(e.brightGreen,dt[10]),t.ansi[11]=Qe(e.brightYellow,dt[11]),t.ansi[12]=Qe(e.brightBlue,dt[12]),t.ansi[13]=Qe(e.brightMagenta,dt[13]),t.ansi[14]=Qe(e.brightCyan,dt[14]),t.ansi[15]=Qe(e.brightWhite,dt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Qe(e.extendedAnsi[s],dt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(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()}}};Kl=at([ae(0,jt)],Kl);function Qe(e,t){if(e!==void 0)try{return rt.toColor(e)}catch{}return t}var Jb=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)}},Zb=class{constructor(){this._services=new Jb,this._services.set(Mh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=jg(e).sort((n,o)=>n.index-o.index),s=[];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}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},$b={trace:0,debug:1,info:2,warn:3,error:4,off:5},eS="xterm.js: ",ql=class extends Oe{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=$b[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?"":eS)+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)}};ql=at([ae(0,jt)],ql);var Vc=class extends Oe{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 s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}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 r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ae=3,ct=Object.freeze(new bo),Io=0,Ha=2,Wn=class Gf{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ae);let r=i||xi.fromCharData([0,ff,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*Ae+0],s=i&2097151;return[this._data[t*Ae+1],i&2097152?this._combined[t]:s?Ps(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Ae+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Ae+0]=t|2097152|i[2]<<22):this._data[t*Ae+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Ae+0]>>22}hasWidth(t){return this._data[t*Ae+0]&12582912}getFg(t){return this._data[t*Ae+1]}getBg(t){return this._data[t*Ae+2]}hasContent(t){return this._data[t*Ae+0]&4194303}getCodePoint(t){let i=this._data[t*Ae+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Ae+0]&2097152}getString(t){let i=this._data[t*Ae+0];return i&2097152?this._combined[t]:i&2097151?Ps(i&2097151):""}isProtected(t){return this._data[t*Ae+2]&536870912}loadCell(t,i){return Io=t*Ae,i.content=this._data[Io+0],i.fg=this._data[Io+1],i.bg=this._data[Io+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*Ae+0]=i.content,this._data[t*Ae+1]=i.fg,this._data[t*Ae+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*Ae+0]=i|s<<22,this._data[t*Ae+1]=r.fg,this._data[t*Ae+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*Ae+0];r&2097152?this._combined[t]+=Ps(i):r&2097151?(this._combined[t]=Ps(r&2097151)+Ps(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*Ae+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new xi;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new xi;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Ha<this._data.buffer.byteLength;let s=t*Ae;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[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,s*4*Ha<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ha<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 s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 Gf(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*Ae+0]&4194303)return t+(this._data[t*Ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ae+0]&4194303||this._data[t*Ae+2]&50331648)return t+(this._data[t*Ae+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let c=r-1;c>=0;c--){for(let h=0;h<Ae;h++)this._data[(s+c)*Ae+h]=o[(i+c)*Ae+h];o[(i+c)*Ae+2]&268435456&&(this._extendedAttrs[s+c]=t._extendedAttrs[i+c])}else for(let c=0;c<r;c++){for(let h=0;h<Ae;h++)this._data[(s+c)*Ae+h]=o[(i+c)*Ae+h];o[(i+c)*Ae+2]&268435456&&(this._extendedAttrs[s+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+s]=t._combined[h])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*Ae+0],a=o&2097151,c=o&2097152?this._combined[i]:a?Ps(a):zs;if(n+=c,r)for(let h=0;h<c.length;++h)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function tS(e,t,i,s,r,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&&s>=a&&s<c){a+=d.length-1;continue}let u=0,f=eo(d,u,t),_=1,v=0;for(;_<d.length;){let g=eo(d,_,t),y=g-v,C=i-f,k=Math.min(y,C);d[u].copyCellsFrom(d[_],v,f,k,!1),f+=k,f===i&&(u++,f=0),v+=k,v===g&&(_++,v=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,r))}d[u].replaceCells(f,i,r);let m=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)m++;m>0&&(o.push(a+d.length-m),o.push(m)),a+=d.length-1}return o}function iS(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function sS(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function rS(e,t,i){let s=[],r=e.map((c,h)=>eo(e,h,t)).reduce((c,h)=>c+h),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let c=eo(e,o,t);n>c&&(n-=c,o++);let h=e[o].getWidth(n-1)===2;h&&n--;let d=h?i-1:i;s.push(d),a+=d}return s}function eo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Xf=class Qf{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Qf._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(),Br(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Xf._nextId=1;var nS=Xf,mt={},sr=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 Yc=4294967295,Gc=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=ct.clone(),this.savedCharset=sr,this.markers=[],this._nullCell=xi.fromCharData([0,ff,1,0]),this._whitespaceCell=xi.fromCharData([0,zs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new sa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Vc(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 $o),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 $o),this._whitespaceCell}getBlankLine(e,t){return new Wn(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>Yc?Yc:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ct);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 Vc(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(ct),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+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 Wn(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 Wn(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(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,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++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let 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,s=tS(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ct),i);if(s.length>0){let r=iS(this.lines,s);sS(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(ct),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Wn(e,s))):(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,s=this.getNullCell(ct),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),c.unshift(a);if(!i){let k=this.ybase+this.y;if(k>=o&&k<o+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=rS(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 k=0;k<u;k++){let w=this.getBlankLine(ct,!0);_.push(w)}_.length>0&&(r.push({start:o+c.length+n,newLines:_}),n+=_.length),c.push(..._);let v=d.length-1,m=d[v];m===0&&(v--,m=d[v]);let g=c.length-u-1,y=h;for(;g>=0;){let k=Math.min(y,m);if(c[v]===void 0)break;if(c[v].copyCellsFrom(c[g],y-k,m-k,k,!0),m-=k,m===0&&(v--,m=d[v]),y-=k,y===0){g--;let w=Math.max(g,0);y=eo(c,w,this._cols)}}for(let k=0;k<c.length;k++)d[k]<e&&c[k].setCell(d[k],s);let C=u-f;for(;C-- >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(r.length>0){let o=[],a=[];for(let m=0;m<this.lines.length;m++)a.push(this.lines.get(m));let c=this.lines.length,h=c-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let f=0;for(let m=Math.min(this.lines.maxLength-1,c+n-1);m>=0;m--)if(u&&u.start>h+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(m--,u.newLines[g]);m++,o.push({index:h+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(m,a[h--]);let _=0;for(let m=o.length-1;m>=0;m--)o[m].index+=_,this.lines.onInsertEmitter.fire(o[m]),_+=o[m].amount;let v=Math.max(0,c+n-this.lines.maxLength);v>0&&this.lines.onTrimEmitter.fire(v)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}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 nS(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)}},oS=class extends Oe{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 Gc(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Gc(!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)}},Jf=2,Zf=1,jl=class extends Oe{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,Jf),this.rows=Math.max(e.rawOptions.rows||0,Zf),this.buffers=this._register(new oS(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,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=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(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.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 s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};jl=at([ae(0,jt)],jl);var zr={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:ia,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},aS=["normal","bold","100","200","300","400","500","600","700","800","900"],lS=class extends Oe{constructor(e){super(),this._onOptionChange=this._register(new te),this.onOptionChange=this._onOptionChange.event;let t={...zr};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(it(()=>{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 zr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in zr))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=zr[e]),!hS(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=zr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=aS.includes(t)?t:zr[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 hS(e){return e==="block"||e==="underline"||e==="bar"}function Hn(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Hn(e[s],t-1);return i}var Xc=Object.freeze({insertMode:!1}),Qc=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Vl=class extends Oe{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=Hn(Xc),this.decPrivateModes=Hn(Qc)}reset(){this.modes=Hn(Xc),this.decPrivateModes=Hn(Qc)}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(s=>s.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))}};Vl=at([ae(0,qt),ae(1,mf),ae(2,jt)],Vl);var Jc={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 za(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 Ua=String.fromCharCode,Zc={DEFAULT:e=>{let t=[za(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ua(t[0])}${Ua(t[1])}${Ua(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${za(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${za(e,!0)};${e.x};${e.y}${t}`}},Yl=class extends Oe{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 s of Object.keys(Jc))this.addProtocol(s,Jc[s]);for(let s of Object.keys(Zc))this.addEncoding(s,Zc[s]);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 s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_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)}};Yl=at([ae(0,qt),ae(1,Ir),ae(2,jt)],Yl);var Ka=[[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]],cS=[[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]],ft;function uS(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var dS=class{constructor(){if(this.version="6",!ft){ft=new Uint8Array(65536),ft.fill(1),ft[0]=0,ft.fill(0,1,32),ft.fill(0,127,160),ft.fill(2,4352,4448),ft[9001]=2,ft[9002]=2,ft.fill(2,11904,42192),ft[12351]=1,ft.fill(2,44032,55204),ft.fill(2,63744,64256),ft.fill(2,65040,65050),ft.fill(2,65072,65136),ft.fill(2,65280,65377),ft.fill(2,65504,65511);for(let e=0;e<Ka.length;++e)ft.fill(0,Ka[e][0],Ka[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ft[e]:uS(e,cS)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=lr.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return lr.createPropertyValue(0,i,s)}},lr=class Yo{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new te,this.onChange=this._onChange.event;let t=new dS;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,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?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,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)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,s),c=Yo.extractWidth(a);Yo.extractShouldJoin(a)&&(c-=Yo.extractWidth(s)),i+=c,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},fS=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 $c(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.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 Ln=2147483647,_S=256,$f=class Gl{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>_S)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 Gl;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Gl(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 s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}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>Ln?Ln: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>Ln?Ln: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,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,Ln):t}},An=[],vS=class{constructor(){this._state=0,this._active=An,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 s=i.indexOf(t);s!==-1&&i.splice(s,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=An}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=An,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||An,!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",Sa(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].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 s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-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,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=An,this._id=-1,this._state=0}}},si=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+=Sa(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}},On=[],pS=class{constructor(){this._handlers=Object.create(null),this._active=On,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=On}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=On,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||On,!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",Sa(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=On,this._ident=0}},zn=new $f;zn.addParam(0);var eu=class{constructor(e){this._handler=e,this._data="",this._params=zn,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():zn,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Sa(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=zn,this._data="",this._hitLimit=!1,i));return this._params=zn,this._data="",this._hitLimit=!1,t}},gS=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},bi=160,mS=(function(){let e=new gS(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),i=(a,c)=>t.slice(a,c),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,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(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,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(r,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(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,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(r,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(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(bi,0,2,0),e.add(bi,8,5,8),e.add(bi,6,0,6),e.add(bi,11,0,11),e.add(bi,13,13,13),e})(),bS=class extends Oe{constructor(e=mS){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 $f,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},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(it(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new vS),this._dcsParser=this._register(new pS),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 r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);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 s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,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 s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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 s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(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(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===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(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:bi)],r>>4){case 2:for(let f=a+1;;++f){if(f>=t||(s=e[f])<32||s>126&&s<bi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<bi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<bi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<bi){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|s],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,r,a),o;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let d=this._escHandlers[this._collect<<8|s],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,r,a),o;u<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(s=e[f])===24||s===26||s===27||s>127&&s<bi){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=a+1;;f++)if(f>=t||(s=e[f])<32||s>127&&s<bi){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},SS=/^([\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})$/,yS=/^[\da-f]+$/;function tu(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=SS.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),yS.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function qa(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function wS(e,t=16){let[i,s,r]=e;return`rgb:${qa(i,t)}/${qa(s,t)}/${qa(r,t)}`}var CS={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ds=131072,iu=10;function su(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 ru=5e3,nu=0,kS=class extends Oe{constructor(e,t,i,s,r,n,o,a,c=new bS){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Kg,this._utf8Decoder=new qg,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ct.clone(),this._eraseAttrDataInternal=ct.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 Xl(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(V.BEL,()=>this.bell()),this._parser.setExecuteHandler(V.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(V.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(V.BS,()=>this.backspace()),this._parser.setExecuteHandler(V.HT,()=>this.tab()),this._parser.setExecuteHandler(V.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(V.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(jo.IND,()=>this.index()),this._parser.setExecuteHandler(jo.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(jo.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new si(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new si(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new si(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new si(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new si(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new si(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new si(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new si(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new si(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new si(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new si(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new si(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 eu((h,d)=>this.requestStatusString(h,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),ru))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${ru} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=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;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ds&&(n=this._parseStack.position+Ds)}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<Ds&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ds))),o||this._dirtyRowTracker.clearRange(),e.length>Ds)for(let h=n;h<e.length;h+=Ds){let d=h+Ds<e.length?h+Ds: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(s,r,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(s,r,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&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 s,r,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(s=e[_],s<127&&n){let y=n[String.fromCharCode(s)];y&&(s=y.charCodeAt(0))}let v=this._unicodeService.charProperties(s,f);r=lr.extractWidth(v);let m=lr.extractShouldJoin(v),g=m?lr.extractWidth(f):0;if(f=v,o&&this._onA11yChar.fire(Ps(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>a){if(c){let y=u,C=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 Wn&&u.copyCellsFrom(y,C,0,g,!1);C<a;)y.setCellFromCodepoint(C++,0,1,d)}else if(this._activeBuffer.x=a-1,r===2)continue}if(m&&this._activeBuffer.x){let y=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-y,s,r);for(let C=r-g;--C>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(d)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)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=>su(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new eu(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new si(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,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(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 s;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--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.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 r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(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,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-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,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let 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(ct));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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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,s=lr.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),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(V.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(V.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(V.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(V.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(V.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,sr),this._charsetService.setgCharset(1,sr),this._charsetService.setgCharset(2,sr),this._charsetService.setgCharset(3,sr);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){(m=>(m[m.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",m[m.SET=1]="SET",m[m.RESET=2]="RESET",m[m.PERMANENTLY_SET=3]="PERMANENTLY_SET",m[m.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:h,alt:d}=a,u=this._optionsService.rawOptions,f=(m,g)=>(o.triggerDataEvent(`${V.ESC}[${t?"":"?"}${m};${g}$y`),!0),_=m=>m?1:2,v=e.params[0];return t?v===2?f(v,4):v===4?f(v,_(o.modes.insertMode)):v===12?f(v,3):v===20?f(v,_(u.convertEol)):f(v,0):v===1?f(v,_(s.applicationCursorKeys)):v===3?f(v,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):v===6?f(v,_(s.origin)):v===7?f(v,_(s.wraparound)):v===8?f(v,3):v===9?f(v,_(r==="X10")):v===12?f(v,_(u.cursorBlink)):v===25?f(v,_(!o.isCursorHidden)):v===45?f(v,_(s.reverseWraparound)):v===66?f(v,_(s.applicationKeypad)):v===67?f(v,4):v===1e3?f(v,_(r==="VT200")):v===1002?f(v,_(r==="DRAG")):v===1003?f(v,_(r==="ANY")):v===1004?f(v,_(s.sendFocus)):v===1005?f(v,4):v===1006?f(v,_(n==="SGR")):v===1015?f(v,4):v===1016?f(v,_(n==="SGR_PIXELS")):v===1048?f(v,1):v===47||v===1047||v===1049?f(v,_(h===d)):v===2004?f(v,_(s.bracketedPasteMode)):v===2026?f(v,_(s.synchronizedOutput)):f(v,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=bo.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[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=ct.fg,e.bg=ct.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,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=ct.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=ct.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=ct.fg&16777215,s.bg&=-67108864,s.bg|=ct.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${V.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${V.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(`${V.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=ct.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(!su(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(`${V.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>iu&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>iu&&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 s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(ou(n))if(r==="?")t.push({type:0,index:n});else{let o=tu(r);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(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=tu(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}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 s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);ou(r)&&t.push({type:2,index:r})}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,sr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(CS[e[0]],mt[e[1]]||sr),!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=ct.clone(),this._eraseAttrDataInternal=ct.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 xi;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,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${V.ESC}${o}${V.ESC}\\`),!0),s=this._bufferService.buffer,r=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${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Xl=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&&(nu=e,e=t,t=nu),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Xl=at([ae(0,qt)],Xl);function ou(e){return 0<=e&&e<256}var xS=5e7,au=12,ES=50,DS=class extends Oe{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 s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>xS)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 s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=au?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=au)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>ES&&(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()}},Ql=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,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.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(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}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)))}};Ql=at([ae(0,qt)],Ql);var lu=!1,RS=class extends Oe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new yn),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 Zb,this.optionsService=this._register(new lS(e)),this._instantiationService.setService(jt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(jl)),this._instantiationService.setService(qt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ql)),this._instantiationService.setService(mf,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Vl)),this._instantiationService.setService(Ir,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Yl)),this._instantiationService.setService(gf,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(lr)),this._instantiationService.setService(Gg,this.unicodeService),this._charsetService=this._instantiationService.createInstance(fS),this._instantiationService.setService(Yg,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ql),this._instantiationService.setService(bf,this._oscLinkService),this._inputHandler=this._register(new kS(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Mt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Mt.forward(this._bufferService.onResize,this._onResize)),this._register(Mt.forward(this.coreService.onData,this._onData)),this._register(Mt.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 DS((t,i)=>this._inputHandler.parse(t,i))),this._register(Mt.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&&!lu&&(this._logService.warn("writeSync is unreliable and will be removed soon."),lu=!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,Jf),t=Math.max(t,Zf),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($c.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>($c(this._bufferService),!1))),this._windowsWrappingHeuristics.value=it(()=>{for(let t of e)t.dispose()})}}},PS={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 TS(e,t,i,s){var o;let r={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?r.key=V.ESC+"OA":r.key=V.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=V.ESC+"OD":r.key=V.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=V.ESC+"OC":r.key=V.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=V.ESC+"OB":r.key=V.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":V.DEL,e.altKey&&(r.key=V.ESC+r.key);break;case 9:if(e.shiftKey){r.key=V.ESC+"[Z";break}r.key=V.HT,r.cancel=!0;break;case 13:r.key=e.altKey?V.ESC+V.CR:V.CR,r.cancel=!0;break;case 27:r.key=V.ESC,e.altKey&&(r.key=V.ESC+V.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=V.ESC+"[1;"+(n+1)+"D":t?r.key=V.ESC+"OD":r.key=V.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=V.ESC+"[1;"+(n+1)+"C":t?r.key=V.ESC+"OC":r.key=V.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=V.ESC+"[1;"+(n+1)+"A":t?r.key=V.ESC+"OA":r.key=V.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=V.ESC+"[1;"+(n+1)+"B":t?r.key=V.ESC+"OB":r.key=V.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=V.ESC+"[2~");break;case 46:n?r.key=V.ESC+"[3;"+(n+1)+"~":r.key=V.ESC+"[3~";break;case 36:n?r.key=V.ESC+"[1;"+(n+1)+"H":t?r.key=V.ESC+"OH":r.key=V.ESC+"[H";break;case 35:n?r.key=V.ESC+"[1;"+(n+1)+"F":t?r.key=V.ESC+"OF":r.key=V.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=V.ESC+"[5;"+(n+1)+"~":r.key=V.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=V.ESC+"[6;"+(n+1)+"~":r.key=V.ESC+"[6~";break;case 112:n?r.key=V.ESC+"[1;"+(n+1)+"P":r.key=V.ESC+"OP";break;case 113:n?r.key=V.ESC+"[1;"+(n+1)+"Q":r.key=V.ESC+"OQ";break;case 114:n?r.key=V.ESC+"[1;"+(n+1)+"R":r.key=V.ESC+"OR";break;case 115:n?r.key=V.ESC+"[1;"+(n+1)+"S":r.key=V.ESC+"OS";break;case 116:n?r.key=V.ESC+"[15;"+(n+1)+"~":r.key=V.ESC+"[15~";break;case 117:n?r.key=V.ESC+"[17;"+(n+1)+"~":r.key=V.ESC+"[17~";break;case 118:n?r.key=V.ESC+"[18;"+(n+1)+"~":r.key=V.ESC+"[18~";break;case 119:n?r.key=V.ESC+"[19;"+(n+1)+"~":r.key=V.ESC+"[19~";break;case 120:n?r.key=V.ESC+"[20;"+(n+1)+"~":r.key=V.ESC+"[20~";break;case 121:n?r.key=V.ESC+"[21;"+(n+1)+"~":r.key=V.ESC+"[21~";break;case 122:n?r.key=V.ESC+"[23;"+(n+1)+"~":r.key=V.ESC+"[23~";break;case 123:n?r.key=V.ESC+"[24;"+(n+1)+"~":r.key=V.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=V.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=V.DEL:e.keyCode===219?r.key=V.ESC:e.keyCode===220?r.key=V.FS:e.keyCode===221&&(r.key=V.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=PS[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=V.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()),r.key=V.ESC+h}else if(e.keyCode===32)r.key=V.ESC+(e.ctrlKey?V.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let c=e.code.slice(3,4);e.shiftKey||(c=c.toLowerCase()),r.key=V.ESC+c,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=V.US),e.key==="@"&&(r.key=V.NUL));break}return r}var lt=0,MS=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new sa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new sa,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((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(lt=this._search(t),lt===-1)||this._getKey(this._array[lt])!==t)return!1;do if(this._array[lt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(lt),!0;while(++lt<this._array.length&&this._getKey(this._array[lt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];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&&(lt=this._search(e),!(lt<0||lt>=this._array.length)&&this._getKey(this._array[lt])===e))do yield this._array[lt];while(++lt<this._array.length&&this._getKey(this._array[lt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(lt=this._search(e),!(lt<0||lt>=this._array.length)&&this._getKey(this._array[lt])===e))do t(this._array[lt]);while(++lt<this._array.length&&this._getKey(this._array[lt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},ja=0,hu=0,BS=class extends Oe{constructor(){super(),this._decorations=new MS(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(it(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new LS(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.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 s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{ja=r.options.x??0,hu=ja+(r.options.width??1),e>=ja&&e<hu&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},LS=class extends Ys{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=rt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=rt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},AS=1e3,OS=class{constructor(e,t=AS){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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let 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)}},cu=20,ra=class extends Oe{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new OS(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(`
34
- `))),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(we(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(it(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<cu+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
35
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===cu+1&&(this._liveRegion.textContent+=pl.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,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",c=(i.ydisp+r+1).toString(),h=this._rowElements[r];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",c),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({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=r(t),o=r(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 r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};ra=at([ae(1,Mh),ae(2,ys),ae(3,ws)],ra);var Jl=class extends Oe{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,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(it(()=>{var n;Br(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(we(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(we(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(we(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(we(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 s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.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 s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.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?(r=this._activeProviderReplies)!=null&&r.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 s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[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)){r.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.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&&IS(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,Br(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,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.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,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.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 s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Jl=at([ae(1,Bh),ae(2,ws),ae(3,qt),ae(4,yf)],Jl);function IS(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 NS=class extends RS{constructor(e={}){super(e),this._linkifier=this._register(new yn),this.browser=Hf,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new yn),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(BS),this._instantiationService.setService(So,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Eb),this._instantiationService.setService(yf,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ml)),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(Mt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Mt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Mt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Mt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(it(()=>{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,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=$e.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${V.ESC}]${s};${wS(r)}${Ff.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ut.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ut.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(ra,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(V.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(V.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),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,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=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(we(this.element,"copy",t=>{this.hasSelection()&&zg(t,this._selectionService)}));let e=t=>Ug(t,this.textarea,this.coreService,this.optionsService);this._register(we(this.textarea,"paste",e)),this._register(we(this.element,"paste",e)),zf?this._register(we(this.element,"mousedown",t=>{t.button===2&&Sc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(we(this.element,"contextmenu",t=>{Sc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Hh&&this._register(we(this.element,"auxclick",t=>{t.button===1&&df(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(we(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(we(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(we(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(we(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(we(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(we(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(we(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;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"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=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(we(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",vl.get()),qf||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(kb,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ys,this._coreBrowserService),this._register(we(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(we(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wl,this._document,this._helperContainer),this._instantiationService.setService(ya,this._charSizeService),this._themeService=this._instantiationService.createInstance(Kl),this._instantiationService.setService(En,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ta),this._instantiationService.setService(Sf,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(zl,this.rows,this.screenElement)),this._instantiationService.setService(ws,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(Il,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hl),this._instantiationService.setService(Bh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Jl,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(Al,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(Ul,this.element,this.screenElement,s)),this._instantiationService.setService(Qg,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(Mt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Ol,this.screenElement)),this._register(we(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(ra,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ea,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ea,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Fl,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 v=n.deltaY;if(v===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=v<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 s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.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?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(we(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(we(t,"wheel",n=>{var o,a,c,h,d;if(!s.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=V.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){uf(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=TS(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),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===V.ETX||i.key===V.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)&&(FS(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(ct));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(V.ESC+"[I"):this.coreService.triggerDataEvent(V.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(`${V.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${V.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function FS(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var WS=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)}},HS=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 xi)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},uu=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 HS(t)}getNullCell(){return new xi}},zS=class extends Oe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new te),this.onBufferChange=this._onBufferChange.event,this._normal=new uu(this._core.buffers.normal,"normal"),this._alternate=new uu(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)}},US=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,s)=>t(i,s.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)}},KS=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}},qS=["cols","rows"],ji=0,jS=class extends Oe{constructor(e){super(),this._core=this._register(new NS(e)),this._addonManager=this._register(new WS),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(qS.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 US(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new KS(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 zS(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
36
- `,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 vl.get()},set promptLabel(e){vl.set(e)},get tooMuchOutput(){return pl.get()},set tooMuchOutput(e){pl.set(e)}}}_verifyIntegers(...e){for(ji of e)if(ji===1/0||isNaN(ji)||ji%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ji of e)if(ji&&(ji===1/0||isNaN(ji)||ji%1!==0||ji<0))throw new Error("This API only accepts positive integers")}};/**
33
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Hh&&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,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_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 r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=zc(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=Wh(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,-Wa),Wa),t/=Wa,t/Math.abs(t)+Math.round(t*(Vb-1)))}shouldForceSelection(e){return ia?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(),Yb)}_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&&!(ia&&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 s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<Gb&&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 s=Fb(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!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 s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-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,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.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 C=n.getString(y).length;for(C>1&&(_+=C-1,c+=C-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):k>1&&(f+=k-1,a-=k-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 k=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,y++):k>1&&(_+=k-1,c+=k-1),c++,y++}}c++;let v=a+h-d+f,m=Math.min(this._bufferService.cols,c-a+d+u-f-_);if(!(!t&&o.slice(a,c).trim()==="")){if(i&&v===0&&n.getCodePoint(0)!==32){let g=r.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 C=this._bufferService.cols-y.start;v-=C,m+=C}}}if(s&&v+m===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.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&&(m+=y.length)}}return{start:v,length:m}}}_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=zc(i,this._bufferService.cols)}};Ul=ot([ae(3,Kt),ae(4,Ir),ae(5,Bh),ae(6,qt),ae(7,Cs),ae(8,ws)],Ul);var Uc=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={}}},Kc=class{constructor(){this._color=new Uc,this._css=new Uc}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()}},dt=Object.freeze((()=>{let e=[st.toColor("#2e3436"),st.toColor("#cc0000"),st.toColor("#4e9a06"),st.toColor("#c4a000"),st.toColor("#3465a4"),st.toColor("#75507b"),st.toColor("#06989a"),st.toColor("#d3d7cf"),st.toColor("#555753"),st.toColor("#ef2929"),st.toColor("#8ae234"),st.toColor("#fce94f"),st.toColor("#729fcf"),st.toColor("#ad7fa8"),st.toColor("#34e2e2"),st.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ut.toCss(s,r,n),rgba:ut.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ut.toCss(s,s,s),rgba:ut.toRgba(s,s,s)})}return e})()),ir=st.toColor("#ffffff"),Fn=st.toColor("#000000"),qc=st.toColor("#ffffff"),jc=Fn,Bn={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Jb=ir,Kl=class extends Oe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Kc,this._halfContrastCache=new Kc,this._onChangeColors=this._register(new ie),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ir,background:Fn,cursor:qc,cursorAccent:jc,selectionForeground:void 0,selectionBackgroundTransparent:Bn,selectionBackgroundOpaque:et.blend(Fn,Bn),selectionInactiveBackgroundTransparent:Bn,selectionInactiveBackgroundOpaque:et.blend(Fn,Bn),scrollbarSliderBackground:et.opacity(ir,.2),scrollbarSliderHoverBackground:et.opacity(ir,.4),scrollbarSliderActiveBackground:et.opacity(ir,.5),overviewRulerBorder:ir,ansi:dt.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=Xe(e.foreground,ir),t.background=Xe(e.background,Fn),t.cursor=et.blend(t.background,Xe(e.cursor,qc)),t.cursorAccent=et.blend(t.background,Xe(e.cursorAccent,jc)),t.selectionBackgroundTransparent=Xe(e.selectionBackground,Bn),t.selectionBackgroundOpaque=et.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Xe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=et.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Xe(e.selectionForeground,Fc):void 0,t.selectionForeground===Fc&&(t.selectionForeground=void 0),et.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=et.opacity(t.selectionBackgroundTransparent,.3)),et.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=et.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Xe(e.scrollbarSliderBackground,et.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Xe(e.scrollbarSliderHoverBackground,et.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Xe(e.scrollbarSliderActiveBackground,et.opacity(t.foreground,.5)),t.overviewRulerBorder=Xe(e.overviewRulerBorder,Jb),t.ansi=dt.slice(),t.ansi[0]=Xe(e.black,dt[0]),t.ansi[1]=Xe(e.red,dt[1]),t.ansi[2]=Xe(e.green,dt[2]),t.ansi[3]=Xe(e.yellow,dt[3]),t.ansi[4]=Xe(e.blue,dt[4]),t.ansi[5]=Xe(e.magenta,dt[5]),t.ansi[6]=Xe(e.cyan,dt[6]),t.ansi[7]=Xe(e.white,dt[7]),t.ansi[8]=Xe(e.brightBlack,dt[8]),t.ansi[9]=Xe(e.brightRed,dt[9]),t.ansi[10]=Xe(e.brightGreen,dt[10]),t.ansi[11]=Xe(e.brightYellow,dt[11]),t.ansi[12]=Xe(e.brightBlue,dt[12]),t.ansi[13]=Xe(e.brightMagenta,dt[13]),t.ansi[14]=Xe(e.brightCyan,dt[14]),t.ansi[15]=Xe(e.brightWhite,dt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Xe(e.extendedAnsi[s],dt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(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()}}};Kl=ot([ae(0,qt)],Kl);function Xe(e,t){if(e!==void 0)try{return st.toColor(e)}catch{}return t}var Zb=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)}},$b=class{constructor(){this._services=new Zb,this._services.set(Mh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=Vg(e).sort((n,o)=>n.index-o.index),s=[];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}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},eS={trace:0,debug:1,info:2,warn:3,error:4,off:5},tS="xterm.js: ",ql=class extends Oe{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=eS[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?"":tS)+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)}};ql=ot([ae(0,qt)],ql);var Vc=class extends Oe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ie),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ie),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ie),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 s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}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 r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ae=3,ct=Object.freeze(new bo),Io=0,Ha=2,Wn=class Xf{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ae);let r=i||xi.fromCharData([0,_f,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*Ae+0],s=i&2097151;return[this._data[t*Ae+1],i&2097152?this._combined[t]:s?Ts(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Ae+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Ae+0]=t|2097152|i[2]<<22):this._data[t*Ae+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Ae+0]>>22}hasWidth(t){return this._data[t*Ae+0]&12582912}getFg(t){return this._data[t*Ae+1]}getBg(t){return this._data[t*Ae+2]}hasContent(t){return this._data[t*Ae+0]&4194303}getCodePoint(t){let i=this._data[t*Ae+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Ae+0]&2097152}getString(t){let i=this._data[t*Ae+0];return i&2097152?this._combined[t]:i&2097151?Ts(i&2097151):""}isProtected(t){return this._data[t*Ae+2]&536870912}loadCell(t,i){return Io=t*Ae,i.content=this._data[Io+0],i.fg=this._data[Io+1],i.bg=this._data[Io+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*Ae+0]=i.content,this._data[t*Ae+1]=i.fg,this._data[t*Ae+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*Ae+0]=i|s<<22,this._data[t*Ae+1]=r.fg,this._data[t*Ae+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*Ae+0];r&2097152?this._combined[t]+=Ts(i):r&2097151?(this._combined[t]=Ts(r&2097151)+Ts(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*Ae+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new xi;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new xi;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Ha<this._data.buffer.byteLength;let s=t*Ae;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[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,s*4*Ha<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ha<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 s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 Xf(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*Ae+0]&4194303)return t+(this._data[t*Ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ae+0]&4194303||this._data[t*Ae+2]&50331648)return t+(this._data[t*Ae+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let c=r-1;c>=0;c--){for(let h=0;h<Ae;h++)this._data[(s+c)*Ae+h]=o[(i+c)*Ae+h];o[(i+c)*Ae+2]&268435456&&(this._extendedAttrs[s+c]=t._extendedAttrs[i+c])}else for(let c=0;c<r;c++){for(let h=0;h<Ae;h++)this._data[(s+c)*Ae+h]=o[(i+c)*Ae+h];o[(i+c)*Ae+2]&268435456&&(this._extendedAttrs[s+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+s]=t._combined[h])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*Ae+0],a=o&2097151,c=o&2097152?this._combined[i]:a?Ts(a):Us;if(n+=c,r)for(let h=0;h<c.length;++h)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function iS(e,t,i,s,r,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&&s>=a&&s<c){a+=d.length-1;continue}let u=0,f=eo(d,u,t),_=1,v=0;for(;_<d.length;){let g=eo(d,_,t),y=g-v,C=i-f,k=Math.min(y,C);d[u].copyCellsFrom(d[_],v,f,k,!1),f+=k,f===i&&(u++,f=0),v+=k,v===g&&(_++,v=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,r))}d[u].replaceCells(f,i,r);let m=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)m++;m>0&&(o.push(a+d.length-m),o.push(m)),a+=d.length-1}return o}function sS(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function rS(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function nS(e,t,i){let s=[],r=e.map((c,h)=>eo(e,h,t)).reduce((c,h)=>c+h),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let c=eo(e,o,t);n>c&&(n-=c,o++);let h=e[o].getWidth(n-1)===2;h&&n--;let d=h?i-1:i;s.push(d),a+=d}return s}function eo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Qf=class Jf{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Jf._nextId++,this._onDispose=this.register(new ie),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Br(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Qf._nextId=1;var oS=Qf,gt={},sr=gt.B;gt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};gt.A={"#":"£"};gt.B=void 0;gt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};gt.C=gt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};gt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};gt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};gt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};gt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};gt.E=gt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};gt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};gt.H=gt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};gt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Yc=4294967295,Gc=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=ct.clone(),this.savedCharset=sr,this.markers=[],this._nullCell=xi.fromCharData([0,_f,1,0]),this._whitespaceCell=xi.fromCharData([0,Us,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new sa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Vc(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 $o),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 $o),this._whitespaceCell}getBlankLine(e,t){return new Wn(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>Yc?Yc:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ct);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 Vc(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(ct),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+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 Wn(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 Wn(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(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,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++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let 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,s=iS(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ct),i);if(s.length>0){let r=sS(this.lines,s);rS(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(ct),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Wn(e,s))):(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,s=this.getNullCell(ct),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),c.unshift(a);if(!i){let k=this.ybase+this.y;if(k>=o&&k<o+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=nS(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 k=0;k<u;k++){let w=this.getBlankLine(ct,!0);_.push(w)}_.length>0&&(r.push({start:o+c.length+n,newLines:_}),n+=_.length),c.push(..._);let v=d.length-1,m=d[v];m===0&&(v--,m=d[v]);let g=c.length-u-1,y=h;for(;g>=0;){let k=Math.min(y,m);if(c[v]===void 0)break;if(c[v].copyCellsFrom(c[g],y-k,m-k,k,!0),m-=k,m===0&&(v--,m=d[v]),y-=k,y===0){g--;let w=Math.max(g,0);y=eo(c,w,this._cols)}}for(let k=0;k<c.length;k++)d[k]<e&&c[k].setCell(d[k],s);let C=u-f;for(;C-- >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(r.length>0){let o=[],a=[];for(let m=0;m<this.lines.length;m++)a.push(this.lines.get(m));let c=this.lines.length,h=c-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let f=0;for(let m=Math.min(this.lines.maxLength-1,c+n-1);m>=0;m--)if(u&&u.start>h+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(m--,u.newLines[g]);m++,o.push({index:h+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(m,a[h--]);let _=0;for(let m=o.length-1;m>=0;m--)o[m].index+=_,this.lines.onInsertEmitter.fire(o[m]),_+=o[m].amount;let v=Math.max(0,c+n-this.lines.maxLength);v>0&&this.lines.onTrimEmitter.fire(v)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}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 oS(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)}},aS=class extends Oe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ie),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 Gc(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Gc(!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)}},Zf=2,$f=1,jl=class extends Oe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ie),this.onResize=this._onResize.event,this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Zf),this.rows=Math.max(e.rawOptions.rows||0,$f),this.buffers=this._register(new aS(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,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=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(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.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 s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};jl=ot([ae(0,qt)],jl);var Hr={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:ia,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},lS=["normal","bold","100","200","300","400","500","600","700","800","900"],hS=class extends Oe{constructor(e){super(),this._onOptionChange=this._register(new ie),this.onOptionChange=this._onOptionChange.event;let t={...Hr};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(tt(()=>{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 Hr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Hr))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Hr[e]),!cS(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Hr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=lS.includes(t)?t:Hr[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 cS(e){return e==="block"||e==="underline"||e==="bar"}function Hn(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Hn(e[s],t-1);return i}var Xc=Object.freeze({insertMode:!1}),Qc=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Vl=class extends Oe{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 ie),this.onData=this._onData.event,this._onUserInput=this._register(new ie),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ie),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ie),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Hn(Xc),this.decPrivateModes=Hn(Qc)}reset(){this.modes=Hn(Xc),this.decPrivateModes=Hn(Qc)}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(s=>s.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))}};Vl=ot([ae(0,Kt),ae(1,bf),ae(2,qt)],Vl);var Jc={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 za(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 Ua=String.fromCharCode,Zc={DEFAULT:e=>{let t=[za(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ua(t[0])}${Ua(t[1])}${Ua(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${za(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${za(e,!0)};${e.x};${e.y}${t}`}},Yl=class extends Oe{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 ie),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Jc))this.addProtocol(s,Jc[s]);for(let s of Object.keys(Zc))this.addEncoding(s,Zc[s]);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 s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_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)}};Yl=ot([ae(0,Kt),ae(1,Ir),ae(2,qt)],Yl);var Ka=[[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]],uS=[[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]],ft;function dS(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var fS=class{constructor(){if(this.version="6",!ft){ft=new Uint8Array(65536),ft.fill(1),ft[0]=0,ft.fill(0,1,32),ft.fill(0,127,160),ft.fill(2,4352,4448),ft[9001]=2,ft[9002]=2,ft.fill(2,11904,42192),ft[12351]=1,ft.fill(2,44032,55204),ft.fill(2,63744,64256),ft.fill(2,65040,65050),ft.fill(2,65072,65136),ft.fill(2,65280,65377),ft.fill(2,65504,65511);for(let e=0;e<Ka.length;++e)ft.fill(0,Ka[e][0],Ka[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ft[e]:dS(e,uS)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=lr.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return lr.createPropertyValue(0,i,s)}},lr=class Yo{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ie,this.onChange=this._onChange.event;let t=new fS;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,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?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,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)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,s),c=Yo.extractWidth(a);Yo.extractShouldJoin(a)&&(c-=Yo.extractWidth(s)),i+=c,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},_S=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 $c(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.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 Ln=2147483647,vS=256,e_=class Gl{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>vS)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 Gl;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Gl(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 s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}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>Ln?Ln: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>Ln?Ln: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,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,Ln):t}},An=[],pS=class{constructor(){this._state=0,this._active=An,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 s=i.indexOf(t);s!==-1&&i.splice(s,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=An}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=An,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||An,!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",Sa(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].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 s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-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,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=An,this._id=-1,this._state=0}}},si=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+=Sa(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}},On=[],gS=class{constructor(){this._handlers=Object.create(null),this._active=On,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=On}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=On,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||On,!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",Sa(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=On,this._ident=0}},zn=new e_;zn.addParam(0);var eu=class{constructor(e){this._handler=e,this._data="",this._params=zn,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():zn,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Sa(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=zn,this._data="",this._hitLimit=!1,i));return this._params=zn,this._data="",this._hitLimit=!1,t}},mS=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},mi=160,bS=(function(){let e=new mS(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),i=(a,c)=>t.slice(a,c),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,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(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,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(r,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(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,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(r,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(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(mi,0,2,0),e.add(mi,8,5,8),e.add(mi,6,0,6),e.add(mi,11,0,11),e.add(mi,13,13,13),e})(),SS=class extends Oe{constructor(e=bS){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 e_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},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(tt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new pS),this._dcsParser=this._register(new gS),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 r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);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 s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,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 s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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 s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(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(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===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(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:mi)],r>>4){case 2:for(let f=a+1;;++f){if(f>=t||(s=e[f])<32||s>126&&s<mi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<mi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<mi){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<mi){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|s],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,r,a),o;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let d=this._escHandlers[this._collect<<8|s],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,r,a),o;u<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(s=e[f])===24||s===26||s===27||s>127&&s<mi){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=a+1;;f++)if(f>=t||(s=e[f])<32||s>127&&s<mi){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},yS=/^([\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})$/,wS=/^[\da-f]+$/;function tu(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=yS.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),wS.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function qa(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function CS(e,t=16){let[i,s,r]=e;return`rgb:${qa(i,t)}/${qa(s,t)}/${qa(r,t)}`}var kS={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Rs=131072,iu=10;function su(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 ru=5e3,nu=0,xS=class extends Oe{constructor(e,t,i,s,r,n,o,a,c=new SS){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new qg,this._utf8Decoder=new jg,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ct.clone(),this._eraseAttrDataInternal=ct.clone(),this._onRequestBell=this._register(new ie),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ie),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ie),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ie),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ie),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ie),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ie),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ie),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ie),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ie),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ie),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ie),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 Xl(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(q.BEL,()=>this.bell()),this._parser.setExecuteHandler(q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(q.BS,()=>this.backspace()),this._parser.setExecuteHandler(q.HT,()=>this.tab()),this._parser.setExecuteHandler(q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(jo.IND,()=>this.index()),this._parser.setExecuteHandler(jo.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(jo.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new si(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new si(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new si(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new si(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new si(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new si(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new si(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new si(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new si(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new si(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new si(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new si(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 gt)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 eu((h,d)=>this.requestStatusString(h,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),ru))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${ru} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=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;s=this._parseStack.cursorStartX,r=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(s,r,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(s,r,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&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 s,r,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(s=e[_],s<127&&n){let y=n[String.fromCharCode(s)];y&&(s=y.charCodeAt(0))}let v=this._unicodeService.charProperties(s,f);r=lr.extractWidth(v);let m=lr.extractShouldJoin(v),g=m?lr.extractWidth(f):0;if(f=v,o&&this._onA11yChar.fire(Ts(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>a){if(c){let y=u,C=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 Wn&&u.copyCellsFrom(y,C,0,g,!1);C<a;)y.setCellFromCodepoint(C++,0,1,d)}else if(this._activeBuffer.x=a-1,r===2)continue}if(m&&this._activeBuffer.x){let y=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-y,s,r);for(let C=r-g;--C>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(d)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)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=>su(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new eu(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new si(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,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(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 s;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--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.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 r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(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,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-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,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let 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(ct));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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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,s=lr.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),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(q.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(q.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(q.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(q.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(q.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,sr),this._charsetService.setgCharset(1,sr),this._charsetService.setgCharset(2,sr),this._charsetService.setgCharset(3,sr);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){(m=>(m[m.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",m[m.SET=1]="SET",m[m.RESET=2]="RESET",m[m.PERMANENTLY_SET=3]="PERMANENTLY_SET",m[m.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:h,alt:d}=a,u=this._optionsService.rawOptions,f=(m,g)=>(o.triggerDataEvent(`${q.ESC}[${t?"":"?"}${m};${g}$y`),!0),_=m=>m?1:2,v=e.params[0];return t?v===2?f(v,4):v===4?f(v,_(o.modes.insertMode)):v===12?f(v,3):v===20?f(v,_(u.convertEol)):f(v,0):v===1?f(v,_(s.applicationCursorKeys)):v===3?f(v,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):v===6?f(v,_(s.origin)):v===7?f(v,_(s.wraparound)):v===8?f(v,3):v===9?f(v,_(r==="X10")):v===12?f(v,_(u.cursorBlink)):v===25?f(v,_(!o.isCursorHidden)):v===45?f(v,_(s.reverseWraparound)):v===66?f(v,_(s.applicationKeypad)):v===67?f(v,4):v===1e3?f(v,_(r==="VT200")):v===1002?f(v,_(r==="DRAG")):v===1003?f(v,_(r==="ANY")):v===1004?f(v,_(s.sendFocus)):v===1005?f(v,4):v===1006?f(v,_(n==="SGR")):v===1015?f(v,4):v===1016?f(v,_(n==="SGR_PIXELS")):v===1048?f(v,1):v===47||v===1047||v===1049?f(v,_(h===d)):v===2004?f(v,_(s.bracketedPasteMode)):v===2026?f(v,_(s.synchronizedOutput)):f(v,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=bo.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[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=ct.fg,e.bg=ct.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,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=ct.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=ct.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=ct.fg&16777215,s.bg&=-67108864,s.bg|=ct.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${q.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${q.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(`${q.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=ct.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(!su(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(`${q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>iu&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>iu&&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 s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(ou(n))if(r==="?")t.push({type:0,index:n});else{let o=tu(r);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(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=tu(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}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 s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);ou(r)&&t.push({type:2,index:r})}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,sr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(kS[e[0]],gt[e[1]]||sr),!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=ct.clone(),this._eraseAttrDataInternal=ct.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 xi;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,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${q.ESC}${o}${q.ESC}\\`),!0),s=this._bufferService.buffer,r=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${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Xl=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&&(nu=e,e=t,t=nu),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Xl=ot([ae(0,Kt)],Xl);function ou(e){return 0<=e&&e<256}var ES=5e7,au=12,DS=50,RS=class extends Oe{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 ie),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 s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>ES)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 s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=au?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=au)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>DS&&(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()}},Ql=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,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.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(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}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)))}};Ql=ot([ae(0,Kt)],Ql);var lu=!1,PS=class extends Oe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Sn),this._onBinary=this._register(new ie),this.onBinary=this._onBinary.event,this._onData=this._register(new ie),this.onData=this._onData.event,this._onLineFeed=this._register(new ie),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ie),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ie),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ie),this._instantiationService=new $b,this.optionsService=this._register(new hS(e)),this._instantiationService.setService(qt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(jl)),this._instantiationService.setService(Kt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ql)),this._instantiationService.setService(bf,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Vl)),this._instantiationService.setService(Ir,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Yl)),this._instantiationService.setService(mf,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(lr)),this._instantiationService.setService(Xg,this.unicodeService),this._charsetService=this._instantiationService.createInstance(_S),this._instantiationService.setService(Gg,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ql),this._instantiationService.setService(Sf,this._oscLinkService),this._inputHandler=this._register(new xS(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Bt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Bt.forward(this._bufferService.onResize,this._onResize)),this._register(Bt.forward(this.coreService.onData,this._onData)),this._register(Bt.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 RS((t,i)=>this._inputHandler.parse(t,i))),this._register(Bt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ie),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&&!lu&&(this._logService.warn("writeSync is unreliable and will be removed soon."),lu=!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,Zf),t=Math.max(t,$f),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($c.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>($c(this._bufferService),!1))),this._windowsWrappingHeuristics.value=tt(()=>{for(let t of e)t.dispose()})}}},TS={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 MS(e,t,i,s){var o;let r={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?r.key=q.ESC+"OA":r.key=q.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=q.ESC+"OD":r.key=q.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=q.ESC+"OC":r.key=q.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=q.ESC+"OB":r.key=q.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":q.DEL,e.altKey&&(r.key=q.ESC+r.key);break;case 9:if(e.shiftKey){r.key=q.ESC+"[Z";break}r.key=q.HT,r.cancel=!0;break;case 13:r.key=e.altKey?q.ESC+q.CR:q.CR,r.cancel=!0;break;case 27:r.key=q.ESC,e.altKey&&(r.key=q.ESC+q.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"D":t?r.key=q.ESC+"OD":r.key=q.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"C":t?r.key=q.ESC+"OC":r.key=q.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"A":t?r.key=q.ESC+"OA":r.key=q.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"B":t?r.key=q.ESC+"OB":r.key=q.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=q.ESC+"[2~");break;case 46:n?r.key=q.ESC+"[3;"+(n+1)+"~":r.key=q.ESC+"[3~";break;case 36:n?r.key=q.ESC+"[1;"+(n+1)+"H":t?r.key=q.ESC+"OH":r.key=q.ESC+"[H";break;case 35:n?r.key=q.ESC+"[1;"+(n+1)+"F":t?r.key=q.ESC+"OF":r.key=q.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=q.ESC+"[5;"+(n+1)+"~":r.key=q.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=q.ESC+"[6;"+(n+1)+"~":r.key=q.ESC+"[6~";break;case 112:n?r.key=q.ESC+"[1;"+(n+1)+"P":r.key=q.ESC+"OP";break;case 113:n?r.key=q.ESC+"[1;"+(n+1)+"Q":r.key=q.ESC+"OQ";break;case 114:n?r.key=q.ESC+"[1;"+(n+1)+"R":r.key=q.ESC+"OR";break;case 115:n?r.key=q.ESC+"[1;"+(n+1)+"S":r.key=q.ESC+"OS";break;case 116:n?r.key=q.ESC+"[15;"+(n+1)+"~":r.key=q.ESC+"[15~";break;case 117:n?r.key=q.ESC+"[17;"+(n+1)+"~":r.key=q.ESC+"[17~";break;case 118:n?r.key=q.ESC+"[18;"+(n+1)+"~":r.key=q.ESC+"[18~";break;case 119:n?r.key=q.ESC+"[19;"+(n+1)+"~":r.key=q.ESC+"[19~";break;case 120:n?r.key=q.ESC+"[20;"+(n+1)+"~":r.key=q.ESC+"[20~";break;case 121:n?r.key=q.ESC+"[21;"+(n+1)+"~":r.key=q.ESC+"[21~";break;case 122:n?r.key=q.ESC+"[23;"+(n+1)+"~":r.key=q.ESC+"[23~";break;case 123:n?r.key=q.ESC+"[24;"+(n+1)+"~":r.key=q.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=q.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=q.DEL:e.keyCode===219?r.key=q.ESC:e.keyCode===220?r.key=q.FS:e.keyCode===221&&(r.key=q.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=TS[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=q.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()),r.key=q.ESC+h}else if(e.keyCode===32)r.key=q.ESC+(e.ctrlKey?q.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let c=e.code.slice(3,4);e.shiftKey||(c=c.toLowerCase()),r.key=q.ESC+c,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=q.US),e.key==="@"&&(r.key=q.NUL));break}return r}var at=0,BS=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new sa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new sa,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((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(at=this._search(t),at===-1)||this._getKey(this._array[at])!==t)return!1;do if(this._array[at]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(at),!0;while(++at<this._array.length&&this._getKey(this._array[at])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];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&&(at=this._search(e),!(at<0||at>=this._array.length)&&this._getKey(this._array[at])===e))do yield this._array[at];while(++at<this._array.length&&this._getKey(this._array[at])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(at=this._search(e),!(at<0||at>=this._array.length)&&this._getKey(this._array[at])===e))do t(this._array[at]);while(++at<this._array.length&&this._getKey(this._array[at])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},ja=0,hu=0,LS=class extends Oe{constructor(){super(),this._decorations=new BS(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ie),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ie),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(tt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new AS(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.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 s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{ja=r.options.x??0,hu=ja+(r.options.width??1),e>=ja&&e<hu&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},AS=class extends Gs{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ie),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ie),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=st.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=st.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},OS=1e3,IS=class{constructor(e,t=OS){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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let 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)}},cu=20,ra=class extends Oe{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new IS(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(`
34
+ `))),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(Ce(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(tt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<cu+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
35
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===cu+1&&(this._liveRegion.textContent+=pl.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,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",c=(i.ydisp+r+1).toString(),h=this._rowElements[r];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",c),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({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=r(t),o=r(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 r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};ra=ot([ae(1,Mh),ae(2,ws),ae(3,Cs)],ra);var Jl=class extends Oe{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ie),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ie),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(tt(()=>{var n;Br(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(Ce(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ce(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ce(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ce(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 s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.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 s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.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?(r=this._activeProviderReplies)!=null&&r.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 s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[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)){r.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.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&&NS(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,Br(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,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.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,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.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 s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Jl=ot([ae(1,Bh),ae(2,Cs),ae(3,Kt),ae(4,wf)],Jl);function NS(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 FS=class extends PS{constructor(e={}){super(e),this._linkifier=this._register(new Sn),this.browser=zf,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Sn),this._onCursorMove=this._register(new ie),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ie),this.onKey=this._onKey.event,this._onRender=this._register(new ie),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ie),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ie),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ie),this.onBell=this._onBell.event,this._onFocus=this._register(new ie),this._onBlur=this._register(new ie),this._onA11yCharEmitter=this._register(new ie),this._onA11yTabEmitter=this._register(new ie),this._onWillOpen=this._register(new ie),this._setup(),this._decorationService=this._instantiationService.createInstance(LS),this._instantiationService.setService(So,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Db),this._instantiationService.setService(wf,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ml)),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(Bt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Bt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Bt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Bt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(tt(()=>{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,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=et.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${q.ESC}]${s};${CS(r)}${Wf.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ut.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ut.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(ra,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.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(q.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),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,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=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ce(this.element,"copy",t=>{this.hasSelection()&&Ug(t,this._selectionService)}));let e=t=>Kg(t,this.textarea,this.coreService,this.optionsService);this._register(Ce(this.textarea,"paste",e)),this._register(Ce(this.element,"paste",e)),Uf?this._register(Ce(this.element,"mousedown",t=>{t.button===2&&Sc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ce(this.element,"contextmenu",t=>{Sc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Hh&&this._register(Ce(this.element,"auxclick",t=>{t.button===1&&ff(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ce(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ce(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ce(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ce(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ce(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ce(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ce(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;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"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=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(Ce(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",vl.get()),jf||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(xb,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ws,this._coreBrowserService),this._register(Ce(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(Ce(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wl,this._document,this._helperContainer),this._instantiationService.setService(ya,this._charSizeService),this._themeService=this._instantiationService.createInstance(Kl),this._instantiationService.setService(xn,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ta),this._instantiationService.setService(yf,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(zl,this.rows,this.screenElement)),this._instantiationService.setService(Cs,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(Il,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hl),this._instantiationService.setService(Bh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Jl,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(Al,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(Ul,this.element,this.screenElement,s)),this._instantiationService.setService(Jg,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(Bt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Ol,this.screenElement)),this._register(Ce(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(ra,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ea,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ea,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Fl,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 v=n.deltaY;if(v===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=v<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 s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.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?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ce(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(Ce(t,"wheel",n=>{var o,a,c,h,d;if(!s.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=q.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){df(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=MS(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),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===q.ETX||i.key===q.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)&&(WS(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(ct));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(q.ESC+"[I"):this.coreService.triggerDataEvent(q.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(`${q.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${q.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function WS(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var HS=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)}},zS=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 xi)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},uu=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 zS(t)}getNullCell(){return new xi}},US=class extends Oe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ie),this.onBufferChange=this._onBufferChange.event,this._normal=new uu(this._core.buffers.normal,"normal"),this._alternate=new uu(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)}},KS=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,s)=>t(i,s.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)}},qS=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}},jS=["cols","rows"],Vi=0,VS=class extends Oe{constructor(e){super(),this._core=this._register(new FS(e)),this._addonManager=this._register(new HS),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(jS.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 KS(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new qS(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 US(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
36
+ `,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 vl.get()},set promptLabel(e){vl.set(e)},get tooMuchOutput(){return pl.get()},set tooMuchOutput(e){pl.set(e)}}}_verifyIntegers(...e){for(Vi of e)if(Vi===1/0||isNaN(Vi)||Vi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Vi of e)if(Vi&&(Vi===1/0||isNaN(Vi)||Vi%1!==0||Vi<0))throw new Error("This API only accepts positive integers")}};/**
37
37
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
38
38
  * @license MIT
39
39
  *
@@ -44,4 +44,4 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
44
44
  * Fabrice Bellard's javascript vt100 for jslinux:
45
45
  * http://bellard.org/jslinux/
46
46
  * Copyright (c) 2011 Fabrice Bellard
47
- */var VS=2,YS=1,GS=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),s=parseInt(i.getPropertyValue("height")),r=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=s-a,d=r-c-t;return{cols:Math.max(VS,Math.floor(d/e.css.cell.width)),rows:Math.max(YS,Math.floor(h/e.css.cell.height))}}},XS=L('<div class="scroll-fabs svelte-5qgfij"><button class="scroll-fab svelte-5qgfij" data-dir="up" aria-label="Page up">&#9650;</button> <button class="scroll-fab svelte-5qgfij" data-dir="down" aria-label="Page down">&#9660;</button> <button class="scroll-fab scroll-fab-bottom svelte-5qgfij" data-dir="bottom" aria-label="Skip to bottom">&#8615;</button></div>'),QS=L('<div><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 e_(e,t){Ye(t,!0);let i=Kt(t,"useTmux",3,!1),s=Kt(t,"companionMode",3,!1),r,n=I(null),o,a=!1;function c(){return l(n)}function h(){var j;(j=l(n))==null||j.focus()}function d(){if(!l(n))return;const j=l(n).buffer.active,ie=j.viewportY>=j.baseY,Q=j.viewportY;o==null||o.fit(),ie?l(n).scrollToBottom():l(n).scrollToLine(Q),Ba(l(n).cols,l(n).rows),E()}xn(()=>{const j=new jS({cursorBlink:!0,fontSize:Rt?12:14,fontFamily:"Menlo, monospace",scrollback:1e4,theme:{background:"#000000",foreground:"#d4d4d4",cursor:"#d4d4d4"}});if(o=new GS,j.loadAddon(o),j.open(r),Rt){const M=r.querySelector(".xterm-viewport");M&&(M.style.touchAction="none",M.style.overflowY="hidden");const J=r.querySelector(".xterm-screen");if(J){J.addEventListener("wheel",Be=>{Be.stopImmediatePropagation(),Be.preventDefault()},{capture:!0,passive:!1});const fe=Be=>{j.modes.mouseTrackingMode!=="none"&&Be.stopImmediatePropagation()};for(const Be of["mousedown","mouseup","mousemove"])J.addEventListener(Be,fe,{capture:!0})}}o.fit(),j.onData(M=>Er(M));{const M=/Mac|iPhone|iPad|iPod/.test(navigator.platform||"");j.attachCustomKeyEventHandler(J=>!M&&J.type==="keydown"&&J.ctrlKey&&!J.shiftKey&&!J.altKey&&!J.metaKey&&(J.key==="v"||J.key==="V")&&navigator.clipboard&&navigator.clipboard.read?(navigator.clipboard.read().then(fe=>{let Be=null,qe=null;for(const Te of fe){for(const tt of Te.types)if(tt.startsWith("image/")){qe=tt,Be=Te;break}if(Be)break}Be&&qe?Be.getType(qe).then(Te=>xe(Te,qe)):navigator.clipboard.readText().then(Te=>{Te&&j.paste(Te)})}).catch(()=>{navigator.clipboard.readText&&navigator.clipboard.readText().then(fe=>{fe&&j.paste(fe)}).catch(()=>{})}),!1):!0)}j.parser.registerOscHandler(52,M=>{var Be;const J=M.indexOf(";");if(J===-1)return!0;const fe=M.slice(J+1);if(!fe||fe==="?")return!0;try{const qe=Uint8Array.from(atob(fe),tt=>tt.charCodeAt(0)),Te=new TextDecoder("utf-8").decode(qe);(Be=navigator.clipboard)==null||Be.writeText(Te).catch(()=>{})}catch{}return!0}),j.onScroll(E),j.onWriteParsed(E);let ie=null;const Q=new ResizeObserver(()=>{ie&&clearTimeout(ie),ie=setTimeout(()=>{const M=j.buffer.active,J=M.viewportY>=M.baseY,fe=M.viewportY;o.fit(),J?j.scrollToBottom():j.scrollToLine(fe),Ba(j.cols,j.rows),E()},Rt?150:0)});return Q.observe(r),Rt&&(document.addEventListener("touchmove",he,{passive:!1}),document.addEventListener("touchend",ge),document.addEventListener("touchcancel",ge)),b(n,j,!0),()=>{ie&&clearTimeout(ie),U&&clearTimeout(U),Q.disconnect(),j.dispose(),b(n,null),y=!1,u=!1,Rt&&(document.removeEventListener("touchmove",he),document.removeEventListener("touchend",ge),document.removeEventListener("touchcancel",ge))}}),Ui(()=>{t.sessionId&&l(n)&&!s()&&(l(n).reset(),of(t.sessionId,l(n),()=>{l(n)&&Ba(l(n).cols,l(n).rows)},()=>{}))});let u=!1,f=0,_=0,v=I(0),m=I(0),g=I(!1),y=!1,C=0,k=0,w=!1,D=0,F=0,z=I(!1),N=I(!1),U=null,Y=0,K=0;const W=500,O=10;let A=!1;function E(){A||(A=!0,requestAnimationFrame(B))}function B(){if(A=!1,!l(n))return;const j=l(n).buffer.active,ie=j.baseY+l(n).rows,Q=j.viewportY,M=ue;if(!M)return;const J=M.clientHeight;if(ie<=l(n).rows){b(g,!1);return}b(g,!0),b(v,Math.max(Rt?44:20,l(n).rows/ie*J),!0),b(m,Q/(ie-l(n).rows)*(J-l(v)))}function R(j){if(!l(n)||!ue)return;const ie=ue.getBoundingClientRect(),M=l(n).buffer.active.baseY+l(n).rows;if(M<=l(n).rows)return;const J=ue.clientHeight,fe=Math.max(Rt?44:20,l(n).rows/M*J),Be=J-fe,qe=j-ie.top-fe/2,Te=Math.max(0,Math.min(1,qe/Be)),tt=Math.round(Te*(M-l(n).rows));l(n).scrollToLine(tt)}function P(j){const ie=j.touches[0];ie&&(u=!0,f=ie.clientY,_=l(m))}function H(){var j;l(N)&&(b(N,!1),(j=t.onCopyModeChange)==null||j.call(t,!1))}function Z(){var Q;if(U=null,y=!1,navigator.vibrate&&navigator.vibrate(50),i()){b(N,!0),(Q=t.onCopyModeChange)==null||Q.call(t,!0),Er("[");return}b(z,!0);const j=r.querySelector(".xterm-screen");j&&(j.style.userSelect="text",j.style.webkitUserSelect="text"),r.querySelectorAll("canvas").forEach(M=>{M.style.pointerEvents="none"});const ie=r.querySelector(".xterm-rows");if(ie){const M=document.createRange();M.selectNodeContents(ie);const J=window.getSelection();J==null||J.removeAllRanges(),J==null||J.addRange(M)}}function de(){var ie;b(z,!1);const j=r.querySelector(".xterm-screen");j&&(j.style.userSelect="",j.style.webkitUserSelect=""),r.querySelectorAll("canvas").forEach(Q=>{Q.style.pointerEvents=""}),(ie=window.getSelection())==null||ie.removeAllRanges()}function be(j){var Q;if(l(z)){const M=((Q=window.getSelection())==null?void 0:Q.toString())??"";M.trim().length>0&&(navigator.clipboard.writeText(M).catch(()=>{}),navigator.vibrate&&navigator.vibrate(30)),de();return}if(l(N)||j.target.closest(".terminal-scrollbar")||j.target.closest(".scroll-fabs")||!l(n))return;const ie=j.touches[0];ie&&(C=ie.clientY,F=ie.clientY,k=l(n).buffer.active.viewportY,w=!1,D=0,y=!0,Y=ie.clientX,K=ie.clientY,U&&clearTimeout(U),U=setTimeout(()=>{Z()},W))}function he(j){const ie=j.touches[0];if(ie){if(u){if(!l(n)||!ue)return;j.preventDefault();const Q=ie.clientY-f,J=l(n).buffer.active.baseY+l(n).rows;if(J<=l(n).rows)return;const fe=ue.clientHeight,Be=Math.max(44,l(n).rows/J*fe),qe=fe-Be,tt=Math.max(0,Math.min(qe,_+Q))/qe,De=Math.round(tt*(J-l(n).rows));l(n).scrollToLine(De);return}if(y&&l(n)&&!l(z)){if(U){const M=Math.abs(ie.clientX-Y),J=Math.abs(ie.clientY-K);(M>O||J>O)&&(clearTimeout(U),U=null)}if(l(n).rows===0||r.clientHeight===0)return;const Q=C-ie.clientY;if(Math.abs(Q)>5){w=!0,j.preventDefault();const M=r.clientHeight/l(n).rows;if(l(n).buffer.active.type==="alternate"){const J=F-ie.clientY;F=ie.clientY;const fe=J/M;D+=fe;const Be=Math.trunc(D);if(Be!==0){D-=Be;const qe=Be>0?65:64,Te=Math.max(1,Math.round(l(n).cols/2)),tt=Math.max(1,Math.round(l(n).rows/2)),De=`\x1B[<${qe};${Te};${tt}M`,At=Math.min(Math.abs(Be),5);for(let ei=0;ei<At;ei++)Er(De)}}else{const J=Q/M,fe=l(n).buffer.active.baseY,Be=Math.max(0,Math.min(fe,Math.round(k+J)));l(n).scrollToLine(Be)}}}}}function ge(){U&&(clearTimeout(U),U=null),u=!1,y=!1,w=!1,D=0}function ye(j){j.target!==pe&&R(j.clientY)}function ke(j){var M,J,fe;j.preventDefault();const ie=j.target.closest("button");if(!ie)return;const Q=ie.dataset.dir;Q==="up"?(M=l(n))==null||M.scrollPages(-1):Q==="down"?(J=l(n))==null||J.scrollPages(1):Q==="bottom"&&((fe=l(n))==null||fe.scrollToBottom())}let ue,pe;async function xe(j,ie){var M;if(a||!t.sessionId)return;a=!0,(M=t.onImageUpload)==null||M.call(t,"Pasting image…",!1);const Q=new FileReader;Q.onload=async()=>{var fe,Be,qe;const J=Q.result.split(",")[1];try{const Te=await Lp(t.sessionId,J,ie);Te.clipboardSet?(fe=t.onImageUpload)==null||fe.call(t,"Image pasted",!1):(Be=t.onImageUpload)==null||Be.call(t,Te.path,!0,Te.path)}catch(Te){const tt=Te instanceof Error?Te.message:"Image upload failed";(qe=t.onImageUpload)==null||qe.call(t,tt,!1)}finally{a=!1}},Q.readAsDataURL(j)}function Le(j){var ie;if((ie=j.clipboardData)!=null&&ie.items){for(const Q of j.clipboardData.items)if(Q.type.startsWith("image/")){j.preventDefault(),j.stopPropagation();const M=Q.getAsFile();M&&xe(M,Q.type);return}}}let We=I(!1);function ze(j){var ie;(ie=j.dataTransfer)!=null&&ie.types.includes("Files")&&(j.preventDefault(),b(We,!0))}function Ce(){b(We,!1)}function q(j){var Q;if(j.preventDefault(),b(We,!1),!((Q=j.dataTransfer)!=null&&Q.files.length))return;const ie=j.dataTransfer.files[0];ie.type.startsWith("image/")&&xe(ie,ie.type)}function ne(j){var ie;u||w||j.target.closest(".terminal-scrollbar")||l(z)||((ie=l(n))==null||ie.focus(),j.preventDefault())}var Se={getTerm:c,focusTerm:h,fitTerm:d,exitCopyMode:H,handleImageUpload:xe},ve=QS();let Ee;var le=S(ve);Je(le,j=>r=j,()=>r);var Pe=x(le,2);Me(Pe,"aria-valuenow",0);var Ke=S(Pe);let He;Je(Ke,j=>pe=j,()=>pe),Je(Pe,j=>ue=j,()=>ue);var me=x(Pe,2);{var Ie=j=>{var ie=XS();X("mousedown",ie,ke),T(j,ie)};ee(me,j=>{Rt&&l(g)&&j(Ie)})}return re(()=>{Ee=et(ve,1,"terminal-wrapper svelte-5qgfij",null,Ee,{"drag-over":l(We),"selection-mode":l(z)}),He=Or(Ke,"",He,{display:l(g)?"block":"none",height:l(v)+"px",top:l(m)+"px"})}),X("touchstart",ve,function(...j){var ie;(ie=Rt?be:void 0)==null||ie.apply(this,j)}),X("touchend",ve,function(...j){var ie;(ie=Rt?ne:void 0)==null||ie.apply(this,j)}),$i("paste",le,Le),$i("dragover",le,ze),$i("dragleave",le,Ce),$i("drop",le,q),X("click",Pe,ye),X("touchstart",Ke,P),T(e,ve),Ge(Se)}Ze(["touchstart","touchend","click","mousedown"]);const JS=3/1e6,ZS=15/1e6,$S=15/1e6,ey=75/1e6,ty={sonnet:{input:JS,output:ZS},opus:{input:$S,output:ey}};function t_(e,t,i="sonnet"){const s=ty[i];return e*s.input+t*s.output}function i_(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"k":String(e)}function s_(e){return e<.005?"<$0.01":"$"+e.toFixed(2)}const Yr=Xe({}),to=Xe({}),na=Xe({}),io=Xe({});function iy(e){const t=Yr[e];if(!t||t.length===0)return[];switch(t[t.length-1].type){case"turn_completed":return["Continue","Show diff","Summarize changes"];case"error":return["Retry","Show logs","Skip"];case"agent_message":return["Continue","Thanks"];default:return[]}}function sy(e){return{get events(){return Yr[e]??[]},get activePermission(){return to[e]??null},get tokenUsage(){return na[e]??{input:0,output:0,estimatedCost:0}},get isStreaming(){return io[e]??!1},get quickReplies(){return iy(e)}}}function du(e,t){Yr[e]||(Yr[e]=[]),Yr[e].push(t),t.type==="turn_started"?io[e]=!0:(t.type==="turn_completed"||t.type==="error")&&(io[e]=!1),t.usage&&ny(e,t.usage.input_tokens,t.usage.output_tokens)}function ry(e,t){to[e]=t}function fu(e,t){const i=to[e];i&&(to[e]={...i,status:t})}function ny(e,t,i){const s=na[e]??{input:0,output:0};na[e]={input:s.input+t,output:s.output+i,estimatedCost:t_(s.input+t,s.output+i)}}function oy(e){Yr[e]=[],to[e]=null,na[e]={input:0,output:0,estimatedCost:0},io[e]=!1}function ay(e,t){io[e]=t}var ly=L('<div class="user-message svelte-1q16011"><div class="user-message-text svelte-1q16011"> </div></div>');function hy(e,t){var i=ly(),s=S(i),r=S(s);re(()=>se(r,t.text)),T(e,i)}var cy=L('<div class="agent-message svelte-1r3r7jb"><!></div>');function uy(e,t){Ye(t,!0);function i(n){const o=[];let a=n.replace(/```(\w*)\n([\s\S]*?)```/g,(h,d,u)=>{const f=u.trim().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),_=o.length;return o.push('<pre class="code-block"><code>'+f+"</code></pre>"),"\0CB"+_+"\0"});const c=[];return a=a.replace(/`([^`]+)`/g,(h,d)=>{const u=d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),f=c.length;return c.push('<code class="inline-code">'+u+"</code>"),"\0IC"+f+"\0"}),a=a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),a=a.replace(/^(#{1,6})\s+(.+)$/gm,(h,d,u)=>{const f=d.length;return`<h${f} class="md-heading">${u}</h${f}>`}),a=a.replace(/^---+$/gm,'<hr class="md-hr">'),a=a.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),a=a.replace(new RegExp("(?<!\\*)\\*([^*]+?)\\*(?!\\*)","g"),"<em>$1</em>"),a=a.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(h,d,u)=>/^(?:https?:\/\/|\/|\.\/|#)/.test(u)?`<a href="${u.replace(/"/g,"&quot;")}" target="_blank" rel="noopener">${d}</a>`:d),a=a.replace(/^(?:[-*])\s+(.+)$/gm,'<li class="md-li">$1</li>'),a=a.replace(/((?:<li class="md-li">.*<\/li>\n?)+)/g,'<ul class="md-ul">$1</ul>'),a=a.replace(/^\d+\.\s+(.+)$/gm,'<li class="md-li">$1</li>'),a=a.replace(/\n/g,"<br>"),a=a.replace(/<\/(pre|ul|ol|h[1-6]|hr)><br>/g,"</$1>"),a=a.replace(/<br><(pre|ul|ol|h[1-6]|hr)/g,"<$1"),a=a.replace(/\x00CB(\d+)\x00/g,(h,d)=>o[parseInt(d)]??""),a=a.replace(/\x00IC(\d+)\x00/g,(h,d)=>c[parseInt(d)]??""),a}var s=cy(),r=S(s);al(r,()=>i(t.text)),T(e,s),Ge()}var dy=L('<span class="file-dir svelte-649juz"> </span>'),fy=L('<span class="diff-add svelte-649juz"> </span>'),_y=L('<span class="diff-remove svelte-649juz"> </span>'),vy=L('<div class="file-change-card svelte-649juz"><span class="file-icon svelte-649juz">&#128196;</span> <span class="file-path svelte-649juz"><!><span class="file-name svelte-649juz"> </span></span> <span class="diff-stats svelte-649juz"><!> <!></span></div>');function py(e,t){Ye(t,!0);let i=Kt(t,"additions",3,0),s=Kt(t,"deletions",3,0),r=ce(()=>t.path.split("/").pop()??t.path),n=ce(()=>t.path.includes("/")?t.path.slice(0,t.path.lastIndexOf("/")+1):"");var o=vy(),a=x(S(o),2),c=S(a);{var h=y=>{var C=dy(),k=S(C);re(()=>se(k,l(n))),T(y,C)};ee(c,y=>{l(n)&&y(h)})}var d=x(c),u=S(d),f=x(a,2),_=S(f);{var v=y=>{var C=fy(),k=S(C);re(()=>se(k,`+${i()??""}`)),T(y,C)};ee(_,y=>{i()&&y(v)})}var m=x(_,2);{var g=y=>{var C=_y(),k=S(C);re(()=>se(k,`-${s()??""}`)),T(y,C)};ee(m,y=>{s()&&y(g)})}re(()=>se(u,l(r))),T(e,o),Ge()}var gy=L("<span> </span>"),my=L('<pre class="tool-input svelte-9tdk1v"> </pre>'),by=L('<div class="tool-call-card svelte-9tdk1v"><button class="tool-header svelte-9tdk1v"><span class="tool-name svelte-9tdk1v"> </span> <!> <span class="toggle-icon svelte-9tdk1v"> </span></button> <!></div>');function Sy(e,t){let i=I(!1);function s(v){return v?v==="success"||v==="completed"?"status-success":v==="error"||v==="failed"?"status-error":v==="running"||v==="pending"?"status-pending":"":""}var r=by(),n=S(r),o=S(n),a=S(o),c=x(o,2);{var h=v=>{var m=gy(),g=S(m);re(y=>{et(m,1,`tool-status ${y??""}`,"svelte-9tdk1v"),se(g,t.status)},[()=>s(t.status)]),T(v,m)};ee(c,v=>{t.status&&v(h)})}var d=x(c,2),u=S(d),f=x(n,2);{var _=v=>{var m=my(),g=S(m);re(y=>se(g,y),[()=>JSON.stringify(t.toolInput,null,2)]),T(v,m)};ee(f,v=>{l(i)&&t.toolInput&&v(_)})}re(()=>{se(a,t.toolName),se(u,l(i)?"▲":"▼")}),X("click",n,()=>b(i,!l(i))),T(e,r)}Ze(["click"]);var yy=L('Thinking<span class="dots svelte-fizs81">...</span>',1),wy=L('<div class="reasoning-content svelte-fizs81" id="reasoning-content"> </div>'),Cy=L('<div class="reasoning-panel svelte-fizs81"><button class="reasoning-header svelte-fizs81" aria-controls="reasoning-content"><span class="reasoning-label svelte-fizs81"><!></span> <span class="toggle-icon svelte-fizs81"> </span></button> <!></div>');function ky(e,t){let i=I(!1);var s=Cy(),r=S(s),n=S(r),o=S(n);{var a=_=>{var v=Vs("Thinking");T(_,v)},c=_=>{var v=yy();T(_,v)};ee(o,_=>{l(i)?_(a):_(c,!1)})}var h=x(n,2),d=S(h),u=x(r,2);{var f=_=>{var v=wy(),m=S(v);re(()=>se(m,t.text)),T(_,v)};ee(u,_=>{l(i)&&_(f)})}re(()=>{Me(r,"aria-expanded",l(i)),se(d,l(i)?"▲":"▼")}),X("click",r,()=>b(i,!l(i))),T(e,s)}Ze(["click"]);var xy=L('<button class="dismiss-btn svelte-au1iu7" aria-label="Dismiss error">&times;</button>'),Ey=L('<button class="retry-btn svelte-au1iu7">Retry</button>'),Dy=L('<div class="error-card svelte-au1iu7"><div class="error-body svelte-au1iu7"><span class="error-text svelte-au1iu7"> </span> <!></div> <!></div>');function Ry(e,t){var i=Dy(),s=S(i),r=S(s),n=S(r),o=x(r,2);{var a=d=>{var u=xy();X("click",u,function(...f){var _;(_=t.onDismiss)==null||_.apply(this,f)}),T(d,u)};ee(o,d=>{t.onDismiss&&d(a)})}var c=x(s,2);{var h=d=>{var u=Ey();X("click",u,function(...f){var _;(_=t.onRetry)==null||_.apply(this,f)}),T(d,u)};ee(c,d=>{t.onRetry&&d(h)})}re(()=>se(n,t.text)),T(e,i)}Ze(["click"]);var Py=L('<div class="usage-info svelte-1q2w5up"> </div>'),Ty=L('<div class="turn-completed svelte-1q2w5up"><div class="separator-line svelte-1q2w5up"></div> <!></div>');function My(e,t){Ye(t,!0);var i=Ty(),s=x(S(i),2);{var r=n=>{var o=Py(),a=S(o);re((c,h)=>se(a,`${c??""} tokens · ${h??""}`),[()=>i_(t.usage.input_tokens+t.usage.output_tokens),()=>s_(t_(t.usage.input_tokens,t.usage.output_tokens))]),T(n,o)};ee(s,n=>{t.usage&&n(r)})}T(e,i),Ge()}var By=L('<div class="empty-state svelte-o5aojg"><p class="svelte-o5aojg">Send a message to start a conversation</p> <span class="cursor-blink svelte-o5aojg">|</span></div>'),Ly=L('<div class="session-started svelte-o5aojg"><span class="session-started-text svelte-o5aojg"> </span></div>'),Ay=L('<div class="working-indicator svelte-o5aojg"><span class="working-dot svelte-o5aojg">&#9679;</span> <span class="working-text svelte-o5aojg">Claude is working...</span></div>'),Oy=L('<div class="message-list svelte-o5aojg"><!> <!></div>'),Iy=L('<div class="chat-view svelte-o5aojg"><!></div>');function Ny(e,t){Ye(t,!0);let i,s=I(!0);Ui(()=>{t.events.length,l(s)&&i&&queueMicrotask(()=>{i==null||i.scrollTo({top:i.scrollHeight})})});function r(){if(!i)return;const{scrollTop:h,scrollHeight:d,clientHeight:u}=i;b(s,d-h-u<40)}var n=Iy(),o=S(n);{var a=h=>{var d=By();T(h,d)},c=h=>{var d=Oy(),u=S(d);vt(u,17,()=>t.events,v=>v.id??v.timestamp,(v,m)=>{var g=Hi(),y=pt(g);{var C=Y=>{hy(Y,{get text(){return l(m).text}})},k=Y=>{uy(Y,{get text(){return l(m).text}})},w=Y=>{py(Y,{get path(){return l(m).path},get additions(){return l(m).additions},get deletions(){return l(m).deletions}})},D=Y=>{Sy(Y,{get toolName(){return l(m).toolName},get toolInput(){return l(m).toolInput},get status(){return l(m).status}})},F=Y=>{ky(Y,{get text(){return l(m).text}})},z=Y=>{Ry(Y,{get text(){return l(m).text},get onRetry(){return t.onRetry}})},N=Y=>{My(Y,{get usage(){return l(m).usage}})},U=Y=>{var K=Ly(),W=S(K),O=S(W);re(()=>se(O,l(m).text)),T(Y,K)};ee(y,Y=>{l(m).type==="user_message"&&l(m).text?Y(C):l(m).type==="agent_message"&&l(m).text?Y(k,1):l(m).type==="file_change"&&l(m).path?Y(w,2):l(m).type==="tool_call"&&l(m).toolName?Y(D,3):l(m).type==="reasoning"&&l(m).text?Y(F,4):l(m).type==="error"&&l(m).text?Y(z,5):l(m).type==="turn_completed"?Y(N,6):l(m).type==="session_started"&&l(m).text&&Y(U,7)})}T(v,g)});var f=x(u,2);{var _=v=>{var m=Ay();T(v,m)};ee(f,v=>{t.isStreaming&&v(_)})}T(h,d)};ee(o,h=>{t.events.length===0?h(a):h(c,!1)})}Je(n,h=>i=h,()=>i),$i("scroll",n,r),T(e,n),Ge()}var Fy=L('<span class="send-dots svelte-mnrni5">...</span>'),Wy=$v('<svg class="send-icon svelte-mnrni5" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>'),Hy=L('<div class="chat-input-container svelte-mnrni5"><textarea placeholder="Send a message..." rows="1" class="chat-textarea svelte-mnrni5"></textarea> <button aria-label="Send message"><!></button></div>');function zy(e,t){Ye(t,!0);let i=Kt(t,"disabled",3,!1),s=I(""),r;function n(){const g=l(s).trim();!g||i()||(t.onSend(g),b(s,""),r&&(r.style.height="auto"))}function o(g){g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),n())}function a(){r&&(r.style.height="auto",r.style.height=Math.min(r.scrollHeight,120)+"px")}let c=ce(()=>!i()&&l(s).trim().length>0);var h=Hy(),d=S(h);Je(d,g=>r=g,()=>r);var u=x(d,2);let f;var _=S(u);{var v=g=>{var y=Fy();T(g,y)},m=g=>{var y=Wy();T(g,y)};ee(_,g=>{i()?g(v):g(m,!1)})}re(()=>{d.disabled=i(),f=et(u,1,"send-btn svelte-mnrni5",null,f,{disabled:!l(c)}),u.disabled=!l(c)}),X("input",d,a),X("keydown",d,o),yi(d,()=>l(s),g=>b(s,g)),X("click",u,n),T(e,h),Ge()}Ze(["input","keydown","click"]);var Uy=L('<button class="quick-reply-btn svelte-2y5bi6"> </button>'),Ky=L('<div class="quick-replies svelte-2y5bi6" role="group" aria-label="Quick replies"></div>');function qy(e,t){Ye(t,!0);var i=Hi(),s=pt(i);{var r=n=>{var o=Ky();vt(o,21,()=>t.suggestions,Sn,(a,c)=>{var h=Uy(),d=S(h);re(()=>se(d,l(c))),X("click",h,()=>t.onSelect(l(c))),T(a,h)}),T(n,o)};ee(s,n=>{t.suggestions.length>0&&n(r)})}T(e,i),Ge()}Ze(["click"]);var jy=L('<div class="permission-actions svelte-1amwf6m"><button class="approve-btn svelte-1amwf6m">Approve</button> <button class="deny-btn svelte-1amwf6m">Deny</button></div>'),Vy=L('<div class="permission-badge badge-approved svelte-1amwf6m">Approved &#10003;</div>'),Yy=L('<div class="permission-badge badge-denied svelte-1amwf6m">Denied &#10007;</div>'),Gy=L('<div class="permission-badge badge-timeout svelte-1amwf6m">Timed out</div>'),Xy=L('<div><div class="permission-header svelte-1amwf6m"><span class="permission-tool svelte-1amwf6m"> </span></div> <!></div>');function Qy(e,t){Ye(t,!0);let i=ce(()=>{const _=t.permission.input;if(t.permission.toolName==="Edit"||t.permission.toolName==="Write"){const v=_.file_path??_.path??"";return t.permission.toolName+": "+String(v)}if(t.permission.toolName==="Bash"||t.permission.toolName==="Run"){const v=_.command??_.cmd??"";return"Run: "+String(v)}return t.permission.toolName});var s=Xy();let r;var n=S(s),o=S(n),a=S(o),c=x(n,2);{var h=_=>{var v=jy(),m=S(v),g=x(m,2);re(()=>{Me(m,"aria-label",`Approve: ${l(i)??""}`),Me(g,"aria-label",`Deny: ${l(i)??""}`)}),X("click",m,()=>t.onApprove(t.permission.id)),X("click",g,()=>t.onDeny(t.permission.id)),T(_,v)},d=_=>{var v=Vy();T(_,v)},u=_=>{var v=Yy();T(_,v)},f=_=>{var v=Gy();T(_,v)};ee(c,_=>{t.permission.status==="pending"?_(h):t.permission.status==="approved"?_(d,1):t.permission.status==="denied"?_(u,2):t.permission.status==="timed_out"&&_(f,3)})}re(()=>{r=et(s,1,"permission-card svelte-1amwf6m",null,r,{resolved:t.permission.status!=="pending",timed_out:t.permission.status==="timed_out"}),se(a,l(i))}),T(e,s),Ge()}Ze(["click"]);var Jy=L('<div class="cost-display svelte-p9ddlc"> </div>');function Zy(e,t){Ye(t,!0);let i=ce(()=>t.usage.input>0||t.usage.output>0?i_(t.usage.input+t.usage.output)+" tokens · "+s_(t.usage.estimatedCost):"—");var s=Jy(),r=S(s);re(()=>se(r,l(i))),T(e,s),Ge()}var $y=L('<div class="fallback-banner svelte-oor1t0">SDK mode unavailable — fell back to terminal</div>'),ew=L('<div class="session-view svelte-oor1t0"><!> <div class="tab-bar svelte-oor1t0" role="tablist"><button class="tab active svelte-oor1t0" role="tab">Chat</button></div> <div class="tab-content svelte-oor1t0"><div class="tab-panel chat-panel svelte-oor1t0"><div class="chat-scroll-area svelte-oor1t0"><!></div> <!> <!> <!> <!></div></div></div>');function tw(e,t){Ye(t,!0);let i=Kt(t,"mode",3,"pty"),s=Kt(t,"sdkFallback",3,!1),r=Kt(t,"useTmux",3,!1),n=I("chat"),o=I(void 0),a=I(!1),c=I(!1),h=I(!1),d=I(""),u=ce(()=>t.sessionId?sy(t.sessionId):null),f=ce(()=>()=>l(u)?l(u).events:[]);Ui(()=>{if(t.sessionId&&i()==="sdk"){oy(t.sessionId),b(d,""),b(a,!1),b(h,!1),b(n,"chat");const K={onEvent:W=>{t.sessionId&&(W.type==="tool_call"&&W.status==="pending"&&W.id&&W.toolName&&ry(t.sessionId,{id:W.id,toolName:W.toolName,input:W.toolInput??{},status:"pending"}),du(t.sessionId,W))},onTerminalData:W=>{b(c,!1),b(a,!0)},onTerminalExit:()=>{b(a,!1)},onSessionEnd:()=>{t.sessionId&&ay(t.sessionId,!1)}};lf(t.sessionId,K)}});function _(K){t.sessionId&&(b(d,K,!0),du(t.sessionId,{type:"user_message",text:K,timestamp:new Date().toISOString(),id:"user-"+Date.now()}),ug(K))}function v(K){_(K)}function m(K){t.sessionId&&fu(t.sessionId,"approved"),pc(K,!0)}function g(K){t.sessionId&&fu(t.sessionId,"denied"),pc(K,!1)}function y(){_(l(d)||"Retry")}function C(){var K;(K=l(o))==null||K.focusTerm()}function k(){var K;(K=l(o))==null||K.fitTerm()}function w(){var K;(K=l(o))==null||K.exitCopyMode()}function D(K,W){var O;(O=l(o))==null||O.handleImageUpload(K,W)}var F={focusTerm:C,fitTerm:k,exitCopyMode:w,handleImageUpload:D},z=Hi(),N=pt(z);{var U=K=>{var W=ew(),O=S(W);{var A=ue=>{var pe=$y();T(ue,pe)};ee(O,ue=>{s()&&ue(A)})}var E=x(O,2),B=S(E);Me(B,"aria-selected",!0);var R=x(E,2),P=S(R);let H;var Z=S(P),de=S(Z);{let ue=ce(()=>l(f)()),pe=ce(()=>{var xe;return((xe=l(u))==null?void 0:xe.isStreaming)??!1});Ny(de,{get events(){return l(ue)},get isStreaming(){return l(pe)},onRetry:y})}var be=x(Z,2);{var he=ue=>{Qy(ue,{get permission(){return l(u).activePermission},onApprove:m,onDeny:g})};ee(be,ue=>{var pe;(pe=l(u))!=null&&pe.activePermission&&l(u).activePermission.status==="pending"&&ue(he)})}var ge=x(be,2);{let ue=ce(()=>{var pe;return((pe=l(u))==null?void 0:pe.quickReplies)??[]});qy(ge,{get suggestions(){return l(ue)},onSelect:v})}var ye=x(ge,2);{let ue=ce(()=>{var pe;return((pe=l(u))==null?void 0:pe.tokenUsage)??{input:0,output:0,estimatedCost:0}});Zy(ye,{get usage(){return l(ue)}})}var ke=x(ye,2);{let ue=ce(()=>{var pe;return((pe=l(u))==null?void 0:pe.isStreaming)??!1});zy(ke,{get disabled(){return l(ue)},onSend:_})}re(()=>H=Or(P,"",H,{display:l(n)==="chat"?"flex":"none"})),T(K,W)},Y=K=>{{let W=ce(()=>t.onImageUpload??void 0),O=ce(()=>t.onCopyModeChange??void 0);Je(e_(K,{get sessionId(){return t.sessionId},get onImageUpload(){return l(W)},get useTmux(){return r()},get onCopyModeChange(){return l(O)}}),A=>b(o,A,!0),()=>l(o))}};ee(N,K=>{i()==="sdk"?K(U):K(Y,!1)})}return T(e,z),Ge(F)}var Co=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(){}},iw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ms,_h,Mu,sw=(Mu=class{constructor(){$(this,Ms,iw);$(this,_h,!1)}setTimeoutProvider(e){G(this,Ms,e)}setTimeout(e,t){return p(this,Ms).setTimeout(e,t)}clearTimeout(e){p(this,Ms).clearTimeout(e)}setInterval(e,t){return p(this,Ms).setInterval(e,t)}clearInterval(e){p(this,Ms).clearInterval(e)}},Ms=new WeakMap,_h=new WeakMap,Mu),hr=new sw;function rw(e){setTimeout(e,0)}var wn=typeof window>"u"||"Deno"in globalThis;function gi(){}function nw(e,t){return typeof e=="function"?e(t):e}function Zl(e){return typeof e=="number"&&e>=0&&e!==1/0}function r_(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Gs(e,t){return typeof e=="function"?e(t):e}function Si(e,t){return typeof e=="function"?e(t):e}function _u(e,t){const{type:i="all",exact:s,fetchStatus:r,predicate:n,queryKey:o,stale:a}=e;if(o){if(s){if(t.queryHash!==zh(o,t.options))return!1}else if(!ro(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||r&&r!==t.state.fetchStatus||n&&!n(t))}function vu(e,t){const{exact:i,status:s,predicate:r,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(i){if(so(t.options.mutationKey)!==so(n))return!1}else if(!ro(t.options.mutationKey,n))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function zh(e,t){return((t==null?void 0:t.queryKeyHashFn)||so)(e)}function so(e){return JSON.stringify(e,(t,i)=>eh(i)?Object.keys(i).sort().reduce((s,r)=>(s[r]=i[r],s),{}):i)}function ro(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>ro(e[i],t[i])):!1}var ow=Object.prototype.hasOwnProperty;function n_(e,t,i=0){if(e===t)return e;if(i>500)return t;const s=pu(e)&&pu(t);if(!s&&!(eh(e)&&eh(t)))return t;const n=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),a=o.length,c=s?new Array(a):{};let h=0;for(let d=0;d<a;d++){const u=s?d:o[d],f=e[u],_=t[u];if(f===_){c[u]=f,(s?d<n:ow.call(e,u))&&h++;continue}if(f===null||_===null||typeof f!="object"||typeof _!="object"){c[u]=_;continue}const v=n_(f,_,i+1);c[u]=v,v===f&&h++}return n===a&&h===n?e:c}function $l(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 pu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function eh(e){if(!gu(e))return!1;const t=e.constructor;if(t===void 0)return!0;const i=t.prototype;return!(!gu(i)||!i.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function gu(e){return Object.prototype.toString.call(e)==="[object Object]"}function aw(e){return new Promise(t=>{hr.setTimeout(t,e)})}function th(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?n_(e,t):t}function lw(e,t,i=0){const s=[...e,t];return i&&s.length>i?s.slice(1):s}function hw(e,t,i=0){const s=[t,...e];return i&&s.length>i?s.slice(0,-1):s}var Uh=Symbol();function o_(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Uh?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function cw(e,t,i){let s=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??(r=t()),s||(s=!0,r.aborted?i():r.addEventListener("abort",i,{once:!0})),r)}),e}var vr,Bs,tn,Bu,uw=(Bu=class extends Co{constructor(){super();$(this,vr);$(this,Bs);$(this,tn);G(this,tn,t=>{if(!wn&&window.addEventListener){const i=()=>t();return window.addEventListener("visibilitychange",i,!1),()=>{window.removeEventListener("visibilitychange",i)}}})}onSubscribe(){p(this,Bs)||this.setEventListener(p(this,tn))}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,Bs))==null||t.call(this),G(this,Bs,void 0))}setEventListener(t){var i;G(this,tn,t),(i=p(this,Bs))==null||i.call(this),G(this,Bs,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){p(this,vr)!==t&&(G(this,vr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(i=>{i(t)})}isFocused(){var t;return typeof p(this,vr)=="boolean"?p(this,vr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},vr=new WeakMap,Bs=new WeakMap,tn=new WeakMap,Bu),Kh=new uw;function ih(){let e,t;const i=new Promise((r,n)=>{e=r,t=n});i.status="pending",i.catch(()=>{});function s(r){Object.assign(i,r),delete i.resolve,delete i.reject}return i.resolve=r=>{s({status:"fulfilled",value:r}),e(r)},i.reject=r=>{s({status:"rejected",reason:r}),t(r)},i}var dw=rw;function fw(){let e=[],t=0,i=a=>{a()},s=a=>{a()},r=dw;const n=a=>{t?e.push(a):r(()=>{i(a)})},o=()=>{const a=e;e=[],a.length&&r(()=>{s(()=>{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=>{s=a},setScheduler:a=>{r=a}}}var Nt=fw(),sn,Ls,rn,Lu,_w=(Lu=class extends Co{constructor(){super();$(this,sn,!0);$(this,Ls);$(this,rn);G(this,rn,t=>{if(!wn&&window.addEventListener){const i=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",i,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",s)}}})}onSubscribe(){p(this,Ls)||this.setEventListener(p(this,rn))}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,Ls))==null||t.call(this),G(this,Ls,void 0))}setEventListener(t){var i;G(this,rn,t),(i=p(this,Ls))==null||i.call(this),G(this,Ls,t(this.setOnline.bind(this)))}setOnline(t){p(this,sn)!==t&&(G(this,sn,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return p(this,sn)}},sn=new WeakMap,Ls=new WeakMap,rn=new WeakMap,Lu),oa=new _w;function vw(e){return Math.min(1e3*2**e,3e4)}function a_(e){return(e??"online")==="online"?oa.isOnline():!0}var sh=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function l_(e){let t=!1,i=0,s;const r=ih(),n=()=>r.status!=="pending",o=m=>{var g;if(!n()){const y=new sh(m);f(y),(g=e.onCancel)==null||g.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},h=()=>Kh.isFocused()&&(e.networkMode==="always"||oa.isOnline())&&e.canRun(),d=()=>a_(e.networkMode)&&e.canRun(),u=m=>{n()||(s==null||s(),r.resolve(m))},f=m=>{n()||(s==null||s(),r.reject(m))},_=()=>new Promise(m=>{var g;s=y=>{(n()||h())&&m(y)},(g=e.onPause)==null||g.call(e)}).then(()=>{var m;s=void 0,n()||(m=e.onContinue)==null||m.call(e)}),v=()=>{if(n())return;let m;const g=i===0?e.initialPromise:void 0;try{m=g??e.fn()}catch(y){m=Promise.reject(y)}Promise.resolve(m).then(u).catch(y=>{var F;if(n())return;const C=e.retry??(wn?0:3),k=e.retryDelay??vw,w=typeof k=="function"?k(i,y):k,D=C===!0||typeof C=="number"&&i<C||typeof C=="function"&&C(i,y);if(t||!D){f(y);return}i++,(F=e.onFail)==null||F.call(e,i,y),aw(w).then(()=>h()?void 0:_()).then(()=>{t?f(y):v()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(s==null||s(),r),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?v():_().then(v),r)}}var pr,Au,h_=(Au=class{constructor(){$(this,pr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Zl(this.gcTime)&&G(this,pr,hr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(wn?1/0:300*1e3))}clearGcTimeout(){p(this,pr)&&(hr.clearTimeout(p(this,pr)),G(this,pr,void 0))}},pr=new WeakMap,Au),gr,nn,vi,mr,St,ho,br,Ai,as,Ou,pw=(Ou=class extends h_{constructor(t){super();$(this,Ai);$(this,gr);$(this,nn);$(this,vi);$(this,mr);$(this,St);$(this,ho);$(this,br);G(this,br,!1),G(this,ho,t.defaultOptions),this.setOptions(t.options),this.observers=[],G(this,mr,t.client),G(this,vi,p(this,mr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,G(this,gr,bu(this.options)),this.state=t.state??p(this,gr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=p(this,St))==null?void 0:t.promise}setOptions(t){if(this.options={...p(this,ho),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const i=bu(this.options);i.data!==void 0&&(this.setState(mu(i.data,i.dataUpdatedAt)),G(this,gr,i))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&p(this,vi).remove(this)}setData(t,i){const s=th(this.state.data,t,this.options);return _e(this,Ai,as).call(this,{data:s,type:"success",dataUpdatedAt:i==null?void 0:i.updatedAt,manual:i==null?void 0:i.manual}),s}setState(t,i){_e(this,Ai,as).call(this,{type:"setState",state:t,setStateOptions:i})}cancel(t){var s,r;const i=(s=p(this,St))==null?void 0:s.promise;return(r=p(this,St))==null||r.cancel(t),i?i.then(gi).catch(gi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(p(this,gr))}isActive(){return this.observers.some(t=>Si(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Uh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Gs(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:!r_(this.state.dataUpdatedAt,t)}onFocus(){var i;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(i=p(this,St))==null||i.continue()}onOnline(){var i;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(i=p(this,St))==null||i.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),p(this,vi).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(i=>i!==t),this.observers.length||(p(this,St)&&(p(this,br)?p(this,St).cancel({revert:!0}):p(this,St).cancelRetry()),this.scheduleGc()),p(this,vi).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||_e(this,Ai,as).call(this,{type:"invalidate"})}async fetch(t,i){var c,h,d,u,f,_,v,m,g,y,C,k;if(this.state.fetchStatus!=="idle"&&((c=p(this,St))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(i!=null&&i.cancelRefetch))this.cancel({silent:!0});else if(p(this,St))return p(this,St).continueRetry(),p(this,St).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(D=>D.options.queryFn);w&&this.setOptions(w.options)}const s=new AbortController,r=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(G(this,br,!0),s.signal)})},n=()=>{const w=o_(this.options,i),F=(()=>{const z={client:p(this,mr),queryKey:this.queryKey,meta:this.meta};return r(z),z})();return G(this,br,!1),this.options.persister?this.options.persister(w,F,this):w(F)},a=(()=>{const w={fetchOptions:i,options:this.options,queryKey:this.queryKey,client:p(this,mr),state:this.state,fetchFn:n};return r(w),w})();(h=this.options.behavior)==null||h.onFetch(a,this),G(this,nn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&_e(this,Ai,as).call(this,{type:"fetch",meta:(u=a.fetchOptions)==null?void 0:u.meta}),G(this,St,l_({initialPromise:i==null?void 0:i.initialPromise,fn:a.fetchFn,onCancel:w=>{w instanceof sh&&w.revert&&this.setState({...p(this,nn),fetchStatus:"idle"}),s.abort()},onFail:(w,D)=>{_e(this,Ai,as).call(this,{type:"failed",failureCount:w,error:D})},onPause:()=>{_e(this,Ai,as).call(this,{type:"pause"})},onContinue:()=>{_e(this,Ai,as).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const w=await p(this,St).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(_=(f=p(this,vi).config).onSuccess)==null||_.call(f,w,this),(m=(v=p(this,vi).config).onSettled)==null||m.call(v,w,this.state.error,this),w}catch(w){if(w instanceof sh){if(w.silent)return p(this,St).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw _e(this,Ai,as).call(this,{type:"error",error:w}),(y=(g=p(this,vi).config).onError)==null||y.call(g,w,this),(k=(C=p(this,vi).config).onSettled)==null||k.call(C,this.state.data,w,this),w}finally{this.scheduleGc()}}},gr=new WeakMap,nn=new WeakMap,vi=new WeakMap,mr=new WeakMap,St=new WeakMap,ho=new WeakMap,br=new WeakMap,Ai=new WeakSet,as=function(t){const i=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...c_(s.data,this.options),fetchMeta:t.meta??null};case"success":const r={...s,...mu(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return G(this,nn,t.manual?r:void 0),r;case"error":const n=t.error;return{...s,error:n,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=i(this.state),Nt.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),p(this,vi).notify({query:this,type:"updated",action:t})})},Ou);function c_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:a_(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function mu(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function bu(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,i=t!==void 0,s=i?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:i?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:i?"success":"pending",fetchStatus:"idle"}}var Xt,Fe,co,zt,Sr,on,us,As,uo,an,ln,yr,wr,Os,hn,Ve,Un,rh,nh,oh,ah,lh,hh,ch,u_,Iu,gw=(Iu=class extends Co{constructor(t,i){super();$(this,Ve);$(this,Xt);$(this,Fe);$(this,co);$(this,zt);$(this,Sr);$(this,on);$(this,us);$(this,As);$(this,uo);$(this,an);$(this,ln);$(this,yr);$(this,wr);$(this,Os);$(this,hn,new Set);this.options=i,G(this,Xt,t),G(this,As,null),G(this,us,ih()),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(p(this,Fe).addObserver(this),Su(p(this,Fe),this.options)?_e(this,Ve,Un).call(this):this.updateResult(),_e(this,Ve,ah).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return uh(p(this,Fe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return uh(p(this,Fe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,_e(this,Ve,lh).call(this),_e(this,Ve,hh).call(this),p(this,Fe).removeObserver(this)}setOptions(t){const i=this.options,s=p(this,Fe);if(this.options=p(this,Xt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Si(this.options.enabled,p(this,Fe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");_e(this,Ve,ch).call(this),p(this,Fe).setOptions(this.options),i._defaulted&&!$l(this.options,i)&&p(this,Xt).getQueryCache().notify({type:"observerOptionsUpdated",query:p(this,Fe),observer:this});const r=this.hasListeners();r&&yu(p(this,Fe),s,this.options,i)&&_e(this,Ve,Un).call(this),this.updateResult(),r&&(p(this,Fe)!==s||Si(this.options.enabled,p(this,Fe))!==Si(i.enabled,p(this,Fe))||Gs(this.options.staleTime,p(this,Fe))!==Gs(i.staleTime,p(this,Fe)))&&_e(this,Ve,rh).call(this);const n=_e(this,Ve,nh).call(this);r&&(p(this,Fe)!==s||Si(this.options.enabled,p(this,Fe))!==Si(i.enabled,p(this,Fe))||n!==p(this,Os))&&_e(this,Ve,oh).call(this,n)}getOptimisticResult(t){const i=p(this,Xt).getQueryCache().build(p(this,Xt),t),s=this.createResult(i,t);return bw(this,s)&&(G(this,zt,s),G(this,on,this.options),G(this,Sr,p(this,Fe).state)),s}getCurrentResult(){return p(this,zt)}trackResult(t,i){return new Proxy(t,{get:(s,r)=>(this.trackProp(r),i==null||i(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&p(this,us).status==="pending"&&p(this,us).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(t){p(this,hn).add(t)}getCurrentQuery(){return p(this,Fe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=p(this,Xt).defaultQueryOptions(t),s=p(this,Xt).getQueryCache().build(p(this,Xt),i);return s.fetch().then(()=>this.createResult(s,i))}fetch(t){return _e(this,Ve,Un).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),p(this,zt)))}createResult(t,i){var U;const s=p(this,Fe),r=this.options,n=p(this,zt),o=p(this,Sr),a=p(this,on),h=t!==s?t.state:p(this,co),{state:d}=t;let u={...d},f=!1,_;if(i._optimisticResults){const Y=this.hasListeners(),K=!Y&&Su(t,i),W=Y&&yu(t,s,i,r);(K||W)&&(u={...u,...c_(d.data,t.options)}),i._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:v,errorUpdatedAt:m,status:g}=u;_=u.data;let y=!1;if(i.placeholderData!==void 0&&_===void 0&&g==="pending"){let Y;n!=null&&n.isPlaceholderData&&i.placeholderData===(a==null?void 0:a.placeholderData)?(Y=n.data,y=!0):Y=typeof i.placeholderData=="function"?i.placeholderData((U=p(this,ln))==null?void 0:U.state.data,p(this,ln)):i.placeholderData,Y!==void 0&&(g="success",_=th(n==null?void 0:n.data,Y,i),f=!0)}if(i.select&&_!==void 0&&!y)if(n&&_===(o==null?void 0:o.data)&&i.select===p(this,uo))_=p(this,an);else try{G(this,uo,i.select),_=i.select(_),_=th(n==null?void 0:n.data,_,i),G(this,an,_),G(this,As,null)}catch(Y){G(this,As,Y)}p(this,As)&&(v=p(this,As),_=p(this,an),m=Date.now(),g="error");const C=u.fetchStatus==="fetching",k=g==="pending",w=g==="error",D=k&&C,F=_!==void 0,N={status:g,fetchStatus:u.fetchStatus,isPending:k,isSuccess:g==="success",isError:w,isInitialLoading:D,isLoading:D,data:_,dataUpdatedAt:u.dataUpdatedAt,error:v,errorUpdatedAt:m,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:C,isRefetching:C&&!k,isLoadingError:w&&!F,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&F,isStale:qh(t,i),refetch:this.refetch,promise:p(this,us),isEnabled:Si(i.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const Y=N.data!==void 0,K=N.status==="error"&&!Y,W=E=>{K?E.reject(N.error):Y&&E.resolve(N.data)},O=()=>{const E=G(this,us,N.promise=ih());W(E)},A=p(this,us);switch(A.status){case"pending":t.queryHash===s.queryHash&&W(A);break;case"fulfilled":(K||N.data!==A.value)&&O();break;case"rejected":(!K||N.error!==A.reason)&&O();break}}return N}updateResult(){const t=p(this,zt),i=this.createResult(p(this,Fe),this.options);if(G(this,Sr,p(this,Fe).state),G(this,on,this.options),p(this,Sr).data!==void 0&&G(this,ln,p(this,Fe)),$l(i,t))return;G(this,zt,i);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,n=typeof r=="function"?r():r;if(n==="all"||!n&&!p(this,hn).size)return!0;const o=new Set(n??p(this,hn));return this.options.throwOnError&&o.add("error"),Object.keys(p(this,zt)).some(a=>{const c=a;return p(this,zt)[c]!==t[c]&&o.has(c)})};_e(this,Ve,u_).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&_e(this,Ve,ah).call(this)}},Xt=new WeakMap,Fe=new WeakMap,co=new WeakMap,zt=new WeakMap,Sr=new WeakMap,on=new WeakMap,us=new WeakMap,As=new WeakMap,uo=new WeakMap,an=new WeakMap,ln=new WeakMap,yr=new WeakMap,wr=new WeakMap,Os=new WeakMap,hn=new WeakMap,Ve=new WeakSet,Un=function(t){_e(this,Ve,ch).call(this);let i=p(this,Fe).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(gi)),i},rh=function(){_e(this,Ve,lh).call(this);const t=Gs(this.options.staleTime,p(this,Fe));if(wn||p(this,zt).isStale||!Zl(t))return;const s=r_(p(this,zt).dataUpdatedAt,t)+1;G(this,yr,hr.setTimeout(()=>{p(this,zt).isStale||this.updateResult()},s))},nh=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(p(this,Fe)):this.options.refetchInterval)??!1},oh=function(t){_e(this,Ve,hh).call(this),G(this,Os,t),!(wn||Si(this.options.enabled,p(this,Fe))===!1||!Zl(p(this,Os))||p(this,Os)===0)&&G(this,wr,hr.setInterval(()=>{(this.options.refetchIntervalInBackground||Kh.isFocused())&&_e(this,Ve,Un).call(this)},p(this,Os)))},ah=function(){_e(this,Ve,rh).call(this),_e(this,Ve,oh).call(this,_e(this,Ve,nh).call(this))},lh=function(){p(this,yr)&&(hr.clearTimeout(p(this,yr)),G(this,yr,void 0))},hh=function(){p(this,wr)&&(hr.clearInterval(p(this,wr)),G(this,wr,void 0))},ch=function(){const t=p(this,Xt).getQueryCache().build(p(this,Xt),this.options);if(t===p(this,Fe))return;const i=p(this,Fe);G(this,Fe,t),G(this,co,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},u_=function(t){Nt.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(p(this,zt))}),p(this,Xt).getQueryCache().notify({query:p(this,Fe),type:"observerResultsUpdated"})})},Iu);function mw(e,t){return Si(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Su(e,t){return mw(e,t)||e.state.data!==void 0&&uh(e,t,t.refetchOnMount)}function uh(e,t,i){if(Si(t.enabled,e)!==!1&&Gs(t.staleTime,e)!=="static"){const s=typeof i=="function"?i(e):i;return s==="always"||s!==!1&&qh(e,t)}return!1}function yu(e,t,i,s){return(e!==t||Si(s.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&qh(e,i)}function qh(e,t){return Si(t.enabled,e)!==!1&&e.isStaleByTime(Gs(t.staleTime,e))}function bw(e,t){return!$l(e.getCurrentResult(),t)}function wu(e){return{onFetch:(t,i)=>{var d,u,f,_,v;const s=t.options,r=(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=((v=t.state.data)==null?void 0:v.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const h=async()=>{let m=!1;const g=k=>{cw(k,()=>t.signal,()=>m=!0)},y=o_(t.options,t.fetchOptions),C=async(k,w,D)=>{if(m)return Promise.reject();if(w==null&&k.pages.length)return Promise.resolve(k);const z=(()=>{const K={client:t.client,queryKey:t.queryKey,pageParam:w,direction:D?"backward":"forward",meta:t.options.meta};return g(K),K})(),N=await y(z),{maxPages:U}=t.options,Y=D?hw:lw;return{pages:Y(k.pages,N,U),pageParams:Y(k.pageParams,w,U)}};if(r&&n.length){const k=r==="backward",w=k?Sw:Cu,D={pages:n,pageParams:o},F=w(s,D);a=await C(D,F,k)}else{const k=e??n.length;do{const w=c===0?o[0]??s.initialPageParam:Cu(s,a);if(c>0&&w==null)break;a=await C(a,w),c++}while(c<k)}return a};t.options.persister?t.fetchFn=()=>{var m,g;return(g=(m=t.options).persister)==null?void 0:g.call(m,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i)}:t.fetchFn=h}}}function Cu(e,{pages:t,pageParams:i}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,i[s],i):void 0}function Sw(e,{pages:t,pageParams:i}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,i[0],i):void 0}var fo,Qi,It,Cr,Ji,Rs,Nu,yw=(Nu=class extends h_{constructor(t){super();$(this,Ji);$(this,fo);$(this,Qi);$(this,It);$(this,Cr);G(this,fo,t.client),this.mutationId=t.mutationId,G(this,It,t.mutationCache),G(this,Qi,[]),this.state=t.state||ww(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){p(this,Qi).includes(t)||(p(this,Qi).push(t),this.clearGcTimeout(),p(this,It).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){G(this,Qi,p(this,Qi).filter(i=>i!==t)),this.scheduleGc(),p(this,It).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){p(this,Qi).length||(this.state.status==="pending"?this.scheduleGc():p(this,It).remove(this))}continue(){var t;return((t=p(this,Cr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,c,h,d,u,f,_,v,m,g,y,C,k,w,D,F,z;const i=()=>{_e(this,Ji,Rs).call(this,{type:"continue"})},s={client:p(this,fo),meta:this.options.meta,mutationKey:this.options.mutationKey};G(this,Cr,l_({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(N,U)=>{_e(this,Ji,Rs).call(this,{type:"failed",failureCount:N,error:U})},onPause:()=>{_e(this,Ji,Rs).call(this,{type:"pause"})},onContinue:i,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>p(this,It).canRun(this)}));const r=this.state.status==="pending",n=!p(this,Cr).canStart();try{if(r)i();else{_e(this,Ji,Rs).call(this,{type:"pending",variables:t,isPaused:n}),p(this,It).config.onMutate&&await p(this,It).config.onMutate(t,this,s);const U=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,s));U!==this.state.context&&_e(this,Ji,Rs).call(this,{type:"pending",context:U,variables:t,isPaused:n})}const N=await p(this,Cr).start();return await((h=(c=p(this,It).config).onSuccess)==null?void 0:h.call(c,N,t,this.state.context,this,s)),await((u=(d=this.options).onSuccess)==null?void 0:u.call(d,N,t,this.state.context,s)),await((_=(f=p(this,It).config).onSettled)==null?void 0:_.call(f,N,null,this.state.variables,this.state.context,this,s)),await((m=(v=this.options).onSettled)==null?void 0:m.call(v,N,null,t,this.state.context,s)),_e(this,Ji,Rs).call(this,{type:"success",data:N}),N}catch(N){try{await((y=(g=p(this,It).config).onError)==null?void 0:y.call(g,N,t,this.state.context,this,s))}catch(U){Promise.reject(U)}try{await((k=(C=this.options).onError)==null?void 0:k.call(C,N,t,this.state.context,s))}catch(U){Promise.reject(U)}try{await((D=(w=p(this,It).config).onSettled)==null?void 0:D.call(w,void 0,N,this.state.variables,this.state.context,this,s))}catch(U){Promise.reject(U)}try{await((z=(F=this.options).onSettled)==null?void 0:z.call(F,void 0,N,t,this.state.context,s))}catch(U){Promise.reject(U)}throw _e(this,Ji,Rs).call(this,{type:"error",error:N}),N}finally{p(this,It).runNext(this)}}},fo=new WeakMap,Qi=new WeakMap,It=new WeakMap,Cr=new WeakMap,Ji=new WeakSet,Rs=function(t){const i=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=i(this.state),Nt.batch(()=>{p(this,Qi).forEach(s=>{s.onMutationUpdate(t)}),p(this,It).notify({mutation:this,type:"updated",action:t})})},Nu);function ww(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ds,Oi,_o,Fu,Cw=(Fu=class extends Co{constructor(t={}){super();$(this,ds);$(this,Oi);$(this,_o);this.config=t,G(this,ds,new Set),G(this,Oi,new Map),G(this,_o,0)}build(t,i,s){const r=new yw({client:t,mutationCache:this,mutationId:++xo(this,_o)._,options:t.defaultMutationOptions(i),state:s});return this.add(r),r}add(t){p(this,ds).add(t);const i=No(t);if(typeof i=="string"){const s=p(this,Oi).get(i);s?s.push(t):p(this,Oi).set(i,[t])}this.notify({type:"added",mutation:t})}remove(t){if(p(this,ds).delete(t)){const i=No(t);if(typeof i=="string"){const s=p(this,Oi).get(i);if(s)if(s.length>1){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}else s[0]===t&&p(this,Oi).delete(i)}}this.notify({type:"removed",mutation:t})}canRun(t){const i=No(t);if(typeof i=="string"){const s=p(this,Oi).get(i),r=s==null?void 0:s.find(n=>n.state.status==="pending");return!r||r===t}else return!0}runNext(t){var s;const i=No(t);if(typeof i=="string"){const r=(s=p(this,Oi).get(i))==null?void 0:s.find(n=>n!==t&&n.state.isPaused);return(r==null?void 0:r.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Nt.batch(()=>{p(this,ds).forEach(t=>{this.notify({type:"removed",mutation:t})}),p(this,ds).clear(),p(this,Oi).clear()})}getAll(){return Array.from(p(this,ds))}find(t){const i={exact:!0,...t};return this.getAll().find(s=>vu(i,s))}findAll(t={}){return this.getAll().filter(i=>vu(t,i))}notify(t){Nt.batch(()=>{this.listeners.forEach(i=>{i(t)})})}resumePausedMutations(){const t=this.getAll().filter(i=>i.state.isPaused);return Nt.batch(()=>Promise.all(t.map(i=>i.continue().catch(gi))))}},ds=new WeakMap,Oi=new WeakMap,_o=new WeakMap,Fu);function No(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Zi,Wu,kw=(Wu=class extends Co{constructor(t={}){super();$(this,Zi);this.config=t,G(this,Zi,new Map)}build(t,i,s){const r=i.queryKey,n=i.queryHash??zh(r,i);let o=this.get(n);return o||(o=new pw({client:t,queryKey:r,queryHash:n,options:t.defaultQueryOptions(i),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){p(this,Zi).has(t.queryHash)||(p(this,Zi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const i=p(this,Zi).get(t.queryHash);i&&(t.destroy(),i===t&&p(this,Zi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Nt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return p(this,Zi).get(t)}getAll(){return[...p(this,Zi).values()]}find(t){const i={exact:!0,...t};return this.getAll().find(s=>_u(i,s))}findAll(t={}){const i=this.getAll();return Object.keys(t).length>0?i.filter(s=>_u(t,s)):i}notify(t){Nt.batch(()=>{this.listeners.forEach(i=>{i(t)})})}onFocus(){Nt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Nt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Zi=new WeakMap,Wu),nt,Is,Ns,cn,un,Fs,dn,fn,Hu,d_=(Hu=class{constructor(e={}){$(this,nt);$(this,Is);$(this,Ns);$(this,cn);$(this,un);$(this,Fs);$(this,dn);$(this,fn);G(this,nt,e.queryCache||new kw),G(this,Is,e.mutationCache||new Cw),G(this,Ns,e.defaultOptions||{}),G(this,cn,new Map),G(this,un,new Map),G(this,Fs,0)}mount(){xo(this,Fs)._++,p(this,Fs)===1&&(G(this,dn,Kh.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,nt).onFocus())})),G(this,fn,oa.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,nt).onOnline())})))}unmount(){var e,t;xo(this,Fs)._--,p(this,Fs)===0&&((e=p(this,dn))==null||e.call(this),G(this,dn,void 0),(t=p(this,fn))==null||t.call(this),G(this,fn,void 0))}isFetching(e){return p(this,nt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return p(this,Is).findAll({...e,status:"pending"}).length}getQueryData(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=p(this,nt).get(t.queryHash))==null?void 0:i.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),i=p(this,nt).build(this,t),s=i.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime(Gs(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return p(this,nt).findAll(e).map(({queryKey:t,state:i})=>{const s=i.data;return[t,s]})}setQueryData(e,t,i){const s=this.defaultQueryOptions({queryKey:e}),r=p(this,nt).get(s.queryHash),n=r==null?void 0:r.state.data,o=nw(t,n);if(o!==void 0)return p(this,nt).build(this,s).setData(o,{...i,manual:!0})}setQueriesData(e,t,i){return Nt.batch(()=>p(this,nt).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,i)]))}getQueryState(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=p(this,nt).get(t.queryHash))==null?void 0:i.state}removeQueries(e){const t=p(this,nt);Nt.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=p(this,nt);return Nt.batch(()=>(i.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},s=Nt.batch(()=>p(this,nt).findAll(e).map(r=>r.cancel(i)));return Promise.all(s).then(gi).catch(gi)}invalidateQueries(e,t={}){return Nt.batch(()=>(p(this,nt).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},s=Nt.batch(()=>p(this,nt).findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let n=r.fetch(void 0,i);return i.throwOnError||(n=n.catch(gi)),r.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(gi)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const i=p(this,nt).build(this,t);return i.isStaleByTime(Gs(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(gi).catch(gi)}fetchInfiniteQuery(e){return e.behavior=wu(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(gi).catch(gi)}ensureInfiniteQueryData(e){return e.behavior=wu(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return oa.isOnline()?p(this,Is).resumePausedMutations():Promise.resolve()}getQueryCache(){return p(this,nt)}getMutationCache(){return p(this,Is)}getDefaultOptions(){return p(this,Ns)}setDefaultOptions(e){G(this,Ns,e)}setQueryDefaults(e,t){p(this,cn).set(so(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...p(this,cn).values()],i={};return t.forEach(s=>{ro(e,s.queryKey)&&Object.assign(i,s.defaultOptions)}),i}setMutationDefaults(e,t){p(this,un).set(so(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...p(this,un).values()],i={};return t.forEach(s=>{ro(e,s.mutationKey)&&Object.assign(i,s.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={...p(this,Ns).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=zh(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===Uh&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...p(this,Ns).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){p(this,nt).clear(),p(this,Is).clear()}},nt=new WeakMap,Is=new WeakMap,Ns=new WeakMap,cn=new WeakMap,un=new WeakMap,Fs=new WeakMap,dn=new WeakMap,fn=new WeakMap,Hu);const f_=Symbol("QueryClient"),xw=()=>{const e=Qu(f_);if(!e)throw new Error("No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?");return e},Ew=e=>{fv(f_,e)},Dw=Symbol("isRestoring"),Rw=()=>{try{return Qu(Dw)??{current:!1}}catch{return{current:!1}}};function Pw(){return Rw()}function Tw(e){return xw()}var Mw=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],Bw=["difference","intersection","symmetricDifference","union"],ku=!1,_n,Ii,Ws,ca,Cn,__,v_;const ua=class ua extends Set{constructor(i){super();$(this,Cn);$(this,_n,new Map);$(this,Ii,I(0));$(this,Ws,I(0));$(this,ca,ms||-1);if(i){for(var s of i)super.add(s);p(this,Ws).v=super.size}ku||_e(this,Cn,v_).call(this)}has(i){var s=super.has(i),r=p(this,_n),n=r.get(i);if(n===void 0){if(!s)return l(p(this,Ii)),!1;n=_e(this,Cn,__).call(this,!0),r.set(i,n)}return l(n),s}add(i){return super.has(i)||(super.add(i),b(p(this,Ws),super.size),js(p(this,Ii))),this}delete(i){var s=super.delete(i),r=p(this,_n),n=r.get(i);return n!==void 0&&(r.delete(i),b(n,!1)),s&&(b(p(this,Ws),super.size),js(p(this,Ii))),s}clear(){if(super.size!==0){super.clear();var i=p(this,_n);for(var s of i.values())b(s,!1);i.clear(),b(p(this,Ws),0),js(p(this,Ii))}}keys(){return this.values()}values(){return l(p(this,Ii)),super.values()}entries(){return l(p(this,Ii)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return l(p(this,Ws))}};_n=new WeakMap,Ii=new WeakMap,Ws=new WeakMap,ca=new WeakMap,Cn=new WeakSet,__=function(i){return ms===p(this,ca)?I(i):Xs(i)},v_=function(){ku=!0;var i=ua.prototype,s=Set.prototype;for(const r of Mw)i[r]=function(...n){return l(p(this,Ii)),s[r].apply(this,n)};for(const r of Bw)i[r]=function(...n){l(p(this,Ii));var o=s[r].apply(this,n);return new ua(o)}};let dh=ua;function Lw(e){const t=Array.isArray(e)?[]:{},i=new dh,s=new Proxy(t,{set(n,o,a,c){if(i.delete(o),o in n)return Reflect.set(n,o,a,c);let h=I(a);return Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:()=>l(h)&&Ow(l(h))?l(h)():l(h),set:d=>{b(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 r(n){const o=Object.keys(s),a=Object.keys(n),c=o.filter(h=>!a.includes(h));for(const h of c)delete s[h];for(const h of a)s[h]=Aw(()=>n[h])}return r(e),[s,r]}const p_=Symbol("LazyValue");function Aw(e){return e[p_]=!0,e}function Ow(e){return!!e[p_]}function Iw(e,t){switch(e){case"post":Ui(t);break;case"pre":zv(t);break}}const Va=(e,t,i)=>{let s=!1,r=Array.isArray(e)?[]:void 0;Iw(t,()=>{const n=Array.isArray(e)?e.map(a=>a()):e();if(!s){s=!0,r=n;return}const o=Js(()=>i(n,r));return r=n,o})};function Nw(e,t,i){const s=ce(()=>Tw()),r=Pw(),n=ce(()=>{const d=l(s).defaultQueryOptions(e());return d._optimisticResults=r.current?"isRestoring":"optimistic",d});let o=I(Xe(new t(l(s),l(n))));Va(()=>l(s),"pre",()=>{b(o,new t(l(s),l(n)),!0)});function a(){const d=l(o).getOptimisticResult(l(n));return l(n).notifyOnChangeProps?d:l(o).trackResult(d)}const[c,h]=Lw(a());return Ui(()=>{const d=r.current?()=>{}:l(o).subscribe(()=>h(a()));return l(o).updateResult(),d}),Va(()=>l(n),"pre",()=>{l(o).setOptions(l(n))}),Va(()=>[l(n),l(o)],"pre",()=>{h(a())}),c}function aa(e,t){return Nw(e,gw)}function Fw(e,t){Ye(t,!0);const i=Kt(t,"client",19,()=>new d_);xn(()=>{i().mount()}),Ew(i()),mp(()=>{i().unmount()});var s=Hi(),r=pt(s);op(r,()=>t.children),T(e,s),Ge()}function g_(e){const{commitsAhead:t,prState:i,ciFailing:s,ciPending:r,ciTotal:n}=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"?s>0?{type:"fix-errors",color:"error",label:`Fix Errors ${s}/${n}`}:r>0?{type:"checks-running",color:"warning",label:"Checks Running..."}:{type:"code-review",color:"success",label:"Code Review"}:{type:"none",color:"none",label:""}}function Ww(e,t){switch(e.type){case"create-pr":return`Create a pull request for the branch "${t}". Write a clear title and description based on the changes.`;case"ready-for-review":return`Mark the draft PR for branch "${t}" as ready for review using: gh pr ready`;case"code-review":return`Review the code changes in the pull request for branch "${t}". Check for bugs, code quality, and suggest improvements.`;case"fix-errors":return`The CI checks are failing on branch "${t}". Investigate the failing checks and fix the errors.`;case"archive-merged":case"archive-closed":return null;case"checks-running":case"none":return null}}function m_(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 b_(e){return e==="success"||e==="warning"}var Hw=L('<div class="branch-error svelte-1ogsozk"> </div>'),zw=L('<div class="branch-loading svelte-1ogsozk">Loading...</div>'),Uw=L('<div class="branch-empty svelte-1ogsozk">No branches match</div>'),Kw=L('<span class="branch-check svelte-1ogsozk">✓</span>'),qw=L('<span class="branch-check branch-check--empty svelte-1ogsozk"></span>'),jw=L('<span class="branch-spinner svelte-1ogsozk">…</span>'),Vw=L('<li role="option"><!> <span class="branch-option-name svelte-1ogsozk"> </span> <!></li>'),Yw=L('<ul class="branch-list svelte-1ogsozk"></ul>'),Gw=L('<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>'),Xw=L('<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 Qw(e,t){Ye(t,!0);let i=I(!1),s=I(""),r=I(null),n=I(null),o=I(null),a=I(null);const c=aa(()=>({queryKey:["branches",t.workspacePath],queryFn:()=>Eh(t.workspacePath),staleTime:3e4,enabled:l(i)}));let h=ce(()=>{const D=c.data??[];if(!l(s).trim())return D;const F=l(s).toLowerCase();return D.filter(z=>z.toLowerCase().includes(F))});function d(){b(i,!0),b(s,""),b(a,null),requestAnimationFrame(()=>{var D;return(D=l(n))==null?void 0:D.focus()})}function u(){b(i,!1),b(s,"")}async function f(D){if(D===t.currentBranch){u();return}b(o,D,!0),b(a,null);try{const F=await Tp(t.workspacePath,D);F.success?(u(),t.onSwitch(D)):b(a,F.error??"Failed to switch branch",!0)}catch{b(a,"Failed to switch branch")}finally{b(o,null)}}function _(D){l(i)&&l(r)&&document.contains(D.target)&&!l(r).contains(D.target)&&u()}function v(D){D.key==="Escape"&&l(i)&&(u(),D.stopPropagation())}var m=Xw();$i("click",Xo,_);var g=S(m),y=x(S(g),2),C=S(y),k=x(g,2);{var w=D=>{var F=Gw(),z=S(F),N=S(z);Je(N,E=>b(n,E),()=>l(n));var U=x(z,2);{var Y=E=>{var B=Hw(),R=S(B);re(()=>se(R,l(a))),T(E,B)};ee(U,E=>{l(a)&&E(Y)})}var K=x(U,2);{var W=E=>{var B=zw();T(E,B)},O=E=>{var B=Uw();T(E,B)},A=E=>{var B=Yw();vt(B,20,()=>l(h),R=>R,(R,P)=>{var H=Vw();let Z;var de=S(H);{var be=pe=>{var xe=Kw();T(pe,xe)},he=pe=>{var xe=qw();T(pe,xe)};ee(de,pe=>{P===t.currentBranch?pe(be):pe(he,!1)})}var ge=x(de,2),ye=S(ge),ke=x(ge,2);{var ue=pe=>{var xe=jw();T(pe,xe)};ee(ke,pe=>{l(o)===P&&pe(ue)})}re(()=>{Z=et(H,1,"branch-option svelte-1ogsozk",null,Z,{"branch-current":P===t.currentBranch,"branch-switching":l(o)===P}),Me(H,"aria-selected",P===t.currentBranch),se(ye,P)}),X("mousedown",H,()=>f(P)),T(R,H)}),T(E,B)};ee(K,E=>{c.isLoading?E(W):l(h).length===0?E(O,1):E(A,!1)})}X("keydown",F,v),X("keydown",N,v),yi(N,()=>l(s),E=>b(s,E)),T(D,F)};ee(k,D=>{l(i)&&D(w)})}Je(m,D=>b(r,D),()=>l(r)),re(()=>{Me(g,"aria-expanded",l(i)),se(C,t.currentBranch)}),X("click",g,d),T(e,m),Ge()}Ze(["click","keydown","mousedown"]);var Jw=L('<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>'),Zw=L('<div class="bar-middle svelte-1shtc4l" aria-label="pull request"><a class="pr-link svelte-1shtc4l" target="_blank" rel="noopener noreferrer"> <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>'),$w=L('<span class="bar-loading svelte-1shtc4l">…</span>'),e0=L("<button> </button>"),t0=L('<div class="pr-top-bar svelte-1shtc4l"><div class="bar-left svelte-1shtc4l"><!> <!></div> <!> <div class="bar-right svelte-1shtc4l"><!></div></div>');function i0(e,t){Ye(t,!0);let i=I(Xe(t.branchName));Ui(()=>{b(i,t.branchName,!0)}),Ui(()=>{!t.branchName&&t.workspacePath&&Pp(t.workspacePath).then(N=>{N&&b(i,N,!0)})});const s=aa(()=>({queryKey:["pr",t.workspacePath,l(i)],queryFn:()=>Rp(t.workspacePath,l(i)),staleTime:6e4,refetchOnWindowFocus:!0})),r=aa(()=>{var N;return{queryKey:["ci-status",t.workspacePath,l(i)],queryFn:()=>Dp(t.workspacePath,l(i)),staleTime:3e4,refetchOnWindowFocus:!0,enabled:((N=s.data)==null?void 0:N.state)==="OPEN"}});let n=ce(()=>s.data??null),o=ce(()=>r.data??null),a=ce(()=>{var U,Y,K,W;const N=l(n)?l(n).isDraft?"DRAFT":l(n).state:null;return g_({commitsAhead:l(n)?1:0,prState:N,ciPassing:((U=l(o))==null?void 0:U.passing)??0,ciFailing:((Y=l(o))==null?void 0:Y.failing)??0,ciPending:((K=l(o))==null?void 0:K.pending)??0,ciTotal:((W=l(o))==null?void 0:W.total)??0})}),c=ce(()=>m_(l(a).color)),h=ce(()=>b_(l(a).color)),d=ce(()=>l(a).type!=="none");function u(){var U;const N=Ww(l(a),l(i));N!==null?t.sessionId&&Er(N+"\r"):(U=t.onArchive)==null||U.call(t)}function f(N){b(i,N,!0)}var _=t0(),v=S(_),m=S(v);Qw(m,{get workspacePath(){return t.workspacePath},get currentBranch(){return l(i)},onSwitch:f});var g=x(m,2);{var y=N=>{var U=Jw(),Y=x(S(U),2),K=S(Y);re(()=>se(K,l(n).baseRefName)),T(N,U)};ee(g,N=>{var U;(U=l(n))!=null&&U.baseRefName&&N(y)})}var C=x(v,2);{var k=N=>{var U=Zw(),Y=S(U),K=S(Y);re(()=>{Me(Y,"href",l(n).url),Me(Y,"aria-label",`PR #${l(n).number??""}: ${l(n).title??""}`),se(K,`PR #${l(n).number??""} `)}),T(N,U)};ee(C,N=>{l(n)&&N(k)})}var w=x(C,2),D=S(w);{var F=N=>{var U=$w();T(N,U)},z=N=>{var U=e0();let Y,K;var W=S(U);re(()=>{Y=et(U,1,"action-btn svelte-1shtc4l",null,Y,{"action-btn--dark-text":l(h),"action-btn--disabled":l(a).type==="checks-running"}),U.disabled=l(a).type==="checks-running",Me(U,"aria-label",l(a).label),K=Or(U,"",K,{"--action-color":l(c)}),se(W,l(a).label)}),X("click",U,u),T(N,U)};ee(D,N=>{s.isLoading?N(F):l(d)&&N(z,1)})}T(e,_),Ge()}Ze(["click"]);var s0=L('<button role="tab"><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">×</span></button>'),r0=L('<div class="new-menu svelte-3dfyyn" role="menu" tabindex="-1"><button class="new-menu-item svelte-3dfyyn" role="menuitem"><span class="new-menu-icon svelte-3dfyyn">🤖</span> New Claude Session</button> <button class="new-menu-item svelte-3dfyyn" role="menuitem"><span class="new-menu-icon svelte-3dfyyn">🖥</span> New Terminal</button></div>'),n0=L('<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">+</button> <!></div></div>');function o0(e,t){Ye(t,!0);let i=I(!1),s=I(null);function r(C){return C.type==="terminal"?"🖥":"🤖"}function n(C,k){C.stopPropagation(),t.onCloseSession(k)}function o(C,k){(C.key==="Enter"||C.key===" ")&&(C.stopPropagation(),t.onCloseSession(k))}function a(){b(i,!l(i))}function c(){b(i,!1),t.onNewSession()}function h(){b(i,!1),t.onNewTerminal()}function d(C){var k;l(i)&&l(s)&&document.contains(C.target)&&!((k=l(s).closest(".new-btn-wrap"))!=null&&k.contains(C.target))&&b(i,!1)}function u(C){var k;C.key==="Escape"&&l(i)&&(b(i,!1),(k=l(s))==null||k.focus())}var f=n0();$i("click",Xo,d);var _=S(f);vt(_,21,()=>t.sessions,C=>C.id,(C,k)=>{const w=ce(()=>l(k).id===t.activeSessionId);var D=s0();let F;var z=S(D),N=S(z),U=x(z,2),Y=S(U),K=x(U,2);re(W=>{F=et(D,1,"tab svelte-3dfyyn",null,F,{"tab--active":l(w)}),Me(D,"aria-selected",l(w)),Me(D,"aria-label",l(k).displayName||l(k).id),Me(D,"tabindex",l(w)?0:-1),se(N,W),se(Y,l(k).displayName||l(k).repoName||l(k).id),Me(K,"aria-label",`Close ${(l(k).displayName||l(k).id)??""}`)},[()=>r(l(k))]),X("click",D,()=>t.onSelectSession(l(k).id)),X("click",K,W=>n(W,l(k).id)),X("keydown",K,W=>o(W,l(k).id)),T(C,D)});var v=x(_,2),m=S(v);Je(m,C=>b(s,C),()=>l(s));var g=x(m,2);{var y=C=>{var k=r0(),w=S(k),D=x(w,2);X("keydown",k,u),X("click",w,c),X("click",D,h),T(C,k)};ee(g,C=>{l(i)&&C(y)})}re(()=>Me(m,"aria-expanded",l(i))),X("click",m,a),X("keydown",m,u),T(e,f),Ge()}Ze(["click","keydown"]);var a0=L('<div class="non-git-notice svelte-bvvs2r"><span class="non-git-msg svelte-bvvs2r">Not a git repository</span></div>'),l0=L('<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>'),h0=L('<div class="pr-list svelte-bvvs2r"></div>'),c0=L('<div class="section-message svelte-bvvs2r">Could not load pull requests</div>'),u0=L('<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>'),d0=L('<div class="section-message svelte-bvvs2r">No open pull requests</div>'),f0=L('<button class="pr-action-pill pr-conflict-pill svelte-bvvs2r" title="Open worktree and fix merge conflicts">Fix Conflicts</button>'),_0=L('<a class="pr-action-pill pr-merge-pill svelte-bvvs2r" target="_blank" rel="noopener noreferrer" title="Ready to merge on GitHub">Merge</a>'),v0=L('<a target="_blank" rel="noopener noreferrer"> </a>'),p0=L('<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"><!> <!> <!></div></div>'),g0=L('<div class="pr-list svelte-bvvs2r"></div>'),m0=L('<div class="activity-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-activity svelte-bvvs2r"></div></div>'),b0=L('<div class="activity-list svelte-bvvs2r"></div>'),S0=L('<div class="section-message svelte-bvvs2r">No recent commits (24h)</div>'),y0=L('<span class="commit-branch svelte-bvvs2r"> </span>'),w0=L('<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>'),C0=L('<div class="activity-list svelte-bvvs2r"></div>'),k0=L('<section class="dashboard-section svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">OPEN PULL REQUESTS</div> <!></section> <section class="dashboard-section svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">RECENT ACTIVITY</div> <!></section>',1),x0=L('<button class="cta-btn svelte-bvvs2r">+ New Worktree</button>'),E0=L('<div class="repo-dashboard svelte-bvvs2r"><!> <div class="cta-row svelte-bvvs2r"><button class="cta-btn svelte-bvvs2r">+ Start Session</button> <!></div></div>');function D0(e,t){Ye(t,!0);const i=aa(()=>({queryKey:["dashboard",t.workspacePath],queryFn:()=>Ep(t.workspacePath),staleTime:6e4,refetchOnWindowFocus:!0}));let s=ce(()=>i.data),r=ce(()=>i.isLoading),n=ce(()=>i.isError);function o(C){return C.state!=="OPEN"?"dot dot-muted":C.reviewDecision==="CHANGES_REQUESTED"?"dot dot-error":"dot dot-success"}function a(C){const k=C.state==="OPEN"?"OPEN":C.state==="MERGED"?"MERGED":"CLOSED";return g_({commitsAhead:1,prState:k,ciFailing:0,ciPending:0,ciTotal:0})}function c(C){return C.role==="author"?"by you":"review requested"}function h(C){return!C.branches||C.branches.length===0?"":"("+C.branches.join(", ")+")"}var d=E0(),u=S(d);{var f=C=>{var k=a0();T(C,k)},_=C=>{var k=k0(),w=pt(k),D=x(S(w),2);{var F=B=>{var R=h0();vt(R,20,()=>[1,2],Sn,(P,H)=>{var Z=l0();T(P,Z)}),T(B,R)},z=B=>{var R=c0();T(B,R)},N=B=>{var R=u0();T(B,R)},U=B=>{var R=d0();T(B,R)},Y=B=>{var R=g0();vt(R,21,()=>l(s).prs,P=>P.number,(P,H)=>{const Z=ce(()=>a(l(H))),de=ce(()=>m_(l(Z).color)),be=ce(()=>b_(l(Z).color));var he=p0(),ge=S(he),ye=S(ge),ke=S(ye),ue=x(ke,2),pe=S(ue),xe=x(ye,2),Le=S(xe),We=S(Le),ze=x(Le,4),Ce=S(ze),q=x(ze,4),ne=S(q),Se=x(ge,2),ve=S(Se);{var Ee=me=>{var Ie=f0();X("click",Ie,()=>t.onFixConflicts(l(H))),T(me,Ie)};ee(ve,me=>{l(H).mergeable==="CONFLICTING"&&me(Ee)})}var le=x(ve,2);{var Pe=me=>{var Ie=_0();re(()=>Me(Ie,"href",l(H).url)),T(me,Ie)};ee(le,me=>{l(H).mergeable==="MERGEABLE"&&l(H).state==="OPEN"&&me(Pe)})}var Ke=x(le,2);{var He=me=>{var Ie=v0();let j,ie;var Q=S(Ie);re(()=>{j=et(Ie,1,"pr-action-pill svelte-bvvs2r",null,j,{"dark-text":l(be)}),Me(Ie,"href",l(H).url),ie=Or(Ie,"",ie,{"--pill-color":l(de)}),se(Q,l(Z).label)}),T(me,Ie)};ee(Ke,me=>{l(Z).type!=="none"&&l(Z).label&&me(He)})}re((me,Ie,j)=>{et(ke,1,me,"svelte-bvvs2r"),Me(ue,"href",l(H).url),se(pe,l(H).title),se(We,`#${l(H).number??""}`),se(Ce,Ie),se(ne,j)},[()=>Wd(o(l(H))),()=>c(l(H)),()=>dg(l(H).updatedAt)]),T(P,he)}),T(B,R)};ee(D,B=>{l(r)?B(F):l(n)?B(z,1):l(s)&&!l(s).hasGhCli?B(N,2):l(s)&&l(s).prs.length===0?B(U,3):l(s)&&B(Y,4)})}var K=x(w,2),W=x(S(K),2);{var O=B=>{var R=b0();vt(R,20,()=>[1,2,3],Sn,(P,H)=>{var Z=m0();T(P,Z)}),T(B,R)},A=B=>{var R=S0();T(B,R)},E=B=>{var R=C0();vt(R,21,()=>l(s).activity,P=>P.hash,(P,H)=>{var Z=w0(),de=S(Z),be=S(de),he=x(de,2),ge=S(he),ye=x(he,2);{var ke=xe=>{var Le=y0(),We=S(Le);re(ze=>se(We,ze),[()=>h(l(H))]),T(xe,Le)};ee(ye,xe=>{l(H).branches.length>0&&xe(ke)})}var ue=x(ye,2),pe=S(ue);re(()=>{se(be,l(H).shortHash),se(ge,l(H).message),se(pe,l(H).timeAgo)}),T(P,Z)}),T(B,R)};ee(W,B=>{l(r)?B(O):l(s)&&l(s).activity.length===0?B(A,1):l(s)&&B(E,2)})}T(C,k)};ee(u,C=>{l(s)&&!l(s).isGitRepo?C(f):C(_,!1)})}var v=x(u,2),m=S(v),g=x(m,2);{var y=C=>{var k=x0();X("click",k,function(...w){var D;(D=t.onNewWorktree)==null||D.apply(this,w)}),T(C,k)};ee(g,C=>{(!l(s)||l(s).isGitRepo)&&C(y)})}X("click",m,function(...C){var k;(k=t.onNewSession)==null||k.apply(this,C)}),T(e,d),Ge()}Ze(["click"]);var R0=L('<div class="empty-icon svelte-1luen49" aria-hidden="true"> </div>'),P0=L('<p class="empty-description svelte-1luen49"> </p>'),T0=L('<button class="empty-action svelte-1luen49"> </button>'),M0=L('<div class="empty-state svelte-1luen49"><!> <div class="empty-heading svelte-1luen49"> </div> <!> <!></div>');function B0(e,t){var i=M0(),s=S(i);{var r=u=>{var f=R0(),_=S(f);re(()=>se(_,t.icon)),T(u,f)};ee(s,u=>{t.icon&&u(r)})}var n=x(s,2),o=S(n),a=x(n,2);{var c=u=>{var f=P0(),_=S(f);re(()=>se(_,t.description)),T(u,f)};ee(a,u=>{t.description&&u(c)})}var h=x(a,2);{var d=u=>{var f=T0(),_=S(f);re(()=>se(_,t.actionLabel)),X("click",f,function(...v){var m;(m=t.onAction)==null||m.apply(this,v)}),T(u,f)};ee(h,u=>{t.actionLabel&&t.onAction&&u(d)})}re(()=>se(o,t.heading)),T(e,i)}Ze(["click"]);var L0=L("<button><!></button>"),A0=L("<button><!></button>"),O0=L('<div class="toolbar svelte-k7we1m" role="toolbar"><div class="toolbar-grid svelte-k7we1m"><!></div></div>');function I0(e,t){Ye(t,!0),Kt(t,"useTmux",3,!1);let i=Kt(t,"inCopyMode",3,!1);const s=[{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"}],r=[{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(),Rt&&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(),Rt&&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(),Rt&&t.onRefocusMobileInput())}function o(u){var f;t.onSendKey(u.key),u.exitsCopyMode&&((f=t.onExitCopyMode)==null||f.call(t)),Rt&&t.onRefocusMobileInput()}function a(u){u.preventDefault();const f=u.target.closest("button");if(!f)return;if(i()){const v=r.find(m=>f.dataset.key===m.key);v&&o(v);return}const _=s.find(v=>v.id===f.id||v.key&&f.dataset.key===v.key);_&&n(_)}var c=Hi(),h=pt(c);{var d=u=>{var f=O0(),_=S(f),v=S(_);{var m=y=>{var C=Hi(),k=pt(C);vt(k,17,()=>r,w=>w.label,(w,D)=>{var F=L0(),z=S(F);al(z,()=>l(D).html),re(()=>{et(F,1,`tb-btn ${l(D).extraClass??""??""}`,"svelte-k7we1m"),Me(F,"data-key",l(D).key),Me(F,"aria-label",l(D).label)}),T(w,F)}),T(y,C)},g=y=>{var C=Hi(),k=pt(C);vt(k,17,()=>s,w=>w.label,(w,D)=>{var F=A0(),z=S(F);al(z,()=>l(D).html),re(()=>{et(F,1,`tb-btn ${l(D).extraClass??""??""}`,"svelte-k7we1m"),Me(F,"id",l(D).id),Me(F,"data-key",l(D).key),Me(F,"aria-label",l(D).label)}),T(w,F)}),T(y,C)};ee(v,y=>{i()?y(m):y(g,!1)})}X("mousedown",f,a),T(u,f)};ee(h,u=>{Rt&&u(d)})}T(e,c),Ge()}Ze(["mousedown"]);var N0=L('<div><button class="icon-btn svelte-wp0i5g" aria-label="Open sessions menu">&#9776;</button> <span class="mobile-title svelte-wp0i5g"> </span></div>');function F0(e,t){let i=Kt(t,"hidden",3,!1);var s=N0();let r;var n=S(s),o=x(n,2),a=S(o);re(()=>{r=et(s,1,"mobile-header svelte-wp0i5g",null,r,{hidden:i()}),se(a,t.title)}),X("click",n,function(...c){var h;(h=t.onMenuClick)==null||h.apply(this,c)}),T(e,s)}Ze(["click"]);var W0=L('<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>'),H0=L('<div class="update-toast svelte-1trivgv"><div class="update-toast-content svelte-1trivgv"><span class="update-toast-text svelte-1trivgv"> </span> <!></div></div>');function z0(e,t){Ye(t,!0);let i=I(!1),s=I(""),r=I("Update Now"),n=I(!1),o=I(!0);xn(async()=>{try{const f=await Ud();f.updateAvailable&&(b(s,`Update available: v${f.current} → v${f.latest}`),b(r,"Update Now"),b(n,!1),b(o,!0),b(i,!0))}catch{}});async function a(){b(n,!0),b(r,"Updating…");try{(await Kd()).restarting?(b(s,"Updated! Restarting server…"),b(o,!1),setTimeout(()=>{location.reload()},5e3)):(b(s,"Updated! Please restart the server manually."),b(o,!1))}catch{b(s,"Update failed. Please try again."),b(n,!1),b(r,"Retry"),b(o,!0)}}function c(){b(i,!1)}var h=Hi(),d=pt(h);{var u=f=>{var _=H0(),v=S(_),m=S(v),g=S(m),y=x(m,2);{var C=k=>{var w=W0(),D=S(w),F=S(D),z=x(D,2);re(()=>{D.disabled=l(n),se(F,l(r))}),X("click",D,a),X("click",z,c),T(k,w)};ee(y,k=>{l(o)&&k(C)})}re(()=>se(g,l(s))),T(f,_)};ee(d,f=>{l(i)&&f(u)})}T(e,h),Ge()}Ze(["click"]);var U0=L('<button class="image-toast-insert svelte-1y8sviv">Insert</button>'),K0=L('<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 q0(e,t){Ye(t,!0);let i=I(!1),s=I(""),r=I(!1),n=I(null),o=null;function a(g,y,C){o&&(clearTimeout(o),o=null),b(s,g,!0),b(r,y,!0),b(n,C??null,!0),b(i,!0)}function c(){b(i,!1),b(n,null),o&&(clearTimeout(o),o=null)}function h(g){o&&clearTimeout(o),o=setTimeout(()=>{l(n)||c()},g)}function d(){l(n)&&Er(l(n)),c()}function u(){c()}var f={show:a,hide:c,autoDismiss:h},_=Hi(),v=pt(_);{var m=g=>{var y=K0(),C=S(y),k=S(C),w=S(k),D=x(k,2),F=S(D);{var z=U=>{var Y=U0();X("click",Y,d),T(U,Y)};ee(F,U=>{l(r)&&U(z)})}var N=x(F,2);re(()=>se(w,l(s))),X("click",N,u),T(g,y)};ee(v,g=>{l(i)&&g(m)})}return T(e,_),Ge(f)}Ze(["click"]);var j0=L('<span class="dialog-title-repo svelte-thtd9b"> </span>'),V0=L('<li class="branch-create-new svelte-thtd9b" role="option" aria-selected="false"> </li>'),Y0=L('<li role="option" aria-selected="false" class="svelte-thtd9b"> </li>'),G0=L('<ul class="branch-dropdown svelte-thtd9b"><!> <!></ul>'),X0=L('<div class="dialog-field svelte-thtd9b"><div class="dialog-label-row svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-branch">Branch name</label> <button type="button" class="branch-refresh svelte-thtd9b" aria-label="Fetch latest remote branches" title="Fetch latest remote branches"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12a8 8 0 0 1-13.66 5.66M4 12a8 8 0 0 1 13.66-5.66M17 3.5v4h-4M7 20.5v-4h4" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"></path></svg></button></div> <div class="branch-input-wrap svelte-thtd9b"><input id="ns-branch" type="text" class="dialog-input svelte-thtd9b" placeholder="e.g. feat/my-feature" autocomplete="off"/> <!></div></div>'),Q0=L('<div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-continue" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-continue" class="dialog-label-inline svelte-thtd9b">Continue existing session</label></div>'),J0=L('<dialog class="dialog svelte-thtd9b"><div class="dialog-content svelte-thtd9b"><h2 class="dialog-title svelte-thtd9b"> <!></h2> <div class="dialog-tabs svelte-thtd9b"><button>Repo Session</button> <button>Worktree</button></div> <div class="dialog-body svelte-thtd9b"><div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-agent">Coding agent</label> <select id="ns-agent" class="dialog-select svelte-thtd9b"><option>Claude</option><option>Codex</option></select></div> <!> <!> <div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-yolo" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-yolo" class="dialog-label-inline svelte-thtd9b">Yolo mode (skip permission checks)</label></div> <div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-tmux" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-tmux" class="dialog-label-inline svelte-thtd9b">Launch in tmux</label></div> <div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-args">Extra args (optional)</label> <input id="ns-args" type="text" class="dialog-input svelte-thtd9b" placeholder="e.g. --verbose" autocomplete="off"/></div></div> <div class="dialog-footer svelte-thtd9b"><button class="btn btn-ghost svelte-thtd9b">Cancel</button> <button class="btn btn-primary svelte-thtd9b"> </button></div></div></dialog>');function Z0(e,t){Ye(t,!0);let i=Kt(t,"preselectedRepo",3,null);const s=Th();let r,n=I("repos"),o=I(""),a=I(""),c=I(""),h=I(""),d=I("claude"),u=I(!1),f=I(!1),_=I(!1),v=I(Xe([])),m=I(!1),g=I(!1),y=I(!1),C=0,k=ce(()=>{if(!l(c).trim())return[];const Q=l(c).toLowerCase();return l(v).filter(M=>M.toLowerCase().includes(Q)).slice(0,10)}),w=ce(()=>l(v).some(Q=>Q===l(c)));async function D(Q,M={}){const J=++C;if(Q){M.preserveExisting||b(v,[],!0),M.refresh?b(y,!0):b(g,!0);try{const fe=await Eh(Q,M.refresh?{refresh:!0}:{});if(J!==C||Q!==l(o))return;b(v,fe,!0),l(c).trim()&&b(m,!0)}catch{if(J!==C||Q!==l(o))return;M.preserveExisting||b(v,[],!0)}finally{J===C&&(b(g,!1),b(y,!1))}}}async function F(){!l(o)||l(y)||await D(l(o),{refresh:!0,preserveExisting:!0})}function z(){C+=1,b(c,""),b(v,[],!0),b(m,!1),b(g,!1),b(y,!1)}function N(){b(m,l(c).trim().length>0)}function U(Q){b(c,Q,!0),b(m,!1)}function Y(){b(o,""),b(a,""),b(h,""),b(u,!1),b(f,!1),b(_,!1),z()}async function K(Q,M){Y(),b(n,"repos"),await hf(),b(d,s.defaultAgent,!0),M!=null&&M.agent&&b(d,M.agent,!0),b(u,s.defaultYolo,!0),b(f,s.defaultContinue,!0),b(_,s.launchInTmux,!0),(M==null?void 0:M.yolo)!==void 0&&b(u,M.yolo,!0),(M==null?void 0:M.useTmux)!==void 0&&b(_,M.useTmux,!0);const J=Q??i();J&&(b(o,J.path,!0),b(a,J.name,!0),M!=null&&M.branchName&&(b(n,"worktrees"),await D(J.path))),M!=null&&M.branchName&&b(c,M.branchName,!0),M!=null&&M.claudeArgs&&b(h,M.claudeArgs,!0),r.showModal()}function W(){r.close()}async function O(){var Be,qe;const Q=l(o);if(!Q)return;const M=l(h).trim().split(/\s+/).filter(Boolean),J=Math.max(80,Math.floor((window.innerWidth-60)/8)),fe=Math.max(24,Math.floor((window.innerHeight-120)/17));try{let Te;l(n)==="repos"?Te=await Mp({repoPath:Q,repoName:l(a)||Q.split("/").filter(Boolean).pop(),continue:l(f),yolo:l(u),claudeArgs:M.length>0?M:void 0,agent:l(d),useTmux:l(_),cols:J,rows:fe,allowMultiple:!0}):Te=await qr({repoPath:Q,repoName:l(a)||Q.split("/").filter(Boolean).pop(),branchName:l(c).trim()||void 0,yolo:l(u),claudeArgs:M.length>0?M:void 0,agent:l(d),useTmux:l(_),cols:J,rows:fe}),r.close(),await Ut(),Te!=null&&Te.id&&((Be=t.onSessionCreated)==null||Be.call(t,Te.id))}catch(Te){if(Te instanceof Error&&"sessionId"in Te){const tt=Te;r.close(),await Ut(),tt.sessionId&&((qe=t.onSessionCreated)==null||qe.call(t,tt.sessionId))}}}function A(Q){Q.target===r&&r.close()}function E(Q){l(m)&&Q.key==="Escape"&&(b(m,!1),Q.stopPropagation())}var B={open:K,close:W},R=J0(),P=S(R),H=S(P),Z=S(H),de=x(Z);{var be=Q=>{var M=j0(),J=S(M);re(()=>se(J,`— ${l(a)??""}`)),T(Q,M)};ee(de,Q=>{l(a)&&Q(be)})}var he=x(H,2),ge=S(he);let ye;var ke=x(ge,2);let ue;var pe=x(he,2),xe=S(pe),Le=x(S(xe),2),We=S(Le);We.value=We.__value="claude";var ze=x(We);ze.value=ze.__value="codex";var Ce=x(xe,2);{var q=Q=>{var M=X0(),J=S(M),fe=x(S(J),2),Be=S(fe);let qe;var Te=x(J,2),tt=S(Te),De=x(tt,2);{var At=ti=>{var Zs=G0(),Nr=S(Zs);{var Fr=Wt=>{var Di=V0(),$s=S(Di);re(Rn=>se($s,`Create new: ${Rn??""}`),[()=>l(c).trim()]),X("mousedown",Di,()=>U(l(c).trim())),T(Wt,Di)},Cs=ce(()=>!l(w)&&l(c).trim());ee(Nr,Wt=>{l(Cs)&&Wt(Fr)})}var hi=x(Nr,2);vt(hi,16,()=>l(k),Wt=>Wt,(Wt,Di)=>{var $s=Y0(),Rn=S($s);re(()=>se(Rn,Di)),X("mousedown",$s,()=>U(Di)),T(Wt,$s)}),T(ti,Zs)},ei=ce(()=>l(m)&&(l(k).length>0||l(c).trim()&&!l(w)));ee(De,ti=>{l(ei)&&ti(At)})}re(()=>{fe.disabled=!l(o)||l(g)||l(y),qe=et(Be,0,"svelte-thtd9b",null,qe,{spinning:l(g)||l(y)})}),X("click",fe,F),X("input",tt,N),$i("focus",tt,()=>{l(c).trim()&&b(m,!0)}),yi(tt,()=>l(c),ti=>b(c,ti)),T(Q,M)};ee(Ce,Q=>{l(n)==="worktrees"&&Q(q)})}var ne=x(Ce,2);{var Se=Q=>{var M=Q0(),J=S(M);Ni(J,()=>l(f),fe=>b(f,fe)),T(Q,M)};ee(ne,Q=>{l(n)==="repos"&&Q(Se)})}var ve=x(ne,2),Ee=S(ve),le=x(ve,2),Pe=S(le),Ke=x(le,2),He=x(S(Ke),2),me=x(pe,2),Ie=S(me),j=x(Ie,2),ie=S(j);return Je(R,Q=>r=Q,()=>r),re(()=>{se(Z,`${l(n)==="repos"?"New Session":"New Worktree"} `),ye=et(ge,1,"dialog-tab svelte-thtd9b",null,ye,{active:l(n)==="repos"}),ue=et(ke,1,"dialog-tab svelte-thtd9b",null,ue,{active:l(n)==="worktrees"}),j.disabled=!l(o),se(ie,l(n)==="repos"?"Start Session":"Create Worktree")}),X("click",R,A),X("keydown",R,E),X("click",ge,()=>{b(n,"repos")}),X("click",ke,()=>{b(n,"worktrees"),l(o)&&l(v).length===0&&D(l(o))}),Qo(Le,()=>l(d),Q=>b(d,Q)),Ni(Ee,()=>l(u),Q=>b(u,Q)),Ni(Pe,()=>l(_),Q=>b(_,Q)),yi(He,()=>l(h),Q=>b(h,Q)),X("click",Ie,()=>r.close()),X("click",j,O),T(e,R),Ge(B)}Ze(["click","keydown","input","mousedown"]);var $0=L('<p class="error-msg svelte-fdtoa4"> </p>'),e1=L('<span class="version-status svelte-fdtoa4">Up to date</span>'),t1=L('<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>'),i1=L('<button class="btn btn-ghost btn-sm svelte-fdtoa4"> </button>'),s1=L('<p class="version-status-msg svelte-fdtoa4"> </p>'),r1=L('<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">Session Defaults</h3> <p class="section-desc svelte-fdtoa4">Default options for new sessions. Override per-session via Customize.</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">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 n1(e,t){Ye(t,!0);let i,s=I(!1);const r=Th();let n=I(""),o=I(""),a=I(null),c=I(!1),h=I(!1),d=I(!1),u=I(!1),f=I("");async function _(){b(n,""),b(f,""),b(h,!1),b(u,!1),b(s,localStorage.getItem("devtools-enabled")==="true"),await hf(),i.showModal(),w()}function v(){i.close()}async function m(){const M=r.defaultAgent;b(n,"");try{await Op(r.defaultAgent)}catch{r.defaultAgent=M,b(n,"Failed to update default agent.")}}async function g(){const M=r.defaultContinue;b(n,"");try{await Np(r.defaultContinue)}catch{r.defaultContinue=M,b(n,"Failed to update continue default.")}}async function y(){const M=r.defaultYolo;b(n,"");try{await Wp(r.defaultYolo)}catch{r.defaultYolo=M,b(n,"Failed to update yolo default.")}}async function C(){const M=r.launchInTmux;b(n,"");try{await zp(r.launchInTmux)}catch(J){r.launchInTmux=M,b(n,J instanceof Error?J.message:"Failed to update tmux setting.",!0)}}async function k(){const M=r.defaultNotifications;b(n,"");try{await Kp(r.defaultNotifications)}catch{r.defaultNotifications=M,b(n,"Failed to update notifications default.")}}async function w(){b(d,!0),b(f,"");try{const M=await Ud();b(o,M.current,!0),b(a,M.latest,!0),b(c,M.updateAvailable,!0),b(h,!0)}catch{b(f,"Failed to check for updates.")}finally{b(d,!1)}}async function D(){b(u,!0),b(f,"");try{(await Kd()).restarting?(b(f,"Updated! Restarting server…"),setTimeout(()=>{location.reload()},5e3)):b(f,"Updated! Please restart the server manually."),b(c,!1)}catch{b(f,"Update failed. Please try again."),b(u,!1)}}function F(){localStorage.setItem("devtools-enabled",l(s)?"true":"false"),window.dispatchEvent(new Event("devtools-changed"))}async function z(){i.close(),await Ut()}function N(M){M.target===i&&z()}var U={open:_,close:v},Y=r1(),K=S(Y),W=S(K),O=x(S(W),2),A=x(W,2),E=S(A);{var B=M=>{var J=$0(),fe=S(J);re(()=>se(fe,l(n))),T(M,J)};ee(E,M=>{l(n)&&M(B)})}var R=x(E,2),P=x(S(R),4),H=S(P);H.value=H.__value="claude";var Z=x(H);Z.value=Z.__value="codex";var de=x(R,2),be=x(S(de),4),he=S(be),ge=x(be,2),ye=S(ge),ke=x(ge,2),ue=S(ke),pe=x(ke,2),xe=S(pe),Le=x(de,2),We=x(S(Le),2),ze=S(We),Ce=x(Le,2),q=x(S(Ce),2),ne=S(q),Se=S(ne);{var ve=M=>{var J=Vs();re(()=>se(J,`v${l(o)??""}`)),T(M,J)},Ee=M=>{var J=Vs("...");T(M,J)};ee(Se,M=>{l(o)?M(ve):M(Ee,!1)})}var le=x(ne,2);{var Pe=M=>{var J=e1();T(M,J)};ee(le,M=>{l(h)&&!l(c)&&!l(u)&&M(Pe)})}var Ke=x(q,2);{var He=M=>{var J=t1(),fe=S(J),Be=S(fe),qe=x(fe,2),Te=S(qe);re(()=>{se(Be,`v${l(o)??""} → v${l(a)??""}`),qe.disabled=l(u),se(Te,l(u)?"Updating…":"Update Now")}),X("click",qe,D),T(M,J)},me=M=>{var J=i1(),fe=S(J);re(()=>{J.disabled=l(d),se(fe,l(d)?"Checking…":"Check for updates")}),X("click",J,w),T(M,J)};ee(Ke,M=>{l(c)?M(He):l(h)||M(me,1)})}var Ie=x(Ke,2);{var j=M=>{var J=s1(),fe=S(J);re(()=>se(fe,l(f))),T(M,J)};ee(Ie,M=>{l(f)&&M(j)})}var ie=x(A,2),Q=S(ie);return Je(Y,M=>i=M,()=>i),X("click",Y,N),X("click",O,z),X("change",P,m),Qo(P,()=>r.defaultAgent,M=>r.defaultAgent=M),X("change",he,g),Ni(he,()=>r.defaultContinue,M=>r.defaultContinue=M),X("change",ye,y),Ni(ye,()=>r.defaultYolo,M=>r.defaultYolo=M),X("change",ue,C),Ni(ue,()=>r.launchInTmux,M=>r.launchInTmux=M),X("change",xe,k),Ni(xe,()=>r.defaultNotifications,M=>r.defaultNotifications=M),X("change",ze,F),Ni(ze,()=>l(s),M=>b(s,M)),X("click",Q,z),T(e,Y),Ge(U)}Ze(["click","change"]);var o1=L('<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),a1=L('<p class="error-msg svelte-15sco2n"> </p>'),l1=L('<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 h1(e,t){Ye(t,!0);let i,s=I(null),r=I(""),n=I(!1);function o(z){b(s,z,!0),b(r,""),b(n,!1),i.showModal()}function a(){i.close()}async function c(){if(!(!l(s)||l(n))){b(n,!0),b(r,""),lg(l(s).path);try{await Bp(l(s).path,l(s).repoPath),i.close(),await Ut()}catch(z){b(r,z instanceof Error?z.message:"Failed to delete worktree.",!0),b(n,!1)}finally{l(s)&&hg(l(s).path)}}}function h(){i.close()}function d(z){z.target===i&&i.close()}var u={open:o,close:a},f=l1(),_=S(f),v=x(S(_),2),m=S(v);{var g=z=>{var N=o1(),U=pt(N),Y=x(S(U)),K=S(Y),W=x(U,2),O=S(W);re(()=>{se(K,l(s).displayName||l(s).name),se(O,l(s).path)}),T(z,N)};ee(m,z=>{l(s)&&z(g)})}var y=x(m,2);{var C=z=>{var N=a1(),U=S(N);re(()=>se(U,l(r))),T(z,N)};ee(y,z=>{l(r)&&z(C)})}var k=x(v,2),w=S(k),D=x(w,2),F=S(D);return Je(f,z=>i=z,()=>i),re(()=>{w.disabled=l(n),D.disabled=l(n),se(F,l(n)?"Deleting...":"Delete")}),X("click",f,d),X("click",w,h),X("click",D,c),T(e,f),Ge(u)}Ze(["click"]);var c1=L('<div class="loading-placeholder svelte-15gfcbp">Loading...</div>'),u1=L('<div class="empty-placeholder svelte-15gfcbp"><!></div>'),d1=L('<span class="spinner svelte-15gfcbp">...</span>'),f1=L("<span>&#9654;</span>"),_1=L('<button class="expand-btn svelte-15gfcbp"><!></button>'),v1=L('<span class="expand-spacer svelte-15gfcbp"></span>'),p1=L('<span class="git-badge svelte-15gfcbp" aria-label="Git repository">git</span>'),g1=L('<div role="treeitem"><!> <input type="checkbox" class="node-checkbox svelte-15gfcbp"/> <span class="node-name svelte-15gfcbp"> </span> <!></div>'),m1=L('<div class="truncated-notice svelte-15gfcbp"> </div>'),b1=L("<!> <!>",1),S1=L('<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 y1(e,t){Ye(t,!0);let i=Kt(t,"selectedPaths",31,()=>Xe([])),s=I(Xe([])),r=I(""),n=I(-1),o=I(!0),a=I(null),c=I(void 0);xn(()=>{h()});async function h(){b(o,!0),b(a,null);try{const R=await hc();b(s,R.entries.map(P=>d(P,0)),!0),R.truncated&&b(a,{shown:R.entries.length,total:R.total},!0)}catch{b(s,[],!0)}finally{b(o,!1)}}function d(R,P){return{name:R.name,path:R.path,isGitRepo:R.isGitRepo,hasChildren:R.hasChildren,children:null,expanded:!1,selected:!1,loading:!1,depth:P,truncatedInfo:null}}async function u(R){if(R.expanded){R.expanded=!1;return}if(R.children===null){R.loading=!0;try{const P=await hc(R.path);R.children=P.entries.map(H=>d(H,R.depth+1)),R.truncatedInfo=P.truncated?{shown:P.entries.length,total:P.total}:null}catch{R.children=[]}finally{R.loading=!1}}R.expanded=!0}function f(R){R.selected=!R.selected,_()}function _(){i(v(l(s)))}function v(R){const P=[];for(const H of R)H.selected&&P.push(H.path),H.children&&P.push(...v(H.children));return P}function m(R,P){return R.toLowerCase().includes(P.toLowerCase())}function g(R,P){var H;return!!(!P||R.expanded||m(R.name,P)||(H=R.children)!=null&&H.some(Z=>g(Z,P)))}function y(R,P){const H=[];for(const Z of R)g(Z,P)&&(H.push(Z),Z.expanded&&Z.children&&H.push(...y(Z.children,P)));return H}let C=ce(()=>y(l(s),l(r)));function k(R){var H;if(R.key==="ArrowDown"){R.preventDefault(),b(n,Math.min(l(n)+1,l(C).length-1),!0);return}if(R.key==="ArrowUp"){R.preventDefault(),b(n,Math.max(l(n)-1,0),!0);return}const P=l(n)>=0?l(C)[l(n)]:void 0;if(P){if(R.key==="ArrowRight"){if(R.preventDefault(),P.hasChildren&&!P.expanded)u(P);else if(P.expanded&&((H=P.children)!=null&&H.length)){const Z=l(C).indexOf(P.children[0]);Z>=0&&b(n,Z,!0)}return}if(R.key==="ArrowLeft"){if(R.preventDefault(),P.expanded)P.expanded=!1;else{const Z=P.depth-1;for(let de=l(n)-1;de>=0;de--)if(l(C)[de].depth===Z){b(n,de,!0);break}}return}if(R.key===" "){R.preventDefault(),f(P);return}}}function w(R,P){const H=P.target;H.closest(".expand-btn")||H.closest(".node-checkbox")||(R.hasChildren&&!R.expanded?u(R):f(R))}function D(){b(r,""),b(n,-1),F(l(s)),i([]),z(l(s))}function F(R){for(const P of R)P.selected=!1,P.children&&F(P.children)}function z(R){for(const P of R)P.expanded=!1,P.children&&z(P.children)}var N={reset:D},U=S1(),Y=S(U),K=S(Y),W=x(Y,2),O=S(W);{var A=R=>{var P=c1();T(R,P)},E=R=>{var P=u1(),H=S(P);{var Z=be=>{var he=Vs();re(()=>se(he,`No matches for "${l(r)??""}"`)),T(be,he)},de=be=>{var he=Vs("No directories found");T(be,he)};ee(H,be=>{l(r)?be(Z):be(de,!1)})}T(R,P)},B=R=>{var P=b1(),H=pt(P);vt(H,19,()=>l(C),be=>be.path,(be,he,ge)=>{var ye=g1();let ke;var ue=S(ye);{var pe=ne=>{var Se=_1(),ve=S(Se);{var Ee=Pe=>{var Ke=d1();T(Pe,Ke)},le=Pe=>{var Ke=f1();let He;re(()=>He=et(Ke,1,"arrow svelte-15gfcbp",null,He,{expanded:l(he).expanded})),T(Pe,Ke)};ee(ve,Pe=>{l(he).loading?Pe(Ee):Pe(le,!1)})}re(()=>Me(Se,"aria-label",l(he).expanded?"Collapse":"Expand")),X("click",Se,()=>u(l(he))),T(ne,Se)},xe=ne=>{var Se=v1();T(ne,Se)};ee(ue,ne=>{l(he).hasChildren?ne(pe):ne(xe,!1)})}var Le=x(ue,2),We=x(Le,2),ze=S(We),Ce=x(We,2);{var q=ne=>{var Se=p1();T(ne,Se)};ee(Ce,ne=>{l(he).isGitRepo&&ne(q)})}re(()=>{ke=et(ye,1,"tree-row svelte-15gfcbp",null,ke,{focused:l(ge)===l(n),selected:l(he).selected}),Or(ye,`padding-left: ${12+l(he).depth*20}px`),Me(ye,"aria-expanded",l(he).hasChildren?l(he).expanded:void 0),Me(ye,"aria-selected",l(he).selected),Me(ye,"aria-level",l(he).depth+1),vp(Le,l(he).selected),Me(Le,"aria-label",`Select ${l(he).name??""}`),se(ze,l(he).name)}),X("click",ye,ne=>w(l(he),ne)),X("change",Le,()=>f(l(he))),X("click",Le,ne=>ne.stopPropagation()),T(be,ye)});var Z=x(H,2);{var de=be=>{var he=m1(),ge=S(he);re(()=>se(ge,`Showing ${l(a).shown??""} of ${l(a).total??""} directories. Use the filter to narrow results.`)),T(be,he)};ee(Z,be=>{l(a)&&be(de)})}T(R,P)};ee(O,R=>{l(o)?R(A):l(C).length===0?R(E,1):R(B,!1)})}return Je(W,R=>b(c,R),()=>l(c)),yi(K,()=>l(r),R=>b(r,R)),X("keydown",W,k),T(e,U),Ge(N)}Ze(["keydown","click","change"]);var w1=L('<p class="error-msg svelte-4yj2yx"> </p>'),C1=L('<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 k1(e,t){Ye(t,!0);let i,s=I(void 0),r=I(Xe([])),n=I(""),o=I(!1);function a(){var A;b(r,[],!0),b(n,""),b(o,!1),(A=l(s))==null||A.reset(),i.showModal()}function c(){i.close()}async function h(){if(l(r).length!==0){b(o,!0),b(n,"");try{const A=await xp(l(r));if(A.errors.length>0&&A.added.length===0){b(n,A.errors.map(E=>`${E.path}: ${E.error}`).join("; "),!0),b(o,!1);return}A.added.length>0&&t.onWorkspacesAdded(A.added.map(E=>E.path)),A.errors.length>0&&console.warn("Some workspaces failed to add:",A.errors),c()}catch{b(n,"Failed to add workspaces.")}finally{b(o,!1)}}}function d(A){A.target===i&&c()}var u={open:a,close:c},f=C1(),_=S(f),v=S(_),m=x(S(v),2),g=x(v,2),y=x(S(g),2);Je(y1(y,{get selectedPaths(){return l(r)},set selectedPaths(A){b(r,A,!0)}}),A=>b(s,A,!0),()=>l(s));var C=x(y,2);{var k=A=>{var E=w1(),B=S(E);re(()=>se(B,l(n))),T(A,E)};ee(C,A=>{l(n)&&A(k)})}var w=x(g,2),D=S(w),F=S(D);{var z=A=>{var E=Vs();re(()=>se(E,`${l(r).length??""} selected`)),T(A,E)};ee(F,A=>{l(r).length>0&&A(z)})}var N=x(D,2),U=S(N),Y=x(U,2),K=S(Y);{var W=A=>{var E=Vs("Adding...");T(A,E)},O=A=>{var E=Vs();re(()=>se(E,`Add Workspace${l(r).length>1?"s":""}`)),T(A,E)};ee(K,A=>{l(o)?A(W):A(O,!1)})}return Je(f,A=>i=A,()=>i),re(()=>Y.disabled=l(r).length===0||l(o)),X("click",f,d),X("click",m,c),X("click",U,c),X("click",Y,h),T(e,f),Ge(u)}Ze(["click"]);var x1=L('<p class="error-msg svelte-1n78dcx"> </p>'),E1=L("<option> </option>"),D1=L("<option> </option>"),R1=L('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. focus on security, error handling"></textarea>'),P1=L('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. include test plan section"></textarea>'),T1=L('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. prefix with dy/, use conventional commits style"></textarea>'),M1=L('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. use TypeScript, follow CLAUDE.md"></textarea>'),B1=L('<span class="save-success svelte-1n78dcx">Saved</span>'),L1=L('<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 A1(e,t){Ye(t,!0);let i,s=I(""),r=I(""),n=I(!1),o=I(""),a=I(!1),c=I(Xe([])),h=I(""),d=I(""),u=I(""),f=I("claude"),_=I(!1),v=I(!1),m=I(!1),g=I(""),y=I(""),C=I(""),k=I(""),w=I(!1),D=I(!1),F=I(!1),z=I(!1);async function N(oe,je){b(s,oe,!0),b(r,je,!0),b(o,""),b(a,!1),b(n,!1),b(h,""),b(d,""),b(u,""),b(f,"claude"),b(_,!1),b(v,!1),b(m,!1),b(g,""),b(y,""),b(C,""),b(k,""),i.showModal();try{const[bt,Wr]=await Promise.all([ll(oe),Eh(oe).catch(()=>[])]);b(c,Wr,!0),Y(bt)}catch{b(o,"Failed to load workspace settings.")}}function U(){i.close()}function Y(oe){b(h,oe.defaultBranch??"",!0),b(d,oe.remote??"",!0),b(u,oe.branchPrefix??"",!0),b(f,oe.defaultAgent??"claude",!0),b(_,oe.defaultContinue??!1,!0),b(v,oe.defaultYolo??!1,!0),b(m,oe.launchInTmux??!1,!0),b(g,oe.promptCodeReview??"",!0),b(y,oe.promptCreatePr??"",!0),b(C,oe.promptBranchRename??"",!0),b(k,oe.promptGeneral??"",!0)}async function K(){b(n,!0),b(o,""),b(a,!1);try{const oe={defaultAgent:l(f),defaultContinue:l(_),defaultYolo:l(v),launchInTmux:l(m)};l(h)&&(oe.defaultBranch=l(h)),l(d)&&(oe.remote=l(d)),l(u)&&(oe.branchPrefix=l(u)),l(g)&&(oe.promptCodeReview=l(g)),l(y)&&(oe.promptCreatePr=l(y)),l(C)&&(oe.promptBranchRename=l(C)),l(k)&&(oe.promptGeneral=l(k)),await jp(l(s),oe),b(a,!0),setTimeout(()=>{b(a,!1)},2e3)}catch(oe){b(o,oe instanceof Error?oe.message:"Failed to save settings.",!0)}finally{b(n,!1)}}function W(){i.close(),t.onRemoveWorkspace(l(s))}function O(oe){oe.target===i&&i.close()}var A={open:N,close:U},E=L1(),B=S(E),R=S(B),P=S(R),H=x(S(P)),Z=x(P,2),de=x(R,2),be=S(de);{var he=oe=>{var je=x1(),bt=S(je);re(()=>se(bt,l(o))),T(oe,je)};ee(be,oe=>{l(o)&&oe(he)})}var ge=x(be,2),ye=x(S(ge),2),ke=x(S(ye),2),ue=S(ke);ue.value=ue.__value="";var pe=x(ue);vt(pe,17,()=>l(c),Sn,(oe,je)=>{var bt=E1(),Wr=S(bt),Gh={};re(()=>{se(Wr,l(je)),Gh!==(Gh=l(je))&&(bt.value=(bt.__value=l(je))??"")}),T(oe,bt)});var xe=x(pe);{var Le=oe=>{var je=D1(),bt=S(je),Wr={};re(()=>{se(bt,l(h)),Wr!==(Wr=l(h))&&(je.value=(je.__value=l(h))??"")}),T(oe,je)},We=ce(()=>l(h)&&!l(c).includes(l(h)));ee(xe,oe=>{l(We)&&oe(Le)})}var ze=x(ye,2),Ce=x(S(ze),2),q=x(ze,2),ne=x(S(q),2),Se=x(ge,4),ve=x(S(Se),2),Ee=x(S(ve),2),le=S(Ee);le.value=le.__value="claude";var Pe=x(le);Pe.value=Pe.__value="codex";var Ke=x(ve,2),He=S(Ke),me=S(He),Ie=x(He,2),j=S(Ie),ie=x(Ie,2),Q=S(ie),M=x(Se,4),J=x(S(M),2),fe=S(J),Be=S(fe),qe=S(Be),Te=x(fe,2);{var tt=oe=>{var je=R1();Me(je,"rows",3),yi(je,()=>l(g),bt=>b(g,bt)),T(oe,je)};ee(Te,oe=>{l(w)&&oe(tt)})}var De=x(J,2),At=S(De),ei=S(At),ti=S(ei),Zs=x(At,2);{var Nr=oe=>{var je=P1();Me(je,"rows",3),yi(je,()=>l(y),bt=>b(y,bt)),T(oe,je)};ee(Zs,oe=>{l(D)&&oe(Nr)})}var Fr=x(De,2),Cs=S(Fr),hi=S(Cs),Wt=S(hi),Di=x(Cs,2);{var $s=oe=>{var je=T1();Me(je,"rows",3),yi(je,()=>l(C),bt=>b(C,bt)),T(oe,je)};ee(Di,oe=>{l(F)&&oe($s)})}var Rn=x(Fr,2),ko=S(Rn),S_=S(ko),y_=S(S_),w_=x(ko,2);{var C_=oe=>{var je=M1();Me(je,"rows",3),yi(je,()=>l(k),bt=>b(k,bt)),T(oe,je)};ee(w_,oe=>{l(z)&&oe(C_)})}var k_=x(de,2),Vh=S(k_),x_=x(Vh,2),Yh=S(x_);{var E_=oe=>{var je=B1();T(oe,je)};ee(Yh,oe=>{l(a)&&oe(E_)})}var ka=x(Yh,2),D_=S(ka);return Je(E,oe=>i=oe,()=>i),re(()=>{se(H,` ${l(r)??""}`),Me(fe,"aria-expanded",l(w)),se(qe,l(w)?"▾":"▸"),Me(At,"aria-expanded",l(D)),se(ti,l(D)?"▾":"▸"),Me(Cs,"aria-expanded",l(F)),se(Wt,l(F)?"▾":"▸"),Me(ko,"aria-expanded",l(z)),se(y_,l(z)?"▾":"▸"),ka.disabled=l(n),se(D_,l(n)?"Saving…":"Save")}),X("click",E,O),X("click",Z,()=>i.close()),Qo(ke,()=>l(h),oe=>b(h,oe)),yi(Ce,()=>l(d),oe=>b(d,oe)),yi(ne,()=>l(u),oe=>b(u,oe)),Qo(Ee,()=>l(f),oe=>b(f,oe)),Ni(me,()=>l(_),oe=>b(_,oe)),Ni(j,()=>l(v),oe=>b(v,oe)),Ni(Q,()=>l(m),oe=>b(m,oe)),X("click",fe,()=>{b(w,!l(w))}),X("click",At,()=>{b(D,!l(D))}),X("click",Cs,()=>{b(F,!l(F))}),X("click",ko,()=>{b(z,!l(z))}),X("click",Vh,W),X("click",ka,K),T(e,E),Ge(A)}Ze(["click"]);var O1=L('<div class="sidebar-overlay svelte-13zv0lp"></div>'),I1=L("<!> <!> <!> <!>",1),N1=L('<div class="main-app svelte-13zv0lp"><!> <!> <div class="terminal-area svelte-13zv0lp"><!> <!></div></div> <!> <!> <!> <!> <!> <!> <!>',1);function F1(e,t){Ye(t,!0);const i=new d_({defaultOptions:{queries:{staleTime:60*1e3,gcTime:600*1e3,refetchOnWindowFocus:!0}}}),s=qd(),r=Qd(),n=Rh(),o=Th();function a(q,ne){n.activeSessionId=q;const Se=n.sessions.find(ve=>ve.id===q);Se&&(r.activeWorkspacePath=Se.repoPath),vc(q),pi()}$p(a);let c=I(void 0),h=I(void 0),d=I(void 0),u=I(void 0),f=I(void 0),_=I(void 0),v=I(void 0),m=I(!1);xn(()=>{Vp();let q,ne;if(Rt&&window.visualViewport){const Ee=window.visualViewport;let le=null;const Pe=()=>{const Ke=window.innerHeight-Ee.height;b(m,Ke>50),l(v)&&(l(v).style.height=l(m)?Ee.height+"px":""),window.scrollTo(0,0),le&&clearTimeout(le),le=setTimeout(()=>{var He;return(He=l(c))==null?void 0:He.fitTerm()},100)};Ee.addEventListener("resize",Pe),Ee.addEventListener("scroll",Pe),q=()=>{Ee.removeEventListener("resize",Pe),Ee.removeEventListener("scroll",Pe),le&&clearTimeout(le)}}const Se=navigator.platform.toUpperCase().includes("MAC");let ve;{const Ee=le=>{var He;const Pe=(He=document.activeElement)==null?void 0:He.tagName;if(!(Pe==="INPUT"||Pe==="TEXTAREA"||!(Se?le.metaKey:le.ctrlKey))){if(le.key==="t"&&!le.shiftKey){le.preventDefault(),K();return}if(le.key==="w"&&!le.shiftKey){le.preventDefault(),n.activeSessionId&&R(n.activeSessionId);return}if(!le.shiftKey&&le.key>="1"&&le.key<="9"){const me=l(k);if(me.length===0)return;le.preventDefault();const Ie=parseInt(le.key,10),j=Ie===9?me[me.length-1]:me[Ie-1];j&&Y(j.id);return}if(le.shiftKey&&le.key==="["){const me=l(k);if(me.length===0)return;le.preventDefault();const Ie=me.findIndex(ie=>ie.id===n.activeSessionId),j=Ie<=0?me[me.length-1]:me[Ie-1];j&&Y(j.id);return}if(le.shiftKey&&le.key==="]"){const me=l(k);if(me.length===0)return;le.preventDefault();const Ie=me.findIndex(ie=>ie.id===n.activeSessionId),j=Ie===-1||Ie===me.length-1?me[0]:me[Ie+1];j&&Y(j.id);return}}};document.addEventListener("keydown",Ee),ve=()=>document.removeEventListener("keydown",Ee)}if(Rt){let Pe=0,Ke=0,He=!1;const me=ie=>{const Q=ie.touches[0];Q&&Q.clientX<=30&&!r.sidebarOpen&&(Pe=Q.clientX,Ke=Q.clientY,He=!0)},Ie=ie=>{if(!He)return;const Q=ie.touches[0];if(!Q)return;const M=Q.clientX-Pe,J=Math.abs(Q.clientY-Ke);if(J>M&&(J>8||M>8)){He=!1;return}M>=50&&(He=!1,fc())},j=()=>{He=!1};document.addEventListener("touchstart",me,{passive:!0}),document.addEventListener("touchmove",Ie,{passive:!0}),document.addEventListener("touchend",j),ne=()=>{document.removeEventListener("touchstart",me),document.removeEventListener("touchmove",Ie),document.removeEventListener("touchend",j)}}return()=>{ve==null||ve(),q==null||q(),ne==null||ne()}}),Ui(()=>{s.authenticated&&Ut().then(()=>{const ne=new URLSearchParams(window.location.search).get("session");ne&&(window.history.replaceState({},"","/"),a(ne)),!n.activeSessionId&&!ne&&n.sessions.length===1&&Y(n.sessions[0].id);for(const Se of n.sessions)Po(Se.id,o.defaultNotifications);ig().then(()=>{sg(ag())})})}),Ui(()=>{s.authenticated&&nf(q=>{q.type==="worktrees-changed"?Ut():q.type==="session-idle-changed"&&q.sessionId&&og(q.sessionId,q.idle??!1)})});let g=ce(()=>r.activeWorkspacePath?n.workspaces.find(q=>q.path===r.activeWorkspacePath):void 0),y=ce(()=>r.activeWorkspacePath?rf(r.activeWorkspacePath):[]),C=ce(()=>n.activeSessionId?n.sessions.find(q=>q.id===n.activeSessionId):void 0),k=ce(()=>l(C)?l(y).filter(q=>q.repoPath===l(C).repoPath):l(y)),w=ce(()=>!!l(C)&&!!r.activeWorkspacePath&&(l(C).repoPath===r.activeWorkspacePath||l(C).repoPath.startsWith(r.activeWorkspacePath+"/"))),D=ce(()=>{var q,ne;return((q=l(C))==null?void 0:q.displayName)||((ne=l(g))==null?void 0:ne.name)||"Claude Remote CLI"}),F=ce(()=>{var q;return((q=l(C))==null?void 0:q.useTmux)??!1}),z=ce(()=>{var q;return((q=l(C))==null?void 0:q.mode)??"pty"}),N=I(!1),U=ce(()=>l(g)?l(w)?"session":"dashboard":"empty");function Y(q){var Se;n.activeSessionId=q;const ne=n.sessions.find(ve=>ve.id===q);if(ne){const ve=n.workspaces.find(Ee=>ne.repoPath===Ee.path||ne.repoPath.startsWith(Ee.path+"/"));r.activeWorkspacePath=(ve==null?void 0:ve.path)??ne.repoPath}vc(q),pi(),(Se=l(c))==null||Se.focusTerm()}function K(q,ne){var Se,ve,Ee;q?(Se=l(d))==null||Se.open({name:q.name,path:q.path},ne):l(g)?(ve=l(d))==null||ve.open({name:l(g).name,path:l(g).path},ne):(Ee=l(d))==null||Ee.open(void 0,ne)}function W(q){var ne,Se;q?(ne=l(_))==null||ne.open(q.path,q.name):(Se=l(u))==null||Se.open()}async function O(q){var ne,Se;try{let ve=o.defaultYolo,Ee=o.defaultAgent,le=o.launchInTmux;try{const me=await ll(q.path);me.defaultYolo!==void 0&&(ve=me.defaultYolo),me.defaultAgent&&(Ee=me.defaultAgent),me.launchInTmux!==void 0&&(le=me.launchInTmux)}catch{}const{branchName:Pe,worktreePath:Ke}=await cc(q.path),He=await qr({repoPath:q.path,repoName:q.name,worktreePath:Ke,branchName:Pe,yolo:ve,agent:Ee,useTmux:le,needsBranchRename:!0});await Ut(),n.activeSessionId=He.id,r.activeWorkspacePath=q.path,Po(He.id,o.defaultNotifications),pi(),(ne=l(c))==null||ne.focusTerm()}catch{(Se=l(d))==null||Se.open({name:q.name,path:q.path})}}async function A(q){if(!l(g))return;const ne=l(g).path,Se=n.sessions.find(le=>le.branchName===q.headRefName&&le.repoPath.startsWith(ne)),ve=n.worktrees.find(le=>le.branchName===q.headRefName&&le.repoPath===ne);let Ee=`Merge the branch "${q.baseRefName}" into this branch and resolve all merge conflicts. Use \`git merge ${q.baseRefName}\` and fix any conflicts in the working tree. After resolving, verify the build passes.`;try{const le=await ll(ne);le.promptFixConflicts&&(Ee=le.promptFixConflicts.replace(/\{baseRefName\}/g,q.baseRefName).replace(/\{headRefName\}/g,q.headRefName))}catch{}try{let le,Pe;if(Se)le=Se.repoPath,Pe=Se.branchName;else if(ve)le=ve.path,Pe=ve.branchName;else{const He=await cc(ne,q.headRefName);le=He.worktreePath,Pe=He.branchName}const Ke=await qr({repoPath:ne,repoName:l(g).name,worktreePath:le,branchName:Pe,allowMultiple:!0});await Ut(),n.activeSessionId=Ke.id,r.activeWorkspacePath=ne,Po(Ke.id,o.defaultNotifications),pi(),setTimeout(()=>{Er(Ee+"\r")},1500)}catch(le){console.error("Failed to start conflict resolution:",le)}}function E(q){var ne;(ne=l(f))==null||ne.open(q)}function B(q){var ne;n.activeSessionId=q,Po(q,o.defaultNotifications),pi(),(ne=l(c))==null||ne.focusTerm()}function R(q){var ne;if(fetch(`/sessions/${q}`,{method:"DELETE"}).then(()=>Ut()),n.activeSessionId===q){const Se=l(k).filter(ve=>ve.id!==q);n.activeSessionId=((ne=Se[0])==null?void 0:ne.id)??null}}function P(q,ne,Se){var ve,Ee;(ve=l(h))==null||ve.show(q,ne,Se),ne||(Ee=l(h))==null||Ee.autoDismiss(3e3)}function H(q){Er(q)}function Z(){}function de(){}function be(){const q=document.createElement("input");q.type="file",q.accept="image/*",q.onchange=()=>{var Se,ve;const ne=(Se=q.files)==null?void 0:Se[0];ne&&((ve=l(c))==null||ve.handleImageUpload(ne,ne.type))},q.click()}function he(){var q;(q=l(c))==null||q.focusTerm()}function ge(q){b(N,q,!0)}function ye(){var q;(q=l(c))==null||q.exitCopyMode()}let ke=I(void 0);function ue(){var q;(q=l(ke))==null||q.open()}async function pe(q){await Ut(),q.length>0&&(r.activeWorkspacePath=q[0])}var xe=Hi(),Le=pt(xe);{var We=q=>{},ze=q=>{vg(q,{})},Ce=q=>{Fw(q,{get client(){return i},children:(ne,Se)=>{var ve=N1(),Ee=pt(ve),le=S(Ee);{var Pe=De=>{var At=O1();X("click",At,function(...ei){pi==null||pi.apply(this,ei)}),T(De,At)};ee(le,De=>{r.sidebarOpen&&De(Pe)})}var Ke=x(le,2);Ig(Ke,{onSelectSession:Y,onOpenSettings:W,onNewWorktree:O,onNewSession:De=>K(De),onNewTerminal:De=>K(De,{agent:"claude"}),onAddWorkspace:ue,onDeleteSession:R,onDeleteWorktree:E});var He=x(Ke,2),me=S(He);F0(me,{get title(){return l(D)},get onMenuClick(){return fc},get hidden(){return l(m)}});var Ie=x(me,2);{var j=De=>{B0(De,{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:ue})},ie=De=>{{let At=ce(()=>r.activeWorkspacePath??""),ei=ce(()=>{var ti;return((ti=l(g))==null?void 0:ti.name)??""});D0(De,{get workspacePath(){return l(At)},get workspaceName(){return l(ei)},onNewSession:()=>K(),onNewWorktree:()=>{l(g)&&O(l(g))},onFixConflicts:A})}},Q=De=>{var At=I1(),ei=pt(At);{let hi=ce(()=>r.activeWorkspacePath??""),Wt=ce(()=>{var Di;return((Di=l(C))==null?void 0:Di.branchName)??""});i0(ei,{get workspacePath(){return l(hi)},get branchName(){return l(Wt)},get sessionId(){return n.activeSessionId}})}var ti=x(ei,2);o0(ti,{get sessions(){return l(k)},get activeSessionId(){return n.activeSessionId},onSelectSession:Y,onCloseSession:R,onNewSession:()=>K(),onNewTerminal:()=>K(void 0,{agent:"claude"})});var Zs=x(ti,2);{var Nr=hi=>{Je(tw(hi,{get sessionId(){return n.activeSessionId},mode:"sdk",onImageUpload:P,get useTmux(){return l(F)},onCopyModeChange:ge}),Wt=>b(c,Wt,!0),()=>l(c))},Fr=hi=>{Je(e_(hi,{get sessionId(){return n.activeSessionId},onImageUpload:P,get useTmux(){return l(F)},onCopyModeChange:ge}),Wt=>b(c,Wt,!0),()=>l(c))};ee(Zs,hi=>{l(z)==="sdk"?hi(Nr):hi(Fr,!1)})}var Cs=x(Zs,2);I0(Cs,{onSendKey:H,onFlushComposedText:Z,onClearInput:de,onUploadImage:be,onRefocusMobileInput:he,get useTmux(){return l(F)},get inCopyMode(){return l(N)},onExitCopyMode:ye}),T(De,At)};ee(Ie,De=>{l(U)==="empty"?De(j):l(U)==="dashboard"?De(ie,1):l(U)==="session"&&De(Q,2)})}Je(Ee,De=>b(v,De),()=>l(v));var M=x(Ee,2);Je(Z0(M,{onSessionCreated:B}),De=>b(d,De,!0),()=>l(d));var J=x(M,2);Je(n1(J,{}),De=>b(u,De,!0),()=>l(u));var fe=x(J,2);Je(h1(fe,{}),De=>b(f,De,!0),()=>l(f));var Be=x(fe,2);Je(k1(Be,{onWorkspacesAdded:pe}),De=>b(ke,De,!0),()=>l(ke));var qe=x(Be,2);Je(A1(qe,{onRemoveWorkspace:async De=>{await fetch("/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:De})}),await Ut(),r.activeWorkspacePath===De&&(r.activeWorkspacePath=null)}}),De=>b(_,De,!0),()=>l(_));var Te=x(qe,2);z0(Te,{});var tt=x(Te,2);Je(q0(tt,{}),De=>b(h,De,!0),()=>l(h)),T(ne,ve)},$$slots:{default:!0}})};ee(Le,q=>{s.checking?q(We):s.authenticated?q(Ce,!1):q(ze,1)})}T(e,xe),Ge()}Ze(["click"]);ep(F1,{target:document.getElementById("app")});
47
+ */var YS=2,GS=1,XS=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),s=parseInt(i.getPropertyValue("height")),r=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=s-a,d=r-c-t;return{cols:Math.max(YS,Math.floor(d/e.css.cell.width)),rows:Math.max(GS,Math.floor(h/e.css.cell.height))}}},QS=O('<div class="scroll-fabs svelte-5qgfij"><button class="scroll-fab svelte-5qgfij" data-dir="up" aria-label="Page up">&#9650;</button> <button class="scroll-fab svelte-5qgfij" data-dir="down" aria-label="Page down">&#9660;</button> <button class="scroll-fab scroll-fab-bottom svelte-5qgfij" data-dir="bottom" aria-label="Skip to bottom">&#8615;</button></div>'),JS=O('<div><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 t_(e,t){je(t,!0);let i=Ut(t,"useTmux",3,!1),s=Ut(t,"companionMode",3,!1),r,n=F(null),o,a=!1;function c(){return l(n)}function h(){var K;(K=l(n))==null||K.focus()}function d(){if(!l(n))return;const K=l(n).buffer.active,te=K.viewportY>=K.baseY,Q=K.viewportY;o==null||o.fit(),te?l(n).scrollToBottom():l(n).scrollToLine(Q),Ba(l(n).cols,l(n).rows),x()}kn(()=>{const K=new VS({cursorBlink:!0,fontSize:Pt?12:14,fontFamily:"Menlo, monospace",scrollback:1e4,theme:{background:"#000000",foreground:"#d4d4d4",cursor:"#d4d4d4"}});if(o=new XS,K.loadAddon(o),K.open(r),Pt){const B=r.querySelector(".xterm-viewport");B&&(B.style.touchAction="none",B.style.overflowY="hidden");const J=r.querySelector(".xterm-screen");if(J){J.addEventListener("wheel",Le=>{Le.stopImmediatePropagation(),Le.preventDefault()},{capture:!0,passive:!1});const ue=Le=>{K.modes.mouseTrackingMode!=="none"&&Le.stopImmediatePropagation()};for(const Le of["mousedown","mouseup","mousemove"])J.addEventListener(Le,ue,{capture:!0})}}o.fit(),K.onData(B=>Er(B));{const B=/Mac|iPhone|iPad|iPod/.test(navigator.platform||"");K.attachCustomKeyEventHandler(J=>!B&&J.type==="keydown"&&J.ctrlKey&&!J.shiftKey&&!J.altKey&&!J.metaKey&&(J.key==="v"||J.key==="V")&&navigator.clipboard&&navigator.clipboard.read?(navigator.clipboard.read().then(ue=>{let Le=null,Ue=null;for(const Me of ue){for(const $e of Me.types)if($e.startsWith("image/")){Ue=$e,Le=Me;break}if(Le)break}Le&&Ue?Le.getType(Ue).then(Me=>De(Me,Ue)):navigator.clipboard.readText().then(Me=>{Me&&K.paste(Me)})}).catch(()=>{navigator.clipboard.readText&&navigator.clipboard.readText().then(ue=>{ue&&K.paste(ue)}).catch(()=>{})}),!1):!0)}K.parser.registerOscHandler(52,B=>{var Le;const J=B.indexOf(";");if(J===-1)return!0;const ue=B.slice(J+1);if(!ue||ue==="?")return!0;try{const Ue=Uint8Array.from(atob(ue),$e=>$e.charCodeAt(0)),Me=new TextDecoder("utf-8").decode(Ue);(Le=navigator.clipboard)==null||Le.writeText(Me).catch(()=>{})}catch{}return!0}),K.onScroll(x),K.onWriteParsed(x);let te=null;const Q=new ResizeObserver(()=>{te&&clearTimeout(te),te=setTimeout(()=>{const B=K.buffer.active,J=B.viewportY>=B.baseY,ue=B.viewportY;o.fit(),J?K.scrollToBottom():K.scrollToLine(ue),Ba(K.cols,K.rows),x()},Pt?150:0)});return Q.observe(r),Pt&&(document.addEventListener("touchmove",he,{passive:!1}),document.addEventListener("touchend",me),document.addEventListener("touchcancel",me)),b(n,K,!0),()=>{te&&clearTimeout(te),Z&&clearTimeout(Z),Q.disconnect(),K.dispose(),b(n,null),y=!1,u=!1,Pt&&(document.removeEventListener("touchmove",he),document.removeEventListener("touchend",me),document.removeEventListener("touchcancel",me))}}),Ci(()=>{t.sessionId&&l(n)&&!s()&&(l(n).reset(),af(t.sessionId,l(n),()=>{l(n)&&Ba(l(n).cols,l(n).rows)},()=>{}))});let u=!1,f=0,_=0,v=F(0),m=F(0),g=F(!1),y=!1,C=0,k=0,w=!1,P=0,H=0,U=F(!1),j=F(!1),Z=null,G=0,N=0;const I=500,A=10;let L=!1;function x(){L||(L=!0,requestAnimationFrame(M))}function M(){if(L=!1,!l(n))return;const K=l(n).buffer.active,te=K.baseY+l(n).rows,Q=K.viewportY,B=fe;if(!B)return;const J=B.clientHeight;if(te<=l(n).rows){b(g,!1);return}b(g,!0),b(v,Math.max(Pt?44:20,l(n).rows/te*J),!0),b(m,Q/(te-l(n).rows)*(J-l(v)))}function E(K){if(!l(n)||!fe)return;const te=fe.getBoundingClientRect(),B=l(n).buffer.active.baseY+l(n).rows;if(B<=l(n).rows)return;const J=fe.clientHeight,ue=Math.max(Pt?44:20,l(n).rows/B*J),Le=J-ue,Ue=K-te.top-ue/2,Me=Math.max(0,Math.min(1,Ue/Le)),$e=Math.round(Me*(B-l(n).rows));l(n).scrollToLine($e)}function R(K){const te=K.touches[0];te&&(u=!0,f=te.clientY,_=l(m))}function z(){var K;l(j)&&(b(j,!1),(K=t.onCopyModeChange)==null||K.call(t,!1))}function X(){var Q;if(Z=null,y=!1,navigator.vibrate&&navigator.vibrate(50),i()){b(j,!0),(Q=t.onCopyModeChange)==null||Q.call(t,!0),Er("[");return}b(U,!0);const K=r.querySelector(".xterm-screen");K&&(K.style.userSelect="text",K.style.webkitUserSelect="text"),r.querySelectorAll("canvas").forEach(B=>{B.style.pointerEvents="none"});const te=r.querySelector(".xterm-rows");if(te){const B=document.createRange();B.selectNodeContents(te);const J=window.getSelection();J==null||J.removeAllRanges(),J==null||J.addRange(B)}}function de(){var te;b(U,!1);const K=r.querySelector(".xterm-screen");K&&(K.style.userSelect="",K.style.webkitUserSelect=""),r.querySelectorAll("canvas").forEach(Q=>{Q.style.pointerEvents=""}),(te=window.getSelection())==null||te.removeAllRanges()}function Se(K){var Q;if(l(U)){const B=((Q=window.getSelection())==null?void 0:Q.toString())??"";B.trim().length>0&&(navigator.clipboard.writeText(B).catch(()=>{}),navigator.vibrate&&navigator.vibrate(30)),de();return}if(l(j)||K.target.closest(".terminal-scrollbar")||K.target.closest(".scroll-fabs")||!l(n))return;const te=K.touches[0];te&&(C=te.clientY,H=te.clientY,k=l(n).buffer.active.viewportY,w=!1,P=0,y=!0,G=te.clientX,N=te.clientY,Z&&clearTimeout(Z),Z=setTimeout(()=>{X()},I))}function he(K){const te=K.touches[0];if(te){if(u){if(!l(n)||!fe)return;K.preventDefault();const Q=te.clientY-f,J=l(n).buffer.active.baseY+l(n).rows;if(J<=l(n).rows)return;const ue=fe.clientHeight,Le=Math.max(44,l(n).rows/J*ue),Ue=ue-Le,$e=Math.max(0,Math.min(Ue,_+Q))/Ue,Ui=Math.round($e*(J-l(n).rows));l(n).scrollToLine(Ui);return}if(y&&l(n)&&!l(U)){if(Z){const B=Math.abs(te.clientX-G),J=Math.abs(te.clientY-N);(B>A||J>A)&&(clearTimeout(Z),Z=null)}if(l(n).rows===0||r.clientHeight===0)return;const Q=C-te.clientY;if(Math.abs(Q)>5){w=!0,K.preventDefault();const B=r.clientHeight/l(n).rows;if(l(n).buffer.active.type==="alternate"){const J=H-te.clientY;H=te.clientY;const ue=J/B;P+=ue;const Le=Math.trunc(P);if(Le!==0){P-=Le;const Ue=Le>0?65:64,Me=Math.max(1,Math.round(l(n).cols/2)),$e=Math.max(1,Math.round(l(n).rows/2)),Ui=`\x1B[<${Ue};${Me};${$e}M`,Ee=Math.min(Math.abs(Le),5);for(let jt=0;jt<Ee;jt++)Er(Ui)}}else{const J=Q/B,ue=l(n).buffer.active.baseY,Le=Math.max(0,Math.min(ue,Math.round(k+J)));l(n).scrollToLine(Le)}}}}}function me(){Z&&(clearTimeout(Z),Z=null),u=!1,y=!1,w=!1,P=0}function we(K){K.target!==ge&&E(K.clientY)}function xe(K){var B,J,ue;K.preventDefault();const te=K.target.closest("button");if(!te)return;const Q=te.dataset.dir;Q==="up"?(B=l(n))==null||B.scrollPages(-1):Q==="down"?(J=l(n))==null||J.scrollPages(1):Q==="bottom"&&((ue=l(n))==null||ue.scrollToBottom())}let fe,ge;async function De(K,te){var B;if(a||!t.sessionId)return;a=!0,(B=t.onImageUpload)==null||B.call(t,"Pasting image…",!1);const Q=new FileReader;Q.onload=async()=>{var ue,Le,Ue;const J=Q.result.split(",")[1];try{const Me=await Ap(t.sessionId,J,te);Me.clipboardSet?(ue=t.onImageUpload)==null||ue.call(t,"Image pasted",!1):(Le=t.onImageUpload)==null||Le.call(t,Me.path,!0,Me.path)}catch(Me){const $e=Me instanceof Error?Me.message:"Image upload failed";(Ue=t.onImageUpload)==null||Ue.call(t,$e,!1)}finally{a=!1}},Q.readAsDataURL(K)}function Be(K){var te;if((te=K.clipboardData)!=null&&te.items){for(const Q of K.clipboardData.items)if(Q.type.startsWith("image/")){K.preventDefault(),K.stopPropagation();const B=Q.getAsFile();B&&De(B,Q.type);return}}}let We=F(!1);function He(K){var te;(te=K.dataTransfer)!=null&&te.types.includes("Files")&&(K.preventDefault(),b(We,!0))}function ke(){b(We,!1)}function mt(K){var Q;if(K.preventDefault(),b(We,!1),!((Q=K.dataTransfer)!=null&&Q.files.length))return;const te=K.dataTransfer.files[0];te.type.startsWith("image/")&&De(te,te.type)}function W(K){var te;u||w||K.target.closest(".terminal-scrollbar")||l(U)||((te=l(n))==null||te.focus(),K.preventDefault())}var ne={getTerm:c,focusTerm:h,fitTerm:d,exitCopyMode:z,handleImageUpload:De},_e=JS();let be;var ye=S(_e);Qe(ye,K=>r=K,()=>r);var le=D(ye,2);Pe(le,"aria-valuenow",0);var Ie=S(le);let Ge;Qe(Ie,K=>ge=K,()=>ge),Qe(le,K=>fe=K,()=>fe);var Te=D(le,2);{var pe=K=>{var te=QS();Y("mousedown",te,xe),T(K,te)};ee(Te,K=>{Pt&&l(g)&&K(pe)})}return re(()=>{be=Ze(_e,1,"terminal-wrapper svelte-5qgfij",null,be,{"drag-over":l(We),"selection-mode":l(U)}),Ge=Or(Ie,"",Ge,{display:l(g)?"block":"none",height:l(v)+"px",top:l(m)+"px"})}),Y("touchstart",_e,function(...K){var te;(te=Pt?Se:void 0)==null||te.apply(this,K)}),Y("touchend",_e,function(...K){var te;(te=Pt?W:void 0)==null||te.apply(this,K)}),es("paste",ye,Be),es("dragover",ye,He),es("dragleave",ye,ke),es("drop",ye,mt),Y("click",le,we),Y("touchstart",Ie,R),T(e,_e),Ve(ne)}Je(["touchstart","touchend","click","mousedown"]);const ZS=3/1e6,$S=15/1e6,ey=15/1e6,ty=75/1e6,iy={sonnet:{input:ZS,output:$S},opus:{input:ey,output:ty}};function i_(e,t,i="sonnet"){const s=iy[i];return e*s.input+t*s.output}function s_(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"k":String(e)}function r_(e){return e<.005?"<$0.01":"$"+e.toFixed(2)}const Vr=Ye({}),to=Ye({}),na=Ye({}),io=Ye({});function sy(e){const t=Vr[e];if(!t||t.length===0)return[];switch(t[t.length-1].type){case"turn_completed":return["Continue","Show diff","Summarize changes"];case"error":return["Retry","Show logs","Skip"];case"agent_message":return["Continue","Thanks"];default:return[]}}function ry(e){return{get events(){return Vr[e]??[]},get activePermission(){return to[e]??null},get tokenUsage(){return na[e]??{input:0,output:0,estimatedCost:0}},get isStreaming(){return io[e]??!1},get quickReplies(){return sy(e)}}}function du(e,t){Vr[e]||(Vr[e]=[]),Vr[e].push(t),t.type==="turn_started"?io[e]=!0:(t.type==="turn_completed"||t.type==="error")&&(io[e]=!1),t.usage&&oy(e,t.usage.input_tokens,t.usage.output_tokens)}function ny(e,t){to[e]=t}function fu(e,t){const i=to[e];i&&(to[e]={...i,status:t})}function oy(e,t,i){const s=na[e]??{input:0,output:0};na[e]={input:s.input+t,output:s.output+i,estimatedCost:i_(s.input+t,s.output+i)}}function ay(e){Vr[e]=[],to[e]=null,na[e]={input:0,output:0,estimatedCost:0},io[e]=!1}function ly(e,t){io[e]=t}var hy=O('<div class="user-message svelte-1q16011"><div class="user-message-text svelte-1q16011"> </div></div>');function cy(e,t){var i=hy(),s=S(i),r=S(s);re(()=>se(r,t.text)),T(e,i)}var uy=O('<div class="agent-message svelte-1r3r7jb"><!></div>');function dy(e,t){je(t,!0);function i(n){const o=[];let a=n.replace(/```(\w*)\n([\s\S]*?)```/g,(h,d,u)=>{const f=u.trim().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),_=o.length;return o.push('<pre class="code-block"><code>'+f+"</code></pre>"),"\0CB"+_+"\0"});const c=[];return a=a.replace(/`([^`]+)`/g,(h,d)=>{const u=d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),f=c.length;return c.push('<code class="inline-code">'+u+"</code>"),"\0IC"+f+"\0"}),a=a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),a=a.replace(/^(#{1,6})\s+(.+)$/gm,(h,d,u)=>{const f=d.length;return`<h${f} class="md-heading">${u}</h${f}>`}),a=a.replace(/^---+$/gm,'<hr class="md-hr">'),a=a.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),a=a.replace(new RegExp("(?<!\\*)\\*([^*]+?)\\*(?!\\*)","g"),"<em>$1</em>"),a=a.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(h,d,u)=>/^(?:https?:\/\/|\/|\.\/|#)/.test(u)?`<a href="${u.replace(/"/g,"&quot;")}" target="_blank" rel="noopener">${d}</a>`:d),a=a.replace(/^(?:[-*])\s+(.+)$/gm,'<li class="md-li">$1</li>'),a=a.replace(/((?:<li class="md-li">.*<\/li>\n?)+)/g,'<ul class="md-ul">$1</ul>'),a=a.replace(/^\d+\.\s+(.+)$/gm,'<li class="md-li">$1</li>'),a=a.replace(/\n/g,"<br>"),a=a.replace(/<\/(pre|ul|ol|h[1-6]|hr)><br>/g,"</$1>"),a=a.replace(/<br><(pre|ul|ol|h[1-6]|hr)/g,"<$1"),a=a.replace(/\x00CB(\d+)\x00/g,(h,d)=>o[parseInt(d)]??""),a=a.replace(/\x00IC(\d+)\x00/g,(h,d)=>c[parseInt(d)]??""),a}var s=uy(),r=S(s);al(r,()=>i(t.text)),T(e,s),Ve()}var fy=O('<span class="file-dir svelte-649juz"> </span>'),_y=O('<span class="diff-add svelte-649juz"> </span>'),vy=O('<span class="diff-remove svelte-649juz"> </span>'),py=O('<div class="file-change-card svelte-649juz"><span class="file-icon svelte-649juz">&#128196;</span> <span class="file-path svelte-649juz"><!><span class="file-name svelte-649juz"> </span></span> <span class="diff-stats svelte-649juz"><!> <!></span></div>');function gy(e,t){je(t,!0);let i=Ut(t,"additions",3,0),s=Ut(t,"deletions",3,0),r=ce(()=>t.path.split("/").pop()??t.path),n=ce(()=>t.path.includes("/")?t.path.slice(0,t.path.lastIndexOf("/")+1):"");var o=py(),a=D(S(o),2),c=S(a);{var h=y=>{var C=fy(),k=S(C);re(()=>se(k,l(n))),T(y,C)};ee(c,y=>{l(n)&&y(h)})}var d=D(c),u=S(d),f=D(a,2),_=S(f);{var v=y=>{var C=_y(),k=S(C);re(()=>se(k,`+${i()??""}`)),T(y,C)};ee(_,y=>{i()&&y(v)})}var m=D(_,2);{var g=y=>{var C=vy(),k=S(C);re(()=>se(k,`-${s()??""}`)),T(y,C)};ee(m,y=>{s()&&y(g)})}re(()=>se(u,l(r))),T(e,o),Ve()}var my=O("<span> </span>"),by=O('<pre class="tool-input svelte-9tdk1v"> </pre>'),Sy=O('<div class="tool-call-card svelte-9tdk1v"><button class="tool-header svelte-9tdk1v"><span class="tool-name svelte-9tdk1v"> </span> <!> <span class="toggle-icon svelte-9tdk1v"> </span></button> <!></div>');function yy(e,t){let i=F(!1);function s(v){return v?v==="success"||v==="completed"?"status-success":v==="error"||v==="failed"?"status-error":v==="running"||v==="pending"?"status-pending":"":""}var r=Sy(),n=S(r),o=S(n),a=S(o),c=D(o,2);{var h=v=>{var m=my(),g=S(m);re(y=>{Ze(m,1,`tool-status ${y??""}`,"svelte-9tdk1v"),se(g,t.status)},[()=>s(t.status)]),T(v,m)};ee(c,v=>{t.status&&v(h)})}var d=D(c,2),u=S(d),f=D(n,2);{var _=v=>{var m=by(),g=S(m);re(y=>se(g,y),[()=>JSON.stringify(t.toolInput,null,2)]),T(v,m)};ee(f,v=>{l(i)&&t.toolInput&&v(_)})}re(()=>{se(a,t.toolName),se(u,l(i)?"▲":"▼")}),Y("click",n,()=>b(i,!l(i))),T(e,r)}Je(["click"]);var wy=O('Thinking<span class="dots svelte-fizs81">...</span>',1),Cy=O('<div class="reasoning-content svelte-fizs81" id="reasoning-content"> </div>'),ky=O('<div class="reasoning-panel svelte-fizs81"><button class="reasoning-header svelte-fizs81" aria-controls="reasoning-content"><span class="reasoning-label svelte-fizs81"><!></span> <span class="toggle-icon svelte-fizs81"> </span></button> <!></div>');function xy(e,t){let i=F(!1);var s=ky(),r=S(s),n=S(r),o=S(n);{var a=_=>{var v=Ys("Thinking");T(_,v)},c=_=>{var v=wy();T(_,v)};ee(o,_=>{l(i)?_(a):_(c,!1)})}var h=D(n,2),d=S(h),u=D(r,2);{var f=_=>{var v=Cy(),m=S(v);re(()=>se(m,t.text)),T(_,v)};ee(u,_=>{l(i)&&_(f)})}re(()=>{Pe(r,"aria-expanded",l(i)),se(d,l(i)?"▲":"▼")}),Y("click",r,()=>b(i,!l(i))),T(e,s)}Je(["click"]);var Ey=O('<button class="dismiss-btn svelte-au1iu7" aria-label="Dismiss error">&times;</button>'),Dy=O('<button class="retry-btn svelte-au1iu7">Retry</button>'),Ry=O('<div class="error-card svelte-au1iu7"><div class="error-body svelte-au1iu7"><span class="error-text svelte-au1iu7"> </span> <!></div> <!></div>');function Py(e,t){var i=Ry(),s=S(i),r=S(s),n=S(r),o=D(r,2);{var a=d=>{var u=Ey();Y("click",u,function(...f){var _;(_=t.onDismiss)==null||_.apply(this,f)}),T(d,u)};ee(o,d=>{t.onDismiss&&d(a)})}var c=D(s,2);{var h=d=>{var u=Dy();Y("click",u,function(...f){var _;(_=t.onRetry)==null||_.apply(this,f)}),T(d,u)};ee(c,d=>{t.onRetry&&d(h)})}re(()=>se(n,t.text)),T(e,i)}Je(["click"]);var Ty=O('<div class="usage-info svelte-1q2w5up"> </div>'),My=O('<div class="turn-completed svelte-1q2w5up"><div class="separator-line svelte-1q2w5up"></div> <!></div>');function By(e,t){je(t,!0);var i=My(),s=D(S(i),2);{var r=n=>{var o=Ty(),a=S(o);re((c,h)=>se(a,`${c??""} tokens · ${h??""}`),[()=>s_(t.usage.input_tokens+t.usage.output_tokens),()=>r_(i_(t.usage.input_tokens,t.usage.output_tokens))]),T(n,o)};ee(s,n=>{t.usage&&n(r)})}T(e,i),Ve()}var Ly=O('<div class="empty-state svelte-o5aojg"><p class="svelte-o5aojg">Send a message to start a conversation</p> <span class="cursor-blink svelte-o5aojg">|</span></div>'),Ay=O('<div class="session-started svelte-o5aojg"><span class="session-started-text svelte-o5aojg"> </span></div>'),Oy=O('<div class="working-indicator svelte-o5aojg"><span class="working-dot svelte-o5aojg">&#9679;</span> <span class="working-text svelte-o5aojg">Claude is working...</span></div>'),Iy=O('<div class="message-list svelte-o5aojg"><!> <!></div>'),Ny=O('<div class="chat-view svelte-o5aojg"><!></div>');function Fy(e,t){je(t,!0);let i,s=F(!0);Ci(()=>{t.events.length,l(s)&&i&&queueMicrotask(()=>{i==null||i.scrollTo({top:i.scrollHeight})})});function r(){if(!i)return;const{scrollTop:h,scrollHeight:d,clientHeight:u}=i;b(s,d-h-u<40)}var n=Ny(),o=S(n);{var a=h=>{var d=Ly();T(h,d)},c=h=>{var d=Iy(),u=S(d);vt(u,17,()=>t.events,v=>v.id??v.timestamp,(v,m)=>{var g=Wi(),y=ht(g);{var C=G=>{cy(G,{get text(){return l(m).text}})},k=G=>{dy(G,{get text(){return l(m).text}})},w=G=>{gy(G,{get path(){return l(m).path},get additions(){return l(m).additions},get deletions(){return l(m).deletions}})},P=G=>{yy(G,{get toolName(){return l(m).toolName},get toolInput(){return l(m).toolInput},get status(){return l(m).status}})},H=G=>{xy(G,{get text(){return l(m).text}})},U=G=>{Py(G,{get text(){return l(m).text},get onRetry(){return t.onRetry}})},j=G=>{By(G,{get usage(){return l(m).usage}})},Z=G=>{var N=Ay(),I=S(N),A=S(I);re(()=>se(A,l(m).text)),T(G,N)};ee(y,G=>{l(m).type==="user_message"&&l(m).text?G(C):l(m).type==="agent_message"&&l(m).text?G(k,1):l(m).type==="file_change"&&l(m).path?G(w,2):l(m).type==="tool_call"&&l(m).toolName?G(P,3):l(m).type==="reasoning"&&l(m).text?G(H,4):l(m).type==="error"&&l(m).text?G(U,5):l(m).type==="turn_completed"?G(j,6):l(m).type==="session_started"&&l(m).text&&G(Z,7)})}T(v,g)});var f=D(u,2);{var _=v=>{var m=Oy();T(v,m)};ee(f,v=>{t.isStreaming&&v(_)})}T(h,d)};ee(o,h=>{t.events.length===0?h(a):h(c,!1)})}Qe(n,h=>i=h,()=>i),es("scroll",n,r),T(e,n),Ve()}var Wy=O('<span class="send-dots svelte-mnrni5">...</span>'),Hy=ep('<svg class="send-icon svelte-mnrni5" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>'),zy=O('<div class="chat-input-container svelte-mnrni5"><textarea placeholder="Send a message..." rows="1" class="chat-textarea svelte-mnrni5"></textarea> <button aria-label="Send message"><!></button></div>');function Uy(e,t){je(t,!0);let i=Ut(t,"disabled",3,!1),s=F(""),r;function n(){const g=l(s).trim();!g||i()||(t.onSend(g),b(s,""),r&&(r.style.height="auto"))}function o(g){g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),n())}function a(){r&&(r.style.height="auto",r.style.height=Math.min(r.scrollHeight,120)+"px")}let c=ce(()=>!i()&&l(s).trim().length>0);var h=zy(),d=S(h);Qe(d,g=>r=g,()=>r);var u=D(d,2);let f;var _=S(u);{var v=g=>{var y=Wy();T(g,y)},m=g=>{var y=Hy();T(g,y)};ee(_,g=>{i()?g(v):g(m,!1)})}re(()=>{d.disabled=i(),f=Ze(u,1,"send-btn svelte-mnrni5",null,f,{disabled:!l(c)}),u.disabled=!l(c)}),Y("input",d,a),Y("keydown",d,o),Si(d,()=>l(s),g=>b(s,g)),Y("click",u,n),T(e,h),Ve()}Je(["input","keydown","click"]);var Ky=O('<button class="quick-reply-btn svelte-2y5bi6"> </button>'),qy=O('<div class="quick-replies svelte-2y5bi6" role="group" aria-label="Quick replies"></div>');function jy(e,t){je(t,!0);var i=Wi(),s=ht(i);{var r=n=>{var o=qy();vt(o,21,()=>t.suggestions,bn,(a,c)=>{var h=Ky(),d=S(h);re(()=>se(d,l(c))),Y("click",h,()=>t.onSelect(l(c))),T(a,h)}),T(n,o)};ee(s,n=>{t.suggestions.length>0&&n(r)})}T(e,i),Ve()}Je(["click"]);var Vy=O('<div class="permission-actions svelte-1amwf6m"><button class="approve-btn svelte-1amwf6m">Approve</button> <button class="deny-btn svelte-1amwf6m">Deny</button></div>'),Yy=O('<div class="permission-badge badge-approved svelte-1amwf6m">Approved &#10003;</div>'),Gy=O('<div class="permission-badge badge-denied svelte-1amwf6m">Denied &#10007;</div>'),Xy=O('<div class="permission-badge badge-timeout svelte-1amwf6m">Timed out</div>'),Qy=O('<div><div class="permission-header svelte-1amwf6m"><span class="permission-tool svelte-1amwf6m"> </span></div> <!></div>');function Jy(e,t){je(t,!0);let i=ce(()=>{const _=t.permission.input;if(t.permission.toolName==="Edit"||t.permission.toolName==="Write"){const v=_.file_path??_.path??"";return t.permission.toolName+": "+String(v)}if(t.permission.toolName==="Bash"||t.permission.toolName==="Run"){const v=_.command??_.cmd??"";return"Run: "+String(v)}return t.permission.toolName});var s=Qy();let r;var n=S(s),o=S(n),a=S(o),c=D(n,2);{var h=_=>{var v=Vy(),m=S(v),g=D(m,2);re(()=>{Pe(m,"aria-label",`Approve: ${l(i)??""}`),Pe(g,"aria-label",`Deny: ${l(i)??""}`)}),Y("click",m,()=>t.onApprove(t.permission.id)),Y("click",g,()=>t.onDeny(t.permission.id)),T(_,v)},d=_=>{var v=Yy();T(_,v)},u=_=>{var v=Gy();T(_,v)},f=_=>{var v=Xy();T(_,v)};ee(c,_=>{t.permission.status==="pending"?_(h):t.permission.status==="approved"?_(d,1):t.permission.status==="denied"?_(u,2):t.permission.status==="timed_out"&&_(f,3)})}re(()=>{r=Ze(s,1,"permission-card svelte-1amwf6m",null,r,{resolved:t.permission.status!=="pending",timed_out:t.permission.status==="timed_out"}),se(a,l(i))}),T(e,s),Ve()}Je(["click"]);var Zy=O('<div class="cost-display svelte-p9ddlc"> </div>');function $y(e,t){je(t,!0);let i=ce(()=>t.usage.input>0||t.usage.output>0?s_(t.usage.input+t.usage.output)+" tokens · "+r_(t.usage.estimatedCost):"—");var s=Zy(),r=S(s);re(()=>se(r,l(i))),T(e,s),Ve()}var ew=O('<div class="fallback-banner svelte-oor1t0">SDK mode unavailable — fell back to terminal</div>'),tw=O('<div class="session-view svelte-oor1t0"><!> <div class="tab-bar svelte-oor1t0" role="tablist"><button class="tab active svelte-oor1t0" role="tab">Chat</button></div> <div class="tab-content svelte-oor1t0"><div class="tab-panel chat-panel svelte-oor1t0"><div class="chat-scroll-area svelte-oor1t0"><!></div> <!> <!> <!> <!></div></div></div>');function iw(e,t){je(t,!0);let i=Ut(t,"mode",3,"pty"),s=Ut(t,"sdkFallback",3,!1),r=Ut(t,"useTmux",3,!1),n=F("chat"),o=F(void 0),a=F(!1),c=F(!1),h=F(!1),d=F(""),u=ce(()=>t.sessionId?ry(t.sessionId):null),f=ce(()=>()=>l(u)?l(u).events:[]);Ci(()=>{if(t.sessionId&&i()==="sdk"){ay(t.sessionId),b(d,""),b(a,!1),b(h,!1),b(n,"chat");const N={onEvent:I=>{t.sessionId&&(I.type==="tool_call"&&I.status==="pending"&&I.id&&I.toolName&&ny(t.sessionId,{id:I.id,toolName:I.toolName,input:I.toolInput??{},status:"pending"}),du(t.sessionId,I))},onTerminalData:I=>{b(c,!1),b(a,!0)},onTerminalExit:()=>{b(a,!1)},onSessionEnd:()=>{t.sessionId&&ly(t.sessionId,!1)}};hf(t.sessionId,N)}});function _(N){t.sessionId&&(b(d,N,!0),du(t.sessionId,{type:"user_message",text:N,timestamp:new Date().toISOString(),id:"user-"+Date.now()}),dg(N))}function v(N){_(N)}function m(N){t.sessionId&&fu(t.sessionId,"approved"),pc(N,!0)}function g(N){t.sessionId&&fu(t.sessionId,"denied"),pc(N,!1)}function y(){_(l(d)||"Retry")}function C(){var N;(N=l(o))==null||N.focusTerm()}function k(){var N;(N=l(o))==null||N.fitTerm()}function w(){var N;(N=l(o))==null||N.exitCopyMode()}function P(N,I){var A;(A=l(o))==null||A.handleImageUpload(N,I)}var H={focusTerm:C,fitTerm:k,exitCopyMode:w,handleImageUpload:P},U=Wi(),j=ht(U);{var Z=N=>{var I=tw(),A=S(I);{var L=fe=>{var ge=ew();T(fe,ge)};ee(A,fe=>{s()&&fe(L)})}var x=D(A,2),M=S(x);Pe(M,"aria-selected",!0);var E=D(x,2),R=S(E);let z;var X=S(R),de=S(X);{let fe=ce(()=>l(f)()),ge=ce(()=>{var De;return((De=l(u))==null?void 0:De.isStreaming)??!1});Fy(de,{get events(){return l(fe)},get isStreaming(){return l(ge)},onRetry:y})}var Se=D(X,2);{var he=fe=>{Jy(fe,{get permission(){return l(u).activePermission},onApprove:m,onDeny:g})};ee(Se,fe=>{var ge;(ge=l(u))!=null&&ge.activePermission&&l(u).activePermission.status==="pending"&&fe(he)})}var me=D(Se,2);{let fe=ce(()=>{var ge;return((ge=l(u))==null?void 0:ge.quickReplies)??[]});jy(me,{get suggestions(){return l(fe)},onSelect:v})}var we=D(me,2);{let fe=ce(()=>{var ge;return((ge=l(u))==null?void 0:ge.tokenUsage)??{input:0,output:0,estimatedCost:0}});$y(we,{get usage(){return l(fe)}})}var xe=D(we,2);{let fe=ce(()=>{var ge;return((ge=l(u))==null?void 0:ge.isStreaming)??!1});Uy(xe,{get disabled(){return l(fe)},onSend:_})}re(()=>z=Or(R,"",z,{display:l(n)==="chat"?"flex":"none"})),T(N,I)},G=N=>{{let I=ce(()=>t.onImageUpload??void 0),A=ce(()=>t.onCopyModeChange??void 0);Qe(t_(N,{get sessionId(){return t.sessionId},get onImageUpload(){return l(I)},get useTmux(){return r()},get onCopyModeChange(){return l(A)}}),L=>b(o,L,!0),()=>l(o))}};ee(j,N=>{i()==="sdk"?N(Z):N(G,!1)})}return T(e,U),Ve(H)}var Co=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(){}},sw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Bs,_h,Mu,rw=(Mu=class{constructor(){$(this,Bs,sw);$(this,_h,!1)}setTimeoutProvider(e){V(this,Bs,e)}setTimeout(e,t){return p(this,Bs).setTimeout(e,t)}clearTimeout(e){p(this,Bs).clearTimeout(e)}setInterval(e,t){return p(this,Bs).setInterval(e,t)}clearInterval(e){p(this,Bs).clearInterval(e)}},Bs=new WeakMap,_h=new WeakMap,Mu),hr=new rw;function nw(e){setTimeout(e,0)}var yn=typeof window>"u"||"Deno"in globalThis;function pi(){}function ow(e,t){return typeof e=="function"?e(t):e}function Zl(e){return typeof e=="number"&&e>=0&&e!==1/0}function n_(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Xs(e,t){return typeof e=="function"?e(t):e}function bi(e,t){return typeof e=="function"?e(t):e}function _u(e,t){const{type:i="all",exact:s,fetchStatus:r,predicate:n,queryKey:o,stale:a}=e;if(o){if(s){if(t.queryHash!==zh(o,t.options))return!1}else if(!ro(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||r&&r!==t.state.fetchStatus||n&&!n(t))}function vu(e,t){const{exact:i,status:s,predicate:r,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(i){if(so(t.options.mutationKey)!==so(n))return!1}else if(!ro(t.options.mutationKey,n))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function zh(e,t){return((t==null?void 0:t.queryKeyHashFn)||so)(e)}function so(e){return JSON.stringify(e,(t,i)=>eh(i)?Object.keys(i).sort().reduce((s,r)=>(s[r]=i[r],s),{}):i)}function ro(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>ro(e[i],t[i])):!1}var aw=Object.prototype.hasOwnProperty;function o_(e,t,i=0){if(e===t)return e;if(i>500)return t;const s=pu(e)&&pu(t);if(!s&&!(eh(e)&&eh(t)))return t;const n=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),a=o.length,c=s?new Array(a):{};let h=0;for(let d=0;d<a;d++){const u=s?d:o[d],f=e[u],_=t[u];if(f===_){c[u]=f,(s?d<n:aw.call(e,u))&&h++;continue}if(f===null||_===null||typeof f!="object"||typeof _!="object"){c[u]=_;continue}const v=o_(f,_,i+1);c[u]=v,v===f&&h++}return n===a&&h===n?e:c}function $l(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 pu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function eh(e){if(!gu(e))return!1;const t=e.constructor;if(t===void 0)return!0;const i=t.prototype;return!(!gu(i)||!i.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function gu(e){return Object.prototype.toString.call(e)==="[object Object]"}function lw(e){return new Promise(t=>{hr.setTimeout(t,e)})}function th(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?o_(e,t):t}function hw(e,t,i=0){const s=[...e,t];return i&&s.length>i?s.slice(1):s}function cw(e,t,i=0){const s=[t,...e];return i&&s.length>i?s.slice(0,-1):s}var Uh=Symbol();function a_(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Uh?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function uw(e,t,i){let s=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??(r=t()),s||(s=!0,r.aborted?i():r.addEventListener("abort",i,{once:!0})),r)}),e}var vr,Ls,en,Bu,dw=(Bu=class extends Co{constructor(){super();$(this,vr);$(this,Ls);$(this,en);V(this,en,t=>{if(!yn&&window.addEventListener){const i=()=>t();return window.addEventListener("visibilitychange",i,!1),()=>{window.removeEventListener("visibilitychange",i)}}})}onSubscribe(){p(this,Ls)||this.setEventListener(p(this,en))}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,Ls))==null||t.call(this),V(this,Ls,void 0))}setEventListener(t){var i;V(this,en,t),(i=p(this,Ls))==null||i.call(this),V(this,Ls,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){p(this,vr)!==t&&(V(this,vr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(i=>{i(t)})}isFocused(){var t;return typeof p(this,vr)=="boolean"?p(this,vr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},vr=new WeakMap,Ls=new WeakMap,en=new WeakMap,Bu),Kh=new dw;function ih(){let e,t;const i=new Promise((r,n)=>{e=r,t=n});i.status="pending",i.catch(()=>{});function s(r){Object.assign(i,r),delete i.resolve,delete i.reject}return i.resolve=r=>{s({status:"fulfilled",value:r}),e(r)},i.reject=r=>{s({status:"rejected",reason:r}),t(r)},i}var fw=nw;function _w(){let e=[],t=0,i=a=>{a()},s=a=>{a()},r=fw;const n=a=>{t?e.push(a):r(()=>{i(a)})},o=()=>{const a=e;e=[],a.length&&r(()=>{s(()=>{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=>{s=a},setScheduler:a=>{r=a}}}var Ft=_w(),tn,As,sn,Lu,vw=(Lu=class extends Co{constructor(){super();$(this,tn,!0);$(this,As);$(this,sn);V(this,sn,t=>{if(!yn&&window.addEventListener){const i=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",i,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",s)}}})}onSubscribe(){p(this,As)||this.setEventListener(p(this,sn))}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,As))==null||t.call(this),V(this,As,void 0))}setEventListener(t){var i;V(this,sn,t),(i=p(this,As))==null||i.call(this),V(this,As,t(this.setOnline.bind(this)))}setOnline(t){p(this,tn)!==t&&(V(this,tn,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return p(this,tn)}},tn=new WeakMap,As=new WeakMap,sn=new WeakMap,Lu),oa=new vw;function pw(e){return Math.min(1e3*2**e,3e4)}function l_(e){return(e??"online")==="online"?oa.isOnline():!0}var sh=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function h_(e){let t=!1,i=0,s;const r=ih(),n=()=>r.status!=="pending",o=m=>{var g;if(!n()){const y=new sh(m);f(y),(g=e.onCancel)==null||g.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},h=()=>Kh.isFocused()&&(e.networkMode==="always"||oa.isOnline())&&e.canRun(),d=()=>l_(e.networkMode)&&e.canRun(),u=m=>{n()||(s==null||s(),r.resolve(m))},f=m=>{n()||(s==null||s(),r.reject(m))},_=()=>new Promise(m=>{var g;s=y=>{(n()||h())&&m(y)},(g=e.onPause)==null||g.call(e)}).then(()=>{var m;s=void 0,n()||(m=e.onContinue)==null||m.call(e)}),v=()=>{if(n())return;let m;const g=i===0?e.initialPromise:void 0;try{m=g??e.fn()}catch(y){m=Promise.reject(y)}Promise.resolve(m).then(u).catch(y=>{var H;if(n())return;const C=e.retry??(yn?0:3),k=e.retryDelay??pw,w=typeof k=="function"?k(i,y):k,P=C===!0||typeof C=="number"&&i<C||typeof C=="function"&&C(i,y);if(t||!P){f(y);return}i++,(H=e.onFail)==null||H.call(e,i,y),lw(w).then(()=>h()?void 0:_()).then(()=>{t?f(y):v()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(s==null||s(),r),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?v():_().then(v),r)}}var pr,Au,c_=(Au=class{constructor(){$(this,pr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Zl(this.gcTime)&&V(this,pr,hr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(yn?1/0:300*1e3))}clearGcTimeout(){p(this,pr)&&(hr.clearTimeout(p(this,pr)),V(this,pr,void 0))}},pr=new WeakMap,Au),gr,rn,_i,mr,yt,ho,br,Li,ls,Ou,gw=(Ou=class extends c_{constructor(t){super();$(this,Li);$(this,gr);$(this,rn);$(this,_i);$(this,mr);$(this,yt);$(this,ho);$(this,br);V(this,br,!1),V(this,ho,t.defaultOptions),this.setOptions(t.options),this.observers=[],V(this,mr,t.client),V(this,_i,p(this,mr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,V(this,gr,bu(this.options)),this.state=t.state??p(this,gr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=p(this,yt))==null?void 0:t.promise}setOptions(t){if(this.options={...p(this,ho),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const i=bu(this.options);i.data!==void 0&&(this.setState(mu(i.data,i.dataUpdatedAt)),V(this,gr,i))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&p(this,_i).remove(this)}setData(t,i){const s=th(this.state.data,t,this.options);return ve(this,Li,ls).call(this,{data:s,type:"success",dataUpdatedAt:i==null?void 0:i.updatedAt,manual:i==null?void 0:i.manual}),s}setState(t,i){ve(this,Li,ls).call(this,{type:"setState",state:t,setStateOptions:i})}cancel(t){var s,r;const i=(s=p(this,yt))==null?void 0:s.promise;return(r=p(this,yt))==null||r.cancel(t),i?i.then(pi).catch(pi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(p(this,gr))}isActive(){return this.observers.some(t=>bi(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Uh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Xs(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:!n_(this.state.dataUpdatedAt,t)}onFocus(){var i;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(i=p(this,yt))==null||i.continue()}onOnline(){var i;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(i=p(this,yt))==null||i.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),p(this,_i).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(i=>i!==t),this.observers.length||(p(this,yt)&&(p(this,br)?p(this,yt).cancel({revert:!0}):p(this,yt).cancelRetry()),this.scheduleGc()),p(this,_i).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ve(this,Li,ls).call(this,{type:"invalidate"})}async fetch(t,i){var c,h,d,u,f,_,v,m,g,y,C,k;if(this.state.fetchStatus!=="idle"&&((c=p(this,yt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(i!=null&&i.cancelRefetch))this.cancel({silent:!0});else if(p(this,yt))return p(this,yt).continueRetry(),p(this,yt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(P=>P.options.queryFn);w&&this.setOptions(w.options)}const s=new AbortController,r=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(V(this,br,!0),s.signal)})},n=()=>{const w=a_(this.options,i),H=(()=>{const U={client:p(this,mr),queryKey:this.queryKey,meta:this.meta};return r(U),U})();return V(this,br,!1),this.options.persister?this.options.persister(w,H,this):w(H)},a=(()=>{const w={fetchOptions:i,options:this.options,queryKey:this.queryKey,client:p(this,mr),state:this.state,fetchFn:n};return r(w),w})();(h=this.options.behavior)==null||h.onFetch(a,this),V(this,rn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&ve(this,Li,ls).call(this,{type:"fetch",meta:(u=a.fetchOptions)==null?void 0:u.meta}),V(this,yt,h_({initialPromise:i==null?void 0:i.initialPromise,fn:a.fetchFn,onCancel:w=>{w instanceof sh&&w.revert&&this.setState({...p(this,rn),fetchStatus:"idle"}),s.abort()},onFail:(w,P)=>{ve(this,Li,ls).call(this,{type:"failed",failureCount:w,error:P})},onPause:()=>{ve(this,Li,ls).call(this,{type:"pause"})},onContinue:()=>{ve(this,Li,ls).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const w=await p(this,yt).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(_=(f=p(this,_i).config).onSuccess)==null||_.call(f,w,this),(m=(v=p(this,_i).config).onSettled)==null||m.call(v,w,this.state.error,this),w}catch(w){if(w instanceof sh){if(w.silent)return p(this,yt).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw ve(this,Li,ls).call(this,{type:"error",error:w}),(y=(g=p(this,_i).config).onError)==null||y.call(g,w,this),(k=(C=p(this,_i).config).onSettled)==null||k.call(C,this.state.data,w,this),w}finally{this.scheduleGc()}}},gr=new WeakMap,rn=new WeakMap,_i=new WeakMap,mr=new WeakMap,yt=new WeakMap,ho=new WeakMap,br=new WeakMap,Li=new WeakSet,ls=function(t){const i=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...u_(s.data,this.options),fetchMeta:t.meta??null};case"success":const r={...s,...mu(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return V(this,rn,t.manual?r:void 0),r;case"error":const n=t.error;return{...s,error:n,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=i(this.state),Ft.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),p(this,_i).notify({query:this,type:"updated",action:t})})},Ou);function u_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:l_(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function mu(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function bu(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,i=t!==void 0,s=i?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:i?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:i?"success":"pending",fetchStatus:"idle"}}var Jt,Fe,co,zt,Sr,nn,ds,Os,uo,on,an,yr,wr,Is,ln,qe,Un,rh,nh,oh,ah,lh,hh,ch,d_,Iu,mw=(Iu=class extends Co{constructor(t,i){super();$(this,qe);$(this,Jt);$(this,Fe);$(this,co);$(this,zt);$(this,Sr);$(this,nn);$(this,ds);$(this,Os);$(this,uo);$(this,on);$(this,an);$(this,yr);$(this,wr);$(this,Is);$(this,ln,new Set);this.options=i,V(this,Jt,t),V(this,Os,null),V(this,ds,ih()),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(p(this,Fe).addObserver(this),Su(p(this,Fe),this.options)?ve(this,qe,Un).call(this):this.updateResult(),ve(this,qe,ah).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return uh(p(this,Fe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return uh(p(this,Fe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ve(this,qe,lh).call(this),ve(this,qe,hh).call(this),p(this,Fe).removeObserver(this)}setOptions(t){const i=this.options,s=p(this,Fe);if(this.options=p(this,Jt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof bi(this.options.enabled,p(this,Fe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ve(this,qe,ch).call(this),p(this,Fe).setOptions(this.options),i._defaulted&&!$l(this.options,i)&&p(this,Jt).getQueryCache().notify({type:"observerOptionsUpdated",query:p(this,Fe),observer:this});const r=this.hasListeners();r&&yu(p(this,Fe),s,this.options,i)&&ve(this,qe,Un).call(this),this.updateResult(),r&&(p(this,Fe)!==s||bi(this.options.enabled,p(this,Fe))!==bi(i.enabled,p(this,Fe))||Xs(this.options.staleTime,p(this,Fe))!==Xs(i.staleTime,p(this,Fe)))&&ve(this,qe,rh).call(this);const n=ve(this,qe,nh).call(this);r&&(p(this,Fe)!==s||bi(this.options.enabled,p(this,Fe))!==bi(i.enabled,p(this,Fe))||n!==p(this,Is))&&ve(this,qe,oh).call(this,n)}getOptimisticResult(t){const i=p(this,Jt).getQueryCache().build(p(this,Jt),t),s=this.createResult(i,t);return Sw(this,s)&&(V(this,zt,s),V(this,nn,this.options),V(this,Sr,p(this,Fe).state)),s}getCurrentResult(){return p(this,zt)}trackResult(t,i){return new Proxy(t,{get:(s,r)=>(this.trackProp(r),i==null||i(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&p(this,ds).status==="pending"&&p(this,ds).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(t){p(this,ln).add(t)}getCurrentQuery(){return p(this,Fe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=p(this,Jt).defaultQueryOptions(t),s=p(this,Jt).getQueryCache().build(p(this,Jt),i);return s.fetch().then(()=>this.createResult(s,i))}fetch(t){return ve(this,qe,Un).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),p(this,zt)))}createResult(t,i){var Z;const s=p(this,Fe),r=this.options,n=p(this,zt),o=p(this,Sr),a=p(this,nn),h=t!==s?t.state:p(this,co),{state:d}=t;let u={...d},f=!1,_;if(i._optimisticResults){const G=this.hasListeners(),N=!G&&Su(t,i),I=G&&yu(t,s,i,r);(N||I)&&(u={...u,...u_(d.data,t.options)}),i._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:v,errorUpdatedAt:m,status:g}=u;_=u.data;let y=!1;if(i.placeholderData!==void 0&&_===void 0&&g==="pending"){let G;n!=null&&n.isPlaceholderData&&i.placeholderData===(a==null?void 0:a.placeholderData)?(G=n.data,y=!0):G=typeof i.placeholderData=="function"?i.placeholderData((Z=p(this,an))==null?void 0:Z.state.data,p(this,an)):i.placeholderData,G!==void 0&&(g="success",_=th(n==null?void 0:n.data,G,i),f=!0)}if(i.select&&_!==void 0&&!y)if(n&&_===(o==null?void 0:o.data)&&i.select===p(this,uo))_=p(this,on);else try{V(this,uo,i.select),_=i.select(_),_=th(n==null?void 0:n.data,_,i),V(this,on,_),V(this,Os,null)}catch(G){V(this,Os,G)}p(this,Os)&&(v=p(this,Os),_=p(this,on),m=Date.now(),g="error");const C=u.fetchStatus==="fetching",k=g==="pending",w=g==="error",P=k&&C,H=_!==void 0,j={status:g,fetchStatus:u.fetchStatus,isPending:k,isSuccess:g==="success",isError:w,isInitialLoading:P,isLoading:P,data:_,dataUpdatedAt:u.dataUpdatedAt,error:v,errorUpdatedAt:m,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:C,isRefetching:C&&!k,isLoadingError:w&&!H,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&H,isStale:qh(t,i),refetch:this.refetch,promise:p(this,ds),isEnabled:bi(i.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const G=j.data!==void 0,N=j.status==="error"&&!G,I=x=>{N?x.reject(j.error):G&&x.resolve(j.data)},A=()=>{const x=V(this,ds,j.promise=ih());I(x)},L=p(this,ds);switch(L.status){case"pending":t.queryHash===s.queryHash&&I(L);break;case"fulfilled":(N||j.data!==L.value)&&A();break;case"rejected":(!N||j.error!==L.reason)&&A();break}}return j}updateResult(){const t=p(this,zt),i=this.createResult(p(this,Fe),this.options);if(V(this,Sr,p(this,Fe).state),V(this,nn,this.options),p(this,Sr).data!==void 0&&V(this,an,p(this,Fe)),$l(i,t))return;V(this,zt,i);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,n=typeof r=="function"?r():r;if(n==="all"||!n&&!p(this,ln).size)return!0;const o=new Set(n??p(this,ln));return this.options.throwOnError&&o.add("error"),Object.keys(p(this,zt)).some(a=>{const c=a;return p(this,zt)[c]!==t[c]&&o.has(c)})};ve(this,qe,d_).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ve(this,qe,ah).call(this)}},Jt=new WeakMap,Fe=new WeakMap,co=new WeakMap,zt=new WeakMap,Sr=new WeakMap,nn=new WeakMap,ds=new WeakMap,Os=new WeakMap,uo=new WeakMap,on=new WeakMap,an=new WeakMap,yr=new WeakMap,wr=new WeakMap,Is=new WeakMap,ln=new WeakMap,qe=new WeakSet,Un=function(t){ve(this,qe,ch).call(this);let i=p(this,Fe).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(pi)),i},rh=function(){ve(this,qe,lh).call(this);const t=Xs(this.options.staleTime,p(this,Fe));if(yn||p(this,zt).isStale||!Zl(t))return;const s=n_(p(this,zt).dataUpdatedAt,t)+1;V(this,yr,hr.setTimeout(()=>{p(this,zt).isStale||this.updateResult()},s))},nh=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(p(this,Fe)):this.options.refetchInterval)??!1},oh=function(t){ve(this,qe,hh).call(this),V(this,Is,t),!(yn||bi(this.options.enabled,p(this,Fe))===!1||!Zl(p(this,Is))||p(this,Is)===0)&&V(this,wr,hr.setInterval(()=>{(this.options.refetchIntervalInBackground||Kh.isFocused())&&ve(this,qe,Un).call(this)},p(this,Is)))},ah=function(){ve(this,qe,rh).call(this),ve(this,qe,oh).call(this,ve(this,qe,nh).call(this))},lh=function(){p(this,yr)&&(hr.clearTimeout(p(this,yr)),V(this,yr,void 0))},hh=function(){p(this,wr)&&(hr.clearInterval(p(this,wr)),V(this,wr,void 0))},ch=function(){const t=p(this,Jt).getQueryCache().build(p(this,Jt),this.options);if(t===p(this,Fe))return;const i=p(this,Fe);V(this,Fe,t),V(this,co,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},d_=function(t){Ft.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(p(this,zt))}),p(this,Jt).getQueryCache().notify({query:p(this,Fe),type:"observerResultsUpdated"})})},Iu);function bw(e,t){return bi(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Su(e,t){return bw(e,t)||e.state.data!==void 0&&uh(e,t,t.refetchOnMount)}function uh(e,t,i){if(bi(t.enabled,e)!==!1&&Xs(t.staleTime,e)!=="static"){const s=typeof i=="function"?i(e):i;return s==="always"||s!==!1&&qh(e,t)}return!1}function yu(e,t,i,s){return(e!==t||bi(s.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&qh(e,i)}function qh(e,t){return bi(t.enabled,e)!==!1&&e.isStaleByTime(Xs(t.staleTime,e))}function Sw(e,t){return!$l(e.getCurrentResult(),t)}function wu(e){return{onFetch:(t,i)=>{var d,u,f,_,v;const s=t.options,r=(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=((v=t.state.data)==null?void 0:v.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const h=async()=>{let m=!1;const g=k=>{uw(k,()=>t.signal,()=>m=!0)},y=a_(t.options,t.fetchOptions),C=async(k,w,P)=>{if(m)return Promise.reject();if(w==null&&k.pages.length)return Promise.resolve(k);const U=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:w,direction:P?"backward":"forward",meta:t.options.meta};return g(N),N})(),j=await y(U),{maxPages:Z}=t.options,G=P?cw:hw;return{pages:G(k.pages,j,Z),pageParams:G(k.pageParams,w,Z)}};if(r&&n.length){const k=r==="backward",w=k?yw:Cu,P={pages:n,pageParams:o},H=w(s,P);a=await C(P,H,k)}else{const k=e??n.length;do{const w=c===0?o[0]??s.initialPageParam:Cu(s,a);if(c>0&&w==null)break;a=await C(a,w),c++}while(c<k)}return a};t.options.persister?t.fetchFn=()=>{var m,g;return(g=(m=t.options).persister)==null?void 0:g.call(m,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i)}:t.fetchFn=h}}}function Cu(e,{pages:t,pageParams:i}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,i[s],i):void 0}function yw(e,{pages:t,pageParams:i}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,i[0],i):void 0}var fo,Ji,It,Cr,Zi,Ps,Nu,ww=(Nu=class extends c_{constructor(t){super();$(this,Zi);$(this,fo);$(this,Ji);$(this,It);$(this,Cr);V(this,fo,t.client),this.mutationId=t.mutationId,V(this,It,t.mutationCache),V(this,Ji,[]),this.state=t.state||Cw(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){p(this,Ji).includes(t)||(p(this,Ji).push(t),this.clearGcTimeout(),p(this,It).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){V(this,Ji,p(this,Ji).filter(i=>i!==t)),this.scheduleGc(),p(this,It).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){p(this,Ji).length||(this.state.status==="pending"?this.scheduleGc():p(this,It).remove(this))}continue(){var t;return((t=p(this,Cr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,c,h,d,u,f,_,v,m,g,y,C,k,w,P,H,U;const i=()=>{ve(this,Zi,Ps).call(this,{type:"continue"})},s={client:p(this,fo),meta:this.options.meta,mutationKey:this.options.mutationKey};V(this,Cr,h_({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(j,Z)=>{ve(this,Zi,Ps).call(this,{type:"failed",failureCount:j,error:Z})},onPause:()=>{ve(this,Zi,Ps).call(this,{type:"pause"})},onContinue:i,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>p(this,It).canRun(this)}));const r=this.state.status==="pending",n=!p(this,Cr).canStart();try{if(r)i();else{ve(this,Zi,Ps).call(this,{type:"pending",variables:t,isPaused:n}),p(this,It).config.onMutate&&await p(this,It).config.onMutate(t,this,s);const Z=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,s));Z!==this.state.context&&ve(this,Zi,Ps).call(this,{type:"pending",context:Z,variables:t,isPaused:n})}const j=await p(this,Cr).start();return await((h=(c=p(this,It).config).onSuccess)==null?void 0:h.call(c,j,t,this.state.context,this,s)),await((u=(d=this.options).onSuccess)==null?void 0:u.call(d,j,t,this.state.context,s)),await((_=(f=p(this,It).config).onSettled)==null?void 0:_.call(f,j,null,this.state.variables,this.state.context,this,s)),await((m=(v=this.options).onSettled)==null?void 0:m.call(v,j,null,t,this.state.context,s)),ve(this,Zi,Ps).call(this,{type:"success",data:j}),j}catch(j){try{await((y=(g=p(this,It).config).onError)==null?void 0:y.call(g,j,t,this.state.context,this,s))}catch(Z){Promise.reject(Z)}try{await((k=(C=this.options).onError)==null?void 0:k.call(C,j,t,this.state.context,s))}catch(Z){Promise.reject(Z)}try{await((P=(w=p(this,It).config).onSettled)==null?void 0:P.call(w,void 0,j,this.state.variables,this.state.context,this,s))}catch(Z){Promise.reject(Z)}try{await((U=(H=this.options).onSettled)==null?void 0:U.call(H,void 0,j,t,this.state.context,s))}catch(Z){Promise.reject(Z)}throw ve(this,Zi,Ps).call(this,{type:"error",error:j}),j}finally{p(this,It).runNext(this)}}},fo=new WeakMap,Ji=new WeakMap,It=new WeakMap,Cr=new WeakMap,Zi=new WeakSet,Ps=function(t){const i=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=i(this.state),Ft.batch(()=>{p(this,Ji).forEach(s=>{s.onMutationUpdate(t)}),p(this,It).notify({mutation:this,type:"updated",action:t})})},Nu);function Cw(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var fs,Ai,_o,Fu,kw=(Fu=class extends Co{constructor(t={}){super();$(this,fs);$(this,Ai);$(this,_o);this.config=t,V(this,fs,new Set),V(this,Ai,new Map),V(this,_o,0)}build(t,i,s){const r=new ww({client:t,mutationCache:this,mutationId:++xo(this,_o)._,options:t.defaultMutationOptions(i),state:s});return this.add(r),r}add(t){p(this,fs).add(t);const i=No(t);if(typeof i=="string"){const s=p(this,Ai).get(i);s?s.push(t):p(this,Ai).set(i,[t])}this.notify({type:"added",mutation:t})}remove(t){if(p(this,fs).delete(t)){const i=No(t);if(typeof i=="string"){const s=p(this,Ai).get(i);if(s)if(s.length>1){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}else s[0]===t&&p(this,Ai).delete(i)}}this.notify({type:"removed",mutation:t})}canRun(t){const i=No(t);if(typeof i=="string"){const s=p(this,Ai).get(i),r=s==null?void 0:s.find(n=>n.state.status==="pending");return!r||r===t}else return!0}runNext(t){var s;const i=No(t);if(typeof i=="string"){const r=(s=p(this,Ai).get(i))==null?void 0:s.find(n=>n!==t&&n.state.isPaused);return(r==null?void 0:r.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ft.batch(()=>{p(this,fs).forEach(t=>{this.notify({type:"removed",mutation:t})}),p(this,fs).clear(),p(this,Ai).clear()})}getAll(){return Array.from(p(this,fs))}find(t){const i={exact:!0,...t};return this.getAll().find(s=>vu(i,s))}findAll(t={}){return this.getAll().filter(i=>vu(t,i))}notify(t){Ft.batch(()=>{this.listeners.forEach(i=>{i(t)})})}resumePausedMutations(){const t=this.getAll().filter(i=>i.state.isPaused);return Ft.batch(()=>Promise.all(t.map(i=>i.continue().catch(pi))))}},fs=new WeakMap,Ai=new WeakMap,_o=new WeakMap,Fu);function No(e){var t;return(t=e.options.scope)==null?void 0:t.id}var $i,Wu,xw=(Wu=class extends Co{constructor(t={}){super();$(this,$i);this.config=t,V(this,$i,new Map)}build(t,i,s){const r=i.queryKey,n=i.queryHash??zh(r,i);let o=this.get(n);return o||(o=new gw({client:t,queryKey:r,queryHash:n,options:t.defaultQueryOptions(i),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){p(this,$i).has(t.queryHash)||(p(this,$i).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const i=p(this,$i).get(t.queryHash);i&&(t.destroy(),i===t&&p(this,$i).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ft.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return p(this,$i).get(t)}getAll(){return[...p(this,$i).values()]}find(t){const i={exact:!0,...t};return this.getAll().find(s=>_u(i,s))}findAll(t={}){const i=this.getAll();return Object.keys(t).length>0?i.filter(s=>_u(t,s)):i}notify(t){Ft.batch(()=>{this.listeners.forEach(i=>{i(t)})})}onFocus(){Ft.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ft.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},$i=new WeakMap,Wu),rt,Ns,Fs,hn,cn,Ws,un,dn,Hu,f_=(Hu=class{constructor(e={}){$(this,rt);$(this,Ns);$(this,Fs);$(this,hn);$(this,cn);$(this,Ws);$(this,un);$(this,dn);V(this,rt,e.queryCache||new xw),V(this,Ns,e.mutationCache||new kw),V(this,Fs,e.defaultOptions||{}),V(this,hn,new Map),V(this,cn,new Map),V(this,Ws,0)}mount(){xo(this,Ws)._++,p(this,Ws)===1&&(V(this,un,Kh.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,rt).onFocus())})),V(this,dn,oa.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,rt).onOnline())})))}unmount(){var e,t;xo(this,Ws)._--,p(this,Ws)===0&&((e=p(this,un))==null||e.call(this),V(this,un,void 0),(t=p(this,dn))==null||t.call(this),V(this,dn,void 0))}isFetching(e){return p(this,rt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return p(this,Ns).findAll({...e,status:"pending"}).length}getQueryData(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=p(this,rt).get(t.queryHash))==null?void 0:i.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),i=p(this,rt).build(this,t),s=i.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime(Xs(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return p(this,rt).findAll(e).map(({queryKey:t,state:i})=>{const s=i.data;return[t,s]})}setQueryData(e,t,i){const s=this.defaultQueryOptions({queryKey:e}),r=p(this,rt).get(s.queryHash),n=r==null?void 0:r.state.data,o=ow(t,n);if(o!==void 0)return p(this,rt).build(this,s).setData(o,{...i,manual:!0})}setQueriesData(e,t,i){return Ft.batch(()=>p(this,rt).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,i)]))}getQueryState(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=p(this,rt).get(t.queryHash))==null?void 0:i.state}removeQueries(e){const t=p(this,rt);Ft.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=p(this,rt);return Ft.batch(()=>(i.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},s=Ft.batch(()=>p(this,rt).findAll(e).map(r=>r.cancel(i)));return Promise.all(s).then(pi).catch(pi)}invalidateQueries(e,t={}){return Ft.batch(()=>(p(this,rt).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},s=Ft.batch(()=>p(this,rt).findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let n=r.fetch(void 0,i);return i.throwOnError||(n=n.catch(pi)),r.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(pi)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const i=p(this,rt).build(this,t);return i.isStaleByTime(Xs(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(pi).catch(pi)}fetchInfiniteQuery(e){return e.behavior=wu(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(pi).catch(pi)}ensureInfiniteQueryData(e){return e.behavior=wu(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return oa.isOnline()?p(this,Ns).resumePausedMutations():Promise.resolve()}getQueryCache(){return p(this,rt)}getMutationCache(){return p(this,Ns)}getDefaultOptions(){return p(this,Fs)}setDefaultOptions(e){V(this,Fs,e)}setQueryDefaults(e,t){p(this,hn).set(so(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...p(this,hn).values()],i={};return t.forEach(s=>{ro(e,s.queryKey)&&Object.assign(i,s.defaultOptions)}),i}setMutationDefaults(e,t){p(this,cn).set(so(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...p(this,cn).values()],i={};return t.forEach(s=>{ro(e,s.mutationKey)&&Object.assign(i,s.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={...p(this,Fs).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=zh(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===Uh&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...p(this,Fs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){p(this,rt).clear(),p(this,Ns).clear()}},rt=new WeakMap,Ns=new WeakMap,Fs=new WeakMap,hn=new WeakMap,cn=new WeakMap,Ws=new WeakMap,un=new WeakMap,dn=new WeakMap,Hu);const __=Symbol("QueryClient"),Ew=()=>{const e=Qu(__);if(!e)throw new Error("No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?");return e},Dw=e=>{_v(__,e)},Rw=Symbol("isRestoring"),Pw=()=>{try{return Qu(Rw)??{current:!1}}catch{return{current:!1}}};function Tw(){return Pw()}function Mw(e){return Ew()}var Bw=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],Lw=["difference","intersection","symmetricDifference","union"],ku=!1,fn,Oi,Hs,ca,wn,v_,p_;const ua=class ua extends Set{constructor(i){super();$(this,wn);$(this,fn,new Map);$(this,Oi,F(0));$(this,Hs,F(0));$(this,ca,bs||-1);if(i){for(var s of i)super.add(s);p(this,Hs).v=super.size}ku||ve(this,wn,p_).call(this)}has(i){var s=super.has(i),r=p(this,fn),n=r.get(i);if(n===void 0){if(!s)return l(p(this,Oi)),!1;n=ve(this,wn,v_).call(this,!0),r.set(i,n)}return l(n),s}add(i){return super.has(i)||(super.add(i),b(p(this,Hs),super.size),Vs(p(this,Oi))),this}delete(i){var s=super.delete(i),r=p(this,fn),n=r.get(i);return n!==void 0&&(r.delete(i),b(n,!1)),s&&(b(p(this,Hs),super.size),Vs(p(this,Oi))),s}clear(){if(super.size!==0){super.clear();var i=p(this,fn);for(var s of i.values())b(s,!1);i.clear(),b(p(this,Hs),0),Vs(p(this,Oi))}}keys(){return this.values()}values(){return l(p(this,Oi)),super.values()}entries(){return l(p(this,Oi)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return l(p(this,Hs))}};fn=new WeakMap,Oi=new WeakMap,Hs=new WeakMap,ca=new WeakMap,wn=new WeakSet,v_=function(i){return bs===p(this,ca)?F(i):Qs(i)},p_=function(){ku=!0;var i=ua.prototype,s=Set.prototype;for(const r of Bw)i[r]=function(...n){return l(p(this,Oi)),s[r].apply(this,n)};for(const r of Lw)i[r]=function(...n){l(p(this,Oi));var o=s[r].apply(this,n);return new ua(o)}};let dh=ua;function Aw(e){const t=Array.isArray(e)?[]:{},i=new dh,s=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)&&Iw(l(h))?l(h)():l(h),set:d=>{b(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 r(n){const o=Object.keys(s),a=Object.keys(n),c=o.filter(h=>!a.includes(h));for(const h of c)delete s[h];for(const h of a)s[h]=Ow(()=>n[h])}return r(e),[s,r]}const g_=Symbol("LazyValue");function Ow(e){return e[g_]=!0,e}function Iw(e){return!!e[g_]}function Nw(e,t){switch(e){case"post":Ci(t);break;case"pre":Uv(t);break}}const Va=(e,t,i)=>{let s=!1,r=Array.isArray(e)?[]:void 0;Nw(t,()=>{const n=Array.isArray(e)?e.map(a=>a()):e();if(!s){s=!0,r=n;return}const o=Zs(()=>i(n,r));return r=n,o})};function Fw(e,t,i){const s=ce(()=>Mw()),r=Tw(),n=ce(()=>{const d=l(s).defaultQueryOptions(e());return d._optimisticResults=r.current?"isRestoring":"optimistic",d});let o=F(Ye(new t(l(s),l(n))));Va(()=>l(s),"pre",()=>{b(o,new t(l(s),l(n)),!0)});function a(){const d=l(o).getOptimisticResult(l(n));return l(n).notifyOnChangeProps?d:l(o).trackResult(d)}const[c,h]=Aw(a());return Ci(()=>{const d=r.current?()=>{}:l(o).subscribe(()=>h(a()));return l(o).updateResult(),d}),Va(()=>l(n),"pre",()=>{l(o).setOptions(l(n))}),Va(()=>[l(n),l(o)],"pre",()=>{h(a())}),c}function aa(e,t){return Fw(e,mw)}function Ww(e,t){je(t,!0);const i=Ut(t,"client",19,()=>new f_);kn(()=>{i().mount()}),Dw(i()),bp(()=>{i().unmount()});var s=Wi(),r=ht(s);ap(r,()=>t.children),T(e,s),Ve()}function m_(e){const{commitsAhead:t,prState:i,ciFailing:s,ciPending:r,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"}:s>0?{type:"fix-errors",color:"error",label:`Fix Errors ${s}/${n}`}:r>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 Hw(e,t){return e.type==="resolve-comments"?{type:"review-pr",color:"muted",label:"Review PR"}:null}function zw(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 b_(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 S_(e){return e==="success"||e==="warning"}var Uw=O('<div class="branch-error svelte-1ogsozk"> </div>'),Kw=O('<div class="branch-loading svelte-1ogsozk">Loading...</div>'),qw=O('<div class="branch-empty svelte-1ogsozk">No branches match</div>'),jw=O('<span class="branch-check svelte-1ogsozk">✓</span>'),Vw=O('<span class="branch-check branch-check--empty svelte-1ogsozk"></span>'),Yw=O('<span class="branch-spinner svelte-1ogsozk">…</span>'),Gw=O('<li role="option"><!> <span class="branch-option-name svelte-1ogsozk"> </span> <!></li>'),Xw=O('<ul class="branch-list svelte-1ogsozk"></ul>'),Qw=O('<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>'),Jw=O('<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 Zw(e,t){je(t,!0);let i=F(!1),s=F(""),r=F(null),n=F(null),o=F(null),a=F(null);const c=aa(()=>({queryKey:["branches",t.workspacePath],queryFn:()=>Eh(t.workspacePath),staleTime:3e4,enabled:l(i)}));let h=ce(()=>{const P=c.data??[];if(!l(s).trim())return P;const H=l(s).toLowerCase();return P.filter(U=>U.toLowerCase().includes(H))});function d(){b(i,!0),b(s,""),b(a,null),requestAnimationFrame(()=>{var P;return(P=l(n))==null?void 0:P.focus()})}function u(){b(i,!1),b(s,"")}async function f(P){if(P===t.currentBranch){u();return}b(o,P,!0),b(a,null);try{const H=await Mp(t.workspacePath,P);H.success?(u(),t.onSwitch(P)):b(a,H.error??"Failed to switch branch",!0)}catch{b(a,"Failed to switch branch")}finally{b(o,null)}}function _(P){l(i)&&l(r)&&document.contains(P.target)&&!l(r).contains(P.target)&&u()}function v(P){P.key==="Escape"&&l(i)&&(u(),P.stopPropagation())}var m=Jw();es("click",Xo,_);var g=S(m),y=D(S(g),2),C=S(y),k=D(g,2);{var w=P=>{var H=Qw(),U=S(H),j=S(U);Qe(j,x=>b(n,x),()=>l(n));var Z=D(U,2);{var G=x=>{var M=Uw(),E=S(M);re(()=>se(E,l(a))),T(x,M)};ee(Z,x=>{l(a)&&x(G)})}var N=D(Z,2);{var I=x=>{var M=Kw();T(x,M)},A=x=>{var M=qw();T(x,M)},L=x=>{var M=Xw();vt(M,20,()=>l(h),E=>E,(E,R)=>{var z=Gw();let X;var de=S(z);{var Se=ge=>{var De=jw();T(ge,De)},he=ge=>{var De=Vw();T(ge,De)};ee(de,ge=>{R===t.currentBranch?ge(Se):ge(he,!1)})}var me=D(de,2),we=S(me),xe=D(me,2);{var fe=ge=>{var De=Yw();T(ge,De)};ee(xe,ge=>{l(o)===R&&ge(fe)})}re(()=>{X=Ze(z,1,"branch-option svelte-1ogsozk",null,X,{"branch-current":R===t.currentBranch,"branch-switching":l(o)===R}),Pe(z,"aria-selected",R===t.currentBranch),se(we,R)}),Y("mousedown",z,()=>f(R)),T(E,z)}),T(x,M)};ee(N,x=>{c.isLoading?x(I):l(h).length===0?x(A,1):x(L,!1)})}Y("keydown",H,v),Y("keydown",j,v),Si(j,()=>l(s),x=>b(s,x)),T(P,H)};ee(k,P=>{l(i)&&P(w)})}Qe(m,P=>b(r,P),()=>l(r)),re(()=>{Pe(g,"aria-expanded",l(i)),se(C,t.currentBranch)}),Y("click",g,d),T(e,m),Ve()}Je(["click","keydown","mousedown"]);var $w=O('<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>'),e0=O('<div class="bar-middle svelte-1shtc4l" aria-label="pull request"><a class="pr-link svelte-1shtc4l" target="_blank" rel="noopener noreferrer"> <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),t0=O('<span class="bar-loading svelte-1shtc4l">…</span>'),i0=O('<button class="action-btn action-btn--secondary svelte-1shtc4l"> </button>'),s0=O("<button> </button>"),r0=O("<!> <!>",1),n0=O('<div><div class="bar-left svelte-1shtc4l"><!> <!></div> <!> <div class="bar-right svelte-1shtc4l"><!></div></div>');function o0(e,t){je(t,!0);let i=F(Ye(t.branchName));Ci(()=>{b(i,t.branchName,!0)}),Ci(()=>{!t.branchName&&t.workspacePath&&Tp(t.workspacePath).then(N=>{N&&b(i,N,!0)})});const s=aa(()=>({queryKey:["pr",t.workspacePath,l(i)],queryFn:()=>Pp(t.workspacePath,l(i)),staleTime:6e4,refetchOnWindowFocus:!0})),r=aa(()=>{var N;return{queryKey:["ci-status",t.workspacePath,l(i)],queryFn:()=>Rp(t.workspacePath,l(i)),staleTime:3e4,refetchOnWindowFocus:!0,enabled:((N=s.data)==null?void 0:N.state)==="OPEN"}});Ci(()=>{t.sessionId&&(s.refetch(),r.refetch())});let n=ce(()=>s.data??null),o=ce(()=>r.data??null),a=ce(()=>{var N,I,A,L,x,M;return{commitsAhead:l(n)?1:0,prState:l(n)?l(n).isDraft?"DRAFT":l(n).state:null,ciPassing:((N=l(o))==null?void 0:N.passing)??0,ciFailing:((I=l(o))==null?void 0:I.failing)??0,ciPending:((A=l(o))==null?void 0:A.pending)??0,ciTotal:((L=l(o))==null?void 0:L.total)??0,mergeable:((x=l(n))==null?void 0:x.mergeable)??null,unresolvedCommentCount:((M=l(n))==null?void 0:M.unresolvedCommentCount)??0}}),c=ce(()=>m_(l(a))),h=ce(()=>Hw(l(c),l(a))),d=ce(()=>b_(l(c).color)),u=ce(()=>S_(l(c).color)),f=ce(()=>l(c).type!=="none");function _(N=l(c)){var L,x,M,E;const I={branchName:l(i),baseBranch:((L=l(n))==null?void 0:L.baseRefName)??"",prNumber:((x=l(n))==null?void 0:x.number)??0,unresolvedCommentCount:((M=l(n))==null?void 0:M.unresolvedCommentCount)??0},A=zw(N,I);A!==null?t.sessionId&&Er(A+"\r"):(E=t.onArchive)==null||E.call(t)}function v(N){b(i,N,!0)}var m=n0();let g;var y=S(m),C=S(y);Zw(C,{get workspacePath(){return t.workspacePath},get currentBranch(){return l(i)},onSwitch:v});var k=D(C,2);{var w=N=>{var I=$w(),A=D(S(I),2),L=S(A);re(()=>se(L,l(n).baseRefName)),T(N,I)};ee(k,N=>{var I;(I=l(n))!=null&&I.baseRefName&&N(w)})}var P=D(y,2);{var H=N=>{var I=e0(),A=ht(I),L=S(A),x=S(L),M=D(A,2),E=S(M),R=S(E),z=D(E,2),X=S(z);re(()=>{Pe(L,"href",l(n).url),Pe(L,"aria-label",`PR #${l(n).number??""}: ${l(n).title??""}`),se(x,`PR #${l(n).number??""} `),se(R,`+${l(n).additions??""}`),se(X,`-${l(n).deletions??""}`)}),T(N,I)};ee(P,N=>{l(n)&&N(H)})}var U=D(P,2),j=S(U);{var Z=N=>{var I=t0();T(N,I)},G=N=>{var I=r0(),A=ht(I);{var L=E=>{var R=i0(),z=S(R);re(()=>{Pe(R,"aria-label",l(h).label),se(z,l(h).label)}),Y("click",R,()=>_(l(h))),T(E,R)};ee(A,E=>{l(h)&&E(L)})}var x=D(A,2);{var M=E=>{var R=s0();let z,X;var de=S(R);re(()=>{z=Ze(R,1,"action-btn svelte-1shtc4l",null,z,{"action-btn--dark-text":l(u),"action-btn--disabled":l(c).type==="checks-running"}),R.disabled=l(c).type==="checks-running",Pe(R,"aria-label",l(c).label),X=Or(R,"",X,{"--action-color":l(d)}),se(de,l(c).label)}),Y("click",R,()=>_()),T(E,R)};ee(x,E=>{l(f)&&E(M)})}T(N,I)};ee(j,N=>{s.isLoading?N(Z):N(G,!1)})}re(()=>{var N,I;return g=Ze(m,1,"pr-top-bar svelte-1shtc4l",null,g,{"bar-merged":((N=l(n))==null?void 0:N.state)==="MERGED","bar-conflicts":((I=l(n))==null?void 0:I.mergeable)==="CONFLICTING"})}),T(e,m),Ve()}Je(["click"]);var a0=O('<button role="tab"><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">×</span></button>'),l0=O('<div class="new-menu svelte-3dfyyn" role="menu" tabindex="-1"><button class="new-menu-item svelte-3dfyyn" role="menuitem"><span class="new-menu-icon svelte-3dfyyn">🤖</span> New Claude Session</button> <button class="new-menu-item svelte-3dfyyn" role="menuitem"><span class="new-menu-icon svelte-3dfyyn">🖥</span> New Terminal</button></div>'),h0=O('<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">+</button> <!></div></div>');function c0(e,t){je(t,!0);let i=F(!1),s=F(null);function r(C){return C.type==="terminal"?"🖥":"🤖"}function n(C,k){C.stopPropagation(),t.onCloseSession(k)}function o(C,k){(C.key==="Enter"||C.key===" ")&&(C.stopPropagation(),t.onCloseSession(k))}function a(){b(i,!l(i))}function c(){b(i,!1),t.onNewSession()}function h(){b(i,!1),t.onNewTerminal()}function d(C){var k;l(i)&&l(s)&&document.contains(C.target)&&!((k=l(s).closest(".new-btn-wrap"))!=null&&k.contains(C.target))&&b(i,!1)}function u(C){var k;C.key==="Escape"&&l(i)&&(b(i,!1),(k=l(s))==null||k.focus())}var f=h0();es("click",Xo,d);var _=S(f);vt(_,21,()=>t.sessions,C=>C.id,(C,k)=>{const w=ce(()=>l(k).id===t.activeSessionId);var P=a0();let H;var U=S(P),j=S(U),Z=D(U,2),G=S(Z),N=D(Z,2);re(I=>{H=Ze(P,1,"tab svelte-3dfyyn",null,H,{"tab--active":l(w)}),Pe(P,"aria-selected",l(w)),Pe(P,"aria-label",l(k).displayName||l(k).id),Pe(P,"tabindex",l(w)?0:-1),se(j,I),se(G,l(k).displayName||l(k).repoName||l(k).id),Pe(N,"aria-label",`Close ${(l(k).displayName||l(k).id)??""}`)},[()=>r(l(k))]),Y("click",P,()=>t.onSelectSession(l(k).id)),Y("click",N,I=>n(I,l(k).id)),Y("keydown",N,I=>o(I,l(k).id)),T(C,P)});var v=D(_,2),m=S(v);Qe(m,C=>b(s,C),()=>l(s));var g=D(m,2);{var y=C=>{var k=l0(),w=S(k),P=D(w,2);Y("keydown",k,u),Y("click",w,c),Y("click",P,h),T(C,k)};ee(g,C=>{l(i)&&C(y)})}re(()=>Pe(m,"aria-expanded",l(i))),Y("click",m,a),Y("keydown",m,u),T(e,f),Ve()}Je(["click","keydown"]);var u0=O('<div class="non-git-notice svelte-bvvs2r"><span class="non-git-msg svelte-bvvs2r">Not a git repository</span></div>'),d0=O('<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>'),f0=O('<div class="pr-list svelte-bvvs2r"></div>'),_0=O('<div class="section-message svelte-bvvs2r">Could not load pull requests</div>'),v0=O('<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>'),p0=O('<div class="section-message svelte-bvvs2r">No open pull requests</div>'),g0=O('<button class="pr-action-pill pr-conflict-pill svelte-bvvs2r" title="Open worktree and fix merge conflicts">Fix Conflicts</button>'),m0=O('<a class="pr-action-pill pr-merge-pill svelte-bvvs2r" target="_blank" rel="noopener noreferrer" title="Ready to merge on GitHub">Merge</a>'),b0=O('<a target="_blank" rel="noopener noreferrer"> </a>'),S0=O('<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"><!> <!> <!></div></div>'),y0=O('<div class="pr-list svelte-bvvs2r"></div>'),w0=O('<div class="activity-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-activity svelte-bvvs2r"></div></div>'),C0=O('<div class="activity-list svelte-bvvs2r"></div>'),k0=O('<div class="section-message svelte-bvvs2r">No recent commits (24h)</div>'),x0=O('<span class="commit-branch svelte-bvvs2r"> </span>'),E0=O('<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>'),D0=O('<div class="activity-list svelte-bvvs2r"></div>'),R0=O('<section class="dashboard-section svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">OPEN PULL REQUESTS</div> <!></section> <section class="dashboard-section svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">RECENT ACTIVITY</div> <!></section>',1),P0=O('<button class="cta-btn svelte-bvvs2r">+ New Worktree</button>'),T0=O('<div class="repo-dashboard svelte-bvvs2r"><!> <div class="cta-row svelte-bvvs2r"><button class="cta-btn svelte-bvvs2r">+ Start Session</button> <!></div></div>');function M0(e,t){je(t,!0);const i=aa(()=>({queryKey:["dashboard",t.workspacePath],queryFn:()=>Dp(t.workspacePath),staleTime:6e4,refetchOnWindowFocus:!0}));let s=ce(()=>i.data),r=ce(()=>i.isLoading),n=ce(()=>i.isError);function o(C){return C.state!=="OPEN"?"dot dot-muted":C.reviewDecision==="CHANGES_REQUESTED"?"dot dot-error":"dot dot-success"}function a(C){const k=C.state==="OPEN"?"OPEN":C.state==="MERGED"?"MERGED":"CLOSED";return m_({commitsAhead:1,prState:k,ciFailing:0,ciPending:0,ciTotal:0,mergeable:C.mergeable??null,unresolvedCommentCount:0})}function c(C){return C.role==="author"?"by you":"review requested"}function h(C){return!C.branches||C.branches.length===0?"":"("+C.branches.join(", ")+")"}var d=T0(),u=S(d);{var f=C=>{var k=u0();T(C,k)},_=C=>{var k=R0(),w=ht(k),P=D(S(w),2);{var H=M=>{var E=f0();vt(E,20,()=>[1,2],bn,(R,z)=>{var X=d0();T(R,X)}),T(M,E)},U=M=>{var E=_0();T(M,E)},j=M=>{var E=v0();T(M,E)},Z=M=>{var E=p0();T(M,E)},G=M=>{var E=y0();vt(E,21,()=>l(s).prs,R=>R.number,(R,z)=>{const X=ce(()=>a(l(z))),de=ce(()=>b_(l(X).color)),Se=ce(()=>S_(l(X).color));var he=S0(),me=S(he),we=S(me),xe=S(we),fe=D(xe,2),ge=S(fe),De=D(we,2),Be=S(De),We=S(Be),He=D(Be,4),ke=S(He),mt=D(He,4),W=S(mt),ne=D(me,2),_e=S(ne);{var be=Te=>{var pe=g0();Y("click",pe,()=>t.onFixConflicts(l(z))),T(Te,pe)};ee(_e,Te=>{l(z).mergeable==="CONFLICTING"&&Te(be)})}var ye=D(_e,2);{var le=Te=>{var pe=m0();re(()=>Pe(pe,"href",l(z).url)),T(Te,pe)};ee(ye,Te=>{l(z).mergeable==="MERGEABLE"&&l(z).state==="OPEN"&&Te(le)})}var Ie=D(ye,2);{var Ge=Te=>{var pe=b0();let K,te;var Q=S(pe);re(()=>{K=Ze(pe,1,"pr-action-pill svelte-bvvs2r",null,K,{"dark-text":l(Se)}),Pe(pe,"href",l(z).url),te=Or(pe,"",te,{"--pill-color":l(de)}),se(Q,l(X).label)}),T(Te,pe)};ee(Ie,Te=>{l(X).type!=="none"&&l(X).label&&Te(Ge)})}re((Te,pe,K)=>{Ze(xe,1,Te,"svelte-bvvs2r"),Pe(fe,"href",l(z).url),se(ge,l(z).title),se(We,`#${l(z).number??""}`),se(ke,pe),se(W,K)},[()=>Wd(o(l(z))),()=>c(l(z)),()=>fg(l(z).updatedAt)]),T(R,he)}),T(M,E)};ee(P,M=>{l(r)?M(H):l(n)?M(U,1):l(s)&&!l(s).hasGhCli?M(j,2):l(s)&&l(s).prs.length===0?M(Z,3):l(s)&&M(G,4)})}var N=D(w,2),I=D(S(N),2);{var A=M=>{var E=C0();vt(E,20,()=>[1,2,3],bn,(R,z)=>{var X=w0();T(R,X)}),T(M,E)},L=M=>{var E=k0();T(M,E)},x=M=>{var E=D0();vt(E,21,()=>l(s).activity,R=>R.hash,(R,z)=>{var X=E0(),de=S(X),Se=S(de),he=D(de,2),me=S(he),we=D(he,2);{var xe=De=>{var Be=x0(),We=S(Be);re(He=>se(We,He),[()=>h(l(z))]),T(De,Be)};ee(we,De=>{l(z).branches.length>0&&De(xe)})}var fe=D(we,2),ge=S(fe);re(()=>{se(Se,l(z).shortHash),se(me,l(z).message),se(ge,l(z).timeAgo)}),T(R,X)}),T(M,E)};ee(I,M=>{l(r)?M(A):l(s)&&l(s).activity.length===0?M(L,1):l(s)&&M(x,2)})}T(C,k)};ee(u,C=>{l(s)&&!l(s).isGitRepo?C(f):C(_,!1)})}var v=D(u,2),m=S(v),g=D(m,2);{var y=C=>{var k=P0();Y("click",k,function(...w){var P;(P=t.onNewWorktree)==null||P.apply(this,w)}),T(C,k)};ee(g,C=>{(!l(s)||l(s).isGitRepo)&&C(y)})}Y("click",m,function(...C){var k;(k=t.onNewSession)==null||k.apply(this,C)}),T(e,d),Ve()}Je(["click"]);var B0=O('<div class="empty-icon svelte-1luen49" aria-hidden="true"> </div>'),L0=O('<p class="empty-description svelte-1luen49"> </p>'),A0=O('<button class="empty-action svelte-1luen49"> </button>'),O0=O('<div class="empty-state svelte-1luen49"><!> <div class="empty-heading svelte-1luen49"> </div> <!> <!></div>');function I0(e,t){var i=O0(),s=S(i);{var r=u=>{var f=B0(),_=S(f);re(()=>se(_,t.icon)),T(u,f)};ee(s,u=>{t.icon&&u(r)})}var n=D(s,2),o=S(n),a=D(n,2);{var c=u=>{var f=L0(),_=S(f);re(()=>se(_,t.description)),T(u,f)};ee(a,u=>{t.description&&u(c)})}var h=D(a,2);{var d=u=>{var f=A0(),_=S(f);re(()=>se(_,t.actionLabel)),Y("click",f,function(...v){var m;(m=t.onAction)==null||m.apply(this,v)}),T(u,f)};ee(h,u=>{t.actionLabel&&t.onAction&&u(d)})}re(()=>se(o,t.heading)),T(e,i)}Je(["click"]);var N0=O("<button><!></button>"),F0=O("<button><!></button>"),W0=O('<div class="toolbar svelte-k7we1m" role="toolbar"><div class="toolbar-grid svelte-k7we1m"><!></div></div>');function H0(e,t){je(t,!0),Ut(t,"useTmux",3,!1);let i=Ut(t,"inCopyMode",3,!1);const s=[{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"}],r=[{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(),Pt&&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(),Pt&&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(),Pt&&t.onRefocusMobileInput())}function o(u){var f;t.onSendKey(u.key),u.exitsCopyMode&&((f=t.onExitCopyMode)==null||f.call(t)),Pt&&t.onRefocusMobileInput()}function a(u){u.preventDefault();const f=u.target.closest("button");if(!f)return;if(i()){const v=r.find(m=>f.dataset.key===m.key);v&&o(v);return}const _=s.find(v=>v.id===f.id||v.key&&f.dataset.key===v.key);_&&n(_)}var c=Wi(),h=ht(c);{var d=u=>{var f=W0(),_=S(f),v=S(_);{var m=y=>{var C=Wi(),k=ht(C);vt(k,17,()=>r,w=>w.label,(w,P)=>{var H=N0(),U=S(H);al(U,()=>l(P).html),re(()=>{Ze(H,1,`tb-btn ${l(P).extraClass??""??""}`,"svelte-k7we1m"),Pe(H,"data-key",l(P).key),Pe(H,"aria-label",l(P).label)}),T(w,H)}),T(y,C)},g=y=>{var C=Wi(),k=ht(C);vt(k,17,()=>s,w=>w.label,(w,P)=>{var H=F0(),U=S(H);al(U,()=>l(P).html),re(()=>{Ze(H,1,`tb-btn ${l(P).extraClass??""??""}`,"svelte-k7we1m"),Pe(H,"id",l(P).id),Pe(H,"data-key",l(P).key),Pe(H,"aria-label",l(P).label)}),T(w,H)}),T(y,C)};ee(v,y=>{i()?y(m):y(g,!1)})}Y("mousedown",f,a),T(u,f)};ee(h,u=>{Pt&&u(d)})}T(e,c),Ve()}Je(["mousedown"]);var z0=O('<div><button class="icon-btn svelte-wp0i5g" aria-label="Open sessions menu">&#9776;</button> <span class="mobile-title svelte-wp0i5g"> </span></div>');function U0(e,t){let i=Ut(t,"hidden",3,!1);var s=z0();let r;var n=S(s),o=D(n,2),a=S(o);re(()=>{r=Ze(s,1,"mobile-header svelte-wp0i5g",null,r,{hidden:i()}),se(a,t.title)}),Y("click",n,function(...c){var h;(h=t.onMenuClick)==null||h.apply(this,c)}),T(e,s)}Je(["click"]);var K0=O('<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>'),q0=O('<div class="update-toast svelte-1trivgv"><div class="update-toast-content svelte-1trivgv"><span class="update-toast-text svelte-1trivgv"> </span> <!></div></div>');function j0(e,t){je(t,!0);let i=F(!1),s=F(""),r=F("Update Now"),n=F(!1),o=F(!0);kn(async()=>{try{const f=await Kd();f.updateAvailable&&(b(s,`Update available: v${f.current} → v${f.latest}`),b(r,"Update Now"),b(n,!1),b(o,!0),b(i,!0))}catch{}});async function a(){b(n,!0),b(r,"Updating…");try{(await qd()).restarting?(b(s,"Updated! Restarting server…"),b(o,!1),setTimeout(()=>{location.reload()},5e3)):(b(s,"Updated! Please restart the server manually."),b(o,!1))}catch{b(s,"Update failed. Please try again."),b(n,!1),b(r,"Retry"),b(o,!0)}}function c(){b(i,!1)}var h=Wi(),d=ht(h);{var u=f=>{var _=q0(),v=S(_),m=S(v),g=S(m),y=D(m,2);{var C=k=>{var w=K0(),P=S(w),H=S(P),U=D(P,2);re(()=>{P.disabled=l(n),se(H,l(r))}),Y("click",P,a),Y("click",U,c),T(k,w)};ee(y,k=>{l(o)&&k(C)})}re(()=>se(g,l(s))),T(f,_)};ee(d,f=>{l(i)&&f(u)})}T(e,h),Ve()}Je(["click"]);var V0=O('<button class="image-toast-insert svelte-1y8sviv">Insert</button>'),Y0=O('<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 G0(e,t){je(t,!0);let i=F(!1),s=F(""),r=F(!1),n=F(null),o=null;function a(g,y,C){o&&(clearTimeout(o),o=null),b(s,g,!0),b(r,y,!0),b(n,C??null,!0),b(i,!0)}function c(){b(i,!1),b(n,null),o&&(clearTimeout(o),o=null)}function h(g){o&&clearTimeout(o),o=setTimeout(()=>{l(n)||c()},g)}function d(){l(n)&&Er(l(n)),c()}function u(){c()}var f={show:a,hide:c,autoDismiss:h},_=Wi(),v=ht(_);{var m=g=>{var y=Y0(),C=S(y),k=S(C),w=S(k),P=D(k,2),H=S(P);{var U=Z=>{var G=V0();Y("click",G,d),T(Z,G)};ee(H,Z=>{l(r)&&Z(U)})}var j=D(H,2);re(()=>se(w,l(s))),Y("click",j,u),T(g,y)};ee(v,g=>{l(i)&&g(m)})}return T(e,_),Ve(f)}Je(["click"]);var X0=O('<span class="dialog-title-repo svelte-thtd9b"> </span>'),Q0=O('<li class="branch-create-new svelte-thtd9b" role="option" aria-selected="false"> </li>'),J0=O('<li role="option" aria-selected="false" class="svelte-thtd9b"> </li>'),Z0=O('<ul class="branch-dropdown svelte-thtd9b"><!> <!></ul>'),$0=O('<div class="dialog-field svelte-thtd9b"><div class="dialog-label-row svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-branch">Branch name</label> <button type="button" class="branch-refresh svelte-thtd9b" aria-label="Fetch latest remote branches" title="Fetch latest remote branches"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12a8 8 0 0 1-13.66 5.66M4 12a8 8 0 0 1 13.66-5.66M17 3.5v4h-4M7 20.5v-4h4" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"></path></svg></button></div> <div class="branch-input-wrap svelte-thtd9b"><input id="ns-branch" type="text" class="dialog-input svelte-thtd9b" placeholder="e.g. feat/my-feature" autocomplete="off"/> <!></div></div>'),e1=O('<div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-continue" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-continue" class="dialog-label-inline svelte-thtd9b">Continue existing session</label></div>'),t1=O('<dialog class="dialog svelte-thtd9b"><div class="dialog-content svelte-thtd9b"><h2 class="dialog-title svelte-thtd9b"> <!></h2> <div class="dialog-tabs svelte-thtd9b"><button>Repo Session</button> <button>Worktree</button></div> <div class="dialog-body svelte-thtd9b"><div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-agent">Coding agent</label> <select id="ns-agent" class="dialog-select svelte-thtd9b"><option>Claude</option><option>Codex</option></select></div> <!> <!> <div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-yolo" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-yolo" class="dialog-label-inline svelte-thtd9b">Yolo mode (skip permission checks)</label></div> <div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-tmux" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-tmux" class="dialog-label-inline svelte-thtd9b">Launch in tmux</label></div> <div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-args">Extra args (optional)</label> <input id="ns-args" type="text" class="dialog-input svelte-thtd9b" placeholder="e.g. --verbose" autocomplete="off"/></div></div> <div class="dialog-footer svelte-thtd9b"><button class="btn btn-ghost svelte-thtd9b">Cancel</button> <button class="btn btn-primary svelte-thtd9b"> </button></div></div></dialog>');function i1(e,t){je(t,!0);let i=Ut(t,"preselectedRepo",3,null);const s=Th();let r,n=F("repos"),o=F(""),a=F(""),c=F(""),h=F(""),d=F("claude"),u=F(!1),f=F(!1),_=F(!1),v=F(Ye([])),m=F(!1),g=F(!1),y=F(!1),C=0,k=ce(()=>{if(!l(c).trim())return[];const Q=l(c).toLowerCase();return l(v).filter(B=>B.toLowerCase().includes(Q)).slice(0,10)}),w=ce(()=>l(v).some(Q=>Q===l(c)));async function P(Q,B={}){const J=++C;if(Q){B.preserveExisting||b(v,[],!0),B.refresh?b(y,!0):b(g,!0);try{const ue=await Eh(Q,B.refresh?{refresh:!0}:{});if(J!==C||Q!==l(o))return;b(v,ue,!0),l(c).trim()&&b(m,!0)}catch{if(J!==C||Q!==l(o))return;B.preserveExisting||b(v,[],!0)}finally{J===C&&(b(g,!1),b(y,!1))}}}async function H(){!l(o)||l(y)||await P(l(o),{refresh:!0,preserveExisting:!0})}function U(){C+=1,b(c,""),b(v,[],!0),b(m,!1),b(g,!1),b(y,!1)}function j(){b(m,l(c).trim().length>0)}function Z(Q){b(c,Q,!0),b(m,!1)}function G(){b(o,""),b(a,""),b(h,""),b(u,!1),b(f,!1),b(_,!1),U()}async function N(Q,B){G(),b(n,"repos"),await cf(),b(d,s.defaultAgent,!0),B!=null&&B.agent&&b(d,B.agent,!0),b(u,s.defaultYolo,!0),b(f,s.defaultContinue,!0),b(_,s.launchInTmux,!0),(B==null?void 0:B.yolo)!==void 0&&b(u,B.yolo,!0),(B==null?void 0:B.useTmux)!==void 0&&b(_,B.useTmux,!0);const J=Q??i();J&&(b(o,J.path,!0),b(a,J.name,!0),B!=null&&B.branchName&&(b(n,"worktrees"),await P(J.path))),B!=null&&B.branchName&&b(c,B.branchName,!0),B!=null&&B.claudeArgs&&b(h,B.claudeArgs,!0),r.showModal()}function I(){r.close()}async function A(){var Le,Ue;const Q=l(o);if(!Q)return;const B=l(h).trim().split(/\s+/).filter(Boolean),J=Math.max(80,Math.floor((window.innerWidth-60)/8)),ue=Math.max(24,Math.floor((window.innerHeight-120)/17));try{let Me;l(n)==="repos"?Me=await Bp({repoPath:Q,repoName:l(a)||Q.split("/").filter(Boolean).pop(),continue:l(f),yolo:l(u),claudeArgs:B.length>0?B:void 0,agent:l(d),useTmux:l(_),cols:J,rows:ue,allowMultiple:!0}):Me=await Kr({repoPath:Q,repoName:l(a)||Q.split("/").filter(Boolean).pop(),branchName:l(c).trim()||void 0,yolo:l(u),claudeArgs:B.length>0?B:void 0,agent:l(d),useTmux:l(_),cols:J,rows:ue}),r.close(),await Nt(),Me!=null&&Me.id&&((Le=t.onSessionCreated)==null||Le.call(t,Me.id))}catch(Me){if(Me instanceof Error&&"sessionId"in Me){const $e=Me;r.close(),await Nt(),$e.sessionId&&((Ue=t.onSessionCreated)==null||Ue.call(t,$e.sessionId))}}}function L(Q){Q.target===r&&r.close()}function x(Q){l(m)&&Q.key==="Escape"&&(b(m,!1),Q.stopPropagation())}var M={open:N,close:I},E=t1(),R=S(E),z=S(R),X=S(z),de=D(X);{var Se=Q=>{var B=X0(),J=S(B);re(()=>se(J,`— ${l(a)??""}`)),T(Q,B)};ee(de,Q=>{l(a)&&Q(Se)})}var he=D(z,2),me=S(he);let we;var xe=D(me,2);let fe;var ge=D(he,2),De=S(ge),Be=D(S(De),2),We=S(Be);We.value=We.__value="claude";var He=D(We);He.value=He.__value="codex";var ke=D(De,2);{var mt=Q=>{var B=$0(),J=S(B),ue=D(S(J),2),Le=S(ue);let Ue;var Me=D(J,2),$e=S(Me),Ui=D($e,2);{var Ee=Vt=>{var Ki=Z0(),$s=S(Ki);{var Nr=bt=>{var Yt=Q0(),qi=S(Yt);re(Rn=>se(qi,`Create new: ${Rn??""}`),[()=>l(c).trim()]),Y("mousedown",Yt,()=>Z(l(c).trim())),T(bt,Yt)},ks=ce(()=>!l(w)&&l(c).trim());ee($s,bt=>{l(ks)&&bt(Nr)})}var Dn=D($s,2);vt(Dn,16,()=>l(k),bt=>bt,(bt,Yt)=>{var qi=J0(),Rn=S(qi);re(()=>se(Rn,Yt)),Y("mousedown",qi,()=>Z(Yt)),T(bt,qi)}),T(Vt,Ki)},jt=ce(()=>l(m)&&(l(k).length>0||l(c).trim()&&!l(w)));ee(Ui,Vt=>{l(jt)&&Vt(Ee)})}re(()=>{ue.disabled=!l(o)||l(g)||l(y),Ue=Ze(Le,0,"svelte-thtd9b",null,Ue,{spinning:l(g)||l(y)})}),Y("click",ue,H),Y("input",$e,j),es("focus",$e,()=>{l(c).trim()&&b(m,!0)}),Si($e,()=>l(c),Vt=>b(c,Vt)),T(Q,B)};ee(ke,Q=>{l(n)==="worktrees"&&Q(mt)})}var W=D(ke,2);{var ne=Q=>{var B=e1(),J=S(B);Ii(J,()=>l(f),ue=>b(f,ue)),T(Q,B)};ee(W,Q=>{l(n)==="repos"&&Q(ne)})}var _e=D(W,2),be=S(_e),ye=D(_e,2),le=S(ye),Ie=D(ye,2),Ge=D(S(Ie),2),Te=D(ge,2),pe=S(Te),K=D(pe,2),te=S(K);return Qe(E,Q=>r=Q,()=>r),re(()=>{se(X,`${l(n)==="repos"?"New Session":"New Worktree"} `),we=Ze(me,1,"dialog-tab svelte-thtd9b",null,we,{active:l(n)==="repos"}),fe=Ze(xe,1,"dialog-tab svelte-thtd9b",null,fe,{active:l(n)==="worktrees"}),K.disabled=!l(o),se(te,l(n)==="repos"?"Start Session":"Create Worktree")}),Y("click",E,L),Y("keydown",E,x),Y("click",me,()=>{b(n,"repos")}),Y("click",xe,()=>{b(n,"worktrees"),l(o)&&l(v).length===0&&P(l(o))}),Qo(Be,()=>l(d),Q=>b(d,Q)),Ii(be,()=>l(u),Q=>b(u,Q)),Ii(le,()=>l(_),Q=>b(_,Q)),Si(Ge,()=>l(h),Q=>b(h,Q)),Y("click",pe,()=>r.close()),Y("click",K,A),T(e,E),Ve(M)}Je(["click","keydown","input","mousedown"]);var s1=O('<p class="error-msg svelte-fdtoa4"> </p>'),r1=O('<span class="version-status svelte-fdtoa4">Up to date</span>'),n1=O('<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>'),o1=O('<button class="btn btn-ghost btn-sm svelte-fdtoa4"> </button>'),a1=O('<p class="version-status-msg svelte-fdtoa4"> </p>'),l1=O('<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">Session Defaults</h3> <p class="section-desc svelte-fdtoa4">Default options for new sessions. Override per-session via Customize.</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">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 h1(e,t){je(t,!0);let i,s=F(!1);const r=Th();let n=F(""),o=F(""),a=F(null),c=F(!1),h=F(!1),d=F(!1),u=F(!1),f=F("");async function _(){b(n,""),b(f,""),b(h,!1),b(u,!1),b(s,localStorage.getItem("devtools-enabled")==="true"),await cf(),i.showModal(),w()}function v(){i.close()}async function m(){const B=r.defaultAgent;b(n,"");try{await Ip(r.defaultAgent)}catch{r.defaultAgent=B,b(n,"Failed to update default agent.")}}async function g(){const B=r.defaultContinue;b(n,"");try{await Fp(r.defaultContinue)}catch{r.defaultContinue=B,b(n,"Failed to update continue default.")}}async function y(){const B=r.defaultYolo;b(n,"");try{await Hp(r.defaultYolo)}catch{r.defaultYolo=B,b(n,"Failed to update yolo default.")}}async function C(){const B=r.launchInTmux;b(n,"");try{await Up(r.launchInTmux)}catch(J){r.launchInTmux=B,b(n,J instanceof Error?J.message:"Failed to update tmux setting.",!0)}}async function k(){const B=r.defaultNotifications;b(n,"");try{await qp(r.defaultNotifications)}catch{r.defaultNotifications=B,b(n,"Failed to update notifications default.")}}async function w(){b(d,!0),b(f,"");try{const B=await Kd();b(o,B.current,!0),b(a,B.latest,!0),b(c,B.updateAvailable,!0),b(h,!0)}catch{b(f,"Failed to check for updates.")}finally{b(d,!1)}}async function P(){b(u,!0),b(f,"");try{(await qd()).restarting?(b(f,"Updated! Restarting server…"),setTimeout(()=>{location.reload()},5e3)):b(f,"Updated! Please restart the server manually."),b(c,!1)}catch{b(f,"Update failed. Please try again."),b(u,!1)}}function H(){localStorage.setItem("devtools-enabled",l(s)?"true":"false"),window.dispatchEvent(new Event("devtools-changed"))}async function U(){i.close(),await Nt()}function j(B){B.target===i&&U()}var Z={open:_,close:v},G=l1(),N=S(G),I=S(N),A=D(S(I),2),L=D(I,2),x=S(L);{var M=B=>{var J=s1(),ue=S(J);re(()=>se(ue,l(n))),T(B,J)};ee(x,B=>{l(n)&&B(M)})}var E=D(x,2),R=D(S(E),4),z=S(R);z.value=z.__value="claude";var X=D(z);X.value=X.__value="codex";var de=D(E,2),Se=D(S(de),4),he=S(Se),me=D(Se,2),we=S(me),xe=D(me,2),fe=S(xe),ge=D(xe,2),De=S(ge),Be=D(de,2),We=D(S(Be),2),He=S(We),ke=D(Be,2),mt=D(S(ke),2),W=S(mt),ne=S(W);{var _e=B=>{var J=Ys();re(()=>se(J,`v${l(o)??""}`)),T(B,J)},be=B=>{var J=Ys("...");T(B,J)};ee(ne,B=>{l(o)?B(_e):B(be,!1)})}var ye=D(W,2);{var le=B=>{var J=r1();T(B,J)};ee(ye,B=>{l(h)&&!l(c)&&!l(u)&&B(le)})}var Ie=D(mt,2);{var Ge=B=>{var J=n1(),ue=S(J),Le=S(ue),Ue=D(ue,2),Me=S(Ue);re(()=>{se(Le,`v${l(o)??""} → v${l(a)??""}`),Ue.disabled=l(u),se(Me,l(u)?"Updating…":"Update Now")}),Y("click",Ue,P),T(B,J)},Te=B=>{var J=o1(),ue=S(J);re(()=>{J.disabled=l(d),se(ue,l(d)?"Checking…":"Check for updates")}),Y("click",J,w),T(B,J)};ee(Ie,B=>{l(c)?B(Ge):l(h)||B(Te,1)})}var pe=D(Ie,2);{var K=B=>{var J=a1(),ue=S(J);re(()=>se(ue,l(f))),T(B,J)};ee(pe,B=>{l(f)&&B(K)})}var te=D(L,2),Q=S(te);return Qe(G,B=>i=B,()=>i),Y("click",G,j),Y("click",A,U),Y("change",R,m),Qo(R,()=>r.defaultAgent,B=>r.defaultAgent=B),Y("change",he,g),Ii(he,()=>r.defaultContinue,B=>r.defaultContinue=B),Y("change",we,y),Ii(we,()=>r.defaultYolo,B=>r.defaultYolo=B),Y("change",fe,C),Ii(fe,()=>r.launchInTmux,B=>r.launchInTmux=B),Y("change",De,k),Ii(De,()=>r.defaultNotifications,B=>r.defaultNotifications=B),Y("change",He,H),Ii(He,()=>l(s),B=>b(s,B)),Y("click",Q,U),T(e,G),Ve(Z)}Je(["click","change"]);var c1=O('<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),u1=O('<p class="error-msg svelte-15sco2n"> </p>'),d1=O('<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 f1(e,t){je(t,!0);let i,s=F(null),r=F(""),n=F(!1);function o(U){b(s,U,!0),b(r,""),b(n,!1),i.showModal()}function a(){i.close()}async function c(){if(!(!l(s)||l(n))){b(n,!0),b(r,""),hg(l(s).path);try{await Ud(l(s).path,l(s).repoPath),i.close(),await Nt()}catch(U){b(r,U instanceof Error?U.message:"Failed to delete worktree.",!0),b(n,!1)}finally{l(s)&&cg(l(s).path)}}}function h(){i.close()}function d(U){U.target===i&&i.close()}var u={open:o,close:a},f=d1(),_=S(f),v=D(S(_),2),m=S(v);{var g=U=>{var j=c1(),Z=ht(j),G=D(S(Z)),N=S(G),I=D(Z,2),A=S(I);re(()=>{se(N,l(s).displayName||l(s).name),se(A,l(s).path)}),T(U,j)};ee(m,U=>{l(s)&&U(g)})}var y=D(m,2);{var C=U=>{var j=u1(),Z=S(j);re(()=>se(Z,l(r))),T(U,j)};ee(y,U=>{l(r)&&U(C)})}var k=D(v,2),w=S(k),P=D(w,2),H=S(P);return Qe(f,U=>i=U,()=>i),re(()=>{w.disabled=l(n),P.disabled=l(n),se(H,l(n)?"Deleting...":"Delete")}),Y("click",f,d),Y("click",w,h),Y("click",P,c),T(e,f),Ve(u)}Je(["click"]);var _1=O('<div class="loading-placeholder svelte-15gfcbp">Loading...</div>'),v1=O('<div class="empty-placeholder svelte-15gfcbp"><!></div>'),p1=O('<span class="spinner svelte-15gfcbp">...</span>'),g1=O("<span>&#9654;</span>"),m1=O('<button class="expand-btn svelte-15gfcbp"><!></button>'),b1=O('<span class="expand-spacer svelte-15gfcbp"></span>'),S1=O('<span class="git-badge svelte-15gfcbp" aria-label="Git repository">git</span>'),y1=O('<div role="treeitem"><!> <input type="checkbox" class="node-checkbox svelte-15gfcbp"/> <span class="node-name svelte-15gfcbp"> </span> <!></div>'),w1=O('<div class="truncated-notice svelte-15gfcbp"> </div>'),C1=O("<!> <!>",1),k1=O('<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 x1(e,t){je(t,!0);let i=Ut(t,"selectedPaths",31,()=>Ye([])),s=F(Ye([])),r=F(""),n=F(-1),o=F(!0),a=F(null),c=F(void 0);kn(()=>{h()});async function h(){b(o,!0),b(a,null);try{const E=await hc();b(s,E.entries.map(R=>d(R,0)),!0),E.truncated&&b(a,{shown:E.entries.length,total:E.total},!0)}catch{b(s,[],!0)}finally{b(o,!1)}}function d(E,R){return{name:E.name,path:E.path,isGitRepo:E.isGitRepo,hasChildren:E.hasChildren,children:null,expanded:!1,selected:!1,loading:!1,depth:R,truncatedInfo:null}}async function u(E){if(E.expanded){E.expanded=!1;return}if(E.children===null){E.loading=!0;try{const R=await hc(E.path);E.children=R.entries.map(z=>d(z,E.depth+1)),E.truncatedInfo=R.truncated?{shown:R.entries.length,total:R.total}:null}catch{E.children=[]}finally{E.loading=!1}}E.expanded=!0}function f(E){E.selected=!E.selected,_()}function _(){i(v(l(s)))}function v(E){const R=[];for(const z of E)z.selected&&R.push(z.path),z.children&&R.push(...v(z.children));return R}function m(E,R){return E.toLowerCase().includes(R.toLowerCase())}function g(E,R){var z;return!!(!R||E.expanded||m(E.name,R)||(z=E.children)!=null&&z.some(X=>g(X,R)))}function y(E,R){const z=[];for(const X of E)g(X,R)&&(z.push(X),X.expanded&&X.children&&z.push(...y(X.children,R)));return z}let C=ce(()=>y(l(s),l(r)));function k(E){var z;if(E.key==="ArrowDown"){E.preventDefault(),b(n,Math.min(l(n)+1,l(C).length-1),!0);return}if(E.key==="ArrowUp"){E.preventDefault(),b(n,Math.max(l(n)-1,0),!0);return}const R=l(n)>=0?l(C)[l(n)]:void 0;if(R){if(E.key==="ArrowRight"){if(E.preventDefault(),R.hasChildren&&!R.expanded)u(R);else if(R.expanded&&((z=R.children)!=null&&z.length)){const X=l(C).indexOf(R.children[0]);X>=0&&b(n,X,!0)}return}if(E.key==="ArrowLeft"){if(E.preventDefault(),R.expanded)R.expanded=!1;else{const X=R.depth-1;for(let de=l(n)-1;de>=0;de--)if(l(C)[de].depth===X){b(n,de,!0);break}}return}if(E.key===" "){E.preventDefault(),f(R);return}}}function w(E,R){const z=R.target;z.closest(".expand-btn")||z.closest(".node-checkbox")||(E.hasChildren&&!E.expanded?u(E):f(E))}function P(){b(r,""),b(n,-1),H(l(s)),i([]),U(l(s))}function H(E){for(const R of E)R.selected=!1,R.children&&H(R.children)}function U(E){for(const R of E)R.expanded=!1,R.children&&U(R.children)}var j={reset:P},Z=k1(),G=S(Z),N=S(G),I=D(G,2),A=S(I);{var L=E=>{var R=_1();T(E,R)},x=E=>{var R=v1(),z=S(R);{var X=Se=>{var he=Ys();re(()=>se(he,`No matches for "${l(r)??""}"`)),T(Se,he)},de=Se=>{var he=Ys("No directories found");T(Se,he)};ee(z,Se=>{l(r)?Se(X):Se(de,!1)})}T(E,R)},M=E=>{var R=C1(),z=ht(R);vt(z,19,()=>l(C),Se=>Se.path,(Se,he,me)=>{var we=y1();let xe;var fe=S(we);{var ge=W=>{var ne=m1(),_e=S(ne);{var be=le=>{var Ie=p1();T(le,Ie)},ye=le=>{var Ie=g1();let Ge;re(()=>Ge=Ze(Ie,1,"arrow svelte-15gfcbp",null,Ge,{expanded:l(he).expanded})),T(le,Ie)};ee(_e,le=>{l(he).loading?le(be):le(ye,!1)})}re(()=>Pe(ne,"aria-label",l(he).expanded?"Collapse":"Expand")),Y("click",ne,()=>u(l(he))),T(W,ne)},De=W=>{var ne=b1();T(W,ne)};ee(fe,W=>{l(he).hasChildren?W(ge):W(De,!1)})}var Be=D(fe,2),We=D(Be,2),He=S(We),ke=D(We,2);{var mt=W=>{var ne=S1();T(W,ne)};ee(ke,W=>{l(he).isGitRepo&&W(mt)})}re(()=>{xe=Ze(we,1,"tree-row svelte-15gfcbp",null,xe,{focused:l(me)===l(n),selected:l(he).selected}),Or(we,`padding-left: ${12+l(he).depth*20}px`),Pe(we,"aria-expanded",l(he).hasChildren?l(he).expanded:void 0),Pe(we,"aria-selected",l(he).selected),Pe(we,"aria-level",l(he).depth+1),pp(Be,l(he).selected),Pe(Be,"aria-label",`Select ${l(he).name??""}`),se(He,l(he).name)}),Y("click",we,W=>w(l(he),W)),Y("change",Be,()=>f(l(he))),Y("click",Be,W=>W.stopPropagation()),T(Se,we)});var X=D(z,2);{var de=Se=>{var he=w1(),me=S(he);re(()=>se(me,`Showing ${l(a).shown??""} of ${l(a).total??""} directories. Use the filter to narrow results.`)),T(Se,he)};ee(X,Se=>{l(a)&&Se(de)})}T(E,R)};ee(A,E=>{l(o)?E(L):l(C).length===0?E(x,1):E(M,!1)})}return Qe(I,E=>b(c,E),()=>l(c)),Si(N,()=>l(r),E=>b(r,E)),Y("keydown",I,k),T(e,Z),Ve(j)}Je(["keydown","click","change"]);var E1=O('<p class="error-msg svelte-4yj2yx"> </p>'),D1=O('<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 R1(e,t){je(t,!0);let i,s=F(void 0),r=F(Ye([])),n=F(""),o=F(!1);function a(){var L;b(r,[],!0),b(n,""),b(o,!1),(L=l(s))==null||L.reset(),i.showModal()}function c(){i.close()}async function h(){if(l(r).length!==0){b(o,!0),b(n,"");try{const L=await Ep(l(r));if(L.errors.length>0&&L.added.length===0){b(n,L.errors.map(x=>`${x.path}: ${x.error}`).join("; "),!0),b(o,!1);return}L.added.length>0&&t.onWorkspacesAdded(L.added.map(x=>x.path)),L.errors.length>0&&console.warn("Some workspaces failed to add:",L.errors),c()}catch{b(n,"Failed to add workspaces.")}finally{b(o,!1)}}}function d(L){L.target===i&&c()}var u={open:a,close:c},f=D1(),_=S(f),v=S(_),m=D(S(v),2),g=D(v,2),y=D(S(g),2);Qe(x1(y,{get selectedPaths(){return l(r)},set selectedPaths(L){b(r,L,!0)}}),L=>b(s,L,!0),()=>l(s));var C=D(y,2);{var k=L=>{var x=E1(),M=S(x);re(()=>se(M,l(n))),T(L,x)};ee(C,L=>{l(n)&&L(k)})}var w=D(g,2),P=S(w),H=S(P);{var U=L=>{var x=Ys();re(()=>se(x,`${l(r).length??""} selected`)),T(L,x)};ee(H,L=>{l(r).length>0&&L(U)})}var j=D(P,2),Z=S(j),G=D(Z,2),N=S(G);{var I=L=>{var x=Ys("Adding...");T(L,x)},A=L=>{var x=Ys();re(()=>se(x,`Add Workspace${l(r).length>1?"s":""}`)),T(L,x)};ee(N,L=>{l(o)?L(I):L(A,!1)})}return Qe(f,L=>i=L,()=>i),re(()=>G.disabled=l(r).length===0||l(o)),Y("click",f,d),Y("click",m,c),Y("click",Z,c),Y("click",G,h),T(e,f),Ve(u)}Je(["click"]);var P1=O('<p class="error-msg svelte-1n78dcx"> </p>'),T1=O("<option> </option>"),M1=O("<option> </option>"),B1=O('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. focus on security, error handling"></textarea>'),L1=O('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. include test plan section"></textarea>'),A1=O('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. prefix with dy/, use conventional commits style"></textarea>'),O1=O('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. use TypeScript, follow CLAUDE.md"></textarea>'),I1=O('<span class="save-success svelte-1n78dcx">Saved</span>'),N1=O('<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 F1(e,t){je(t,!0);let i,s=F(""),r=F(""),n=F(!1),o=F(""),a=F(!1),c=F(Ye([])),h=F(""),d=F(""),u=F(""),f=F("claude"),_=F(!1),v=F(!1),m=F(!1),g=F(""),y=F(""),C=F(""),k=F(""),w=F(!1),P=F(!1),H=F(!1),U=F(!1);async function j(oe,Ke){b(s,oe,!0),b(r,Ke,!0),b(o,""),b(a,!1),b(n,!1),b(h,""),b(d,""),b(u,""),b(f,"claude"),b(_,!1),b(v,!1),b(m,!1),b(g,""),b(y,""),b(C,""),b(k,""),i.showModal();try{const[St,Fr]=await Promise.all([ll(oe),Eh(oe).catch(()=>[])]);b(c,Fr,!0),G(St)}catch{b(o,"Failed to load workspace settings.")}}function Z(){i.close()}function G(oe){b(h,oe.defaultBranch??"",!0),b(d,oe.remote??"",!0),b(u,oe.branchPrefix??"",!0),b(f,oe.defaultAgent??"claude",!0),b(_,oe.defaultContinue??!1,!0),b(v,oe.defaultYolo??!1,!0),b(m,oe.launchInTmux??!1,!0),b(g,oe.promptCodeReview??"",!0),b(y,oe.promptCreatePr??"",!0),b(C,oe.promptBranchRename??"",!0),b(k,oe.promptGeneral??"",!0)}async function N(){b(n,!0),b(o,""),b(a,!1);try{const oe={defaultAgent:l(f),defaultContinue:l(_),defaultYolo:l(v),launchInTmux:l(m)};l(h)&&(oe.defaultBranch=l(h)),l(d)&&(oe.remote=l(d)),l(u)&&(oe.branchPrefix=l(u)),l(g)&&(oe.promptCodeReview=l(g)),l(y)&&(oe.promptCreatePr=l(y)),l(C)&&(oe.promptBranchRename=l(C)),l(k)&&(oe.promptGeneral=l(k)),await Vp(l(s),oe),b(a,!0),setTimeout(()=>{b(a,!1)},2e3)}catch(oe){b(o,oe instanceof Error?oe.message:"Failed to save settings.",!0)}finally{b(n,!1)}}function I(){i.close(),t.onRemoveWorkspace(l(s))}function A(oe){oe.target===i&&i.close()}var L={open:j,close:Z},x=N1(),M=S(x),E=S(M),R=S(E),z=D(S(R)),X=D(R,2),de=D(E,2),Se=S(de);{var he=oe=>{var Ke=P1(),St=S(Ke);re(()=>se(St,l(o))),T(oe,Ke)};ee(Se,oe=>{l(o)&&oe(he)})}var me=D(Se,2),we=D(S(me),2),xe=D(S(we),2),fe=S(xe);fe.value=fe.__value="";var ge=D(fe);vt(ge,17,()=>l(c),bn,(oe,Ke)=>{var St=T1(),Fr=S(St),Gh={};re(()=>{se(Fr,l(Ke)),Gh!==(Gh=l(Ke))&&(St.value=(St.__value=l(Ke))??"")}),T(oe,St)});var De=D(ge);{var Be=oe=>{var Ke=M1(),St=S(Ke),Fr={};re(()=>{se(St,l(h)),Fr!==(Fr=l(h))&&(Ke.value=(Ke.__value=l(h))??"")}),T(oe,Ke)},We=ce(()=>l(h)&&!l(c).includes(l(h)));ee(De,oe=>{l(We)&&oe(Be)})}var He=D(we,2),ke=D(S(He),2),mt=D(He,2),W=D(S(mt),2),ne=D(me,4),_e=D(S(ne),2),be=D(S(_e),2),ye=S(be);ye.value=ye.__value="claude";var le=D(ye);le.value=le.__value="codex";var Ie=D(_e,2),Ge=S(Ie),Te=S(Ge),pe=D(Ge,2),K=S(pe),te=D(pe,2),Q=S(te),B=D(ne,4),J=D(S(B),2),ue=S(J),Le=S(ue),Ue=S(Le),Me=D(ue,2);{var $e=oe=>{var Ke=B1();Pe(Ke,"rows",3),Si(Ke,()=>l(g),St=>b(g,St)),T(oe,Ke)};ee(Me,oe=>{l(w)&&oe($e)})}var Ui=D(J,2),Ee=S(Ui),jt=S(Ee),Vt=S(jt),Ki=D(Ee,2);{var $s=oe=>{var Ke=L1();Pe(Ke,"rows",3),Si(Ke,()=>l(y),St=>b(y,St)),T(oe,Ke)};ee(Ki,oe=>{l(P)&&oe($s)})}var Nr=D(Ui,2),ks=S(Nr),Dn=S(ks),bt=S(Dn),Yt=D(ks,2);{var qi=oe=>{var Ke=A1();Pe(Ke,"rows",3),Si(Ke,()=>l(C),St=>b(C,St)),T(oe,Ke)};ee(Yt,oe=>{l(H)&&oe(qi)})}var Rn=D(Nr,2),ko=S(Rn),y_=S(ko),w_=S(y_),C_=D(ko,2);{var k_=oe=>{var Ke=O1();Pe(Ke,"rows",3),Si(Ke,()=>l(k),St=>b(k,St)),T(oe,Ke)};ee(C_,oe=>{l(U)&&oe(k_)})}var x_=D(de,2),Vh=S(x_),E_=D(Vh,2),Yh=S(E_);{var D_=oe=>{var Ke=I1();T(oe,Ke)};ee(Yh,oe=>{l(a)&&oe(D_)})}var ka=D(Yh,2),R_=S(ka);return Qe(x,oe=>i=oe,()=>i),re(()=>{se(z,` ${l(r)??""}`),Pe(ue,"aria-expanded",l(w)),se(Ue,l(w)?"▾":"▸"),Pe(Ee,"aria-expanded",l(P)),se(Vt,l(P)?"▾":"▸"),Pe(ks,"aria-expanded",l(H)),se(bt,l(H)?"▾":"▸"),Pe(ko,"aria-expanded",l(U)),se(w_,l(U)?"▾":"▸"),ka.disabled=l(n),se(R_,l(n)?"Saving…":"Save")}),Y("click",x,A),Y("click",X,()=>i.close()),Qo(xe,()=>l(h),oe=>b(h,oe)),Si(ke,()=>l(d),oe=>b(d,oe)),Si(W,()=>l(u),oe=>b(u,oe)),Qo(be,()=>l(f),oe=>b(f,oe)),Ii(Te,()=>l(_),oe=>b(_,oe)),Ii(K,()=>l(v),oe=>b(v,oe)),Ii(Q,()=>l(m),oe=>b(m,oe)),Y("click",ue,()=>{b(w,!l(w))}),Y("click",Ee,()=>{b(P,!l(P))}),Y("click",ks,()=>{b(H,!l(H))}),Y("click",ko,()=>{b(U,!l(U))}),Y("click",Vh,I),Y("click",ka,N),T(e,x),Ve(L)}Je(["click"]);var W1=O('<div class="sidebar-overlay svelte-13zv0lp"></div>'),H1=O("<!> <!> <!> <!>",1),z1=O('<div class="main-app svelte-13zv0lp"><!> <!> <div class="terminal-area svelte-13zv0lp"><!> <!></div></div> <!> <!> <!> <!> <!> <!> <!>',1);function U1(e,t){je(t,!0);const i=new f_({defaultOptions:{queries:{staleTime:60*1e3,gcTime:600*1e3,refetchOnWindowFocus:!0}}}),s=jd(),r=Jd(),n=Rh(),o=Th();function a(W,ne){n.activeSessionId=W;const _e=n.sessions.find(be=>be.id===W);_e&&(r.activeWorkspacePath=_e.repoPath),vc(W),vi()}eg(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),v=F(void 0),m=F(!1);kn(()=>{Yp();let W,ne;if(Pt&&window.visualViewport){const ye=window.visualViewport;let le=null;const Ie=()=>{const Ge=window.innerHeight-ye.height;b(m,Ge>50),l(v)&&(l(v).style.height=l(m)?ye.height+"px":""),window.scrollTo(0,0),le&&clearTimeout(le),le=setTimeout(()=>{var Te;return(Te=l(c))==null?void 0:Te.fitTerm()},100)};ye.addEventListener("resize",Ie),ye.addEventListener("scroll",Ie),W=()=>{ye.removeEventListener("resize",Ie),ye.removeEventListener("scroll",Ie),le&&clearTimeout(le)}}const _e=navigator.platform.toUpperCase().includes("MAC");let be;{const ye=le=>{var Te;const Ie=(Te=document.activeElement)==null?void 0:Te.tagName;if(!(Ie==="INPUT"||Ie==="TEXTAREA"||!(_e?le.metaKey:le.ctrlKey))){if(le.key==="t"&&!le.shiftKey){le.preventDefault(),N();return}if(le.key==="w"&&!le.shiftKey){le.preventDefault(),n.activeSessionId&&E(n.activeSessionId);return}if(!le.shiftKey&&le.key>="1"&&le.key<="9"){const pe=l(k);if(pe.length===0)return;le.preventDefault();const K=parseInt(le.key,10),te=K===9?pe[pe.length-1]:pe[K-1];te&&G(te.id);return}if(le.shiftKey&&le.key==="["){const pe=l(k);if(pe.length===0)return;le.preventDefault();const K=pe.findIndex(Q=>Q.id===n.activeSessionId),te=K<=0?pe[pe.length-1]:pe[K-1];te&&G(te.id);return}if(le.shiftKey&&le.key==="]"){const pe=l(k);if(pe.length===0)return;le.preventDefault();const K=pe.findIndex(Q=>Q.id===n.activeSessionId),te=K===-1||K===pe.length-1?pe[0]:pe[K+1];te&&G(te.id);return}}};document.addEventListener("keydown",ye),be=()=>document.removeEventListener("keydown",ye)}if(Pt){let Ie=0,Ge=0,Te=!1;const pe=Q=>{const B=Q.touches[0];B&&B.clientX<=30&&!r.sidebarOpen&&(Ie=B.clientX,Ge=B.clientY,Te=!0)},K=Q=>{if(!Te)return;const B=Q.touches[0];if(!B)return;const J=B.clientX-Ie,ue=Math.abs(B.clientY-Ge);if(ue>J&&(ue>8||J>8)){Te=!1;return}J>=50&&(Te=!1,fc())},te=()=>{Te=!1};document.addEventListener("touchstart",pe,{passive:!0}),document.addEventListener("touchmove",K,{passive:!0}),document.addEventListener("touchend",te),ne=()=>{document.removeEventListener("touchstart",pe),document.removeEventListener("touchmove",K),document.removeEventListener("touchend",te)}}return()=>{be==null||be(),W==null||W(),ne==null||ne()}}),Ci(()=>{s.authenticated&&Nt().then(()=>{const ne=new URLSearchParams(window.location.search).get("session");ne&&(window.history.replaceState({},"","/"),a(ne)),!n.activeSessionId&&!ne&&n.sessions.length===1&&G(n.sessions[0].id);for(const _e of n.sessions)Po(_e.id,o.defaultNotifications);sg().then(()=>{rg(lg())})})}),Ci(()=>{s.authenticated&&of(W=>{W.type==="worktrees-changed"?Nt():W.type==="session-idle-changed"&&W.sessionId?ag(W.sessionId,W.idle??!1):W.type==="session-ended"&&(i.invalidateQueries({queryKey:["pr"]}),i.invalidateQueries({queryKey:["ci-status"]}))})});let g=ce(()=>r.activeWorkspacePath?n.workspaces.find(W=>W.path===r.activeWorkspacePath):void 0),y=ce(()=>r.activeWorkspacePath?nf(r.activeWorkspacePath):[]),C=ce(()=>n.activeSessionId?n.sessions.find(W=>W.id===n.activeSessionId):void 0),k=ce(()=>l(C)?l(y).filter(W=>W.repoPath===l(C).repoPath):l(y)),w=ce(()=>!!l(C)&&!!r.activeWorkspacePath&&(l(C).repoPath===r.activeWorkspacePath||l(C).repoPath.startsWith(r.activeWorkspacePath+"/"))),P=ce(()=>{var W,ne;return((W=l(C))==null?void 0:W.displayName)||((ne=l(g))==null?void 0:ne.name)||"Claude Remote CLI"}),H=ce(()=>{var W;return((W=l(C))==null?void 0:W.useTmux)??!1}),U=ce(()=>{var W;return((W=l(C))==null?void 0:W.mode)??"pty"}),j=F(!1),Z=ce(()=>l(g)?l(w)?"session":"dashboard":"empty");function G(W){var _e;n.activeSessionId=W;const ne=n.sessions.find(be=>be.id===W);if(ne){const be=n.workspaces.find(ye=>ne.repoPath===ye.path||ne.repoPath.startsWith(ye.path+"/"));r.activeWorkspacePath=(be==null?void 0:be.path)??ne.repoPath}vc(W),vi(),(_e=l(c))==null||_e.focusTerm()}function N(W,ne){var _e,be,ye;W?(_e=l(d))==null||_e.open({name:W.name,path:W.path},ne):l(g)?(be=l(d))==null||be.open({name:l(g).name,path:l(g).path},ne):(ye=l(d))==null||ye.open(void 0,ne)}function I(W){var ne,_e;W?(ne=l(_))==null||ne.open(W.path,W.name):(_e=l(u))==null||_e.open()}async function A(W){var ne,_e;try{let be=o.defaultYolo,ye=o.defaultAgent,le=o.launchInTmux;try{const pe=await ll(W.path);pe.defaultYolo!==void 0&&(be=pe.defaultYolo),pe.defaultAgent&&(ye=pe.defaultAgent),pe.launchInTmux!==void 0&&(le=pe.launchInTmux)}catch{}const{branchName:Ie,worktreePath:Ge}=await cc(W.path),Te=await Kr({repoPath:W.path,repoName:W.name,worktreePath:Ge,branchName:Ie,yolo:be,agent:ye,useTmux:le,needsBranchRename:!0});await Nt(),n.activeSessionId=Te.id,r.activeWorkspacePath=W.path,Po(Te.id,o.defaultNotifications),vi(),(ne=l(c))==null||ne.focusTerm()}catch{(_e=l(d))==null||_e.open({name:W.name,path:W.path})}}async function L(W){if(!l(g))return;const ne=l(g).path,_e=n.sessions.find(le=>le.branchName===W.headRefName&&le.repoPath.startsWith(ne)),be=n.worktrees.find(le=>le.branchName===W.headRefName&&le.repoPath===ne);let ye=`Merge the branch "${W.baseRefName}" into this branch and resolve all merge conflicts. Use \`git merge ${W.baseRefName}\` and fix any conflicts in the working tree. After resolving, verify the build passes.`;try{const le=await ll(ne);le.promptFixConflicts&&(ye=le.promptFixConflicts.replace(/\{baseRefName\}/g,W.baseRefName).replace(/\{headRefName\}/g,W.headRefName))}catch{}try{let le,Ie;if(_e)le=_e.repoPath,Ie=_e.branchName;else if(be)le=be.path,Ie=be.branchName;else{const Te=await cc(ne,W.headRefName);le=Te.worktreePath,Ie=Te.branchName}const Ge=await Kr({repoPath:ne,repoName:l(g).name,worktreePath:le,branchName:Ie,allowMultiple:!0});await Nt(),n.activeSessionId=Ge.id,r.activeWorkspacePath=ne,Po(Ge.id,o.defaultNotifications),vi(),setTimeout(()=>{Er(ye+"\r")},1500)}catch(le){console.error("Failed to start conflict resolution:",le)}}function x(W){var ne;(ne=l(f))==null||ne.open(W)}function M(W){var ne;n.activeSessionId=W,Po(W,o.defaultNotifications),vi(),(ne=l(c))==null||ne.focusTerm()}function E(W){var ne;if(fetch(`/sessions/${W}`,{method:"DELETE"}).then(()=>Nt()),n.activeSessionId===W){const _e=l(k).filter(be=>be.id!==W);n.activeSessionId=((ne=_e[0])==null?void 0:ne.id)??null}}function R(W,ne,_e){var be,ye;(be=l(h))==null||be.show(W,ne,_e),ne||(ye=l(h))==null||ye.autoDismiss(3e3)}function z(W){Er(W)}function X(){}function de(){}function Se(){const W=document.createElement("input");W.type="file",W.accept="image/*",W.onchange=()=>{var _e,be;const ne=(_e=W.files)==null?void 0:_e[0];ne&&((be=l(c))==null||be.handleImageUpload(ne,ne.type))},W.click()}function he(){var W;(W=l(c))==null||W.focusTerm()}function me(W){b(j,W,!0)}function we(){var W;(W=l(c))==null||W.exitCopyMode()}let xe=F(void 0);function fe(){var W;(W=l(xe))==null||W.open()}async function ge(W){await Nt(),W.length>0&&(r.activeWorkspacePath=W[0])}async function De(){const W=n.activeSessionId;if(!W)return;const ne=n.sessions.find(_e=>_e.id===W);if(ne){if(await Lp(W),ne.type==="worktree"){const _e=n.workspaces.find(be=>ne.repoPath===be.path||ne.repoPath.startsWith(be.path+"/"));if(_e&&ne.repoPath!==_e.path)try{await Ud(ne.repoPath,_e.path)}catch{}}n.activeSessionId=null,await Nt()}}var Be=Wi(),We=ht(Be);{var He=W=>{},ke=W=>{pg(W,{})},mt=W=>{Ww(W,{get client(){return i},children:(ne,_e)=>{var be=z1(),ye=ht(be),le=S(ye);{var Ie=Ee=>{var jt=W1();Y("click",jt,function(...Vt){vi==null||vi.apply(this,Vt)}),T(Ee,jt)};ee(le,Ee=>{r.sidebarOpen&&Ee(Ie)})}var Ge=D(le,2);Ng(Ge,{onSelectSession:G,onOpenSettings:I,onNewWorktree:A,onNewSession:Ee=>N(Ee),onNewTerminal:Ee=>N(Ee,{agent:"claude"}),onAddWorkspace:fe,onDeleteSession:E,onDeleteWorktree:x});var Te=D(Ge,2),pe=S(Te);U0(pe,{get title(){return l(P)},get onMenuClick(){return fc},get hidden(){return l(m)}});var K=D(pe,2);{var te=Ee=>{I0(Ee,{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:fe})},Q=Ee=>{{let jt=ce(()=>r.activeWorkspacePath??""),Vt=ce(()=>{var Ki;return((Ki=l(g))==null?void 0:Ki.name)??""});M0(Ee,{get workspacePath(){return l(jt)},get workspaceName(){return l(Vt)},onNewSession:()=>N(),onNewWorktree:()=>{l(g)&&A(l(g))},onFixConflicts:L})}},B=Ee=>{var jt=H1(),Vt=ht(jt);{let bt=ce(()=>r.activeWorkspacePath??""),Yt=ce(()=>{var qi;return((qi=l(C))==null?void 0:qi.branchName)??""});o0(Vt,{get workspacePath(){return l(bt)},get branchName(){return l(Yt)},get sessionId(){return n.activeSessionId},onArchive:De})}var Ki=D(Vt,2);c0(Ki,{get sessions(){return l(k)},get activeSessionId(){return n.activeSessionId},onSelectSession:G,onCloseSession:E,onNewSession:()=>N(),onNewTerminal:()=>N(void 0,{agent:"claude"})});var $s=D(Ki,2);{var Nr=bt=>{Qe(iw(bt,{get sessionId(){return n.activeSessionId},mode:"sdk",onImageUpload:R,get useTmux(){return l(H)},onCopyModeChange:me}),Yt=>b(c,Yt,!0),()=>l(c))},ks=bt=>{Qe(t_(bt,{get sessionId(){return n.activeSessionId},onImageUpload:R,get useTmux(){return l(H)},onCopyModeChange:me}),Yt=>b(c,Yt,!0),()=>l(c))};ee($s,bt=>{l(U)==="sdk"?bt(Nr):bt(ks,!1)})}var Dn=D($s,2);H0(Dn,{onSendKey:z,onFlushComposedText:X,onClearInput:de,onUploadImage:Se,onRefocusMobileInput:he,get useTmux(){return l(H)},get inCopyMode(){return l(j)},onExitCopyMode:we}),T(Ee,jt)};ee(K,Ee=>{l(Z)==="empty"?Ee(te):l(Z)==="dashboard"?Ee(Q,1):l(Z)==="session"&&Ee(B,2)})}Qe(ye,Ee=>b(v,Ee),()=>l(v));var J=D(ye,2);Qe(i1(J,{onSessionCreated:M}),Ee=>b(d,Ee,!0),()=>l(d));var ue=D(J,2);Qe(h1(ue,{}),Ee=>b(u,Ee,!0),()=>l(u));var Le=D(ue,2);Qe(f1(Le,{}),Ee=>b(f,Ee,!0),()=>l(f));var Ue=D(Le,2);Qe(R1(Ue,{onWorkspacesAdded:ge}),Ee=>b(xe,Ee,!0),()=>l(xe));var Me=D(Ue,2);Qe(F1(Me,{onRemoveWorkspace:async Ee=>{await fetch("/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Ee})}),await Nt(),r.activeWorkspacePath===Ee&&(r.activeWorkspacePath=null)}}),Ee=>b(_,Ee,!0),()=>l(_));var $e=D(Me,2);j0($e,{});var Ui=D($e,2);Qe(G0(Ui,{}),Ee=>b(h,Ee,!0),()=>l(h)),T(ne,be)},$$slots:{default:!0}})};ee(We,W=>{s.checking?W(He):s.authenticated?W(mt,!1):W(ke,1)})}T(e,Be),Ve()}Je(["click"]);tp(U1,{target:document.getElementById("app")});